Skip to content

Commit

Permalink
Merge pull request #302 from zjeffer/fix/zjeffer/monitor-id-option
Browse files Browse the repository at this point in the history
Fix null monitors causing panics
  • Loading branch information
yavko authored Jan 13, 2025
2 parents c07d326 + 5c06457 commit bc428ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/data/regular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MonitorId>,
/// The amount of windows in the workspace
pub windows: u16,
/// A bool that shows if there is a fullscreen window in the workspace
Expand Down Expand Up @@ -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<MonitorId>,
/// The initial window class
#[serde(rename = "initialClass")]
pub initial_class: String,
Expand Down
4 changes: 2 additions & 2 deletions src/event_listener/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ pub struct ChangedSpecialEventData {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MonitorAddedEventData {
/// The monitor's id
pub id: u8,
pub id: MonitorId,
/// The monitor's name
pub name: String,
/// the monitor's description
Expand Down Expand Up @@ -805,7 +805,7 @@ pub(crate) fn event_parser(event: String) -> crate::Result<Vec<Event>> {
}
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" => MonitorId),
name: get![args;1],
description: get![args;2],
})),
Expand Down

0 comments on commit bc428ac

Please sign in to comment.