elput: Send touch motion before sending touch button events
authorChris Michael <cp.michael@samsung.com>
Thu, 12 Jan 2017 16:09:47 +0000 (11:09 -0500)
committerChris Michael <cp.michael@samsung.com>
Thu, 12 Jan 2017 16:11:50 +0000 (11:11 -0500)
This patch sends a touch motion event before sending of touch up/down
events. This allows some compositors (enlightenment) to update their
internal representation of where the mouse pointer is before handling
button events (as touch down/up is treated as a mouse button down/up).

Fixes T5094 for the old man ;)

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/elput/elput_evdev.c

index 6a4f170..8bbb591 100644 (file)
@@ -582,8 +582,6 @@ _touch_create(Elput_Seat *seat)
    touch = calloc(1, sizeof(Elput_Touch));
    if (!touch) return NULL;
 
-   touch->x = -1;
-   touch->y = -1;
    touch->seat = seat;
 
    return touch;
@@ -1006,6 +1004,45 @@ _touch_event_send(Elput_Device *dev, int type)
 }
 
 static void
+_touch_motion_send(Elput_Device *dev)
+{
+   Elput_Touch *touch;
+   Ecore_Event_Mouse_Move *ev;
+
+   touch = _evdev_touch_get(dev->seat);
+   if (!touch) return;
+
+   ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
+   if (!ev) return;
+
+   ev->window = dev->seat->manager->window;
+   ev->event_window = dev->seat->manager->window;
+   ev->root_window = dev->seat->manager->window;
+   ev->timestamp = touch->timestamp;
+   ev->same_screen = 1;
+
+   ev->x = touch->x;
+   ev->y = touch->y;
+   ev->root.x = touch->x;
+   ev->root.y = touch->y;
+
+   ev->modifiers = dev->seat->modifiers;
+
+   ev->multi.device = touch->slot;
+   ev->multi.radius = 1;
+   ev->multi.radius_x = 1;
+   ev->multi.radius_y = 1;
+   ev->multi.pressure = 1.0;
+   ev->multi.angle = 0.0;
+   ev->multi.x = ev->x;
+   ev->multi.y = ev->y;
+   ev->multi.root.x = ev->x;
+   ev->multi.root.y = ev->y;
+
+   ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
+}
+
+static void
 _touch_down(struct libinput_device *idevice, struct libinput_event_touch *event)
 {
    Elput_Device *dev;
@@ -1036,6 +1073,7 @@ _touch_down(struct libinput_device *idevice, struct libinput_event_touch *event)
 
    touch->points++;
 
+   _touch_motion_send(dev);
    _touch_event_send(dev, ECORE_EVENT_MOUSE_BUTTON_DOWN);
 
    if (touch->points == 1)
@@ -1062,52 +1100,12 @@ _touch_up(struct libinput_device *idevice, struct libinput_event_touch *event)
    touch->points--;
    touch->slot = libinput_event_touch_get_seat_slot(event);
    touch->timestamp = libinput_event_touch_get_time(event);
-   touch->x = 0;
-   touch->y = 0;
 
+   _touch_motion_send(dev);
    _touch_event_send(dev, ECORE_EVENT_MOUSE_BUTTON_UP);
 }
 
 static void
-_touch_motion_send(Elput_Device *dev)
-{
-   Elput_Touch *touch;
-   Ecore_Event_Mouse_Move *ev;
-
-   touch = _evdev_touch_get(dev->seat);
-   if (!touch) return;
-
-   ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
-   if (!ev) return;
-
-   ev->window = dev->seat->manager->window;
-   ev->event_window = dev->seat->manager->window;
-   ev->root_window = dev->seat->manager->window;
-   ev->timestamp = touch->timestamp;
-   ev->same_screen = 1;
-
-   ev->x = touch->x;
-   ev->y = touch->y;
-   ev->root.x = touch->x;
-   ev->root.y = touch->y;
-
-   ev->modifiers = dev->seat->modifiers;
-
-   ev->multi.device = touch->slot;
-   ev->multi.radius = 1;
-   ev->multi.radius_x = 1;
-   ev->multi.radius_y = 1;
-   ev->multi.pressure = 1.0;
-   ev->multi.angle = 0.0;
-   ev->multi.x = ev->x;
-   ev->multi.y = ev->y;
-   ev->multi.root.x = ev->x;
-   ev->multi.root.y = ev->y;
-
-   ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
-}
-
-static void
 _touch_motion(struct libinput_device *idevice, struct libinput_event_touch *event)
 {
    Elput_Device *dev;