[mutter] theme: Get rid of x/y_offset usage when drawing frames



commit b265e8099a954b26c0de97f400f4f45ce54a9487
Author: Benjamin Otte <otte redhat com>
Date:   Mon Sep 27 13:55:28 2010 +0200

    theme: Get rid of x/y_offset usage when drawing frames
    
    Commit aa65f94c672df8cc345575269d7e9dedf0e7ef24 that started passing
    cairo_t around broke offsets. Since passing cairo_t makes them
    unnecessary, this patches removes them rather than fixing them.
    
    This patch changes API.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630203

 src/ui/frames.c         |   18 +++++++-----------
 src/ui/preview-widget.c |    5 +++--
 src/ui/theme-viewer.c   |    1 -
 src/ui/theme.c          |   20 ++------------------
 src/ui/theme.h          |   10 ----------
 5 files changed, 12 insertions(+), 42 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 4bfbc34..1e638c1 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -83,9 +83,7 @@ static void meta_frames_attach_style (MetaFrames  *frames,
 
 static void meta_frames_paint        (MetaFrames   *frames,
                                       MetaUIFrame  *frame,
-                                      cairo_t      *cr,
-                                      int           x_offset,
-                                      int           y_offset);
+                                      cairo_t      *cr);
 
 static void meta_frames_set_window_background (MetaFrames   *frames,
                                                MetaUIFrame  *frame);
@@ -2112,11 +2110,12 @@ generate_pixmap (MetaFrames *frames,
                             rect->width, rect->height);
   
   cr = meta_pixmap_cairo_create (result);
+  cairo_translate (cr, -rect->x, -rect->y);
 
-  setup_bg_cr (cr, frame->window, rect->x, rect->y);
+  setup_bg_cr (cr, frame->window, 0, 0);
   cairo_paint (cr);
 
-  meta_frames_paint (frames, frame, cr, -rect->x, -rect->y);
+  meta_frames_paint (frames, frame, cr);
 
   cairo_destroy (cr);
 
