diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-02 21:55:37 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-02 21:55:37 +1000 |
commit | 9339026a31103b453545cf65cd45f345e44d0437 (patch) | |
tree | afeaa5fc41b11ac8ef4e1cc0fc31efe6b6f723f5 | |
parent | Link xcb dependency to meson options "enable_xwayland" (#2393) (diff) | |
download | sway-9339026a31103b453545cf65cd45f345e44d0437.tar.gz sway-9339026a31103b453545cf65cd45f345e44d0437.tar.zst sway-9339026a31103b453545cf65cd45f345e44d0437.zip |
Fix focus related crashes
* seat_set_focus_warp lacked a container NULL check
* view mapping code needs to use seat_get_focus_inactive
Also, seat_set_focus_warp triggered the wrong IPC event if focus was a
workspace, which resulted in swaybar not showing the workspace as
active.
-rw-r--r-- | sway/input/seat.c | 8 | ||||
-rw-r--r-- | sway/tree/view.c | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 869560af..dd4d5c3b 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -775,8 +775,12 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
775 | } | 775 | } |
776 | } | 776 | } |
777 | 777 | ||
778 | if (container->type == C_VIEW) { | 778 | if (container) { |
779 | ipc_event_window(container, "focus"); | 779 | if (container->type == C_VIEW) { |
780 | ipc_event_window(container, "focus"); | ||
781 | } else if (container->type == C_WORKSPACE) { | ||
782 | ipc_event_workspace(NULL, container, "focus"); | ||
783 | } | ||
780 | } | 784 | } |
781 | 785 | ||
782 | seat->has_focus = (container != NULL); | 786 | seat->has_focus = (container != NULL); |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 051b93ce..97318daa 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -496,7 +496,7 @@ static struct sway_container *select_workspace(struct sway_view *view) { | |||
496 | } | 496 | } |
497 | 497 | ||
498 | // Use the focused workspace | 498 | // Use the focused workspace |
499 | ws = seat_get_focus(seat); | 499 | ws = seat_get_focus_inactive(seat, &root_container); |
500 | if (ws->type != C_WORKSPACE) { | 500 | if (ws->type != C_WORKSPACE) { |
501 | ws = container_parent(ws, C_WORKSPACE); | 501 | ws = container_parent(ws, C_WORKSPACE); |
502 | } | 502 | } |
@@ -505,7 +505,8 @@ static struct sway_container *select_workspace(struct sway_view *view) { | |||
505 | 505 | ||
506 | static bool should_focus(struct sway_view *view) { | 506 | static bool should_focus(struct sway_view *view) { |
507 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 507 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
508 | struct sway_container *prev_focus = seat_get_focus(seat); | 508 | struct sway_container *prev_focus = |
509 | seat_get_focus_inactive(seat, &root_container); | ||
509 | struct sway_container *prev_ws = prev_focus->type == C_WORKSPACE ? | 510 | struct sway_container *prev_ws = prev_focus->type == C_WORKSPACE ? |
510 | prev_focus : container_parent(prev_focus, C_WORKSPACE); | 511 | prev_focus : container_parent(prev_focus, C_WORKSPACE); |
511 | struct sway_container *map_ws = container_parent(view->swayc, C_WORKSPACE); | 512 | struct sway_container *map_ws = container_parent(view->swayc, C_WORKSPACE); |