view: make request_activate take a seat

This way we can move focus on the same seat an activation token
originates from.
This commit is contained in:
Ronan Pigott 2022-11-30 12:02:10 -07:00
parent 0780d3a465
commit 842609da64
4 changed files with 12 additions and 5 deletions

View file

@ -271,7 +271,7 @@ void view_set_activated(struct sway_view *view, bool activated);
/** /**
* Called when the view requests to be focused. * 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. * If possible, instructs the client to change their decoration mode.

View file

@ -630,7 +630,7 @@ static void handle_request_activate(struct wl_listener *listener, void *data) {
if (!xsurface->mapped) { if (!xsurface->mapped) {
return; return;
} }
view_request_activate(view); view_request_activate(view, NULL);
transaction_commit_dirty(); transaction_commit_dirty();
} }

View file

@ -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; struct sway_workspace *ws = view->container->pending.workspace;
if (!ws) { // hidden scratchpad container if (!ws) { // hidden scratchpad container
return; return;
} }
struct sway_seat *seat = input_manager_current_seat(); if (!seat) {
seat = input_manager_current_seat();
}
switch (config->focus_on_window_activation) { switch (config->focus_on_window_activation) {
case FOWA_SMART: case FOWA_SMART:

View file

@ -31,5 +31,10 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
return; 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);
}
} }