diff --git a/libxfce4ui/xfce-spawn.c b/libxfce4ui/xfce-spawn.c index b4946d3..5402091 100644 --- a/libxfce4ui/xfce-spawn.c +++ b/libxfce4ui/xfce-spawn.c @@ -56,6 +56,10 @@ #include #endif +#ifdef GDK_WINDOWING_WAYLAND +#include +#endif + #include #include #include @@ -335,6 +339,7 @@ xfce_spawn_on_screen_with_child_watch (GdkScreen *screen, guint n_cenvp; gchar *display_name; GPid pid; + GdkDisplay *display; XfceSpawnData *spawn_data; #ifdef HAVE_LIBSTARTUP_NOTIFICATION SnLauncherContext *sn_launcher = NULL; @@ -352,6 +357,8 @@ xfce_spawn_on_screen_with_child_watch (GdkScreen *screen, if (screen == NULL) screen = xfce_gdk_screen_get_active (NULL); + display = gdk_screen_get_display (screen); + /* setup the child environment (stripping $DESKTOP_STARTUP_ID and $DISPLAY) */ if (G_LIKELY (envp == NULL)) envp = (gchar **) environ; @@ -359,15 +366,27 @@ xfce_spawn_on_screen_with_child_watch (GdkScreen *screen, cenvp = g_new0 (gchar *, n + 3); for (n_cenvp = n = 0; envp[n] != NULL; ++n) { +#ifdef GDK_WINDOWING_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY (display)) + cenvp[n_cenvp++] = g_strdup (envp[n]); + else +#endif if (strncmp (envp[n], "DESKTOP_STARTUP_ID", 18) != 0 && strncmp (envp[n], "DISPLAY", 7) != 0) cenvp[n_cenvp++] = g_strdup (envp[n]); } - /* add the real display name for the screen */ - display_name = gdk_screen_make_display_name (screen); - cenvp[n_cenvp++] = g_strconcat ("DISPLAY=", display_name, NULL); - g_free (display_name); +#ifdef GDK_WINDOWING_X11 +#ifdef GDK_IS_X11_DISPLAY + if (GDK_IS_X11_DISPLAY (display)) +#endif + { + /* add the real display name for the screen */ + display_name = gdk_screen_make_display_name (screen); + cenvp[n_cenvp++] = g_strconcat ("DISPLAY=", display_name, NULL); + g_free (display_name); + } +#endif #ifdef HAVE_LIBSTARTUP_NOTIFICATION /* initialize the sn launcher context */