Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QCOCOASCREEN_H
6#define QCOCOASCREEN_H
7
8#include "qcocoacursor.h"
9
10#include <qpa/qplatformintegration.h>
11#include <QtCore/private/qcore_mac_p.h>
12
13#include <CoreGraphics/CoreGraphics.h>
14#include <CoreVideo/CoreVideo.h>
15
16#import <AppKit/NSScreen.h>
17#import <Foundation/NSArray.h>
18
20
21class QCocoaIntegration;
22
24{
25public:
26 ~QCocoaScreen();
27
28 // ----------------------------------------------------
29 // Virtual methods overridden from QPlatformScreen
30 QPixmap grabWindow(WId window, int x, int y, int width, int height) const override;
31 QRect geometry() const override { return m_geometry; }
32 QRect availableGeometry() const override { return m_availableGeometry; }
33 int depth() const override { return m_depth; }
34 QImage::Format format() const override { return m_format; }
35 QColorSpace colorSpace() const override { return m_colorSpace; }
36 qreal devicePixelRatio() const override { return m_devicePixelRatio; }
37 QSizeF physicalSize() const override { return m_physicalSize; }
38 QDpi logicalBaseDpi() const override { return QDpi(72, 72); }
39 qreal refreshRate() const override { return m_refreshRate; }
40 QString name() const override { return m_name; }
41 QPlatformCursor *cursor() const override { return m_cursor; }
42 QWindow *topLevelAt(const QPoint &point) const override;
43 QList<QPlatformScreen *> virtualSiblings() const override;
45 Qt::ScreenOrientation orientation() const override;
46
47 // ----------------------------------------------------
48
49 static NSScreen *nativeScreenForDisplayId(CGDirectDisplayID displayId);
50 NSScreen *nativeScreen() const override;
51
52 bool requestUpdate();
54
56 static QCocoaScreen *get(NSScreen *nsScreen);
57 static QCocoaScreen *get(CGDirectDisplayID displayId);
58 static QCocoaScreen *get(CFUUIDRef uuid);
59
61 static CGRect mapToNative(const QRectF &rect, QCocoaScreen *screen = QCocoaScreen::primaryScreen());
64
65private:
66 static void initializeScreens();
67 static void updateScreens();
68 static void cleanupScreens();
69
70 static void updateHdrWindows();
71
72 static QMacNotificationObserver s_screenParameterObserver;
73 static CGDisplayReconfigurationCallBack s_displayReconfigurationCallBack;
74
75 static void add(CGDirectDisplayID displayId);
76 QCocoaScreen(CGDirectDisplayID displayId);
77 void update(CGDirectDisplayID displayId);
78 void remove();
79
80 bool isOnline() const;
81 bool isMirroring() const;
82
83 CGDirectDisplayID m_displayId = kCGNullDirectDisplay;
84 CGDirectDisplayID displayId() const { return m_displayId; }
85
86 QRect m_geometry;
87 QRect m_availableGeometry;
88 qreal m_refreshRate = 0;
89 int m_depth = 0;
90 QString m_name;
91 QImage::Format m_format;
92 QColorSpace m_colorSpace;
93 QSizeF m_physicalSize;
94 QCocoaCursor *m_cursor;
95 qreal m_devicePixelRatio = 0;
96 qreal m_rotation = 0;
97
98 CVDisplayLinkRef m_displayLink = nullptr;
99 dispatch_source_t m_displayLinkSource = nullptr;
100 QAtomicInt m_pendingUpdateRequests;
101 QAtomicInt m_pendingDisplayLinkUpdates;
102
103 void maybeStopDisplayLink();
104
105 friend class QCocoaIntegration;
106 friend class QCocoaWindow;
107 friend QDebug operator<<(QDebug debug, const QCocoaScreen *screen);
108};
109
110#ifndef QT_NO_DEBUG_STREAM
111QDebug operator<<(QDebug debug, const QCocoaScreen *screen);
112#endif
113
114QT_END_NAMESPACE
115
116#if defined(__OBJC__)
117
118// @compatibility_alias doesn't work with categories or their methods
119#define qt_displayId QT_MANGLE_NAMESPACE(qt_displayId)
120
121@interface NSScreen (QtExtras)
122@property(readonly) CGDirectDisplayID qt_displayId;
123@end
124#endif
125
126#endif // QCOCOASCREEN_H
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())
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()
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.
static CGRect mapToNative(const QRectF &rect, QCocoaScreen *screen=QCocoaScreen::primaryScreen())
NSScreen * nativeScreen() const override
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 QCocoaScreen * get(CGDirectDisplayID displayId)
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.
\inmodule QtCore\reentrant
Definition qpoint.h:231