Speed up per-frame layout, hit testing, and stacking paths

Split ScrollingLayout validation so the per-frame geometry solve only
checks scalars and keeps the full tree validation behind debug_assert,
removing a HashSet build from every frame. Replace the per-region Vec
in decode_regions with a stack array via as_chunks, and skip the window
hit test in PointerMotion when Overview is not presenting, where
visual_scale_for_window returns 1.0 regardless.

Guard sync_window_stacking behind a check that the space already matches
the target order with uniform z_index, avoiding an O(n^2) raise_element
loop on every redraw. Narrow window_under_visual to the space iterator
outside Overview, keeping the collected and sorted candidate list for
the Overview branch where front-to-back order is load-bearing.

Raise rust-version to 1.98 and clear the resulting Clippy findings
across the workspace: let-chain collapses, clamp, and while-let loops.
This commit is contained in:
Samuel Onoja committed 2026-09-29 09:49:04 +01:00
1 parent 391f6b4e37
commit 67192c0c04
25 files changed
+886 -700

No files matched your search

+20 -16
View File
@@ -39,6 +39,7 @@ pub fn default_wallpaper() -> &'static str {
.unwrap_or_else(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/wallpapers/ferese.png")
});
path.canonicalize()
.unwrap_or(path)
.to_string_lossy()
@@ -50,6 +51,7 @@ fn field(name: &str, parent: &str) -> String {
if parent == "commands" {
return name.to_owned();
}
match name {
"binding" => "bindings".into(),
"window-rule" => "window_rules".into(),
@@ -61,11 +63,14 @@ fn field(name: &str, parent: &str) -> String {
}
fn is_records(key: &str, parent: &str) -> bool {
match (parent, key) {
("", "bindings" | "window_rules" | "output_profiles" | "autostart") => true,
("output_profiles", "outputs") | ("desktop_widgets", "notes") => true,
_ => false,
}
matches!(
(parent, key),
(
"",
"bindings" | "window_rules" | "output_profiles" | "autostart"
) | ("output_profiles", "outputs")
| ("desktop_widgets", "notes")
)
}
fn is_array(key: &str, parent: &str) -> bool {
@@ -365,11 +370,11 @@ fn restore_node_formats(doc: &mut KdlDocument, formats: &mut impl Iterator<Item
entry.set_format(format);
}
}
if let Some(terminator) = terminator {
if let Some(format) = node.format_mut() {
format.before_terminator = " ".into();
format.terminator = terminator;
}
if let Some(terminator) = terminator
&& let Some(format) = node.format_mut()
{
format.before_terminator = " ".into();
format.terminator = terminator;
}
}
if let Some(children) = node.children_mut() {
@@ -519,15 +524,14 @@ fn set_in(doc: &mut KdlDocument, parts: &[&str], parent: &str, value: Value) ->
}
let node = &mut doc.nodes_mut()[i];
if parts.len() == 2 {
if let Some(entry) = node
if parts.len() == 2
&& let Some(entry) = node
.entries_mut()
.iter_mut()
.find(|e| e.name().is_some_and(|n| field(n.value(), key) == parts[1]))
{
set_entry_value(entry, kdl_value(&value)?);
return Ok(());
}
{
set_entry_value(entry, kdl_value(&value)?);
return Ok(());
}
set_in(
+10 -2
View File
@@ -456,7 +456,10 @@ impl ScrollingLayout {
if let Some(focused) = focused {
self.focus(focused)?;
}
self.validate()?;
self.validate_scalars()?;
debug_assert!(self.validate().is_ok());
if self.columns.is_empty() {
self.viewport_x = 0.0;
return Ok(LayoutResult::default());
@@ -673,7 +676,7 @@ impl ScrollingLayout {
})
}
pub fn validate(&self) -> Result<(), LayoutError> {
fn validate_scalars(&self) -> Result<(), LayoutError> {
if !self.viewport_x.is_finite() {
return Err(LayoutError::InvalidTree(
"scrolling viewport offset is invalid",
@@ -701,6 +704,11 @@ impl ScrollingLayout {
"scrolling active column is invalid",
));
}
Ok(())
}
pub fn validate(&self) -> Result<(), LayoutError> {
self.validate_scalars()?;
let mut windows = HashSet::new();
for column in &self.columns {