[mutter/wip/wayland-work: 42/54] Set DISPLAY and WAYLAND_DISPLAY for dbus activated services and for autostarted apps



commit 1e9949e99ae71f3662df1cb1520165be53b9af7a
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 463758d..2c35dba 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -1565,6 +1565,35 @@ on_monitors_changed (MetaMonitorManager    *monitors,
   compositor->outputs = meta_wayland_compositor_update_outputs (compositor, monitors);
 }
 
+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)
 {
@@ -1574,6 +1603,7 @@ meta_wayland_init (void)
   ClutterBackend *backend;
   CoglContext *cogl_context;
   CoglRenderer *cogl_renderer;
+  char *display_name;
 
   memset (compositor, 0, sizeof (MetaWaylandCompositor));
 
@@ -1694,7 +1724,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]