diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2016-07-20 14:56:14 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2016-07-21 21:51:20 +0300 |
commit | e5c7b019ffd952010bd8ae25a436c96f223fbb2d (patch) | |
tree | a188e553545de834a14849639f01862fe4c92170 | |
parent | More progress on window events (diff) | |
download | sway-e5c7b019ffd952010bd8ae25a436c96f223fbb2d.tar.gz sway-e5c7b019ffd952010bd8ae25a436c96f223fbb2d.tar.zst sway-e5c7b019ffd952010bd8ae25a436c96f223fbb2d.zip |
Fix dispatching and assigning events
-rw-r--r-- | sway/ipc-server.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 24df4649..8110bd41 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -54,6 +54,8 @@ bool ipc_send_reply(struct ipc_client *client, const char *payload, uint32_t pay | |||
54 | void ipc_get_workspaces_callback(swayc_t *workspace, void *data); | 54 | void ipc_get_workspaces_callback(swayc_t *workspace, void *data); |
55 | void ipc_get_outputs_callback(swayc_t *container, void *data); | 55 | void ipc_get_outputs_callback(swayc_t *container, void *data); |
56 | 56 | ||
57 | #define event_mask(ev) (1 << (ev & 0x7F)) | ||
58 | |||
57 | void ipc_init(void) { | 59 | void ipc_init(void) { |
58 | ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); | 60 | ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); |
59 | if (ipc_socket == -1) { | 61 | if (ipc_socket == -1) { |
@@ -334,18 +336,18 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
334 | for (int i = 0; i < json_object_array_length(request); i++) { | 336 | for (int i = 0; i < json_object_array_length(request); i++) { |
335 | const char *event_type = json_object_get_string(json_object_array_get_idx(request, i)); | 337 | const char *event_type = json_object_get_string(json_object_array_get_idx(request, i)); |
336 | if (strcmp(event_type, "workspace") == 0) { | 338 | if (strcmp(event_type, "workspace") == 0) { |
337 | client->subscribed_events |= IPC_EVENT_WORKSPACE; | 339 | client->subscribed_events |= event_mask(IPC_EVENT_WORKSPACE); |
338 | } else if (strcmp(event_type, "barconfig_update") == 0) { | 340 | } else if (strcmp(event_type, "barconfig_update") == 0) { |
339 | client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; | 341 | client->subscribed_events |= event_mask(IPC_EVENT_BARCONFIG_UPDATE); |
340 | } else if (strcmp(event_type, "mode") == 0) { | 342 | } else if (strcmp(event_type, "mode") == 0) { |
341 | client->subscribed_events |= IPC_EVENT_MODE; | 343 | client->subscribed_events |= event_mask(IPC_EVENT_MODE); |
342 | } else if (strcmp(event_type, "window") == 0) { | 344 | } else if (strcmp(event_type, "window") == 0) { |
343 | client->subscribed_events |= IPC_EVENT_WINDOW; | 345 | client->subscribed_events |= event_mask(IPC_EVENT_WINDOW); |
344 | } else if (strcmp(event_type, "modifier") == 0) { | 346 | } else if (strcmp(event_type, "modifier") == 0) { |
345 | client->subscribed_events |= IPC_EVENT_MODIFIER; | 347 | client->subscribed_events |= event_mask(IPC_EVENT_MODIFIER); |
346 | #if SWAY_BINDING_EVENT | 348 | #if SWAY_BINDING_EVENT |
347 | } else if (strcmp(event_type, "binding") == 0) { | 349 | } else if (strcmp(event_type, "binding") == 0) { |
348 | client->subscribed_events |= IPC_EVENT_BINDING; | 350 | client->subscribed_events |= event_mask(IPC_EVENT_BINDING); |
349 | #endif | 351 | #endif |
350 | } else { | 352 | } else { |
351 | ipc_send_reply(client, "{\"success\": false}", 18); | 353 | ipc_send_reply(client, "{\"success\": false}", 18); |
@@ -524,7 +526,7 @@ void ipc_send_event(const char *json_string, enum ipc_command_type event) { | |||
524 | struct ipc_client *client; | 526 | struct ipc_client *client; |
525 | for (i = 0; i < ipc_client_list->length; i++) { | 527 | for (i = 0; i < ipc_client_list->length; i++) { |
526 | client = ipc_client_list->items[i]; | 528 | client = ipc_client_list->items[i]; |
527 | if ((client->subscribed_events & event) == 0) { | 529 | if ((client->subscribed_events & event_mask(event)) == 0) { |
528 | continue; | 530 | continue; |
529 | } | 531 | } |
530 | client->current_command = event; | 532 | client->current_command = event; |