diff options
author | Orestis Floros <orestisflo@gmail.com> | 2022-12-14 13:19:00 +0100 |
---|---|---|
committer | Orestis Floros <orestisflo@gmail.com> | 2022-12-14 13:23:12 +0100 |
commit | d5c8319b6c5a93d32658c22792ca3fc5422937b2 (patch) | |
tree | 877f81e7a479295091e1f0b7c5b2f8d0712c0452 /src | |
parent | 1786b13f0dfd6280fc9111576e2fa4869091e773 (diff) | |
download | i3-d5c8319b6c5a93d32658c22792ca3fc5422937b2.tar.gz i3-d5c8319b6c5a93d32658c22792ca3fc5422937b2.zip |
Add "mode" field in binding event
This does *not* go in the binding object to reflect the same hierarchy
of the config file: a mode is a collection of bindings.
Fixes #5323
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings.c | 6 | ||||
-rw-r--r-- | src/ipc.c | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/bindings.c b/src/bindings.c index 0aa960d3..4cb916fa 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -843,6 +843,10 @@ CommandResult *run_binding(Binding *bind, Con *con) { sasprintf(&command, "[con_id=\"%p\"] %s", con, bind->command); Binding *bind_cp = binding_copy(bind); + /* The "mode" command might change the current mode, so back it up to + * correctly produce an event later. */ + const char *modename = current_binding_mode; + CommandResult *result = parse_command(command, NULL, NULL); free(command); @@ -868,7 +872,7 @@ CommandResult *run_binding(Binding *bind, Con *con) { free(pageraction); } - ipc_send_binding_event("run", bind_cp); + ipc_send_binding_event("run", bind_cp, modename); binding_free(bind_cp); return result; @@ -1678,7 +1678,7 @@ void ipc_send_barconfig_update_event(Barconfig *barconfig) { /* * For the binding events, we send the serialized binding struct. */ -void ipc_send_binding_event(const char *event_type, Binding *bind) { +void ipc_send_binding_event(const char *event_type, Binding *bind, const char *modename) { DLOG("Issue IPC binding %s event (sym = %s, code = %d)\n", event_type, bind->symbol, bind->keycode); setlocale(LC_NUMERIC, "C"); @@ -1690,6 +1690,13 @@ void ipc_send_binding_event(const char *event_type, Binding *bind) { ystr("change"); ystr(event_type); + ystr("mode"); + if (modename == NULL) { + ystr("default"); + } else { + ystr(modename); + } + ystr("binding"); dump_binding(gen, bind); |