Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
40typedef QPair<qreal, qreal> QDpi;
41
42
43class Q_GUI_EXPORT QPlatformScreen
44{
46 Q_DECLARE_PRIVATE(QPlatformScreen)
47
48public:
49 Q_DISABLE_COPY_MOVE(QPlatformScreen)
50
51 enum SubpixelAntialiasingType { // copied from qfontengine_p.h since we can't include private headers
56 Subpixel_VBGR
57 };
58
65
70
72 virtual ~QPlatformScreen();
73
74 virtual bool isPlaceholder() const { return false; }
75
76 virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
77
78 virtual QRect geometry() const = 0;
79 virtual QRect availableGeometry() const {return geometry();}
80
81 virtual int depth() const = 0;
82 virtual QImage::Format format() const = 0;
83 virtual QColorSpace colorSpace() const { return QColorSpace::SRgb; }
84
85 virtual QSizeF physicalSize() const;
86 virtual QDpi logicalDpi() const;
87 virtual QDpi logicalBaseDpi() const;
88 virtual qreal devicePixelRatio() const;
89
90 virtual qreal refreshRate() const;
91
92 virtual Qt::ScreenOrientation nativeOrientation() const;
93 virtual Qt::ScreenOrientation orientation() const;
94
95 virtual QWindow *topLevelAt(const QPoint &point) const;
96 QWindowList windows() const;
97
98 virtual QList<QPlatformScreen *> virtualSiblings() const;
99 const QPlatformScreen *screenForPosition(const QPoint &point) const;
100
101 QScreen *screen() const;
102
103 //jl: should this function be in QPlatformIntegration
104 //jl: maybe screenForWindow is a better name?
105 static QPlatformScreen *platformScreenForWindow(const QWindow *window);
106
107 virtual QString name() const { return QString(); }
108
109 virtual QString manufacturer() const;
110 virtual QString model() const;
111 virtual QString serialNumber() const;
112
113 virtual QPlatformCursor *cursor() const;
114 virtual SubpixelAntialiasingType subpixelAntialiasingTypeHint() const;
115
116 virtual PowerState powerState() const;
117 virtual void setPowerState(PowerState state);
118
119 virtual QList<Mode> modes() const;
120
121 virtual int currentMode() const;
122 virtual int preferredMode() const;
123
124 static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b);
125 static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target);
126 static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect);
127
128 static QDpi overrideDpi(const QDpi &in);
129
130protected:
131 void resizeMaximizedWindows();
132
133 QScopedPointer<QPlatformScreenPrivate> d_ptr;
134
135private:
136 friend class QScreen;
137};
138
139// Qt doesn't currently support running with no platform screen
140// QPA plugins can use this class to create a fake screen
141class Q_GUI_EXPORT QPlatformPlaceholderScreen : public QPlatformScreen {
142public:
143 // virtualSibling can be passed in to make the placeholder a sibling with other screens during
144 // the transitioning phase when the real screen is about to be removed, or the first real screen
145 // is about to be added. This is useful because Qt will currently recreate (but now show!)
146 // windows when they are moved from one virtual desktop to another, so if the last monitor is
147 // unplugged, then plugged in again, windows will be hidden unless the placeholder belongs to
148 // the same virtual desktop as the other screens.
149 QPlatformPlaceholderScreen(bool virtualSibling = true) : m_virtualSibling(virtualSibling) {}
150 bool isPlaceholder() const override { return true; }
151 QRect geometry() const override { return QRect(); }
152 QRect availableGeometry() const override { return QRect(); }
153 int depth() const override { return 32; }
155 QList<QPlatformScreen *> virtualSiblings() const override;
156private:
157 bool m_virtualSibling = true;
158};
159
161
162#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:25
\inmodule QtCore\reentrant
Definition qrect.h:30
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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:271
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
#define Q_GADGET
double qreal
Definition qtypes.h:187
QSqlQueryModel * model
[16]
aWidget window() -> setWindowTitle("New Window Title")
[2]