diff options
-rw-r--r-- | include/sway/tree/container.h | 7 | ||||
-rw-r--r-- | sway/commands/move.c | 6 | ||||
-rw-r--r-- | sway/commands/sticky.c | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 2 | ||||
-rw-r--r-- | sway/tree/container.c | 8 | ||||
-rw-r--r-- | sway/tree/view.c | 10 | ||||
-rw-r--r-- | sway/tree/workspace.c | 4 |
7 files changed, 25 insertions, 14 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 136d618b..c9290108 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -78,6 +78,9 @@ struct sway_container { | |||
78 | enum sway_container_layout layout; | 78 | enum sway_container_layout layout; |
79 | enum sway_container_layout prev_split_layout; | 79 | enum sway_container_layout prev_split_layout; |
80 | 80 | ||
81 | // Whether stickiness has been enabled on this container. Use | ||
82 | // `container_is_sticky_[or_child]` rather than accessing this field | ||
83 | // directly; it'll also check that the container is floating. | ||
81 | bool is_sticky; | 84 | bool is_sticky; |
82 | 85 | ||
83 | // For C_ROOT, this has no meaning | 86 | // For C_ROOT, this has no meaning |
@@ -367,4 +370,8 @@ bool container_is_scratchpad_hidden(struct sway_container *con); | |||
367 | 370 | ||
368 | bool container_is_scratchpad_hidden_or_child(struct sway_container *con); | 371 | bool container_is_scratchpad_hidden_or_child(struct sway_container *con); |
369 | 372 | ||
373 | bool container_is_sticky(struct sway_container *con); | ||
374 | |||
375 | bool container_is_sticky_or_child(struct sway_container *con); | ||
376 | |||
370 | #endif | 377 | #endif |
diff --git a/sway/commands/move.c b/sway/commands/move.c index 876a5616..204596c0 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -482,7 +482,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth, | |||
482 | // We have to create the workspace, but if the container is | 482 | // We have to create the workspace, but if the container is |
483 | // sticky and the workspace is going to be created on the same | 483 | // sticky and the workspace is going to be created on the same |
484 | // output, we'll bail out first. | 484 | // output, we'll bail out first. |
485 | if (container->is_sticky && container_is_floating_or_child(container)) { | 485 | if (container_is_sticky_or_child(container)) { |
486 | struct sway_output *new_output = | 486 | struct sway_output *new_output = |
487 | workspace_get_initial_output(ws_name); | 487 | workspace_get_initial_output(ws_name); |
488 | if (old_output == new_output) { | 488 | if (old_output == new_output) { |
@@ -521,8 +521,8 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth, | |||
521 | return cmd_move_to_scratchpad(); | 521 | return cmd_move_to_scratchpad(); |
522 | } | 522 | } |
523 | 523 | ||
524 | if (container->is_sticky && container_is_floating_or_child(container) && | 524 | if (container_is_sticky_or_child(container) && old_output && |
525 | old_output && node_has_ancestor(destination, &old_output->node)) { | 525 | node_has_ancestor(destination, &old_output->node)) { |
526 | return cmd_results_new(CMD_FAILURE, "Can't move sticky " | 526 | return cmd_results_new(CMD_FAILURE, "Can't move sticky " |
527 | "container to another workspace on the same output"); | 527 | "container to another workspace on the same output"); |
528 | } | 528 | } |
diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c index 9df1fe09..3c93a276 100644 --- a/sway/commands/sticky.c +++ b/sway/commands/sticky.c | |||
@@ -25,7 +25,7 @@ struct cmd_results *cmd_sticky(int argc, char **argv) { | |||
25 | 25 | ||
26 | container->is_sticky = parse_boolean(argv[0], container->is_sticky); | 26 | container->is_sticky = parse_boolean(argv[0], container->is_sticky); |
27 | 27 | ||
28 | if (container->is_sticky && container_is_floating_or_child(container) && | 28 | if (container_is_sticky_or_child(container) && |
29 | !container_is_scratchpad_hidden(container)) { | 29 | !container_is_scratchpad_hidden(container)) { |
30 | // move container to active workspace | 30 | // move container to active workspace |
31 | struct sway_workspace *active_workspace = | 31 | struct sway_workspace *active_workspace = |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 24d7e903..2b41d1cb 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1151,7 +1151,7 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | |||
1151 | for (int i = 0; i < new_output_last_ws->floating->length; ++i) { | 1151 | for (int i = 0; i < new_output_last_ws->floating->length; ++i) { |
1152 | struct sway_container *floater = | 1152 | struct sway_container *floater = |
1153 | new_output_last_ws->floating->items[i]; | 1153 | new_output_last_ws->floating->items[i]; |
1154 | if (floater->is_sticky) { | 1154 | if (container_is_sticky(floater)) { |
1155 | container_detach(floater); | 1155 | container_detach(floater); |
1156 | workspace_add_floating(new_workspace, floater); | 1156 | workspace_add_floating(new_workspace, floater); |
1157 | --i; | 1157 | --i; |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 8557210f..10d621b4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1609,3 +1609,11 @@ bool container_is_scratchpad_hidden_or_child(struct sway_container *con) { | |||
1609 | con = container_toplevel_ancestor(con); | 1609 | con = container_toplevel_ancestor(con); |
1610 | return con->scratchpad && !con->workspace; | 1610 | return con->scratchpad && !con->workspace; |
1611 | } | 1611 | } |
1612 | |||
1613 | bool container_is_sticky(struct sway_container *con) { | ||
1614 | return con->is_sticky && container_is_floating(con); | ||
1615 | } | ||
1616 | |||
1617 | bool container_is_sticky_or_child(struct sway_container *con) { | ||
1618 | return container_is_sticky(container_toplevel_ancestor(con)); | ||
1619 | } | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index d699b01e..354f2d34 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -1244,13 +1244,9 @@ bool view_is_visible(struct sway_view *view) { | |||
1244 | return false; | 1244 | return false; |
1245 | } | 1245 | } |
1246 | } | 1246 | } |
1247 | // Determine if view is nested inside a floating container which is sticky | 1247 | |
1248 | struct sway_container *floater = view->container; | 1248 | if (!container_is_sticky_or_child(view->container) && workspace && |
1249 | while (floater->parent) { | 1249 | !workspace_is_visible(workspace)) { |
1250 | floater = floater->parent; | ||
1251 | } | ||
1252 | bool is_sticky = container_is_floating(floater) && floater->is_sticky; | ||
1253 | if (!is_sticky && workspace && !workspace_is_visible(workspace)) { | ||
1254 | return false; | 1250 | return false; |
1255 | } | 1251 | } |
1256 | // Check view isn't in a tabbed or stacked container on an inactive tab | 1252 | // Check view isn't in a tabbed or stacked container on an inactive tab |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 476c2568..ffcbe933 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -498,7 +498,7 @@ bool workspace_is_empty(struct sway_workspace *ws) { | |||
498 | // Sticky views are not considered to be part of this workspace | 498 | // Sticky views are not considered to be part of this workspace |
499 | for (int i = 0; i < ws->floating->length; ++i) { | 499 | for (int i = 0; i < ws->floating->length; ++i) { |
500 | struct sway_container *floater = ws->floating->items[i]; | 500 | struct sway_container *floater = ws->floating->items[i]; |
501 | if (!floater->is_sticky) { | 501 | if (!container_is_sticky(floater)) { |
502 | return false; | 502 | return false; |
503 | } | 503 | } |
504 | } | 504 | } |
@@ -819,7 +819,7 @@ size_t workspace_num_tiling_views(struct sway_workspace *ws) { | |||
819 | } | 819 | } |
820 | 820 | ||
821 | static void count_sticky_containers(struct sway_container *con, void *data) { | 821 | static void count_sticky_containers(struct sway_container *con, void *data) { |
822 | if (container_is_floating(con) && con->is_sticky) { | 822 | if (container_is_sticky(con)) { |
823 | size_t *count = data; | 823 | size_t *count = data; |
824 | *count += 1; | 824 | *count += 1; |
825 | } | 825 | } |