[mutter] main: Let the X11 CM backend deal with selecting the display
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] main: Let the X11 CM backend deal with selecting the display
- Date: Mon, 17 May 2021 16:34:29 +0000 (UTC)
commit 6558d43cd5ccb9e2a3949ff0ef4bd36736bac7fd
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Feb 25 22:00:06 2021 +0100
main: Let the X11 CM backend deal with selecting the display
It's specific to that backend, so do it there.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
src/backends/x11/cm/meta-backend-x11-cm.c | 72 +++++++++++++++++++++++++++++++
src/core/main.c | 40 ++++++-----------
2 files changed, 85 insertions(+), 27 deletions(-)
---
diff --git a/src/backends/x11/cm/meta-backend-x11-cm.c b/src/backends/x11/cm/meta-backend-x11-cm.c
index 0a02e1df12..ec9354db4f 100644
--- a/src/backends/x11/cm/meta-backend-x11-cm.c
+++ b/src/backends/x11/cm/meta-backend-x11-cm.c
@@ -37,10 +37,23 @@
#include "compositor/meta-compositor-x11.h"
#include "core/display-private.h"
+enum
+{
+ PROP_0,
+
+ PROP_DISPLAY_NAME,
+
+ N_PROPS
+};
+
+static GParamSpec *obj_props[N_PROPS];
+
struct _MetaBackendX11Cm
{
MetaBackendX11 parent;
+ char *display_name;
+
MetaCursorRenderer *cursor_renderer;
char *keymap_layouts;
char *keymap_variants;
@@ -437,6 +450,50 @@ meta_backend_x11_cm_translate_crossing_event (MetaBackendX11 *x11,
}
}
+static void
+meta_backend_x11_cm_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MetaBackendX11Cm *backend_x11_cm = META_BACKEND_X11_CM (object);
+
+ switch (prop_id)
+ {
+ case PROP_DISPLAY_NAME:
+ backend_x11_cm->display_name = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+meta_backend_x11_cm_finalize (GObject *object)
+{
+ MetaBackendX11Cm *x11_cm = META_BACKEND_X11_CM (object);
+
+ g_clear_pointer (&x11_cm->display_name, g_free);
+}
+
+static void
+meta_backend_x11_cm_constructed (GObject *object)
+{
+ MetaBackendX11Cm *x11_cm = META_BACKEND_X11_CM (object);
+ const char *display_name;
+
+ if (x11_cm->display_name)
+ display_name = (const char *) x11_cm->display_name;
+ else
+ display_name = g_getenv ("MUTTER_DISPLAY");
+
+ if (display_name)
+ g_setenv ("DISPLAY", display_name, TRUE);
+
+ G_OBJECT_CLASS (meta_backend_x11_cm_parent_class)->constructed (object);
+}
+
static void
meta_backend_x11_cm_init (MetaBackendX11Cm *backend_x11_cm)
{
@@ -455,9 +512,14 @@ meta_backend_x11_cm_init (MetaBackendX11Cm *backend_x11_cm)
static void
meta_backend_x11_cm_class_init (MetaBackendX11CmClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
MetaBackendX11Class *backend_x11_class = META_BACKEND_X11_CLASS (klass);
+ object_class->set_property = meta_backend_x11_cm_set_property;
+ object_class->finalize = meta_backend_x11_cm_finalize;
+ object_class->constructed = meta_backend_x11_cm_constructed;
+
backend_class->post_init = meta_backend_x11_cm_post_init;
backend_class->create_renderer = meta_backend_x11_cm_create_renderer;
backend_class->create_monitor_manager = meta_backend_x11_cm_create_monitor_manager;
@@ -472,5 +534,15 @@ meta_backend_x11_cm_class_init (MetaBackendX11CmClass *klass)
backend_x11_class->handle_host_xevent = meta_backend_x11_cm_handle_host_xevent;
backend_x11_class->translate_device_event = meta_backend_x11_cm_translate_device_event;
backend_x11_class->translate_crossing_event = meta_backend_x11_cm_translate_crossing_event;
+
+ obj_props[PROP_DISPLAY_NAME] =
+ g_param_spec_string ("display-name",
+ "display name",
+ "X11 display name",
+ NULL,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_properties (object_class, N_PROPS, obj_props);
}
diff --git a/src/core/main.c b/src/core/main.c
index 888753732c..5b874a5627 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -303,28 +303,6 @@ meta_get_option_context (void)
return ctx;
}
-/**
- * meta_select_display:
- *
- * Selects which display Mutter should use. It first tries to use
- * @display_name as the display. If @display_name is %NULL then
- * try to use the environment variable MUTTER_DISPLAY. If that
- * also is %NULL, use the default - :0.0
- */
-static void
-meta_select_display (char *display_arg)
-{
- const char *display_name;
-
- if (display_arg)
- display_name = (const char *) display_arg;
- else
- display_name = g_getenv ("MUTTER_DISPLAY");
-
- if (display_name)
- g_setenv ("DISPLAY", display_name, TRUE);
-}
-
void
meta_finalize (void)
{
@@ -653,6 +631,19 @@ calculate_compositor_configuration (MetaCompositorType *compositor_type,
else
#endif /* HAVE_WAYLAND */
{
+ static const char *display_name_prop_names[] = {
+ "display-name",
+ };
+ static GValue display_name_prop_values[] = {
+ G_VALUE_INIT,
+ };
+
+ g_value_init (&display_name_prop_values[0], G_TYPE_STRING);
+ g_value_set_string (&display_name_prop_values[0], opt_display_name);
+
+ *n_properties = G_N_ELEMENTS (display_name_prop_values);
+ *prop_names = display_name_prop_names;
+ *prop_values = display_name_prop_values;
*backend_gtype = META_TYPE_BACKEND_X11_CM;
return;
}
@@ -793,11 +784,6 @@ meta_init (void)
g_irepository_prepend_search_path (MUTTER_PKGLIBDIR);
#endif
- /* NB: When running as a hybrid wayland compositor we run our own headless X
- * server so the user can't control the X display to connect too. */
- if (!meta_is_wayland_compositor ())
- meta_select_display (opt_display_name);
-
meta_init_backend (backend_gtype, n_properties, prop_names, prop_values);
for (i = 0; i < n_properties; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]