summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpynappo <[email protected]>2025-01-16 10:33:45 -0800
committerGitHub <[email protected]>2025-01-16 19:33:45 +0100
commit897c6d810acfd31e6cc55df7692755b177a84fcb (patch)
treef2cbe4f93340f1e1ff9f6813aad9e19b399fffee
parent8e00ed94760379ccba1ca04c8bcd069afaf30484 (diff)
fix(hyprland): update clients on openwindow if needed (#148)
closes #188
-rw-r--r--lib/hyprland/hyprland.vala42
1 files changed, 25 insertions, 17 deletions
diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala
index 5bdff81..70b5a25 100644
--- a/lib/hyprland/hyprland.vala
+++ b/lib/hyprland/hyprland.vala
@@ -303,6 +303,20 @@ public class Hyprland : Object {
}
}
+ private async bool try_add_client(string addr) throws Error {
+ if (addr == "" || get_client(addr) != null) {
+ return true;
+ }
+
+ var client = new Client();
+ _clients.insert(addr, client);
+ yield sync_clients();
+ yield sync_workspaces();
+ client_added(client);
+ notify_property("clients");
+ return false;
+ }
+
private async void handle_event(string line) throws Error {
var args = line.split(">>");
@@ -320,21 +334,6 @@ public class Hyprland : Object {
focused_workspace = get_workspace_by_name(argv[1]);
break;
- // first event that signals a new client
- case "activewindowv2":
- if (args[1] != "" && get_client(args[1]) == null) {
- var client = new Client();
- _clients.insert(args[1], client);
- yield sync_clients();
- yield sync_workspaces();
- client_added(client);
- notify_property("clients");
- focused_client = client;
- } else {
- focused_client = get_client(args[1]);
- }
- break;
-
// TODO: nag vaxry for fullscreenv2 that passes address
case "fullscreen":
yield sync_clients();
@@ -393,9 +392,18 @@ public class Hyprland : Object {
keyboard_layout(argv[0], argv[1]);
break;
+ // first event that signals a new client when it opens as an active window
+ case "activewindowv2":
+ yield try_add_client(args[1]);
+ focused_client = get_client(args[1]);
+ break;
+
case "openwindow":
- yield sync_clients();
- yield sync_workspaces();
+ var addr = args[1].split(",")[0];
+ if (yield try_add_client(addr)) {
+ yield sync_clients();
+ yield sync_workspaces();
+ }
break;
case "closewindow":