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 QWindow::SurfaceType surfaceType = QWindow::RasterSurface;
133 Qt::WindowFlags windowFlags = Qt::Window;
134 QWindow *parentWindow = nullptr;
135 QPlatformWindow *platformWindow = nullptr;
136 bool visible= false;
137 bool visibilityOnDestroy = false;
138 bool exposed = false;
139 QSurfaceFormat requestedFormat;
140 QString windowTitle;
141 QString windowFilePath;
142 QIcon windowIcon;
143 QRect geometry;
144 Qt::WindowStates windowState = Qt::WindowNoState;
145 QWindow::Visibility visibility = QWindow::Hidden;
146 bool resizeEventPending = true;
147 bool receivedExpose = false;
148 PositionPolicy positionPolicy = WindowFrameExclusive;
149 bool positionAutomatic = true;
150 // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry().
151 // It also indicates that width/height=0 is acceptable (for example, for
152 // the QRollEffect widget) and is thus not cleared in setGeometry().
153 // An alternative approach might be using -1,-1 as a default size.
154 bool resizeAutomatic = true;
155 Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation;
156 qreal opacity= 1;
157 QRegion mask;
158
159 QSize minimumSize = {0, 0};
160 QSize maximumSize = {QWINDOWSIZE_MAX, QWINDOWSIZE_MAX};
161 QSize baseSize;
162 QSize sizeIncrement;
163
164 Qt::WindowModality modality = Qt::NonModal;
165 bool blockedByModalWindow = false;
166
167 bool updateRequestPending = false;
168 bool transientParentPropertySet = false;
169
170 QPointer<QWindow> transientParent;
171 QPointer<QScreen> topLevelScreen;
172
173#ifndef QT_NO_CURSOR
174 QCursor cursor = {Qt::ArrowCursor};
175 bool hasCursor = false;
176#endif
177
178 bool compositing = false;
179 QElapsedTimer lastComposeTime;
180
181#if QT_CONFIG(vulkan)
182 QVulkanInstance *vulkanInstance = nullptr;
183#endif
184};
185
186
187QT_END_NAMESPACE
188
189#endif // QWINDOW_P_H
190