Get display name from gdk_display_get_name
authorPeng Huang <shawn.p.huang@gmail.com>
Mon, 30 Mar 2009 06:31:15 +0000 (14:31 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Mon, 30 Mar 2009 06:31:15 +0000 (14:31 +0800)
client/gtk2/ibusimcontext.c
src/ibusshare.c
src/ibusshare.h

index f99e60a..a0e97c1 100644 (file)
@@ -312,6 +312,8 @@ ibus_im_context_init (GObject *obj)
 
     /* init bus object */
     if (_bus == NULL)
+        
+        ibus_set_display (gdk_display_get_name (GDK_DISPLAY()));
         _bus = ibus_bus_new();
 
     if (ibus_bus_is_connected (_bus)) {
index f87bb0c..c8f37a8 100644 (file)
 #include <pwd.h>
 #include "ibusshare.h"
 
+static gchar *display = NULL;
+
+void
+ibus_set_display (const gchar *display)
+{
+    if (display != NULL)
+        g_free (display);
+    display = g_strdup (display);
+}
+
 const gchar *
 ibus_get_user_name (void)
 {
@@ -64,14 +74,16 @@ ibus_get_socket_path (void)
     static gchar *path = NULL;
 
     if (path == NULL) {
-        gchar *display;
         gchar *hostname = "";
         gchar *displaynumber = "0";
         gchar *screennumber = "0";
         const gchar *username = NULL;
         gchar *p;
 
-        display = g_strdup (g_getenv ("DISPLAY"));
+        if (display == NULL) {
+            display = g_strdup (g_getenv ("DISPLAY"));
+        }
+
         if (display == NULL) {
             g_warning ("DISPLAY is empty! We use default DISPLAY (:0.0)");
         }
@@ -104,7 +116,6 @@ ibus_get_socket_path (void)
             "/tmp/ibus-%s/ibus-%s-%s",
             username, hostname, displaynumber);
 
-        g_free (display);
     }
     return path;
 
index 142bd47..f3b34c4 100644 (file)
@@ -45,6 +45,7 @@
 
 G_BEGIN_DECLS
 
+void             ibus_set_display       (const gchar    *display);
 const gchar     *ibus_get_address       (void);
 const gchar     *ibus_get_user_name     (void);
 const gchar     *ibus_get_socket_path   (void);