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 QWindow;
67class QIcon;
68class QRegion;
69
70class Q_GUI_EXPORT QPlatformWindow : public QPlatformSurface
71{
72 Q_DECLARE_PRIVATE(QPlatformWindow)
73public:
74 Q_DISABLE_COPY_MOVE(QPlatformWindow)
75
76 explicit QPlatformWindow(QWindow *window);
77 ~QPlatformWindow() override;
78
79 virtual void initialize();
80
81 QWindow *window() const;
82 QPlatformWindow *parent() const;
83
84 QPlatformScreen *screen() const override;
85
86 virtual QSurfaceFormat format() const override;
87
88 virtual void setGeometry(const QRect &rect);
89 virtual QRect geometry() const;
90 virtual QRect normalGeometry() const;
91
92 virtual QMargins frameMargins() const;
93 virtual QMargins safeAreaMargins() const;
94
95 virtual void setVisible(bool visible);
96 virtual void setWindowFlags(Qt::WindowFlags flags);
97 virtual void setWindowState(Qt::WindowStates state);
98
99 virtual WId winId() const;
100 virtual void setParent(const QPlatformWindow *window);
101
102 virtual void setWindowTitle(const QString &title);
103 virtual void setWindowFilePath(const QString &title);
104 virtual void setWindowIcon(const QIcon &icon);
105 virtual bool close();
106 virtual void raise();
107 virtual void lower();
108
109 virtual bool isExposed() const;
110 virtual bool isActive() const;
111 virtual bool isAncestorOf(const QPlatformWindow *child) const;
112 virtual bool isEmbedded() const;
113 virtual bool isForeignWindow() const { return false; };
114 virtual QPoint mapToGlobal(const QPoint &pos) const;
115 virtual QPoint mapFromGlobal(const QPoint &pos) const;
116
117 virtual void propagateSizeHints();
118
119 virtual void setOpacity(qreal level);
120 virtual void setMask(const QRegion &region);
121 virtual void requestActivateWindow();
122
123 virtual void handleContentOrientationChange(Qt::ScreenOrientation orientation);
124
125 virtual qreal devicePixelRatio() const;
126
127 virtual bool setKeyboardGrabEnabled(bool grab);
128 virtual bool setMouseGrabEnabled(bool grab);
129
130 virtual bool setWindowModified(bool modified);
131
132 virtual bool windowEvent(QEvent *event);
133
134 virtual bool startSystemResize(const QPoint &pos, Qt::Corner corner);
135 virtual bool startSystemMove(const QPoint &pos);
136
137 virtual void setFrameStrutEventsEnabled(bool enabled);
138 virtual bool frameStrutEventsEnabled() const;
139
140 virtual void setAlertState(bool enabled);
141 virtual bool isAlertState() const;
142
143 virtual void invalidateSurface();
144
145 static QRect initialGeometry(const QWindow *w,
146 const QRect &initialGeometry, int defaultWidth, int defaultHeight);
147
148 virtual void requestUpdate();
149 bool hasPendingUpdateRequest() const;
150 virtual void deliverUpdateRequest();
151
152 // Window property accessors. Platform plugins should use these
153 // instead of accessing QWindow directly.
154 QSize windowMinimumSize() const;
155 QSize windowMaximumSize() const;
156 QSize windowBaseSize() const;
157 QSize windowSizeIncrement() const;
158 QRect windowGeometry() const;
159 QRect windowFrameGeometry() const;
160 QRectF windowClosestAcceptableGeometry(const QRectF &nativeRect) const;
161 static QRectF closestAcceptableGeometry(const QWindow *w, const QRectF &nativeRect);
162
163protected:
164 static QString formatWindowTitle(const QString &title, const QString &separator);
165 QPlatformScreen *screenForGeometry(const QRect &newGeometry) const;
166 static QSize constrainWindowSize(const QSize &size);
167
168 QScopedPointer<QPlatformWindowPrivate> d_ptr;
169};
170
171QT_END_NAMESPACE
172
173#endif //QPLATFORMWINDOW_H
174