[Xfce4-commits] <libxfce4ui:new-sm-client> add --display arg to restart command if necessary

Brian J. Tarricone brian at tarricone.org
Tue Sep 15 12:42:02 CEST 2009


Updating branch refs/heads/kelnos/new-sm-client
         to 42506c6e8f56bc60b10f6c8f785b9b021904603a (commit)
       from bef8eee3c84fd9c40d008b5486ff4c01d5069f4e (commit)

commit 42506c6e8f56bc60b10f6c8f785b9b021904603a
Author: Brian J. Tarricone <brian at tarricone.org>
Date:   Tue Sep 15 03:41:17 2009 -0700

    add --display arg to restart command if necessary

 libxfce4ui/xfce-sm-client.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/libxfce4ui/xfce-sm-client.c b/libxfce4ui/xfce-sm-client.c
index 232f4b3..d0ca320 100644
--- a/libxfce4ui/xfce-sm-client.c
+++ b/libxfce4ui/xfce-sm-client.c
@@ -668,10 +668,12 @@ xfce_sm_client_parse_argv(XfceSMClient *sm_client)
 {
     guint argc = 0;
     gchar **argv = NULL;
-    gchar **clone_command = NULL;
+    gchar **clone_command = NULL, **restart_command = NULL;
     guint clone_argc = 0;
     const gchar *client_id = NULL;
     int i;
+    gboolean got_display = FALSE;
+    gchar *display_name = NULL;
 
     if(sm_client->argc == 0 || !sm_client->argv)
         return;
@@ -682,20 +684,40 @@ xfce_sm_client_parse_argv(XfceSMClient *sm_client)
     clone_command = g_new0(gchar *, argc + 1);
 
     for(i = 0; i < argc; ++i) {
-        if(!g_ascii_strncasecmp(argv[i], SM_ID_ARG, strlen(SM_ID_ARG))) {
+        if(!strncmp(argv[i], SM_ID_ARG, strlen(SM_ID_ARG))) {
             if(argv[i][strlen(SM_ID_ARG)] == '=')
                 client_id = &(argv[i][strlen(SM_ID_ARG)+1]);
             else
                 client_id = argv[++i];
+        } else if(!strncmp(argv[i], DPY_ARG, strlen(DPY_ARG))) {
+            got_display = TRUE;
+            if(argv[i][strlen(DPY_ARG)] != '=')
+                i++;
         } else
             clone_command[clone_argc++] = argv[i];
     }
 
     if(client_id)
         xfce_sm_client_set_client_id(sm_client, client_id);
-    xfce_sm_client_set_restart_command(sm_client, argv);
+
+    if(!got_display) {
+        GdkDisplay *gdpy = gdk_display_get_default();
+        GdkScreen *gscreen = gdk_display_get_default_screen(gdpy);
+
+        restart_command = g_new0(gchar *, argc + 3);
+        for(i = 0; i < argc; ++i)
+            restart_command[i] = argv[i];
+        restart_command[i++] = "--display";
+        restart_command[i++] = display_name = gdk_screen_make_display_name(gscreen);
+    } else
+        restart_command = argv;
+
+    xfce_sm_client_set_restart_command(sm_client, restart_command);
     xfce_sm_client_set_clone_command(sm_client, clone_command);
 
+    if(restart_command != argv)
+        g_free(restart_command);
+    g_free(display_name);
     g_free(clone_command);
 
     sm_client->argc = 0;



More information about the Xfce4-commits mailing list