diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2023-11-27 13:57:58 +0100 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2024-03-20 09:05:36 +0100 |
commit | 3e77c1699a843c0512a347cf25938d1f93e715ae (patch) | |
tree | 3baa41366627777dda472fd8e67f3c369303cbf0 /hw/xwayland | |
parent | 7a78756d0a4e7a2332e53940413b9e61b418345b (diff) |
xwayland: Add helper function for fractional scaling
Fractional scaling may not be available, or not suitable for the current
configuration (e.g. if running rootless).
Add a helper function to tell whether fractional scaling should be used.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
Diffstat (limited to 'hw/xwayland')
-rw-r--r-- | hw/xwayland/xwayland-screen.c | 23 | ||||
-rw-r--r-- | hw/xwayland/xwayland-screen.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c index 6a0f5a2ef..42c9a0e20 100644 --- a/hw/xwayland/xwayland-screen.c +++ b/hw/xwayland/xwayland-screen.c @@ -774,12 +774,35 @@ xwl_screen_lost_focus(struct xwl_screen *xwl_screen) } Bool +xwl_screen_should_use_fractional_scale(struct xwl_screen *xwl_screen) +{ + /* Fullscreen uses a viewport already */ + if (xwl_screen->fullscreen) + return FALSE; + + if (xwl_screen->rootless) + return FALSE; + + /* We need both fractional scale and viewporter protocols */ + if (!xwl_screen->fractional_scale_manager) + return FALSE; + + if (!xwl_screen->viewporter) + return FALSE; + + return xwl_screen->hidpi; +} + +Bool xwl_screen_update_global_surface_scale(struct xwl_screen *xwl_screen) { ScreenPtr screen = xwl_screen->screen; struct xwl_window *xwl_window; int32_t old_scale; + if (xwl_screen_should_use_fractional_scale(xwl_screen)) + return FALSE; + if (xwl_screen->rootless) return FALSE; diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h index d2c0865b8..477473eea 100644 --- a/hw/xwayland/xwayland-screen.h +++ b/hw/xwayland/xwayland-screen.h @@ -173,5 +173,6 @@ void xwl_surface_damage(struct xwl_screen *xwl_screen, int xwl_screen_get_next_output_serial(struct xwl_screen * xwl_screen); void xwl_screen_lost_focus(struct xwl_screen *xwl_screen); Bool xwl_screen_update_global_surface_scale(struct xwl_screen *xwl_screen); +Bool xwl_screen_should_use_fractional_scale(struct xwl_screen *xwl_screen); #endif /* XWAYLAND_SCREEN_H */ |