aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-03-12 13:57:40 -0400
committerLibravatar emersion <contact@emersion.fr>2019-03-12 19:14:04 +0100
commit3330faded5ed59b19b2a1982bb52c05322b03510 (patch)
treef6acaeb4793ff21534e84ea5b9b37bf87ddf7f91 /sway/tree/workspace.c
parentconfig.in: allow launch apps with args via dmenu (diff)
downloadsway-3330faded5ed59b19b2a1982bb52c05322b03510.tar.gz
sway-3330faded5ed59b19b2a1982bb52c05322b03510.tar.zst
sway-3330faded5ed59b19b2a1982bb52c05322b03510.zip
Handle seat_get_focused_workspace returning NULL
This modifiers the callers of seat_get_focused_workspace to handle getting NULL as the return value, if they did not already.
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 73322491..5e28197b 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -368,13 +368,13 @@ struct sway_workspace *workspace_by_name(const char *name) {
368 struct sway_seat *seat = input_manager_current_seat(); 368 struct sway_seat *seat = input_manager_current_seat();
369 struct sway_workspace *current = seat_get_focused_workspace(seat); 369 struct sway_workspace *current = seat_get_focused_workspace(seat);
370 370
371 if (strcmp(name, "prev") == 0) { 371 if (current && strcmp(name, "prev") == 0) {
372 return workspace_prev(current); 372 return workspace_prev(current);
373 } else if (strcmp(name, "prev_on_output") == 0) { 373 } else if (current && strcmp(name, "prev_on_output") == 0) {
374 return workspace_output_prev(current, false); 374 return workspace_output_prev(current, false);
375 } else if (strcmp(name, "next") == 0) { 375 } else if (current && strcmp(name, "next") == 0) {
376 return workspace_next(current); 376 return workspace_next(current);
377 } else if (strcmp(name, "next_on_output") == 0) { 377 } else if (current && strcmp(name, "next_on_output") == 0) {
378 return workspace_output_next(current, false); 378 return workspace_output_next(current, false);
379 } else if (strcmp(name, "current") == 0) { 379 } else if (strcmp(name, "current") == 0) {
380 return current; 380 return current;
@@ -399,6 +399,11 @@ static struct sway_workspace *workspace_output_prev_next_impl(
399 struct sway_output *output, int dir, bool create) { 399 struct sway_output *output, int dir, bool create) {
400 struct sway_seat *seat = input_manager_current_seat(); 400 struct sway_seat *seat = input_manager_current_seat();
401 struct sway_workspace *workspace = seat_get_focused_workspace(seat); 401 struct sway_workspace *workspace = seat_get_focused_workspace(seat);
402 if (!workspace) {
403 sway_log(SWAY_DEBUG,
404 "No focused workspace to base prev/next on output off of");
405 return NULL;
406 }
402 407
403 int index = list_find(output->workspaces, workspace); 408 int index = list_find(output->workspaces, workspace);
404 if (!workspace_is_empty(workspace) && create && 409 if (!workspace_is_empty(workspace) && create &&