]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: move touch only with one touch point
authorJens Peters <jp7677@gmail.com>
Tue, 5 Nov 2024 19:59:14 +0000 (20:59 +0100)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Sun, 10 Nov 2024 08:08:38 +0000 (17:08 +0900)
In other words, do not move the cursor when more than
one finger is down.

src/input/touch.c

index e7c9a26e5bdc22cdf5070d46f2ef56238ea44003..fc330d898639c03c1bf60438e96f3ef0c2f19f0e 100644 (file)
@@ -63,6 +63,8 @@ handle_touch_motion(struct wl_listener *listener, void *data)
        struct wlr_touch_motion_event *event = data;
        idle_manager_notify_activity(seat->seat);
 
+       int touch_point_count = wl_list_length(&seat->touch_points);
+
        /* Find existing touch point to determine initial offsets to subtract */
        struct touch_point *touch_point;
        wl_list_for_each(touch_point, &seat->touch_points, link) {
@@ -77,13 +79,17 @@ handle_touch_motion(struct wl_listener *listener, void *data)
                                double sx = lx - touch_point->x_offset;
                                double sy = ly - touch_point->y_offset;
 
-                               wlr_cursor_warp_absolute(seat->cursor,
-                                       &event->touch->base, event->x, event->y);
+                               if (touch_point_count == 1) {
+                                       wlr_cursor_warp_absolute(seat->cursor, &event->touch->base,
+                                               event->x, event->y);
+                               }
                                wlr_seat_touch_notify_motion(seat->seat, event->time_msec,
                                        event->touch_id, sx, sy);
                        } else {
-                               cursor_emulate_move_absolute(seat, &event->touch->base,
-                                       event->x, event->y, event->time_msec);
+                               if (touch_point_count == 1) {
+                                       cursor_emulate_move_absolute(seat, &event->touch->base,
+                                               event->x, event->y, event->time_msec);
+                               }
                        }
                        return;
                }
@@ -114,6 +120,7 @@ handle_touch_down(struct wl_listener *listener, void *data)
        touch_point->y_offset = y_offset;
 
        wl_list_insert(&seat->touch_points, &touch_point->link);
+       int touch_point_count = wl_list_length(&seat->touch_points);
 
        if (touch_point->surface) {
                /* Convert coordinates: first [0, 1] => layout */
@@ -135,13 +142,17 @@ handle_touch_down(struct wl_listener *listener, void *data)
                        }
                }
 
-               wlr_cursor_warp_absolute(seat->cursor,
-                       &event->touch->base, event->x, event->y);
+               if (touch_point_count == 1) {
+                       wlr_cursor_warp_absolute(seat->cursor, &event->touch->base,
+                               event->x, event->y);
+               }
                wlr_seat_touch_notify_down(seat->seat, touch_point->surface,
                        event->time_msec, event->touch_id, sx, sy);
        } else {
-               cursor_emulate_move_absolute(seat, &event->touch->base,
-                       event->x, event->y, event->time_msec);
+               if (touch_point_count == 1) {
+                       cursor_emulate_move_absolute(seat, &event->touch->base,
+                               event->x, event->y, event->time_msec);
+               }
                cursor_emulate_button(seat, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED,
                        event->time_msec);
        }