]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/cursor.c: add cursor lock confinement
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 24 Feb 2023 09:20:14 +0000 (10:20 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 24 Feb 2023 21:32:25 +0000 (21:32 +0000)
src/cursor.c

index 595636842faa393cfd260a95a6b04ed2f6931f85..1f05ad0ffa08e13d4350dfa95d91bdfe7bcab767 100644 (file)
@@ -595,6 +595,7 @@ apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, doub
        if (!seat->current_constraint || pointer->base.type != WLR_INPUT_DEVICE_POINTER) {
                return;
        }
+       assert(seat->current_constraint->type == WLR_POINTER_CONSTRAINT_V1_CONFINED);
 
        double sx = seat->cursor->x;
        double sy = seat->cursor->y;
@@ -612,10 +613,21 @@ apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, doub
        *y = sy_confined - sy;
 }
 
+static bool
+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;
+}
+
 static void
 preprocess_cursor_motion(struct seat *seat, struct wlr_pointer *pointer,
                uint32_t time_msec, double dx, double dy)
 {
+       if (cursor_locked(seat, pointer)) {
+               return;
+       }
        apply_constraint(seat, pointer, &dx, &dy);
 
        /*