forge
Explore
Log in

Don't you dare go Hollow

input: apply output transform for tablet input (#737)

Browse files at this commit

0c5e046820202858e782d4bf15cbecec88e90420UnverifiedChristian MeisslParent: 907ebc4
when mapping a tablet input to an output apply
the output transform just like we already do for
touch input.
src/input/mod.rsmodified+24 -18
@@ -24,7 +24,7 @@ use smithay::input::pointer::{
24 GrabStartData as PointerGrabStartData, MotionEvent, RelativeMotionEvent,24 GrabStartData as PointerGrabStartData, MotionEvent, RelativeMotionEvent,
25 };25 };
26 use smithay::input::touch::{DownEvent, MotionEvent as TouchMotionEvent, UpEvent};26 use smithay::input::touch::{DownEvent, MotionEvent as TouchMotionEvent, UpEvent};
27-use smithay::utils::{Logical, Point, Rectangle, SERIAL_COUNTER};27+use smithay::utils::{Logical, Point, Rectangle, Transform, SERIAL_COUNTER};
28 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};28 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};
29 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};29 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
30 30
@@ -243,25 +243,30 @@ impl State {
243 where243 where
244 I::Device: 'static,244 I::Device: 'static,
245 {245 {
246- let (target_geo, keep_ratio, px) = if let Some(output) = self.niri.output_for_tablet() {246+ let (target_geo, keep_ratio, px, transform) =
247- (247+ if let Some(output) = self.niri.output_for_tablet() {
248- self.niri.global_space.output_geometry(output).unwrap(),248+ (
249- true,249+ self.niri.global_space.output_geometry(output).unwrap(),
250- 1. / output.current_scale().fractional_scale(),250+ true,
251- )251+ 1. / output.current_scale().fractional_scale(),
252- } else {252+ output.current_transform(),
253- let geo = self.global_bounding_rectangle()?;253+ )
254+ } else {
255+ let geo = self.global_bounding_rectangle()?;
254 256
255- // FIXME: this 1 px size should ideally somehow be computed for the rightmost output257+ // FIXME: this 1 px size should ideally somehow be computed for the rightmost output
256- // corresponding to the position on the right when clamping.258+ // corresponding to the position on the right when clamping.
257- let output = self.niri.global_space.outputs().next().unwrap();259+ let output = self.niri.global_space.outputs().next().unwrap();
258- let scale = output.current_scale().fractional_scale();260+ let scale = output.current_scale().fractional_scale();
259 261
260- // Do not keep ratio for the unified mode as this is what OpenTabletDriver expects.262+ // Do not keep ratio for the unified mode as this is what OpenTabletDriver expects.
261- (geo, false, 1. / scale)263+ (geo, false, 1. / scale, Transform::Normal)
262- };264+ };
263 265
264- let mut pos = event.position_transformed(target_geo.size);266+ let mut pos = {
267+ let size = transform.invert().transform_size(target_geo.size);
268+ transform.transform_point_in(event.position_transformed(size), &size.to_f64())
269+ };
265 270
266 if keep_ratio {271 if keep_ratio {
267 pos.x /= target_geo.size.w as f64;272 pos.x /= target_geo.size.w as f64;
@@ -271,7 +276,8 @@ impl State {
271 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {276 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
272 if let Some(data) = self.niri.tablets.get(device) {277 if let Some(data) = self.niri.tablets.get(device) {
273 // This code does the same thing as mutter with "keep aspect ratio" enabled.278 // This code does the same thing as mutter with "keep aspect ratio" enabled.
274- let output_aspect_ratio = target_geo.size.w as f64 / target_geo.size.h as f64;279+ let size = transform.invert().transform_size(target_geo.size);
280+ let output_aspect_ratio = size.w as f64 / size.h as f64;
275 let ratio = data.aspect_ratio / output_aspect_ratio;281 let ratio = data.aspect_ratio / output_aspect_ratio;
276 282
277 if ratio > 1. {283 if ratio > 1. {