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
qcocoascreen.h
Go to the documentation of this file.
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
4#ifndef QCOCOASCREEN_H
5#define QCOCOASCREEN_H
6
7#include "qcocoacursor.h"
8
9#include <qpa/qplatformintegration.h>
10#include <QtCore/private/qcore_mac_p.h>
11
12#include <CoreGraphics/CoreGraphics.h>
13#include <CoreVideo/CoreVideo.h>
14
17
19
21
23{
24public:
26
27 // ----------------------------------------------------
28 // Virtual methods overridden from QPlatformScreen
29 QPixmap grabWindow(WId window, int x, int y, int width, int height) const override;
30 QRect geometry() const override { return m_geometry; }
31 QRect availableGeometry() const override { return m_availableGeometry; }
32 int depth() const override { return m_depth; }
33 QImage::Format format() const override { return m_format; }
34 QColorSpace colorSpace() const override { return m_colorSpace; }
35 qreal devicePixelRatio() const override { return m_devicePixelRatio; }
36 QSizeF physicalSize() const override { return m_physicalSize; }
37 QDpi logicalBaseDpi() const override { return QDpi(72, 72); }
38 qreal refreshRate() const override { return m_refreshRate; }
39 QString name() const override { return m_name; }
40 QPlatformCursor *cursor() const override { return m_cursor; }
41 QWindow *topLevelAt(const QPoint &point) const override;
42 QList<QPlatformScreen *> virtualSiblings() const override;
44 Qt::ScreenOrientation orientation() const override;
45
46 // ----------------------------------------------------
47
48 static NSScreen *nativeScreenForDisplayId(CGDirectDisplayID displayId);
49 NSScreen *nativeScreen() const;
50
51 bool requestUpdate();
53 bool isRunningDisplayLink() const;
54
56 static QCocoaScreen *get(NSScreen *nsScreen);
57 static QCocoaScreen *get(CGDirectDisplayID displayId);
58 static QCocoaScreen *get(CFUUIDRef uuid);
59
64
65private:
66 static void initializeScreens();
67 static void updateScreens();
68 static void cleanupScreens();
69
70 static QMacNotificationObserver s_screenParameterObserver;
71 static CGDisplayReconfigurationCallBack s_displayReconfigurationCallBack;
72
73 static void add(CGDirectDisplayID displayId);
74 QCocoaScreen(CGDirectDisplayID displayId);
75 void update(CGDirectDisplayID displayId);
76 void remove();
77
78 bool isOnline() const;
79 bool isMirroring() const;
80
81 CGDirectDisplayID m_displayId = kCGNullDirectDisplay;
82 CGDirectDisplayID displayId() const { return m_displayId; }
83
84 QRect m_geometry;
85 QRect m_availableGeometry;
86 qreal m_refreshRate = 0;
87 int m_depth = 0;
88 QString m_name;
89 QImage::Format m_format;
90 QColorSpace m_colorSpace;
91 QSizeF m_physicalSize;
92 QCocoaCursor *m_cursor;
93 qreal m_devicePixelRatio = 0;
94 qreal m_rotation = 0;
95
96 CVDisplayLinkRef m_displayLink = nullptr;
97 dispatch_source_t m_displayLinkSource = nullptr;
98 QAtomicInt m_pendingUpdates;
99
100 friend class QCocoaIntegration;
101 friend class QCocoaWindow;
103};
104
105#ifndef QT_NO_DEBUG_STREAM
107#endif
108
110
111#if defined(__OBJC__)
112
113// @compatibility_alias doesn't work with categories or their methods
114#define qt_displayId QT_MANGLE_NAMESPACE(qt_displayId)
115
116@interface NSScreen (QtExtras)
117@property(readonly) CGDirectDisplayID qt_displayId;
118@end
119#endif
120
121#endif // QCOCOASCREEN_H
\inmodule QtCore
Definition qatomic.h:112
qreal refreshRate() const override
Reimplement this function in subclass to return the vertical refresh rate of the screen,...
QRect availableGeometry() const override
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
QColorSpace colorSpace() const override
static CGPoint mapToNative(const QPointF &pos, QCocoaScreen *screen=QCocoaScreen::primaryScreen())
friend QDebug operator<<(QDebug debug, const QCocoaScreen *screen)
static NSScreen * nativeScreenForDisplayId(CGDirectDisplayID displayId)
QSizeF physicalSize() const override
Reimplement this function in subclass to return the physical size of the screen, in millimeters.
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
QPixmap grabWindow(WId window, int x, int y, int width, int height) const override
static QCocoaScreen * get(NSScreen *nsScreen)
QDpi logicalBaseDpi() const override
Reimplement to return the base logical DPI for the platform.
void deliverUpdateRequests()
bool isRunningDisplayLink() const
int depth() const override
Reimplement in subclass to return current depth of the screen.
bool requestUpdate()
qreal devicePixelRatio() const override
Reimplement this function in subclass to return the device pixel ratio for the screen.
QPlatformScreen::SubpixelAntialiasingType subpixelAntialiasingTypeHint() const override
Returns a hint about this screen's subpixel layout structure.
static QCocoaScreen * primaryScreen()
The screen used as a reference for global window geometry.
static QPointF mapFromNative(CGPoint pos, QCocoaScreen *screen=QCocoaScreen::primaryScreen())
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
QString name() const override
QList< QPlatformScreen * > virtualSiblings() const override
Returns a list of all the platform screens that are part of the same virtual desktop.
QWindow * topLevelAt(const QPoint &point) const override
Return the given top level window for a given position.
NSScreen * nativeScreen() const
The QColorSpace class provides a color space abstraction.
Definition qcolorspace.h:21
\inmodule QtCore
Format
The following image formats are available in Qt.
Definition qimage.h:41
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:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:208
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtGui
Definition qwindow.h:63
rect
[4]
Combined button and popup list for selecting options.
ScreenOrientation
Definition qnamespace.h:271
QDebug operator<<(QDebug debug, const QCocoaScreen *screen)
#define Q_FORWARD_DECLARE_OBJC_CLASS(classname)
QPair< qreal, qreal > QDpi
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLint GLsizei width
GLint y
QScreen * screen
[1]
Definition main.cpp:29
double qreal
Definition qtypes.h:187
aWidget window() -> setWindowTitle("New Window Title")
[2]