5#include <AppKit/AppKit.h>
6#include <ScreenCaptureKit/ScreenCaptureKit.h>
14#include <QtCore/qcoreapplication.h>
15#include <QtGui/private/qcoregraphics_p.h>
17#include <IOKit/graphics/IOGraphicsLib.h>
19#include <QtGui/qpainter.h>
20#include <QtGui/private/qwindow_p.h>
21#include <QtGui/private/qhighdpiscaling_p.h>
23#include <QtCore/private/qcore_mac_p.h>
24#include <QtCore/private/qeventdispatcher_cf_p.h>
43 Q_ENUM_NS(DisplayChange)
46QMacNotificationObserver
QCocoaScreen::s_screenParameterObserver;
47CGDisplayReconfigurationCallBack
QCocoaScreen::s_displayReconfigurationCallBack =
nullptr;
53 s_displayReconfigurationCallBack = [](CGDirectDisplayID displayId, CGDisplayChangeSummaryFlags flags,
void *userInfo) {
56 const bool beforeReconfigure = flags & kCGDisplayBeginConfigurationFlag;
57 qCDebug(lcQpaScreen).verbosity(0) <<
"Display" << displayId
58 << (beforeReconfigure ?
"beginning" :
"finished") <<
"reconfigure"
61 if (!beforeReconfigure)
64 CGDisplayRegisterReconfigurationCallback(s_displayReconfigurationCallBack,
nullptr);
66 s_screenParameterObserver = QMacNotificationObserver(NSApplication.sharedApplication,
67 NSApplicationDidChangeScreenParametersNotification, [&]() {
68 qCDebug(lcQpaScreen) <<
"Received screen parameter change notification";
78
79
80
81
89 static bool updatingScreens =
false;
90 if (updatingScreens) {
91 qCInfo(lcQpaScreen) <<
"Skipping screen update, already updating";
94 QScopedValueRollback recursionGuard(updatingScreens,
true);
96 uint32_t displayCount = 0;
97 if (CGGetOnlineDisplayList(0,
nullptr, &displayCount) != kCGErrorSuccess)
98 qFatal(
"Failed to get number of online displays");
100 QVector<CGDirectDisplayID> onlineDisplays(displayCount);
101 if (CGGetOnlineDisplayList(displayCount, onlineDisplays.data(), &displayCount) != kCGErrorSuccess)
102 qFatal(
"Failed to get online displays");
104 qCInfo(lcQpaScreen) <<
"Updating screens with" << displayCount
105 <<
"online displays:" << onlineDisplays;
108 int mainDisplayIndex = onlineDisplays.indexOf(CGMainDisplayID());
109 if (mainDisplayIndex < 0) {
110 qCWarning(lcQpaScreen) <<
"Main display not in list of online displays!";
111 }
else if (mainDisplayIndex > 0) {
112 qCWarning(lcQpaScreen) <<
"Main display not first display, making sure it is";
113 onlineDisplays.move(mainDisplayIndex, 0);
116 for (CGDirectDisplayID displayId : onlineDisplays) {
117 Q_ASSERT(CGDisplayIsOnline(displayId));
119 if (CGDisplayMirrorsDisplay(displayId))
128 QCFType<CFUUIDRef> uuid = CGDisplayCreateUUIDFromDisplayID(displayId);
131 if (QCocoaScreen *existingScreen = QCocoaScreen::get(uuid)) {
132 existingScreen->update(displayId);
133 qCInfo(lcQpaScreen) <<
"Updated" << existingScreen;
134 if (CGDisplayIsMain(displayId) && existingScreen != qGuiApp->primaryScreen()->handle()) {
135 qCInfo(lcQpaScreen) <<
"Primary screen changed to" << existingScreen;
136 QWindowSystemInterface::handlePrimaryScreenChanged(existingScreen);
139 QCocoaScreen::add(displayId);
143 for (QScreen *screen : QGuiApplication::screens()) {
144 QCocoaScreen *platformScreen =
static_cast<QCocoaScreen*>(screen->handle());
145 if (!platformScreen->isOnline() || platformScreen->isMirroring())
146 platformScreen->remove();
152 const bool isPrimary = CGDisplayIsMain(displayId);
154 qCInfo(lcQpaScreen) <<
"Adding" << cocoaScreen
155 << (isPrimary ?
"as new primary screen" :
"");
156 QWindowSystemInterface::handleScreenAdded(cocoaScreen, isPrimary);
160 : QPlatformScreen(), m_displayId(displayId)
163 m_cursor =
new QCocoaCursor;
169 for (QScreen *screen : backwards(QGuiApplication::screens()))
170 static_cast<QCocoaScreen*>(screen->handle())->remove();
172 Q_ASSERT(s_displayReconfigurationCallBack);
173 CGDisplayRemoveReconfigurationCallback(s_displayReconfigurationCallBack,
nullptr);
174 s_displayReconfigurationCallBack =
nullptr;
176 s_screenParameterObserver.remove();
192 qCInfo(lcQpaScreen) <<
"Removing " <<
this;
193 QWindowSystemInterface::handleScreenRemoved(
this);
198 Q_ASSERT_X(!screen(),
"QCocoaScreen",
"QScreen should be deleted first");
202 CVDisplayLinkRelease(m_displayLink);
203 if (m_displayLinkSource)
204 dispatch_release(m_displayLinkSource);
209 if (displayId != m_displayId) {
210 qCDebug(lcQpaScreen) <<
"Reconnecting" <<
this <<
"as display" << displayId;
211 m_displayId = displayId;
217 NSScreen *nsScreen = nativeScreen();
219 qCDebug(lcQpaScreen) <<
"Corresponding NSScreen not yet available. Deferring update";
223 const QRect previousGeometry = m_geometry;
224 const QRect previousAvailableGeometry = m_availableGeometry;
225 const qreal previousRefreshRate = m_refreshRate;
226 const double previousRotation = m_rotation;
229 QRectF primaryScreenGeometry = QRectF::fromCGRect(CGDisplayBounds(CGMainDisplayID()));
230 m_geometry = qt_mac_flip(QRectF::fromCGRect(nsScreen.frame), primaryScreenGeometry).toRect();
231 m_availableGeometry = qt_mac_flip(QRectF::fromCGRect(nsScreen.visibleFrame), primaryScreenGeometry).toRect();
233 if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSTahoe) {
238 if (NSApp.presentationOptions & NSApplicationPresentationFullScreen
239 && m_availableGeometry.height() == m_geometry.height()) {
240 if (
auto menuBarHeight = NSApp.mainMenu.menuBarHeight; menuBarHeight > 0)
241 m_availableGeometry.setTop(m_availableGeometry.top() + qRound(menuBarHeight));
245 m_devicePixelRatio = nsScreen.backingScaleFactor;
247 m_format = QImage::Format_RGB32;
248 m_depth = NSBitsPerPixelFromDepth(nsScreen.depth);
249 m_colorSpace = QColorSpace::fromIccProfile(QByteArray::fromNSData(nsScreen.colorSpace.ICCProfileData));
250 if (!m_colorSpace.isValid()) {
251 qCWarning(lcQpaScreen) <<
"Failed to parse ICC profile for" << nsScreen.colorSpace
252 <<
"with ICC data" << nsScreen.colorSpace.ICCProfileData
253 <<
"- Falling back to sRGB";
254 m_colorSpace = QColorSpace::SRgb;
257 CGSize size = CGDisplayScreenSize(m_displayId);
258 m_physicalSize = QSizeF(size.width, size.height);
260 QCFType<CGDisplayModeRef> displayMode = CGDisplayCopyDisplayMode(m_displayId);
261 float refresh = CGDisplayModeGetRefreshRate(displayMode);
262 m_refreshRate = refresh > 0 ? refresh : 60.0;
263 m_rotation = CGDisplayRotation(displayId);
264 m_name = QString::fromNSString(nsScreen.localizedName);
266 const bool didChangeGeometry = m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry;
268 if (m_rotation != previousRotation)
269 QWindowSystemInterface::handleScreenOrientationChange(screen(), orientation());
271 if (didChangeGeometry)
272 QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), availableGeometry());
273 if (m_refreshRate != previousRefreshRate)
274 QWindowSystemInterface::handleScreenRefreshRateChange(screen(), m_refreshRate);
283 Q_ASSERT(m_displayId);
286 qCDebug(lcQpaScreenUpdates) <<
this <<
"is not online. Ignoring update request";
293 ++m_pendingUpdateRequests;
295 if (!m_displayLink) {
296 qCDebug(lcQpaScreenUpdates) <<
"Creating display link for" <<
this;
297 if (CVDisplayLinkCreateWithCGDisplay(m_displayId, &m_displayLink) != kCVReturnSuccess) {
298 qCWarning(lcQpaScreenUpdates) <<
"Failed to create display link for" <<
this;
301 if (
auto displayId = CVDisplayLinkGetCurrentCGDisplay(m_displayLink); displayId != m_displayId) {
302 qCWarning(lcQpaScreenUpdates) <<
"Unexpected display" << displayId <<
"for display link";
303 CVDisplayLinkRelease(m_displayLink);
304 m_displayLink =
nullptr;
307 CVDisplayLinkSetOutputCallback(m_displayLink, [](CVDisplayLinkRef,
const CVTimeStamp*,
308 const CVTimeStamp*, CVOptionFlags, CVOptionFlags*,
void* displayLinkContext) ->
int {
311 return kCVReturnSuccess;
333 static CFMachPortRef eventTap = []() {
334 CFMachPortRef eventTap = CGEventTapCreateForPid(getpid(), kCGTailAppendEventTap,
335 kCGEventTapOptionListenOnly, NSEventMaskLeftMouseDragged,
336 [](CGEventTapProxy, CGEventType type, CGEventRef event,
void *) -> CGEventRef {
337 if (type == kCGEventTapDisabledByTimeout)
338 qCWarning(lcQpaScreenUpdates) <<
"Event tap disabled due to timeout!";
341 CGEventTapEnable(eventTap,
false);
342 static CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
343 CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
345 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
346 [center addObserverForName:NSWindowWillStartLiveResizeNotification object:nil queue:nil
347 usingBlock:^(NSNotification *notification) {
348 qCDebug(lcQpaScreenUpdates) <<
"Live resize of" << notification.object
349 <<
"started. Enabling event tap";
350 CGEventTapEnable(eventTap,
true);
352 [center addObserverForName:NSWindowDidEndLiveResizeNotification object:nil queue:nil
353 usingBlock:^(NSNotification *notification) {
354 qCDebug(lcQpaScreenUpdates) <<
"Live resize of" << notification.object
355 <<
"ended. Disabling event tap";
356 CGEventTapEnable(eventTap,
false);
363 if (!CVDisplayLinkIsRunning(m_displayLink)) {
364 qCDebug(lcQpaScreenUpdates) <<
"Starting display link for" <<
this;
365 CVDisplayLinkStart(m_displayLink);
375 if (cat.isDebugEnabled())
376 debug =
new QDebug(QMessageLogger().debug(cat).nospace());
390#define qDeferredDebug(helper) if (Q_UNLIKELY(helper.debug)) *helper.debug
395 qCDebug(lcQpaScreenUpdates) <<
this <<
"is not online. Ignoring update request delivery";
399 QMacAutoReleasePool pool;
406 if (!NSThread.isMainThread) {
410 const int pendingUpdates = ++m_pendingDisplayLinkUpdates;
412 const int pendingUpdateRequests = m_pendingUpdateRequests;
415 qDeferredDebug(screenUpdates) <<
"display link callback for screen " << m_displayId
416 <<
" with " << pendingUpdateRequests <<
" pending update requests";
418 if (
const int framesAheadOfDelivery = pendingUpdates - 1) {
423 qDeferredDebug(screenUpdates) <<
", " << framesAheadOfDelivery <<
" frame(s) ahead";
426 if (!pendingUpdateRequests) {
431 qDeferredDebug(screenUpdates) <<
"; skipping signaling dispatch source";
432 m_pendingDisplayLinkUpdates = 0;
438 if (!m_displayLinkSource) {
439 m_displayLinkSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA_ADD, 0, 0, dispatch_get_main_queue());
440 dispatch_source_set_event_handler(m_displayLinkSource, ^{
443 dispatch_resume(m_displayLinkSource);
446 dispatch_source_merge_data(m_displayLinkSource, 1);
452 const int pendingUpdates = m_pendingDisplayLinkUpdates;
453 if (pendingUpdates > 1)
454 qDeferredDebug(screenUpdates) <<
", " << (pendingUpdates - 1) <<
" frame(s) behind display link";
458 int pendingUpdateRequests = 0;
460 auto windows = QGuiApplication::allWindows();
461 for (
int i = 0; i < windows.size(); ++i) {
462 QWindow *window = windows.at(i);
463 if (window->screen() != screen())
466 QPointer<QCocoaWindow> platformWindow =
static_cast<
QCocoaWindow*>(window->handle());
470 if (!platformWindow->hasPendingUpdateRequest())
474 if (!platformWindow->updatesWithDisplayLink())
477 platformWindow->deliverUpdateRequest();
486 if (platformWindow->hasPendingUpdateRequest())
487 ++pendingUpdateRequests;
490 m_pendingUpdateRequests = pendingUpdateRequests;
492 if (
const int missedUpdates = m_pendingDisplayLinkUpdates.fetchAndStoreRelaxed(0) - pendingUpdates) {
493 qCWarning(lcQpaScreenUpdates) <<
"main thread missed" << missedUpdates
494 <<
"update(s) from display link during update request delivery";
501 if (!CVDisplayLinkIsRunning(m_displayLink))
504 const auto windows = QGuiApplication::allWindows();
505 for (
auto *window : windows) {
506 if (window->screen() != screen())
509 QPointer<QCocoaWindow> platformWindow =
static_cast<QCocoaWindow*>(window->handle());
513 if (window->isExposed())
516 if (platformWindow->hasPendingUpdateRequest())
520 qCDebug(lcQpaScreenUpdates) <<
"Stopping display link for" <<
this;
521 CVDisplayLinkStop(m_displayLink);
529 if (@available(macOS 14, *)) {
530 for (
auto *window : QGuiApplication::allWindows()) {
531 auto *platformWindow =
static_cast<QCocoaWindow*>(window->handle());
535 NSView *view = platformWindow->view();
537 if (!view.layer.wantsExtendedDynamicRangeContent)
540 [view setNeedsDisplay:YES];
549 QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint();
550 if (type == QPlatformScreen::Subpixel_None) {
552 type = QPlatformScreen::Subpixel_RGB;
560 return Qt::LandscapeOrientation;
561 if (m_rotation == 90)
562 return Qt::PortraitOrientation;
563 if (m_rotation == 180)
564 return Qt::InvertedLandscapeOrientation;
565 if (m_rotation == 270)
566 return Qt::InvertedPortraitOrientation;
567 return QPlatformScreen::orientation();
572 __block QWindow *window =
nullptr;
573 [NSApp enumerateWindowsWithOptions:NSWindowListOrderedFrontToBack
574 usingBlock:^(NSWindow *nsWindow, BOOL *stop) {
579 if (![nsWindow conformsToProtocol:@protocol(QNSWindowProtocol)])
582 QCocoaWindow *cocoaWindow = qnsview_cast(nsWindow.contentView).platformWindow;
586 QWindow *w = cocoaWindow->window();
590 auto nativeGeometry = QHighDpi::toNativePixels(w->geometry(), w);
591 if (!nativeGeometry.contains(point))
594 QRegion mask = QHighDpi::toNativeLocalPosition(w->mask(), w);
595 if (!mask.isEmpty() && !mask.contains(point - nativeGeometry.topLeft()))
601 if (!window->isTopLevel())
612
613
614
615
616
620 if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(
621 QPlatformIntegration::ScreenWindowGrabbing)) {
622 qCWarning(lcQpaScreen) <<
"Ignoring grabWindow to not bring down WindowServer";
626 auto grabFromDisplay = [](CGDirectDisplayID displayId,
const QRect &grabRect) -> QPixmap {
627 QMacAutoReleasePool pool;
629 const qreal scale = QCocoaScreen::nativeScreenForDisplayId(displayId).backingScaleFactor;
631 dispatch_semaphore_t sem = dispatch_semaphore_create(0);
632 auto cleanup = qScopeGuard([sem]() { dispatch_release(sem); });
634 auto captureShareableContent = [sem](
void (^capture)(SCShareableContent *)) {
638 [SCShareableContent getShareableContentWithCompletionHandler:
639 ^(SCShareableContent *content, NSError *error) {
641 qCDebug(lcQpaScreen) <<
"Failed to capture all windows" << error;
649 [SCShareableContent getCurrentProcessShareableContentWithCompletionHandler:
650 ^(SCShareableContent *content, NSError *error) {
652 qCWarning(lcQpaScreen) <<
"Failed to capture own windows" << error;
656 dispatch_semaphore_signal(sem);
663 __block QImage image;
664 captureShareableContent(^(SCShareableContent *content) {
667 QMacAutoReleasePool pool;
669 SCDisplay *scDisplay = nil;
670 for (SCDisplay *d in content.displays) {
671 if (d.displayID == displayId) {
677 qCWarning(lcQpaScreen) <<
"No SCDisplay for display" << displayId;
678 dispatch_semaphore_signal(sem);
682 SCContentFilter *filter = [[[SCContentFilter alloc]
683 initWithDisplay:scDisplay
684 includingApplications:content.applications
685 exceptingWindows:@[]] autorelease];
686 filter.includeMenuBar = YES;
688 SCStreamConfiguration *config = [[SCStreamConfiguration
new] autorelease];
689 config.sourceRect = grabRect.toCGRect();
690 config.width = qRound(grabRect.width() * scale);
691 config.height = qRound(grabRect.height() * scale);
692 config.showsCursor = NO;
693 config.capturesAudio = NO;
694 config.ignoreShadowsDisplay = NO;
695 config.ignoreShadowsSingleWindow = NO;
697 [SCScreenshotManager captureImageWithFilter:filter configuration:config
698 completionHandler:^(CGImageRef cgImage, NSError *error) {
700 qCWarning(lcQpaScreen) <<
"Failed screen capture" << error;
702 image = qt_mac_toQImage(cgImage);
703 dispatch_semaphore_signal(sem);
709 if (dispatch_semaphore_wait(sem, dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC)) != 0) {
710 qCWarning(lcQpaScreen) <<
"Screen capture timed out for display" << displayId;
714 QPixmap pixmap = QPixmap::fromImage(image);
715 pixmap.setDevicePixelRatio(scale);
719 QRect grabRect = QRect(x, y, width, height);
720 qCDebug(lcQpaScreen) <<
"input grab rect" << grabRect;
724 NSView *nsView =
reinterpret_cast<NSView*>(view);
725 NSPoint windowPoint = [nsView convertPoint:NSMakePoint(0, 0) toView:nil];
726 NSRect screenRect = [nsView.window convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
727 QPoint position = mapFromNative(screenRect.origin).toPoint();
728 QSize size = QRectF::fromCGRect(NSRectToCGRect(nsView.bounds)).toRect().size();
729 QRect windowRect = QRect(position, size);
730 if (!grabRect.isValid())
731 grabRect = windowRect;
733 grabRect.translate(windowRect.topLeft());
736 if (!grabRect.isValid())
737 grabRect = geometry();
741 const int maxDisplays = 128;
742 CGDirectDisplayID displays[maxDisplays];
743 CGDisplayCount displayCount;
744 CGRect cgRect = grabRect.isValid() ? grabRect.toCGRect() : CGRectInfinite;
745 const CGDisplayErr err = CGGetDisplaysWithRect(cgRect, maxDisplays, displays, &displayCount);
746 if (err || displayCount == 0)
749 qCDebug(lcQpaScreen) <<
"final grab rect" << grabRect <<
"from" << displayCount <<
"displays";
754 QVector<QPixmap> pixmaps;
755 QVector<QRect> globalGrabBounds;
757 for (uint i = 0; i < displayCount; ++i) {
758 auto display = displays[i];
759 const QRect displayBounds = QRectF::fromCGRect(CGDisplayBounds(display)).toRect();
760 const QRect grabBounds = displayBounds.intersected(grabRect);
761 if (grabBounds.isNull()) {
762 globalGrabBounds.append(QRect());
763 pixmaps.append(QPixmap());
766 const QRect displayLocalGrabBounds = QRect(QPoint(grabBounds.topLeft() - displayBounds.topLeft()), grabBounds.size());
768 qCDebug(lcQpaScreen) <<
"grab display" << i <<
"global" << grabBounds <<
"local" << displayLocalGrabBounds;
769 QPixmap displayPixmap = grabFromDisplay(display, displayLocalGrabBounds);
771 if (displayCount == 1)
772 return displayPixmap;
774 qCDebug(lcQpaScreen) <<
"grab sub-image size" << displayPixmap.size() <<
"devicePixelRatio" << displayPixmap.devicePixelRatio();
775 pixmaps.append(displayPixmap);
776 globalGrabBounds.append(grabBounds);
777 outputRect = outputRect.united(grabBounds);
782 for (uint i = 0; i < displayCount; ++i)
783 dpr = qMax(dpr, pixmaps.at(i).devicePixelRatio());
786 qCDebug(lcQpaScreen) <<
"Create grap pixmap" << outputRect.size() <<
"at devicePixelRatio" << dpr;
787 QPixmap windowPixmap(outputRect.size() * dpr);
788 windowPixmap.setDevicePixelRatio(dpr);
789 windowPixmap.fill(Qt::transparent);
790 QPainter painter(&windowPixmap);
791 for (uint i = 0; i < displayCount; ++i) {
792 const QRect grabBounds = globalGrabBounds.at(i);
793 if (grabBounds.isNull())
795 const QRect dest(grabBounds.topLeft() - outputRect.topLeft(), grabBounds.size());
796 painter.drawPixmap(dest, pixmaps.at(i));
809 int isOnline = CGDisplayIsOnline(m_displayId);
810 static const int kCGDisplayIsDisconnected = 0xffffffff;
811 return isOnline != kCGDisplayIsDisconnected && isOnline;
815
816
822 return CGDisplayMirrorsDisplay(m_displayId);
826
827
833 return static_cast<QCocoaScreen *>(QGuiApplication::primaryScreen()->handle());
838 QList<QPlatformScreen*> siblings;
841 for (QScreen *screen : QGuiApplication::screens())
842 siblings << screen->handle();
849 auto displayId = nsScreen.qt_displayId;
850 auto *cocoaScreen = get(displayId);
852 qCWarning(lcQpaScreen) <<
"Failed to map" << nsScreen
853 <<
"to QCocoaScreen. Doing last minute update.";
855 cocoaScreen = get(displayId);
857 qCWarning(lcQpaScreen) <<
"Last minute update failed!";
864 for (QScreen *screen : QGuiApplication::screens()) {
865 QCocoaScreen *cocoaScreen =
static_cast<QCocoaScreen*>(screen->handle());
866 if (cocoaScreen->m_displayId == displayId)
875 for (QScreen *screen : QGuiApplication::screens()) {
876 auto *platformScreen =
static_cast<QCocoaScreen*>(screen->handle());
877 if (!platformScreen->isOnline())
880 auto displayId = platformScreen->displayId();
881 QCFType<CFUUIDRef> candidateUuid(CGDisplayCreateUUIDFromDisplayID(displayId));
882 Q_ASSERT(candidateUuid);
884 if (candidateUuid == uuid)
885 return platformScreen;
891NSScreen *
QCocoaScreen::nativeScreenForDisplayId(CGDirectDisplayID displayId)
893 for (NSScreen *screen in NSScreen.screens) {
894 if (screen.qt_displayId == displayId)
905 return nativeScreenForDisplayId(m_displayId);
911 return qt_mac_flip(pos, screen->geometry()).toCGPoint();
917 return qt_mac_flip(rect, screen->geometry()).toCGRect();
923 return qt_mac_flip(QPointF::fromCGPoint(pos), screen->geometry());
929 return qt_mac_flip(QRectF::fromCGRect(rect), screen->geometry());
932#ifndef QT_NO_DEBUG_STREAM
935 QDebugStateSaver saver(debug);
937 debug <<
"QCocoaScreen(" << (
const void *)screen;
939 debug <<
", " << screen->name();
941 if (CGDisplayIsAsleep(screen->displayId()))
942 debug <<
", Sleeping";
943 if (
auto mirroring = CGDisplayMirrorsDisplay(screen->displayId()))
944 debug <<
", mirroring=" << mirroring;
946 debug <<
", Offline";
948 debug <<
", " << screen->geometry();
949 debug <<
", dpr=" << screen->devicePixelRatio();
950 debug <<
", displayId=" << screen->displayId();
952 if (
auto nativeScreen = screen->nativeScreen())
953 debug <<
", " << nativeScreen;
962#include "qcocoascreen.moc"
964@implementation NSScreen (QtExtras)
966- (CGDirectDisplayID)qt_displayId
968 return [self.deviceDescription[@
"NSScreenNumber"] unsignedIntValue];
QPixmap grabWindow(WId window, int x, int y, int width, int height) const override
void deliverUpdateRequests()
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.
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
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
@ ReconfiguredWithFlagsMissing
#define qDeferredDebug(helper)
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
DeferredDebugHelper(const QLoggingCategory &cat)