diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-10-09 22:05:05 +0100 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-03-01 21:44:52 +0100 |
commit | 44a2cff3b309f181848b535857b80e2e4e7891e1 (patch) | |
tree | 4bf19210814e8b6957f620a6f8a78c2df163082a /sway | |
parent | 5e18ed3cf03eee9e83909fede46dd98dff652647 (diff) |
ext-action-binder-v1: implement new protocol
and add a new command to trigger actions.
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'sway')
-rw-r--r-- | sway/action-binder-v1.c | 15 | ||||
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/action.c | 18 | ||||
-rw-r--r-- | sway/meson.build | 2 | ||||
-rw-r--r-- | sway/server.c | 11 |
5 files changed, 47 insertions, 0 deletions
diff --git a/sway/action-binder-v1.c b/sway/action-binder-v1.c new file mode 100644 index 00000000..bf6ffef5 --- /dev/null +++ b/sway/action-binder-v1.c @@ -0,0 +1,15 @@ +#include <wlr/types/wlr_action_binder_v1.h> + +void action_binder_v1_bind(struct wl_listener *listener, void *data) { + struct wlr_action_binder_v1_state *state = data; + struct wlr_action_binding_v1 *binding = NULL, *tmp = NULL; + wl_list_for_each_safe(binding, tmp, &state->bind_queue, link) { + wlr_action_binder_v1_bind(binding, ""); + } +} + +void action_binder_v1_unbind(struct wl_listener *listener, void *data) { +} + +void action_binder_v1_delete(struct wl_listener *listener, void *data) { +} diff --git a/sway/commands.c b/sway/commands.c index 8d003dfa..68879af7 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -112,6 +112,7 @@ static const struct cmd_handler config_handlers[] = { /* Runtime-only commands. Keep alphabetized */ static const struct cmd_handler command_handlers[] = { + { "action", cmd_action }, { "border", cmd_border }, { "create_output", cmd_create_output }, { "exit", cmd_exit }, diff --git a/sway/commands/action.c b/sway/commands/action.c new file mode 100644 index 00000000..96cb3b59 --- /dev/null +++ b/sway/commands/action.c @@ -0,0 +1,18 @@ +#include "log.h" +#include <wlr/types/wlr_action_binder_v1.h> +#include "ext-action-binder-v1-protocol.h" +#include "sway/commands.h" +#include "sway/server.h" +#include "sway/input/input-manager.h" + +struct cmd_results *cmd_action(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "action", EXPECTED_EQUAL_TO, 2))) { + return error; + } + + wlr_action_binder_v1_trigger(server.action_binder, argv[0], argv[1], + EXT_ACTION_BINDING_V1_TRIGGER_TYPE_ONE_SHOT); + + return cmd_results_new(CMD_SUCCESS, NULL); +} diff --git a/sway/meson.build b/sway/meson.build index d937e425..b24d8fbc 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -1,4 +1,5 @@ sway_sources = files( + 'action-binder-v1.c', 'commands.c', 'config.c', 'criteria.c', @@ -41,6 +42,7 @@ sway_sources = files( 'config/seat.c', 'config/input.c', + 'commands/action.c', 'commands/assign.c', 'commands/bar.c', 'commands/bind.c', diff --git a/sway/server.c b/sway/server.c index 684b1dbd..573a018b 100644 --- a/sway/server.c +++ b/sway/server.c @@ -350,6 +350,17 @@ bool server_init(struct sway_server *server) { wl_list_init(&server->pending_launcher_ctxs); + server->action_binder = wlr_action_binder_v1_create(server->wl_display); + server->action_binder_bind.notify = action_binder_v1_bind; + wl_signal_add(&server->action_binder->events.bind, + &server->action_binder_bind); + server->action_binder_unbind.notify = action_binder_v1_unbind; + wl_signal_add(&server->action_binder->events.unbind, + &server->action_binder_unbind); + server->action_binder_destroy.notify = action_binder_v1_delete; + wl_signal_add(&server->action_binder->events.destroy, + &server->action_binder_destroy); + // Avoid using "wayland-0" as display socket char name_candidate[16]; for (unsigned int i = 1; i <= 32; ++i) { |