feat(kde): install the settings handle

New module settings.rs: KdeSettings (empty platform part) and settings(), a
LazyLock<Handle<KdeSettings>> starting from Shared::defaults_for(
PlatformDefaults::KDE). Nothing reads it yet, so nothing changes at runtime.
A test pins that the starting settings equal the starting values of the
statics (paddings, resize delta, mouse follows focus, border enabled/width/
offset/radius and the six colours), so that S3 and S6 can move each group
over without changing a default. Plan step 10, S2. Pure refactor.

Verified: KDE cargo test -p komorebi --lib --tests (lite env, own target
dir): all test binaries ok, 0 failed, including the new pin. KDE VM suites
not run.
This commit is contained in:
LGUG2Z committed 2026-10-31 11:25:29 -07:00
1 parent 3a287fcf0d
commit b7b95320ee
2 files changed
+98

No files matched your search

+1
View File
@@ -85,6 +85,7 @@ pub mod process_command;
pub mod process_event;
pub mod reconcile;
pub mod scrolling;
pub mod settings;
pub mod state;
pub mod static_config;
pub mod theme_manager;
+97
View File
@@ -0,0 +1,97 @@
//! 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.
use std::sync::LazyLock;
use komorebi_settings::Handle;
use komorebi_settings::Shared;
use komorebi_settings::shared::PlatformDefaults;
/// The part of the settings that only this platform has.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct KdeSettings {}
pub type Settings = komorebi_settings::Settings<KdeSettings>;
static SETTINGS: LazyLock<Handle<KdeSettings>> = LazyLock::new(|| {
Handle::new(Settings::new(
Shared::defaults_for(PlatformDefaults::KDE),
KdeSettings::default(),
))
});
/// The settings of the running daemon: take a [`Handle::snapshot`] once per unit of work.
pub fn settings() -> &'static Handle<KdeSettings> {
&SETTINGS
}
#[cfg(test)]
mod tests {
use std::sync::atomic::Ordering;
use super::*;
use crate::border_manager;
// The statics are still the source of truth. These pin that the starting values of the
// settings are the starting values of the statics, so that moving a group over changes nothing.
// (They read the statics without any test writing them first: no test here sets them.)
#[test]
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,
crate::DEFAULT_MOUSE_FOLLOWS_FOCUS
);
assert_eq!(
shared.border.enabled,
border_manager::BORDER_ENABLED.load(Ordering::SeqCst)
);
assert_eq!(
shared.border.width,
border_manager::BORDER_WIDTH.load(Ordering::SeqCst)
);
assert_eq!(
shared.border.offset,
border_manager::BORDER_OFFSET.load(Ordering::SeqCst)
);
assert_eq!(
shared.border.radius,
border_manager::BORDER_RADIUS.load(Ordering::SeqCst)
);
let colours = shared.border.colours;
assert_eq!(
colours.single,
border_manager::FOCUSED.load(Ordering::SeqCst)
);
assert_eq!(colours.stack, border_manager::STACK.load(Ordering::SeqCst));
assert_eq!(
colours.monocle,
border_manager::MONOCLE.load(Ordering::SeqCst)
);
assert_eq!(
colours.floating,
border_manager::FLOATING.load(Ordering::SeqCst)
);
assert_eq!(
colours.unfocused,
border_manager::UNFOCUSED.load(Ordering::SeqCst)
);
assert_eq!(
colours.unfocused_locked,
border_manager::UNFOCUSED_LOCKED.load(Ordering::SeqCst)
);
}
}