@@ -2341,7 +2340,7 @@ meta_frames_draw (GtkWidget *widget,
 
       cairo_push_group (cr);
 
-      meta_frames_paint (frames, frame, cr, 0, 0);
+      meta_frames_paint (frames, frame, cr);
 
       cairo_pop_group_to_source (cr);
       cairo_paint (cr);
@@ -2405,7 +2404,7 @@ meta_frames_expose_event (GtkWidget           *widget,
       /* no need to clip, begin_paint_region ensures the pixmap
        * is only as big as the rect we use. */
 
-      meta_frames_paint (frames, frame, cr, 0, 0);
+      meta_frames_paint (frames, frame, cr);
 
       cairo_destroy (cr);
       gdk_window_end_paint (event->window);
@@ -2424,9 +2423,7 @@ meta_frames_expose_event (GtkWidget           *widget,
 static void
 meta_frames_paint (MetaFrames   *frames,
                    MetaUIFrame  *frame,
-                   cairo_t      *cr,
-                   int           x_offset,
-                   int           y_offset)
+                   cairo_t      *cr)
 {
   GtkWidget *widget;
   MetaFrameFlags flags;
@@ -2556,7 +2553,6 @@ meta_frames_paint (MetaFrames   *frames,
                                     frame->style,
                                     widget,
                                     cr,
-                                    x_offset, y_offset,
                                     type,
                                     flags,
                                     w, h,
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index f49c970..27eb2f9 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -233,8 +233,10 @@ meta_preview_expose (GtkWidget      *widget,
       };
   
       ensure_info (preview);
+      cairo_save (cr);
 
       border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+      cairo_translate (cr, border_width, border_width);
 
       client_width = allocation.width - preview->left_width - preview->right_width - border_width * 2;
       client_height = allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
@@ -247,8 +249,6 @@ meta_preview_expose (GtkWidget      *widget,
       meta_theme_draw_frame (preview->theme,
                              widget,
                              cr,
-                             border_width,
-                             border_width,
                              preview->type,
                              preview->flags,
                              client_width, client_height,
@@ -259,6 +259,7 @@ meta_preview_expose (GtkWidget      *widget,
                              meta_preview_get_mini_icon (),
                              meta_preview_get_icon ());
 
+      cairo_restore (cr);
     }
 
 #ifdef USE_GTK3
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index e7cd29c..4e6fe3e 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -1016,7 +1016,6 @@ run_theme_benchmark (void)
       meta_theme_draw_frame (global_theme,
                              widget,
                              cr,
-                             0, 0,
                              META_FRAME_TYPE_NORMAL,
                              get_flags (widget),
                              client_width, client_height,
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 0e308a5..c94cf6b 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -4358,8 +4358,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle          *style,
                                   GtkStyle                *style_gtk,
                        GtkWidget               *widget,
                        cairo_t                 *cr,
-                       int                      x_offset,
-                       int                      y_offset,
                        const MetaFrameGeometry *fgeom,
                        int                      client_width,
                        int                      client_height,
@@ -4546,9 +4544,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle          *style,
             {
               button_rect (j, fgeom, middle_bg_offset, &rect);
               
-              rect.x += x_offset;
-              rect.y += y_offset;
-              
               op_list = get_button (style, j, button_states[j]);
               
               if (op_list)
@@ -4598,8 +4593,6 @@ void
 meta_frame_style_draw (MetaFrameStyle          *style,
                        GtkWidget               *widget,
                        cairo_t                 *cr,
-                       int                      x_offset,
-                       int                      y_offset,
                        const MetaFrameGeometry *fgeom,
                        int                      client_width,
                        int                      client_height,
@@ -4610,8 +4603,7 @@ meta_frame_style_draw (MetaFrameStyle          *style,
                        GdkPixbuf               *icon)
 {
   meta_frame_style_draw_with_style (style, gtk_widget_get_style (widget), widget,
-                                    cr, x_offset, y_offset,
-                                    fgeom, client_width, client_height,
+                                    cr, fgeom, client_width, client_height,
                                     title_layout, text_height,
                                     button_states, mini_icon, icon);
 }
@@ -5181,8 +5173,6 @@ meta_theme_draw_frame_with_style (MetaTheme              *theme,
                                   GtkStyle               *style_gtk,
                        GtkWidget              *widget,
                        cairo_t                *cr,
-                       int                     x_offset,
-                       int                     y_offset,
                        MetaFrameType           type,
                        MetaFrameFlags          flags,
                        int                     client_width,
@@ -5217,7 +5207,6 @@ meta_theme_draw_frame_with_style (MetaTheme              *theme,
                                     style_gtk,
                                     widget,
                                     cr,
-                                    x_offset, y_offset,
                                     &fgeom,
                                     client_width, client_height,
                                     title_layout,
@@ -5230,8 +5219,6 @@ void
 meta_theme_draw_frame (MetaTheme              *theme,
                        GtkWidget              *widget,
                        cairo_t                *cr,
-                       int                     x_offset,
-                       int                     y_offset,
                        MetaFrameType           type,
                        MetaFrameFlags          flags,
                        int                     client_width,
@@ -5244,7 +5231,7 @@ meta_theme_draw_frame (MetaTheme              *theme,
                        GdkPixbuf              *icon)
 {
   meta_theme_draw_frame_with_style (theme, gtk_widget_get_style (widget), widget,
-                                    cr, x_offset, y_offset, type,flags,
+                                    cr, type,flags,
                                     client_width, client_height,
                                     title_layout, text_height,
                                     button_layout, button_states,
@@ -5255,8 +5242,6 @@ void
 meta_theme_draw_frame_by_name (MetaTheme              *theme,
                                GtkWidget              *widget,
                                cairo_t                *cr,
-                               int                     x_offset,
-                               int                     y_offset,
                                const gchar             *style_name,
                                MetaFrameFlags          flags,
                                int                     client_width,
@@ -5288,7 +5273,6 @@ meta_theme_draw_frame_by_name (MetaTheme              *theme,
   meta_frame_style_draw (style,
                          widget,
                          cr,
-                         x_offset, y_offset,
                          &fgeom,
                          client_width, client_height,
                          title_layout,
diff --git a/src/ui/theme.h b/src/ui/theme.h
index cedbc12..af1f832 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -1010,8 +1010,6 @@ void            meta_frame_style_unref (MetaFrameStyle *style);
 void meta_frame_style_draw (MetaFrameStyle          *style,
                             GtkWidget               *widget,
                             cairo_t                 *cr,
-                            int                      x_offset,
-                            int                      y_offset,
                             const MetaFrameGeometry *fgeom,
                             int                      client_width,
                             int                      client_height,
@@ -1026,8 +1024,6 @@ void meta_frame_style_draw_with_style (MetaFrameStyle          *style,
                                        GtkStyle                *style_gtk,
                                        GtkWidget               *widget,
                                        cairo_t                 *cr,
-                                       int                      x_offset,
-                                       int                      y_offset,
                                        const MetaFrameGeometry *fgeom,
                                        int                      client_width,
                                        int                      client_height,
@@ -1073,8 +1069,6 @@ double meta_theme_get_title_scale (MetaTheme     *theme,
 void meta_theme_draw_frame (MetaTheme              *theme,
                             GtkWidget              *widget,
                             cairo_t                *cr,
-                            int                     x_offset,
-                            int                     y_offset,
                             MetaFrameType           type,
                             MetaFrameFlags          flags,
                             int                     client_width,
@@ -1089,8 +1083,6 @@ void meta_theme_draw_frame (MetaTheme              *theme,
 void meta_theme_draw_frame_by_name (MetaTheme              *theme,
                                     GtkWidget              *widget,
                                     cairo_t                *cr,
-                                    int                     x_offset,
-                                    int                     y_offset,
                                     const gchar             *style_name,
                                     MetaFrameFlags          flags,
                                     int                     client_width,
@@ -1106,8 +1098,6 @@ void meta_theme_draw_frame_with_style (MetaTheme              *theme,
                                        GtkStyle               *style_gtk,
                                        GtkWidget              *widget,
                                        cairo_t                *cr,
-                                       int                     x_offset,
-                                       int                     y_offset,
                                        MetaFrameType           type,
                                        MetaFrameFlags          flags,
                                        int                     client_width,



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