Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/layout/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,13 @@ impl<W: LayoutElement> Monitor<W> {
(0..=self.workspaces.len()).map(move |idx| {
let y = first_ws_y + idx as f64 * ws_height_with_gap;
let loc = Point::from((0., y)) + static_offset;

// Even though all components that go into loc are rounded to physical pixels, the
// floating point addition may lose precision. This can result for example in the
// current workspace having y = 0.0000000000002 and thus missing pointer hits at the
// monitor edge with y = 0. So, post-round the location too.
let loc = loc.to_physical_precise_round(scale).to_logical(scale);

Rectangle::new(loc, ws_size)
})
}
Expand Down
35 changes: 35 additions & 0 deletions src/layout/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3691,6 +3691,41 @@ fn expel_pending_left_from_fullscreen_tabbed_column() {
check_ops(ops);
}

#[test]
fn workspace_render_geo_at_fractional_scale() {
let ops = [
Op::AddScaledOutput {
id: 1,
scale: 1.1,
layout_config: None,
},
Op::AddWindow {
params: TestWindowParams::new(1),
},
Op::FocusWorkspaceDown,
Op::CompleteAnimations,
];

let layout = check_ops(ops);

let MonitorSet::Normal { monitors, .. } = &layout.monitor_set else {
unreachable!()
};

let mon = &monitors[0];
let mut iter = mon.workspaces_with_render_geo();
let (_ws, geo) = iter.next().unwrap();
assert!(
iter.next().is_none(),
"animations are completed, only one workspace should be visible"
);
assert_eq!(
geo.loc.y, 0.,
"active workspace must be at y = 0 exactly, \
otherwise a pointer against the screen edge at y = 0 won't hit it"
);
}

fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {
if parent_id == id {
return true;
Expand Down