aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-10-01 09:41:15 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-10-01 09:41:15 -0400
commit742d1764a6fb1fb9269dc9ffe08319da98f4d7b8 (patch)
tree9a9dbe4dd968f78e728496a33e17bf695c773dcd /sway/tree
parentMerge pull request #2737 from Ragnis/criteria-floating (diff)
downloadsway-742d1764a6fb1fb9269dc9ffe08319da98f4d7b8.tar.gz
sway-742d1764a6fb1fb9269dc9ffe08319da98f4d7b8.tar.zst
sway-742d1764a6fb1fb9269dc9ffe08319da98f4d7b8.zip
Fix smart gaps
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c26
-rw-r--r--sway/tree/view.c36
-rw-r--r--sway/tree/workspace.c12
3 files changed, 50 insertions, 24 deletions
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
165bool 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
165void view_autoconfigure(struct sway_view *view) { 182void 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