From 9d83d67fde4cb9ed36d5370d028796a766cb4b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sat, 31 Aug 2024 22:45:21 +0200 Subject: [PATCH] xwayland: Add helper to get X11 UI scaling factor This is different from MetaSetting's UI scaling factor, and different from the effective Xwayland scale. The MetaSetting's UI scaling factor is the scaling factor used by gnome-shell chrome itself. The effective Xwayland scale is, with `native-xwayland-scaling` enabled, the scale everything X11 is scaled with. The X11 UI scaling factor is intended to be the scaling factor X11 clients are told to use, and how to derive that differs depending on the layout mode and the effective Xwayland scale. Part-of: --- src/wayland/meta-xwayland.c | 21 +++++++++++++++++++++ src/wayland/meta-xwayland.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c index eee4bf055..a581bf760 100644 --- a/src/wayland/meta-xwayland.c +++ b/src/wayland/meta-xwayland.c @@ -1356,3 +1356,24 @@ meta_xwayland_get_effective_scale (MetaXWaylandManager *manager) return 1; } + +int +meta_xwayland_get_x11_ui_scaling_factor (MetaXWaylandManager *manager) +{ + MetaWaylandCompositor *compositor = manager->compositor; + MetaContext *context = meta_wayland_compositor_get_context (compositor); + MetaBackend *backend = meta_context_get_backend (context); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); + MetaSettings *settings = meta_backend_get_settings (backend); + + switch (meta_monitor_manager_get_layout_mode (monitor_manager)) + { + case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL: + return meta_settings_get_ui_scaling_factor (settings); + case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL: + return meta_xwayland_get_effective_scale (manager); + } + + g_assert_not_reached (); +} diff --git a/src/wayland/meta-xwayland.h b/src/wayland/meta-xwayland.h index ae7a06977..9852840d5 100644 --- a/src/wayland/meta-xwayland.h +++ b/src/wayland/meta-xwayland.h @@ -50,3 +50,5 @@ gboolean meta_xwayland_signal (MetaXWaylandManager *manager, GError **error); int meta_xwayland_get_effective_scale (MetaXWaylandManager *manager); + +int meta_xwayland_get_x11_ui_scaling_factor (MetaXWaylandManager *manager);