aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/focus.c3
-rw-r--r--sway/commands/move.c25
-rw-r--r--sway/commands/sticky.c6
-rw-r--r--sway/commands/swap.c4
-rw-r--r--sway/commands/titlebar_border_thickness.c7
5 files changed, 40 insertions, 5 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(
struct sway_output *output, enum wlr_direction dir) {
struct sway_seat *seat = config->handler_context.seat;
struct sway_workspace *ws = output_get_active_workspace(output);
+ if (!sway_assert(ws, "Expected output to have a workspace")) {
+ return NULL;
+ }
if (ws->fullscreen) {
return seat_get_focus_inactive(seat, &ws->fullscreen->node);
}
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 16f8cdb6..4306aac8 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,
return false;
}
struct sway_workspace *ws = output_get_active_workspace(new_output);
+ if (!sway_assert(ws, "Expected output to have a workspace")) {
+ return false;
+ }
container_move_to_workspace(container, ws);
return true;
}
@@ -360,6 +363,9 @@ static bool container_move_in_direction(struct sway_container *container,
output_get_in_direction(container->workspace->output, move_dir);
if (output) {
struct sway_workspace *ws = output_get_active_workspace(output);
+ if (!sway_assert(ws, "Expected output to have a workspace")) {
+ return false;
+ }
container_move_to_workspace_from_direction(container, ws, move_dir);
return true;
}
@@ -525,6 +531,10 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
case N_OUTPUT: {
struct sway_output *output = destination->sway_output;
struct sway_workspace *ws = output_get_active_workspace(output);
+ if (!sway_assert(ws, "Expected output to have a workspace")) {
+ return cmd_results_new(CMD_FAILURE,
+ "Expected output to have a workspace");
+ }
container_move_to_workspace(container, ws);
}
break;
@@ -538,6 +548,10 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
// restore focus on destination output back to its last active workspace
struct sway_workspace *new_workspace =
output_get_active_workspace(new_output);
+ if (!sway_assert(new_workspace, "Expected output to have a workspace")) {
+ return cmd_results_new(CMD_FAILURE,
+ "Expected output to have a workspace");
+ }
if (new_output_last_ws && new_output_last_ws != new_workspace) {
struct sway_node *new_output_last_focus =
seat_get_focus_inactive(seat, &new_output_last_ws->node);
@@ -585,6 +599,9 @@ static void workspace_move_to_output(struct sway_workspace *workspace,
workspace_detach(workspace);
struct sway_workspace *new_output_old_ws =
output_get_active_workspace(output);
+ if (!sway_assert(new_output_old_ws, "Expected output to have a workspace")) {
+ return;
+ }
output_add_workspace(output, workspace);
@@ -837,11 +854,11 @@ static struct cmd_results *cmd_move_to_scratchpad(void) {
}
}
- if (con->scratchpad) {
- return cmd_results_new(CMD_INVALID,
- "Container is already in the scratchpad");
+ if (!con->scratchpad) {
+ root_scratchpad_add_container(con);
+ } else if (con->workspace) {
+ root_scratchpad_hide(con);
}
- root_scratchpad_add_container(con);
return cmd_results_new(CMD_SUCCESS, NULL);
}
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 @@
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#include "list.h"
+#include "log.h"
#include "util.h"
struct cmd_results *cmd_sticky(int argc, char **argv) {
@@ -29,6 +30,11 @@ struct cmd_results *cmd_sticky(int argc, char **argv) {
// move container to active workspace
struct sway_workspace *active_workspace =
output_get_active_workspace(container->workspace->output);
+ if (!sway_assert(active_workspace,
+ "Expected output to have a workspace")) {
+ return cmd_results_new(CMD_FAILURE,
+ "Expected output to have a workspace");
+ }
if (container->workspace != active_workspace) {
struct sway_workspace *old_workspace = container->workspace;
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,
output_get_active_workspace(con1->workspace->output);
struct sway_workspace *vis2 =
output_get_active_workspace(con2->workspace->output);
+ if (!sway_assert(vis1 && vis2, "con1 or con2 are on an output without a"
+ "workspace. This should not happen")) {
+ return;
+ }
char *stored_prev_name = NULL;
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) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
- arrange_workspace(output_get_active_workspace(output));
+ struct sway_workspace *ws = output_get_active_workspace(output);
+ if (!sway_assert(ws, "Expected output to have a workspace")) {
+ return cmd_results_new(CMD_FAILURE,
+ "Expected output to have a workspace");
+ }
+ arrange_workspace(ws);
output_damage_whole(output);
}