diff options
author | Chris Michael <cp.michael@samsung.com> | 2017-01-12 10:24:18 -0500 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2017-01-12 11:11:50 -0500 |
commit | 343a27232899c377397466877201f45f1ec94a10 (patch) | |
tree | 3435a1062c97de145c87595fa86eb7c062ca7a27 /src/lib/elput | |
parent | 078a4eef71a97ea869d8dfc8a8e60d90b8e42265 (diff) |
elput: Store touch timestamp and slot
This patch adds a timestamp field to the touch structure so that we
can store it and do not have to refetch the timestamp when sending
touch events.
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/elput')
-rw-r--r-- | src/lib/elput/elput_evdev.c | 33 | ||||
-rw-r--r-- | src/lib/elput/elput_private.h | 1 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c index d191f49110..6a4f1706a4 100644 --- a/src/lib/elput/elput_evdev.c +++ b/src/lib/elput/elput_evdev.c | |||
@@ -582,6 +582,8 @@ _touch_create(Elput_Seat *seat) | |||
582 | touch = calloc(1, sizeof(Elput_Touch)); | 582 | touch = calloc(1, sizeof(Elput_Touch)); |
583 | if (!touch) return NULL; | 583 | if (!touch) return NULL; |
584 | 584 | ||
585 | touch->x = -1; | ||
586 | touch->y = -1; | ||
585 | touch->seat = seat; | 587 | touch->seat = seat; |
586 | 588 | ||
587 | return touch; | 589 | return touch; |
@@ -955,7 +957,7 @@ _pointer_axis(struct libinput_device *idevice, struct libinput_event_pointer *ev | |||
955 | } | 957 | } |
956 | 958 | ||
957 | static void | 959 | static void |
958 | _touch_event_send(Elput_Device *dev, struct libinput_event_touch *event, int type) | 960 | _touch_event_send(Elput_Device *dev, int type) |
959 | { | 961 | { |
960 | Elput_Touch *touch; | 962 | Elput_Touch *touch; |
961 | Ecore_Event_Mouse_Button *ev; | 963 | Ecore_Event_Mouse_Button *ev; |
@@ -970,7 +972,7 @@ _touch_event_send(Elput_Device *dev, struct libinput_event_touch *event, int typ | |||
970 | ev->window = dev->seat->manager->window; | 972 | ev->window = dev->seat->manager->window; |
971 | ev->event_window = dev->seat->manager->window; | 973 | ev->event_window = dev->seat->manager->window; |
972 | ev->root_window = dev->seat->manager->window; | 974 | ev->root_window = dev->seat->manager->window; |
973 | ev->timestamp = libinput_event_touch_get_time(event); | 975 | ev->timestamp = touch->timestamp; |
974 | ev->same_screen = 1; | 976 | ev->same_screen = 1; |
975 | 977 | ||
976 | ev->x = touch->x; | 978 | ev->x = touch->x; |
@@ -1008,8 +1010,6 @@ _touch_down(struct libinput_device *idevice, struct libinput_event_touch *event) | |||
1008 | { | 1010 | { |
1009 | Elput_Device *dev; | 1011 | Elput_Device *dev; |
1010 | Elput_Touch *touch; | 1012 | Elput_Touch *touch; |
1011 | unsigned int timestamp; | ||
1012 | int slot; | ||
1013 | 1013 | ||
1014 | dev = libinput_device_get_user_data(idevice); | 1014 | dev = libinput_device_get_user_data(idevice); |
1015 | if (!dev) return; | 1015 | if (!dev) return; |
@@ -1017,8 +1017,8 @@ _touch_down(struct libinput_device *idevice, struct libinput_event_touch *event) | |||
1017 | touch = _evdev_touch_get(dev->seat); | 1017 | touch = _evdev_touch_get(dev->seat); |
1018 | if (!touch) return; | 1018 | if (!touch) return; |
1019 | 1019 | ||
1020 | slot = libinput_event_touch_get_seat_slot(event); | 1020 | touch->slot = libinput_event_touch_get_seat_slot(event); |
1021 | timestamp = libinput_event_touch_get_time(event); | 1021 | touch->timestamp = libinput_event_touch_get_time(event); |
1022 | 1022 | ||
1023 | touch->x = libinput_event_touch_get_x_transformed(event, dev->ow); | 1023 | touch->x = libinput_event_touch_get_x_transformed(event, dev->ow); |
1024 | touch->y = libinput_event_touch_get_y_transformed(event, dev->oh); | 1024 | touch->y = libinput_event_touch_get_y_transformed(event, dev->oh); |
@@ -1028,23 +1028,22 @@ _touch_down(struct libinput_device *idevice, struct libinput_event_touch *event) | |||
1028 | /* touch->x, touch->y, */ | 1028 | /* touch->x, touch->y, */ |
1029 | /* &touch->x, &touch->y); */ | 1029 | /* &touch->x, &touch->y); */ |
1030 | 1030 | ||
1031 | if (slot == touch->grab.id) | 1031 | if (touch->slot == touch->grab.id) |
1032 | { | 1032 | { |
1033 | touch->grab.x = touch->x; | 1033 | touch->grab.x = touch->x; |
1034 | touch->grab.y = touch->y; | 1034 | touch->grab.y = touch->y; |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | touch->slot = slot; | ||
1038 | touch->points++; | 1037 | touch->points++; |
1039 | 1038 | ||
1040 | _touch_event_send(dev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN); | 1039 | _touch_event_send(dev, ECORE_EVENT_MOUSE_BUTTON_DOWN); |
1041 | 1040 | ||
1042 | if (touch->points == 1) | 1041 | if (touch->points == 1) |
1043 | { | 1042 | { |
1044 | touch->grab.id = slot; | 1043 | touch->grab.id = touch->slot; |
1045 | touch->grab.x = touch->x; | 1044 | touch->grab.x = touch->x; |
1046 | touch->grab.y = touch->y; | 1045 | touch->grab.y = touch->y; |
1047 | touch->grab.timestamp = timestamp; | 1046 | touch->grab.timestamp = touch->timestamp; |
1048 | } | 1047 | } |
1049 | } | 1048 | } |
1050 | 1049 | ||
@@ -1062,12 +1061,15 @@ _touch_up(struct libinput_device *idevice, struct libinput_event_touch *event) | |||
1062 | 1061 | ||
1063 | touch->points--; | 1062 | touch->points--; |
1064 | touch->slot = libinput_event_touch_get_seat_slot(event); | 1063 | touch->slot = libinput_event_touch_get_seat_slot(event); |
1064 | touch->timestamp = libinput_event_touch_get_time(event); | ||
1065 | touch->x = 0; | ||
1066 | touch->y = 0; | ||
1065 | 1067 | ||
1066 | _touch_event_send(dev, event, ECORE_EVENT_MOUSE_BUTTON_UP); | 1068 | _touch_event_send(dev, ECORE_EVENT_MOUSE_BUTTON_UP); |
1067 | } | 1069 | } |
1068 | 1070 | ||
1069 | static void | 1071 | static void |
1070 | _touch_motion_send(Elput_Device *dev, struct libinput_event_touch *event) | 1072 | _touch_motion_send(Elput_Device *dev) |
1071 | { | 1073 | { |
1072 | Elput_Touch *touch; | 1074 | Elput_Touch *touch; |
1073 | Ecore_Event_Mouse_Move *ev; | 1075 | Ecore_Event_Mouse_Move *ev; |
@@ -1081,7 +1083,7 @@ _touch_motion_send(Elput_Device *dev, struct libinput_event_touch *event) | |||
1081 | ev->window = dev->seat->manager->window; | 1083 | ev->window = dev->seat->manager->window; |
1082 | ev->event_window = dev->seat->manager->window; | 1084 | ev->event_window = dev->seat->manager->window; |
1083 | ev->root_window = dev->seat->manager->window; | 1085 | ev->root_window = dev->seat->manager->window; |
1084 | ev->timestamp = libinput_event_touch_get_time(event); | 1086 | ev->timestamp = touch->timestamp; |
1085 | ev->same_screen = 1; | 1087 | ev->same_screen = 1; |
1086 | 1088 | ||
1087 | ev->x = touch->x; | 1089 | ev->x = touch->x; |
@@ -1126,8 +1128,9 @@ _touch_motion(struct libinput_device *idevice, struct libinput_event_touch *even | |||
1126 | /* &touch->x, &touch->y); */ | 1128 | /* &touch->x, &touch->y); */ |
1127 | 1129 | ||
1128 | touch->slot = libinput_event_touch_get_seat_slot(event); | 1130 | touch->slot = libinput_event_touch_get_seat_slot(event); |
1131 | touch->timestamp = libinput_event_touch_get_time(event); | ||
1129 | 1132 | ||
1130 | _touch_motion_send(dev, event); | 1133 | _touch_motion_send(dev); |
1131 | } | 1134 | } |
1132 | 1135 | ||
1133 | void | 1136 | void |
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h index 59ec76e36a..51c6f0ab07 100644 --- a/src/lib/elput/elput_private.h +++ b/src/lib/elput/elput_private.h | |||
@@ -175,6 +175,7 @@ struct _Elput_Touch | |||
175 | double x, y; | 175 | double x, y; |
176 | int slot; | 176 | int slot; |
177 | unsigned int points; | 177 | unsigned int points; |
178 | unsigned int timestamp; | ||
178 | 179 | ||
179 | struct | 180 | struct |
180 | { | 181 | { |