From c6e58f84ee9fed3f173ec0bf3e907cac1750fcd0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 30 Sep 2010 15:50:52 +0200 Subject: [PATCH] trayicon: Use gdk_cairo_get_clip_rectangle() to simplify code --- gtk/gtktrayicon-x11.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c index 48d25ed2f7..0d9b3afd17 100644 --- a/gtk/gtktrayicon-x11.c +++ b/gtk/gtktrayicon-x11.c @@ -335,23 +335,24 @@ gtk_tray_icon_draw (GtkWidget *widget, } else { - double x1, y1, x2, y2; + GdkRectangle clip; - cairo_clip_extents (cr, &x1, &x2, &y1, &y2); - /* Clear to parent-relative pixmap - * We need to use direct X access here because GDK doesn't know about - * the parent realtive pixmap. */ - cairo_surface_flush (target); + if (gdk_cairo_get_clip_rectangle (cr, &clip)) + { + /* Clear to parent-relative pixmap + * We need to use direct X access here because GDK doesn't know about + * the parent realtive pixmap. */ + cairo_surface_flush (target); - XClearArea (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XID (window), - floor (x1), floor (y1), - ceil (x2) - floor (x1), ceil (y2) - floor (y1), - False); - cairo_surface_mark_dirty_rectangle (target, - floor (x1), floor (y1), - ceil (x2) - floor (x1), - ceil (y2) - floor (y1)); + XClearArea (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), + clip.x, clip.y, + clip.width, clip.height, + False); + cairo_surface_mark_dirty_rectangle (target, + clip.x, clip.y, + clip.width, clip.height); + } } if (GTK_WIDGET_CLASS (gtk_tray_icon_parent_class)->draw)