1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QWINDOW_P_H
41#define QWINDOW_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtGui/private/qtguiglobal_p.h>
55#include <QtGui/qscreen.h>
56#include <QtGui/qwindow.h>
57#include <qpa/qplatformwindow.h>
58
59#include <QtCore/private/qobject_p.h>
60#include <QtCore/qelapsedtimer.h>
61#include <QtGui/QIcon>
62
63QT_BEGIN_NAMESPACE
64
65#define QWINDOWSIZE_MAX ((1<<24)-1)
66
67class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate
68{
69 Q_DECLARE_PUBLIC(QWindow)
70
71public:
72 enum PositionPolicy
73 {
74 WindowFrameInclusive,
75 WindowFrameExclusive
76 };
77
78 QWindowPrivate()
79 : QObjectPrivate()
80 , surfaceType(QWindow::RasterSurface)
81 , windowFlags(Qt::Window)
82 , parentWindow(nullptr)
83 , platformWindow(nullptr)
84 , visible(false)
85 , visibilityOnDestroy(false)
86 , exposed(false)
87 , windowState(Qt::WindowNoState)
88 , visibility(QWindow::Hidden)
89 , resizeEventPending(true)
90 , receivedExpose(false)
91 , positionPolicy(WindowFrameExclusive)
92 , positionAutomatic(true)
93 , contentOrientation(Qt::PrimaryOrientation)
94 , opacity(qreal(1.0))
95 , minimumSize(0, 0)
96 , maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
97 , modality(Qt::NonModal)
98 , blockedByModalWindow(false)
99 , updateRequestPending(false)
100 , transientParent(nullptr)
101 , topLevelScreen(nullptr)
102#ifndef QT_NO_CURSOR
103 , cursor(Qt::ArrowCursor)
104 , hasCursor(false)
105#endif
106 , compositing(false)
107#if QT_CONFIG(vulkan)
108 , vulkanInstance(nullptr)
109#endif
110 {
111 isWindow = true;
112 }
113
114 ~QWindowPrivate()
115 {
116 }
117
118 void init(QScreen *targetScreen = nullptr);
119
120 void maybeQuitOnLastWindowClosed();
121#ifndef QT_NO_CURSOR
122 void setCursor(const QCursor *c = nullptr);
123 bool applyCursor();
124#endif
125
126 QPoint globalPosition() const;
127
128 QWindow *topLevelWindow(QWindow::AncestorMode mode = QWindow::IncludeTransients) const;
129
130#if QT_CONFIG(opengl)
131 virtual QOpenGLContext *shareContext() const;
132#endif
133
134 virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
135
136 virtual void setVisible(bool visible);
137 void updateVisibility();
138 void _q_clearAlert();
139
140 enum SiblingPosition { PositionTop, PositionBottom };
141 void updateSiblingPosition(SiblingPosition);
142
143 bool windowRecreationRequired(QScreen *newScreen) const;
144 void create(bool recursive, WId nativeHandle = 0);
145 void destroy();
146 void setTopLevelScreen(QScreen *newScreen, bool recreate);
147 void connectToScreen(QScreen *topLevelScreen);
148 void disconnectFromScreen();
149 void emitScreenChangedRecursion(QScreen *newScreen);
150 QScreen *screenForGeometry(const QRect &rect);
151 void setTransientParent(QWindow *parent);
152
153 virtual void clearFocusObject();
154 virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
155
156 virtual void processSafeAreaMarginsChanged() {};
157
158 bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; }
159
160 static QWindowPrivate *get(QWindow *window) { return window->d_func(); }
161
162 static Qt::WindowState effectiveState(Qt::WindowStates);
163
164 QWindow::SurfaceType surfaceType;
165 Qt::WindowFlags windowFlags;
166 QWindow *parentWindow;
167 QPlatformWindow *platformWindow;
168 bool visible;
169 bool visibilityOnDestroy;
170 bool exposed;
171 QSurfaceFormat requestedFormat;
172 QString windowTitle;
173 QString windowFilePath;
174 QIcon windowIcon;
175 QRect geometry;
176 Qt::WindowStates windowState;
177 QWindow::Visibility visibility;
178 bool resizeEventPending;
179 bool receivedExpose;
180 PositionPolicy positionPolicy;
181 bool positionAutomatic;
182 Qt::ScreenOrientation contentOrientation;
183 qreal opacity;
184 QRegion mask;
185
186 QSize minimumSize;
187 QSize maximumSize;
188 QSize baseSize;
189 QSize sizeIncrement;
190
191 Qt::WindowModality modality;
192 bool blockedByModalWindow;
193
194 bool updateRequestPending;
195 bool transientParentPropertySet = false;
196
197 QPointer<QWindow> transientParent;
198 QPointer<QScreen> topLevelScreen;
199
200#ifndef QT_NO_CURSOR
201 QCursor cursor;
202 bool hasCursor;
203#endif
204
205 bool compositing;
206 QElapsedTimer lastComposeTime;
207
208#if QT_CONFIG(vulkan)
209 QVulkanInstance *vulkanInstance;
210#endif
211};
212
213
214QT_END_NAMESPACE
215
216#endif // QWINDOW_P_H
217