aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-11-03 00:16:15 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2020-11-11 20:43:58 -0500
commit07042486c3c4b8e7083405ba9b34b1b87f8d396d (patch)
tree5ec7b68db2acbc1c68538a08b0b039477e8f8858 /sway/commands
parentAdd missing includes for wlr_input_device.h (diff)
downloadsway-07042486c3c4b8e7083405ba9b34b1b87f8d396d.tar.gz
sway-07042486c3c4b8e7083405ba9b34b1b87f8d396d.tar.zst
sway-07042486c3c4b8e7083405ba9b34b1b87f8d396d.zip
tree/container: introduce `container_is_sticky[_or_child]` functions
To query whether a container is sticky, checking `con->is_sticky` is insufficient. `container_is_floating_or_child` must also return true; this led to a lot of repetition. This commit introduces `container_is_sticky[_or_child]` functions, and switches all stickiness checks to use them. (Including ones where the container is already known to be floating, for consistency.)
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/move.c6
-rw-r--r--sway/commands/sticky.c2
2 files changed, 4 insertions, 4 deletions
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 =