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
29QT_BEGIN_NAMESPACE
30
31class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate
32{
33 Q_DECLARE_PUBLIC(QWindow)
34
35public:
36 enum PositionPolicy
37 {
38 WindowFrameInclusive,
39 WindowFrameExclusive
40 };
41
42 QWindowPrivate();
43 ~QWindowPrivate() override;
44
45 void init(QScreen *targetScreen = nullptr);
46
47#ifndef QT_NO_CURSOR
48 void setCursor(const QCursor *c = nullptr);
49 bool applyCursor();
50#endif
51
52 QPoint globalPosition() const;
53
54 QWindow *topLevelWindow(QWindow::AncestorMode mode = QWindow::IncludeTransients) const;
55
56 virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
57 virtual QPalette windowPalette() const { return QPalette(); }
58
59 virtual void setVisible(bool visible);
60 void updateVisibility();
61 void _q_clearAlert();
62
63 enum SiblingPosition { PositionTop, PositionBottom };
64 void updateSiblingPosition(SiblingPosition);
65
66 bool windowRecreationRequired(QScreen *newScreen) const;
67 void create(bool recursive, WId nativeHandle = 0);
68 void destroy();
69 void setTopLevelScreen(QScreen *newScreen, bool recreate);
70 void connectToScreen(QScreen *topLevelScreen);
71 void disconnectFromScreen();
72 void emitScreenChangedRecursion(QScreen *newScreen);
73 QScreen *screenForGeometry(const QRect &rect) const;
74 void setTransientParent(QWindow *parent);
75
76 virtual void clearFocusObject();
77 virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
78
79 void setMinOrMaxSize(QSize *oldSizeMember, const QSize &size,
80 qxp::function_ref<void()> funcWidthChanged,
81 qxp::function_ref<void()> funcHeightChanged);
82
83 virtual void processSafeAreaMarginsChanged() {}
84
85 virtual bool participatesInLastWindowClosed() const;
86 virtual bool treatAsVisible() const;
87
88 bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; }
89 void setAutomaticPositionAndResizeEnabled(bool a)
90 { positionAutomatic = resizeAutomatic = a; }
91
92 void updateDevicePixelRatio();
93
94 static QWindowPrivate *get(QWindow *window) { return window->d_func(); }
95
96 static Qt::WindowState effectiveState(Qt::WindowStates);
97
98 QWindow::SurfaceType surfaceType = QWindow::RasterSurface;
99 Qt::WindowFlags windowFlags = Qt::Window;
100 QWindow *parentWindow = nullptr;
101 QPlatformWindow *platformWindow = nullptr;
102 bool visible= false;
103 bool visibilityOnDestroy = false;
104 bool exposed = false;
105 bool inClose = false;
106 QSurfaceFormat requestedFormat;
107 QString windowTitle;
108 QString windowFilePath;
109 QIcon windowIcon;
110 QRect geometry;
111 qreal devicePixelRatio = 1.0;
112 Qt::WindowStates windowState = Qt::WindowNoState;
113 QWindow::Visibility visibility = QWindow::Hidden;
114 bool resizeEventPending = true;
115 bool receivedExpose = false;
116 PositionPolicy positionPolicy = WindowFrameExclusive;
117 bool positionAutomatic = true;
118 // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry().
119 // It also indicates that width/height=0 is acceptable (for example, for
120 // the QRollEffect widget) and is thus not cleared in setGeometry().
121 // An alternative approach might be using -1,-1 as a default size.
122 bool resizeAutomatic = true;
123 Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation;
124 qreal opacity= 1;
125 QRegion mask;
126
127 QSize minimumSize = {0, 0};
128 QSize maximumSize = {QWINDOWSIZE_MAX, QWINDOWSIZE_MAX};
129 QSize baseSize;
130 QSize sizeIncrement;
131
132 Qt::WindowModality modality = Qt::NonModal;
133 bool blockedByModalWindow = false;
134
135 bool updateRequestPending = false;
136 bool transientParentPropertySet = false;
137
138 QPointer<QWindow> transientParent;
139 QPointer<QScreen> topLevelScreen;
140
141#ifndef QT_NO_CURSOR
142 QCursor cursor = {Qt::ArrowCursor};
143 bool hasCursor = false;
144#endif
145
146 bool compositing = false;
147 QElapsedTimer lastComposeTime;
148
149#if QT_CONFIG(vulkan)
150 QVulkanInstance *vulkanInstance = nullptr;
151#endif
152};
153
154
155QT_END_NAMESPACE
156
157#endif // QWINDOW_P_H
158

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