diff options
author | Riteo <riteo@posteo.net> | 2024-03-16 14:48:11 +0100 |
---|---|---|
committer | Riteo <riteo@posteo.net> | 2024-05-07 19:50:48 +0200 |
commit | 1bb8199342fc40e00145ff06a634c3389f1ba0d6 (patch) | |
tree | f96812861db6c062850ea079a85097389532d84c /platform/linuxbsd | |
parent | d8aa2c65a9f857e86d0c1fc1cc6b95b8ccf23099 (diff) | |
download | redot-engine-1bb8199342fc40e00145ff06a634c3389f1ba0d6.tar.gz |
Wayland: Workaround API limitation in screen/UI scale logic
Mainly, this fixes auto UI scaling with _single-monitor_ fractional
setups (see the comment in `display_server_wayland.cpp` for more info).
This is the result of a bunch of current limitations, mainly the fact
that the UI scale is static (it's probed at startup) and the fact that
Wayland exposes fractional scales only at the window-level, by design.
The `screen_get_scale` special case should help in 99% of cases, while
the auto UI scale part will unfortunately only help with single-screen
situations, as multi-screen fractional scaling requires dynamic UI
scale changing.
Diffstat (limited to 'platform/linuxbsd')
-rw-r--r-- | platform/linuxbsd/wayland/display_server_wayland.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp index 1c3cae0435..f7995472d0 100644 --- a/platform/linuxbsd/wayland/display_server_wayland.cpp +++ b/platform/linuxbsd/wayland/display_server_wayland.cpp @@ -550,7 +550,15 @@ float DisplayServerWayland::screen_get_scale(int p_screen) const { MutexLock mutex_lock(wayland_thread.mutex); if (p_screen == SCREEN_OF_MAIN_WINDOW) { - p_screen = window_get_current_screen(); + // Wayland does not expose fractional scale factors at the screen-level, but + // some code relies on it. Since this special screen is the default and a lot + // of code relies on it, we'll return the window's scale, which is what we + // really care about. After all, we have very little use of the actual screen + // enumeration APIs and we're (for now) in single-window mode anyways. + struct wl_surface *wl_surface = wayland_thread.window_get_wl_surface(MAIN_WINDOW_ID); + WaylandThread::WindowState *ws = wayland_thread.wl_surface_get_window_state(wl_surface); + + return wayland_thread.window_state_get_scale_factor(ws); } return wayland_thread.screen_get_data(p_screen).scale; |