@@ -303,6 +303,20 @@ public class Hyprland : Object {
303
303
}
304
304
}
305
305
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
+
306
320
private async void handle_event (string line ) throws Error {
307
321
var args = line. split(" >>" );
308
322
@@ -320,21 +334,6 @@ public class Hyprland : Object {
320
334
focused_workspace = get_workspace_by_name(argv[1 ]);
321
335
break ;
322
336
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
-
338
337
// TODO: nag vaxry for fullscreenv2 that passes address
339
338
case " fullscreen" :
340
339
yield sync_clients();
@@ -393,9 +392,18 @@ public class Hyprland : Object {
393
392
keyboard_layout(argv[0 ], argv[1 ]);
394
393
break ;
395
394
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
+
396
401
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
+ }
399
407
break ;
400
408
401
409
case " closewindow" :
0 commit comments