Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowsscreen.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 QWINDOWSSCREEN_H
5#define QWINDOWSSCREEN_H
6
7#include "qtwindowsglobal.h"
8
9#include <QtCore/qlist.h>
10#include <QtCore/qpair.h>
11#include <QtCore/qscopedpointer.h>
12#include <qpa/qplatformscreen.h>
13#include <qpa/qplatformscreen_p.h>
14
16
18{
19 enum Flags
20 {
23 LockScreen = 0x4 // Temporary screen existing during user change, etc.
24 };
25
28 QDpi dpi{96, 96};
30 int depth = 32;
39 HMONITOR hMonitor = nullptr;
42 std::optional<int> deviceIndex = std::nullopt;
43};
44
47{
48public:
49#ifndef QT_NO_CURSOR
51#endif
52
53 explicit QWindowsScreen(const QWindowsScreenData &data);
54
55 QRect geometry() const override { return m_data.geometry; }
56 QRect availableGeometry() const override { return m_data.availableGeometry; }
57 int depth() const override { return m_data.depth; }
58 QImage::Format format() const override { return m_data.format; }
59 QSizeF physicalSize() const override { return m_data.physicalSizeMM; }
60 QDpi logicalDpi() const override { return m_data.dpi; }
61 QDpi logicalBaseDpi() const override { return QDpi(baseDpi, baseDpi); }
62 qreal devicePixelRatio() const override { return 1.0; }
63 qreal refreshRate() const override { return m_data.refreshRateHz; }
64 QString name() const override;
65 QString manufacturer() const override { return m_data.manufacturer; }
66 QString model() const override { return m_data.model; }
67 QString serialNumber() const override { return m_data.serialNumber; }
68 Qt::ScreenOrientation orientation() const override { return m_data.orientation; }
70 QWindow *topLevelAt(const QPoint &point) const override;
71 static QWindow *windowAt(const QPoint &point, unsigned flags);
72
73 QPixmap grabWindow(WId window, int qX, int qY, int qWidth, int qHeight) const override;
75
78
79 inline void handleChanges(const QWindowsScreenData &newData);
80
81 HMONITOR handle() const override;
82
83#ifndef QT_NO_CURSOR
84 QPlatformCursor *cursor() const override { return m_cursor.data(); }
85 const CursorPtr &cursorPtr() const { return m_cursor; }
86#else
87 QPlatformCursor *cursor() const { return 0; }
88#endif // !QT_NO_CURSOR
89
90 const QWindowsScreenData &data() const { return m_data; }
91
93 static inline int baseDpi = 96;
94
95private:
96 QWindowsScreenData m_data;
97#ifndef QT_NO_CURSOR
98 const CursorPtr m_cursor;
99#endif
100};
101
103{
104 Q_DISABLE_COPY_MOVE(QWindowsScreenManager)
105public:
107
109 void initialize();
111
112 void clearScreens();
113
114 bool handleScreenChanges();
115 const WindowsScreenList &screens() const { return m_screens; }
116
117 const QWindowsScreen *screenAtDp(const QPoint &p) const;
118 const QWindowsScreen *screenForHwnd(HWND hwnd) const;
119
120 static bool isSingleScreen();
121
122private:
123 void removeScreen(int index);
124
125 HWND m_displayChangeObserver = nullptr;
126 WindowsScreenList m_screens;
127};
128
130
131#endif // QWINDOWSSCREEN_H
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
Definition qlist.h:74
Native interface to QScreen, to be retrieved from QPlatformIntegration. \inmodule QtGui.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
The QPlatformCursor class provides information about pointer device events (movement,...
The QPlatformScreen class provides an abstraction for visual displays.
QScreen * screen() const
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
T * data() const noexcept
Returns the value of the pointer referenced by this object.
\inmodule QtCore
Definition qsize.h:207
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtGui
Definition qwindow.h:63
Manages a list of QWindowsScreen.
bool handleScreenChanges()
Synchronizes the screen list, adds new screens, removes deleted ones and propagates resolution change...
QList< QWindowsScreen * > WindowsScreenList
const QWindowsScreen * screenForHwnd(HWND hwnd) const
const QWindowsScreen * screenAtDp(const QPoint &p) const
const WindowsScreenList & screens() const
Windows screen.
qreal refreshRate() const override
Reimplement this function in subclass to return the vertical refresh rate of the screen,...
QString serialNumber() const override
Reimplement this function in subclass to return the serial number of this screen.
static QWindow * windowAt(const QPoint &point, unsigned flags)
QDpi logicalDpi() const override
Reimplement this function in subclass to return the logical horizontal and vertical dots per inch met...
QList< QPlatformScreen * > virtualSiblings() const override
Determine siblings in a virtual desktop system.
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
QPixmap grabWindow(WId window, int qX, int qY, int qWidth, int qHeight) const override
This function is called when Qt needs to be able to grab the content of a window.
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
qreal devicePixelRatio() const override
Reimplement this function in subclass to return the device pixel ratio for the screen.
const CursorPtr & cursorPtr() const
QPlatformScreen::SubpixelAntialiasingType subpixelAntialiasingTypeHint() const override
Queries ClearType settings to check the pixel layout.
void handleChanges(const QWindowsScreenData &newData)
Notify QWindowSystemInterface about changes of a screen and synchronize data.
static bool setOrientationPreference(Qt::ScreenOrientation o)
static int baseDpi
static QRect virtualGeometry(const QPlatformScreen *screen)
QRect availableGeometry() const override
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
QString name() const override
QString manufacturer() const override
Reimplement this function in subclass to return the manufacturer of this screen.
QString model() const override
Reimplement this function in subclass to return the model of this screen.
QWindow * topLevelAt(const QPoint &point) const override
Find a top level window taking the flags of ChildWindowFromPointEx.
QDpi logicalBaseDpi() const override
Reimplement to return the base logical DPI for the platform.
HMONITOR handle() const override
int depth() const override
Reimplement in subclass to return current depth of the screen.
QSizeF physicalSize() const override
Reimplement this function in subclass to return the physical size of the screen, in millimeters.
const QWindowsScreenData & data() const
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
static Qt::ScreenOrientation orientationPreference()
Combined button and popup list for selecting options.
ScreenOrientation
Definition qnamespace.h:270
@ LandscapeOrientation
Definition qnamespace.h:273
QPair< qreal, qreal > QDpi
GLint GLenum GLsizei GLsizei GLsizei depth
GLuint index
[2]
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat p
[1]
double qreal
Definition qtypes.h:92
aWidget window() -> setWindowTitle("New Window Title")
[2]
Qt::ScreenOrientation orientation
QImage::Format format
std::optional< int > deviceIndex