From 266630304566ebeb5ed9666e46c8893ee16cc634 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 3 May 2012 21:33:40 -0400 Subject: [PATCH] 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 7c7690e71..c389f863c 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 7549a1e15..45bb340e6 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 6fb01a6ab..c799efc64 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;