summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2016-02-07 15:43:07 +0200
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2016-02-07 18:29:48 +0200
commita75484ee331504a9902ee565e619c09472721af3 (patch)
tree6ec9b3f443b39e3575596036ba496a66ebc8c256
parentcb43d2c915c6b4176ac02d4e77ce2485245cc2b6 (diff)
downloadmetacity-a75484ee331504a9902ee565e619c09472721af3.tar.gz
libmetacity: add substructures to MetaFrameLayout
Add gtk and metacity substructures to MetaFrameLayout. Move GTK+ or Metacity only variables to these substructures. This commit also adapts changes from this mutter commit: https://git.gnome.org/browse/mutter/commit/?id=6b92b45021773b93c008aafb4fcd24167784b0d6
-rw-r--r--libmetacity/meta-frame-layout.c105
-rw-r--r--libmetacity/meta-frame-layout.h111
-rw-r--r--libmetacity/meta-theme-gtk.c150
-rw-r--r--libmetacity/meta-theme-metacity.c109
-rw-r--r--libmetacity/meta-theme.h6
5 files changed, 257 insertions, 224 deletions
diff --git a/libmetacity/meta-frame-layout.c b/libmetacity/meta-frame-layout.c
index 27d75154..ce63243b 100644
--- a/libmetacity/meta-frame-layout.c
+++ b/libmetacity/meta-frame-layout.c
@@ -61,9 +61,7 @@ validate_border (const GtkBorder *border,
* MetaFrameLayout is created, all its integer fields are set to -1
* by meta_frame_layout_new(). After an instance of this type
* should have been initialised, this function checks that
- * a given field is not still at -1. It is never called directly, but
- * rather via the CHECK_GEOMETRY_VALUE and CHECK_GEOMETRY_BORDER
- * macros.
+ * a given field is not still at -1.
*
* \param val The value to check
* \param name The name to use in the error message
@@ -120,38 +118,38 @@ meta_frame_layout_new (void)
layout->refcount = 1;
+ /* Spacing as hardcoded in GTK+:
+ * https://git.gnome.org/browse/gtk+/tree/gtk/gtkheaderbar.c?h=gtk-3-14#n53
+ */
+ layout->gtk.titlebar_spacing = 6;
+ layout->gtk.icon_size = 16; /* was META_MINI_ICON_WIDTH from common.h */
+
/* Fill with -1 values to detect invalid themes */
- layout->left_width = -1;
- layout->right_width = -1;
- layout->top_height = 0; /* only used by GTK+ theme */
- layout->bottom_height = -1;
+ layout->metacity.left_width = -1;
+ layout->metacity.right_width = -1;
+ layout->metacity.bottom_height = -1;
+
+ init_border (&layout->metacity.title_border);
+
+ layout->metacity.title_vertical_pad = -1;
+
+ layout->metacity.right_titlebar_edge = -1;
+ layout->metacity.left_titlebar_edge = -1;
+
+ layout->metacity.button_sizing = META_BUTTON_SIZING_LAST;
+ layout->metacity.button_aspect = 1.0;
+ layout->metacity.button_width = -1;
+ layout->metacity.button_height = -1;
layout->invisible_border.left = 10;
layout->invisible_border.right = 10;
layout->invisible_border.bottom = 10;
layout->invisible_border.top = 10;
- init_border (&layout->title_border);
-
- layout->title_vertical_pad = -1;
-
- layout->right_titlebar_edge = -1;
- layout->left_titlebar_edge = -1;
-
- layout->button_sizing = META_BUTTON_SIZING_LAST;
- layout->button_aspect = 1.0;
- layout->button_width = -1;
- layout->button_height = -1;
+ init_border (&layout->button_border);
- /* Spacing as hardcoded in GTK+:
- * https://git.gnome.org/browse/gtk+/tree/gtk/gtkheaderbar.c?h=gtk-3-14#n53
- */
- layout->titlebar_spacing = 6;
layout->has_title = TRUE;
- layout->title_scale = 1.0;
- layout->icon_size = 16; /* was META_MINI_ICON_WIDTH from common.h */
-
- init_border (&layout->button_border);
+ layout->title_scale = PANGO_SCALE_MEDIUM;
return layout;
}
@@ -196,37 +194,56 @@ meta_frame_layout_validate (const MetaFrameLayout *layout,
{
g_return_val_if_fail (layout != NULL, FALSE);
-#define CHECK_GEOMETRY_VALUE(vname) if (!validate_geometry_value (layout->vname, #vname, error)) return FALSE
+ if (!validate_geometry_value (layout->metacity.left_width,
+ "left_width", error))
+ return FALSE;
+
+ if (!validate_geometry_value (layout->metacity.right_width,
+ "right_width", error))
+ return FALSE;
-#define CHECK_GEOMETRY_BORDER(bname) if (!validate_geometry_border (&layout->bname, #bname, error)) return FALSE
+ if (!validate_geometry_value (layout->metacity.bottom_height,
+ "bottom_height", error))
+ return FALSE;
- CHECK_GEOMETRY_VALUE (left_width);
- CHECK_GEOMETRY_VALUE (right_width);
- CHECK_GEOMETRY_VALUE (bottom_height);
+ if (!validate_geometry_border (&layout->metacity.title_border,
+ "title_border", error))
+ return FALSE;
- CHECK_GEOMETRY_BORDER (title_border);
+ if (!validate_geometry_value (layout->metacity.title_vertical_pad,
+ "title_vertical_pad", error))
+ return FALSE;
- CHECK_GEOMETRY_VALUE (title_vertical_pad);
+ if (!validate_geometry_value (layout->metacity.right_titlebar_edge,
+ "right_titlebar_edge", error))
+ return FALSE;
- CHECK_GEOMETRY_VALUE (right_titlebar_edge);
- CHECK_GEOMETRY_VALUE (left_titlebar_edge);
+ if (!validate_geometry_value (layout->metacity.left_titlebar_edge,
+ "left_titlebar_edge", error))
+ return FALSE;
- switch (layout->button_sizing)
+ switch (layout->metacity.button_sizing)
{
case META_BUTTON_SIZING_ASPECT:
- if (layout->button_aspect < (0.1) || layout->button_aspect > (15.0))
+ if (layout->metacity.button_aspect < (0.1) ||
+ layout->metacity.button_aspect > (15.0))
{
g_set_error (error, META_THEME_ERROR,
META_THEME_ERROR_FRAME_GEOMETRY,
_("Button aspect ratio %g is not reasonable"),
- layout->button_aspect);
+ layout->metacity.button_aspect);
return FALSE;
}
break;
case META_BUTTON_SIZING_FIXED:
- CHECK_GEOMETRY_VALUE (button_width);
- CHECK_GEOMETRY_VALUE (button_height);
+ if (!validate_geometry_value (layout->metacity.button_width,
+ "button_width", error))
+ return FALSE;
+
+ if (!validate_geometry_value (layout->metacity.button_height,
+ "button_height", error))
+ return FALSE;
break;
case META_BUTTON_SIZING_LAST:
default:
@@ -236,7 +253,13 @@ meta_frame_layout_validate (const MetaFrameLayout *layout,
return FALSE;
}
- CHECK_GEOMETRY_BORDER (button_border);
+ if (!validate_geometry_border (&layout->metacity.title_border,
+ "title_border", error))
+ return FALSE;
+
+ if (!validate_geometry_border (&layout->button_border,
+ "button_border", error))
+ return FALSE;
return TRUE;
}
diff --git a/libmetacity/meta-frame-layout.h b/libmetacity/meta-frame-layout.h
index 015eed7c..934c65b2 100644
--- a/libmetacity/meta-frame-layout.h
+++ b/libmetacity/meta-frame-layout.h
@@ -51,65 +51,72 @@ typedef enum
**/
struct _MetaFrameLayout
{
- /** Reference count. */
- int refcount;
-
- /** Size of left side */
- int left_width;
- /** Size of right side */
- int right_width;
- /** Size of top side */
- int top_height;
- /** Size of bottom side */
- int bottom_height;
+ gint refcount;
+
+ struct {
+ /** Border/padding of the entire frame */
+ GtkBorder frame_border;
+ /** Border/padding of the titlebar region */
+ GtkBorder titlebar_border;
+ /** Border/padding of titlebar buttons */
+
+ /** Size of images in buttons */
+ guint icon_size;
+
+ /** Space between titlebar elements */
+ guint titlebar_spacing;
+ } gtk;
+
+ struct {
+ /** Size of left side */
+ gint left_width;
+ /** Size of right side */
+ gint right_width;
+ /** Size of bottom side */
+ gint bottom_height;
+
+ /** Border of blue title region
+ * \bug (blue?!)
+ **/
+ GtkBorder title_border;
+
+ /** Extra height for inside of title region, above the font height */
+ int title_vertical_pad;
+
+ /** Right indent of buttons from edges of frame */
+ int right_titlebar_edge;
+ /** Left indent of buttons from edges of frame */
+ int left_titlebar_edge;
+
+ /**
+ * Sizing rule of buttons, either META_BUTTON_SIZING_ASPECT
+ * (in which case button_aspect will be honoured, and
+ * button_width and button_height set from it), or
+ * META_BUTTON_SIZING_FIXED (in which case we read the width
+ * and height directly).
+ */
+ MetaButtonSizing button_sizing;
+
+ /**
+ * Ratio of height/width. Honoured only if
+ * button_sizing==META_BUTTON_SIZING_ASPECT.
+ * Otherwise we figure out the height from the button_border.
+ */
+ double button_aspect;
+
+ /** Width of a button; set even when we are using aspect sizing */
+ gint button_width;
+
+ /** Height of a button; set even when we are using aspect sizing */
+ gint button_height;
+ } metacity;
/** Invisible border */
GtkBorder invisible_border;
- /** Border of blue title region
- * \bug (blue?!)
- **/
- GtkBorder title_border;
-
- /** Extra height for inside of title region, above the font height */
- int title_vertical_pad;
-
- /** Right indent of buttons from edges of frame */
- int right_titlebar_edge;
- /** Left indent of buttons from edges of frame */
- int left_titlebar_edge;
-
- /**
- * Sizing rule of buttons, either META_BUTTON_SIZING_ASPECT
- * (in which case button_aspect will be honoured, and
- * button_width and button_height set from it), or
- * META_BUTTON_SIZING_FIXED (in which case we read the width
- * and height directly).
- */
- MetaButtonSizing button_sizing;
-
- /**
- * Ratio of height/width. Honoured only if
- * button_sizing==META_BUTTON_SIZING_ASPECT.
- * Otherwise we figure out the height from the button_border.
- */
- double button_aspect;
-
- /** Width of a button; set even when we are using aspect sizing */
- int button_width;
-
- /** Height of a button; set even when we are using aspect sizing */
- int button_height;
-
/** Space around buttons */
GtkBorder button_border;
- /** Size of images in buttons */
- guint icon_size;
-
- /** Space between titlebar elements */
- guint titlebar_spacing;
-
/** scale factor for title text */
double title_scale;
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c
index f2e8d9a1..31ba274d 100644
--- a/libmetacity/meta-theme-gtk.c
+++ b/libmetacity/meta-theme-gtk.c
@@ -195,28 +195,32 @@ frame_layout_sync_with_style (MetaFrameLayout *layout,
meta_style_info_set_flags (style_info, flags);
style = style_info->styles[META_STYLE_ELEMENT_DECORATION];
- get_padding_and_border (style, &border);
- scale_border (&border, layout->title_scale);
-
- layout->left_width = border.left;
- layout->right_width = border.right;
- layout->top_height = border.top;
- layout->bottom_height = border.bottom;
+ get_padding_and_border (style, &layout->gtk.frame_border);
+ scale_border (&layout->gtk.frame_border, layout->title_scale);
if (composited)
- get_margin (style, &layout->invisible_border);
+ {
+ /* With compositing manager: margin is resize area */
+ get_margin (style, &layout->invisible_border);
+ }
else
{
+ layout->invisible_border.top = 0;
+ layout->invisible_border.bottom = 0;
+ layout->invisible_border.left = 0;
+ layout->invisible_border.right = 0;
+
+ /* Without compositing manager: margin is part of border */
get_margin (style, &border);
- layout->left_width += border.left;
- layout->right_width += border.right;
- layout->top_height += border.top;
- layout->bottom_height += border.bottom;
+ layout->gtk.frame_border.left += border.left;
+ layout->gtk.frame_border.right += border.right;
+ layout->gtk.frame_border.top += border.top;
+ layout->gtk.frame_border.bottom += border.bottom;
}
if (layout->hide_buttons)
- layout->icon_size = 0;
+ layout->gtk.icon_size = 0;
if (!layout->has_title && layout->hide_buttons)
return; /* border-only - be done */
@@ -235,37 +239,27 @@ frame_layout_sync_with_style (MetaFrameLayout *layout,
*/
layout->top_left_corner_rounded_radius = border_radius;
layout->top_right_corner_rounded_radius = border_radius;
- max_radius = MIN (layout->bottom_height, layout->left_width);
+ max_radius = MIN (layout->gtk.frame_border.bottom, layout->gtk.frame_border.left);
layout->bottom_left_corner_rounded_radius = MAX (border_radius, max_radius);
- max_radius = MIN (layout->bottom_height, layout->right_width);
+ max_radius = MIN (layout->gtk.frame_border.bottom, layout->gtk.frame_border.left);
layout->bottom_right_corner_rounded_radius = MAX (border_radius, max_radius);
}
- get_padding_and_border (style, &border);
- scale_border (&border, layout->title_scale);
- layout->left_titlebar_edge = layout->left_width + border.left;
- layout->right_titlebar_edge = layout->right_width + border.right;
- layout->title_vertical_pad = border.top;
-
- layout->button_border.top = border.top;
- layout->button_border.bottom = border.bottom;
- layout->button_border.left = 0;
- layout->button_border.right = 0;
-
- layout->button_width = layout->icon_size;
- layout->button_height = layout->icon_size;
+ get_padding_and_border (style, &layout->gtk.titlebar_border);
+ scale_border (&layout->gtk.titlebar_border, layout->title_scale);
style = style_info->styles[META_STYLE_ELEMENT_BUTTON];
- get_padding_and_border (style, &border);
- scale_border (&border, layout->title_scale);
- layout->button_width += border.left + border.right;
- layout->button_height += border.top + border.bottom;
+ 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_padding_and_border (style, &border);
scale_border (&border, layout->title_scale);
- layout->button_width += border.left + border.right;
- layout->button_height += border.top + border.bottom;
+
+ layout->button_border.left += border.left;
+ layout->button_border.right += border.right;
+ layout->button_border.top += border.top;
+ layout->button_border.bottom += border.bottom;
}
static void
@@ -278,7 +272,8 @@ meta_theme_gtk_get_frame_borders (MetaThemeImpl *impl,
MetaFrameType type,
MetaFrameBorders *borders)
{
- int buttons_height, title_height;
+ gint buttons_height;
+ gint content_height;
frame_layout_sync_with_style (layout, style_info, composited, flags);
@@ -293,16 +288,17 @@ meta_theme_gtk_get_frame_borders (MetaThemeImpl *impl,
if (!layout->has_title)
text_height = 0;
- buttons_height = layout->button_height +
+ buttons_height = layout->gtk.icon_size +
layout->button_border.top + layout->button_border.bottom;
- title_height = text_height +
- layout->title_vertical_pad +
- layout->title_border.top + layout->title_border.bottom;
- borders->visible.top = layout->top_height + MAX (buttons_height, title_height);
- borders->visible.left = layout->left_width;
- borders->visible.right = layout->right_width;
- borders->visible.bottom = layout->bottom_height;
+ content_height = MAX (buttons_height, text_height) +
+ layout->gtk.titlebar_border.top +
+ layout->gtk.titlebar_border.bottom;
+
+ borders->visible.top = layout->gtk.frame_border.top + content_height;
+ borders->visible.left = layout->gtk.frame_border.left;
+ borders->visible.right = layout->gtk.frame_border.right;
+ borders->visible.bottom = layout->gtk.frame_border.bottom;
/* FIXME: invisible = MAX (margin, shadow) */
borders->invisible.left = layout->invisible_border.left;
@@ -465,6 +461,7 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
int button_y;
int title_right_edge;
int width, height;
+ int content_width, content_height;
int button_width, button_height;
int min_size_for_rounding;
@@ -482,7 +479,12 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
type, &borders);
fgeom->borders = borders;
- fgeom->top_height = layout->top_height;
+
+ fgeom->content_border = layout->gtk.frame_border;
+ fgeom->content_border.left += layout->gtk.titlebar_border.left;
+ fgeom->content_border.right += layout->gtk.titlebar_border.right;
+ fgeom->content_border.top += layout->gtk.titlebar_border.top;
+ fgeom->content_border.bottom += layout->gtk.titlebar_border.bottom;
width = client_width + borders.total.left + borders.total.right;
@@ -492,13 +494,15 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
fgeom->width = width;
fgeom->height = height;
- fgeom->top_titlebar_edge = layout->title_border.top;
- fgeom->bottom_titlebar_edge = layout->title_border.bottom;
- fgeom->left_titlebar_edge = layout->left_titlebar_edge;
- fgeom->right_titlebar_edge = layout->right_titlebar_edge;
+ content_width = width -
+ (fgeom->content_border.left + borders.invisible.left) -
+ (fgeom->content_border.right + borders.invisible.right);
+ content_height = borders.visible.top - fgeom->content_border.top - fgeom->content_border.bottom;
- button_width = layout->button_width;
- button_height = layout->button_height;
+ button_width = layout->gtk.icon_size +
+ layout->button_border.left + layout->button_border.right;
+ button_height = layout->gtk.icon_size +
+ layout->button_border.top + layout->button_border.bottom;
/* FIXME all this code sort of pretends that duplicate buttons
* with the same function are allowed, but that breaks the
@@ -551,21 +555,18 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
while (n_left > 0 || n_right > 0)
{
int space_used_by_buttons;
- int space_available;
-
- space_available = fgeom->width - layout->left_titlebar_edge - layout->right_titlebar_edge;
space_used_by_buttons = 0;
space_used_by_buttons += button_width * n_left;
space_used_by_buttons += (button_width * 0.75) * n_left_spacers;
- space_used_by_buttons += layout->titlebar_spacing * MAX (n_left - 1, 0);
+ space_used_by_buttons += layout->gtk.titlebar_spacing * MAX (n_left - 1, 0);
space_used_by_buttons += button_width * n_right;
space_used_by_buttons += (button_width * 0.75) * n_right_spacers;
- space_used_by_buttons += layout->titlebar_spacing * MAX (n_right - 1, 0);
+ space_used_by_buttons += layout->gtk.titlebar_spacing * MAX (n_right - 1, 0);
- if (space_used_by_buttons <= space_available)
+ if (space_used_by_buttons <= content_width)
break; /* Everything fits, bail out */
/* First try to remove separators */
@@ -629,11 +630,11 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
fgeom->n_right_buttons = n_right;
/* center buttons vertically */
- button_y = (borders.visible.top - fgeom->top_height -
- (button_height + layout->button_border.top + layout->button_border.bottom)) / 2 + layout->button_border.top + fgeom->top_height + borders.invisible.top;
+ button_y = fgeom->content_border.top + borders.invisible.top +
+ MAX(content_height - button_height, 0) / 2;
/* right edge of farthest-right button */
- x = width - layout->right_titlebar_edge - borders.invisible.right;
+ x = width - fgeom->content_border.right - borders.invisible.right;
i = n_right - 1;
while (i >= 0)
@@ -663,7 +664,7 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
rect->clickable.height = button_height;
if (i == n_right - 1)
- rect->clickable.width += layout->right_titlebar_edge + layout->right_width;
+ rect->clickable.width += fgeom->content_border.right;
}
else
g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
@@ -671,18 +672,18 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
x = rect->visible.x;
if (i > 0)
- x -= layout->titlebar_spacing;
+ x -= layout->gtk.titlebar_spacing;
--i;
}
/* save right edge of titlebar for later use */
- title_right_edge = x - layout->title_border.right;
+ title_right_edge = x;
/* Now x changes to be position from the left and we go through
* the left-side buttons
*/
- x = layout->left_titlebar_edge + borders.invisible.left;
+ x = fgeom->content_border.left + borders.invisible.left;
for (i = 0; i < n_left; i++)
{
MetaButtonSpace *rect;
@@ -706,18 +707,17 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
x = rect->visible.x + rect->visible.width;
if (i < n_left - 1)
- x += layout->titlebar_spacing;
+ x += layout->gtk.titlebar_spacing;
if (left_buttons_has_spacer[i])
x += (button_width * 0.75);
}
- /* We always fill as much vertical space as possible with title rect,
- * rather than centering it like the buttons
- */
- fgeom->title_rect.x = x + layout->title_border.left;
- fgeom->title_rect.y = layout->title_border.top + borders.invisible.top;
+ /* Center vertically in the available content area */
+ fgeom->title_rect.x = x;
+ fgeom->title_rect.y = fgeom->content_border.top + borders.invisible.top +
+ (content_height - text_height) / 2;
fgeom->title_rect.width = title_right_edge - fgeom->title_rect.x;
- fgeom->title_rect.height = borders.visible.top - layout->title_border.top - layout->title_border.bottom;
+ fgeom->title_rect.height = text_height;
/* Nuke title if it won't fit */
if (fgeom->title_rect.width < 0 ||
@@ -799,9 +799,9 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
visible_rect.width, visible_rect.height);
titlebar_rect.x = visible_rect.x + borders->visible.left;
- titlebar_rect.y = visible_rect.y + fgeom->top_height;
+ titlebar_rect.y = visible_rect.y + fgeom->content_border.top;
titlebar_rect.width = visible_rect.width - borders->visible.left - borders->visible.right;
- titlebar_rect.height = borders->visible.top - fgeom->top_height;
+ titlebar_rect.height = borders->visible.top - fgeom->content_border.top;
context = style_info->styles[META_STYLE_ELEMENT_TITLEBAR];
gtk_render_background (context, cr,
@@ -919,7 +919,7 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
GtkIconTheme *theme = gtk_icon_theme_get_default ();
GtkIconInfo *info;
- info = gtk_icon_theme_lookup_icon (theme, icon_name, style->layout->icon_size, 0);
+ info = gtk_icon_theme_lookup_icon (theme, icon_name, style->layout->gtk.icon_size, 0);
pixbuf = gtk_icon_info_load_symbolic_for_context (info, context, NULL, NULL);
}
@@ -935,8 +935,8 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl,
cairo_translate (cr, x, y);
cairo_scale (cr,
- width / style->layout->icon_size,
- height / style->layout->icon_size);
+ width / style->layout->gtk.icon_size,
+ height / style->layout->gtk.icon_size);
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
cairo_paint (cr);
diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c
index 0140eeec..e42e78c4 100644
--- a/libmetacity/meta-theme-metacity.c
+++ b/libmetacity/meta-theme-metacity.c
@@ -1434,16 +1434,16 @@ parse_aspect_ratio (GMarkupParseContext *context,
if (strcmp (name, "button") == 0)
{
- info->layout->button_aspect = val;
+ info->layout->metacity.button_aspect = val;
- if (info->layout->button_sizing != META_BUTTON_SIZING_LAST)
+ if (info->layout->metacity.button_sizing != META_BUTTON_SIZING_LAST)
{
set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
_("Cannot specify both 'button_width'/'button_height' and 'aspect_ratio' for buttons"));
return;
}
- info->layout->button_sizing = META_BUTTON_SIZING_ASPECT;
+ info->layout->metacity.button_sizing = META_BUTTON_SIZING_ASPECT;
}
else
{
@@ -1503,7 +1503,7 @@ parse_border (GMarkupParseContext *context,
border = NULL;
if (strcmp (name, "title_border") == 0)
- border = &info->layout->title_border;
+ border = &info->layout->metacity.title_border;
else if (strcmp (name, "button_border") == 0)
border = &info->layout->button_border;
@@ -1546,44 +1546,44 @@ parse_distance (GMarkupParseContext *context,
g_assert (info->layout);
if (strcmp (name, "left_width") == 0)
- info->layout->left_width = val;
+ info->layout->metacity.left_width = val;
else if (strcmp (name, "right_width") == 0)
- info->layout->right_width = val;
+ info->layout->metacity.right_width = val;
else if (strcmp (name, "bottom_height") == 0)
- info->layout->bottom_height = val;
+ info->layout->metacity.bottom_height = val;
else if (strcmp (name, "title_vertical_pad") == 0)
- info->layout->title_vertical_pad = val;
+ info->layout->metacity.title_vertical_pad = val;
else if (strcmp (name, "right_titlebar_edge") == 0)
- info->layout->right_titlebar_edge = val;
+ info->layout->metacity.right_titlebar_edge = val;
else if (strcmp (name, "left_titlebar_edge") == 0)
- info->layout->left_titlebar_edge = val;
+ info->layout->metacity.left_titlebar_edge = val;
else if (strcmp (name, "button_width") == 0)
{
- info->layout->button_width = val;
+ info->layout->metacity.button_width = val;
- if (!(info->layout->button_sizing == META_BUTTON_SIZING_LAST ||
- info->layout->button_sizing == META_BUTTON_SIZING_FIXED))
+ if (!(info->layout->metacity.button_sizing == META_BUTTON_SIZING_LAST ||
+ info->layout->metacity.button_sizing == META_BUTTON_SIZING_FIXED))
{
set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
_("Cannot specify both 'button_width'/'button_height' and 'aspect_ratio' for buttons"));
return;
}
- info->layout->button_sizing = META_BUTTON_SIZING_FIXED;
+ info->layout->metacity.button_sizing = META_BUTTON_SIZING_FIXED;
}
else if (strcmp (name, "button_height") == 0)
{
- info->layout->button_height = val;
+ info->layout->metacity.button_height = val;
- if (!(info->layout->button_sizing == META_BUTTON_SIZING_LAST ||
- info->layout->button_sizing == META_BUTTON_SIZING_FIXED))
+ if (!(info->layout->metacity.button_sizing == META_BUTTON_SIZING_LAST ||
+ info->layout->metacity.button_sizing == META_BUTTON_SIZING_FIXED))
{
set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE,
_("Cannot specify both 'button_width'/'button_height' and 'aspect_ratio' for buttons"));
return;
}
- info->layout->button_sizing = META_BUTTON_SIZING_FIXED;
+ info->layout->metacity.button_sizing = META_BUTTON_SIZING_FIXED;
}
else
{
@@ -4631,16 +4631,19 @@ meta_theme_metacity_get_frame_borders (MetaThemeImpl *impl,
if (!layout->has_title)
text_height = 0;
- buttons_height = layout->button_height +
- layout->button_border.top + layout->button_border.bottom;
+ buttons_height = layout->metacity.button_height +
+ layout->button_border.top +
+ layout->button_border.bottom;
+
title_height = text_height +
- layout->title_vertical_pad +
- layout->title_border.top + layout->title_border.bottom;
+ layout->metacity.title_vertical_pad +
+ layout->metacity.title_border.top +
+ layout->metacity.title_border.bottom;
- borders->visible.top = layout->top_height + MAX (buttons_height, title_height);
- borders->visible.left = layout->left_width;
- borders->visible.right = layout->right_width;
- borders->visible.bottom = layout->bottom_height;
+ borders->visible.top = MAX (buttons_height, title_height);
+ borders->visible.left = layout->metacity.left_width;
+ borders->visible.right = layout->metacity.right_width;
+ borders->visible.bottom = layout->metacity.bottom_height;
if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE)
{
@@ -4848,7 +4851,6 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
type, &borders);
fgeom->borders = borders;
- fgeom->top_height = layout->top_height;
width = client_width + borders.total.left + borders.total.right;
@@ -4858,24 +4860,24 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
fgeom->width = width;
fgeom->height = height;
- fgeom->top_titlebar_edge = layout->title_border.top;
- fgeom->bottom_titlebar_edge = layout->title_border.bottom;
- fgeom->left_titlebar_edge = layout->left_titlebar_edge;
- fgeom->right_titlebar_edge = layout->right_titlebar_edge;
+ fgeom->content_border.top = layout->metacity.title_border.top;
+ fgeom->content_border.bottom = layout->metacity.title_border.bottom;
+ fgeom->content_border.left = layout->metacity.left_titlebar_edge;
+ fgeom->content_border.right = layout->metacity.right_titlebar_edge;
/* gcc warnings */
button_width = -1;
button_height = -1;
- switch (layout->button_sizing)
+ switch (layout->metacity.button_sizing)
{
case META_BUTTON_SIZING_ASPECT:
button_height = borders.visible.top - layout->button_border.top - layout->button_border.bottom;
- button_width = button_height / layout->button_aspect;
+ button_width = button_height / layout->metacity.button_aspect;
break;
case META_BUTTON_SIZING_FIXED:
- button_width = layout->button_width;
- button_height = layout->button_height;
+ button_width = layout->metacity.button_width;
+ button_height = layout->metacity.button_height;
break;
case META_BUTTON_SIZING_LAST:
default:
@@ -4968,7 +4970,8 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
int space_used_by_buttons;
int space_available;
- space_available = fgeom->width - layout->left_titlebar_edge - layout->right_titlebar_edge;
+ space_available = fgeom->width - layout->metacity.left_titlebar_edge -
+ layout->metacity.right_titlebar_edge;
space_used_by_buttons = 0;
@@ -5062,11 +5065,11 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
fgeom->n_right_buttons = n_right;
/* center buttons vertically */
- button_y = (borders.visible.top - fgeom->top_height -
- (button_height + layout->button_border.top + layout->button_border.bottom)) / 2 + layout->button_border.top + fgeom->top_height + borders.invisible.top;
+ button_y = (borders.visible.top -
+ (button_height + layout->button_border.top + layout->button_border.bottom)) / 2 + layout->button_border.top + borders.invisible.top;
/* right edge of farthest-right button */
- x = width - layout->right_titlebar_edge - borders.invisible.right;
+ x = width - layout->metacity.right_titlebar_edge - borders.invisible.right;
i = n_right - 1;
while (i >= 0)
@@ -5095,7 +5098,9 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
rect->clickable.height = button_height;
if (i == n_right - 1)
- rect->clickable.width += layout->right_titlebar_edge + layout->right_width + layout->button_border.right;
+ rect->clickable.width += layout->metacity.right_titlebar_edge +
+ layout->metacity.right_width +
+ layout->button_border.right;
}
else
g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
@@ -5108,12 +5113,12 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
}
/* save right edge of titlebar for later use */
- title_right_edge = x - layout->title_border.right;
+ title_right_edge = x - layout->metacity.title_border.right;
/* Now x changes to be position from the left and we go through
* the left-side buttons
*/
- x = layout->left_titlebar_edge + borders.invisible.left;
+ x = layout->metacity.left_titlebar_edge + borders.invisible.left;
for (i = 0; i < n_left; i++)
{
MetaButtonSpace *rect;
@@ -5145,10 +5150,12 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
/* We always fill as much vertical space as possible with title rect,
* rather than centering it like the buttons
*/
- fgeom->title_rect.x = x + layout->title_border.left;
- fgeom->title_rect.y = layout->title_border.top + borders.invisible.top;
+ fgeom->title_rect.x = x + layout->metacity.title_border.left;
+ fgeom->title_rect.y = layout->metacity.title_border.top + borders.invisible.top;
fgeom->title_rect.width = title_right_edge - fgeom->title_rect.x;
- fgeom->title_rect.height = borders.visible.top - layout->title_border.top - layout->title_border.bottom;
+ fgeom->title_rect.height = borders.visible.top -
+ layout->metacity.title_border.top -
+ layout->metacity.title_border.bottom;
/* Nuke title if it won't fit */
if (fgeom->title_rect.width < 0 ||
@@ -5286,23 +5293,23 @@ meta_theme_metacity_draw_frame (MetaThemeImpl *impl,
titlebar_rect.height = borders->visible.top;
left_titlebar_edge.x = titlebar_rect.x;
- left_titlebar_edge.y = titlebar_rect.y + fgeom->top_titlebar_edge;
- left_titlebar_edge.width = fgeom->left_titlebar_edge;
- left_titlebar_edge.height = titlebar_rect.height - fgeom->top_titlebar_edge - fgeom->bottom_titlebar_edge;
+ left_titlebar_edge.y = titlebar_rect.y + fgeom->content_border.top;
+ left_titlebar_edge.width = fgeom->content_border.left;
+ left_titlebar_edge.height = titlebar_rect.height - fgeom->content_border.top - fgeom->content_border.bottom;
right_titlebar_edge.y = left_titlebar_edge.y;
right_titlebar_edge.height = left_titlebar_edge.height;
- right_titlebar_edge.width = fgeom->right_titlebar_edge;
+ right_titlebar_edge.width = fgeom->content_border.right;
right_titlebar_edge.x = titlebar_rect.x + titlebar_rect.width - right_titlebar_edge.width;
top_titlebar_edge.x = titlebar_rect.x;
top_titlebar_edge.y = titlebar_rect.y;
top_titlebar_edge.width = titlebar_rect.width;
- top_titlebar_edge.height = fgeom->top_titlebar_edge;
+ top_titlebar_edge.height = fgeom->content_border.top;
bottom_titlebar_edge.x = titlebar_rect.x;
bottom_titlebar_edge.width = titlebar_rect.width;
- bottom_titlebar_edge.height = fgeom->bottom_titlebar_edge;
+ bottom_titlebar_edge.height = fgeom->content_border.bottom;
bottom_titlebar_edge.y = titlebar_rect.y + titlebar_rect.height - bottom_titlebar_edge.height;
left_edge.x = visible_rect.x;
diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h
index f7414289..e966c0b0 100644
--- a/libmetacity/meta-theme.h
+++ b/libmetacity/meta-theme.h
@@ -100,17 +100,13 @@ struct _MetaButtonSpace
struct _MetaFrameGeometry
{
MetaFrameBorders borders;
- int top_height;
int width;
int height;
GdkRectangle title_rect;
- int left_titlebar_edge;
- int right_titlebar_edge;
- int top_titlebar_edge;
- int bottom_titlebar_edge;
+ GtkBorder content_border;
/* used for a memset hack */
#define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))