diff options
-rw-r--r-- | lib/sway/node.vala | 11 | ||||
-rw-r--r-- | lib/sway/sway.vala | 14 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/sway/node.vala b/lib/sway/node.vala index 9a0332c..8f1e925 100644 --- a/lib/sway/node.vala +++ b/lib/sway/node.vala @@ -66,13 +66,7 @@ public class Node : Object { } } - internal static async void sync_tree() { - var str = yield Sway.get_default().message_async(PayloadType.MESSAGE_GET_TREE, ""); - var obj = Json.from_string(str).get_object(); - if (obj == null) { - return; - } - + internal static async void sync_tree(Json.Object obj) { Node root = build(obj); _temp_nodes = new HashTable<int, Node>(i => i, (a,b) => a==b); root.sync(obj); @@ -99,7 +93,8 @@ public class Node : Object { var arr2 = obj.get_array_member("floating_nodes"); sync_nodes(arr); sync_nodes(arr2); - + + notify_property("windows"); } private void sync_nodes(Json.Array arr) { diff --git a/lib/sway/sway.vala b/lib/sway/sway.vala index 8fdbb17..f6c20b4 100644 --- a/lib/sway/sway.vala +++ b/lib/sway/sway.vala @@ -29,7 +29,12 @@ public class Sway : Object { private void init() throws Error { ipc = new Ipc(); ipc.init(); - subscribe.begin(() => sync_tree.begin()); + subscribe.begin(); + sync_tree.begin(() => { + notify_property("outputs"); + notify_property("workspaces"); + notify_property("windows"); + }); } public Workspace focused_workspace; @@ -95,7 +100,12 @@ public class Sway : Object { } public async void sync_tree() { - yield Node.sync_tree(); + var str = yield message_async(MESSAGE_GET_TREE, ""); + var obj = Json.from_string(str).get_object(); + if (obj == null) { + return; + } + yield Node.sync_tree(obj); _nodes = Node._all_nodes; var new_workspaces = new HashTable<string, Workspace>(str_hash, str_equal); |