aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-09-02 21:22:38 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-09-05 18:01:43 +1000
commit7263e39f6423d928b71916b43972c51fb11a00c9 (patch)
treebb787fad1867a8f32f215ce53399b038b260cd2e /sway/commands
parent4e0452fce3bfc96db6f6f2951794cbb26e75ccd7 (diff)
Fix crash when using focus parent/child from an empty workspace
Diffstat (limited to 'sway/commands')
-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(
static struct sway_node *node_get_in_direction(struct sway_container *container,
struct sway_seat *seat, enum movement_direction dir) {
- if (dir == MOVE_CHILD) {
- return seat_get_active_child(seat, &container->node);
- }
if (container->is_fullscreen) {
if (dir == MOVE_PARENT) {
return NULL;
@@ -256,8 +253,20 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
"or 'focus output <direction|name>'");
}
+ if (direction == MOVE_CHILD) {
+ struct sway_node *focus = seat_get_active_child(seat, node);
+ if (focus) {
+ seat_set_focus(seat, focus);
+ }
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+ }
+
if (node->type == N_WORKSPACE) {
- // A workspace is focused, so just jump to the next output
+ if (direction == MOVE_PARENT) {
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+ }
+
+ // Jump to the next output
struct sway_output *new_output =
output_get_in_direction(workspace->output, direction);
if (!new_output) {