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 | #ifndef QWINDOW_P_H |
5 | #define QWINDOW_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtGui/private/qtguiglobal_p.h> |
19 | #include <QtGui/qscreen.h> |
20 | #include <QtGui/qwindow.h> |
21 | #include <qpa/qplatformwindow.h> |
22 | |
23 | #include <QtCore/private/qobject_p.h> |
24 | #include <QtCore/qelapsedtimer.h> |
25 | #include <QtCore/qxpfunctional.h> |
26 | #include <QtGui/qicon.h> |
27 | #include <QtGui/qpalette.h> |
28 | |
29 | #include <QtCore/qpointer.h> |
30 | |
31 | QT_BEGIN_NAMESPACE |
32 | |
33 | class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate |
34 | { |
35 | Q_DECLARE_PUBLIC(QWindow) |
36 | |
37 | public: |
38 | enum PositionPolicy |
39 | { |
40 | WindowFrameInclusive, |
41 | WindowFrameExclusive |
42 | }; |
43 | |
44 | QWindowPrivate(); |
45 | ~QWindowPrivate() override; |
46 | |
47 | void init(QWindow *parent, QScreen *targetScreen = nullptr); |
48 | |
49 | #ifndef QT_NO_CURSOR |
50 | void setCursor(const QCursor *c = nullptr); |
51 | bool applyCursor(); |
52 | #endif |
53 | |
54 | QPoint globalPosition() const; |
55 | |
56 | QWindow *topLevelWindow(QWindow::AncestorMode mode = QWindow::IncludeTransients) const; |
57 | |
58 | virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; } |
59 | virtual QPalette windowPalette() const { return QPalette(); } |
60 | |
61 | virtual void setVisible(bool visible); |
62 | void updateVisibility(); |
63 | void _q_clearAlert(); |
64 | |
65 | enum SiblingPosition { PositionTop, PositionBottom }; |
66 | void updateSiblingPosition(SiblingPosition); |
67 | |
68 | bool windowRecreationRequired(QScreen *newScreen) const; |
69 | void create(bool recursive); |
70 | void destroy(); |
71 | void setTopLevelScreen(QScreen *newScreen, bool recreate); |
72 | void connectToScreen(QScreen *topLevelScreen); |
73 | void disconnectFromScreen(); |
74 | void emitScreenChangedRecursion(QScreen *newScreen); |
75 | QScreen *screenForGeometry(const QRect &rect) const; |
76 | void setTransientParent(QWindow *parent); |
77 | |
78 | virtual void clearFocusObject(); |
79 | |
80 | enum class FocusTarget { |
81 | First, |
82 | Last, |
83 | Current, |
84 | Next, |
85 | Prev |
86 | }; |
87 | virtual void setFocusToTarget(FocusTarget, Qt::FocusReason) {} |
88 | |
89 | virtual QRectF closestAcceptableGeometry(const QRectF &rect) const; |
90 | |
91 | void setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, |
92 | qxp::function_ref<void()> funcWidthChanged, |
93 | qxp::function_ref<void()> funcHeightChanged); |
94 | |
95 | virtual void processSafeAreaMarginsChanged() {} |
96 | |
97 | virtual bool participatesInLastWindowClosed() const; |
98 | virtual bool treatAsVisible() const; |
99 | |
100 | const QWindow *(QEvent *event, const QWindow *); |
101 | |
102 | bool () const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; } |
103 | void setAutomaticPositionAndResizeEnabled(bool a) |
104 | { positionAutomatic = resizeAutomatic = a; } |
105 | |
106 | bool updateDevicePixelRatio(); |
107 | |
108 | static QWindowPrivate *get(QWindow *window) { return window->d_func(); } |
109 | |
110 | static Qt::WindowState effectiveState(Qt::WindowStates); |
111 | |
112 | QWindow::SurfaceType surfaceType = QWindow::RasterSurface; |
113 | Qt::WindowFlags windowFlags = Qt::Window; |
114 | QWindow *parentWindow = nullptr; |
115 | QPlatformWindow *platformWindow = nullptr; |
116 | bool visible= false; |
117 | bool visibilityOnDestroy = false; |
118 | bool exposed = false; |
119 | bool inClose = false; |
120 | QSurfaceFormat requestedFormat; |
121 | QString windowTitle; |
122 | QString windowFilePath; |
123 | QIcon windowIcon; |
124 | QRect geometry; |
125 | qreal devicePixelRatio = 1.0; |
126 | Qt::WindowStates windowState = Qt::WindowNoState; |
127 | QWindow::Visibility visibility = QWindow::Hidden; |
128 | bool resizeEventPending = true; |
129 | bool receivedExpose = false; |
130 | PositionPolicy positionPolicy = WindowFrameExclusive; |
131 | bool positionAutomatic = true; |
132 | // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry(). |
133 | // It also indicates that width/height=0 is acceptable (for example, for |
134 | // the QRollEffect widget) and is thus not cleared in setGeometry(). |
135 | // An alternative approach might be using -1,-1 as a default size. |
136 | bool resizeAutomatic = true; |
137 | Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation; |
138 | qreal opacity= 1; |
139 | QRegion mask; |
140 | |
141 | QSize minimumSize = {0, 0}; |
142 | QSize maximumSize = {QWINDOWSIZE_MAX, QWINDOWSIZE_MAX}; |
143 | QSize baseSize; |
144 | QSize sizeIncrement; |
145 | |
146 | Qt::WindowModality modality = Qt::NonModal; |
147 | bool blockedByModalWindow = false; |
148 | |
149 | bool updateRequestPending = false; |
150 | bool transientParentPropertySet = false; |
151 | |
152 | QPointer<QWindow> transientParent; |
153 | QPointer<QScreen> topLevelScreen; |
154 | |
155 | #ifndef QT_NO_CURSOR |
156 | QCursor cursor = {Qt::ArrowCursor}; |
157 | bool hasCursor = false; |
158 | #endif |
159 | |
160 | QElapsedTimer lastComposeTime; |
161 | |
162 | #if QT_CONFIG(vulkan) |
163 | QVulkanInstance *vulkanInstance = nullptr; |
164 | #endif |
165 | }; |
166 | |
167 | |
168 | QT_END_NAMESPACE |
169 | |
170 | #endif // QWINDOW_P_H |
171 | |