[mutter] theme: Consider minimum sizes
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] theme: Consider minimum sizes
- Date: Thu, 21 Jan 2016 22:12:12 +0000 (UTC)
commit d5b69bcd542b759af661de2caa5a0e7fe6901e9f
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jan 14 15:25:49 2016 +0100
theme: Consider minimum sizes
GTK+ improved its CSS support, and the default theme started to make
use of it, so we must update our theming code accordingly. Start by
supporting min-width/min-height where it makes sense.
configure.ac | 2 +-
src/ui/theme-private.h | 5 +++++
src/ui/theme.c | 28 ++++++++++++++++++++++++----
3 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ca4c1b4..89f344c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,7 +59,7 @@ CANBERRA_GTK_VERSION=0.26
CLUTTER_PACKAGE=clutter-1.0
MUTTER_PC_MODULES="
- gtk+-3.0 >= 3.19.1
+ gtk+-3.0 >= 3.19.7
gio-unix-2.0 >= 2.35.1
pango >= 1.2.0
cairo >= 1.10.0
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 61d151d..ea3c532 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;
+ /** Min size of titlebar region */
+ GtkRequisition titlebar_min_size;
+ /** Min size of titlebar buttons */
+ GtkRequisition button_min_size;
+
/** Size of images in buttons */
guint icon_size;
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 1f33c3e..7d7cef0 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -80,9 +80,10 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
if (!layout->has_title)
text_height = 0;
- buttons_height = layout->icon_size +
+ buttons_height = MAX ((int)layout->icon_size, layout->button_min_size.height) +
layout->button_border.top + layout->button_border.bottom;
- content_height = MAX (buttons_height, text_height) +
+ 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;
borders->visible.top = layout->frame_border.top + content_height;
@@ -235,6 +236,16 @@ get_padding_and_border (GtkStyleContext *style,
}
static void
+get_min_size (GtkStyleContext *style,
+ GtkRequisition *requisition)
+{
+ gtk_style_context_get (style, gtk_style_context_get_state (style),
+ "min-width", &requisition->width,
+ "min-height", &requisition->height,
+ NULL);
+}
+
+static void
scale_border (GtkBorder *border,
double factor)
{
@@ -251,6 +262,7 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
{
GtkStyleContext *style;
GtkBorder border;
+ GtkRequisition requisition;
int border_radius, max_radius;
meta_style_info_set_flags (style_info, flags);
@@ -281,14 +293,17 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
max_radius = MIN (layout->frame_border.bottom, layout->frame_border.right);
layout->bottom_right_corner_rounded_radius = MAX (border_radius, max_radius);
+ get_min_size (style, &layout->titlebar_min_size);
get_padding_and_border (style, &layout->titlebar_border);
scale_border (&layout->titlebar_border, 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);
style = style_info->styles[META_STYLE_ELEMENT_IMAGE];
+ get_min_size (style, &requisition);
get_padding_and_border (style, &border);
scale_border (&border, layout->title_scale);
@@ -296,6 +311,11 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
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,
+ requisition.height);
}
static void
@@ -359,9 +379,9 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
(fgeom->content_border.right + borders.invisible.right);
content_height = borders.visible.top - fgeom->content_border.top - fgeom->content_border.bottom;
- button_width = layout->icon_size +
+ button_width = MAX ((int)layout->icon_size, layout->button_min_size.width) +
layout->button_border.left + layout->button_border.right;
- button_height = layout->icon_size +
+ button_height = MAX ((int)layout->icon_size, layout->button_min_size.height) +
layout->button_border.top + layout->button_border.bottom;
button_width *= scale;
button_height *= scale;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]