aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2021-11-11 15:31:27 +0100
committerGuido Günther <agx@sigxcpu.org>2021-12-14 12:01:46 +0100
commit4c59f7d46a949548caa55805b00922f846d58525 (patch)
tree1f995612baa77e092edde4ee9c068d0f153c90b2
parent31914928d22934a09d2f19ef996500c324bd5ff2 (diff)
xdg-activation: Allow to submit tokens
Allows the compositor to submit tokens to the pool of currently active tokens. This can be useful when the launcher doesn't use or support xdg-activation-v1 by itself - e.g. when it is X11 based or use gtk_shell1.
-rw-r--r--include/wlr/types/wlr_xdg_activation_v1.h4
-rw-r--r--types/wlr_xdg_activation_v1.c20
2 files changed, 24 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_xdg_activation_v1.h b/include/wlr/types/wlr_xdg_activation_v1.h
index 46356215..97801af2 100644
--- a/include/wlr/types/wlr_xdg_activation_v1.h
+++ b/include/wlr/types/wlr_xdg_activation_v1.h
@@ -81,4 +81,8 @@ struct wlr_xdg_activation_token_v1 *wlr_xdg_activation_v1_find_token(
const char *wlr_xdg_activation_token_v1_get_name(
struct wlr_xdg_activation_token_v1 *token);
+// Add a token to the pool of known tokens
+struct wlr_xdg_activation_token_v1 *wlr_xdg_activation_v1_add_token(
+ struct wlr_xdg_activation_v1 *activation, const char *token_str);
+
#endif
diff --git a/types/wlr_xdg_activation_v1.c b/types/wlr_xdg_activation_v1.c
index 64864d88..208ada28 100644
--- a/types/wlr_xdg_activation_v1.c
+++ b/types/wlr_xdg_activation_v1.c
@@ -407,3 +407,23 @@ const char *wlr_xdg_activation_token_v1_get_name(
struct wlr_xdg_activation_token_v1 *token) {
return token->token;
}
+
+struct wlr_xdg_activation_token_v1 *wlr_xdg_activation_v1_add_token(
+ struct wlr_xdg_activation_v1 *activation, const char *token_str) {
+ assert(token_str);
+
+ struct wlr_xdg_activation_token_v1 *token = calloc(1, sizeof(*token));
+ if (token == NULL) {
+ return NULL;
+ }
+ wl_list_init(&token->link);
+ wl_list_init(&token->seat_destroy.link);
+ wl_list_init(&token->surface_destroy.link);
+
+ token->activation = activation;
+ token->token = strdup(token_str);
+
+ wl_list_insert(&activation->tokens, &token->link);
+
+ return token;
+}