From 9e7d40931cd23cba405de652c7c903292025c673 Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Sun, 12 Jan 2025 12:26:12 +0100 Subject: [PATCH 1/3] make MonitorID an Option in Workspace and Client datastructs --- Cargo.lock | 4 ++-- src/data/regular.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76a8086..4ba210d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,7 +420,7 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hyprland" -version = "0.4.0-beta.1" +version = "0.4.0-beta.2" dependencies = [ "ahash", "async-net", @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "hyprland-macros" -version = "0.4.0-beta.1" +version = "0.4.0-beta.2" dependencies = [ "proc-macro2", "quote", diff --git a/src/data/regular.rs b/src/data/regular.rs index 99cd5f8..9a7884d 100644 --- a/src/data/regular.rs +++ b/src/data/regular.rs @@ -165,9 +165,9 @@ pub struct Workspace { pub name: String, /// The monitor the workspace is on pub monitor: String, - /// The monitor id the workspace is on + /// The monitor id the workspace is on, can be None in some cases #[serde(rename = "monitorID")] - pub monitor_id: MonitorId, + pub monitor_id: Option, /// The amount of windows in the workspace pub windows: u16, /// A bool that shows if there is a fullscreen window in the workspace @@ -234,8 +234,8 @@ pub struct Client { /// The client fullscreen mode #[serde(rename = "fullscreenClient")] pub fullscreen_client: FullscreenMode, - /// The monitor id the window is on - pub monitor: MonitorId, + /// The monitor id the window is on, can be None in some cases + pub monitor: Option, /// The initial window class #[serde(rename = "initialClass")] pub initial_class: String, From c6d06f4496b66771459a1036e4efd939dd48680d Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Sun, 12 Jan 2025 15:48:05 +0100 Subject: [PATCH 2/3] MonitorAddedV2 can return negative integers --- src/event_listener/shared.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/event_listener/shared.rs b/src/event_listener/shared.rs index 6d5d125..8eeac0c 100644 --- a/src/event_listener/shared.rs +++ b/src/event_listener/shared.rs @@ -418,7 +418,7 @@ pub struct ChangedSpecialEventData { #[derive(Debug, Clone, PartialEq, Eq)] pub struct MonitorAddedEventData { /// The monitor's id - pub id: u8, + pub id: i8, /// The monitor's name pub name: String, /// the monitor's description @@ -805,7 +805,7 @@ pub(crate) fn event_parser(event: String) -> crate::Result> { } ParsedEventType::MonitorRemoved => Ok(Event::MonitorRemoved(get![args;0])), ParsedEventType::MonitorAddedV2 => Ok(Event::MonitorAdded(MonitorAddedEventData { - id: parse_int!(get![ref args;0], event: "MonitorAddedV2" => u8), + id: parse_int!(get![ref args;0], event: "MonitorAddedV2" => i8), name: get![args;1], description: get![args;2], })), From 5c06457792fa965e7f6bdce6743c8305b7462d7b Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Sun, 12 Jan 2025 22:51:17 +0100 Subject: [PATCH 3/3] parse MonitorAddedV2 return value to MonitorId instead of i8 --- src/event_listener/shared.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/event_listener/shared.rs b/src/event_listener/shared.rs index 8eeac0c..35722e1 100644 --- a/src/event_listener/shared.rs +++ b/src/event_listener/shared.rs @@ -418,7 +418,7 @@ pub struct ChangedSpecialEventData { #[derive(Debug, Clone, PartialEq, Eq)] pub struct MonitorAddedEventData { /// The monitor's id - pub id: i8, + pub id: MonitorId, /// The monitor's name pub name: String, /// the monitor's description @@ -805,7 +805,7 @@ pub(crate) fn event_parser(event: String) -> crate::Result> { } ParsedEventType::MonitorRemoved => Ok(Event::MonitorRemoved(get![args;0])), ParsedEventType::MonitorAddedV2 => Ok(Event::MonitorAdded(MonitorAddedEventData { - id: parse_int!(get![ref args;0], event: "MonitorAddedV2" => i8), + id: parse_int!(get![ref args;0], event: "MonitorAddedV2" => MonitorId), name: get![args;1], description: get![args;2], })),