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
This commit is contained in:
Jasper St. Pierre 2011-07-12 00:59:12 -04:00
parent e0fb83c691
commit ce9c7a210d
6 changed files with 30 additions and 35 deletions

View File

@ -301,6 +301,15 @@ meta_frame_get_flags (MetaFrame *frame)
return flags; return flags;
} }
void
meta_frame_borders_clear (MetaFrameBorders *self)
{
self->visible.top = 0;
self->visible.bottom = 0;
self->visible.left = 0;
self->visible.right = 0;
}
void void
meta_frame_calc_borders (MetaFrame *frame, meta_frame_calc_borders (MetaFrame *frame,
MetaFrameBorders *borders) MetaFrameBorders *borders)

View File

@ -311,6 +311,10 @@ struct _MetaFrameBorders
*/ */
GtkBorder visible; GtkBorder visible;
}; };
/* sets all dimensions to zero */
void meta_frame_borders_clear (MetaFrameBorders *self);
/* should investigate changing these to whatever most apps use */ /* should investigate changing these to whatever most apps use */
#define META_ICON_WIDTH 32 #define META_ICON_WIDTH 32
#define META_ICON_HEIGHT 32 #define META_ICON_HEIGHT 32

View File

@ -53,6 +53,8 @@ struct _MetaPreview
int text_height; int text_height;
MetaFrameBorders borders; MetaFrameBorders borders;
guint borders_cached : 1;
MetaButtonLayout button_layout; MetaButtonLayout button_layout;
}; };

View File

@ -93,11 +93,8 @@ meta_preview_init (MetaPreview *preview)
META_FRAME_HAS_FOCUS | META_FRAME_HAS_FOCUS |
META_FRAME_ALLOWS_SHADE | META_FRAME_ALLOWS_SHADE |
META_FRAME_ALLOWS_MOVE; META_FRAME_ALLOWS_MOVE;
preview->borders.visible.left = -1; preview->borders_cached = FALSE;
preview->borders.visible.right = -1;
preview->borders.visible.top = -1;
preview->borders.visible.bottom = -1;
} }
GtkWidget* GtkWidget*
@ -168,23 +165,17 @@ ensure_info (MetaPreview *preview)
pango_font_description_free (font_desc); pango_font_description_free (font_desc);
} }
if (preview->borders.visible.top < 0) if (!preview->borders_cached)
{ {
if (preview->theme) if (preview->theme)
{ meta_theme_get_frame_borders (preview->theme,
meta_theme_get_frame_borders (preview->theme, preview->type,
preview->type, preview->text_height,
preview->text_height, preview->flags,
preview->flags, &preview->borders);
&preview->borders);
}
else else
{ meta_frame_borders_clear (&preview->borders);
preview->borders.visible.top = 0; preview->borders_cached = TRUE;
preview->borders.visible.bottom = 0;
preview->borders.visible.left = 0;
preview->borders.visible.right = 0;
}
} }
} }
@ -342,10 +333,7 @@ clear_cache (MetaPreview *preview)
preview->layout = NULL; preview->layout = NULL;
} }
preview->borders.visible.left = -1; preview->borders_cached = FALSE;
preview->borders.visible.right = -1;
preview->borders.visible.top = -1;
preview->borders.visible.bottom = -1;
} }
void void

View File

@ -425,10 +425,8 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
if (flags & META_FRAME_FULLSCREEN) if (flags & META_FRAME_FULLSCREEN)
{ {
borders->visible.top = 0; meta_frame_borders_clear (borders);
borders->visible.bottom = 0; return;
borders->visible.left = 0;
borders->visible.right = 0;
} }
} }
@ -5585,10 +5583,7 @@ meta_theme_get_frame_borders (MetaTheme *theme,
style = theme_get_style (theme, type, flags); style = theme_get_style (theme, type, flags);
borders->visible.top = 0; meta_frame_borders_clear (borders);
borders->visible.left = 0;
borders->visible.right = 0;
borders->visible.bottom = 0;
/* Parser is not supposed to allow this currently */ /* Parser is not supposed to allow this currently */
if (style == NULL) if (style == NULL)

View File

@ -736,10 +736,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
} }
else else
{ {
borders->visible.top = 0; meta_frame_borders_clear (borders);
borders->visible.bottom = 0;
borders->visible.left = 0;
borders->visible.right = 0;
} }
if (style != NULL) if (style != NULL)