1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017 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 | #ifndef QPLATFORMWINDOW_H |
40 | #define QPLATFORMWINDOW_H |
41 | |
42 | // |
43 | // W A R N I N G |
44 | // ------------- |
45 | // |
46 | // This file is part of the QPA API and is not meant to be used |
47 | // in applications. Usage of this API may make your code |
48 | // source and binary incompatible with future versions of Qt. |
49 | // |
50 | |
51 | #include <QtGui/qtguiglobal.h> |
52 | #include <QtCore/qscopedpointer.h> |
53 | #include <QtCore/qrect.h> |
54 | #include <QtCore/qmargins.h> |
55 | #include <QtCore/qstring.h> |
56 | #include <QtGui/qwindowdefs.h> |
57 | #include <QtGui/qwindow.h> |
58 | #include <qpa/qplatformopenglcontext.h> |
59 | #include <qpa/qplatformsurface.h> |
60 | |
61 | QT_BEGIN_NAMESPACE |
62 | |
63 | |
64 | class QPlatformScreen; |
65 | class QPlatformWindowPrivate; |
66 | class QScreen; |
67 | class QWindow; |
68 | class QIcon; |
69 | class QRegion; |
70 | |
71 | class Q_GUI_EXPORT QPlatformWindow : public QPlatformSurface |
72 | { |
73 | Q_DECLARE_PRIVATE(QPlatformWindow) |
74 | public: |
75 | Q_DISABLE_COPY_MOVE(QPlatformWindow) |
76 | |
77 | explicit QPlatformWindow(QWindow *window); |
78 | ~QPlatformWindow() override; |
79 | |
80 | virtual void initialize(); |
81 | |
82 | QWindow *window() const; |
83 | QPlatformWindow *parent() const; |
84 | |
85 | QPlatformScreen *screen() const override; |
86 | |
87 | virtual QSurfaceFormat format() const override; |
88 | |
89 | virtual void setGeometry(const QRect &rect); |
90 | virtual QRect geometry() const; |
91 | virtual QRect normalGeometry() const; |
92 | |
93 | virtual QMargins frameMargins() const; |
94 | virtual QMargins safeAreaMargins() const; |
95 | |
96 | virtual void setVisible(bool visible); |
97 | virtual void setWindowFlags(Qt::WindowFlags flags); |
98 | virtual void setWindowState(Qt::WindowStates state); |
99 | |
100 | virtual WId winId() const; |
101 | virtual void setParent(const QPlatformWindow *window); |
102 | |
103 | virtual void setWindowTitle(const QString &title); |
104 | virtual void setWindowFilePath(const QString &title); |
105 | virtual void setWindowIcon(const QIcon &icon); |
106 | virtual bool close(); |
107 | virtual void raise(); |
108 | virtual void lower(); |
109 | |
110 | virtual bool isExposed() const; |
111 | virtual bool isActive() const; |
112 | virtual bool isAncestorOf(const QPlatformWindow *child) const; |
113 | virtual bool isEmbedded() const; |
114 | virtual bool isForeignWindow() const { return false; } |
115 | virtual QPoint mapToGlobal(const QPoint &pos) const; |
116 | QPointF mapToGlobalF(const QPointF &pos) const; |
117 | virtual QPoint mapFromGlobal(const QPoint &pos) const; |
118 | QPointF mapFromGlobalF(const QPointF &pos) const; |
119 | |
120 | virtual void propagateSizeHints(); |
121 | |
122 | virtual void setOpacity(qreal level); |
123 | virtual void setMask(const QRegion ®ion); |
124 | virtual void requestActivateWindow(); |
125 | |
126 | virtual void handleContentOrientationChange(Qt::ScreenOrientation orientation); |
127 | |
128 | virtual qreal devicePixelRatio() const; |
129 | |
130 | virtual bool setKeyboardGrabEnabled(bool grab); |
131 | virtual bool setMouseGrabEnabled(bool grab); |
132 | |
133 | virtual bool setWindowModified(bool modified); |
134 | |
135 | virtual bool windowEvent(QEvent *event); |
136 | |
137 | virtual bool startSystemResize(Qt::Edges edges); |
138 | virtual bool startSystemMove(); |
139 | |
140 | virtual void setFrameStrutEventsEnabled(bool enabled); |
141 | virtual bool frameStrutEventsEnabled() const; |
142 | |
143 | virtual void setAlertState(bool enabled); |
144 | virtual bool isAlertState() const; |
145 | |
146 | virtual void invalidateSurface(); |
147 | |
148 | static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry, |
149 | int defaultWidth, int defaultHeight, |
150 | const QScreen **resultingScreenReturn = nullptr); |
151 | |
152 | virtual void requestUpdate(); |
153 | bool hasPendingUpdateRequest() const; |
154 | virtual void deliverUpdateRequest(); |
155 | |
156 | // Window property accessors. Platform plugins should use these |
157 | // instead of accessing QWindow directly. |
158 | QSize windowMinimumSize() const; |
159 | QSize windowMaximumSize() const; |
160 | QSize windowBaseSize() const; |
161 | QSize windowSizeIncrement() const; |
162 | QRect windowGeometry() const; |
163 | QRect windowFrameGeometry() const; |
164 | QRectF windowClosestAcceptableGeometry(const QRectF &nativeRect) const; |
165 | static QRectF closestAcceptableGeometry(const QWindow *w, const QRectF &nativeRect); |
166 | |
167 | protected: |
168 | static QString formatWindowTitle(const QString &title, const QString &separator); |
169 | QPlatformScreen *screenForGeometry(const QRect &newGeometry) const; |
170 | static QSize constrainWindowSize(const QSize &size); |
171 | |
172 | QScopedPointer<QPlatformWindowPrivate> d_ptr; |
173 | }; |
174 | |
175 | QT_END_NAMESPACE |
176 | |
177 | #endif //QPLATFORMWINDOW_H |
178 | |