[mutter] x11-display: Get _GNOME_WM_KEYBINDINGS from the context



commit c1beb204c2915c5303cf249a17664f8b00151acb
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Mar 3 23:02:02 2021 +0100

    x11-display: Get _GNOME_WM_KEYBINDINGS from the context
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 src/core/meta-context-private.h |  2 ++
 src/core/meta-context.c         | 21 +++++++++++++++++++++
 src/meta/main.h                 |  3 ---
 src/meta/meta-context.h         |  4 ++++
 src/x11/meta-x11-display.c      | 19 ++-----------------
 5 files changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h
index 73ae1a86f0..03c9455a51 100644
--- a/src/core/meta-context-private.h
+++ b/src/core/meta-context-private.h
@@ -47,6 +47,8 @@ struct _MetaContextClass
 
 const char * meta_context_get_name (MetaContext *context);
 
+const char * meta_context_get_gnome_wm_keybindings (MetaContext *context);
+
 MetaWaylandCompositor * meta_context_get_wayland_compositor (MetaContext *context);
 
 #endif /* META_CONTEXT_PRIVATE_H */
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
index 4a3c3fabe2..458190e390 100644
--- a/src/core/meta-context.c
+++ b/src/core/meta-context.c
@@ -51,6 +51,7 @@ typedef struct _MetaContextPrivate
   char *name;
   char *plugin_name;
   GType plugin_gtype;
+  char *gnome_wm_keybindings;
 
   GOptionContext *option_context;
 
@@ -111,6 +112,24 @@ meta_context_set_plugin_name (MetaContext *context,
   priv->plugin_name = g_strdup (plugin_name);
 }
 
+void
+meta_context_set_gnome_wm_keybindings (MetaContext *context,
+                                       const char  *wm_keybindings)
+{
+  MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+  g_clear_pointer (&priv->gnome_wm_keybindings, g_free);
+  priv->gnome_wm_keybindings = g_strdup (wm_keybindings);
+}
+
+const char *
+meta_context_get_gnome_wm_keybindings (MetaContext *context)
+{
+  MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+  return priv->gnome_wm_keybindings;
+}
+
 void
 meta_context_notify_ready (MetaContext *context)
 {
@@ -462,6 +481,7 @@ meta_context_finalize (GObject *object)
 
   g_clear_pointer (&priv->option_context, g_option_context_free);
   g_clear_pointer (&priv->main_loop, g_main_loop_unref);
+  g_clear_pointer (&priv->gnome_wm_keybindings, g_free);
   g_clear_pointer (&priv->plugin_name, g_free);
   g_clear_pointer (&priv->name, g_free);
 
@@ -497,6 +517,7 @@ meta_context_init (MetaContext *context)
   MetaContextPrivate *priv = meta_context_get_instance_private (context);
 
   priv->plugin_gtype = G_TYPE_NONE;
+  priv->gnome_wm_keybindings = g_strdup ("Mutter");
 
   if (!setlocale (LC_ALL, ""))
     g_warning ("Locale not understood by C library");
diff --git a/src/meta/main.h b/src/meta/main.h
index 2533c7f22d..f5512caa6d 100644
--- a/src/meta/main.h
+++ b/src/meta/main.h
@@ -29,9 +29,6 @@
 META_EXPORT
 gboolean        meta_get_replace_current_wm (void);  /* Actually defined in util.c */
 
-META_EXPORT
-void            meta_set_gnome_wm_keybindings (const char *wm_keybindings);
-
 META_EXPORT
 void            meta_restart                (const char *message);
 
diff --git a/src/meta/meta-context.h b/src/meta/meta-context.h
index 30ebe82bf7..b72973e682 100644
--- a/src/meta/meta-context.h
+++ b/src/meta/meta-context.h
@@ -51,6 +51,10 @@ META_EXPORT
 void meta_context_set_plugin_name (MetaContext *context,
                                    const char  *plugin_name);
 
+META_EXPORT
+void meta_context_set_gnome_wm_keybindings (MetaContext *context,
+                                            const char  *wm_keybindings);
+
 META_EXPORT
 gboolean meta_context_configure (MetaContext   *context,
                                  int           *argc,
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 40abd32da8..2646e3afe6 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -82,8 +82,6 @@ typedef struct _MetaX11DisplayLogicalMonitorData
 
 static GdkDisplay *prepared_gdk_display = NULL;
 
-static const char *gnome_wm_keybindings = "Mutter";
-
 static char *get_screen_name (Display *xdisplay,
                               int      number);
 
@@ -730,6 +728,7 @@ init_leader_window (MetaX11Display *x11_display,
                     guint32        *timestamp)
 {
   MetaContext *context = meta_display_get_context (x11_display->display);
+  const char *gnome_wm_keybindings;
   gulong data[1];
   XEvent event;
 
@@ -748,6 +747,7 @@ init_leader_window (MetaX11Display *x11_display,
                                   x11_display->atom__NET_WM_NAME,
                                   meta_context_get_name (context));
 
+  gnome_wm_keybindings = meta_context_get_gnome_wm_keybindings (context);
   meta_prop_set_utf8_string_hint (x11_display,
                                   x11_display->leader_window,
                                   x11_display->atom__GNOME_WM_KEYBINDINGS,
@@ -1004,21 +1004,6 @@ set_work_area_hint (MetaDisplay    *display,
   g_free (data);
 }
 
-/**
- * meta_set_gnome_wm_keybindings: (skip)
- * @wm_keybindings: value for _GNOME_WM_KEYBINDINGS
- *
- * Set the value to use for the _GNOME_WM_KEYBINDINGS property. To take
- * effect, it is necessary to call this function before meta_init().
- */
-void
-meta_set_gnome_wm_keybindings (const char *wm_keybindings)
-{
-  g_return_if_fail (meta_get_display () == NULL);
-
-  gnome_wm_keybindings = wm_keybindings;
-}
-
 const gchar *
 meta_x11_get_display_name (void)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]