Ecore_Drm: Fix discontinuous mouse motion when handling multiple pointer devices 21/52621/6
authorDuna Oh <duna.oh@samsung.com>
Wed, 25 Nov 2015 06:30:49 +0000 (15:30 +0900)
committerDuna Oh <duna.oh@samsung.com>
Mon, 30 Nov 2015 23:09:38 +0000 (15:09 -0800)
Change-Id: I3ea09a6b9dc19af586c56cf1d3ea3a2e9ae68190
Signed-off-by: Duna Oh <duna.oh@samsung.com>
src/lib/ecore_drm/ecore_drm_device.c
src/lib/ecore_drm/ecore_drm_evdev.c
src/lib/ecore_drm/ecore_drm_private.h

index 63efa40..a4664ee 100644 (file)
@@ -513,8 +513,7 @@ EAPI void
 ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y)
 {
    Ecore_Drm_Seat *seat;
-   Ecore_Drm_Evdev *edev;
-   Eina_List *l, *ll;
+   Eina_List *l;
 
    if (x) *x = 0;
    if (y) *y = 0;
@@ -524,17 +523,10 @@ ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y)
 
    EINA_LIST_FOREACH(dev->seats, l, seat)
      {
-        EINA_LIST_FOREACH(seat->devices, ll, edev)
-          {
-             if (!libinput_device_has_capability(edev->device, 
-                                                 LIBINPUT_DEVICE_CAP_POINTER))
-               continue;
+        if (x) *x = seat->ptr.dx;
+        if (y) *y = seat->ptr.dy;
 
-             if (x) *x = edev->mouse.dx;
-             if (y) *y = edev->mouse.dy;
-
-             return;
-          }
+        return;
      }
 }
 
index fc1a0c3..3d424f7 100644 (file)
@@ -83,8 +83,10 @@ _device_output_set(Ecore_Drm_Evdev *edev)
         Ecore_Drm_Input *pointer_input;
         Ecore_Event_Mouse_Move *ev;
 
-        edev->mouse.dx = edev->output->current_mode->width / 2;
-        edev->mouse.dy = edev->output->current_mode->height / 2;
+        edev->seat->ptr.ix = edev->seat->ptr.dx = edev->output->current_mode->width / 2;
+        edev->seat->ptr.iy = edev->seat->ptr.dy = edev->output->current_mode->height / 2;
+        edev->mouse.dx = edev->seat->ptr.dx;
+        edev->mouse.dy = edev->seat->ptr.dy;
 
         /* send a fake motion event to let other know the initial pos of mouse */
         if (!(pointer_input = edev->seat->input)) return;
@@ -98,8 +100,8 @@ _device_output_set(Ecore_Drm_Evdev *edev)
         ev->modifiers = edev->xkb.modifiers;
         ev->same_screen = 1;
 
-        ev->x = edev->mouse.dx;
-        ev->y = edev->mouse.dy;
+        ev->x = edev->seat->ptr.ix;
+        ev->y = edev->seat->ptr.iy;
         ev->root.x = ev->x;
         ev->root.y = ev->y;
         ev->multi.device = edev->mt_slot;
@@ -392,15 +394,18 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve
 
    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
 
-   if (edev->mouse.ix < edev->mouse.minx)
-     edev->mouse.dx = edev->mouse.ix = edev->mouse.minx;
-   else if (edev->mouse.ix >= (edev->mouse.minx + edev->mouse.maxw))
-     edev->mouse.dx = edev->mouse.ix = (edev->mouse.minx + edev->mouse.maxw - 1);
+   if (edev->seat->ptr.ix < edev->mouse.minx)
+     edev->seat->ptr.dx = edev->seat->ptr.ix = edev->mouse.minx;
+   else if (edev->seat->ptr.ix >= (edev->mouse.minx + edev->mouse.maxw))
+     edev->seat->ptr.dx = edev->seat->ptr.ix = (edev->mouse.minx + edev->mouse.maxw - 1);
 
