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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3992>
This commit is contained in:
Jonas Ådahl 2024-08-31 22:45:21 +02:00 committed by Marge Bot
parent 736082f41a
commit 9d83d67fde
2 changed files with 23 additions and 0 deletions

View File

@ -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 ();
}

View File

@ -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);