diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/focus.c | 3 | ||||
-rw-r--r-- | sway/commands/move.c | 19 | ||||
-rw-r--r-- | sway/commands/sticky.c | 6 | ||||
-rw-r--r-- | sway/commands/swap.c | 4 | ||||
-rw-r--r-- | sway/commands/titlebar_border_thickness.c | 7 | ||||
-rw-r--r-- | sway/desktop/output.c | 3 | ||||
-rw-r--r-- | sway/input/cursor.c | 3 | ||||
-rw-r--r-- | sway/ipc-json.c | 3 | ||||
-rw-r--r-- | sway/tree/container.c | 2 | ||||
-rw-r--r-- | sway/tree/output.c | 3 |
10 files changed, 50 insertions, 3 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 79b2f551..25df5130 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -37,6 +37,9 @@ static struct sway_node *get_node_in_output_direction( | |||
37 | struct sway_output *output, enum wlr_direction dir) { | 37 | struct sway_output *output, enum wlr_direction dir) { |
38 | struct sway_seat *seat = config->handler_context.seat; | 38 | struct sway_seat *seat = config->handler_context.seat; |
39 | struct sway_workspace *ws = output_get_active_workspace(output); | 39 | struct sway_workspace *ws = output_get_active_workspace(output); |
40 | if (!sway_assert(ws, "Expected output to have a workspace")) { | ||
41 | return NULL; | ||
42 | } | ||
40 | if (ws->fullscreen) { | 43 | if (ws->fullscreen) { |
41 | return seat_get_focus_inactive(seat, &ws->fullscreen->node); | 44 | return seat_get_focus_inactive(seat, &ws->fullscreen->node); |
42 | } | 45 | } |
diff --git a/sway/commands/move.c b/sway/commands/move.c index 16f8cdb6..d4fb9022 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -283,6 +283,9 @@ static bool container_move_in_direction(struct sway_container *container, | |||
283 | return false; | 283 | return false; |
284 | } | 284 | } |
285 | struct sway_workspace *ws = output_get_active_workspace(new_output); | 285 | struct sway_workspace *ws = output_get_active_workspace(new_output); |
286 | if (!sway_assert(ws, "Expected output to have a workspace")) { | ||
287 | return false; | ||
288 | } | ||
286 | container_move_to_workspace(container, ws); | 289 | container_move_to_workspace(container, ws); |
287 | return true; | 290 | return true; |
288 | } | 291 | } |
@@ -360,6 +363,9 @@ static bool container_move_in_direction(struct sway_container *container, | |||
360 | output_get_in_direction(container->workspace->output, move_dir); | 363 | output_get_in_direction(container->workspace->output, move_dir); |
361 | if (output) { | 364 | if (output) { |
362 | struct sway_workspace *ws = output_get_active_workspace(output); | 365 | struct sway_workspace *ws = output_get_active_workspace(output); |
366 | if (!sway_assert(ws, "Expected output to have a workspace")) { | ||
367 | return false; | ||
368 | } | ||
363 | container_move_to_workspace_from_direction(container, ws, move_dir); | 369 | container_move_to_workspace_from_direction(container, ws, move_dir); |
364 | return true; | 370 | return true; |
365 | } | 371 | } |
@@ -525,6 +531,10 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) { | |||
525 | case N_OUTPUT: { | 531 | case N_OUTPUT: { |
526 | struct sway_output *output = destination->sway_output; | 532 | struct sway_output *output = destination->sway_output; |
527 | struct sway_workspace *ws = output_get_active_workspace(output); | 533 | struct sway_workspace *ws = output_get_active_workspace(output); |
534 | if (!sway_assert(ws, "Expected output to have a workspace")) { | ||
535 | return cmd_results_new(CMD_FAILURE, | ||
536 | "Expected output to have a workspace"); | ||
537 | } | ||
528 | container_move_to_workspace(container, ws); | 538 | container_move_to_workspace(container, ws); |
529 | } | 539 | } |
530 | break; | 540 | break; |
@@ -538,7 +548,11 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) { | |||
538 | // restore focus on destination output back to its last active workspace | 548 | // restore focus on destination output back to its last active workspace |
539 | struct sway_workspace *new_workspace = | 549 | struct sway_workspace *new_workspace = |
540 | output_get_active_workspace(new_output); | 550 | output_get_active_workspace(new_output); |
541 | if (new_output_last_ws && new_output_last_ws != new_workspace) { | 551 | if (!sway_assert(new_workspace, "Expected output to have a workspace")) { |
552 | return cmd_results_new(CMD_FAILURE, | ||
553 | "Expected output to have a workspace"); | ||
554 | } | ||
555 | if (new_output_last_ws != new_workspace) { | ||
542 | struct sway_node *new_output_last_focus = | 556 | struct sway_node *new_output_last_focus = |
543 | seat_get_focus_inactive(seat, &new_output_last_ws->node); | 557 | seat_get_focus_inactive(seat, &new_output_last_ws->node); |
544 | seat_set_raw_focus(seat, new_output_last_focus); | 558 | seat_set_raw_focus(seat, new_output_last_focus); |
@@ -585,6 +599,9 @@ static void workspace_move_to_output(struct sway_workspace *workspace, | |||
585 | workspace_detach(workspace); | 599 | workspace_detach(workspace); |
586 | struct sway_workspace *new_output_old_ws = | 600 | struct sway_workspace *new_output_old_ws = |
587 | output_get_active_workspace(output); | 601 | output_get_active_workspace(output); |
602 | if (!sway_assert(new_output_old_ws, "Expected output to have a workspace")) { | ||
603 | return; | ||
604 | } | ||
588 | 605 | ||
589 | output_add_workspace(output, workspace); | 606 | output_add_workspace(output, workspace); |
590 | 607 | ||
diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c index 5b70199c..9df1fe09 100644 --- a/sway/commands/sticky.c +++ b/sway/commands/sticky.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "sway/tree/view.h" | 9 | #include "sway/tree/view.h" |
10 | #include "sway/tree/workspace.h" | 10 | #include "sway/tree/workspace.h" |
11 | #include "list.h" | 11 | #include "list.h" |
12 | #include "log.h" | ||
12 | #include "util.h" | 13 | #include "util.h" |
13 | 14 | ||
14 | struct cmd_results *cmd_sticky(int argc, char **argv) { | 15 | struct cmd_results *cmd_sticky(int argc, char **argv) { |
@@ -29,6 +30,11 @@ struct cmd_results *cmd_sticky(int argc, char **argv) { | |||
29 | // move container to active workspace | 30 | // move container to active workspace |
30 | struct sway_workspace *active_workspace = | 31 | struct sway_workspace *active_workspace = |
31 | output_get_active_workspace(container->workspace->output); | 32 | output_get_active_workspace(container->workspace->output); |
33 | if (!sway_assert(active_workspace, | ||
34 | "Expected output to have a workspace")) { | ||
35 | return cmd_results_new(CMD_FAILURE, | ||
36 | "Expected output to have a workspace"); | ||
37 | } | ||
32 | if (container->workspace != active_workspace) { | 38 | if (container->workspace != active_workspace) { |
33 | struct sway_workspace *old_workspace = container->workspace; | 39 | struct sway_workspace *old_workspace = container->workspace; |
34 | container_detach(container); | 40 | container_detach(container); |
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 0e2c2d10..b978af16 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -118,6 +118,10 @@ static void container_swap(struct sway_container *con1, | |||
118 | output_get_active_workspace(con1->workspace->output); | 118 | output_get_active_workspace(con1->workspace->output); |
119 | struct sway_workspace *vis2 = | 119 | struct sway_workspace *vis2 = |
120 | output_get_active_workspace(con2->workspace->output); | 120 | output_get_active_workspace(con2->workspace->output); |
121 | if (!sway_assert(vis1 && vis2, "con1 or con2 are on an output without a" | ||
122 | "workspace. This should not happen")) { | ||
123 | return; | ||
124 | } | ||
121 | 125 | ||
122 | char *stored_prev_name = NULL; | 126 | char *stored_prev_name = NULL; |
123 | if (seat->prev_workspace_name) { | 127 | if (seat->prev_workspace_name) { |
diff --git a/sway/commands/titlebar_border_thickness.c b/sway/commands/titlebar_border_thickness.c index 3c5e9ba1..7c27c163 100644 --- a/sway/commands/titlebar_border_thickness.c +++ b/sway/commands/titlebar_border_thickness.c | |||
@@ -21,7 +21,12 @@ struct cmd_results *cmd_titlebar_border_thickness(int argc, char **argv) { | |||
21 | 21 | ||
22 | for (int i = 0; i < root->outputs->length; ++i) { | 22 | for (int i = 0; i < root->outputs->length; ++i) { |
23 | struct sway_output *output = root->outputs->items[i]; | 23 | struct sway_output *output = root->outputs->items[i]; |
24 | arrange_workspace(output_get_active_workspace(output)); | 24 | struct sway_workspace *ws = output_get_active_workspace(output); |
25 | if (!sway_assert(ws, "Expected output to have a workspace")) { | ||
26 | return cmd_results_new(CMD_FAILURE, | ||
27 | "Expected output to have a workspace"); | ||
28 | } | ||
29 | arrange_workspace(ws); | ||
25 | output_damage_whole(output); | 30 | output_damage_whole(output); |
26 | } | 31 | } |
27 | 32 | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 61beb7af..d7d3fc07 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -251,6 +251,9 @@ static void output_for_each_surface(struct sway_output *output, | |||
251 | }; | 251 | }; |
252 | 252 | ||
253 | struct sway_workspace *workspace = output_get_active_workspace(output); | 253 | struct sway_workspace *workspace = output_get_active_workspace(output); |
254 | if (!workspace) { | ||
255 | return; | ||
256 | } | ||
254 | struct sway_container *fullscreen_con = root->fullscreen_global; | 257 | struct sway_container *fullscreen_con = root->fullscreen_global; |
255 | if (fullscreen_con && container_is_scratchpad_hidden(fullscreen_con)) { | 258 | if (fullscreen_con && container_is_scratchpad_hidden(fullscreen_con)) { |
256 | fullscreen_con = NULL; | 259 | fullscreen_con = NULL; |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 170532be..3236c74a 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -104,6 +104,9 @@ struct sway_node *node_at_coords( | |||
104 | 104 | ||
105 | // find the focused workspace on the output for this seat | 105 | // find the focused workspace on the output for this seat |
106 | struct sway_workspace *ws = output_get_active_workspace(output); | 106 | struct sway_workspace *ws = output_get_active_workspace(output); |
107 | if (!ws) { | ||
108 | return NULL; | ||
109 | } | ||
107 | 110 | ||
108 | if ((*surface = layer_surface_at(output, | 111 | if ((*surface = layer_surface_at(output, |
109 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], | 112 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 6d36c727..a2ab2bba 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -198,6 +198,9 @@ static void ipc_json_describe_output(struct sway_output *output, | |||
198 | ipc_json_output_transform_description(wlr_output->transform))); | 198 | ipc_json_output_transform_description(wlr_output->transform))); |
199 | 199 | ||
200 | struct sway_workspace *ws = output_get_active_workspace(output); | 200 | struct sway_workspace *ws = output_get_active_workspace(output); |
201 | if (!sway_assert(ws, "Expected output to have a workspace")) { | ||
202 | return; | ||
203 | } | ||
201 | json_object_object_add(object, "current_workspace", | 204 | json_object_object_add(object, "current_workspace", |
202 | json_object_new_string(ws->name)); | 205 | json_object_new_string(ws->name)); |
203 | 206 | ||
diff --git a/sway/tree/container.c b/sway/tree/container.c index 9358dad7..933907f4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -831,7 +831,7 @@ void container_floating_move_to(struct sway_container *con, | |||
831 | } | 831 | } |
832 | struct sway_workspace *new_workspace = | 832 | struct sway_workspace *new_workspace = |
833 | output_get_active_workspace(new_output); | 833 | output_get_active_workspace(new_output); |
834 | if (old_workspace != new_workspace) { | 834 | if (new_workspace && old_workspace != new_workspace) { |
835 | container_detach(con); | 835 | container_detach(con); |
836 | workspace_add_floating(new_workspace, con); | 836 | workspace_add_floating(new_workspace, con); |
837 | arrange_workspace(old_workspace); | 837 | arrange_workspace(old_workspace); |
diff --git a/sway/tree/output.c b/sway/tree/output.c index 146bc423..e0a66e0b 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -143,6 +143,9 @@ void output_enable(struct sway_output *output, struct output_config *oc) { | |||
143 | static void evacuate_sticky(struct sway_workspace *old_ws, | 143 | static void evacuate_sticky(struct sway_workspace *old_ws, |
144 | struct sway_output *new_output) { | 144 | struct sway_output *new_output) { |
145 | struct sway_workspace *new_ws = output_get_active_workspace(new_output); | 145 | struct sway_workspace *new_ws = output_get_active_workspace(new_output); |
146 | if (!sway_assert(new_ws, "New output does not have a workspace")) { | ||
147 | return; | ||
148 | } | ||
146 | while (old_ws->floating->length) { | 149 | while (old_ws->floating->length) { |
147 | struct sway_container *sticky = old_ws->floating->items[0]; | 150 | struct sway_container *sticky = old_ws->floating->items[0]; |
148 | container_detach(sticky); | 151 | container_detach(sticky); |