From 9e143da8145d0c610d0569c178551d3f0a2b84a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= <150025636+git-f0x@users.noreply.github.com> Date: Fri, 19 Dec 2025 18:56:56 +0100 Subject: [PATCH] fix(input): pointer clamping - Reduces the max clamp value by 1, since it previously ended up 1 pixel off screen. Fixes #981. - Moves clamping to before `new_under`, since it previously ignored any motion that goes off screen, causing issues in some fullscreen clients. Fixes #1286. --- src/input/mod.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index 7672be84..9b06d0d7 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -23,7 +23,7 @@ use crate::{ }, zoom::ZoomState, }, - utils::{float::NextDown, prelude::*, quirks::workspace_overview_is_open}, + utils::{prelude::*, quirks::workspace_overview_is_open}, wayland::{ handlers::{screencopy::SessionHolder, xwayland_keyboard_grab::XWaylandGrabSeat}, protocols::screencopy::{BufferConstraints, CursorSessionRef}, @@ -356,6 +356,16 @@ impl State { .cloned() .unwrap_or(current_output.clone()); + let output_geometry = output.geometry(); + position.x = position.x.clamp( + output_geometry.loc.x as f64, + (output_geometry.loc.x + output_geometry.size.w - 1) as f64, + ); + position.y = position.y.clamp( + output_geometry.loc.y as f64, + (output_geometry.loc.y + output_geometry.size.h - 1) as f64, + ); + let new_under = State::surface_under(position, &output, &shell) .map(|(target, pos)| (target, pos.as_logical())); @@ -482,17 +492,6 @@ impl State { } } - let output_geometry = output.geometry(); - - position.x = position.x.clamp( - output_geometry.loc.x as f64, - ((output_geometry.loc.x + output_geometry.size.w) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable - ); - position.y = position.y.clamp( - output_geometry.loc.y as f64, - ((output_geometry.loc.y + output_geometry.size.h) as f64).next_lower(), // FIXME: Replace with f64::next_down when stable - ); - // If confined, don't move pointer if it would go outside surface or region if pointer_confined { if let Some((surface, surface_loc)) = &under {