Skip to content

Commit 897c6d8

Browse files
authored
fix(hyprland): update clients on openwindow if needed (#148)
closes #188
1 parent 8e00ed9 commit 897c6d8

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

lib/hyprland/hyprland.vala

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,20 @@ public class Hyprland : Object {
303303
}
304304
}
305305

306+
private async bool try_add_client(string addr) throws Error {
307+
if (addr == "" || get_client(addr) != null) {
308+
return true;
309+
}
310+
311+
var client = new Client();
312+
_clients.insert(addr, client);
313+
yield sync_clients();
314+
yield sync_workspaces();
315+
client_added(client);
316+
notify_property("clients");
317+
return false;
318+
}
319+
306320
private async void handle_event(string line) throws Error {
307321
var args = line.split(">>");
308322

@@ -320,21 +334,6 @@ public class Hyprland : Object {
320334
focused_workspace = get_workspace_by_name(argv[1]);
321335
break;
322336

323-
// first event that signals a new client
324-
case "activewindowv2":
325-
if (args[1] != "" && get_client(args[1]) == null) {
326-
var client = new Client();
327-
_clients.insert(args[1], client);
328-
yield sync_clients();
329-
yield sync_workspaces();
330-
client_added(client);
331-
notify_property("clients");
332-
focused_client = client;
333-
} else {
334-
focused_client = get_client(args[1]);
335-
}
336-
break;
337-
338337
// TODO: nag vaxry for fullscreenv2 that passes address
339338
case "fullscreen":
340339
yield sync_clients();
@@ -393,9 +392,18 @@ public class Hyprland : Object {
393392
keyboard_layout(argv[0], argv[1]);
394393
break;
395394

395+
// first event that signals a new client when it opens as an active window
396+
case "activewindowv2":
397+
yield try_add_client(args[1]);
398+
focused_client = get_client(args[1]);
399+
break;
400+
396401
case "openwindow":
397-
yield sync_clients();
398-
yield sync_workspaces();
402+
var addr = args[1].split(",")[0];
403+
if (yield try_add_client(addr)) {
404+
yield sync_clients();
405+
yield sync_workspaces();
406+
}
399407
break;
400408

401409
case "closewindow":

0 commit comments

Comments
 (0)