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

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