diff options
-rw-r--r-- | include/sway/tree/container.h | 6 | ||||
-rw-r--r-- | sway/commands/focus.c | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 4 | ||||
-rw-r--r-- | sway/commands/resize.c | 10 | ||||
-rw-r--r-- | sway/commands/split.c | 2 | ||||
-rw-r--r-- | sway/commands/sticky.c | 6 | ||||
-rw-r--r-- | sway/desktop/output.c | 3 | ||||
-rw-r--r-- | sway/desktop/render.c | 3 | ||||
-rw-r--r-- | sway/ipc-json.c | 2 | ||||
-rw-r--r-- | sway/tree/container.c | 15 | ||||
-rw-r--r-- | sway/tree/root.c | 7 | ||||
-rw-r--r-- | sway/tree/view.c | 5 |
12 files changed, 35 insertions, 30 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 543bd2cc..f7a4ac37 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -299,9 +299,9 @@ enum sway_container_layout container_parent_layout(struct sway_container *con); | |||
299 | enum sway_container_layout container_current_parent_layout( | 299 | enum sway_container_layout container_current_parent_layout( |
300 | struct sway_container *con); | 300 | struct sway_container *con); |
301 | 301 | ||
302 | list_t *container_get_siblings(const struct sway_container *container); | 302 | list_t *container_get_siblings(struct sway_container *container); |
303 | 303 | ||
304 | int container_sibling_index(const struct sway_container *child); | 304 | int container_sibling_index(struct sway_container *child); |
305 | 305 | ||
306 | list_t *container_get_current_siblings(struct sway_container *container); | 306 | list_t *container_get_current_siblings(struct sway_container *container); |
307 | 307 | ||
@@ -354,4 +354,6 @@ void container_update_marks_textures(struct sway_container *container); | |||
354 | 354 | ||
355 | void container_raise_floating(struct sway_container *con); | 355 | void container_raise_floating(struct sway_container *con); |
356 | 356 | ||
357 | bool container_is_scratchpad_hidden(struct sway_container *con); | ||
358 | |||
357 | #endif | 359 | #endif |
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); |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index b5f164cb..ad75bb35 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -252,8 +252,7 @@ static void output_for_each_surface(struct sway_output *output, | |||
252 | 252 | ||
253 | struct sway_workspace *workspace = output_get_active_workspace(output); | 253 | struct sway_workspace *workspace = output_get_active_workspace(output); |
254 | struct sway_container *fullscreen_con = root->fullscreen_global; | 254 | struct sway_container *fullscreen_con = root->fullscreen_global; |
255 | if (fullscreen_con && fullscreen_con->scratchpad && | 255 | if (fullscreen_con && container_is_scratchpad_hidden(fullscreen_con)) { |
256 | !fullscreen_con->workspace) { | ||
257 | fullscreen_con = NULL; | 256 | fullscreen_con = NULL; |
258 | } | 257 | } |
259 | if (!fullscreen_con) { | 258 | if (!fullscreen_con) { |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 9102dc34..92e623ef 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -986,8 +986,7 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
986 | } | 986 | } |
987 | 987 | ||
988 | struct sway_container *fullscreen_con = root->fullscreen_global; | 988 | struct sway_container *fullscreen_con = root->fullscreen_global; |
989 | if (fullscreen_con && fullscreen_con->scratchpad && | 989 | if (fullscreen_con && container_is_scratchpad_hidden(fullscreen_con)) { |
990 | !fullscreen_con->workspace) { | ||
991 | fullscreen_con = NULL; | 990 | fullscreen_con = NULL; |
992 | } | 991 | } |
993 | if (!fullscreen_con) { | 992 | if (!fullscreen_con) { |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 87d2c1ec..e1098942 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -282,7 +282,7 @@ static json_object *ipc_json_describe_scratchpad_output(void) { | |||
282 | json_object *floating_array = json_object_new_array(); | 282 | json_object *floating_array = json_object_new_array(); |
283 | for (int i = 0; i < root->scratchpad->length; ++i) { | 283 | for (int i = 0; i < root->scratchpad->length; ++i) { |
284 | struct sway_container *container = root->scratchpad->items[i]; | 284 | struct sway_container *container = root->scratchpad->items[i]; |
285 | if (!container->workspace) { | 285 | if (container_is_scratchpad_hidden(container)) { |
286 | json_object_array_add(floating_array, | 286 | json_object_array_add(floating_array, |
287 | ipc_json_describe_node_recursive(&container->node)); | 287 | ipc_json_describe_node_recursive(&container->node)); |
288 | } | 288 | } |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 1cf5c8e7..e20e44d4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1156,11 +1156,11 @@ enum sway_container_layout container_current_parent_layout( | |||
1156 | return con->current.workspace->current.layout; | 1156 | return con->current.workspace->current.layout; |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | list_t *container_get_siblings(const struct sway_container *container) { | 1159 | list_t *container_get_siblings(struct sway_container *container) { |
1160 | if (container->parent) { | 1160 | if (container->parent) { |
1161 | return container->parent->children; | 1161 | return container->parent->children; |
1162 | } | 1162 | } |
1163 | if (!container->workspace) { | 1163 | if (container_is_scratchpad_hidden(container)) { |
1164 | return NULL; | 1164 | return NULL; |
1165 | } | 1165 | } |
1166 | if (list_find(container->workspace->tiling, container) != -1) { | 1166 | if (list_find(container->workspace->tiling, container) != -1) { |
@@ -1169,7 +1169,7 @@ list_t *container_get_siblings(const struct sway_container *container) { | |||
1169 | return container->workspace->floating; | 1169 | return container->workspace->floating; |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | int container_sibling_index(const struct sway_container *child) { | 1172 | int container_sibling_index(struct sway_container *child) { |
1173 | return list_find(container_get_siblings(child), child); | 1173 | return list_find(container_get_siblings(child), child); |
1174 | } | 1174 | } |
1175 | 1175 | ||
@@ -1181,7 +1181,10 @@ list_t *container_get_current_siblings(struct sway_container *container) { | |||
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | void container_handle_fullscreen_reparent(struct sway_container *con) { | 1183 | void container_handle_fullscreen_reparent(struct sway_container *con) { |
1184 | if (con->fullscreen_mode != FULLSCREEN_WORKSPACE || !con->workspace || | 1184 | if (!sway_assert(con->workspace, "Expected con to have a workspace")) { |
1185 | return; | ||
1186 | } | ||
1187 | if (con->fullscreen_mode != FULLSCREEN_WORKSPACE || | ||
1185 | con->workspace->fullscreen == con) { | 1188 | con->workspace->fullscreen == con) { |
1186 | return; | 1189 | return; |
1187 | } | 1190 | } |
@@ -1460,3 +1463,7 @@ void container_raise_floating(struct sway_container *con) { | |||
1460 | node_set_dirty(&floater->workspace->node); | 1463 | node_set_dirty(&floater->workspace->node); |
1461 | } | 1464 | } |
1462 | } | 1465 | } |
1466 | |||
1467 | bool container_is_scratchpad_hidden(struct sway_container *con) { | ||
1468 | return con->scratchpad && !con->workspace; | ||
1469 | } | ||
diff --git a/sway/tree/root.c b/sway/tree/root.c index 476e47a3..6e13d6ce 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -310,10 +310,7 @@ void root_for_each_container(void (*f)(struct sway_container *con, void *data), | |||
310 | // Scratchpad | 310 | // Scratchpad |
311 | for (int i = 0; i < root->scratchpad->length; ++i) { | 311 | for (int i = 0; i < root->scratchpad->length; ++i) { |
312 | struct sway_container *container = root->scratchpad->items[i]; | 312 | struct sway_container *container = root->scratchpad->items[i]; |
313 | // If the container has a workspace then it's visible on a workspace | 313 | if (container_is_scratchpad_hidden(container)) { |
314 | // and will have been iterated in the previous for loop. So we only | ||
315 | // iterate the hidden scratchpad containers here. | ||
316 | if (!container->workspace) { | ||
317 | f(container, data); | 314 | f(container, data); |
318 | container_for_each_child(container, f, data); | 315 | container_for_each_child(container, f, data); |
319 | } | 316 | } |
@@ -362,7 +359,7 @@ struct sway_container *root_find_container( | |||
362 | // Scratchpad | 359 | // Scratchpad |
363 | for (int i = 0; i < root->scratchpad->length; ++i) { | 360 | for (int i = 0; i < root->scratchpad->length; ++i) { |
364 | struct sway_container *container = root->scratchpad->items[i]; | 361 | struct sway_container *container = root->scratchpad->items[i]; |
365 | if (!container->workspace) { | 362 | if (container_is_scratchpad_hidden(container)) { |
366 | if (test(container, data)) { | 363 | if (test(container, data)) { |
367 | return container; | 364 | return container; |
368 | } | 365 | } |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 9ccb2a31..612cf96a 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -197,8 +197,7 @@ static bool gaps_to_edge(struct sway_view *view) { | |||
197 | 197 | ||
198 | void view_autoconfigure(struct sway_view *view) { | 198 | void view_autoconfigure(struct sway_view *view) { |
199 | struct sway_container *con = view->container; | 199 | struct sway_container *con = view->container; |
200 | if (!con->workspace) { | 200 | if (container_is_scratchpad_hidden(con)) { |
201 | // Hidden in the scratchpad | ||
202 | return; | 201 | return; |
203 | } | 202 | } |
204 | struct sway_output *output = con->workspace->output; | 203 | struct sway_output *output = con->workspace->output; |
@@ -1054,7 +1053,7 @@ void view_set_urgent(struct sway_view *view, bool enable) { | |||
1054 | 1053 | ||
1055 | ipc_event_window(view->container, "urgent"); | 1054 | ipc_event_window(view->container, "urgent"); |
1056 | 1055 | ||
1057 | if (view->container->workspace) { | 1056 | if (!container_is_scratchpad_hidden(view->container)) { |
1058 | workspace_detect_urgent(view->container->workspace); | 1057 | workspace_detect_urgent(view->container->workspace); |
1059 | } | 1058 | } |
1060 | } | 1059 | } |