iOS: Trigger expose on screen brightness change for windows that opt into EDR

When the screen brightness of the display changes, the active EDR headroom of
the display might also be updated.

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: I72ed3b8335ad763f66043daf6fcbac616425845b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Tor Arne Vestbø 2025-02-04 14:04:59 +01:00
parent f0508b7ff3
commit 5d58c9765c
2 changed files with 24 additions and 0 deletions

View File

@ -8,6 +8,8 @@
#include <qpa/qplatformscreen.h>
#include <QtCore/private/qcore_mac_p.h>
@class QIOSOrientationListener;
QT_BEGIN_NAMESPACE
@ -53,6 +55,7 @@ private:
#if !defined(Q_OS_VISIONOS)
UIScreen *m_uiScreen = nullptr;
QMacNotificationObserver m_screenBrightnessObserver;
#endif
QRect m_geometry;
QRect m_availableGeometry;

View File

@ -180,6 +180,27 @@ QIOSScreen::QIOSScreen(UIScreen *screen)
m_displayLink.paused = YES; // Enabled when clients call QWindow::requestUpdate()
[m_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
// The screen brightness might affect the EDR headroom of the display,
// which might affect the rendering of windows that opt in to EDR.
m_screenBrightnessObserver = QMacNotificationObserver(m_uiScreen,
UIScreenBrightnessDidChangeNotification, [&]() {
if (@available(iOS 17, *)) {
for (auto *window : QPlatformScreen::windows()) {
auto *platformWindow = static_cast<QIOSWindow*>(window->handle());
if (!platformWindow)
continue;
UIView *view = platformWindow->view();
if (!view.layer.wantsExtendedDynamicRangeContent)
continue;
[view setNeedsDisplay];
}
}
});
#endif // !defined(Q_OS_VISIONOS))
updateProperties();