[mutter/wip/carlosg/x11less-preparations: 15/18] x11: Add meta_x11_get_display_name()



commit d25b42068e01b6aa500091d303a3dfea8811e994
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jan 31 13:04:15 2019 +0100

    x11: Add meta_x11_get_display_name()
    
    This function is able to tell the display name that X11 connections
    inside the compositor and spawned clients should use. Prefer it over
    the environment variable.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/420

 src/core/meta-launch-context.c     |  3 ++-
 src/x11/meta-x11-display-private.h |  2 ++
 src/x11/meta-x11-display.c         | 21 ++++++++++++++++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/core/meta-launch-context.c b/src/core/meta-launch-context.c
index eb8671bb2..500b2bcb4 100644
--- a/src/core/meta-launch-context.c
+++ b/src/core/meta-launch-context.c
@@ -114,7 +114,8 @@ meta_launch_context_constructed (GObject *object)
   G_OBJECT_CLASS (meta_launch_context_parent_class)->constructed (object);
 
   g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (context),
-                               "DISPLAY", getenv ("DISPLAY"));
+                               "DISPLAY",
+                               meta_x11_get_display_name ());
   g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (context),
                                "WAYLAND_DISPLAY", getenv ("WAYLAND_DISPLAY"));
 }
diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h
index 722d1c5bc..f07ceba27 100644
--- a/src/x11/meta-x11-display-private.h
+++ b/src/x11/meta-x11-display-private.h
@@ -235,4 +235,6 @@ void meta_x11_display_set_input_focus (MetaX11Display *x11_display,
                                        Window          xwindow,
                                        guint32         timestamp);
 
+const gchar * meta_x11_get_display_name (void);
+
 #endif /* META_X11_DISPLAY_PRIVATE_H */
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index cfbeccd2c..acf335d02 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -995,6 +995,25 @@ meta_set_gnome_wm_keybindings (const char *wm_keybindings)
   gnome_wm_keybindings = wm_keybindings;
 }
 
+const gchar *
+meta_x11_get_display_name (void)
+{
+#ifdef HAVE_WAYLAND
+  if (meta_is_wayland_compositor ())
+    {
+      MetaWaylandCompositor *compositor;
+
+      compositor = meta_wayland_compositor_get_default ();
+
+      return meta_wayland_get_xwayland_display_name (compositor);
+    }
+  else
+#endif
+    {
+      return g_getenv ("DISPLAY");
+    }
+}
+
 gboolean
 meta_x11_init_gdk_display (GError **error)
 {
@@ -1003,7 +1022,7 @@ meta_x11_init_gdk_display (GError **error)
   const char *gdk_gl_env = NULL;
   Display *xdisplay;
 
-  xdisplay_name = g_getenv ("DISPLAY");
+  xdisplay_name = meta_x11_get_display_name ();
   if (!xdisplay_name)
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,


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