PointerMotionAbsolute: use union rect of all outputs

This commit is contained in:
galister
2024-06-07 19:41:04 +09:00
committed by Ivan Molodetskikh
parent c6c17cccac
commit dbf0dddfcc

View File

@@ -23,7 +23,7 @@ use smithay::input::pointer::{
GrabStartData as PointerGrabStartData, MotionEvent, RelativeMotionEvent,
};
use smithay::input::touch::{DownEvent, MotionEvent as TouchMotionEvent, UpEvent};
use smithay::utils::{Logical, Point, SERIAL_COUNTER};
use smithay::utils::{Logical, Point, Rectangle, SERIAL_COUNTER};
use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};
use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
@@ -214,6 +214,20 @@ impl State {
}
}
/// Computes the rectangle that covers all outputs in global space.
fn global_bounding_rectangle(&self) -> Rectangle<i32, Logical> {
self.niri
.global_space
.outputs()
.fold(None, |acc: Option<Rectangle<i32, Logical>>, output| {
self.niri
.global_space
.output_geometry(output)
.map(|geo| acc.map(|acc| acc.merge(geo)).unwrap_or(geo))
})
.unwrap_or_else(Default::default)
}
/// Computes the cursor position for the tablet event.
///
/// This function handles the tablet output mapping, as well as coordinate clamping and aspect
@@ -1070,11 +1084,7 @@ impl State {
&mut self,
event: I::PointerMotionAbsoluteEvent,
) {
let Some(output) = self.niri.global_space.outputs().next() else {
return;
};
let output_geo = self.niri.global_space.output_geometry(output).unwrap();
let output_geo = self.global_bounding_rectangle();
let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64();