1
0
Fork 0

x11-display: Expose UI scaling factor via D-Bus

This replaces the `legacy-ui-scaling-factor` entry in
`org.gnome.Mutter.DisplayConfig`, with the motivation being to no longer
expose X11 specific state via the monitor configuration API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3567>
This commit is contained in:
Jonas Ådahl 2023-12-12 22:41:20 +01:00 committed by Marge Bot
parent 2e20602fe8
commit 7635abcbf4
5 changed files with 76 additions and 12 deletions

View file

@ -426,10 +426,6 @@
always use the same scale. Absence of
this means logical monitor scales can
differ.
* "legacy-ui-scaling-factor" (i): The legacy scaling factor traditionally
used to scale X11 clients (commonly
communicated via the
Gdk/WindowScalingFactor XSetting entry).
-->
<method name="GetCurrentState">
<arg name="serial" direction="out" type="u" />

View file

@ -0,0 +1,8 @@
<!DOCTYPE node PUBLIC
'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
<node>
<interface name="org.gnome.Mutter.X11">
<property name="UiScalingFactor" type="i" access="readwrite" />
</interface>
</node>

View file

@ -1948,14 +1948,12 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
GDBusMethodInvocation *invocation,
MetaMonitorManager *manager)
{
MetaSettings *settings = meta_backend_get_settings (manager->backend);
GVariantBuilder monitors_builder;
GVariantBuilder logical_monitors_builder;
GVariantBuilder properties_builder;
GList *l;
int i;
MetaMonitorManagerCapability capabilities;
int ui_scaling_factor;
int max_screen_width, max_screen_height;
g_variant_builder_init (&monitors_builder,
@ -2158,11 +2156,6 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
g_variant_new_boolean (TRUE));
}
ui_scaling_factor = meta_settings_get_ui_scaling_factor (settings);
g_variant_builder_add (&properties_builder, "{sv}",
"legacy-ui-scaling-factor",
g_variant_new_int32 (ui_scaling_factor));
if (meta_monitor_manager_get_max_screen_size (manager,
&max_screen_width,
&max_screen_height))

View file

@ -968,6 +968,11 @@ dbus_interfaces = [
'interface': 'org.gnome.Mutter.DebugControl.xml',
'prefix': 'org.gnome.Mutter',
},
{
'name': 'meta-dbus-x11',
'interface': 'org.gnome.Mutter.X11.xml',
'prefix': 'org.gnome.Mutter',
},
]
if have_profiler

View file

@ -71,7 +71,7 @@
#include "wayland/meta-xwayland-private.h"
#endif
G_DEFINE_TYPE (MetaX11Display, meta_x11_display, G_TYPE_OBJECT)
#include "meta-dbus-x11.h"
static GQuark quark_x11_display_logical_monitor_data = 0;
@ -90,6 +90,14 @@ typedef struct _MetaX11DisplayLogicalMonitorData
int xinerama_index;
} MetaX11DisplayLogicalMonitorData;
typedef struct _MetaX11DisplayPrivate
{
MetaDBusX11 *dbus_api;
guint dbus_name_id;
} MetaX11DisplayPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaX11Display, meta_x11_display, G_TYPE_OBJECT)
static char *get_screen_name (Display *xdisplay,
int number);
@ -152,13 +160,46 @@ meta_x11_event_filter_free (MetaX11EventFilter *filter)
g_free (filter);
}
static void
on_bus_acquired (GDBusConnection *connection,
const char *name,
gpointer user_data)
{
MetaX11Display *x11_display = user_data;
MetaX11DisplayPrivate *priv =
meta_x11_display_get_instance_private (x11_display);
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (priv->dbus_api),
connection,
"/org/gnome/Mutter/X11",
NULL);
}
static void
update_ui_scaling_factor (MetaX11Display *x11_display)
{
MetaX11DisplayPrivate *priv =
meta_x11_display_get_instance_private (x11_display);
MetaBackend *backend = backend_from_x11_display (x11_display);
MetaSettings *settings = meta_backend_get_settings (backend);
int ui_scaling_factor;
ui_scaling_factor = meta_settings_get_ui_scaling_factor (settings);
meta_dbus_x11_set_ui_scaling_factor (priv->dbus_api, ui_scaling_factor);
}
static void
meta_x11_display_dispose (GObject *object)
{
MetaX11Display *x11_display = META_X11_DISPLAY (object);
MetaX11DisplayPrivate *priv =
meta_x11_display_get_instance_private (x11_display);
x11_display->closing = TRUE;
g_clear_handle_id (&priv->dbus_name_id, g_bus_unown_name);
g_clear_object (&priv->dbus_api);
g_clear_pointer (&x11_display->alarm_filters, g_ptr_array_unref);
g_clear_list (&x11_display->event_funcs,
@ -1221,6 +1262,23 @@ meta_x11_display_init_frames_client (MetaX11Display *x11_display)
on_frames_client_died, x11_display);
}
static void
initialize_dbus_interface (MetaX11Display *x11_display)
{
MetaX11DisplayPrivate *priv =
meta_x11_display_get_instance_private (x11_display);
priv->dbus_api = meta_dbus_x11_skeleton_new ();
priv->dbus_name_id =
g_bus_own_name (G_BUS_TYPE_SESSION,
"org.gnome.Mutter.X11",
G_BUS_NAME_OWNER_FLAGS_NONE,
on_bus_acquired,
NULL, NULL,
x11_display, NULL);
update_ui_scaling_factor (x11_display);
}
/**
* meta_x11_display_new:
*
@ -1317,6 +1375,8 @@ meta_x11_display_new (MetaDisplay *display,
x11_display = g_object_new (META_TYPE_X11_DISPLAY, NULL);
x11_display->display = display;
initialize_dbus_interface (x11_display);
/* here we use XDisplayName which is what the user
* probably put in, vs. DisplayString(display) which is
* canonicalized by XOpenDisplay()
@ -1980,6 +2040,8 @@ on_monitors_changed_internal (MetaMonitorManager *monitor_manager,
}
x11_display->has_xinerama_indices = FALSE;
update_ui_scaling_factor (x11_display);
}
static Bool