[mutter] ui: Port draw_workspace() to take a cairo_t



commit 1c31e8ffc217d5d41b0bb0375e1221253102b315
Author: Benjamin Otte <otte redhat com>
Date:   Fri Sep 24 00:15:47 2010 +0200

    ui: Port draw_workspace() to take a cairo_t
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630203

 src/ui/draw-workspace.c |   21 +++++++++++----------
 src/ui/draw-workspace.h |    2 +-
 src/ui/tabpopup.c       |    9 +++++----
 3 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c
index f43821a..590fa2d 100644
--- a/src/ui/draw-workspace.c
+++ b/src/ui/draw-workspace.c
@@ -67,12 +67,11 @@ get_window_rect (const WnckWindowDisplayInfo *win,
 
 static void
 draw_window (GtkWidget                   *widget,
-             GdkDrawable                 *drawable,
+             cairo_t                     *cr,
              const WnckWindowDisplayInfo *win,
              const GdkRectangle          *winrect,
              GtkStateType                state)
 {
-  cairo_t *cr;
   GdkPixbuf *icon;
   int icon_x, icon_y, icon_w, icon_h;
   gboolean is_active;
@@ -81,7 +80,8 @@ draw_window (GtkWidget                   *widget,
 
   is_active = win->is_active;
   
-  cr = gdk_cairo_create (drawable);
+  cairo_save (cr);
+
   cairo_rectangle (cr, winrect->x, winrect->y, winrect->width, winrect->height);
   cairo_clip (cr);
 
@@ -159,12 +159,12 @@ draw_window (GtkWidget                   *widget,
                    MAX (0, winrect->width - 1), MAX (0, winrect->height - 1));
   cairo_stroke (cr);
   
-  cairo_destroy (cr);
+  cairo_restore (cr);
 }
 
 void
 wnck_draw_workspace (GtkWidget                   *widget,
-                     GdkDrawable                 *drawable,
+                     cairo_t                     *cr,
                      int                          x,
                      int                          y,
                      int                          width,
@@ -180,7 +180,6 @@ wnck_draw_workspace (GtkWidget                   *widget,
   GdkRectangle workspace_rect;
   GtkStateType state;
   GtkStyle *style;
-  cairo_t *cr;
 
   workspace_rect.x = x;
   workspace_rect.y = y;
@@ -195,8 +194,9 @@ wnck_draw_workspace (GtkWidget                   *widget,
     state = GTK_STATE_NORMAL;
 
   style = gtk_widget_get_style (widget);
-  cr = gdk_cairo_create (drawable);
   
+  cairo_save (cr);
+
   if (workspace_background)
     {
       gdk_cairo_set_source_pixbuf (cr, workspace_background, x, y);
@@ -209,8 +209,6 @@ wnck_draw_workspace (GtkWidget                   *widget,
       cairo_fill (cr);
     }
 
-  cairo_destroy (cr);
-  
   i = 0;
   while (i < n_windows)
     {
@@ -221,11 +219,14 @@ wnck_draw_workspace (GtkWidget                   *widget,
                        screen_height, &workspace_rect, &winrect);
       
       draw_window (widget,
-                   drawable,
+                   cr,
                    win,
                    &winrect,
                    state);
       
       ++i;
     }
+
+  cairo_restore (cr);
+  
 }
diff --git a/src/ui/draw-workspace.h b/src/ui/draw-workspace.h
index 10018aa..7aa0491 100644
--- a/src/ui/draw-workspace.h
+++ b/src/ui/draw-workspace.h
@@ -46,7 +46,7 @@ typedef struct
 } WnckWindowDisplayInfo;
 
 void wnck_draw_workspace (GtkWidget                   *widget,
-                          GdkDrawable                 *drawable,
+                          cairo_t                     *cr,
                           int                          x,
                           int                          y,
                           int                          width,
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c
index a7c1ee5..face14c 100644
--- a/src/ui/tabpopup.c
+++ b/src/ui/tabpopup.c
@@ -957,8 +957,10 @@ meta_select_workspace_expose_event (GtkWidget      *widget,
   window = gtk_widget_get_window (widget);
   gtk_widget_get_allocation (widget, &allocation);
 
+  cr = gdk_cairo_create (window);
+
   wnck_draw_workspace (widget,
-                       window,
+                       cr,
                        SELECT_OUTLINE_WIDTH,
                        SELECT_OUTLINE_WIDTH,
                        allocation.width - SELECT_OUTLINE_WIDTH * 2,
@@ -975,7 +977,6 @@ meta_select_workspace_expose_event (GtkWidget      *widget,
   if (META_SELECT_WORKSPACE (widget)->selected)
     {
       style = gtk_widget_get_style (widget);
-      cr = gdk_cairo_create (window);
 
       gdk_cairo_set_source_color (cr,
                                   &style->fg[gtk_widget_get_state (widget)]);
@@ -986,10 +987,10 @@ meta_select_workspace_expose_event (GtkWidget      *widget,
                        allocation.width - SELECT_OUTLINE_WIDTH,
                        allocation.height - SELECT_OUTLINE_WIDTH);
       cairo_stroke (cr);
-
-      cairo_destroy (cr);
     }
 
+  cairo_destroy (cr);
+
   return TRUE;
 }
 



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