summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-07-20 23:29:14 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-07-20 23:29:14 +0300
commit11e476ecd1c8d8d5bf8e1f369ba8765d2c42a937 (patch)
tree481681e2b1d505955b78f85b3d8313d4c7e9d18a
parent0baa5d7bdeedab5b5cebc29c762ecb34fca22f7b (diff)
downloadmetacity-11e476ecd1c8d8d5bf8e1f369ba8765d2c42a937.tar.gz
libmetacity: properly calculate available space for buttons
-rw-r--r--libmetacity/meta-theme-gtk.c14
-rw-r--r--libmetacity/meta-theme-metacity.c2
2 files changed, 11 insertions, 5 deletions
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c
index f81b08a0..0012f21a 100644
--- a/libmetacity/meta-theme-gtk.c
+++ b/libmetacity/meta-theme-gtk.c
@@ -341,7 +341,7 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
int title_right_edge;
int width, height;
int scale;
- int content_width, content_height;
+ int content_height;
int button_width, button_height;
int min_size_for_rounding;
@@ -363,9 +363,6 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
/* Scale geometry for HiDPI, see comment in meta_theme_gtk_draw_frame () */
scale = meta_theme_impl_get_scale (impl);
- content_width = width -
- borders.invisible.left - layout->gtk.frame_border.left * scale -
- borders.invisible.right - layout->gtk.frame_border.right * scale;
content_height = borders.visible.top - layout->gtk.frame_border.top * scale;
button_width = MAX ((gint) layout->gtk.icon_size, layout->gtk.button_min_size.width) +
@@ -426,6 +423,13 @@ 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 -
+ borders.total.left -
+ layout->gtk.titlebar_border.left * scale -
+ layout->gtk.titlebar_border.right * scale -
+ borders.total.right;
space_used_by_buttons = 0;
@@ -441,7 +445,7 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl,
space_used_by_buttons += (button_width * 0.75) * n_right_spacers;
space_used_by_buttons += layout->gtk.titlebar_spacing * scale * MAX (n_right - 1, 0);
- if (space_used_by_buttons <= content_width)
+ if (space_used_by_buttons <= space_available)
break; /* Everything fits, bail out */
/* First try to remove separators */
diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c
index a33344c5..37c604d6 100644
--- a/libmetacity/meta-theme-metacity.c
+++ b/libmetacity/meta-theme-metacity.c
@@ -4974,7 +4974,9 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl,
int space_available;
space_available = fgeom->width -
+ borders.invisible.left -
layout->metacity.left_titlebar_edge * scale -
+ borders.invisible.right -
layout->metacity.right_titlebar_edge * scale;
space_used_by_buttons = 0;