diff options
-rw-r--r-- | sway/input/seat.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index d1fc62c4..e88bcfd1 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -476,10 +476,11 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
476 | // find new output's old workspace, which might have to be removed if empty | 476 | // find new output's old workspace, which might have to be removed if empty |
477 | struct sway_container *new_output_last_ws = NULL; | 477 | struct sway_container *new_output_last_ws = NULL; |
478 | if (last_output && new_output && last_output != new_output) { | 478 | if (last_output && new_output && last_output != new_output) { |
479 | new_output_last_ws = seat_get_focus_by_type(seat, new_output, C_WORKSPACE); | 479 | new_output_last_ws = |
480 | seat_get_focus_by_type(seat, new_output, C_WORKSPACE); | ||
480 | } | 481 | } |
481 | 482 | ||
482 | if (container) { | 483 | if (container && container->parent) { |
483 | struct sway_seat_container *seat_con = | 484 | struct sway_seat_container *seat_con = |
484 | seat_container_from_container(seat, container); | 485 | seat_container_from_container(seat, container); |
485 | if (seat_con == NULL) { | 486 | if (seat_con == NULL) { |
@@ -488,8 +489,7 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
488 | 489 | ||
489 | // put all the anscestors of this container on top of the focus stack | 490 | // put all the anscestors of this container on top of the focus stack |
490 | struct sway_seat_container *parent = | 491 | struct sway_seat_container *parent = |
491 | seat_container_from_container(seat, | 492 | seat_container_from_container(seat, container->parent); |
492 | seat_con->container->parent); | ||
493 | while (parent) { | 493 | while (parent) { |
494 | wl_list_remove(&parent->link); | 494 | wl_list_remove(&parent->link); |
495 | wl_list_insert(&seat->focus_stack, &parent->link); | 495 | wl_list_insert(&seat->focus_stack, &parent->link); |
@@ -516,24 +516,24 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
516 | // clean up unfocused empty workspace on new output | 516 | // clean up unfocused empty workspace on new output |
517 | if (new_output_last_ws) { | 517 | if (new_output_last_ws) { |
518 | if (!workspace_is_visible(new_output_last_ws) | 518 | if (!workspace_is_visible(new_output_last_ws) |
519 | && new_output_last_ws->children->length == 0) { | 519 | && new_output_last_ws->children->length == 0) { |
520 | if (last_workspace == new_output_last_ws) { | ||
521 | last_focus = NULL; | ||
522 | last_workspace = NULL; | ||
523 | } | ||
520 | container_destroy(new_output_last_ws); | 524 | container_destroy(new_output_last_ws); |
521 | } | 525 | } |
522 | } | 526 | } |
523 | 527 | ||
524 | if (last_focus) { | 528 | if (last_focus) { |
525 | struct sway_container *last_ws = last_focus; | 529 | if (last_workspace) { |
526 | if (last_ws && last_ws->type != C_WORKSPACE) { | 530 | ipc_event_workspace(last_workspace, container, "focus"); |
527 | last_ws = container_parent(last_ws, C_WORKSPACE); | 531 | if (!workspace_is_visible(last_workspace) |
528 | } | 532 | && last_workspace->children->length == 0) { |
529 | if (last_ws) { | 533 | if (last_workspace == last_focus) { |
530 | ipc_event_workspace(last_ws, container, "focus"); | ||
531 | if (!workspace_is_visible(last_ws) | ||
532 | && last_ws->children->length == 0) { | ||
533 | if (last_ws == last_focus) { | ||
534 | last_focus = NULL; | 534 | last_focus = NULL; |
535 | } | 535 | } |
536 | container_destroy(last_ws); | 536 | container_destroy(last_workspace); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||