From ab449c205cb656b32e8d1b8e036783f18704ff8e Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 5 Dec 2022 22:15:01 +0000 Subject: Introduce events for Window device pixel ratio changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a mix between screen device pixel ratio. Currently we store the property on a per-window basis, but the change notifications are still on a per screen basis which can fall apart on edge cases. On wayland we are getting per window DPR changes without as useful screen change events so it's important to fix. It also has potential to clean up the Windows backend in the future where the backend is currently papering over the two concepts. This patch introduces two new events: A QWindowSystemInterface to trigger a window DPR change independently of a screen change. An event to notify windows the new DPR rather than needing to track signals on the screen. This happens either when the window dpr changes or implicitly through a screen change. This can deprecate an existing event ScreenChangeInternal so the value is reused and renamed for clarity. Change-Id: I637a07fd4520ba3184ccc2c987c29d8d23a65ad3 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gui/kernel/qwindow.cpp') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 1e368914f3..5a0fc79f30 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -505,6 +505,8 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle) // the platformWindow, if there was one, is now gone, so make this flag reflect reality now updateRequestPending = false; + const qreal currentDevicePixelRatio = q->devicePixelRatio(); + if (q->parent()) q->parent()->create(); @@ -550,6 +552,11 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle) QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated); QGuiApplication::sendEvent(q, &e); + if (!qFuzzyCompare(currentDevicePixelRatio, q->devicePixelRatio())) { + QEvent dprChangeEvent(QEvent::DevicePixelRatioChange); + QGuiApplication::sendEvent(q, &dprChangeEvent); + } + if (needsUpdate) q->requestUpdate(); } -- cgit v1.2.3