[mutter/wip/cb2eb3: 41/55] frames: Support rendering layouts



commit 266630304566ebeb5ed9666e46c8893ee16cc634
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu May 3 21:33:40 2012 -0400

    frames: Support rendering layouts

 src/ui/frames.c        |    2 +-
 src/ui/theme-private.h |    3 ++-
 src/ui/theme.c         |   19 ++++++++++++++++---
 3 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 7c7690e..c389f86 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -616,7 +616,7 @@ meta_frames_render_background (MetaFrames *frames,
                  META_CORE_GET_END);
 
   meta_frames_calc_geometry (frames, frame, &fgeom);
-  meta_theme_render_background (frame->tv->style_context, cr, flags, &fgeom);
+  meta_theme_render_background (frame->tv->style_context, cr, flags, &fgeom, frame->layout);
 }
 
 /* The client rectangle surrounds client window; it subtracts both
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 7549a1e..45bb340 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -1012,7 +1012,8 @@ double meta_theme_get_title_scale (MetaTheme     *theme,
 void meta_theme_render_background (GtkStyleContext *style,
                                    cairo_t         *cr,
                                    MetaFrameFlags   flags,
-                                   const MetaFrameGeometry *fgeom);
+                                   const MetaFrameGeometry *fgeom,
+                                   PangoLayout     *title_layout);
 
 void meta_theme_draw_frame (MetaTheme              *theme,
                             GtkWidget              *widget,
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 6fb01a6..c799efc 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -4083,7 +4083,8 @@ void
 meta_theme_render_background (GtkStyleContext *style_gtk,
                               cairo_t         *cr,
                               MetaFrameFlags   flags,
-                              const MetaFrameGeometry *fgeom)
+                              const MetaFrameGeometry *fgeom,
+                              PangoLayout     *title_layout)
 {
   GdkRectangle visible_rect;
   const MetaFrameBorders *borders;
@@ -4111,6 +4112,19 @@ meta_theme_render_background (GtkStyleContext *style_gtk,
                     visible_rect.width,
                     visible_rect.height);
 
+  if (title_layout != NULL)
+    {
+      PangoRectangle title_rect;
+
+      pango_layout_get_pixel_extents (title_layout,
+                                      NULL, &title_rect);
+
+      gtk_render_layout (style_gtk, cr,
+                         borders->invisible.left + fgeom->width / 2.0 - title_rect.width / 2.0,
+                         borders->invisible.top + borders->visible.top / 2.0 - title_rect.height / 2.0,
+                         title_layout);
+    }
+
   gtk_style_context_restore (style_gtk);
 }
 
@@ -4128,7 +4142,7 @@ meta_frame_style_draw_with_style (MetaFrameStyle          *style,
                                   GdkPixbuf               *mini_icon,
                                   GdkPixbuf               *icon)
 {
-  meta_theme_render_background (style_gtk, cr, flags, fgeom);
+  meta_theme_render_background (style_gtk, cr, flags, fgeom, title_layout);
 
 #if 0
   int i, j;
@@ -4138,7 +4152,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle          *style,
   GdkRectangle bottom_titlebar_edge;
   GdkRectangle top_titlebar_edge;
   GdkRectangle left_edge, right_edge, bottom_edge;
-  PangoRectangle logical_rect;
   MetaDrawInfo draw_info;
 
   titlebar_rect.x = visible_rect.x;


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