[libwnck] core: Add private _wnck_get_gdk_display() utility API



commit c3cd8987ab4067bcc327a09719ecc059cb3edb76
Author: Vincent Untz <vuntz gnome org>
Date:   Fri Feb 18 19:09:13 2011 +0100

    core: Add private _wnck_get_gdk_display() utility API
    
    We don't have to duplicate error messages this way.

 libwnck/xutils.c |   34 ++++++++++++++++++++--------------
 libwnck/xutils.h |    2 ++
 2 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/libwnck/xutils.c b/libwnck/xutils.c
index 23a1cb9..5820ee9 100644
--- a/libwnck/xutils.c
+++ b/libwnck/xutils.c
@@ -263,13 +263,9 @@ text_property_to_utf8 (Display             *display,
 
   list = NULL;
 
-  gdkdisplay = gdk_x11_lookup_xdisplay (display);
-
-  if (!gdkdisplay) {
-    g_warning ("No GdkDisplay matching Display \"%s\" was found.\n",
-               DisplayString (display));
+  gdkdisplay = _wnck_gdk_display_lookup_from_display (display);
+  if (!gdkdisplay)
     return NULL;
-  }
 
   count = gdk_text_property_to_utf8_list_for_display (gdkdisplay,
                                           gdk_x11_xatom_to_atom (prop->encoding),
@@ -2434,6 +2430,20 @@ _wnck_set_icon_geometry  (Screen *screen,
   _wnck_error_trap_pop ();
 }
 
+GdkDisplay*
+_wnck_gdk_display_lookup_from_display (Display *display)
+{
+  GdkDisplay *gdkdisplay = NULL;
+
+  gdkdisplay = gdk_x11_lookup_xdisplay (display);
+
+  if (!gdkdisplay)
+    g_warning ("No GdkDisplay matching Display \"%s\" was found.\n",
+               DisplayString (display));
+
+  return gdkdisplay;
+}
+
 GdkWindow*
 _wnck_gdk_window_lookup_from_window (Screen *screen,
                                      Window  xwindow)
@@ -2442,15 +2452,11 @@ _wnck_gdk_window_lookup_from_window (Screen *screen,
   GdkDisplay *gdkdisplay;
 
   display = DisplayOfScreen (screen);
-  gdkdisplay = gdk_x11_lookup_xdisplay (display);
-
-  if (gdkdisplay)
-    return gdk_x11_window_lookup_for_display (gdkdisplay, xwindow);
-
-  g_warning ("No GdkDisplay matching Display \"%s\" was found.\n",
-             DisplayString (display));
+  gdkdisplay = _wnck_gdk_display_lookup_from_display (display);
+  if (!gdkdisplay)
+    return NULL;
 
-  return NULL;
+  return gdk_x11_window_lookup_for_display (gdkdisplay, xwindow);
 }
 
 /* orientation of pager */
diff --git a/libwnck/xutils.h b/libwnck/xutils.h
index ed4bffe..b5e77c3 100644
--- a/libwnck/xutils.h
+++ b/libwnck/xutils.h
@@ -221,6 +221,8 @@ void _wnck_set_desktop_layout (Screen *xscreen,
 GdkPixbuf* _wnck_gdk_pixbuf_get_from_pixmap (Screen *screen,
                                              Pixmap  xpixmap);
 
+GdkDisplay* _wnck_gdk_display_lookup_from_display (Display *display);
+
 GdkWindow* _wnck_gdk_window_lookup_from_window (Screen *screen,
                                                 Window  xwindow);
 



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