]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: allow movement until entering the constraint surface
authorJohn Lindgren <john@jlindgren.net>
Thu, 4 Dec 2025 08:02:03 +0000 (03:02 -0500)
committerJohn Lindgren <john@jlindgren.net>
Sat, 6 Dec 2025 16:04:41 +0000 (11:04 -0500)
Fixes an issue where the cursor would get stuck (immovable) outside the
window of a Wine/Wayland game, if it was already outside when the game
started (common with a 4:3 game on a 16:9 screen). Now one can manually
move the cursor into the game window, at which point it becomes locked.

This is a minimal/interim fix. Ideally we should warp the cursor into
the constraint area automatically, but that would be a bit more work.

The change to apply_constraint() just turns an assert-failure into a
safe no-op return, since the function is now entered for "locked" as
well as "confined" constraint types.

src/input/cursor.c

index 2a681a6ea2d2880bc8e3dbf953e60db857620170..86297c9a664f2cea734bb0db7680e8cb8fd2d339 100644 (file)
@@ -840,10 +840,12 @@ apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, doub
        if (!seat->server->active_view) {
                return;
        }
-       if (!seat->current_constraint || pointer->base.type != WLR_INPUT_DEVICE_POINTER) {
+       if (!seat->current_constraint
+                       || pointer->base.type != WLR_INPUT_DEVICE_POINTER
+                       || seat->current_constraint->type
+                               != WLR_POINTER_CONSTRAINT_V1_CONFINED) {
                return;
        }
-       assert(seat->current_constraint->type == WLR_POINTER_CONSTRAINT_V1_CONFINED);
 
        double sx = seat->cursor->x;
        double sy = seat->cursor->y;
@@ -866,7 +868,9 @@ cursor_locked(struct seat *seat, struct wlr_pointer *pointer)
 {
        return seat->current_constraint
                && pointer->base.type == WLR_INPUT_DEVICE_POINTER
-               && seat->current_constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED;
+               && seat->current_constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED
+               && seat->current_constraint->surface
+                       == seat->seat->pointer_state.focused_surface;
 }
 
 static void