From e785bb69b37d7cb63a1828c2aa324adde6a164bc Mon Sep 17 00:00:00 2001 From: Monsta Date: Thu, 24 Dec 2015 14:25:56 +0300 Subject: libmate-panel-applet: move trap push/pop closer to X function call --- libmate-panel-applet/mate-panel-applet.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'libmate-panel-applet/mate-panel-applet.c') diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index be9e3204..bd1806a3 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -1377,17 +1377,22 @@ mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display, GdkVisual *visual, Window xid) { - Window window; - gint x, y; - guint width, height, border, depth; + Status result = 0; + Window window; + gint x, y; + guint width, height, border, depth; - if (!XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xid, &window, - &x, &y, &width, &height, &border, &depth)) - return NULL; + gdk_error_trap_push (); + result = XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xid, &window, + &x, &y, &width, &height, &border, &depth); + gdk_error_trap_pop_ignored (); + + if (result == 0) + return NULL; - return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display), - xid, gdk_x11_visual_get_xvisual (visual), - width, height); + return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display), + xid, gdk_x11_visual_get_xvisual (visual), + width, height); } static cairo_pattern_t * @@ -1432,11 +1437,9 @@ mate_panel_applet_get_pixmap (MatePanelApplet *applet, window = gtk_widget_get_window (GTK_WIDGET (applet)); #if GTK_CHECK_VERSION (3, 0, 0) - gdk_error_trap_push (); background = mate_panel_applet_create_foreign_surface_for_display (gdk_window_get_display (window), gdk_window_get_visual (window), xid); - gdk_error_trap_pop_ignored (); /* background can be NULL if the user changes the background very fast. * We'll get the next update, so it's not a big deal. */ -- cgit v1.2.1