diff options
| author | galister <22305755+galister@users.noreply.github.com> | 2024-06-07 19:41:04 +0900 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-07 19:50:48 +0300 |
| commit | dbf0dddfcc253f9e2b910590ec3d0bd58ed3aa71 (patch) | |
| tree | 614f06c2de2c7dfa4f59e48939d6092a1def5e21 /src | |
| parent | c6c17cccac979575b6402729af39f7c998e90874 (diff) | |
| download | niri-dbf0dddfcc253f9e2b910590ec3d0bd58ed3aa71.tar.gz niri-dbf0dddfcc253f9e2b910590ec3d0bd58ed3aa71.tar.bz2 niri-dbf0dddfcc253f9e2b910590ec3d0bd58ed3aa71.zip | |
PointerMotionAbsolute: use union rect of all outputs
Diffstat (limited to 'src')
| -rw-r--r-- | src/input/mod.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs index 893fd7de..c8bb334e 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -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(); |
