diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2016-07-12 13:58:24 +0000 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2016-07-21 21:51:20 +0300 |
commit | 976e48d79f46fbab02d7af0ae1b6804018774a63 (patch) | |
tree | f230178d62aff86bd83181b588e055aa7963d2a6 /sway/ipc-server.c | |
parent | Remove arrange_windows from post-render (diff) | |
download | sway-976e48d79f46fbab02d7af0ae1b6804018774a63.tar.gz sway-976e48d79f46fbab02d7af0ae1b6804018774a63.tar.zst sway-976e48d79f46fbab02d7af0ae1b6804018774a63.zip |
Initial work on window events
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r-- | sway/ipc-server.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 0729bfd5..1dc3ab79 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -339,6 +339,8 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
339 | client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; | 339 | client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; |
340 | } else if (strcmp(event_type, "mode") == 0) { | 340 | } else if (strcmp(event_type, "mode") == 0) { |
341 | client->subscribed_events |= IPC_EVENT_MODE; | 341 | client->subscribed_events |= IPC_EVENT_MODE; |
342 | } else if (strcmp(event_type, "window") == 0) { | ||
343 | client->subscribed_events |= IPC_EVENT_WINDOW; | ||
342 | } else if (strcmp(event_type, "modifier") == 0) { | 344 | } else if (strcmp(event_type, "modifier") == 0) { |
343 | client->subscribed_events |= IPC_EVENT_MODIFIER; | 345 | client->subscribed_events |= IPC_EVENT_MODIFIER; |
344 | #if SWAY_BINDING_EVENT | 346 | #if SWAY_BINDING_EVENT |
@@ -556,6 +558,21 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) { | |||
556 | json_object_put(obj); // free | 558 | json_object_put(obj); // free |
557 | } | 559 | } |
558 | 560 | ||
561 | void ipc_event_window(swayc_t *window, const char *change) { | ||
562 | json_object *obj = json_object_new_object(); | ||
563 | json_object_object_add(obj, "change", json_object_new_string(change)); | ||
564 | if (strcmp(change, "close") == 0 || !window) { | ||
565 | json_object_object_add(obj, "container", NULL); | ||
566 | } else { | ||
567 | json_object_object_add(obj, "container", ipc_json_describe_container(window)); | ||
568 | } | ||
569 | |||
570 | const char *json_string = json_object_to_json_string(obj); | ||
571 | ipc_send_event(json_string, IPC_EVENT_WINDOW); | ||
572 | |||
573 | json_object_put(obj); // free | ||
574 | } | ||
575 | |||
559 | void ipc_event_barconfig_update(struct bar_config *bar) { | 576 | void ipc_event_barconfig_update(struct bar_config *bar) { |
560 | json_object *json = ipc_json_describe_bar_config(bar); | 577 | json_object *json = ipc_json_describe_bar_config(bar); |
561 | const char *json_string = json_object_to_json_string(json); | 578 | const char *json_string = json_object_to_json_string(json); |