diff options
author | Ronan Pigott <ronan@rjp.ie> | 2022-11-30 11:54:50 -0700 |
---|---|---|
committer | Ronan Pigott <ronan@rjp.ie> | 2023-02-05 00:53:47 -0700 |
commit | 4cda9ee3a3aa122f3f1a6f570d8befa78083c1b5 (patch) | |
tree | dbb1675b116264d102847d929dec5a9c76c3c88d | |
parent | launcher: make launcher context seat aware (diff) | |
download | sway-4cda9ee3a3aa122f3f1a6f570d8befa78083c1b5.tar.gz sway-4cda9ee3a3aa122f3f1a6f570d8befa78083c1b5.tar.zst sway-4cda9ee3a3aa122f3f1a6f570d8befa78083c1b5.zip |
launcher: support external launcher tokens
-rw-r--r-- | include/sway/server.h | 3 | ||||
-rw-r--r-- | sway/server.c | 4 | ||||
-rw-r--r-- | sway/xdg_activation_v1.c | 13 |
3 files changed, 20 insertions, 0 deletions
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 { | |||
114 | 114 | ||
115 | struct wlr_xdg_activation_v1 *xdg_activation_v1; | 115 | struct wlr_xdg_activation_v1 *xdg_activation_v1; |
116 | struct wl_listener xdg_activation_v1_request_activate; | 116 | struct wl_listener xdg_activation_v1_request_activate; |
117 | struct wl_listener xdg_activation_v1_new_token; | ||
117 | 118 | ||
118 | struct wl_list pending_launcher_ctxs; // launcher_ctx::link | 119 | struct wl_list pending_launcher_ctxs; // launcher_ctx::link |
119 | 120 | ||
@@ -175,6 +176,8 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data); | |||
175 | void handle_pointer_constraint(struct wl_listener *listener, void *data); | 176 | void handle_pointer_constraint(struct wl_listener *listener, void *data); |
176 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | 177 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, |
177 | void *data); | 178 | void *data); |
179 | void xdg_activation_v1_handle_new_token(struct wl_listener *listener, | ||
180 | void *data); | ||
178 | 181 | ||
179 | void set_rr_scheduling(void); | 182 | void set_rr_scheduling(void); |
180 | 183 | ||
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) { | |||
225 | xdg_activation_v1_handle_request_activate; | 225 | xdg_activation_v1_handle_request_activate; |
226 | wl_signal_add(&server->xdg_activation_v1->events.request_activate, | 226 | wl_signal_add(&server->xdg_activation_v1->events.request_activate, |
227 | &server->xdg_activation_v1_request_activate); | 227 | &server->xdg_activation_v1_request_activate); |
228 | server->xdg_activation_v1_new_token.notify = | ||
229 | xdg_activation_v1_handle_new_token; | ||
230 | wl_signal_add(&server->xdg_activation_v1->events.new_token, | ||
231 | &server->xdg_activation_v1_new_token); | ||
228 | 232 | ||
229 | wl_list_init(&server->pending_launcher_ctxs); | 233 | wl_list_init(&server->pending_launcher_ctxs); |
230 | 234 | ||
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 @@ | |||
1 | #include <wlr/types/wlr_xdg_activation_v1.h> | 1 | #include <wlr/types/wlr_xdg_activation_v1.h> |
2 | #include "sway/desktop/launcher.h" | 2 | #include "sway/desktop/launcher.h" |
3 | #include "sway/tree/view.h" | 3 | #include "sway/tree/view.h" |
4 | #include "sway/tree/workspace.h" | ||
4 | 5 | ||
5 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | 6 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, |
6 | void *data) { | 7 | void *data) { |
@@ -38,3 +39,15 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | |||
38 | view_request_activate(view, seat); | 39 | view_request_activate(view, seat); |
39 | } | 40 | } |
40 | } | 41 | } |
42 | |||
43 | void xdg_activation_v1_handle_new_token(struct wl_listener *listener, void *data) { | ||
44 | struct wlr_xdg_activation_token_v1 *token = data; | ||
45 | struct sway_seat *seat = token->seat ? token->seat->data : | ||
46 | input_manager_current_seat(); | ||
47 | |||
48 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | ||
49 | if (ws) { | ||
50 | launcher_ctx_create(token, &ws->node); | ||
51 | return; | ||
52 | } | ||
53 | } | ||