diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-26 04:46:28 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-26 05:37:08 +0300 |
commit | ef51825c06242c12892337f87c82299c2996fa50 (patch) | |
tree | 932fed6b420fe4f0a6810ea7c34e24bb01ef4520 | |
parent | 047d0e6c4a96827a35d10111f08a631c8a2c0b64 (diff) |
Fix incorrect UI scaling after changing monitors DPI under Wayland
Add a GHOST_kEventWindowDPIHintChanged event to ensure the UI is
properly updated.
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWayland.cpp | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWayland.cpp | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 57b1a9bb434..13357a3d31a 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -2727,8 +2727,6 @@ static void output_handle_scale(void *data, struct wl_output * /*wl_output*/, co for (GHOST_IWindow *iwin : window_manager->getWindows()) { GHOST_WindowWayland *win = static_cast<GHOST_WindowWayland *>(iwin); win->outputs_changed_update_scale(); - /* TODO(@campbellbarton): support refreshing the UI when the DPI changes. - * There are glitches when resizing the monitor which would be nice to solve. */ } } } diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index e303bd5b6aa..d06ec872eca 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -935,6 +935,9 @@ GHOST_TSuccess GHOST_WindowWayland::notify_size() * Functionality only used for the WAYLAND implementation. * \{ */ +/** + * Return true when the windows scale or DPI changes. + */ bool GHOST_WindowWayland::outputs_changed_update_scale() { uint32_t dpi_next; @@ -963,6 +966,12 @@ bool GHOST_WindowWayland::outputs_changed_update_scale() * use a multiplier for the default DPI as workaround. */ win->dpi = dpi_next; changed = true; + + /* As this is a low-level function, we might want adding this event to be optional, + * always add the event unless it causes issues. */ + GHOST_System *system = (GHOST_System *)GHOST_ISystem::getSystem(); + system->pushEvent( + new GHOST_Event(system->getMilliSeconds(), GHOST_kEventWindowDPIHintChanged, this)); } return changed; |