Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qandroidplatformwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
8
9#include "androidjnimain.h"
10
11#include <qguiapplication.h>
12#include <qpa/qwindowsysteminterface.h>
13#include <private/qhighdpiscaling_p.h>
14
16
18
21{
25 setWindowState(window->windowStates());
26
27 // the following is in relation to the virtual geometry
28 const bool forceMaximize = m_windowState & (Qt::WindowMaximized | Qt::WindowFullScreen);
29 const QRect requestedNativeGeometry =
30 forceMaximize ? QRect() : QHighDpi::toNativePixels(window->geometry(), window);
31 const QRect availableDeviceIndependentGeometry = (window->parent())
32 ? window->parent()->geometry()
33 : QHighDpi::fromNativePixels(platformScreen()->availableGeometry(), window);
34
35 // initialGeometry returns in native pixels
36 const QRect finalNativeGeometry = QPlatformWindow::initialGeometry(
37 window, requestedNativeGeometry, availableDeviceIndependentGeometry.width(),
38 availableDeviceIndependentGeometry.height());
39
40 if (requestedNativeGeometry != finalNativeGeometry)
41 setGeometry(finalNativeGeometry);
42}
43
45{
46 platformScreen()->lower(this);
47}
48
50{
52 platformScreen()->raise(this);
53}
54
56{
58 QRect availableGeometry = platformScreen()->availableGeometry();
59 return QMargins(availableGeometry.left(), availableGeometry.top(),
60 availableGeometry.right(), availableGeometry.bottom());
61 } else {
63 }
64}
65
67{
70}
71
73{
74 if (visible)
76
77 if (visible) {
82 setGeometry(platformScreen()->availableGeometry());
83 }
84 }
85
86 if (visible)
88 else
90
91 QRect availableGeometry = screen()->availableGeometry();
92 if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
94}
95
97{
98 if (m_windowState == state)
99 return;
100
103
104 if (window()->isVisible())
106}
107
109{
110 if (m_windowFlags == flags)
111 return;
112
114}
115
117{
118 return m_windowFlags;
119}
120
122{
124}
125
127{
128 return static_cast<QAndroidPlatformScreen *>(window()->screen()->handle());
129}
130
132{
133 //shut up warning from default implementation
134}
135
137{
139}
140
142{
143 Qt::WindowFlags flags = window()->flags();
144 bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window;
145 if (!isNonRegularWindow) {
150 else
152 }
153}
154
156{
157 return qApp->applicationState() > Qt::ApplicationHidden
158 && window()->isVisible()
159 && !window()->geometry().isEmpty();
160}
161
163{
164 QRegion region;
165 if (isExposed())
166 region = QRect(QPoint(), geometry().size());
167
170}
171
void lower(QAndroidPlatformWindow *window)
void raise(QAndroidPlatformWindow *window)
QRect availableGeometry() const override
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
void removeWindow(QAndroidPlatformWindow *window)
void addWindow(QAndroidPlatformWindow *window)
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
virtual void applicationStateChanged(Qt::ApplicationState)
QAndroidPlatformWindow(QWindow *window)
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
bool isExposed() const override
Returns if this window is exposed in the windowing system.
QAndroidPlatformScreen * platformScreen() const
Qt::WindowFlags windowFlags() const
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QMargins safeAreaMargins() const override
The safe area margins of a window represent the area that is safe to place content within,...
T fetchAndAddRelaxed(T valueToAdd) noexcept
\inmodule QtCore
Definition qmargins.h:23
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.
QPlatformScreen * screen() const override
Returns the platform screen handle corresponding to this platform window, or null if the window is no...
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.
virtual QMargins safeAreaMargins() const
The safe area margins of a window represent the area that is safe to place content within,...
static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry, int defaultWidth, int defaultHeight, const QScreen **resultingScreenReturn=nullptr)
Helper function to get initial geometry on windowing systems which do not do smart positioning and al...
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
Definition qrect.h:166
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:238
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:181
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:175
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:172
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:235
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:178
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 bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Make Qt Gui process all events on the event queue immediately.
static void handleGeometryChange(QWindow *window, const QRect &newRect)
static bool handleExposeEvent(QWindow *window, const QRegion &region)
\inmodule QtGui
Definition qwindow.h:63
Qt::WindowFlags flags
the window flags of the window
Definition qwindow.h:79
rect
[4]
else opt state
[0]
T toNativePixels(const T &value, const C *context)
T fromNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
@ SYSTEM_UI_VISIBILITY_TRANSLUCENT
@ SYSTEM_UI_VISIBILITY_FULLSCREEN
@ SYSTEM_UI_VISIBILITY_NORMAL
void setSystemUiVisibility(SystemUiVisibility uiVisibility)
@ WindowFullScreen
Definition qnamespace.h:254
@ WindowNoState
Definition qnamespace.h:251
@ WindowMaximized
Definition qnamespace.h:253
ApplicationState
Definition qnamespace.h:261
@ ApplicationHidden
Definition qnamespace.h:263
@ Widget
Definition qnamespace.h:205
@ Popup
Definition qnamespace.h:210
@ Window
Definition qnamespace.h:206
@ Dialog
Definition qnamespace.h:207
@ Sheet
Definition qnamespace.h:208
@ MaximizeUsingFullscreenGeometryHint
Definition qnamespace.h:236
QT_BEGIN_NAMESPACE static Q_CONSTINIT QBasicAtomicInt winIdGenerator
#define Q_BASIC_ATOMIC_INITIALIZER(a)
#define qApp
QT_BEGIN_NAMESPACE static Q_CONSTINIT QBasicAtomicInt winIdGenerator
Definition qfbwindow.cpp:12
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei width
GLbitfield flags
#define Q_UNUSED(x)
edit isVisible()
aWidget window() -> setWindowTitle("New Window Title")
[2]