diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 273ff3646..7fc2d95d8 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -271,7 +271,7 @@ void view_set_activated(struct sway_view *view, bool activated); /** * Called when the view requests to be focused. */ -void view_request_activate(struct sway_view *view); +void view_request_activate(struct sway_view *view, struct sway_seat *seat); /** * If possible, instructs the client to change their decoration mode. diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index e15a33415..9c29f66ba 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -630,7 +630,7 @@ static void handle_request_activate(struct wl_listener *listener, void *data) { if (!xsurface->mapped) { return; } - view_request_activate(view); + view_request_activate(view, NULL); transaction_commit_dirty(); } diff --git a/sway/tree/view.c b/sway/tree/view.c index ec0ad4afb..ba3ef4891 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -366,12 +366,14 @@ void view_set_activated(struct sway_view *view, bool activated) { } } -void view_request_activate(struct sway_view *view) { +void view_request_activate(struct sway_view *view, struct sway_seat *seat) { struct sway_workspace *ws = view->container->pending.workspace; if (!ws) { // hidden scratchpad container return; } - struct sway_seat *seat = input_manager_current_seat(); + if (!seat) { + seat = input_manager_current_seat(); + } switch (config->focus_on_window_activation) { case FOWA_SMART: diff --git a/sway/xdg_activation_v1.c b/sway/xdg_activation_v1.c index cc3dcec09..c20e42c18 100644 --- a/sway/xdg_activation_v1.c +++ b/sway/xdg_activation_v1.c @@ -31,5 +31,10 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, return; } - view_request_activate(view); + struct wlr_seat *wlr_seat = event->token->seat; + // The requesting seat may have been destroyed. + if (wlr_seat) { + struct sway_seat *seat = wlr_seat->data; + view_request_activate(view, seat); + } }