diff options
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r-- | sway/ipc-server.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index ed3977d5..f3a4647b 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "commands.h" | 19 | #include "commands.h" |
20 | #include "list.h" | 20 | #include "list.h" |
21 | #include "stringop.h" | 21 | #include "stringop.h" |
22 | #include "util.h" | ||
22 | 23 | ||
23 | static int ipc_socket = -1; | 24 | static int ipc_socket = -1; |
24 | static struct wlc_event_source *ipc_event_source = NULL; | 25 | static struct wlc_event_source *ipc_event_source = NULL; |
@@ -295,6 +296,8 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
295 | client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; | 296 | client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; |
296 | } else if (strcmp(event_type, "mode") == 0) { | 297 | } else if (strcmp(event_type, "mode") == 0) { |
297 | client->subscribed_events |= IPC_EVENT_MODE; | 298 | client->subscribed_events |= IPC_EVENT_MODE; |
299 | } else if (strcmp(event_type, "modifier") == 0) { | ||
300 | client->subscribed_events |= IPC_EVENT_MODIFIER; | ||
298 | } else { | 301 | } else { |
299 | ipc_send_reply(client, "{\"success\": false}", 18); | 302 | ipc_send_reply(client, "{\"success\": false}", 18); |
300 | ipc_client_disconnect(client); | 303 | ipc_client_disconnect(client); |
@@ -508,7 +511,7 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | |||
508 | json_object_object_add(json, "tray_output", NULL); | 511 | json_object_object_add(json, "tray_output", NULL); |
509 | json_object_object_add(json, "mode", json_object_new_string(bar->mode)); | 512 | json_object_object_add(json, "mode", json_object_new_string(bar->mode)); |
510 | json_object_object_add(json, "hidden_state", json_object_new_string(bar->hidden_state)); | 513 | json_object_object_add(json, "hidden_state", json_object_new_string(bar->hidden_state)); |
511 | //json_object_object_add(json, "modifier", json_object_new_string(bar->modifier)); // TODO: Fix modifier | 514 | json_object_object_add(json, "modifier", json_object_new_string(get_modifier_name_by_mask(bar->modifier))); |
512 | switch (bar->position) { | 515 | switch (bar->position) { |
513 | case DESKTOP_SHELL_PANEL_POSITION_TOP: | 516 | case DESKTOP_SHELL_PANEL_POSITION_TOP: |
514 | json_object_object_add(json, "position", json_object_new_string("top")); | 517 | json_object_object_add(json, "position", json_object_new_string("top")); |
@@ -617,3 +620,16 @@ void ipc_event_mode(const char *mode) { | |||
617 | 620 | ||
618 | json_object_put(obj); // free | 621 | json_object_put(obj); // free |
619 | } | 622 | } |
623 | |||
624 | void ipc_event_modifier(uint32_t modifier, const char *state) { | ||
625 | json_object *obj = json_object_new_object(); | ||
626 | json_object_object_add(obj, "change", json_object_new_string(state)); | ||
627 | |||
628 | const char *modifier_name = get_modifier_name_by_mask(modifier); | ||
629 | json_object_object_add(obj, "modifier", json_object_new_string(modifier_name)); | ||
630 | |||
631 | const char *json_string = json_object_to_json_string(obj); | ||
632 | ipc_send_event(json_string, IPC_EVENT_MODIFIER); | ||
633 | |||
634 | json_object_put(obj); // free | ||
635 | } | ||