[mutter/wip/wayland-kms: 35/39] Set DISPLAY and WAYLAND_DISPLAY for dbus activated services and for autostarted apps



commit 70ee4087c2cd1379fda4dd5877066abccc9c1525
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Tue Aug 20 18:03:26 2013 +0200

    Set DISPLAY and WAYLAND_DISPLAY for dbus activated services and for autostarted apps
    
    Call the appropriate method on gnome-session so that autostarted
    and bus activated apps see the X server and wayland socket.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706421

 src/wayland/meta-wayland.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 81648fe..4df2998 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -1486,6 +1486,35 @@ on_evdev_device_open (const char  *path,
                                               path, flags, error);
 }
 
+static void
+set_gnome_env (const char *name,
+              const char *value)
+{
+  GDBusConnection *session_bus;
+  GError *error;
+
+  setenv (name, value, TRUE);
+
+  session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+  g_assert (session_bus);
+
+  error = NULL;
+  g_dbus_connection_call_sync (session_bus,
+                              "org.gnome.SessionManager",
+                              "/org/gnome/SessionManager",
+                              "org.gnome.SessionManager",
+                              "Setenv",
+                              g_variant_new ("(ss)", name, value),
+                              NULL,
+                              G_DBUS_CALL_FLAGS_NONE,
+                              -1, NULL, &error);
+  if (error)
+    {
+      meta_warning ("Failed to set environment variable %s for gnome-session: %s\n", name, error->message);
+      g_clear_error (&error);
+    }
+}
+
 void
 meta_wayland_init (void)
 {
@@ -1495,6 +1524,7 @@ meta_wayland_init (void)
   CoglContext *cogl_context;
   CoglRenderer *cogl_renderer;
   int weston_launch_fd;
+  char *display_name;
 
   memset (compositor, 0, sizeof (MetaWaylandCompositor));
 
@@ -1643,7 +1673,11 @@ meta_wayland_init (void)
   if (!meta_xwayland_start (compositor))
     g_error ("Failed to start X Wayland");
 
-  putenv (g_strdup_printf ("DISPLAY=:%d", compositor->xwayland_display_index));
+  display_name = g_strdup_printf (":%d", compositor->xwayland_display_index);
+  set_gnome_env ("DISPLAY", display_name);
+  g_free (display_name);
+
+  set_gnome_env ("WAYLAND_DISPLAY", "wayland-0");
 }
 
 void


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