Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
11
13
15 : QPlatformWindow(window), mBackingStore(0), mWindowState(Qt::WindowNoState)
16{
17 mWindowId = winIdGenerator.fetchAndAddRelaxed(1) + 1;
18}
19
23
25{
26 return static_cast<QFbScreen *>(window()->screen()->handle());
27}
28
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();
54 newGeom = platformScreen()->availableGeometry();
55 }
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.
71 }
72}
73
79
80void QFbWindow::setWindowFlags(Qt::WindowFlags flags)
81{
83}
84
85Qt::WindowFlags QFbWindow::windowFlags() const
86{
87 return mWindowFlags;
88}
89
95
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
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
Definition qfbscreen_p.h:45
virtual void lower(QFbWindow *window)
Definition qfbscreen.cpp:91
@ DontForceFirstWindowToFullScreen
Definition qfbscreen_p.h:36
virtual void raise(QFbWindow *window)
Definition qfbscreen.cpp:79
virtual void setDirty(const QRect &rect)
QFbWindow(QWindow *window)
Definition qfbwindow.cpp:14
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
QRect mOldGeometry
Definition qfbwindow_p.h:59
virtual void repaint(const QRegion &)
Qt::WindowFlags mWindowFlags
Definition qfbwindow_p.h:60
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
Qt::WindowStates mWindowState
Definition qfbwindow_p.h:61
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
WId mWindowId
Definition qfbwindow_p.h:63
virtual QRect availableGeometry() const
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
The QPlatformWindow class provides an abstraction for top-level windows.
virtual void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or resized using the QWindow API.
virtual void setWindowState(Qt::WindowStates state)
Requests setting the window state of this surface to type.
virtual QRect geometry() const
Returns the current geometry of a window.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
QPlatformScreen * handle() const
Get the platform screen handle.
Definition qscreen.cpp:83
static void handleGeometryChange(QWindow *window, const QRect &newRect)
static bool handleExposeEvent(QWindow *window, const QRegion &region)
\inmodule QtGui
Definition qwindow.h:63
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ WindowFullScreen
Definition qnamespace.h:255
@ WindowMaximized
Definition qnamespace.h:254
#define Q_BASIC_ATOMIC_INITIALIZER(a)
QT_BEGIN_NAMESPACE static Q_CONSTINIT QBasicAtomicInt winIdGenerator
Definition qfbwindow.cpp:12
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLbitfield flags
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
aWidget window() -> setWindowTitle("New Window Title")
[2]