/src/qtbase/src/gui/kernel/qplatformscreen.h
Line | Count | Source |
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 QPLATFORMSCREEN_H |
6 | | #define QPLATFORMSCREEN_H |
7 | | |
8 | | // |
9 | | // W A R N I N G |
10 | | // ------------- |
11 | | // |
12 | | // This file is part of the QPA API and is not meant to be used |
13 | | // in applications. Usage of this API may make your code |
14 | | // source and binary incompatible with future versions of Qt. |
15 | | // |
16 | | |
17 | | #include <QtGui/qtguiglobal.h> |
18 | | #include <QtCore/qmetatype.h> |
19 | | #include <QtCore/qnamespace.h> |
20 | | #include <QtCore/qcoreevent.h> |
21 | | #include <QtCore/qvariant.h> |
22 | | #include <QtCore/qrect.h> |
23 | | #include <QtCore/qobject.h> |
24 | | |
25 | | #include <QtGui/qcolorspace.h> |
26 | | #include <QtGui/qcursor.h> |
27 | | #include <QtGui/qimage.h> |
28 | | #include <QtGui/qwindowdefs.h> |
29 | | #include <qpa/qplatformpixmap.h> |
30 | | |
31 | | QT_BEGIN_NAMESPACE |
32 | | |
33 | | |
34 | | class QPlatformBackingStore; |
35 | | class QPlatformScreenPrivate; |
36 | | class QPlatformWindow; |
37 | | class QPlatformCursor; |
38 | | class QScreen; |
39 | | class QSurfaceFormat; |
40 | | |
41 | | typedef std::pair<qreal, qreal> QDpi; |
42 | | |
43 | | |
44 | | class Q_GUI_EXPORT QPlatformScreen |
45 | | { |
46 | | Q_GADGET |
47 | 0 | Q_DECLARE_PRIVATE(QPlatformScreen) Unexecuted instantiation: QPlatformScreen::d_func() Unexecuted instantiation: QPlatformScreen::d_func() const |
48 | 0 |
|
49 | 0 | public: |
50 | 0 | Q_DISABLE_COPY_MOVE(QPlatformScreen) |
51 | 0 |
|
52 | 0 | enum SubpixelAntialiasingType { // copied from qfontengine_p.h since we can't include private headers |
53 | 0 | Subpixel_None, |
54 | 0 | Subpixel_RGB, |
55 | 0 | Subpixel_BGR, |
56 | 0 | Subpixel_VRGB, |
57 | 0 | Subpixel_VBGR |
58 | 0 | }; |
59 | 0 |
|
60 | 0 | enum PowerState { |
61 | 0 | PowerStateOn, |
62 | 0 | PowerStateStandby, |
63 | 0 | PowerStateSuspend, |
64 | 0 | PowerStateOff |
65 | 0 | }; |
66 | 0 |
|
67 | 0 | struct Mode { |
68 | 0 | QSize size; |
69 | 0 | qreal refreshRate; |
70 | 0 | }; |
71 | 0 |
|
72 | 0 | QPlatformScreen(); |
73 | 0 | virtual ~QPlatformScreen(); |
74 | 0 |
|
75 | 0 | virtual bool isPlaceholder() const { return false; } |
76 | | |
77 | | virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; |
78 | | |
79 | | virtual QRect geometry() const = 0; |
80 | 0 | virtual QRect availableGeometry() const {return geometry();} |
81 | | |
82 | | virtual int depth() const = 0; |
83 | | virtual QImage::Format format() const = 0; |
84 | 0 | virtual QColorSpace colorSpace() const { return QColorSpace::SRgb; } |
85 | | |
86 | | virtual QSizeF physicalSize() const; |
87 | | virtual QDpi logicalDpi() const; |
88 | | virtual QDpi logicalBaseDpi() const; |
89 | | virtual qreal devicePixelRatio() const; |
90 | | |
91 | | virtual qreal refreshRate() const; |
92 | | |
93 | | virtual Qt::ScreenOrientation nativeOrientation() const; |
94 | | virtual Qt::ScreenOrientation orientation() const; |
95 | | |
96 | | virtual QWindow *topLevelAt(const QPoint &point) const; |
97 | | QWindowList windows() const; |
98 | | |
99 | | virtual QList<QPlatformScreen *> virtualSiblings() const; |
100 | | const QPlatformScreen *screenForPosition(const QPoint &point) const; |
101 | | |
102 | | QScreen *screen() const; |
103 | | |
104 | | //jl: should this function be in QPlatformIntegration |
105 | | //jl: maybe screenForWindow is a better name? |
106 | | static QPlatformScreen *platformScreenForWindow(const QWindow *window); |
107 | | |
108 | 0 | virtual QString name() const { return QString(); } |
109 | | |
110 | | virtual QString manufacturer() const; |
111 | | virtual QString model() const; |
112 | | virtual QString serialNumber() const; |
113 | | |
114 | | virtual QPlatformCursor *cursor() const; |
115 | | virtual SubpixelAntialiasingType subpixelAntialiasingTypeHint() const; |
116 | | |
117 | | virtual PowerState powerState() const; |
118 | | virtual void setPowerState(PowerState state); |
119 | | |
120 | | virtual QList<Mode> modes() const; |
121 | | |
122 | | virtual int currentMode() const; |
123 | | virtual int preferredMode() const; |
124 | | |
125 | | static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b); |
126 | | static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target); |
127 | | static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect); |
128 | | |
129 | | static QDpi overrideDpi(const QDpi &in); |
130 | | |
131 | | protected: |
132 | | void resizeMaximizedWindows(); |
133 | | |
134 | | QScopedPointer<QPlatformScreenPrivate> d_ptr; |
135 | | |
136 | | private: |
137 | | friend class QScreen; |
138 | | }; |
139 | | |
140 | | // Qt doesn't currently support running with no platform screen |
141 | | // QPA plugins can use this class to create a fake screen |
142 | | class Q_GUI_EXPORT QPlatformPlaceholderScreen : public QPlatformScreen { |
143 | | public: |
144 | | // virtualSibling can be passed in to make the placeholder a sibling with other screens during |
145 | | // the transitioning phase when the real screen is about to be removed, or the first real screen |
146 | | // is about to be added. This is useful because Qt will currently recreate (but now show!) |
147 | | // windows when they are moved from one virtual desktop to another, so if the last monitor is |
148 | | // unplugged, then plugged in again, windows will be hidden unless the placeholder belongs to |
149 | | // the same virtual desktop as the other screens. |
150 | 0 | QPlatformPlaceholderScreen(bool virtualSibling = true) : m_virtualSibling(virtualSibling) {} |
151 | 0 | bool isPlaceholder() const override { return true; } |
152 | 0 | QRect geometry() const override { return QRect(); } |
153 | 0 | QRect availableGeometry() const override { return QRect(); } |
154 | 0 | int depth() const override { return 32; } |
155 | 0 | QImage::Format format() const override { return QImage::Format::Format_RGB32; } |
156 | | QList<QPlatformScreen *> virtualSiblings() const override; |
157 | | private: |
158 | | bool m_virtualSibling = true; |
159 | | }; |
160 | | |
161 | | QT_END_NAMESPACE |
162 | | |
163 | | #endif // QPLATFORMSCREEN_H |