diff options
author | Florian Müllner <fmuellner@gnome.org> | 2016-01-14 17:32:46 +0100 |
---|---|---|
committer | Florian Müllner <fmuellner@gnome.org> | 2016-01-21 23:04:22 +0100 |
commit | e0ffef06dd810ff5acb54605f05f95133541151b (patch) | |
tree | 71c0b587ce77edd5ef32c32e47ba278945925d24 /src/ui | |
parent | d5b69bcd542b759af661de2caa5a0e7fe6901e9f (diff) | |
download | mutter-e0ffef06dd810ff5acb54605f05f95133541151b.tar.gz |
theme: Support margins on titlebar title/buttons
GTK+ improved its CSS support, and the default theme started to make
use of it, so we must update our theming code accordingly. Add support
for margins where they make sense.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/theme-private.h | 5 | ||||
-rw-r--r-- | src/ui/theme.c | 32 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h index ea3c53232..c27c3f99a 100644 --- a/src/ui/theme-private.h +++ b/src/ui/theme-private.h @@ -60,6 +60,11 @@ struct _MetaFrameLayout /** Border/padding of titlebar buttons */ GtkBorder button_border; + /** Margin of title */ + GtkBorder title_margin; + /** Margin of titlebar buttons */ + GtkBorder button_margin; + /** Min size of titlebar region */ GtkRequisition titlebar_min_size; /** Min size of titlebar buttons */ diff --git a/src/ui/theme.c b/src/ui/theme.c index 7d7cef010..c33d086e9 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -79,9 +79,12 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout, if (!layout->has_title) text_height = 0; + else + text_height = layout->title_margin.top + text_height + layout->title_margin.bottom; buttons_height = MAX ((int)layout->icon_size, layout->button_min_size.height) + - layout->button_border.top + layout->button_border.bottom; + layout->button_margin.top + layout->button_border.top + + layout->button_margin.bottom + layout->button_border.bottom; content_height = MAX (buttons_height, text_height); content_height = MAX (content_height, layout->titlebar_min_size.height) + layout->titlebar_border.top + layout->titlebar_border.bottom; @@ -297,10 +300,18 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout, get_padding_and_border (style, &layout->titlebar_border); scale_border (&layout->titlebar_border, layout->title_scale); + style = style_info->styles[META_STYLE_ELEMENT_TITLE]; + gtk_style_context_get_margin (style, gtk_style_context_get_state (style), + &layout->title_margin); + scale_border (&layout->title_margin, layout->title_scale); + style = style_info->styles[META_STYLE_ELEMENT_BUTTON]; get_min_size (style, &layout->button_min_size); get_padding_and_border (style, &layout->button_border); scale_border (&layout->button_border, layout->title_scale); + gtk_style_context_get_margin (style, gtk_style_context_get_state (style), + &layout->button_margin); + scale_border (&layout->button_margin, layout->title_scale); style = style_info->styles[META_STYLE_ELEMENT_IMAGE]; get_min_size (style, &requisition); @@ -312,6 +323,13 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout, layout->button_border.top += border.top; layout->button_border.bottom += border.bottom; + gtk_style_context_get_margin (style, gtk_style_context_get_state (style), + &border); + layout->button_border.left += border.left; + layout->button_border.right += border.right; + layout->button_border.top += border.top; + layout->button_border.bottom += border.bottom; + layout->button_min_size.width = MAX(layout->button_min_size.width, requisition.width); layout->button_min_size.height = MAX(layout->button_min_size.height, @@ -442,11 +460,15 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout, space_used_by_buttons = 0; + space_used_by_buttons += layout->button_margin.left * scale * n_left; space_used_by_buttons += button_width * n_left; + space_used_by_buttons += layout->button_margin.right * scale * n_left; space_used_by_buttons += (button_width * 0.75) * n_left_spacers; space_used_by_buttons += layout->titlebar_spacing * scale * MAX (n_left - 1, 0); + space_used_by_buttons += layout->button_margin.left * scale * n_right; space_used_by_buttons += button_width * n_right; + space_used_by_buttons += layout->button_margin.right * scale * n_right; space_used_by_buttons += (button_width * 0.75) * n_right_spacers; space_used_by_buttons += layout->titlebar_spacing * scale * MAX (n_right - 1, 0); @@ -516,6 +538,8 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout, if (x < 0) /* if we go negative, leave the buttons we don't get to as 0-width */ break; + x -= layout->button_margin.right * scale; + rect = right_func_rects[i]; rect->visible.x = x - button_width; if (right_buttons_has_spacer[i]) @@ -541,7 +565,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout, else g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable)); - x = rect->visible.x; + x = rect->visible.x - layout->button_margin.left * scale; if (i > 0) x -= layout->titlebar_spacing; @@ -560,6 +584,8 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout, { MetaButtonSpace *rect; + x += layout->button_margin.left * scale; + rect = left_func_rects[i]; rect->visible.x = x; @@ -586,7 +612,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout, else g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable)); - x = rect->visible.x + rect->visible.width; + x = rect->visible.x + rect->visible.width + layout->button_margin.right * scale; if (i < n_left - 1) x += layout->titlebar_spacing * scale; if (left_buttons_has_spacer[i]) |