macOS: Trigger expose on screen param change for windows that opt into EDR
When the active EDR headroom of a display is updated, due to its brightness setting changing e.g., the system sends us a screen parameter change. We don't have a specific signal for these kinds of changes on a screen or window level, so for now we do the next best thing, which is to trigger an expose even for any relevant windows that might need to re-render to reflect the updated EDR headroom. Change-Id: I1edd8ff6b9714b558a9ae92d45aaee56a838af7c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
5d58c9765c
commit
a5d896d70a
@ -66,6 +66,8 @@ private:
|
||||
static void updateScreens();
|
||||
static void cleanupScreens();
|
||||
|
||||
static void updateHdrWindows();
|
||||
|
||||
static QMacNotificationObserver s_screenParameterObserver;
|
||||
static CGDisplayReconfigurationCallBack s_displayReconfigurationCallBack;
|
||||
|
||||
|
@ -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<QCocoaWindow*>(window->handle());
|
||||
if (!platformWindow)
|
||||
continue;
|
||||
|
||||
NSView *view = platformWindow->view();
|
||||
|
||||
if (!view.layer.wantsExtendedDynamicRangeContent)
|
||||
continue;
|
||||
|
||||
[view setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
QPlatformScreen::SubpixelAntialiasingType QCocoaScreen::subpixelAntialiasingTypeHint() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user