diff options
author | infirit <[email protected]> | 2014-10-24 21:59:58 +0200 |
---|---|---|
committer | infirit <[email protected]> | 2014-10-27 12:29:24 +0100 |
commit | bec068ef5ddc73f23ffd6298122bf818fd4d2084 (patch) | |
tree | d7db4682b85c601d069de72cf76dda77b8a5e8dc /src/ui | |
parent | f814451acc48aec6d2fa1c217468f74e57a84340 (diff) | |
download | marco-bec068ef5ddc73f23ffd6298122bf818fd4d2084.tar.bz2 marco-bec068ef5ddc73f23ffd6298122bf818fd4d2084.tar.xz |
Rework tiling code based off Consortium
Taken from
https://github.com/SolusOS-discontinued/consortium/commit/b463e03f5bdeab307ceee6b969c681f29537c76d
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/theme-parser.c | 44 | ||||
-rw-r--r-- | src/ui/theme.c | 63 | ||||
-rw-r--r-- | src/ui/theme.h | 8 |
3 files changed, 113 insertions, 2 deletions
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c index c94e0e9a..dccb47ad 100644 --- a/src/ui/theme-parser.c +++ b/src/ui/theme-parser.c @@ -3136,6 +3136,28 @@ parse_style_set_element (GMarkupParseContext *context, meta_frame_style_ref (frame_style); info->style_set->maximized_styles[frame_focus] = frame_style; break; + case META_FRAME_STATE_TILED_LEFT: + if (info->style_set->tiled_left_styles[frame_focus]) + { + set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, + _("Style has already been specified for state %s focus %s"), + state, focus); + return; + } + meta_frame_style_ref (frame_style); + info->style_set->tiled_left_styles[frame_focus] = frame_style; + break; + case META_FRAME_STATE_TILED_RIGHT: + if (info->style_set->tiled_right_styles[frame_focus]) + { + set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, + _("Style has already been specified for state %s focus %s"), + state, focus); + return; + } + meta_frame_style_ref (frame_style); + info->style_set->tiled_right_styles[frame_focus] = frame_style; + break; case META_FRAME_STATE_SHADED: if (info->style_set->shaded_styles[frame_resize][frame_focus]) { @@ -3158,6 +3180,28 @@ parse_style_set_element (GMarkupParseContext *context, meta_frame_style_ref (frame_style); info->style_set->maximized_and_shaded_styles[frame_focus] = frame_style; break; + case META_FRAME_STATE_TILED_LEFT_AND_SHADED: + if (info->style_set->tiled_left_and_shaded_styles[frame_focus]) + { + set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, + _("Style has already been specified for state %s focus %s"), + state, focus); + return; + } + meta_frame_style_ref (frame_style); + info->style_set->tiled_left_and_shaded_styles[frame_focus] = frame_style; + break; + case META_FRAME_STATE_TILED_RIGHT_AND_SHADED: + if (info->style_set->tiled_right_and_shaded_styles[frame_focus]) + { + set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, + _("Style has already been specified for state %s focus %s"), + state, focus); + return; + } + meta_frame_style_ref (frame_style); + info->style_set->tiled_right_and_shaded_styles[frame_focus] = frame_style; + break; case META_FRAME_STATE_LAST: g_assert_not_reached (); break; diff --git a/src/ui/theme.c b/src/ui/theme.c index aa49963a..763f4f3a 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -851,7 +851,9 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout, rect->visible.width = button_width; rect->visible.height = button_height; - if (flags & META_FRAME_MAXIMIZED) + if (flags & META_FRAME_MAXIMIZED || + flags & META_FRAME_TILED_LEFT || + flags & META_FRAME_TILED_RIGHT) { rect->clickable.x = rect->visible.x; rect->clickable.y = rect->visible.y; @@ -4995,7 +4997,11 @@ meta_frame_style_set_unref (MetaFrameStyleSet *style_set) } free_focus_styles (style_set->maximized_styles); + free_focus_styles (style_set->tiled_left_styles); + free_focus_styles (style_set->tiled_right_styles); free_focus_styles (style_set->maximized_and_shaded_styles); + free_focus_styles (style_set->tiled_left_and_shaded_styles); + free_focus_styles (style_set->tiled_right_and_shaded_styles); if (style_set->parent) meta_frame_style_set_unref (style_set->parent); @@ -5047,9 +5053,21 @@ get_style (MetaFrameStyleSet *style_set, 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: @@ -5059,6 +5077,19 @@ get_style (MetaFrameStyleSet *style_set, 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); @@ -5404,7 +5435,7 @@ theme_get_style (MetaTheme *theme, if (style_set == NULL) return NULL; - switch (flags & (META_FRAME_MAXIMIZED | META_FRAME_SHADED)) + switch (flags & (META_FRAME_MAXIMIZED | META_FRAME_SHADED | META_FRAME_TILED_LEFT | META_FRAME_TILED_RIGHT)) { case 0: state = META_FRAME_STATE_NORMAL; @@ -5412,12 +5443,24 @@ theme_get_style (MetaTheme *theme, case META_FRAME_MAXIMIZED: state = META_FRAME_STATE_MAXIMIZED; break; + case META_FRAME_TILED_LEFT: + state = META_FRAME_STATE_TILED_LEFT; + break; + case META_FRAME_TILED_RIGHT: + state = META_FRAME_STATE_TILED_RIGHT; + break; case META_FRAME_SHADED: state = META_FRAME_STATE_SHADED; break; case (META_FRAME_MAXIMIZED | META_FRAME_SHADED): state = META_FRAME_STATE_MAXIMIZED_AND_SHADED; break; + case (META_FRAME_TILED_LEFT | META_FRAME_SHADED): + state = META_FRAME_STATE_TILED_LEFT_AND_SHADED; + break; + case (META_FRAME_TILED_RIGHT | META_FRAME_SHADED): + state = META_FRAME_STATE_TILED_RIGHT_AND_SHADED; + break; default: g_assert_not_reached (); state = META_FRAME_STATE_LAST; /* compiler */ @@ -6264,10 +6307,18 @@ meta_frame_state_from_string (const char *str) return META_FRAME_STATE_NORMAL; else if (strcmp ("maximized", str) == 0) return META_FRAME_STATE_MAXIMIZED; + else if (strcmp ("tiled_left", str) == 0) + return META_FRAME_STATE_TILED_LEFT; + else if (strcmp ("tiled_right", str) == 0) + return META_FRAME_STATE_TILED_RIGHT; else if (strcmp ("shaded", str) == 0) return META_FRAME_STATE_SHADED; else if (strcmp ("maximized_and_shaded", str) == 0) return META_FRAME_STATE_MAXIMIZED_AND_SHADED; + else if (strcmp ("tiled_left_and_shaded", str) == 0) + return META_FRAME_STATE_TILED_LEFT_AND_SHADED; + else if (strcmp ("tiled_right_and_shaded", str) == 0) + return META_FRAME_STATE_TILED_RIGHT_AND_SHADED; else return META_FRAME_STATE_LAST; } @@ -6281,10 +6332,18 @@ meta_frame_state_to_string (MetaFrameState state) return "normal"; case META_FRAME_STATE_MAXIMIZED: return "maximized"; + case META_FRAME_STATE_TILED_LEFT: + return "tiled_left"; + case META_FRAME_STATE_TILED_RIGHT: + return "tiled_right"; case META_FRAME_STATE_SHADED: return "shaded"; case META_FRAME_STATE_MAXIMIZED_AND_SHADED: return "maximized_and_shaded"; + case META_FRAME_STATE_TILED_LEFT_AND_SHADED: + return "tiled_left_and_shaded"; + case META_FRAME_STATE_TILED_RIGHT_AND_SHADED: + return "tiled_right_and_shaded"; case META_FRAME_STATE_LAST: break; } diff --git a/src/ui/theme.h b/src/ui/theme.h index 89d41efe..c7437bdf 100644 --- a/src/ui/theme.h +++ b/src/ui/theme.h @@ -716,8 +716,12 @@ typedef enum { META_FRAME_STATE_NORMAL, META_FRAME_STATE_MAXIMIZED, + META_FRAME_STATE_TILED_LEFT, + META_FRAME_STATE_TILED_RIGHT, META_FRAME_STATE_SHADED, META_FRAME_STATE_MAXIMIZED_AND_SHADED, + META_FRAME_STATE_TILED_LEFT_AND_SHADED, + META_FRAME_STATE_TILED_RIGHT_AND_SHADED, META_FRAME_STATE_LAST } MetaFrameState; @@ -754,8 +758,12 @@ struct _MetaFrameStyleSet MetaFrameStyleSet *parent; MetaFrameStyle *normal_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST]; MetaFrameStyle *maximized_styles[META_FRAME_FOCUS_LAST]; + MetaFrameStyle *tiled_left_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 *maximized_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]; }; /** |