-   if (edev->mouse.iy < edev->mouse.miny)
-     edev->mouse.dy = edev->mouse.iy = edev->mouse.miny;
-   else if (edev->mouse.iy >= (edev->mouse.miny + edev->mouse.maxh))
-     edev->mouse.dy = edev->mouse.iy = (edev->mouse.miny + edev->mouse.maxh - 1);
+   if (edev->seat->ptr.iy < edev->mouse.miny)
+     edev->seat->ptr.dy = edev->seat->ptr.iy = edev->mouse.miny;
+   else if (edev->seat->ptr.iy >= (edev->mouse.miny + edev->mouse.maxh))
+     edev->seat->ptr.dy = edev->seat->ptr.iy = (edev->mouse.miny + edev->mouse.maxh - 1);
+
+   edev->mouse.dx = edev->seat->ptr.dx;
+   edev->mouse.dy = edev->seat->ptr.dy;
 
    ev->window = (Ecore_Window)input->dev->window;
    ev->event_window = (Ecore_Window)input->dev->window;
@@ -411,8 +416,8 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve
    _device_modifiers_update(edev);
    ev->modifiers = edev->xkb.modifiers;
 
-   ev->x = edev->mouse.ix;
-   ev->y = edev->mouse.iy;
+   ev->x = edev->seat->ptr.ix;
+   ev->y = edev->seat->ptr.iy;
    ev->root.x = ev->x;
    ev->root.y = ev->y;
 
@@ -437,14 +442,17 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev
 
    if (!(edev = libinput_device_get_user_data(device))) return;
 
-   edev->mouse.dx += libinput_event_pointer_get_dx(event);
-   edev->mouse.dy += libinput_event_pointer_get_dy(event);
+   edev->seat->ptr.dx += libinput_event_pointer_get_dx(event);
+   edev->seat->ptr.dy += libinput_event_pointer_get_dy(event);
+
+   edev->mouse.dx = edev->seat->ptr.dx;
+   edev->mouse.dy = edev->seat->ptr.dy;
 
-   if (floor(edev->mouse.dx) == edev->mouse.ix &&
-       floor(edev->mouse.dy) == edev->mouse.iy) return;
+   if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
+       floor(edev->seat->ptr.dy) == edev->seat->ptr.iy) return;
 
-   edev->mouse.ix = edev->mouse.dx;
-   edev->mouse.iy = edev->mouse.dy;
+   edev->seat->ptr.ix = edev->seat->ptr.dx;
+   edev->seat->ptr.iy = edev->seat->ptr.dy;
   _device_pointer_motion(edev, event);
 }
 
@@ -455,16 +463,18 @@ _device_handle_pointer_motion_absolute(struct libinput_device *device, struct li
 
    if (!(edev = libinput_device_get_user_data(device))) return;
 
-   edev->mouse.dx =
+   edev->mouse.dx = edev->seat->ptr.dx =
      libinput_event_pointer_get_absolute_x_transformed(event,
                                                        edev->output->current_mode->width);
-   edev->mouse.dy =
+   edev->mouse.dy = edev->seat->ptr.dy =
      libinput_event_pointer_get_absolute_y_transformed(event,
                                                        edev->output->current_mode->height);
 
-   if (floor(edev->mouse.dx) == edev->mouse.ix &&
-       floor(edev->mouse.dy) == edev->mouse.iy) return;
+   if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
+       floor(edev->seat->ptr.dy) == edev->seat->ptr.iy) return;
 
+   edev->seat->ptr.ix = edev->seat->ptr.dx;
+   edev->seat->ptr.iy = edev->seat->ptr.dy;
    _device_pointer_motion(edev, event);
 }
 
@@ -499,8 +509,8 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
    _device_modifiers_update(edev);
    ev->modifiers = edev->xkb.modifiers;
 
