launcher: track the seat in the launcher ctx

This is a more suitable place to track the requesting seat, since we are
able to respond appropriately to destroy notifications.
This commit is contained in:
Ronan Pigott 2024-02-07 16:13:25 -07:00
parent 541e6e260c
commit f6d22f8e68
3 changed files with 31 additions and 6 deletions

View file

@ -18,11 +18,15 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
return;
}
struct launcher_ctx *ctx = event->token->data;
if (ctx == NULL) {
return;
}
if (!xdg_surface->surface->mapped) {
// This is a startup notification. If we are tracking it, the data
// field is a launcher_ctx.
struct launcher_ctx *ctx = event->token->data;
if (!ctx || ctx->activated) {
if (ctx->activated) {
// This ctx has already been activated and cannot be used again
// for a startup notification. It will be destroyed
return;
@ -33,9 +37,16 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
return;
}
struct wlr_seat *wlr_seat = event->token->seat;
struct sway_seat *seat = wlr_seat ? wlr_seat->data : NULL;
view_request_activate(view, seat);
// This is an activation request. If this context is internal we have ctx->seat.
struct sway_seat *seat = ctx->seat;
if (!seat) {
// Otherwise, use the seat indicated by the launcher client in set_serial
seat = ctx->token->seat ? ctx->token->seat->data : NULL;
}
if (seat) {
view_request_activate(view, seat);
}
}
void xdg_activation_v1_handle_new_token(struct wl_listener *listener, void *data) {