aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/focus.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-02 21:22:38 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-05 18:01:43 +1000
commit7263e39f6423d928b71916b43972c51fb11a00c9 (patch)
treebb787fad1867a8f32f215ce53399b038b260cd2e /sway/commands/focus.c
parentFix scratchpad related crashes (diff)
downloadsway-7263e39f6423d928b71916b43972c51fb11a00c9.tar.gz
sway-7263e39f6423d928b71916b43972c51fb11a00c9.tar.zst
sway-7263e39f6423d928b71916b43972c51fb11a00c9.zip
Fix crash when using focus parent/child from an empty workspace
Diffstat (limited to 'sway/commands/focus.c')
-rw-r--r--sway/commands/focus.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index e48e48aa..83b8c64a 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -95,9 +95,6 @@ static struct sway_node *get_node_in_output_direction(
95 95
96static struct sway_node *node_get_in_direction(struct sway_container *container, 96static struct sway_node *node_get_in_direction(struct sway_container *container,
97 struct sway_seat *seat, enum movement_direction dir) { 97 struct sway_seat *seat, enum movement_direction dir) {
98 if (dir == MOVE_CHILD) {
99 return seat_get_active_child(seat, &container->node);
100 }
101 if (container->is_fullscreen) { 98 if (container->is_fullscreen) {
102 if (dir == MOVE_PARENT) { 99 if (dir == MOVE_PARENT) {
103 return NULL; 100 return NULL;
@@ -256,8 +253,20 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
256 "or 'focus output <direction|name>'"); 253 "or 'focus output <direction|name>'");
257 } 254 }
258 255
256 if (direction == MOVE_CHILD) {
257 struct sway_node *focus = seat_get_active_child(seat, node);
258 if (focus) {
259 seat_set_focus(seat, focus);
260 }
261 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
262 }
263
259 if (node->type == N_WORKSPACE) { 264 if (node->type == N_WORKSPACE) {
260 // A workspace is focused, so just jump to the next output 265 if (direction == MOVE_PARENT) {
266 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
267 }
268
269 // Jump to the next output
261 struct sway_output *new_output = 270 struct sway_output *new_output =
262 output_get_in_direction(workspace->output, direction); 271 output_get_in_direction(workspace->output, direction);
263 if (!new_output) { 272 if (!new_output) {