diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 58573071..e00cca34 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -1,5 +1,10 @@ #![warn(clippy::all, clippy::nursery, clippy::pedantic)] -#![allow(clippy::missing_errors_doc, clippy::redundant_pub_crate)] +#![allow( + clippy::missing_errors_doc, + clippy::redundant_pub_crate, + clippy::significant_drop_tightening, + clippy::significant_drop_in_scrutinee +)] use std::collections::HashMap; use std::fs::File; diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 2ca7df94..52083d2b 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1341,7 +1341,8 @@ pub fn read_commands_tcp( break; } Ok(size) => { - let Ok(message) = SocketMessage::from_str(&String::from_utf8_lossy(&buf[..size])) else { + let Ok(message) = SocketMessage::from_str(&String::from_utf8_lossy(&buf[..size])) + else { tracing::warn!("client sent an invalid message, disconnecting: {addr}"); let mut connections = TCP_CONNECTIONS.lock(); connections.remove(addr); diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 05c04d3d..db0bb644 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -22,6 +22,7 @@ use crate::FLOAT_IDENTIFIERS; use crate::HIDING_BEHAVIOUR; use crate::LAYERED_WHITELIST; use crate::MANAGE_IDENTIFIERS; +use crate::MONITOR_INDEX_PREFERENCES; use crate::OBJECT_NAME_CHANGE_ON_LAUNCH; use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS; use crate::WORKSPACE_RULES; @@ -70,9 +71,9 @@ pub struct Rgb { impl From for Rgb { fn from(value: u32) -> Self { Self { - r: value & 0xff, - g: value >> 8 & 0xff, - b: value >> 16 & 0xff + r: value & 0xff, + g: value >> 8 & 0xff, + b: value >> 16 & 0xff, } } } @@ -297,9 +298,13 @@ pub struct StaticConfig { /// Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare) #[serde(skip_serializing_if = "Option::is_none")] pub object_name_change_applications: Option>, + /// Set monitor index preferences + #[serde(skip_serializing_if = "Option::is_none")] + pub monitor_index_preferences: Option>, } impl From<&WindowManager> for StaticConfig { + #[allow(clippy::too_many_lines)] fn from(value: &WindowManager) -> Self { let default_invisible_borders = Rect { left: 7, @@ -411,15 +416,19 @@ impl From<&WindowManager> for StaticConfig { tray_and_multi_window_applications: None, layered_applications: None, object_name_change_applications: None, + monitor_index_preferences: Option::from(MONITOR_INDEX_PREFERENCES.lock().clone()), } - - } } impl StaticConfig { #[allow(clippy::cognitive_complexity, clippy::too_many_lines)] fn apply_globals(&self) -> Result<()> { + if let Some(monitor_index_preferences) = &self.monitor_index_preferences { + let mut preferences = MONITOR_INDEX_PREFERENCES.lock(); + *preferences = monitor_index_preferences.clone(); + } + if let Some(behaviour) = self.window_hiding_behaviour { let mut window_hiding_behaviour = HIDING_BEHAVIOUR.lock(); *window_hiding_behaviour = behaviour; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 4dea3116..3ac0eb1b 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -50,6 +50,7 @@ use crate::FLOAT_IDENTIFIERS; use crate::HOME_DIR; use crate::LAYERED_WHITELIST; use crate::MANAGE_IDENTIFIERS; +use crate::MONITOR_INDEX_PREFERENCES; use crate::NO_TITLEBAR; use crate::OBJECT_NAME_CHANGE_ON_LAUNCH; use crate::REMOVE_TITLEBARS; @@ -98,6 +99,7 @@ pub struct State { pub tray_and_multi_window_identifiers: Vec, pub border_overflow_identifiers: Vec, pub name_change_on_launch_identifiers: Vec, + pub monitor_index_preferences: HashMap, } impl AsRef for WindowManager { @@ -126,6 +128,7 @@ impl From<&WindowManager> for State { tray_and_multi_window_identifiers: TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock().clone(), border_overflow_identifiers: BORDER_OVERFLOW_IDENTIFIERS.lock().clone(), name_change_on_launch_identifiers: OBJECT_NAME_CHANGE_ON_LAUNCH.lock().clone(), + monitor_index_preferences: MONITOR_INDEX_PREFERENCES.lock().clone(), } } } diff --git a/schema.json b/schema.json index 8ba451ca..7f54f131 100644 --- a/schema.json +++ b/schema.json @@ -154,6 +154,16 @@ "$ref": "#/definitions/IdWithIdentifier" } }, + "monitor_index_preferences": { + "description": "Set monitor index preferences", + "type": [ + "object", + "null" + ], + "additionalProperties": { + "$ref": "#/definitions/Rect" + } + }, "monitors": { "description": "Monitor and workspace configurations", "type": [