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 {
81 isWindow = true;
82 }
83
84 void init(QScreen *targetScreen = nullptr);
85
86 void maybeQuitOnLastWindowClosed();
87#ifndef QT_NO_CURSOR
88 void setCursor(const QCursor *c = nullptr);
89 bool applyCursor();
90#endif
91
92 QPoint globalPosition() const;
93
94 QWindow *topLevelWindow(QWindow::AncestorMode mode = QWindow::IncludeTransients) const;
95
96#if QT_CONFIG(opengl)
97 virtual QOpenGLContext *shareContext() const;
98#endif
99
100 virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
101
102 virtual void setVisible(bool visible);
103 void updateVisibility();
104 void _q_clearAlert();
105
106 enum SiblingPosition { PositionTop, PositionBottom };
107 void updateSiblingPosition(SiblingPosition);
108
109 bool windowRecreationRequired(QScreen *newScreen) const;
110 void create(bool recursive, WId nativeHandle = 0);
111 void destroy();
112 void setTopLevelScreen(QScreen *newScreen, bool recreate);
113 void connectToScreen(QScreen *topLevelScreen);
114 void disconnectFromScreen();
115 void emitScreenChangedRecursion(QScreen *newScreen);
116 QScreen *screenForGeometry(const QRect &rect) const;
117 void setTransientParent(QWindow *parent);
118
119 virtual void clearFocusObject();
120 virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
121
122 virtual void processSafeAreaMarginsChanged() {};
123
124 bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; }
125 void setAutomaticPositionAndResizeEnabled(bool a)
126 { positionAutomatic = resizeAutomatic = a; }
127
128 static QWindowPrivate *get(QWindow *window) { return window->d_func(); }
129
130 static Qt::WindowState effectiveState(Qt::WindowStates);
131
132 // ### Qt6: unused
133 virtual bool allowClickThrough(const QPoint &) const { return true; }
134
135 QWindow::SurfaceType surfaceType = QWindow::RasterSurface;
136 Qt::WindowFlags windowFlags = Qt::Window;
137 QWindow *parentWindow = nullptr;
138 QPlatformWindow *platformWindow = nullptr;
139 bool visible= false;
140 bool visibilityOnDestroy = false;
141 bool exposed = false;
142 QSurfaceFormat requestedFormat;
143 QString windowTitle;
144 QString windowFilePath;
145 QIcon windowIcon;
146 QRect geometry;
147 Qt::WindowStates windowState = Qt::WindowNoState;
148 QWindow::Visibility visibility = QWindow::Hidden;
149 bool resizeEventPending = true;
150 bool receivedExpose = false;
151 PositionPolicy positionPolicy = WindowFrameExclusive;
152 bool positionAutomatic = true;
153 // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry().
154 // It also indicates that width/height=0 is acceptable (for example, for
155 // the QRollEffect widget) and is thus not cleared in setGeometry().
156 // An alternative approach might be using -1,-1 as a default size.
157 bool resizeAutomatic = true;
158 Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation;
159 qreal opacity= 1;
160 QRegion mask;
161
162 QSize minimumSize = {0, 0};
163 QSize maximumSize = {QWINDOWSIZE_MAX, QWINDOWSIZE_MAX};
164 QSize baseSize;
165 QSize sizeIncrement;
166
167 Qt::WindowModality modality = Qt::NonModal;
168 bool blockedByModalWindow = false;
169
170 bool updateRequestPending = false;
171 bool transientParentPropertySet = false;
172
173 QPointer<QWindow> transientParent;
174 QPointer<QScreen> topLevelScreen;
175
176#ifndef QT_NO_CURSOR
177 QCursor cursor = {Qt::ArrowCursor};
178 bool hasCursor = false;
179#endif
180
181 bool compositing = false;
182 QElapsedTimer lastComposeTime;
183
184#if QT_CONFIG(vulkan)
185 QVulkanInstance *vulkanInstance = nullptr;
186#endif
187};
188
189
190QT_END_NAMESPACE
191
192#endif // QWINDOW_P_H
193

source code of qtbase/src/gui/kernel/qwindow_p.h