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