theme: Remove MetaFrameResize

Really, styling windows differently based on how they can be resized
is over the top ...

https://bugzilla.gnome.org/show_bug.cgi?id=741917
This commit is contained in:
Florian Müllner 2014-09-25 16:52:17 +01:00 committed by Jasper St. Pierre
parent ef32899b4d
commit 46f3eb0b71
2 changed files with 42 additions and 131 deletions

View File

@ -247,16 +247,14 @@ struct _MetaFrameStyle
/* Kinds of frame... /* Kinds of frame...
* *
* normal -> noresize / vert only / horz only / both * normal -> focused / unfocused
* focused / unfocused
* max -> focused / unfocused * max -> focused / unfocused
* shaded -> focused / unfocused * shaded -> focused / unfocused
* max/shaded -> focused / unfocused * max/shaded -> focused / unfocused
* *
* so 4 states with 8 sub-states in one, 2 sub-states in the other 3, * so 4 states with 2 sub-states each, meaning 8 total
* meaning 14 total
* *
* 14 window states times 7 or 8 window types. Except some * 8 window states times 7 or 8 window types. Except some
* window types never get a frame so that narrows it down a bit. * window types never get a frame so that narrows it down a bit.
* *
*/ */
@ -273,15 +271,6 @@ typedef enum
META_FRAME_STATE_LAST META_FRAME_STATE_LAST
} MetaFrameState; } MetaFrameState;
typedef enum
{
META_FRAME_RESIZE_NONE,
META_FRAME_RESIZE_VERTICAL,
META_FRAME_RESIZE_HORIZONTAL,
META_FRAME_RESIZE_BOTH,
META_FRAME_RESIZE_LAST
} MetaFrameResize;
typedef enum typedef enum
{ {
META_FRAME_FOCUS_NO, META_FRAME_FOCUS_NO,
@ -291,8 +280,7 @@ typedef enum
/** /**
* How to draw frames at different times: when it's maximised or not, shaded * How to draw frames at different times: when it's maximised or not, shaded
* or not, when it's focussed or not, and (for non-maximised windows), when * or not, tiled or not, and when it's focussed or not.
* it can be horizontally or vertically resized, both, or neither.
* Not all window types actually get a frame. * Not all window types actually get a frame.
* *
* A theme contains one of these objects for each type of window (each * A theme contains one of these objects for each type of window (each
@ -304,11 +292,11 @@ struct _MetaFrameStyleSet
{ {
int refcount; int refcount;
MetaFrameStyleSet *parent; MetaFrameStyleSet *parent;
MetaFrameStyle *normal_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST]; MetaFrameStyle *normal_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *maximized_styles[META_FRAME_FOCUS_LAST]; MetaFrameStyle *maximized_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_left_styles[META_FRAME_FOCUS_LAST]; MetaFrameStyle *tiled_left_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_right_styles[META_FRAME_FOCUS_LAST]; MetaFrameStyle *tiled_right_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *shaded_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST]; MetaFrameStyle *shaded_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *maximized_and_shaded_styles[META_FRAME_FOCUS_LAST]; MetaFrameStyle *maximized_and_shaded_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_left_and_shaded_styles[META_FRAME_FOCUS_LAST]; MetaFrameStyle *tiled_left_and_shaded_styles[META_FRAME_FOCUS_LAST];
MetaFrameStyle *tiled_right_and_shaded_styles[META_FRAME_FOCUS_LAST]; MetaFrameStyle *tiled_right_and_shaded_styles[META_FRAME_FOCUS_LAST];

View File

@ -995,14 +995,8 @@ meta_frame_style_set_unref (MetaFrameStyleSet *style_set)
if (style_set->refcount == 0) if (style_set->refcount == 0)
{ {
int i; free_focus_styles (style_set->normal_styles);
free_focus_styles (style_set->shaded_styles);
for (i = 0; i < META_FRAME_RESIZE_LAST; i++)
{
free_focus_styles (style_set->normal_styles[i]);
free_focus_styles (style_set->shaded_styles[i]);
}
free_focus_styles (style_set->maximized_styles); free_focus_styles (style_set->maximized_styles);
free_focus_styles (style_set->tiled_left_styles); free_focus_styles (style_set->tiled_left_styles);
free_focus_styles (style_set->tiled_right_styles); free_focus_styles (style_set->tiled_right_styles);
@ -1022,88 +1016,44 @@ meta_frame_style_set_unref (MetaFrameStyleSet *style_set)
static MetaFrameStyle* static MetaFrameStyle*
get_style (MetaFrameStyleSet *style_set, get_style (MetaFrameStyleSet *style_set,
MetaFrameState state, MetaFrameState state,
MetaFrameResize resize,
MetaFrameFocus focus) MetaFrameFocus focus)
{ {
MetaFrameStyle *style; MetaFrameStyle **styles;
style = NULL; styles = NULL;
switch (state) switch (state)
{ {
case META_FRAME_STATE_NORMAL: case META_FRAME_STATE_NORMAL:
case META_FRAME_STATE_SHADED: styles = style_set->normal_styles;
{ break;
if (state == META_FRAME_STATE_SHADED) case META_FRAME_STATE_MAXIMIZED:
style = style_set->shaded_styles[resize][focus]; styles = style_set->maximized_styles;
else break;
style = style_set->normal_styles[resize][focus]; case META_FRAME_STATE_TILED_LEFT:
styles = style_set->tiled_left_styles;
/* Try parent if we failed here */ break;
if (style == NULL && style_set->parent) case META_FRAME_STATE_TILED_RIGHT:
style = get_style (style_set->parent, state, resize, focus); styles = style_set->tiled_right_styles;
break;
/* Allow people to omit the vert/horz/none resize modes */ case META_FRAME_STATE_SHADED:
if (style == NULL && styles = style_set->shaded_styles;
resize != META_FRAME_RESIZE_BOTH) break;
style = get_style (style_set, state, META_FRAME_RESIZE_BOTH, focus); case META_FRAME_STATE_MAXIMIZED_AND_SHADED:
} styles = style_set->maximized_and_shaded_styles;
break;
case META_FRAME_STATE_TILED_LEFT_AND_SHADED:
styles = style_set->tiled_left_and_shaded_styles;
break;
case META_FRAME_STATE_TILED_RIGHT_AND_SHADED:
styles = style_set->tiled_right_and_shaded_styles;
break;
case META_FRAME_STATE_LAST:
g_assert_not_reached ();
break; break;
default:
{
MetaFrameStyle **styles;
styles = NULL;
switch (state)
{
case META_FRAME_STATE_MAXIMIZED:
styles = style_set->maximized_styles;
break;
case META_FRAME_STATE_TILED_LEFT:
styles = style_set->tiled_left_styles;
break;
case META_FRAME_STATE_TILED_RIGHT:
styles = style_set->tiled_right_styles;
break;
case META_FRAME_STATE_MAXIMIZED_AND_SHADED:
styles = style_set->maximized_and_shaded_styles;
break;
case META_FRAME_STATE_TILED_LEFT_AND_SHADED:
styles = style_set->tiled_left_and_shaded_styles;
break;
case META_FRAME_STATE_TILED_RIGHT_AND_SHADED:
styles = style_set->tiled_right_and_shaded_styles;
break;
case META_FRAME_STATE_NORMAL:
case META_FRAME_STATE_SHADED:
case META_FRAME_STATE_LAST:
g_assert_not_reached ();
break;
}
style = styles[focus];
/* Tiled states are optional, try falling back to non-tiled states */
if (style == NULL)
{
if (state == META_FRAME_STATE_TILED_LEFT ||
state == META_FRAME_STATE_TILED_RIGHT)
style = get_style (style_set, META_FRAME_STATE_NORMAL,
resize, focus);
else if (state == META_FRAME_STATE_TILED_LEFT_AND_SHADED ||
state == META_FRAME_STATE_TILED_RIGHT_AND_SHADED)
style = get_style (style_set, META_FRAME_STATE_SHADED,
resize, focus);
}
/* Try parent if we failed here */
if (style == NULL && style_set->parent)
style = get_style (style_set->parent, state, resize, focus);
}
} }
return style; return styles[focus];
} }
/** /**
@ -1114,7 +1064,7 @@ MetaTheme*
meta_theme_get_default (void) meta_theme_get_default (void)
{ {
static MetaTheme *theme = NULL; static MetaTheme *theme = NULL;
int i, j, frame_type; int i, frame_type;
if (theme) if (theme)
return theme; return theme;
@ -1151,14 +1101,11 @@ meta_theme_get_default (void)
for (i = 0; i < META_FRAME_FOCUS_LAST; i++) for (i = 0; i < META_FRAME_FOCUS_LAST; i++)
{ {
for (j = 0; j < META_FRAME_RESIZE_LAST; j++) meta_frame_style_ref (style);
{ style_set->normal_styles[i] = style;
meta_frame_style_ref (style);
style_set->normal_styles[j][i] = style;
meta_frame_style_ref (style); meta_frame_style_ref (style);
style_set->shaded_styles[j][i] = style; style_set->shaded_styles[i] = style;
}
meta_frame_style_ref (style); meta_frame_style_ref (style);
style_set->maximized_styles[i] = style; style_set->maximized_styles[i] = style;
@ -1217,9 +1164,7 @@ theme_get_style (MetaTheme *theme,
MetaFrameFlags flags) MetaFrameFlags flags)
{ {
MetaFrameState state; MetaFrameState state;
MetaFrameResize resize;
MetaFrameFocus focus; MetaFrameFocus focus;
MetaFrameStyle *style;
MetaFrameStyleSet *style_set; MetaFrameStyleSet *style_set;
style_set = theme->style_sets_by_type[type]; style_set = theme->style_sets_by_type[type];
@ -1257,26 +1202,6 @@ theme_get_style (MetaTheme *theme,
break; break;
} }
switch (flags & (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE))
{
case 0:
resize = META_FRAME_RESIZE_NONE;
break;
case META_FRAME_ALLOWS_VERTICAL_RESIZE:
resize = META_FRAME_RESIZE_VERTICAL;
break;
case META_FRAME_ALLOWS_HORIZONTAL_RESIZE:
resize = META_FRAME_RESIZE_HORIZONTAL;
break;
case (META_FRAME_ALLOWS_VERTICAL_RESIZE | META_FRAME_ALLOWS_HORIZONTAL_RESIZE):
resize = META_FRAME_RESIZE_BOTH;
break;
default:
g_assert_not_reached ();
resize = META_FRAME_RESIZE_LAST; /* compiler */
break;
}
/* re invert the styles used for focus/unfocussed while flashing a frame */ /* re invert the styles used for focus/unfocussed while flashing a frame */
if (((flags & META_FRAME_HAS_FOCUS) && !(flags & META_FRAME_IS_FLASHING)) if (((flags & META_FRAME_HAS_FOCUS) && !(flags & META_FRAME_IS_FLASHING))
|| (!(flags & META_FRAME_HAS_FOCUS) && (flags & META_FRAME_IS_FLASHING))) || (!(flags & META_FRAME_HAS_FOCUS) && (flags & META_FRAME_IS_FLASHING)))
@ -1284,9 +1209,7 @@ theme_get_style (MetaTheme *theme,
else else
focus = META_FRAME_FOCUS_NO; focus = META_FRAME_FOCUS_NO;
style = get_style (style_set, state, resize, focus); return get_style (style_set, state, focus);
return style;
} }
MetaFrameStyle* MetaFrameStyle*