diff options
author | Ryan Dwyer <RyanDwyer@users.noreply.github.com> | 2018-10-02 08:57:55 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-02 08:57:55 +1000 |
commit | b542c5413efdbbe0bbf3be0196fe566b8c6bb07f (patch) | |
tree | 6b9f56b3700dda60efdaff4446fc684009490b5b | |
parent | Merge pull request #2735 from RedSoxFan/fix-quotes (diff) | |
parent | Merge branch 'master' into fix-2653 (diff) | |
download | sway-b542c5413efdbbe0bbf3be0196fe566b8c6bb07f.tar.gz sway-b542c5413efdbbe0bbf3be0196fe566b8c6bb07f.tar.zst sway-b542c5413efdbbe0bbf3be0196fe566b8c6bb07f.zip |
Merge pull request #2739 from RedSoxFan/fix-2653
Fix smart gaps
-rw-r--r-- | include/sway/tree/view.h | 7 | ||||
-rw-r--r-- | sway/input/seat.c | 6 | ||||
-rw-r--r-- | sway/tree/container.c | 26 | ||||
-rw-r--r-- | sway/tree/view.c | 36 | ||||
-rw-r--r-- | sway/tree/workspace.c | 12 |
5 files changed, 63 insertions, 24 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index d10251dd..56ccbc6c 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -256,6 +256,13 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, | |||
256 | int height); | 256 | int height); |
257 | 257 | ||
258 | /** | 258 | /** |
259 | * Whether or not the view is the only visible view in its tree. If the view | ||
260 | * is tiling, there may be floating views. If the view is floating, there may | ||
261 | * be tiling views or views in a different floating container. | ||
262 | */ | ||
263 | bool view_is_only_visible(struct sway_view *view); | ||
264 | |||
265 | /** | ||
259 | * Configure the view's position and size based on the container's position and | 266 | * Configure the view's position and size based on the container's position and |
260 | * size, taking borders into consideration. | 267 | * size, taking borders into consideration. |
261 | */ | 268 | */ |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 4817eae7..34b64d9c 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -760,6 +760,12 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, | |||
760 | 760 | ||
761 | seat->has_focus = true; | 761 | seat->has_focus = true; |
762 | 762 | ||
763 | if (config->smart_gaps) { | ||
764 | // When smart gaps is on, gaps may change when the focus changes so | ||
765 | // the workspace needs to be arranged | ||
766 | arrange_workspace(new_workspace); | ||
767 | } | ||
768 | |||
763 | update_debug_tree(); | 769 | update_debug_tree(); |
764 | } | 770 | } |
765 | 771 | ||
diff --git a/sway/tree/container.c b/sway/tree/container.c index 788300cc..e1e616f9 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1021,10 +1021,28 @@ void container_add_gaps(struct sway_container *c) { | |||
1021 | if (!c->view && c->layout != L_TABBED && c->layout != L_STACKED) { | 1021 | if (!c->view && c->layout != L_TABBED && c->layout != L_STACKED) { |
1022 | return; | 1022 | return; |
1023 | } | 1023 | } |
1024 | // Children of tabbed/stacked containers re-use the gaps of the container | 1024 | // Descendants of tabbed/stacked containers re-use the gaps of the container |
1025 | enum sway_container_layout layout = container_parent_layout(c); | 1025 | struct sway_container *temp = c; |
1026 | if (layout == L_TABBED || layout == L_STACKED) { | 1026 | while (temp) { |
1027 | return; | 1027 | enum sway_container_layout layout = container_parent_layout(temp); |
1028 | if (layout == L_TABBED || layout == L_STACKED) { | ||
1029 | return; | ||
1030 | } | ||
1031 | temp = temp->parent; | ||
1032 | } | ||
1033 | // If smart gaps is on, don't add gaps if there is only one view visible | ||
1034 | if (config->smart_gaps) { | ||
1035 | struct sway_view *view = c->view; | ||
1036 | if (!view) { | ||
1037 | struct sway_seat *seat = | ||
1038 | input_manager_get_default_seat(input_manager); | ||
1039 | struct sway_container *focus = | ||
1040 | seat_get_focus_inactive_view(seat, &c->node); | ||
1041 | view = focus ? focus->view : NULL; | ||
1042 | } | ||
1043 | if (view && view_is_only_visible(view)) { | ||
1044 | return; | ||
1045 | } | ||
1028 | } | 1046 | } |
1029 | 1047 | ||
1030 | struct sway_workspace *ws = c->workspace; | 1048 | struct sway_workspace *ws = c->workspace; |
diff --git a/sway/tree/view.c b/sway/tree/view.c index a024f325..3b271159 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -162,6 +162,23 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, | |||
162 | return 0; | 162 | return 0; |
163 | } | 163 | } |
164 | 164 | ||
165 | bool view_is_only_visible(struct sway_view *view) { | ||
166 | bool only_view = true; | ||
167 | struct sway_container *con = view->container; | ||
168 | while (con) { | ||
169 | enum sway_container_layout layout = container_parent_layout(con); | ||
170 | if (layout != L_TABBED && layout != L_STACKED) { | ||
171 | list_t *siblings = container_get_siblings(con); | ||
172 | if (siblings && siblings->length > 1) { | ||
173 | only_view = false; | ||
174 | break; | ||
175 | } | ||
176 | } | ||
177 | con = con->parent; | ||
178 | } | ||
179 | return only_view; | ||
180 | } | ||
181 | |||
165 | void view_autoconfigure(struct sway_view *view) { | 182 | void view_autoconfigure(struct sway_view *view) { |
166 | if (!view->container->workspace) { | 183 | if (!view->container->workspace) { |
167 | // Hidden in the scratchpad | 184 | // Hidden in the scratchpad |
@@ -178,24 +195,9 @@ void view_autoconfigure(struct sway_view *view) { | |||
178 | } | 195 | } |
179 | 196 | ||
180 | struct sway_workspace *ws = view->container->workspace; | 197 | struct sway_workspace *ws = view->container->workspace; |
181 | |||
182 | bool other_views = false; | ||
183 | if (config->hide_edge_borders == E_SMART) { | ||
184 | struct sway_container *con = view->container; | ||
185 | while (con) { | ||
186 | enum sway_container_layout layout = container_parent_layout(con); | ||
187 | if (layout != L_TABBED && layout != L_STACKED) { | ||
188 | list_t *siblings = container_get_siblings(con); | ||
189 | if (siblings && siblings->length > 1) { | ||
190 | other_views = true; | ||
191 | break; | ||
192 | } | ||
193 | } | ||
194 | con = con->parent; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | struct sway_container *con = view->container; | 198 | struct sway_container *con = view->container; |
199 | bool other_views = config->hide_edge_borders == E_SMART ? | ||
200 | !view_is_only_visible(view) : false; | ||
199 | 201 | ||
200 | view->border_top = view->border_bottom = true; | 202 | view->border_top = view->border_bottom = true; |
201 | view->border_left = view->border_right = true; | 203 | view->border_left = view->border_right = true; |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 9dd5c815..e9e5dfa2 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -640,11 +640,17 @@ void workspace_add_gaps(struct sway_workspace *ws) { | |||
640 | if (ws->current_gaps > 0) { | 640 | if (ws->current_gaps > 0) { |
641 | return; | 641 | return; |
642 | } | 642 | } |
643 | bool should_apply = | 643 | if (!config->edge_gaps) { |
644 | config->edge_gaps || (config->smart_gaps && ws->tiling->length > 1); | ||
645 | if (!should_apply) { | ||
646 | return; | 644 | return; |
647 | } | 645 | } |
646 | if (config->smart_gaps) { | ||
647 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | ||
648 | struct sway_container *focus = | ||
649 | seat_get_focus_inactive_view(seat, &ws->node); | ||
650 | if (focus && focus->view && view_is_only_visible(focus->view)) { | ||
651 | return; | ||
652 | } | ||
653 | } | ||
648 | 654 | ||
649 | ws->current_gaps = ws->gaps_outer; | 655 | ws->current_gaps = ws->gaps_outer; |
650 | 656 | ||