[mutter/wip/ui-on-own-connection: 7/13] xprop: Don't use GDK for reading text properties



commit 03e5bbf59fcfa3e9d990493d39f464fca69891f7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Apr 6 17:03:53 2014 -0400

    xprop: Don't use GDK for reading text properties

 src/ui/ui.c      |   32 --------------------------------
 src/ui/ui.h      |    3 ---
 src/x11/xprops.c |   28 +++++++++++++++++++++++++---
 3 files changed, 25 insertions(+), 38 deletions(-)
---
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 0c8149b..c5d1842 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -650,38 +650,6 @@ meta_ui_window_should_not_cause_focus (Display *xdisplay,
     return FALSE;
 }
 
-char*
-meta_text_property_to_utf8 (Display             *xdisplay,
-                            const XTextProperty *prop)
-{
-  GdkDisplay *display;
-  char **list;
-  int count;
-  char *retval;
-  
-  list = NULL;
-
-  display = gdk_x11_lookup_xdisplay (xdisplay);
-  count = gdk_text_property_to_utf8_list_for_display (display,
-                                                      gdk_x11_xatom_to_atom_for_display (display, 
prop->encoding),
-                                                      prop->format,
-                                                      prop->value,
-                                                      prop->nitems,
-                                                      &list);
-
-  if (count == 0)
-    retval = NULL;
-  else
-    {
-  retval = list[0];
-  list[0] = g_strdup (""); /* something to free */
-    }
-  
-  g_strfreev (list);
-
-  return retval;
-}
-
 void
 meta_ui_theme_get_frame_borders (MetaUI *ui,
                                  MetaFrameType      type,
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 42b2b09..165129f 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -142,9 +142,6 @@ GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui);
 gboolean  meta_ui_window_should_not_cause_focus (Display *xdisplay,
                                                  Window   xwindow);
 
-char*     meta_text_property_to_utf8 (Display             *xdisplay,
-                                      const XTextProperty *prop);
-
 void     meta_ui_set_current_theme (const char *name);
 gboolean meta_ui_have_a_theme      (void);
 
diff --git a/src/x11/xprops.c b/src/x11/xprops.c
index a04bf04..44c1113 100644
--- a/src/x11/xprops.c
+++ b/src/x11/xprops.c
@@ -736,6 +736,29 @@ meta_prop_get_cardinal_with_atom_type (MetaDisplay   *display,
   return cardinal_with_atom_type_from_results (&results, prop_type, cardinal_p);
 }
 
+static char *
+text_property_to_utf8 (Display *xdisplay,
+                       const XTextProperty *prop)
+{
+  char *ret = NULL;
+  char **local_list = NULL;
+  int count = 0;
+  int res;
+
+  res = XmbTextPropertyToTextList (xdisplay, prop, &local_list, &count);
+  if (res == XNoMemory || res == XLocaleNotSupported || res == XConverterNotFound)
+    goto out;
+
+  if (count == 0)
+    goto out;
+
+  ret = g_strdup (local_list[0]);
+
+ out:
+  meta_XFree (local_list);
+  return ret;
+}
+
 static gboolean
 text_property_from_results (GetPropertyResults *results,
                             char              **utf8_str_p)
@@ -743,15 +766,14 @@ text_property_from_results (GetPropertyResults *results,
   XTextProperty tp;
 
   *utf8_str_p = NULL;
-  
+
   tp.value = results->prop;
   results->prop = NULL;
   tp.encoding = results->type;
   tp.format = results->format;
   tp.nitems = results->n_items;  
   
-  *utf8_str_p = meta_text_property_to_utf8 (results->display->xdisplay,
-                                            &tp);
+  *utf8_str_p = text_property_to_utf8 (results->display->xdisplay, &tp);
   
   if (tp.value != NULL)
     XFree (tp.value);


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