mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-09 22:52:51 +02:00
feat(config): add monitor index prefs to static
This commit adds an "monitor_index_preferences" key to the static config schema, which was missed during the initial rollout of the static configuration files. To help with testing, these indexes have also been exposed on the State struct. resolve #522
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
|
#![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::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|||||||
@@ -1341,7 +1341,8 @@ pub fn read_commands_tcp(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ok(size) => {
|
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}");
|
tracing::warn!("client sent an invalid message, disconnecting: {addr}");
|
||||||
let mut connections = TCP_CONNECTIONS.lock();
|
let mut connections = TCP_CONNECTIONS.lock();
|
||||||
connections.remove(addr);
|
connections.remove(addr);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ use crate::FLOAT_IDENTIFIERS;
|
|||||||
use crate::HIDING_BEHAVIOUR;
|
use crate::HIDING_BEHAVIOUR;
|
||||||
use crate::LAYERED_WHITELIST;
|
use crate::LAYERED_WHITELIST;
|
||||||
use crate::MANAGE_IDENTIFIERS;
|
use crate::MANAGE_IDENTIFIERS;
|
||||||
|
use crate::MONITOR_INDEX_PREFERENCES;
|
||||||
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
||||||
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS;
|
||||||
use crate::WORKSPACE_RULES;
|
use crate::WORKSPACE_RULES;
|
||||||
@@ -70,9 +71,9 @@ pub struct Rgb {
|
|||||||
impl From<u32> for Rgb {
|
impl From<u32> for Rgb {
|
||||||
fn from(value: u32) -> Self {
|
fn from(value: u32) -> Self {
|
||||||
Self {
|
Self {
|
||||||
r: value & 0xff,
|
r: value & 0xff,
|
||||||
g: value >> 8 & 0xff,
|
g: value >> 8 & 0xff,
|
||||||
b: value >> 16 & 0xff
|
b: value >> 16 & 0xff,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,9 +298,13 @@ pub struct StaticConfig {
|
|||||||
/// Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare)
|
/// Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub object_name_change_applications: Option<Vec<IdWithIdentifier>>,
|
pub object_name_change_applications: Option<Vec<IdWithIdentifier>>,
|
||||||
|
/// Set monitor index preferences
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub monitor_index_preferences: Option<HashMap<usize, Rect>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&WindowManager> for StaticConfig {
|
impl From<&WindowManager> for StaticConfig {
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
fn from(value: &WindowManager) -> Self {
|
fn from(value: &WindowManager) -> Self {
|
||||||
let default_invisible_borders = Rect {
|
let default_invisible_borders = Rect {
|
||||||
left: 7,
|
left: 7,
|
||||||
@@ -411,15 +416,19 @@ impl From<&WindowManager> for StaticConfig {
|
|||||||
tray_and_multi_window_applications: None,
|
tray_and_multi_window_applications: None,
|
||||||
layered_applications: None,
|
layered_applications: None,
|
||||||
object_name_change_applications: None,
|
object_name_change_applications: None,
|
||||||
|
monitor_index_preferences: Option::from(MONITOR_INDEX_PREFERENCES.lock().clone()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StaticConfig {
|
impl StaticConfig {
|
||||||
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
|
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
|
||||||
fn apply_globals(&self) -> Result<()> {
|
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 {
|
if let Some(behaviour) = self.window_hiding_behaviour {
|
||||||
let mut window_hiding_behaviour = HIDING_BEHAVIOUR.lock();
|
let mut window_hiding_behaviour = HIDING_BEHAVIOUR.lock();
|
||||||
*window_hiding_behaviour = behaviour;
|
*window_hiding_behaviour = behaviour;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ use crate::FLOAT_IDENTIFIERS;
|
|||||||
use crate::HOME_DIR;
|
use crate::HOME_DIR;
|
||||||
use crate::LAYERED_WHITELIST;
|
use crate::LAYERED_WHITELIST;
|
||||||
use crate::MANAGE_IDENTIFIERS;
|
use crate::MANAGE_IDENTIFIERS;
|
||||||
|
use crate::MONITOR_INDEX_PREFERENCES;
|
||||||
use crate::NO_TITLEBAR;
|
use crate::NO_TITLEBAR;
|
||||||
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
||||||
use crate::REMOVE_TITLEBARS;
|
use crate::REMOVE_TITLEBARS;
|
||||||
@@ -98,6 +99,7 @@ pub struct State {
|
|||||||
pub tray_and_multi_window_identifiers: Vec<String>,
|
pub tray_and_multi_window_identifiers: Vec<String>,
|
||||||
pub border_overflow_identifiers: Vec<String>,
|
pub border_overflow_identifiers: Vec<String>,
|
||||||
pub name_change_on_launch_identifiers: Vec<String>,
|
pub name_change_on_launch_identifiers: Vec<String>,
|
||||||
|
pub monitor_index_preferences: HashMap<usize, Rect>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<Self> for WindowManager {
|
impl AsRef<Self> for WindowManager {
|
||||||
@@ -126,6 +128,7 @@ impl From<&WindowManager> for State {
|
|||||||
tray_and_multi_window_identifiers: TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock().clone(),
|
tray_and_multi_window_identifiers: TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock().clone(),
|
||||||
border_overflow_identifiers: BORDER_OVERFLOW_IDENTIFIERS.lock().clone(),
|
border_overflow_identifiers: BORDER_OVERFLOW_IDENTIFIERS.lock().clone(),
|
||||||
name_change_on_launch_identifiers: OBJECT_NAME_CHANGE_ON_LAUNCH.lock().clone(),
|
name_change_on_launch_identifiers: OBJECT_NAME_CHANGE_ON_LAUNCH.lock().clone(),
|
||||||
|
monitor_index_preferences: MONITOR_INDEX_PREFERENCES.lock().clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
@@ -154,6 +154,16 @@
|
|||||||
"$ref": "#/definitions/IdWithIdentifier"
|
"$ref": "#/definitions/IdWithIdentifier"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"monitor_index_preferences": {
|
||||||
|
"description": "Set monitor index preferences",
|
||||||
|
"type": [
|
||||||
|
"object",
|
||||||
|
"null"
|
||||||
|
],
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/definitions/Rect"
|
||||||
|
}
|
||||||
|
},
|
||||||
"monitors": {
|
"monitors": {
|
||||||
"description": "Monitor and workspace configurations",
|
"description": "Monitor and workspace configurations",
|
||||||
"type": [
|
"type": [
|
||||||
|
|||||||
Reference in New Issue
Block a user