diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-07 22:42:18 -0500 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-07 22:42:18 -0500 |
commit | 6a42643784520e87a043344640e5be9cb67439e3 (patch) | |
tree | a3696d7b4e32e7f7c254d06486da9140160f7a04 /sway/tree/container.c | |
parent | Add focus_follows_mouse always. (#3081) (diff) | |
download | sway-6a42643784520e87a043344640e5be9cb67439e3.tar.gz sway-6a42643784520e87a043344640e5be9cb67439e3.tar.zst sway-6a42643784520e87a043344640e5be9cb67439e3.zip |
gaps: remove duplicate inner gaps
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 458ed7ff..3740cb53 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1009,19 +1009,25 @@ void container_discover_outputs(struct sway_container *con) { | |||
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void container_remove_gaps(struct sway_container *c) { | 1011 | void container_remove_gaps(struct sway_container *c) { |
1012 | if (c->current_gaps == 0) { | 1012 | if (c->current_gaps.top == 0 && c->current_gaps.right == 0 && |
1013 | c->current_gaps.bottom == 0 && c->current_gaps.left == 0) { | ||
1013 | return; | 1014 | return; |
1014 | } | 1015 | } |
1015 | 1016 | ||
1016 | c->width += c->current_gaps * 2; | 1017 | c->width += c->current_gaps.left + c->current_gaps.right; |
1017 | c->height += c->current_gaps * 2; | 1018 | c->height += c->current_gaps.top + c->current_gaps.bottom; |
1018 | c->x -= c->current_gaps; | 1019 | c->x -= c->current_gaps.left; |
1019 | c->y -= c->current_gaps; | 1020 | c->y -= c->current_gaps.top; |
1020 | c->current_gaps = 0; | 1021 | |
1022 | c->current_gaps.top = 0; | ||
1023 | c->current_gaps.right = 0; | ||
1024 | c->current_gaps.bottom = 0; | ||
1025 | c->current_gaps.left = 0; | ||
1021 | } | 1026 | } |
1022 | 1027 | ||
1023 | void container_add_gaps(struct sway_container *c) { | 1028 | void container_add_gaps(struct sway_container *c) { |
1024 | if (c->current_gaps > 0) { | 1029 | if (c->current_gaps.top > 0 || c->current_gaps.right > 0 || |
1030 | c->current_gaps.bottom > 0 || c->current_gaps.left > 0) { | ||
1025 | return; | 1031 | return; |
1026 | } | 1032 | } |
1027 | // Linear containers don't have gaps because it'd create double gaps | 1033 | // Linear containers don't have gaps because it'd create double gaps |
@@ -1054,11 +1060,15 @@ void container_add_gaps(struct sway_container *c) { | |||
1054 | 1060 | ||
1055 | struct sway_workspace *ws = c->workspace; | 1061 | struct sway_workspace *ws = c->workspace; |
1056 | 1062 | ||
1057 | c->current_gaps = ws->gaps_inner; | 1063 | c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0; |
1058 | c->x += c->current_gaps; | 1064 | c->current_gaps.right = ws->gaps_inner; |
1059 | c->y += c->current_gaps; | 1065 | c->current_gaps.bottom = ws->gaps_inner; |
1060 | c->width -= 2 * c->current_gaps; | 1066 | c->current_gaps.left = c->x == ws->x ? ws->gaps_inner : 0; |
1061 | c->height -= 2 * c->current_gaps; | 1067 | |
1068 | c->x += c->current_gaps.left; | ||
1069 | c->y += c->current_gaps.top; | ||
1070 | c->width -= c->current_gaps.left + c->current_gaps.right; | ||
1071 | c->height -= c->current_gaps.top + c->current_gaps.bottom; | ||
1062 | } | 1072 | } |
1063 | 1073 | ||
1064 | enum sway_container_layout container_parent_layout(struct sway_container *con) { | 1074 | enum sway_container_layout container_parent_layout(struct sway_container *con) { |