Ignoring mouse events not participating in drag gesture 28/282428/1
authorLukasz Oleksak <l.oleksak@samsung.com>
Tue, 27 Sep 2022 13:14:49 +0000 (15:14 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Mon, 3 Oct 2022 09:27:18 +0000 (11:27 +0200)
Change-Id: If864f916b215f36b973e0d6eab6fd83850627d00

src/e_screen_reader_gestures.c

index 127ee71..b7f1d59 100644 (file)
@@ -91,6 +91,7 @@ struct _Cover
         Eina_Bool double_tap;
         Ecore_Event_Mouse_Button *ev_down, *ev_multi_down;
         Eina_Bool drag_start;
+        int drag_finger[2];
         int drag_x_delta;
         int drag_y_delta;
    } tap_n_hold_gesture_data;
@@ -1014,6 +1015,8 @@ _hover_event_emit(Cover *cov, gesture_state_e state)
           }
         _emit_mouse_move_event(cov->tap_n_hold_gesture_data.ev_down);
         cov->tap_n_hold_gesture_data.ev_down->multi.radius += MAGIC_NUMBER;
+        cov->tap_n_hold_gesture_data.drag_finger[0] = cov->hover_gesture.finger[0];
+        cov->tap_n_hold_gesture_data.drag_finger[1] = cov->hover_gesture.finger[1];
         cov->tap_n_hold_gesture_data.drag_start = EINA_TRUE;
         ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, cov->tap_n_hold_gesture_data.ev_down, NULL, NULL);
         if (cov->tap_gesture_data.tap_type == TWO_FINGERS_GESTURE)
@@ -1291,6 +1294,8 @@ _tap_gestures_mouse_down(Ecore_Event_Mouse_Button *ev, Cover *cov)
          cov->tap_n_hold_gesture_data.n_taps = 1;
          cov->tap_n_hold_gesture_data.double_tap = EINA_FALSE;
          cov->tap_n_hold_gesture_data.drag_start = EINA_FALSE;
+         cov->tap_n_hold_gesture_data.drag_finger[0] = -1;
+         cov->tap_n_hold_gesture_data.drag_finger[1] = -1;
          if (!(cov->tap_n_hold_gesture_data.ev_down = malloc(sizeof(Ecore_Event_Mouse_Button))))
            {
               DEBUG("NOT ENOUGH MEMORY");
@@ -1466,6 +1471,14 @@ static Eina_Bool
 _mouse_move(int type, Ecore_Event_Mouse_Move *event)
 {
    Ecore_Event_Mouse_Move *ev = event;
+   // During draging ignore events from other fingers than the fingers that initiated the drag
+   if (cover->tap_n_hold_gesture_data.drag_start &&
+       ev->multi.device != cover->tap_n_hold_gesture_data.drag_finger[0] &&
+       ev->multi.device != cover->tap_n_hold_gesture_data.drag_finger[1])
+     {
+        return EINA_FALSE;
+     }
+
    /* flick_to_scroll: 2 fingers touch and move
       drag_start: 1 finger tap and hold move */
    cover->event_time = ev->timestamp;
@@ -1532,6 +1545,14 @@ _mouse_button_up(int type, Ecore_Event_Mouse_Button *event)
         event->multi.radius -= MAGIC_NUMBER;
         return EINA_TRUE;
      }
+   // During draging ignore events from other fingers than the fingers that initiated the drag
+   if (cover->tap_n_hold_gesture_data.drag_start &&
+       ev->multi.device != cover->tap_n_hold_gesture_data.drag_finger[0] &&
+       ev->multi.device != cover->tap_n_hold_gesture_data.drag_finger[1])
+     {
+        return EINA_FALSE;
+     }
+
    if (cover->tap_n_hold_gesture_data.drag_start)
      {
         Ecore_Event_Mouse_Button *ev_up, *ev_multi_up;
@@ -1559,6 +1580,8 @@ _mouse_button_up(int type, Ecore_Event_Mouse_Button *event)
              ev_multi_up->multi.device = 1;
              ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev_multi_up, NULL, NULL);
           }
+        cover->tap_n_hold_gesture_data.drag_finger[0] = -1;
+        cover->tap_n_hold_gesture_data.drag_finger[1] = -1;
         cover->tap_n_hold_gesture_data.drag_start = EINA_FALSE;
         g_context->highlighted_object_x = -1;
         g_context->highlighted_object_y = -1;
@@ -1590,7 +1613,13 @@ _mouse_button_down(int type, Ecore_Event_Mouse_Button *event)
         ev->multi.radius -= MAGIC_NUMBER;
         return EINA_TRUE;
      }
-
+   // During draging ignore events from other fingers than the fingers that initiated the drag
+   if (cover->tap_n_hold_gesture_data.drag_start &&
+       ev->multi.device != cover->tap_n_hold_gesture_data.drag_finger[0] &&
+       ev->multi.device != cover->tap_n_hold_gesture_data.drag_finger[1])
+     {
+        return EINA_FALSE;
+     }
    cover->n_taps++;
    cover->event_time = ev->timestamp;