refactor(windows): move paddings, aspect ratio, layout defaults and display preferences to settings

Plan step 10, S3. The two default paddings, the aspect ratio of a window
toggled to floating (centre with resize), layout_defaults and
display_index_preferences are no longer statics: their writers
(apply_globals through SharedDelta::apply, the DisplayIndexPreference
command) and all readers use settings() together. The semantics are the
statics': a missing padding or display_index_preferences key keeps the
value, a missing layout_defaults clears it, a missing aspect ratio is
Standard (not the initial Widescreen), and the command inserts one entry.
Readers get an owned copy from one snapshot (accessors in settings.rs).

BEHAVIOUR only in this: apply_globals used to store these keys one at a
time and now publishes the group in one update, so a thread can no longer see
a half-applied reload of them. Value semantics are pinned by
crates/komorebi-settings tests/reload.rs and shared.rs (reload merges, a
few keys reset, a load never touches groups it does not name).

Windows: window.rs, windows_api.rs, workspace.rs, monitor.rs,
monitor_reconciliator, stackbar_manager (the gap reads the container padding
from settings), state.rs, static_config.rs, process_command.rs, lib.rs.
MONITOR_INDEX_PREFERENCES stays a static (Windows only).

Verified: Windows clippy -D warnings --locked --all-targets on
komorebi-windows (cross): clean. e2e not run: config_reload, layouts,
workspaces, stackbars (container padding gap) are needed.
This commit is contained in:
LGUG2Z committed 2026-11-05 10:30:05 -08:00
1 parent faf7bbd79e
commit cab39bedfb
12 files changed
+111 -108

No files matched your search

