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 | |
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
-rw-r--r-- | include/sway/tree/container.h | 7 | ||||
-rw-r--r-- | sway/tree/container.c | 34 | ||||
-rw-r--r-- | sway/tree/view.c | 11 |
3 files changed, 34 insertions, 18 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 4366a010..d3155eb3 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -104,7 +104,12 @@ struct sway_container { | |||
104 | bool border_right; | 104 | bool border_right; |
105 | 105 | ||
106 | // The gaps currently applied to the container. | 106 | // The gaps currently applied to the container. |
107 | double current_gaps; | 107 | struct { |
108 | int top; | ||
109 | int right; | ||
110 | int bottom; | ||
111 | int left; | ||
112 | } current_gaps; | ||
108 | 113 | ||
109 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad | 114 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad |
110 | struct sway_container *parent; // NULL if container in root of workspace | 115 | struct sway_container *parent; // NULL if container in root of workspace |
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) { |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 1aa59e68..03bb01d3 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -185,7 +185,8 @@ bool view_is_only_visible(struct sway_view *view) { | |||
185 | static bool gaps_to_edge(struct sway_view *view) { | 185 | static bool gaps_to_edge(struct sway_view *view) { |
186 | struct sway_container *con = view->container; | 186 | struct sway_container *con = view->container; |
187 | while (con) { | 187 | while (con) { |
188 | if (con->current_gaps > 0) { | 188 | if (con->current_gaps.top > 0 || con->current_gaps.right > 0 || |
189 | con->current_gaps.bottom > 0 || con->current_gaps.left > 0) { | ||
189 | return true; | 190 | return true; |
190 | } | 191 | } |
191 | con = con->parent; | 192 | con = con->parent; |
@@ -222,15 +223,15 @@ void view_autoconfigure(struct sway_view *view) { | |||
222 | if (config->hide_edge_borders == E_BOTH | 223 | if (config->hide_edge_borders == E_BOTH |
223 | || config->hide_edge_borders == E_VERTICAL | 224 | || config->hide_edge_borders == E_VERTICAL |
224 | || (smart && !other_views && no_gaps)) { | 225 | || (smart && !other_views && no_gaps)) { |
225 | con->border_left = con->x - con->current_gaps != ws->x; | 226 | con->border_left = con->x - con->current_gaps.left != ws->x; |
226 | int right_x = con->x + con->width + con->current_gaps; | 227 | int right_x = con->x + con->width + con->current_gaps.right; |
227 | con->border_right = right_x != ws->x + ws->width; | 228 | con->border_right = right_x != ws->x + ws->width; |
228 | } | 229 | } |
229 | if (config->hide_edge_borders == E_BOTH | 230 | if (config->hide_edge_borders == E_BOTH |
230 | || config->hide_edge_borders == E_HORIZONTAL | 231 | || config->hide_edge_borders == E_HORIZONTAL |
231 | || (smart && !other_views && no_gaps)) { | 232 | || (smart && !other_views && no_gaps)) { |
232 | con->border_top = con->y - con->current_gaps != ws->y; | 233 | con->border_top = con->y - con->current_gaps.top != ws->y; |
233 | int bottom_y = con->y + con->height + con->current_gaps; | 234 | int bottom_y = con->y + con->height + con->current_gaps.bottom; |
234 | con->border_bottom = bottom_y != ws->y + ws->height; | 235 | con->border_bottom = bottom_y != ws->y + ws->height; |
235 | } | 236 | } |
236 | 237 | ||