aboutsummaryrefslogtreecommitdiff
path: root/sway/ipc-server.c
diff options
context:
space:
mode:
authorMikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-12-21 22:01:36 +0100
committerMikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-12-21 23:07:52 +0100
commit50b04884b65b7e04234e8fa794a4e6db48c133a4 (patch)
treeebf8c63bfb812a5d8bd7ab455a5b68ef81054dd2 /sway/ipc-server.c
parent442a54c38bb60d92bd4383f0d80ca55b876399e8 (diff)
Trigger ipc_event_workspace in all cases
This makes sure that the workspace IPC event is triggered when needed. Fixes #382 while making sure that the IPC event is only triggered once.
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r--sway/ipc-server.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index b459b5ce..e161c756 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -562,15 +562,23 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
return json;
}
-void ipc_event_workspace(swayc_t *old, swayc_t *new) {
+void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) {
json_object *obj = json_object_new_object();
- json_object_object_add(obj, "change", json_object_new_string("focus"));
- if (old) {
- json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
+ json_object_object_add(obj, "change", json_object_new_string(change));
+ if (strcmp("focus", change) == 0) {
+ if (old) {
+ json_object_object_add(obj, "old", ipc_json_describe_workspace(old));
+ } else {
+ json_object_object_add(obj, "old", NULL);
+ }
+ }
+
+ if (new) {
+ json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
} else {
- json_object_object_add(obj, "old", NULL);
+ json_object_object_add(obj, "current", NULL);
}
- json_object_object_add(obj, "current", ipc_json_describe_workspace(new));
+
const char *json_string = json_object_to_json_string(obj);
for (int i = 0; i < ipc_client_list->length; i++) {