Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qfbwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qfbwindow_p.h"
5#include "qfbscreen_p.h"
6
7#include <QtGui/QScreen>
8#include <qpa/qwindowsysteminterface.h>
9
10QT_BEGIN_NAMESPACE
11
12Q_CONSTINIT static QBasicAtomicInt winIdGenerator = Q_BASIC_ATOMIC_INITIALIZER(0);
13
14QFbWindow::QFbWindow(QWindow *window)
15 : QPlatformWindow(window), mBackingStore(0), mWindowState(Qt::WindowNoState)
16{
17 mWindowId = winIdGenerator.fetchAndAddRelaxed(1) + 1;
18}
19
21{
22}
23
25{
26 return static_cast<QFbScreen *>(window()->screen()->handle());
27}
28
29void QFbWindow::setGeometry(const QRect &rect)
30{
31 // store previous geometry for screen update
32 mOldGeometry = geometry();
33
34 QWindowSystemInterface::handleGeometryChange(window(), rect);
35
36 QPlatformWindow::setGeometry(rect);
37
38 if (mOldGeometry != rect)
39 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size()));
40}
41
42void QFbWindow::setVisible(bool visible)
43{
44 QRect newGeom;
45 QFbScreen *fbScreen = platformScreen();
46 if (visible) {
47 bool convOk = false;
48 static bool envDisableForceFullScreen = qEnvironmentVariableIntValue("QT_QPA_FB_FORCE_FULLSCREEN", &convOk) == 0 && convOk;
49 const bool platformDisableForceFullScreen = fbScreen->flags().testFlag(QFbScreen::DontForceFirstWindowToFullScreen);
50 const bool forceFullScreen = !envDisableForceFullScreen && !platformDisableForceFullScreen && fbScreen->windowCount() == 0;
51 if (forceFullScreen || (mWindowState & Qt::WindowFullScreen))
52 newGeom = platformScreen()->geometry();
53 else if (mWindowState & Qt::WindowMaximized)
54 newGeom = platformScreen()->availableGeometry();
55 }
56 QPlatformWindow::setVisible(visible);
57
58 if (visible)
59 fbScreen->addWindow(this);
60 else
61 fbScreen->removeWindow(this);
62
63 if (!newGeom.isEmpty())
64 setGeometry(newGeom); // may or may not generate an expose
65
66 if (newGeom.isEmpty() || newGeom == mOldGeometry) {
67 // QWindow::isExposed() maps to QWindow::visible() by default so simply
68 // generating an expose event regardless of this being a show or hide is
69 // just what is needed here.
70 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size()));
71 }
72}
73
74void QFbWindow::setWindowState(Qt::WindowStates state)
75{
76 QPlatformWindow::setWindowState(state);
77 mWindowState = state;
78}
79
80void QFbWindow::setWindowFlags(Qt::WindowFlags flags)
81{
82 mWindowFlags = flags;
83}
84
86{
87 return mWindowFlags;
88}
89
91{
93 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size()));
94}
95
97{
99 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size()));
100}
101
102void QFbWindow::repaint(const QRegion &region)
103{
104 const QRect currentGeometry = geometry();
105 const QRect oldGeometryLocal = mOldGeometry;
106 mOldGeometry = currentGeometry;
107 // If this is a move, redraw the previous location
108 if (oldGeometryLocal != currentGeometry)
109 platformScreen()->setDirty(oldGeometryLocal);
110 auto topLeft = currentGeometry.topLeft();
111 for (auto rect : region)
112 platformScreen()->setDirty(rect.translated(topLeft));
113}
114
115QT_END_NAMESPACE
virtual int windowCount() const
virtual void lower(QFbWindow *window)
Definition qfbscreen.cpp:91
virtual void raise(QFbWindow *window)
Definition qfbscreen.cpp:79
virtual void removeWindow(QFbWindow *window)
Definition qfbscreen.cpp:70
virtual void addWindow(QFbWindow *window)
Definition qfbscreen.cpp:48
Qt::WindowFlags windowFlags() const
Definition qfbwindow.cpp:85
QFbScreen * platformScreen() const
Definition qfbwindow.cpp:24
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
Definition qfbwindow.cpp:42
virtual void repaint(const QRegion &)
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
Definition qfbwindow.cpp:29
QFbBackingStore * mBackingStore
Definition qfbwindow_p.h:58
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
Definition qfbwindow.cpp:96
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
Definition qfbwindow.cpp:90
void setWindowFlags(Qt::WindowFlags type) override
Requests setting the window flags of this surface to flags.
Definition qfbwindow.cpp:80
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
Definition qfbwindow.cpp:74