forge
Explore
Log in

Don't you dare go Hollow

input/tablet: Use f64 for the target rectangle

Browse files at this commit

adb5b3cd2cd6c5fadd555a52a531ba817dfc00beIvan MolodetskikhParent: 0650e7b
src/input/mod.rsmodified+12 -11
@@ -299,14 +299,15 @@ impl State {
299 let device_output = device_output.as_ref();299 let device_output = device_output.as_ref();
300 let (target_geo, keep_ratio, px, transform) =300 let (target_geo, keep_ratio, px, transform) =
301 if let Some(output) = device_output.or_else(|| self.niri.output_for_tablet()) {301 if let Some(output) = device_output.or_else(|| self.niri.output_for_tablet()) {
302+ let geo = self.niri.global_space.output_geometry(output).unwrap();
302 (303 (
303- self.niri.global_space.output_geometry(output).unwrap(),304+ geo.to_f64(),
304 true,305 true,
305 1. / output.current_scale().fractional_scale(),306 1. / output.current_scale().fractional_scale(),
306 output.current_transform(),307 output.current_transform(),
307 )308 )
308 } else {309 } else {
309- let geo = self.global_bounding_rectangle()?;310+ let geo = self.global_bounding_rectangle()?.to_f64();
310 311
311 // FIXME: this 1 px size should ideally somehow be computed for the rightmost output312 // FIXME: this 1 px size should ideally somehow be computed for the rightmost output
312 // corresponding to the position on the right when clamping.313 // corresponding to the position on the right when clamping.
@@ -319,19 +320,19 @@ impl State {
319 320
320 let mut pos = {321 let mut pos = {
321 let size = transform.invert().transform_size(target_geo.size);322 let size = transform.invert().transform_size(target_geo.size);
322- transform.transform_point_in(event.position_transformed(size), &size.to_f64())323+ transform.transform_point_in(event.position_transformed(size.to_i32_round()), &size)
323 };324 };
324 325
325 if keep_ratio {326 if keep_ratio {
326- pos.x /= target_geo.size.w as f64;327+ pos.x /= target_geo.size.w;
327- pos.y /= target_geo.size.h as f64;328+ pos.y /= target_geo.size.h;
328 329
329 let device = event.device();330 let device = event.device();
330 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {331 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
331 if let Some(data) = self.niri.tablets.get(device) {332 if let Some(data) = self.niri.tablets.get(device) {
332 // This code does the same thing as mutter with "keep aspect ratio" enabled.333 // This code does the same thing as mutter with "keep aspect ratio" enabled.
333 let size = transform.invert().transform_size(target_geo.size);334 let size = transform.invert().transform_size(target_geo.size);
334- let output_aspect_ratio = size.w as f64 / size.h as f64;335+ let output_aspect_ratio = size.w / size.h;
335 let ratio = data.aspect_ratio / output_aspect_ratio;336 let ratio = data.aspect_ratio / output_aspect_ratio;
336 337
337 if ratio > 1. {338 if ratio > 1. {
@@ -342,13 +343,13 @@ impl State {
342 }343 }
343 };344 };
344 345
345- pos.x *= target_geo.size.w as f64;346+ pos.x *= target_geo.size.w;
346- pos.y *= target_geo.size.h as f64;347+ pos.y *= target_geo.size.h;
347 }348 }
348 349
349- pos.x = pos.x.clamp(0.0, target_geo.size.w as f64 - px);350+ pos.x = pos.x.clamp(0.0, target_geo.size.w - px);
350- pos.y = pos.y.clamp(0.0, target_geo.size.h as f64 - px);351+ pos.y = pos.y.clamp(0.0, target_geo.size.h - px);
351- Some(pos + target_geo.loc.to_f64())352+ Some(pos + target_geo.loc)
352 }353 }
353 354
354 fn is_inhibiting_shortcuts(&self) -> bool {355 fn is_inhibiting_shortcuts(&self) -> bool {