Reduce idle shell polling and stabilize overview damage

This commit is contained in:
Samuel Onoja committed 2026-10-02 02:34:35 +01:00
1 parent 6f2951c6b0
commit ab0c174948
9 files changed
+797 -11

No files matched your search

+13 -4
View File
@@ -740,7 +740,7 @@ impl Ferese {
(rect.width - 12.0).max(1.0),
(rect.height - 26.0).max(1.0),
);
let windows = preview_layout(preview_bounds, &windows, 4.0, 4.0).into_iter().collect();
let windows = preview_layout(preview_bounds, &windows, 4.0, 4.0);
WorkspaceCard {
workspace: workspace.id,
index: view.index,
@@ -889,11 +889,15 @@ impl Ferese {
fn overview_layout(bounds: Rect, windows: &[(WindowId, Rect)]) -> HashMap<WindowId, Rect> {
preview_layout(bounds, windows, OVERVIEW_MARGIN, OVERVIEW_GAP)
.into_iter()
.collect()
}
fn preview_layout(bounds: Rect, windows: &[(WindowId, Rect)], margin: f64, gap: f64) -> HashMap<WindowId, Rect> {
// Preserve input order for rendering: the damage tracker includes each
// instance's z index, even when neighboring previews do not overlap.
fn preview_layout(bounds: Rect, windows: &[(WindowId, Rect)], margin: f64, gap: f64) -> Vec<(WindowId, Rect)> {
if windows.is_empty() {
return HashMap::new();
return Vec::new();
}
let margin = margin.min(bounds.width * 0.1).min(bounds.height * 0.1);
@@ -1242,7 +1246,12 @@ mod tests {
.map(|id| (WindowId(id), Rect::new(0.0, 0.0, 1000.0, 800.0)))
.collect::<Vec<_>>();
let layout = preview_layout(bounds, &windows, 4.0, 4.0);
for rect in layout.values() {
assert_eq!(
layout.iter().map(|(id, _)| *id).collect::<Vec<_>>(),
windows.iter().map(|(id, _)| *id).collect::<Vec<_>>()
);
for (_, rect) in layout {
assert!((rect.width / rect.height - 1.25).abs() < 0.001);
assert!(rect.y + rect.height <= bounds.y + bounds.height);
assert!(rect.x + rect.width <= bounds.x + bounds.width);
+11 -5
View File
@@ -136,14 +136,17 @@ pub(super) fn overview_strip_elements(
}
// Cached title textures are independent of window content and stay readable
// when thumbnails are small. Their pills use the shell's material and radius.
for id in frame.windows.keys() {
if !state.window_belongs_to_output(*id, output) {
// Match the grid's stable front-to-back order. A sampled frame's HashMap
// has a fresh seed; iterating it changes z indices and damages still captions.
let caption_ids = state.windows.ordered_ids().rev().collect::<Vec<_>>();
for id in caption_ids {
if !state.window_belongs_to_output(id, output) {
continue;
}
let Some(rect) = frame.windows.get(id).map(|sample| sample.rect) else {
let Some(rect) = frame.windows.get(&id).map(|sample| sample.rect) else {
continue;
};
let Some((buffer, size)) = state.overview_window_label(*id, scale, rect.width) else {
let Some((buffer, size)) = state.overview_window_label(id, scale, rect.width) else {
continue;
};
let width = (f64::from(size.w) / scale + 16.0).min(rect.width);
@@ -227,7 +230,10 @@ pub(super) fn overview_strip_elements(
RoundedRect::new(*rect, output_geometry.loc, scale, 4.0),
scale,
alpha,
true,
// The damage tracker tracks each miniature's crop,
// scale, alpha and geometry. Its corner radius is fixed,
// so an unchanged clip needs no extra full damage.
false,
output,
programs.clone(),
ConstrainScaleBehavior::Stretch,