-   ev->x = edev->mouse.ix;
-   ev->y = edev->mouse.iy;
+   ev->x = edev->seat->ptr.ix;
+   ev->y = edev->seat->ptr.iy;
    ev->root.x = ev->x;
    ev->root.y = ev->y;
 
@@ -581,8 +591,8 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
    _device_modifiers_update(edev);
    ev->modifiers = edev->xkb.modifiers;
 
-   ev->x = edev->mouse.ix;
-   ev->y = edev->mouse.iy;
+   ev->x = edev->seat->ptr.ix;
+   ev->y = edev->seat->ptr.iy;
    ev->root.x = ev->x;
    ev->root.y = ev->y;
 
@@ -692,8 +702,8 @@ _device_handle_touch_event_send(Ecore_Drm_Evdev *edev, struct libinput_event_tou
    _device_modifiers_update(edev);
    ev->modifiers = edev->xkb.modifiers;
 
-   ev->x = edev->mouse.ix;
-   ev->y = edev->mouse.iy;
+   ev->x = edev->seat->ptr.ix;
+   ev->y = edev->seat->ptr.iy;
    ev->root.x = ev->x;
    ev->root.y = ev->y;
 
@@ -767,8 +777,8 @@ _device_handle_touch_motion_send(Ecore_Drm_Evdev *edev, struct libinput_event_to
    ev->modifiers = edev->xkb.modifiers;
    ev->modifiers = 0;
 
-   ev->x = edev->mouse.ix;
-   ev->y = edev->mouse.iy;
+   ev->x = edev->seat->ptr.ix;
+   ev->y = edev->seat->ptr.iy;
    ev->root.x = ev->x;
    ev->root.y = ev->y;
 
@@ -793,9 +803,9 @@ _device_handle_touch_down(struct libinput_device *device, struct libinput_event_
 
    if (!(edev = libinput_device_get_user_data(device))) return;
 
-   edev->mouse.ix = edev->mouse.dx =
+   edev->mouse.dx = edev->seat->ptr.ix = edev->seat->ptr.dx =
      libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width);
-   edev->mouse.iy = edev->mouse.dy =
+   edev->mouse.dy = edev->seat->ptr.iy = edev->seat->ptr.dy =
      libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height);
 
    edev->mt_slot = libinput_event_touch_get_seat_slot(event);
@@ -811,16 +821,16 @@ _device_handle_touch_motion(struct libinput_device *device, struct libinput_even
 
    if (!(edev = libinput_device_get_user_data(device))) return;
 
-   edev->mouse.dx =
+   edev->mouse.dx = edev->seat->ptr.dx =
      libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width);
-   edev->mouse.dy =
+   edev->mouse.dy = edev->seat->ptr.dy =
      libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height);
 
-   if (floor(edev->mouse.dx) == edev->mouse.ix &&
-       floor(edev->mouse.dy) == edev->mouse.iy) return;
+   if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
+       floor(edev->seat->ptr.dy) == edev->seat->ptr.iy) return;
 
-   edev->mouse.ix = edev->mouse.dx;
-   edev->mouse.iy = edev->mouse.dy;
+   edev->seat->ptr.ix = edev->seat->ptr.dx;
+   edev->seat->ptr.iy = edev->seat->ptr.dy;
 
    edev->mt_slot = libinput_event_touch_get_seat_slot(event);
 
index 2513777..33fc969 100644 (file)
@@ -166,6 +166,11 @@ struct _Ecore_Drm_Seat
    const char *name;
    Ecore_Drm_Input *input;
    Eina_List *devices;
+   struct
+     {
+        int ix, iy;
+        double dx, dy;
+     } ptr;
 };
 
 struct _Ecore_Drm_Input
@@ -207,7 +212,6 @@ struct _Ecore_Drm_Evdev
 
    struct 
      {
-        int ix, iy;
         int minx, miny, maxw, maxh;
         double dx, dy;
         unsigned int last, prev;