Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qplatformscreen.h
Go to the documentation of this file.
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
4#ifndef QPLATFORMSCREEN_H
5#define QPLATFORMSCREEN_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is part of the QPA API and is not meant to be used
12// in applications. Usage of this API may make your code
13// source and binary incompatible with future versions of Qt.
14//
15
16#include <QtGui/qtguiglobal.h>
17#include <QtCore/qmetatype.h>
18#include <QtCore/qnamespace.h>
19#include <QtCore/qcoreevent.h>
20#include <QtCore/qvariant.h>
21#include <QtCore/qrect.h>
22#include <QtCore/qobject.h>
23
24#include <QtGui/qcolorspace.h>
25#include <QtGui/qcursor.h>
26#include <QtGui/qimage.h>
27#include <QtGui/qwindowdefs.h>
28#include <qpa/qplatformpixmap.h>
29
31
32
35class QPlatformWindow;
36class QPlatformCursor;
37class QScreen;
38class QSurfaceFormat;
39
41
42
43class Q_GUI_EXPORT QPlatformScreen
44{
45 Q_DECLARE_PRIVATE(QPlatformScreen)
46
47public:
48 Q_DISABLE_COPY_MOVE(QPlatformScreen)
49
50 enum SubpixelAntialiasingType { // copied from qfontengine_p.h since we can't include private headers
55 Subpixel_VBGR
56 };
57
62 PowerStateOff
63 };
64
65 struct Mode {
68 };
69
71 virtual ~QPlatformScreen();
72
73 virtual bool isPlaceholder() const { return false; }
74
75 virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
76
77 virtual QRect geometry() const = 0;
78 virtual QRect availableGeometry() const {return geometry();}
79
80 virtual int depth() const = 0;
81 virtual QImage::Format format() const = 0;
82 virtual QColorSpace colorSpace() const { return QColorSpace::SRgb; }
83
84 virtual QSizeF physicalSize() const;
85 virtual QDpi logicalDpi() const;
86 virtual QDpi logicalBaseDpi() const;
87 virtual qreal devicePixelRatio() const;
88
89 virtual qreal refreshRate() const;
90
91 virtual Qt::ScreenOrientation nativeOrientation() const;
92 virtual Qt::ScreenOrientation orientation() const;
93
94 virtual QWindow *topLevelAt(const QPoint &point) const;
95 QWindowList windows() const;
96
97 virtual QList<QPlatformScreen *> virtualSiblings() const;
98 const QPlatformScreen *screenForPosition(const QPoint &point) const;
99
100 QScreen *screen() const;
101
102 //jl: should this function be in QPlatformIntegration
103 //jl: maybe screenForWindow is a better name?
104 static QPlatformScreen *platformScreenForWindow(const QWindow *window);
105
106 virtual QString name() const { return QString(); }
107
108 virtual QString manufacturer() const;
109 virtual QString model() const;
110 virtual QString serialNumber() const;
111
112 virtual QPlatformCursor *cursor() const;
113 virtual SubpixelAntialiasingType subpixelAntialiasingTypeHint() const;
114
115 virtual PowerState powerState() const;
116 virtual void setPowerState(PowerState state);
117
118 virtual QList<Mode> modes() const;
119
120 virtual int currentMode() const;
121 virtual int preferredMode() const;
122
123 static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b);
124 static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target);
125 static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect);
126
127 static QDpi overrideDpi(const QDpi &in);
128
129protected:
130 void resizeMaximizedWindows();
131
133
134private:
135 friend class QScreen;
136};
137
138// Qt doesn't currently support running with no platform screen
139// QPA plugins can use this class to create a fake screen
140class Q_GUI_EXPORT QPlatformPlaceholderScreen : public QPlatformScreen {
141public:
142 // virtualSibling can be passed in to make the placeholder a sibling with other screens during
143 // the transitioning phase when the real screen is about to be removed, or the first real screen
144 // is about to be added. This is useful because Qt will currently recreate (but now show!)
145 // windows when they are moved from one virtual desktop to another, so if the last monitor is
146 // unplugged, then plugged in again, windows will be hidden unless the placeholder belongs to
147 // the same virtual desktop as the other screens.
148 QPlatformPlaceholderScreen(bool virtualSibling = true) : m_virtualSibling(virtualSibling) {}
149 bool isPlaceholder() const override { return true; }
150 QRect geometry() const override { return QRect(); }
151 QRect availableGeometry() const override { return QRect(); }
152 int depth() const override { return 32; }
154 QList<QPlatformScreen *> virtualSiblings() const override;
155private:
156 bool m_virtualSibling = true;
157};
158
160
161#endif // QPLATFORMSCREEN_H
The QColorSpace class provides a color space abstraction.
Definition qcolorspace.h:21
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_RGB32
Definition qimage.h:46
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
The QPlatformBackingStore class provides the drawing area for top-level windows.
The QPlatformCursor class provides information about pointer device events (movement,...
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
bool isPlaceholder() const override
QRect availableGeometry() const override
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
int depth() const override
Reimplement in subclass to return current depth of the screen.
QPlatformPlaceholderScreen(bool virtualSibling=true)
The QPlatformScreen class provides an abstraction for visual displays.
virtual QRect geometry() const =0
Reimplement in subclass to return the pixel geometry of the screen.
virtual bool isPlaceholder() const
virtual QImage::Format format() const =0
Reimplement in subclass to return the image format which corresponds to the screen format.
virtual int depth() const =0
Reimplement in subclass to return current depth of the screen.
virtual QString name() const
virtual QRect availableGeometry() const
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
virtual QColorSpace colorSpace() const
QScopedPointer< QPlatformScreenPrivate > d_ptr
The QPlatformWindow class provides an abstraction for top-level windows.
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
\inmodule QtCore
Definition qsize.h:207
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
\inmodule QtGui
Definition qwindow.h:63
QCursor cursor
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
ScreenOrientation
Definition qnamespace.h:270
std::pair< T1, T2 > QPair
static QFontEngine::SubpixelAntialiasingType subpixelAntialiasingTypeHint()
QPair< qreal, qreal > QDpi
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei width
GLenum target
GLint y
GLuint in
QPair< qreal, qreal > QDpi
static QT_BEGIN_NAMESPACE QWindow * topLevelAt(const QPoint &pos)
QScreen * screen
[1]
Definition main.cpp:29
double qreal
Definition qtypes.h:92
QSqlQueryModel * model
[16]
aWidget window() -> setWindowTitle("New Window Title")
[2]