diff options
Diffstat (limited to 'lib/hyprland')
-rw-r--r-- | lib/hyprland/config.vala.in | 1 | ||||
-rw-r--r-- | lib/hyprland/default.nix | 15 | ||||
-rw-r--r-- | lib/hyprland/hyprland.vala | 43 | ||||
-rw-r--r-- | lib/hyprland/meson.build | 1 | ||||
-rw-r--r-- | lib/hyprland/structs.vala | 6 |
5 files changed, 49 insertions, 17 deletions
diff --git a/lib/hyprland/config.vala.in b/lib/hyprland/config.vala.in index 65993b2..0cdba75 100644 --- a/lib/hyprland/config.vala.in +++ b/lib/hyprland/config.vala.in @@ -1,3 +1,4 @@ +[CCode (gir_namespace = "AstalHyprland", gir_version = "@API_VERSION@")] namespace AstalHyprland { public const int MAJOR_VERSION = @MAJOR_VERSION@; public const int MINOR_VERSION = @MINOR_VERSION@; diff --git a/lib/hyprland/default.nix b/lib/hyprland/default.nix new file mode 100644 index 0000000..6b5e15d --- /dev/null +++ b/lib/hyprland/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-hyprland"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "hyprland"; + authors = "Aylur"; + gir-suffix = "Hyprland"; + description = "IPC client for Hyprland"; +} diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 9825a91..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(">>"); @@ -315,25 +329,11 @@ public class Hyprland : Object { case "focusedmon": var argv = args[1].split(",", 2); + yield sync_monitors(); focused_monitor = get_monitor_by_name(argv[0]); 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(); @@ -392,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": diff --git a/lib/hyprland/meson.build b/lib/hyprland/meson.build index 7112ee1..9598ba9 100644 --- a/lib/hyprland/meson.build +++ b/lib/hyprland/meson.build @@ -25,6 +25,7 @@ config = configure_file( input: 'config.vala.in', output: 'config.vala', configuration: { + 'API_VERSION': api_version, 'VERSION': meson.project_version(), 'MAJOR_VERSION': version_split[0], 'MINOR_VERSION': version_split[1], diff --git a/lib/hyprland/structs.vala b/lib/hyprland/structs.vala index 25f70c3..d5180b1 100644 --- a/lib/hyprland/structs.vala +++ b/lib/hyprland/structs.vala @@ -4,12 +4,15 @@ public class Bind : Object { public bool mouse { get; construct set; } public bool release { get; construct set; } public bool repeat { get; construct set; } + public bool long_press { get; construct set; } public bool non_consuming { get; construct set; } + public bool has_description { get; construct set; } public int64 modmask { get; construct set; } public string submap { get; construct set; } public string key { get; construct set; } public int64 keycode { get; construct set; } public bool catch_all { get; construct set; } + public string description { get; construct set; } public string dispatcher { get; construct set; } public string arg { get; construct set; } @@ -18,12 +21,15 @@ public class Bind : Object { mouse = obj.get_boolean_member("mouse"); release = obj.get_boolean_member("release"); repeat = obj.get_boolean_member("repeat"); + long_press = obj.get_member("longPress")?.get_boolean() ?? false; non_consuming = obj.get_boolean_member("non_consuming"); + has_description = obj.get_member("has_description")?.get_boolean() ?? false; modmask = obj.get_int_member("modmask"); submap = obj.get_string_member("submap"); key = obj.get_string_member("key"); keycode = obj.get_int_member("keycode"); catch_all = obj.get_boolean_member("catch_all"); + description = obj.get_member("description")?.get_string() ?? ""; dispatcher = obj.get_string_member("dispatcher"); arg = obj.get_string_member("arg"); } |