+5 -14
View File
@@ -12,8 +12,8 @@ pub mod container;
pub mod core;
pub mod focus_manager;
pub mod live_resize;
pub use komorebi_collections::lockable_sequence;
pub use komorebi_collections::Lockable;
pub use komorebi_collections::lockable_sequence;
pub mod monitor;
pub mod monitor_reconciliator;
pub mod pan;
@@ -23,19 +23,19 @@ pub mod process_movement;
pub mod reaper;
pub mod scrolling;
pub mod set_window_position;
pub mod settings;
pub mod splash;
pub mod stackbar_manager;
pub mod settings;
pub mod state;
pub mod static_config;
pub mod styles;
pub mod theme_manager;
pub mod transparency_manager;
pub mod window;
pub mod windows_backend;
pub mod window_manager;
pub mod window_manager_event;
pub mod windows_api;
pub mod windows_backend;
pub mod windows_callbacks;
pub mod winevent;
pub mod winevent_listener;
@@ -52,7 +52,6 @@ use std::path::PathBuf;
use std::process::Command;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicI32;
use std::sync::atomic::AtomicU32;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
@@ -162,8 +161,6 @@ lazy_static! {
static ref TRANSPARENCY_BLACKLIST: Arc<Mutex<Vec<MatchingRule>>> = Arc::new(Mutex::new(Vec::new()));
static ref MONITOR_INDEX_PREFERENCES: Arc<Mutex<HashMap<usize, Rect>>> =
Arc::new(Mutex::new(HashMap::new()));
static ref DISPLAY_INDEX_PREFERENCES: Arc<RwLock<HashMap<usize, String>>> =
Arc::new(RwLock::new(HashMap::new()));
static ref WORKSPACE_MATCHING_RULES: Arc<Mutex<Vec<WorkspaceMatchingRule>>> =
Arc::new(Mutex::new(Vec::new()));
static ref REGEX_IDENTIFIERS: Arc<Mutex<HashMap<String, Regex>>> =
@@ -261,21 +258,15 @@ lazy_static! {
static ref WINDOWS_BY_BAR_HWNDS: Arc<Mutex<HashMap<isize, VecDeque<isize>>>> =
Arc::new(Mutex::new(HashMap::new()));
static ref FLOATING_WINDOW_TOGGLE_ASPECT_RATIO: Arc<Mutex<AspectRatio>> = Arc::new(Mutex::new(AspectRatio::Predefined(PredefinedAspectRatio::Widescreen)));
static ref CURRENT_VIRTUAL_DESKTOP: Arc<Mutex<Option<Vec<u8>>>> = Arc::new(Mutex::new(None));
pub static ref LAYOUT_DEFAULTS: Arc<Mutex<HashMap<DefaultLayout, LayoutDefaultEntry>>> =
Arc::new(Mutex::new(HashMap::new()));
}
pub static DEFAULT_WORKSPACE_PADDING: AtomicI32 =
AtomicI32::new(komorebi_settings::shared::PlatformDefaults::WINDOWS.workspace_padding);
pub static DEFAULT_CONTAINER_PADDING: AtomicI32 =
AtomicI32::new(komorebi_settings::shared::PlatformDefaults::WINDOWS.container_padding);
pub static DEFAULT_RESIZE_DELTA: i32 = komorebi_settings::shared::DEFAULT_RESIZE_DELTA;
pub static DEFAULT_MOUSE_FOLLOWS_FOCUS: bool = komorebi_settings::shared::DEFAULT_MOUSE_FOLLOWS_FOCUS;
pub static DEFAULT_MOUSE_FOLLOWS_FOCUS: bool =
komorebi_settings::shared::DEFAULT_MOUSE_FOLLOWS_FOCUS;
pub static INITIAL_CONFIGURATION_LOADED: AtomicBool = AtomicBool::new(false);
pub static CUSTOM_FFM: AtomicBool = AtomicBool::new(false);
pub static SESSION_ID: AtomicU32 = AtomicU32::new(0);
+4 -6
View File
@@ -15,8 +15,6 @@ use crate::core::Rect;
use komorebi_backend::MonitorId;
use komorebi_core::ContainerWindow;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::DEFAULT_WORKSPACE_PADDING;
use crate::DefaultLayout;
use crate::Layout;
use crate::OperationDirection;
@@ -260,10 +258,10 @@ impl MonitorExt for Monitor {
fn update_workspaces_globals(&mut self, offset: Option<Rect>) {
let container_padding = self
.container_padding
.or(Some(DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst)));
.or(Some(crate::settings::container_padding()));
let workspace_padding = self
.workspace_padding
.or(Some(DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst)));
.or(Some(crate::settings::workspace_padding()));
let (border_width, border_offset) = {
let border_enabled = BORDER_ENABLED.load(Ordering::SeqCst);
if border_enabled {
@@ -298,10 +296,10 @@ impl MonitorExt for Monitor {
fn update_workspace_globals(&mut self, workspace_idx: usize, offset: Option<Rect>) {
let container_padding = self
.container_padding
.or(Some(DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst)));
.or(Some(crate::settings::container_padding()));
let workspace_padding = self
.workspace_padding
.or(Some(DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst)));
.or(Some(crate::settings::workspace_padding()));
let (border_width, border_offset) = {
let border_enabled = BORDER_ENABLED.load(Ordering::SeqCst);
if border_enabled {
+2 -3
View File
@@ -1,6 +1,5 @@
#![deny(clippy::unwrap_used, clippy::expect_used)]
use crate::DISPLAY_INDEX_PREFERENCES;
use crate::DUPLICATE_MONITOR_SERIAL_IDS;
use crate::Notification;
use crate::NotificationEvent;
@@ -106,7 +105,7 @@ pub fn display_change_in_progress(grace_period: std::time::Duration) -> bool {
}
pub fn insert_in_monitor_cache(serial_or_device_id: &str, monitor: Monitor) {
let dip = DISPLAY_INDEX_PREFERENCES.read();
let dip = crate::settings::display_index_preferences();
let mut dip_ids = dip.values();
let preferred_id = if dip_ids.any(|id| id.eq(&monitor.extra.device_id)) {
monitor.extra.device_id.clone()
@@ -653,7 +652,7 @@ where
// Let's add their state to the cache for later, make sure to use what
// the user set as preference as the id.
let dip = DISPLAY_INDEX_PREFERENCES.read();
let dip = crate::settings::display_index_preferences();
let mut dip_ids = dip.values();
let preferred_id = if dip_ids.any(|id| id.eq(&m.extra.device_id)) {
m.extra.device_id.clone()
+6 -3
View File
@@ -27,7 +27,6 @@ use uds_windows::UnixStream;
use crate::CUSTOM_FFM;
use crate::DATA_DIR;
use crate::DISPLAY_INDEX_PREFERENCES;
use crate::FLOATING_APPLICATIONS;
use crate::HIDING_BEHAVIOUR;
use crate::IGNORE_IDENTIFIERS;
@@ -934,8 +933,12 @@ impl WindowManager {
);
}
SocketMessage::DisplayIndexPreference(index_preference, ref display) => {
let mut display_index_preferences = DISPLAY_INDEX_PREFERENCES.write();
display_index_preferences.insert(index_preference, display.clone());
crate::settings::settings().update(|settings| {
settings
.shared
.display_index_preferences
.insert(index_preference, display.clone());
});
}
SocketMessage::EnsureWorkspaces(monitor_idx, workspace_count) => {
self.ensure_workspaces_for_monitor(monitor_idx, workspace_count)?;
+42 -11
View File
@@ -1,11 +1,17 @@
//! The settings of this daemon, as one snapshot (plan step 10, `docs/dev/settings.md`).
//!
//! Nothing reads this yet: the process-wide statics are still the source of truth, and each
//! migration step moves one group of them (writers and readers together) into
//! [`settings()`]. Until then the value is the starting values of those statics.
//! Each migration step moves one group of the process-wide statics (writers and readers together)
//! into [`settings()`]. Moved so far: the two default paddings, the aspect ratio of a window toggled
//! to floating, `layout_defaults` and `display_index_preferences`. The groups that have not moved
//! are still statics and the pin test compares them with the starting settings.
use std::collections::HashMap;
use std::sync::LazyLock;
use komorebi_config::aspect_ratio::AspectRatio;
use komorebi_layouts::DefaultLayout;
use komorebi_layouts::LayoutDefaultEntry;
use komorebi_settings::Handle;
use komorebi_settings::Shared;
use komorebi_settings::shared::PlatformDefaults;
@@ -28,6 +34,39 @@ pub fn settings() -> &'static Handle<WindowsSettings> {
&SETTINGS
}
// Accessors for the groups that have moved over (S3). Each takes one snapshot, so a caller sees one
// configuration, and returns an owned value: the callers are configuration and monitor-change
// paths, not hot paths.
/// `default_container_padding`: the padding around each tile for a monitor that sets none.
pub fn container_padding() -> i32 {
settings().snapshot().shared.defaults.container_padding
}
/// `default_workspace_padding`: the padding inside a work area for a monitor that sets none.
pub fn workspace_padding() -> i32 {
settings().snapshot().shared.defaults.workspace_padding
}
/// `floating_window_aspect_ratio`: the shape of a window that is toggled to floating and centred.
pub fn floating_window_aspect_ratio() -> AspectRatio {
settings().snapshot().shared.floating_window_aspect_ratio
}
/// `layout_defaults`: what each layout starts with when a workspace sets nothing.
pub fn layout_defaults() -> HashMap<DefaultLayout, LayoutDefaultEntry> {
settings().snapshot().shared.layout_defaults.clone()
}
/// `display_index_preferences`: which monitor each configured index belongs to.
pub fn display_index_preferences() -> HashMap<usize, String> {
settings()
.snapshot()
.shared
.display_index_preferences
.clone()
}
#[cfg(test)]
mod tests {
use std::sync::atomic::Ordering;
@@ -42,14 +81,6 @@ mod tests {
fn the_starting_settings_are_the_starting_values_of_the_statics() {
let shared = &settings().snapshot().shared;
assert_eq!(
shared.defaults.container_padding,
crate::DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst)
);
assert_eq!(
shared.defaults.workspace_padding,
crate::DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst)
);
assert_eq!(shared.defaults.resize_delta, crate::DEFAULT_RESIZE_DELTA);
assert_eq!(
shared.defaults.mouse_follows_focus,
+1 -3
View File
@@ -1,6 +1,5 @@
mod stackbar;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::WindowManager;
use crate::WindowsApi;
use crate::container::Container;
@@ -11,7 +10,6 @@ use crate::windows_backend::backend;
use crossbeam_channel::Receiver;
use crossbeam_channel::Sender;
use crossbeam_utils::atomic::AtomicCell;
use crossbeam_utils::atomic::AtomicConsume;
use komorebi_backend::WindowId;
use lazy_static::lazy_static;
use parking_lot::Mutex;
@@ -175,7 +173,7 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
let container_padding = ws
.container_padding
.unwrap_or_else(|| DEFAULT_CONTAINER_PADDING.load_consume());
.unwrap_or_else(crate::settings::container_padding);
'containers: for container in ws.containers_mut() {
let should_add_stackbar = match STACKBAR_MODE.load() {
+3 -4
View File
@@ -1,5 +1,3 @@
use color_eyre::eyre::OptionExt;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::WINDOWS_11;
use crate::WindowsApi;
use crate::border_manager::BORDER_OFFSET;
@@ -20,6 +18,7 @@ use crate::stackbar_manager::STACKBAR_UNFOCUSED_TEXT_COLOUR;
use crate::stackbar_manager::STACKBARS_CONTAINERS;
use crate::windows_api;
use crate::windows_backend::backend;
use color_eyre::eyre::OptionExt;
use crossbeam_utils::atomic::AtomicConsume;
use komorebi_backend::WindowId;
use std::os::windows::ffi::OsStrExt;
@@ -172,7 +171,7 @@ impl Stackbar {
) -> color_eyre::Result<()> {
let width = STACKBAR_TAB_WIDTH.load_consume();
let height = STACKBAR_TAB_HEIGHT.load_consume();
let gap = DEFAULT_CONTAINER_PADDING.load_consume();
let gap = crate::settings::container_padding();
let background = STACKBAR_TAB_BACKGROUND_COLOUR.load_consume();
let focused_text_colour = STACKBAR_FOCUSED_TEXT_COLOUR.load_consume();
let unfocused_text_colour = STACKBAR_UNFOCUSED_TEXT_COLOUR.load_consume();
@@ -341,7 +340,7 @@ impl Stackbar {
let width = STACKBAR_TAB_WIDTH.load_consume();
let height = STACKBAR_TAB_HEIGHT.load_consume();
let gap = DEFAULT_CONTAINER_PADDING.load_consume();
let gap = crate::settings::container_padding();
let focused_window_idx = container.focused_window_idx();
let focused_window_rect = backend()
+1 -2
View File
@@ -3,7 +3,6 @@ use crate::BorderStyle;
use crate::CURRENT_VIRTUAL_DESKTOP;
use crate::CUSTOM_FFM;
use crate::DATA_DIR;
use crate::DISPLAY_INDEX_PREFERENCES;
use crate::DUPLICATE_MONITOR_SERIAL_IDS;
use crate::FocusFollowsMouseImplementation;
use crate::HIDING_BEHAVIOUR;
@@ -211,7 +210,7 @@ impl Default for GlobalState {
tray_and_multi_window_identifiers: TRAY_AND_MULTI_WINDOW_IDENTIFIERS.lock().clone(),
name_change_on_launch_identifiers: OBJECT_NAME_CHANGE_ON_LAUNCH.lock().clone(),
monitor_index_preferences: MONITOR_INDEX_PREFERENCES.lock().clone(),
display_index_preferences: DISPLAY_INDEX_PREFERENCES.read().clone(),
display_index_preferences: crate::settings::display_index_preferences(),
ignored_duplicate_monitor_serial_ids: DUPLICATE_MONITOR_SERIAL_IDS.read().clone(),
workspace_rules: WORKSPACE_MATCHING_RULES.lock().clone(),
window_hiding_behaviour: *HIDING_BEHAVIOUR.lock(),
+40 -50
View File
@@ -1,25 +1,18 @@
use crate::AspectRatio;
use crate::CrossBoundaryBehaviour;
use crate::DATA_DIR;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::DEFAULT_MOUSE_FOLLOWS_FOCUS;
use crate::DEFAULT_RESIZE_DELTA;
use crate::DEFAULT_WORKSPACE_PADDING;
use crate::DISPLAY_INDEX_PREFERENCES;
use crate::FLOATING_APPLICATIONS;
use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO;
use crate::FloatingLayerBehaviour;
use crate::HIDING_BEHAVIOUR;
use crate::IGNORE_IDENTIFIERS;
use crate::LAYERED_WHITELIST;
use crate::LAYOUT_DEFAULTS;
use crate::MANAGE_IDENTIFIERS;
use crate::MONITOR_INDEX_PREFERENCES;
use crate::NO_TITLEBAR;
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
use crate::OBJECT_NAME_CHANGE_TITLE_IGNORE_LIST;
use crate::Placement;
use crate::PredefinedAspectRatio;
use crate::REGEX_IDENTIFIERS;
use crate::SLOW_APPLICATION_COMPENSATION_TIME;
use crate::SLOW_APPLICATION_IDENTIFIERS;
@@ -86,6 +79,7 @@ use color_eyre::eyre;
use crossbeam_channel::Receiver;
use hotwatch::EventKind;
use hotwatch::Hotwatch;
use komorebi_settings::shared::SharedDelta;
use komorebi_themes::colour::Colour;
use parking_lot::Mutex;
use regex::Regex;
@@ -138,8 +132,8 @@ pub fn workspace_config(value: &Workspace) -> WorkspaceConfig {
window_container_behaviour_rules.insert(*threshold, *behaviour);
}
let default_container_padding = DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst);
let default_workspace_padding = DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst);
let default_container_padding = crate::settings::container_padding();
let default_workspace_padding = crate::settings::workspace_padding();
let container_padding = value.container_padding.and_then(|container_padding| {
if container_padding == default_container_padding {
@@ -226,8 +220,8 @@ pub fn monitor_config(value: &Monitor) -> MonitorConfig {
workspaces.push(workspace_config(w));
}
let default_container_padding = DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst);
let default_workspace_padding = DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst);
let default_container_padding = crate::settings::container_padding();
let default_workspace_padding = crate::settings::workspace_padding();
let container_padding = value.container_padding.and_then(|container_padding| {
if container_padding == default_container_padding {
@@ -338,14 +332,10 @@ impl From<&WindowManager> for StaticConfig {
#[allow(deprecated)]
border_z_order: None,
border_implementation: Option::from(IMPLEMENTATION.load()),
default_workspace_padding: Option::from(
DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst),
),
default_container_padding: Option::from(
DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst),
),
default_workspace_padding: Option::from(crate::settings::workspace_padding()),
default_container_padding: Option::from(crate::settings::container_padding()),
layout_defaults: {
let guard = LAYOUT_DEFAULTS.lock();
let guard = crate::settings::layout_defaults();
if guard.is_empty() {
None
} else {
@@ -373,7 +363,7 @@ impl From<&WindowManager> for StaticConfig {
.collect::<Vec<_>>(),
),
monitor_index_preferences: Option::from(MONITOR_INDEX_PREFERENCES.lock().clone()),
display_index_preferences: Option::from(DISPLAY_INDEX_PREFERENCES.read().clone()),
display_index_preferences: Option::from(crate::settings::display_index_preferences()),
stackbar: None,
animation: None,
theme: None,
@@ -383,7 +373,9 @@ impl From<&WindowManager> for StaticConfig {
slow_application_identifiers: Option::from(SLOW_APPLICATION_IDENTIFIERS.lock().clone()),
bar_configurations: None,
remove_titlebar_applications: Option::from(NO_TITLEBAR.lock().clone()),
floating_window_aspect_ratio: Option::from(*FLOATING_WINDOW_TOGGLE_ASPECT_RATIO.lock()),
floating_window_aspect_ratio: Option::from(
crate::settings::floating_window_aspect_ratio(),
),
window_handling_behaviour: Option::from(WINDOW_HANDLING_BEHAVIOUR.load()),
..Default::default()
}
@@ -398,20 +390,28 @@ trait ApplyGlobals {
impl ApplyGlobals for StaticConfig {
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
fn apply_globals(&mut self) -> eyre::Result<()> {
*FLOATING_WINDOW_TOGGLE_ASPECT_RATIO.lock() = self
.floating_window_aspect_ratio
.unwrap_or(AspectRatio::Predefined(PredefinedAspectRatio::Standard));
// The groups that have moved to `Settings` (the two default paddings, the aspect ratio of a
// window toggled to floating, `layout_defaults` and `display_index_preferences`) are applied
// as one update, with the rules the statics had: a missing padding or display index
// preferences key keeps the value, a missing `layout_defaults` clears it and a missing
// aspect ratio is Standard (`SharedDelta::apply`).
crate::settings::settings().update(|settings| {
SharedDelta {
default_container_padding: self.default_container_padding,
default_workspace_padding: self.default_workspace_padding,
floating_window_aspect_ratio: self.floating_window_aspect_ratio,
layout_defaults: self.layout_defaults.clone(),
display_index_preferences: self.display_index_preferences.clone(),
..SharedDelta::default()
}
.apply(&mut settings.shared);
});
if let Some(monitor_index_preferences) = &self.monitor_index_preferences {
let mut preferences = MONITOR_INDEX_PREFERENCES.lock();
preferences.clone_from(monitor_index_preferences);
}
if let Some(display_index_preferences) = &self.display_index_preferences {
let mut preferences = DISPLAY_INDEX_PREFERENCES.write();
preferences.clone_from(display_index_preferences);
}
if let Some(behaviour) = self.window_hiding_behaviour {
let mut window_hiding_behaviour = HIDING_BEHAVIOUR.lock();
*window_hiding_behaviour = behaviour;
@@ -476,20 +476,6 @@ impl ApplyGlobals for StaticConfig {
}
}
if let Some(container) = self.default_container_padding {
DEFAULT_CONTAINER_PADDING.store(container, Ordering::SeqCst);
}
if let Some(workspace) = self.default_workspace_padding {
DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst);
}
if let Some(defaults) = &self.layout_defaults {
*LAYOUT_DEFAULTS.lock() = defaults.clone();
} else {
LAYOUT_DEFAULTS.lock().clear();
}
if let Some(border_width) = self.border_width {
border_manager::BORDER_WIDTH.store(border_width, Ordering::SeqCst);
}
@@ -844,8 +830,10 @@ impl StaticConfigExt for StaticConfig {
let mut value = Self::read(path)?;
let mut wm = wm.lock();
let configs_with_preference: Vec<_> =
DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect();
let configs_with_preference: Vec<_> = crate::settings::display_index_preferences()
.keys()
.copied()
.collect();
let mut configs_used = Vec::new();
let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock();
@@ -855,7 +843,7 @@ impl StaticConfigExt for StaticConfig {
let offset = wm.work_area_offset;
for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() {
let preferred_config_idx = {
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
let display_index_preferences = crate::settings::display_index_preferences();
display_index_preferences.iter().find_map(|(c_idx, id)| {
(monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id)
@@ -950,7 +938,7 @@ impl StaticConfigExt for StaticConfig {
.filter(|i| !configs_used.contains(i))
{
let id = {
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
let display_index_preferences = crate::settings::display_index_preferences();
display_index_preferences.get(i).cloned()
};
if let (Some(id), Some(monitor_config)) =
@@ -1009,8 +997,10 @@ impl StaticConfigExt for StaticConfig {
value.apply_globals()?;
let configs_with_preference: Vec<_> =
DISPLAY_INDEX_PREFERENCES.read().keys().copied().collect();
let configs_with_preference: Vec<_> = crate::settings::display_index_preferences()
.keys()
.copied()
.collect();
let mut configs_used = Vec::new();
let mut workspace_matching_rules = WORKSPACE_MATCHING_RULES.lock();
@@ -1020,7 +1010,7 @@ impl StaticConfigExt for StaticConfig {
let offset = wm.work_area_offset;
for (i, monitor) in wm.monitors_mut().iter_mut().enumerate() {
let preferred_config_idx = {
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
let display_index_preferences = crate::settings::display_index_preferences();
display_index_preferences.iter().find_map(|(c_idx, id)| {
(monitor.serial_number_id.as_ref().is_some_and(|sn| sn == id)
@@ -1118,7 +1108,7 @@ impl StaticConfigExt for StaticConfig {
.filter(|i| !configs_used.contains(i))
{
let id = {
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
let display_index_preferences = crate::settings::display_index_preferences();
display_index_preferences.get(i).cloned()
};
if let (Some(id), Some(monitor_config)) =
+2 -4
View File
@@ -1,6 +1,5 @@
use crate::AnimationStyle;
use crate::FLOATING_APPLICATIONS;
use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO;
use crate::HIDDEN_HWNDS;
use crate::HIDING_BEHAVIOUR;
use crate::IGNORE_IDENTIFIERS;
@@ -316,9 +315,8 @@ impl Window {
pub fn center(&mut self, work_area: &Rect, resize: bool) -> eyre::Result<()> {
let (target_width, target_height) = if resize {
let (aspect_ratio_width, aspect_ratio_height) = FLOATING_WINDOW_TOGGLE_ASPECT_RATIO
.lock()
.width_and_height();
let (aspect_ratio_width, aspect_ratio_height) =
crate::settings::floating_window_aspect_ratio().width_and_height();
let target_height = work_area.bottom / 2;
let target_width = (target_height * aspect_ratio_width) / aspect_ratio_height;
(target_width, target_height)
+3 -4
View File
@@ -161,7 +161,6 @@ use windows_core::HSTRING;
use crate::core::Rect;
use crate::DISPLAY_INDEX_PREFERENCES;
use crate::DUPLICATE_MONITOR_SERIAL_IDS;
use crate::MONITOR_INDEX_PREFERENCES;
use crate::WINDOW_HANDLING_BEHAVIOUR;
@@ -369,8 +368,8 @@ impl WindowsApi {
}
}
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read();
for (index, id) in &*display_index_preferences {
let display_index_preferences = crate::settings::display_index_preferences();
for (index, id) in &display_index_preferences {
if m.serial_number_id.as_ref().is_some_and(|sn| sn == id)
|| id.eq(&m.extra.device_id)
{
@@ -405,7 +404,7 @@ impl WindowsApi {
// Rebuild monitor index map
*monitor_usr_idx_map = HashMap::new();
let mut added_monitor_idxs = Vec::new();
for (index, id) in &*DISPLAY_INDEX_PREFERENCES.read() {
for (index, id) in &crate::settings::display_index_preferences() {
if let Some(m_idx) = monitors.elements().iter().position(|m| {
m.serial_number_id.as_ref().is_some_and(|sn| sn == id) || m.extra.device_id.eq(id)
}) {
+2 -4
View File
@@ -22,8 +22,8 @@ impl komorebi_core::WorkspacePlatform for WindowsPlatform {
fn default_padding() -> (Option<i32>, Option<i32>) {
(
Option::from(DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst)),
Option::from(DEFAULT_WORKSPACE_PADDING.load(Ordering::SeqCst)),
Option::from(crate::settings::container_padding()),
Option::from(crate::settings::workspace_padding()),
)
}
@@ -98,8 +98,6 @@ impl komorebi_core::WorkspacePlatform for WindowsPlatform {
use std::sync::atomic::Ordering;
use crate::DATA_DIR;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::DEFAULT_WORKSPACE_PADDING;
use crate::HIDDEN_HWNDS;
use crate::INITIAL_CONFIGURATION_LOADED;
use crate::KomorebiTheme;