diff options
| author | Tor Arne Vestbø <[email protected]> | 2025-02-04 14:04:59 +0100 |
|---|---|---|
| committer | Tor Arne Vestbø <[email protected]> | 2025-02-11 15:58:38 +0100 |
| commit | 5d58c9765ceb96dc1cd23d2bd3244c561466e507 (patch) | |
| tree | dff5e5f0bd491ef4fdc2554f3123433c982e8bf1 | |
| parent | f0508b7ff3d2393521f49dcb1a9e880bf7665a87 (diff) | |
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 <[email protected]>
| -rw-r--r-- | src/plugins/platforms/ios/qiosscreen.h | 3 | ||||
| -rw-r--r-- | src/plugins/platforms/ios/qiosscreen.mm | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h index dd694283908..07c8f71a53d 100644 --- a/src/plugins/platforms/ios/qiosscreen.h +++ b/src/plugins/platforms/ios/qiosscreen.h @@ -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; diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index c5944ba1a7e..843e33bb8de 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -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(); |
