[mutter] MetaFrameBorders: Add meta_frame_borders_clear



commit ce9c7a210d13cc4f02beb3bc6171e7fcc0443805
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jul 12 00:59:12 2011 -0400

    MetaFrameBorders: Add meta_frame_borders_clear
    
    Just a quick little commit to help clean things up for when we add invisible
    borders. Additionally, do a little housekeeping in preview-widget as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644930

 src/core/frame.c          |    9 +++++++++
 src/meta/common.h         |    4 ++++
 src/meta/preview-widget.h |    2 ++
 src/ui/preview-widget.c   |   34 +++++++++++-----------------------
 src/ui/theme.c            |   11 +++--------
 src/ui/ui.c               |    5 +----
 6 files changed, 30 insertions(+), 35 deletions(-)
---
diff --git a/src/core/frame.c b/src/core/frame.c
index ed35292..e42a13d 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -302,6 +302,15 @@ meta_frame_get_flags (MetaFrame *frame)
 }
 
 void
+meta_frame_borders_clear (MetaFrameBorders *self)
+{
+  self->visible.top    = 0;
+  self->visible.bottom = 0;
+  self->visible.left   = 0;
+  self->visible.right  = 0;
+}
+
+void
 meta_frame_calc_borders (MetaFrame        *frame,
                          MetaFrameBorders *borders)
 {
diff --git a/src/meta/common.h b/src/meta/common.h
index 00436ea..a78516d 100644
--- a/src/meta/common.h
+++ b/src/meta/common.h
@@ -311,6 +311,10 @@ struct _MetaFrameBorders
    */
   GtkBorder visible;
 };
+
+/* sets all dimensions to zero */
+void meta_frame_borders_clear (MetaFrameBorders *self);
+
 /* should investigate changing these to whatever most apps use */
 #define META_ICON_WIDTH 32
 #define META_ICON_HEIGHT 32
diff --git a/src/meta/preview-widget.h b/src/meta/preview-widget.h
index c84bd4e..cbc7580 100644
--- a/src/meta/preview-widget.h
+++ b/src/meta/preview-widget.h
@@ -53,6 +53,8 @@ struct _MetaPreview
   int text_height;
 
   MetaFrameBorders borders;
+  guint            borders_cached : 1;
+
   MetaButtonLayout button_layout;
 };
 
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index b9bd072..1992fb1 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -93,11 +93,8 @@ meta_preview_init (MetaPreview *preview)
     META_FRAME_HAS_FOCUS |
     META_FRAME_ALLOWS_SHADE |
     META_FRAME_ALLOWS_MOVE;
-  
-  preview->borders.visible.left = -1;
-  preview->borders.visible.right = -1;
-  preview->borders.visible.top = -1;
-  preview->borders.visible.bottom = -1;
+
+  preview->borders_cached = FALSE;
 }
 
 GtkWidget*
@@ -168,23 +165,17 @@ ensure_info (MetaPreview *preview)
       pango_font_description_free (font_desc);
     }
 
-  if (preview->borders.visible.top < 0)
+  if (!preview->borders_cached)
     {
       if (preview->theme)
-        {
-          meta_theme_get_frame_borders (preview->theme,
-                                        preview->type,
-                                        preview->text_height,
-                                        preview->flags,
-                                        &preview->borders);
-        }
+        meta_theme_get_frame_borders (preview->theme,
+                                      preview->type,
+                                      preview->text_height,
+                                      preview->flags,
+                                      &preview->borders);
       else
-        {
-          preview->borders.visible.top = 0;
-          preview->borders.visible.bottom = 0;
-          preview->borders.visible.left = 0;
-          preview->borders.visible.right = 0;
-        }
+        meta_frame_borders_clear (&preview->borders);
+      preview->borders_cached = TRUE;
     }
 }
 
@@ -342,10 +333,7 @@ clear_cache (MetaPreview *preview)
       preview->layout = NULL;
     }
 
-  preview->borders.visible.left = -1;
-  preview->borders.visible.right = -1;
-  preview->borders.visible.top = -1;
-  preview->borders.visible.bottom = -1;
+  preview->borders_cached = FALSE;
 }
 
 void
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 6242b20..b878d92 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -425,10 +425,8 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
 
   if (flags & META_FRAME_FULLSCREEN)
     {
-      borders->visible.top = 0;
-      borders->visible.bottom = 0;
-      borders->visible.left = 0;
-      borders->visible.right = 0;
+      meta_frame_borders_clear (borders);
+      return;
     }
 }
 
@@ -5585,10 +5583,7 @@ meta_theme_get_frame_borders (MetaTheme        *theme,
 
   style = theme_get_style (theme, type, flags);
 
-  borders->visible.top = 0;
-  borders->visible.left = 0;
-  borders->visible.right = 0;
-  borders->visible.bottom = 0;
+  meta_frame_borders_clear (borders);
 
   /* Parser is not supposed to allow this currently */
   if (style == NULL)
diff --git a/src/ui/ui.c b/src/ui/ui.c
index d96e29c..749d3e6 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -736,10 +736,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
     }
   else
     {
-      borders->visible.top = 0;
-      borders->visible.bottom = 0;
-      borders->visible.left = 0;
-      borders->visible.right = 0;
+      meta_frame_borders_clear (borders);
     }
 
   if (style != NULL)



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