mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
Merge 52d0f4d6ca into 7e74a49142
This commit is contained in:
commit
5c1b9a7a13
9 changed files with 207 additions and 0 deletions
15
sway/action-binder-v1.c
Normal file
15
sway/action-binder-v1.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include <wlr/types/wlr_action_binder_v1.h>
|
||||
#include "stringop.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) {
|
||||
char *msg = format_str("User defined trigger for %s:%s in the config file.",
|
||||
binding->namespace, binding->name);
|
||||
wlr_action_binding_v1_bind(binding, msg ? msg : "");
|
||||
}
|
||||
}
|
||||
|
||||
void action_binder_v1_delete(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
|
|
@ -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 },
|
||||
|
|
|
|||
23
sway/commands/action.c
Normal file
23
sway/commands/action.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#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;
|
||||
}
|
||||
|
||||
struct wlr_action_binder_v1_state *state = NULL;
|
||||
struct wlr_action_binding_v1 *binding = NULL;
|
||||
wl_list_for_each(state, &server.action_binder->states, link) {
|
||||
wl_list_for_each(binding, &state->binds, link) {
|
||||
wlr_action_binding_v1_trigger(binding, EXT_ACTION_BINDING_V1_TRIGGER_TYPE_ONE_SHOT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <wlr/config.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_action_binder_v1.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_content_type_v1.h>
|
||||
#include <wlr/types/wlr_cursor_shape_v1.h>
|
||||
|
|
@ -394,6 +395,14 @@ 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_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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue