diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h index 1ff9cddd5b5..4898255e022 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.h +++ b/src/plugins/platforms/cocoa/qcocoascreen.h @@ -66,6 +66,8 @@ private: static void updateScreens(); static void cleanupScreens(); + static void updateHdrWindows(); + static QMacNotificationObserver s_screenParameterObserver; static CGDisplayReconfigurationCallBack s_displayReconfigurationCallBack; diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index ba6bda0f8ca..d8b9601f5d1 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -64,6 +64,10 @@ void QCocoaScreen::initializeScreens() NSApplicationDidChangeScreenParametersNotification, [&]() { qCDebug(lcQpaScreen) << "Received screen parameter change notification"; updateScreens(); + + // The notification is posted when the EDR headroom of a display changes, + // which might affect the rendering of windows that opt in to EDR. + updateHdrWindows(); }); } @@ -500,6 +504,27 @@ void QCocoaScreen::maybeStopDisplayLink() CVDisplayLinkStop(m_displayLink); } + +// ----------------------------------------------------------- + +void QCocoaScreen::updateHdrWindows() +{ + if (@available(macOS 14, *)) { + for (auto *window : QGuiApplication::allWindows()) { + auto *platformWindow = static_cast(window->handle()); + if (!platformWindow) + continue; + + NSView *view = platformWindow->view(); + + if (!view.layer.wantsExtendedDynamicRangeContent) + continue; + + [view setNeedsDisplay:YES]; + } + } +} + // ----------------------------------------------------------- QPlatformScreen::SubpixelAntialiasingType QCocoaScreen::subpixelAntialiasingTypeHint() const