[metacity] libmetacity: fix titlebar in GTK+ theme



commit d141fdffbcfb8a9ab9c032ac08b11d3ae83c2567
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Feb 15 22:02:51 2016 +0200

    libmetacity: fix titlebar in GTK+ theme

 libmetacity/meta-theme-gtk.c      |   33 ++++++++++++++++-----------------
 libmetacity/meta-theme-metacity.c |   18 +++++++-----------
 libmetacity/meta-theme.h          |    2 --
 3 files changed, 23 insertions(+), 30 deletions(-)
---
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c
index 8269f1c..25cb9ed 100644
--- a/libmetacity/meta-theme-gtk.c
+++ b/libmetacity/meta-theme-gtk.c
@@ -541,23 +541,18 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl          *impl,
 
   fgeom->borders = borders;
 
-  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;
 
-  height = ((flags & META_FRAME_SHADED) ? 0: client_height) +
-    borders.total.top + borders.total.bottom;
+  height = borders.total.top + borders.total.bottom;
+  if (!(flags & META_FRAME_SHADED))
+    height += client_height;
 
   fgeom->width = width;
   fgeom->height = height;
 
   content_width = width -
-                  (fgeom->content_border.left + borders.invisible.left) -
-                  (fgeom->content_border.right + borders.invisible.right);
+                  borders.invisible.left - layout->gtk.frame_border.left -
+                  borders.invisible.right - layout->gtk.frame_border.right;
   content_height = borders.visible.top - layout->gtk.frame_border.top;
 
   button_width = MAX ((gint) layout->gtk.icon_size, layout->gtk.button_min_size.width) +
@@ -695,11 +690,12 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl          *impl,
   fgeom->n_right_buttons = n_right;
 
   /* center buttons vertically */
-  button_y = fgeom->content_border.top + borders.invisible.top +
+  button_y = borders.invisible.top + layout->gtk.frame_border.top +
              (content_height - button_height) / 2;
 
   /* right edge of farthest-right button */
-  x = width - fgeom->content_border.right - borders.invisible.right;
+  x = width - borders.invisible.right - layout->gtk.frame_border.right -
+      layout->gtk.titlebar_border.right;
 
   i = n_right - 1;
   while (i >= 0)
@@ -731,7 +727,8 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl          *impl,
           rect->clickable.height = button_height;
 
           if (i == n_right - 1)
-            rect->clickable.width += fgeom->content_border.right;
+            rect->clickable.width += layout->gtk.frame_border.right +
+                                     layout->gtk.titlebar_border.right;
         }
       else
         g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
@@ -750,7 +747,9 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl          *impl,
   /* Now x changes to be position from the left and we go through
    * the left-side buttons
    */
-  x = fgeom->content_border.left + borders.invisible.left;
+  x = borders.invisible.left + layout->gtk.frame_border.left +
+      layout->gtk.titlebar_border.left;
+
   for (i = 0; i < n_left; i++)
     {
       MetaButtonSpace *rect;
@@ -783,7 +782,7 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl          *impl,
 
   /* Center vertically in the available content area */
   fgeom->title_rect.x = x;
-  fgeom->title_rect.y = fgeom->content_border.top + borders.invisible.top +
+  fgeom->title_rect.y = borders.invisible.top + layout->gtk.frame_border.top +
                         (content_height - text_height) / 2;
   fgeom->title_rect.width = title_right_edge - fgeom->title_rect.x;
   fgeom->title_rect.height = text_height;
@@ -868,9 +867,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->content_border.top;
+  titlebar_rect.y = visible_rect.y + style->layout->gtk.frame_border.top;
   titlebar_rect.width = visible_rect.width - borders->visible.left - borders->visible.right;
-  titlebar_rect.height = borders->visible.top - fgeom->content_border.top;
+  titlebar_rect.height = borders->visible.top - style->layout->gtk.frame_border.top;
 
   context = style_info->styles[META_STYLE_ELEMENT_TITLEBAR];
   gtk_render_background (context, cr,
diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c
index fbeaa6d..69ac79b 100644
--- a/libmetacity/meta-theme-metacity.c
+++ b/libmetacity/meta-theme-metacity.c
@@ -4860,11 +4860,6 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl          *impl,
   fgeom->width = width;
   fgeom->height = height;
 
-  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;
@@ -5293,23 +5288,24 @@ 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->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;
+  left_titlebar_edge.y = titlebar_rect.y + style->layout->metacity.title_border.top;
+  left_titlebar_edge.width = style->layout->metacity.title_border.left;
+  left_titlebar_edge.height = titlebar_rect.height - style->layout->metacity.title_border.top -
+                              style->layout->metacity.title_border.bottom;
 
   right_titlebar_edge.y = left_titlebar_edge.y;
   right_titlebar_edge.height = left_titlebar_edge.height;
-  right_titlebar_edge.width = fgeom->content_border.right;
+  right_titlebar_edge.width = style->layout->metacity.title_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->content_border.top;
+  top_titlebar_edge.height = style->layout->metacity.title_border.top;
 
   bottom_titlebar_edge.x = titlebar_rect.x;
   bottom_titlebar_edge.width = titlebar_rect.width;
-  bottom_titlebar_edge.height = fgeom->content_border.bottom;
+  bottom_titlebar_edge.height = style->layout->metacity.title_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 0a78b77..d812076 100644
--- a/libmetacity/meta-theme.h
+++ b/libmetacity/meta-theme.h
@@ -105,8 +105,6 @@ struct _MetaFrameGeometry
 
   GdkRectangle title_rect;
 
-  GtkBorder content_border;
-
   /* used for a memset hack */
 #define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
 #define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, right_single_background) + sizeof 
(GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]