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
61QT_BEGIN_NAMESPACE
62
63
64class QPlatformScreen;
65class QPlatformWindowPrivate;
66class QScreen;
67class QWindow;
68class QIcon;
69class QRegion;
70
71class Q_GUI_EXPORT QPlatformWindow : public QPlatformSurface
72{
73 Q_DECLARE_PRIVATE(QPlatformWindow)
74public:
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 virtual QPoint mapFromGlobal(const QPoint &pos) const;
117
118 virtual void propagateSizeHints();
119
120 virtual void setOpacity(qreal level);
121 virtual void setMask(const QRegion &region);
122 virtual void requestActivateWindow();
123
124 virtual void handleContentOrientationChange(Qt::ScreenOrientation orientation);
125
126 virtual qreal devicePixelRatio() const;
127
128 virtual bool setKeyboardGrabEnabled(bool grab);
129 virtual bool setMouseGrabEnabled(bool grab);
130
131 virtual bool setWindowModified(bool modified);
132
133 virtual bool windowEvent(QEvent *event);
134
135 virtual bool startSystemResize(Qt::Edges edges);
136 virtual bool startSystemMove();
137
138 virtual void setFrameStrutEventsEnabled(bool enabled);
139 virtual bool frameStrutEventsEnabled() const;
140
141 virtual void setAlertState(bool enabled);
142 virtual bool isAlertState() const;
143
144 virtual void invalidateSurface();
145
146 static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry,
147 int defaultWidth, int defaultHeight,
148 const QScreen **resultingScreenReturn = nullptr);
149
150 virtual void requestUpdate();
151 bool hasPendingUpdateRequest() const;
152 virtual void deliverUpdateRequest();
153
154 // Window property accessors. Platform plugins should use these
155 // instead of accessing QWindow directly.
156 QSize windowMinimumSize() const;
157 QSize windowMaximumSize() const;
158 QSize windowBaseSize() const;
159 QSize windowSizeIncrement() const;
160 QRect windowGeometry() const;
161 QRect windowFrameGeometry() const;
162 QRectF windowClosestAcceptableGeometry(const QRectF &nativeRect) const;
163 static QRectF closestAcceptableGeometry(const QWindow *w, const QRectF &nativeRect);
164
165protected:
166 static QString formatWindowTitle(const QString &title, const QString &separator);
167 QPlatformScreen *screenForGeometry(const QRect &newGeometry) const;
168 static QSize constrainWindowSize(const QSize &size);
169
170 QScopedPointer<QPlatformWindowPrivate> d_ptr;
171};
172
173QT_END_NAMESPACE
174
175#endif //QPLATFORMWINDOW_H
176

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