feat(core): WorkspaceGlobals moves into komorebi-core

The plain data a monitor gives the workspaces it shows (padding, border
width and offset, work area, offsets, floating layer behaviour), moved
from komorebi-for-kde/komorebi/src/workspace.rs (the Windows struct is
the same nine fields with the same derives) into komorebi-core, with the
KDE doc comments and two unit tests. komorebi-core now depends on
komorebi-config (for FloatingLayerBehaviour, default features off) and
komorebi-layouts (for Rect); its schemars feature enables theirs. The
struct derives JsonSchema under the feature, as Windows' did; a workspace
skips the field when serialised and in its schema, so no schema changes.

No daemon uses it yet: the next two revisions converge KDE and Windows.

Verified: cargo test -p komorebi-core --features schemars (native): 15
passed, 0 failed. Not run: the daemons.
This commit is contained in:
LGUG2Z committed 2026-10-31 12:14:35 -07:00
1 parent e4a5a03b99
commit 88afd37d36
4 files changed
+73 -1

No files matched your search

Generated
+2
View File
@@ -3496,6 +3496,8 @@ name = "komorebi-core"
version = "0.1.42"
dependencies = [
"komorebi-collections",
"komorebi-config",
"komorebi-layouts",
"nanoid",
"schemars 1.2.3",
"serde",
+8 -1
View File
@@ -6,6 +6,8 @@ edition = "2024"
[dependencies]
komorebi-collections = { path = "../komorebi-collections" }
komorebi-config = { path = "../komorebi-config", default-features = false }
komorebi-layouts = { path = "../../komorebi-layouts" }
nanoid = "0.5"
schemars = { workspace = true, optional = true }
serde = { workspace = true }
@@ -16,4 +18,9 @@ serde_json = { workspace = true, features = ["preserve_order"] }
[features]
# derives `schemars::JsonSchema` for the model types
schemars = ["dep:schemars", "komorebi-collections/schemars"]
schemars = [
"dep:schemars",
"komorebi-collections/schemars",
"komorebi-config/schemars",
"komorebi-layouts/schemars",
]
+61
View File
@@ -0,0 +1,61 @@
//! [`WorkspaceGlobals`], what a monitor gives the workspaces it shows.
use komorebi_config::behaviour::FloatingLayerBehaviour;
use komorebi_layouts::Rect;
use serde::Deserialize;
use serde::Serialize;
/// The work area a monitor gives the workspace it shows, the padding and the offset the workspace
/// falls back to when it sets none of its own, the monitor's window-based offset, and the room
/// around each window that a border takes.
///
/// Set by the parent monitor or by the window manager, never read from a file: a workspace skips
/// it when it is serialised.
#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct WorkspaceGlobals {
/// The container padding of the monitor.
pub container_padding: Option<i32>,
/// The workspace padding of the monitor.
pub workspace_padding: Option<i32>,
/// The width of the border around each window, 0 when none is drawn.
pub border_width: i32,
/// The offset of the border from the window.
pub border_offset: i32,
/// The work area of the monitor.
pub work_area: Rect,
/// The offset of the work area, if any.
pub work_area_offset: Option<Rect>,
/// The offset the monitor has asked for according to its windows.
pub window_based_work_area_offset: Option<Rect>,
/// The most windows the window-based offset is applied for.
pub window_based_work_area_offset_limit: isize,
/// The floating layer behaviour of the monitor, which the workspace's own overrides
pub floating_layer_behaviour: Option<FloatingLayerBehaviour>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_default_globals_ask_for_nothing() {
let globals = WorkspaceGlobals::default();
assert_eq!(globals.container_padding, None);
assert_eq!(globals.border_width, 0);
assert_eq!(globals.work_area, Rect::default());
assert_eq!(globals.window_based_work_area_offset_limit, 0);
}
#[test]
fn globals_are_a_copy_that_compares_by_value() {
let a = WorkspaceGlobals {
border_width: 8,
..Default::default()
};
let b = a;
assert_eq!(a, b);
}
}
+2
View File
@@ -8,8 +8,10 @@
#![deny(missing_docs)]
mod container;
mod globals;
pub use container::Container;
pub use container::ContainerWindow;
pub use globals::WorkspaceGlobals;
pub use komorebi_collections::Lockable;
pub use komorebi_collections::ring;