summaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2019-01-28 19:06:42 +1000
committerLibravatar emersion <contact@emersion.fr>2019-01-28 10:35:40 +0100
commit6b8bf10941ec83ac7a6e364b9c34f8c6f74d814a (patch)
tree61a9e61c64fd1b88a79b06a6f9dafeb84e4f8c35 /sway/commands
parentAdd note about required scdoc version to README. (diff)
downloadsway-6b8bf10941ec83ac7a6e364b9c34f8c6f74d814a.tar.gz
sway-6b8bf10941ec83ac7a6e364b9c34f8c6f74d814a.tar.zst
sway-6b8bf10941ec83ac7a6e364b9c34f8c6f74d814a.zip
Introduce container_is_scratchpad_hidden
Just a convenience function that improves readability of the code. Other things worth noting: * container_get_siblings and container_sibling_index no longer use the const keyword * container_handle_fullscreen_reparent is only ever called after attaching the container to a workspace, so its con->workspace check has been changed to an assertion
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/focus.c2
-rw-r--r--sway/commands/move.c4
-rw-r--r--sway/commands/resize.c10
-rw-r--r--sway/commands/split.c2
-rw-r--r--sway/commands/sticky.c6
5 files changed, 13 insertions, 11 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 87fe6cf3..79b2f551 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -271,7 +271,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
271 } 271 }
272 272
273 if (argc == 0 && container) { 273 if (argc == 0 && container) {
274 if (container->scratchpad && !container->workspace) { 274 if (container_is_scratchpad_hidden(container)) {
275 root_scratchpad_show(container); 275 root_scratchpad_show(container);
276 } 276 }
277 seat_set_focus_container(seat, container); 277 seat_set_focus_container(seat, container);
diff --git a/sway/commands/move.c b/sway/commands/move.c
index aa06b168..8c3afae9 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -659,7 +659,7 @@ static struct cmd_results *cmd_move_in_direction(
659 return cmd_results_new(CMD_FAILURE, 659 return cmd_results_new(CMD_FAILURE,
660 "Cannot move workspaces in a direction"); 660 "Cannot move workspaces in a direction");
661 } 661 }
662 if (container->scratchpad && !container->workspace) { 662 if (container_is_scratchpad_hidden(container)) {
663 return cmd_results_new(CMD_FAILURE, 663 return cmd_results_new(CMD_FAILURE,
664 "Cannot move a hidden scratchpad container"); 664 "Cannot move a hidden scratchpad container");
665 } 665 }
@@ -734,7 +734,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
734 return cmd_results_new(CMD_FAILURE, "Only floating containers " 734 return cmd_results_new(CMD_FAILURE, "Only floating containers "
735 "can be moved to an absolute position"); 735 "can be moved to an absolute position");
736 } 736 }
737 if (container->scratchpad && !container->workspace) { 737 if (container_is_scratchpad_hidden(container)) {
738 return cmd_results_new(CMD_FAILURE, 738 return cmd_results_new(CMD_FAILURE,
739 "Cannot move a hidden scratchpad container"); 739 "Cannot move a hidden scratchpad container");
740 } 740 }
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index 204de539..c9261535 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -86,7 +86,8 @@ static void calculate_constraints(int *min_width, int *max_width,
86 *min_height = config->floating_minimum_height; 86 *min_height = config->floating_minimum_height;
87 } 87 }
88 88
89 if (config->floating_maximum_width == -1 || !con->workspace) { // no max 89 if (config->floating_maximum_width == -1 ||
90 container_is_scratchpad_hidden(con)) { // no max
90 *max_width = INT_MAX; 91 *max_width = INT_MAX;
91 } else if (config->floating_maximum_width == 0) { // automatic 92 } else if (config->floating_maximum_width == 0) { // automatic
92 *max_width = con->workspace->width; 93 *max_width = con->workspace->width;
@@ -94,7 +95,8 @@ static void calculate_constraints(int *min_width, int *max_width,
94 *max_width = config->floating_maximum_width; 95 *max_width = config->floating_maximum_width;
95 } 96 }
96 97
97 if (config->floating_maximum_height == -1 || !con->workspace) { // no max 98 if (config->floating_maximum_height == -1 ||
99 container_is_scratchpad_hidden(con)) { // no max
98 *max_height = INT_MAX; 100 *max_height = INT_MAX;
99 } else if (config->floating_maximum_height == 0) { // automatic 101 } else if (config->floating_maximum_height == 0) { // automatic
100 *max_height = con->workspace->height; 102 *max_height = con->workspace->height;
@@ -386,7 +388,7 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
386 if (width->amount) { 388 if (width->amount) {
387 switch (width->unit) { 389 switch (width->unit) {
388 case RESIZE_UNIT_PPT: 390 case RESIZE_UNIT_PPT:
389 if (con->scratchpad && !con->workspace) { 391 if (container_is_scratchpad_hidden(con)) {
390 return cmd_results_new(CMD_FAILURE, 392 return cmd_results_new(CMD_FAILURE,
391 "Cannot resize a hidden scratchpad container by ppt"); 393 "Cannot resize a hidden scratchpad container by ppt");
392 } 394 }
@@ -410,7 +412,7 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
410 if (height->amount) { 412 if (height->amount) {
411 switch (height->unit) { 413 switch (height->unit) {
412 case RESIZE_UNIT_PPT: 414 case RESIZE_UNIT_PPT:
413 if (con->scratchpad && !con->workspace) { 415 if (container_is_scratchpad_hidden(con)) {
414 return cmd_results_new(CMD_FAILURE, 416 return cmd_results_new(CMD_FAILURE,
415 "Cannot resize a hidden scratchpad container by ppt"); 417 "Cannot resize a hidden scratchpad container by ppt");
416 } 418 }
diff --git a/sway/commands/split.c b/sway/commands/split.c
index b7ab7b79..e9670722 100644
--- a/sway/commands/split.c
+++ b/sway/commands/split.c
@@ -13,7 +13,7 @@ static struct cmd_results *do_split(int layout) {
13 struct sway_container *con = config->handler_context.container; 13 struct sway_container *con = config->handler_context.container;
14 struct sway_workspace *ws = config->handler_context.workspace; 14 struct sway_workspace *ws = config->handler_context.workspace;
15 if (con) { 15 if (con) {
16 if (con->scratchpad && !con->workspace) { 16 if (container_is_scratchpad_hidden(con)) {
17 return cmd_results_new(CMD_FAILURE, 17 return cmd_results_new(CMD_FAILURE,
18 "Cannot split a hidden scratchpad container"); 18 "Cannot split a hidden scratchpad container");
19 } 19 }
diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c
index e79af8af..5b70199c 100644
--- a/sway/commands/sticky.c
+++ b/sway/commands/sticky.c
@@ -17,15 +17,15 @@ struct cmd_results *cmd_sticky(int argc, char **argv) {
17 return error; 17 return error;
18 } 18 }
19 struct sway_container *container = config->handler_context.container; 19 struct sway_container *container = config->handler_context.container;
20 20
21 if (container == NULL) { 21 if (container == NULL) {
22 return cmd_results_new(CMD_FAILURE, "No current container"); 22 return cmd_results_new(CMD_FAILURE, "No current container");
23 }; 23 };
24 24
25 container->is_sticky = parse_boolean(argv[0], container->is_sticky); 25 container->is_sticky = parse_boolean(argv[0], container->is_sticky);
26 26
27 if (container->is_sticky && container_is_floating_or_child(container) && 27 if (container->is_sticky && container_is_floating_or_child(container) &&
28 (!container->scratchpad || container->workspace)) { 28 !container_is_scratchpad_hidden(container)) {
29 // move container to active workspace 29 // move container to active workspace
30 struct sway_workspace *active_workspace = 30 struct sway_workspace *active_workspace =
31 output_get_active_workspace(container->workspace->output); 31 output_get_active_workspace(container->workspace->output);