From 4cda9ee3a3aa122f3f1a6f570d8befa78083c1b5 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Wed, 30 Nov 2022 11:54:50 -0700 Subject: [PATCH] launcher: support external launcher tokens --- include/sway/server.h | 3 +++ sway/server.c | 4 ++++ sway/xdg_activation_v1.c | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/sway/server.h b/include/sway/server.h index 309d9d3e..a65843ce 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -114,6 +114,7 @@ struct sway_server { struct wlr_xdg_activation_v1 *xdg_activation_v1; struct wl_listener xdg_activation_v1_request_activate; + struct wl_listener xdg_activation_v1_new_token; struct wl_list pending_launcher_ctxs; // launcher_ctx::link @@ -175,6 +176,8 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data); void handle_pointer_constraint(struct wl_listener *listener, void *data); void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, void *data); +void xdg_activation_v1_handle_new_token(struct wl_listener *listener, + void *data); void set_rr_scheduling(void); diff --git a/sway/server.c b/sway/server.c index 43ff8cfb..1ff0b461 100644 --- a/sway/server.c +++ b/sway/server.c @@ -225,6 +225,10 @@ bool server_init(struct sway_server *server) { xdg_activation_v1_handle_request_activate; wl_signal_add(&server->xdg_activation_v1->events.request_activate, &server->xdg_activation_v1_request_activate); + server->xdg_activation_v1_new_token.notify = + xdg_activation_v1_handle_new_token; + wl_signal_add(&server->xdg_activation_v1->events.new_token, + &server->xdg_activation_v1_new_token); wl_list_init(&server->pending_launcher_ctxs); diff --git a/sway/xdg_activation_v1.c b/sway/xdg_activation_v1.c index c20e42c1..614f51cd 100644 --- a/sway/xdg_activation_v1.c +++ b/sway/xdg_activation_v1.c @@ -1,6 +1,7 @@ #include #include "sway/desktop/launcher.h" #include "sway/tree/view.h" +#include "sway/tree/workspace.h" void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, void *data) { @@ -38,3 +39,15 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, view_request_activate(view, seat); } } + +void xdg_activation_v1_handle_new_token(struct wl_listener *listener, void *data) { + struct wlr_xdg_activation_token_v1 *token = data; + struct sway_seat *seat = token->seat ? token->seat->data : + input_manager_current_seat(); + + struct sway_workspace *ws = seat_get_focused_workspace(seat); + if (ws) { + launcher_ctx_create(token, &ws->node); + return; + } +}