Skip to content

Commit 842609d

Browse files
committed
view: make request_activate take a seat
This way we can move focus on the same seat an activation token originates from.
1 parent 0780d3a commit 842609d

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

include/sway/tree/view.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void view_set_activated(struct sway_view *view, bool activated);
271271
/**
272272
* Called when the view requests to be focused.
273273
*/
274-
void view_request_activate(struct sway_view *view);
274+
void view_request_activate(struct sway_view *view, struct sway_seat *seat);
275275

276276
/**
277277
* If possible, instructs the client to change their decoration mode.

sway/desktop/xwayland.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static void handle_request_activate(struct wl_listener *listener, void *data) {
630630
if (!xsurface->mapped) {
631631
return;
632632
}
633-
view_request_activate(view);
633+
view_request_activate(view, NULL);
634634

635635
transaction_commit_dirty();
636636
}

sway/tree/view.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,14 @@ void view_set_activated(struct sway_view *view, bool activated) {
366366
}
367367
}
368368

369-
void view_request_activate(struct sway_view *view) {
369+
void view_request_activate(struct sway_view *view, struct sway_seat *seat) {
370370
struct sway_workspace *ws = view->container->pending.workspace;
371371
if (!ws) { // hidden scratchpad container
372372
return;
373373
}
374-
struct sway_seat *seat = input_manager_current_seat();
374+
if (!seat) {
375+
seat = input_manager_current_seat();
376+
}
375377

376378
switch (config->focus_on_window_activation) {
377379
case FOWA_SMART:

sway/xdg_activation_v1.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
3131
return;
3232
}
3333

34-
view_request_activate(view);
34+
struct wlr_seat *wlr_seat = event->token->seat;
35+
// The requesting seat may have been destroyed.
36+
if (wlr_seat) {
37+
struct sway_seat *seat = wlr_seat->data;
38+
view_request_activate(view, seat);
39+
}
3540
}

0 commit comments

Comments
 (0)