Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: bind monitor via monitor index instead of device name

Lars Bergerfa4da8c54263
diff --git a/packages/wm/src/monitors/commands/remove_monitor.rs b/packages/wm/src/monitors/commands/remove_monitor.rs
index b2336f88..1af09e3c 100644
--- a/packages/wm/src/monitors/commands/remove_monitor.rs
+++ b/packages/wm/src/monitors/commands/remove_monitor.rs
@@ -58,7 +58,7 @@ pub fn remove_monitor(
state.emit_event(WmEvent::MonitorRemoved {
removed_id: monitor.id(),
- removed_device_name: monitor.name()?.to_string(),
+ removed_device_name: monitor.native().device_name()?.to_string(),
});
Ok(())
diff --git a/packages/wm/src/monitors/monitor.rs b/packages/wm/src/monitors/monitor.rs
index 2651732d..b0908f97 100644
--- a/packages/wm/src/monitors/monitor.rs
+++ b/packages/wm/src/monitors/monitor.rs
@@ -68,10 +68,6 @@ impl Monitor {
self.0.borrow_mut().native = native;
}
- pub fn name(&self) -> anyhow::Result<String> {
- self.native().device_name().cloned()
- }
-
pub fn displayed_workspace(&self) -> Option<Workspace> {
self
.child_focus_order()
diff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rs
index 3f36c635..2a41f53b 100644
--- a/packages/wm/src/user_config.rs
+++ b/packages/wm/src/user_config.rs
@@ -7,7 +7,7 @@ use tokio::fs;
use crate::{
app_command::InvokeCommand,
common::{Color, LengthValue, RectDelta},
- containers::WindowContainer,
+ containers::{traits::CommonGetters, WindowContainer},
monitors::Monitor,
windows::traits::WindowGetters,
workspaces::Workspace,
@@ -295,9 +295,7 @@ impl UserConfig {
config
.bind_to_monitor
.as_ref()
- .and_then(|monitor_name| {
- monitor.name().map(|n| &n == monitor_name).ok()
- })
+ .map(|monitor_index| monitor.index() == *monitor_index as usize)
.unwrap_or(false)
});
@@ -552,7 +550,7 @@ pub enum WindowRuleEvent {
pub struct WorkspaceConfig {
pub name: String,
pub display_name: Option<String>,
- pub bind_to_monitor: Option<String>,
+ pub bind_to_monitor: Option<u32>,
#[serde(default = "default_bool::<false>")]
pub keep_alive: bool,
}