mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Use correct workspace vertical position for rendering
This commit is contained in:
+37
-16
@@ -835,20 +835,6 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn workspace_for_output(&self, output: &Output) -> Option<&Workspace<W>> {
|
|
||||||
let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
monitors.iter().find_map(|monitor| {
|
|
||||||
if &monitor.output == output {
|
|
||||||
Some(&monitor.workspaces[monitor.active_workspace_idx])
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn windows_for_output(&self, output: &Output) -> impl Iterator<Item = &W> + '_ {
|
pub fn windows_for_output(&self, output: &Output) -> impl Iterator<Item = &W> + '_ {
|
||||||
let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {
|
let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {
|
||||||
panic!()
|
panic!()
|
||||||
@@ -1019,8 +1005,12 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
output: &Output,
|
output: &Output,
|
||||||
pos_within_output: Point<f64, Logical>,
|
pos_within_output: Point<f64, Logical>,
|
||||||
) -> Option<(&W, Point<i32, Logical>)> {
|
) -> Option<(&W, Point<i32, Logical>)> {
|
||||||
let ws = self.workspace_for_output(output).unwrap();
|
let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {
|
||||||
ws.window_under(pos_within_output)
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
let mon = monitors.iter().find(|mon| &mon.output == output)?;
|
||||||
|
mon.window_under(pos_within_output)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -1698,6 +1688,37 @@ impl<W: LayoutElement> Monitor<W> {
|
|||||||
|
|
||||||
self.clean_up_workspaces();
|
self.clean_up_workspaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn window_under(
|
||||||
|
&self,
|
||||||
|
pos_within_output: Point<f64, Logical>,
|
||||||
|
) -> Option<(&W, Point<i32, Logical>)> {
|
||||||
|
match &self.workspace_switch {
|
||||||
|
Some(switch) => {
|
||||||
|
let size = output_size(&self.output);
|
||||||
|
|
||||||
|
let render_idx = switch.current_idx();
|
||||||
|
let before_idx = render_idx.floor() as usize;
|
||||||
|
let after_idx = render_idx.ceil() as usize;
|
||||||
|
|
||||||
|
let offset = ((render_idx - before_idx as f64) * size.h as f64).round() as i32;
|
||||||
|
|
||||||
|
let (idx, ws_offset) = if pos_within_output.y < (size.h - offset) as f64 {
|
||||||
|
(before_idx, Point::from((0, offset)))
|
||||||
|
} else {
|
||||||
|
(after_idx, Point::from((0, -size.h + offset)))
|
||||||
|
};
|
||||||
|
|
||||||
|
let ws = &self.workspaces[idx];
|
||||||
|
let (win, win_pos) = ws.window_under(pos_within_output + ws_offset.to_f64())?;
|
||||||
|
Some((win, win_pos - ws_offset))
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
let ws = &self.workspaces[self.active_workspace_idx];
|
||||||
|
ws.window_under(pos_within_output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Monitor<Window> {
|
impl Monitor<Window> {
|
||||||
|
|||||||
Reference in New Issue
Block a user