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::{
2424 GrabStartData as PointerGrabStartData, MotionEvent, RelativeMotionEvent,
2525 };
2626 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};
2828 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};
2929 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
3030
@@ -243,25 +243,30 @@ impl State {
243243 where
244244 I::Device: 'static,
245245 {
246- let (target_geo, keep_ratio, px) = if let Some(output) = self.niri.output_for_tablet() {
247- (
248- self.niri.global_space.output_geometry(output).unwrap(),
249- true,
250- 1. / output.current_scale().fractional_scale(),
251- )
252- } else {
253- let geo = self.global_bounding_rectangle()?;
246+ let (target_geo, keep_ratio, px, transform) =
247+ if let Some(output) = self.niri.output_for_tablet() {
248+ (
249+ self.niri.global_space.output_geometry(output).unwrap(),
250+ true,
251+ 1. / output.current_scale().fractional_scale(),
252+ output.current_transform(),
253+ )
254+ } else {
255+ let geo = self.global_bounding_rectangle()?;
254256
255- // FIXME: this 1 px size should ideally somehow be computed for the rightmost output
256- // corresponding to the position on the right when clamping.
257- let output = self.niri.global_space.outputs().next().unwrap();
258- let scale = output.current_scale().fractional_scale();
257+ // FIXME: this 1 px size should ideally somehow be computed for the rightmost output
258+ // corresponding to the position on the right when clamping.
259+ let output = self.niri.global_space.outputs().next().unwrap();
260+ let scale = output.current_scale().fractional_scale();
259261
260- // Do not keep ratio for the unified mode as this is what OpenTabletDriver expects.
261- (geo, false, 1. / scale)
262- };
262+ // Do not keep ratio for the unified mode as this is what OpenTabletDriver expects.
263+ (geo, false, 1. / scale, Transform::Normal)
264+ };
263265
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+ };
265270
266271 if keep_ratio {
267272 pos.x /= target_geo.size.w as f64;
@@ -271,7 +276,8 @@ impl State {
271276 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
272277 if let Some(data) = self.niri.tablets.get(device) {
273278 // 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;
275281 let ratio = data.aspect_ratio / output_aspect_ratio;
276282
277283 if ratio > 1. {