aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar lbonn <bonnans.l@gmail.com>2021-01-20 22:20:00 +0100
committerLibravatar Tudor Brindus <me@tbrindus.ca>2021-02-25 09:40:20 -0500
commitc6e7cf1ae554f36e5120962ace779737827ad088 (patch)
tree6071546edfe33925f7f205414166e62fbfd6d819
parentAutomatically map built-in touchscreens/tablets to built-in panels (diff)
downloadsway-c6e7cf1ae554f36e5120962ace779737827ad088.tar.gz
sway-c6e7cf1ae554f36e5120962ace779737827ad088.tar.zst
sway-c6e7cf1ae554f36e5120962ace779737827ad088.zip
focus: beyond fullscreen when focused explicitly
When issuing a focus command on a specific container, users expect to proceed it even if is hidden by a fullscreen window. This matches the behavior of i3.
-rw-r--r--include/sway/tree/container.h5
-rw-r--r--sway/commands/focus.c7
-rw-r--r--sway/input/seat.c19
-rw-r--r--sway/tree/container.c22
4 files changed, 38 insertions, 15 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 2c973f71..ddb2d683 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -164,6 +164,11 @@ void container_for_each_child(struct sway_container *container,
164 void (*f)(struct sway_container *container, void *data), void *data); 164 void (*f)(struct sway_container *container, void *data), void *data);
165 165
166/** 166/**
167 * Returns the fullscreen container obstructing this container if it exists.
168 */
169struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container);
170
171/**
167 * Returns true if the given container is an ancestor of this container. 172 * Returns true if the given container is an ancestor of this container.
168 */ 173 */
169bool container_has_ancestor(struct sway_container *container, 174bool container_has_ancestor(struct sway_container *container,
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 6b4f57c1..6771ca2f 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -377,6 +377,13 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
377 if (container_is_scratchpad_hidden_or_child(container)) { 377 if (container_is_scratchpad_hidden_or_child(container)) {
378 root_scratchpad_show(container); 378 root_scratchpad_show(container);
379 } 379 }
380 // if we are switching to a container under a fullscreen window, we first
381 // need to exit fullscreen so that the newly focused container becomes visible
382 struct sway_container *obstructing = container_obstructing_fullscreen_container(container);
383 if (obstructing) {
384 container_fullscreen_disable(obstructing);
385 arrange_root();
386 }
380 seat_set_focus_container(seat, container); 387 seat_set_focus_container(seat, container);
381 seat_consider_warp_to_focus(seat); 388 seat_consider_warp_to_focus(seat);
382 container_raise_floating(container); 389 container_raise_floating(container);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index d23525a8..2d714acd 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1139,26 +1139,15 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
1139 struct sway_container *container = node->type == N_CONTAINER ? 1139 struct sway_container *container = node->type == N_CONTAINER ?
1140 node->sway_container : NULL; 1140 node->sway_container : NULL;
1141 1141
1142 // Deny setting focus to a view which is hidden by a fullscreen container 1142 // Deny setting focus to a view which is hidden by a fullscreen container or global
1143 if (new_workspace && new_workspace->fullscreen && container && 1143 if (container && container_obstructing_fullscreen_container(container)) {
1144 !container_is_fullscreen_or_child(container)) { 1144 return;
1145 // Unless it's a transient container
1146 if (!container_is_transient_for(container, new_workspace->fullscreen)) {
1147 return;
1148 }
1149 } 1145 }
1146
1150 // Deny setting focus to a workspace node when using fullscreen global 1147 // Deny setting focus to a workspace node when using fullscreen global
1151 if (root->fullscreen_global && !container && new_workspace) { 1148 if (root->fullscreen_global && !container && new_workspace) {
1152 return; 1149 return;
1153 } 1150 }
1154 // Deny setting focus to a view which is hidden by a fullscreen global
1155 if (root->fullscreen_global && container != root->fullscreen_global &&
1156 !container_has_ancestor(container, root->fullscreen_global)) {
1157 // Unless it's a transient container
1158 if (!container_is_transient_for(container, root->fullscreen_global)) {
1159 return;
1160 }
1161 }
1162 1151
1163 struct sway_output *new_output = 1152 struct sway_output *new_output =
1164 new_workspace ? new_workspace->output : NULL; 1153 new_workspace ? new_workspace->output : NULL;
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 6b4c6de2..e22c5961 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -418,6 +418,28 @@ void container_for_each_child(struct sway_container *container,
418 } 418 }
419} 419}
420 420
421struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container)
422{
423 struct sway_workspace *workspace = container->pending.workspace;
424
425 if (workspace && workspace->fullscreen && !container_is_fullscreen_or_child(container)) {
426 if (container_is_transient_for(container, workspace->fullscreen)) {
427 return NULL;
428 }
429 return workspace->fullscreen;
430 }
431
432 struct sway_container *fullscreen_global = root->fullscreen_global;
433 if (fullscreen_global && container != fullscreen_global && !container_has_ancestor(container, fullscreen_global)) {
434 if (container_is_transient_for(container, fullscreen_global)) {
435 return NULL;
436 }
437 return fullscreen_global;
438 }
439
440 return NULL;
441}
442
421bool container_has_ancestor(struct sway_container *descendant, 443bool container_has_ancestor(struct sway_container *descendant,
422 struct sway_container *ancestor) { 444 struct sway_container *ancestor) {
423 while (descendant) { 445 while (descendant) {