PointerMotionAbsolute: use union rect of all outputs
Browse files at this commitdbf0dddfcc253f9e2b910590ec3d0bd58ed3aa71Parent: c6c17cc1 changed file +16 -6
- src/input/mod.rs +16 -6
src/input/mod.rsmodified+16 -6
| @@ -23,7 +23,7 @@ use smithay::input::pointer::{ | |||
| 23 | GrabStartData as PointerGrabStartData, MotionEvent, RelativeMotionEvent, | 23 | GrabStartData as PointerGrabStartData, MotionEvent, RelativeMotionEvent, |
| 24 | }; | 24 | }; |
| 25 | use smithay::input::touch::{DownEvent, MotionEvent as TouchMotionEvent, UpEvent}; | 25 | use smithay::input::touch::{DownEvent, MotionEvent as TouchMotionEvent, UpEvent}; |
| 26 | -use smithay::utils::{Logical, Point, SERIAL_COUNTER}; | 26 | +use smithay::utils::{Logical, Point, Rectangle, SERIAL_COUNTER}; |
| 27 | use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint}; | 27 | use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint}; |
| 28 | use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait}; | 28 | use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait}; |
| 29 | 29 | ||
| @@ -214,6 +214,20 @@ impl State { | |||
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | + /// Computes the rectangle that covers all outputs in global space. | ||
| 218 | + fn global_bounding_rectangle(&self) -> Rectangle<i32, Logical> { | ||
| 219 | + self.niri | ||
| 220 | + .global_space | ||
| 221 | + .outputs() | ||
| 222 | + .fold(None, |acc: Option<Rectangle<i32, Logical>>, output| { | ||
| 223 | + self.niri | ||
| 224 | + .global_space | ||
| 225 | + .output_geometry(output) | ||
| 226 | + .map(|geo| acc.map(|acc| acc.merge(geo)).unwrap_or(geo)) | ||
| 227 | + }) | ||
| 228 | + .unwrap_or_else(Default::default) | ||
| 229 | + } | ||
| 230 | + | ||
| 217 | /// Computes the cursor position for the tablet event. | 231 | /// Computes the cursor position for the tablet event. |
| 218 | /// | 232 | /// |
| 219 | /// This function handles the tablet output mapping, as well as coordinate clamping and aspect | 233 | /// This function handles the tablet output mapping, as well as coordinate clamping and aspect |
| @@ -1070,11 +1084,7 @@ impl State { | |||
| 1070 | &mut self, | 1084 | &mut self, |
| 1071 | event: I::PointerMotionAbsoluteEvent, | 1085 | event: I::PointerMotionAbsoluteEvent, |
| 1072 | ) { | 1086 | ) { |
| 1073 | - let Some(output) = self.niri.global_space.outputs().next() else { | 1087 | + let output_geo = self.global_bounding_rectangle(); |
| 1074 | - return; | ||
| 1075 | - }; | ||
| 1076 | - | ||
| 1077 | - let output_geo = self.niri.global_space.output_geometry(output).unwrap(); | ||
| 1078 | 1088 | ||
| 1079 | let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64(); | 1089 | let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64(); |
| 1080 | 1090 | ||