From 976e48d79f46fbab02d7af0ae1b6804018774a63 Mon Sep 17 00:00:00 2001 From: Mykyta Holubakha Date: Tue, 12 Jul 2016 13:58:24 +0000 Subject: Initial work on window events --- sway/ipc-server.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sway/ipc-server.c') 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) { client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; } else if (strcmp(event_type, "mode") == 0) { client->subscribed_events |= IPC_EVENT_MODE; + } else if (strcmp(event_type, "window") == 0) { + client->subscribed_events |= IPC_EVENT_WINDOW; } else if (strcmp(event_type, "modifier") == 0) { client->subscribed_events |= IPC_EVENT_MODIFIER; #if SWAY_BINDING_EVENT @@ -556,6 +558,21 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) { json_object_put(obj); // free } +void ipc_event_window(swayc_t *window, const char *change) { + json_object *obj = json_object_new_object(); + json_object_object_add(obj, "change", json_object_new_string(change)); + if (strcmp(change, "close") == 0 || !window) { + json_object_object_add(obj, "container", NULL); + } else { + json_object_object_add(obj, "container", ipc_json_describe_container(window)); + } + + const char *json_string = json_object_to_json_string(obj); + ipc_send_event(json_string, IPC_EVENT_WINDOW); + + json_object_put(obj); // free +} + void ipc_event_barconfig_update(struct bar_config *bar) { json_object *json = ipc_json_describe_bar_config(bar); const char *json_string = json_object_to_json_string(json); -- cgit v1.2.3