summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-07-28 16:48:38 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-07-28 16:48:38 -0500
commit33439865de327c5bac1c9a531070514e63fe3a04 (patch)
treeec870c0a41c709f722443dbc0869a51e1be66c11
parent2b16fc4278adfdf471c5ea488c08daeb96400a9a (diff)
elput: Fix synthetic relative motion events based on abs events
libinput won't actually give us this info, and logs an error instead. We can't synthesize based on pointer position due to pointer warping. So we must track abs reports and use previous abs reports to synthesize rel events.
-rw-r--r--src/lib/elput/elput_evdev.c30
-rw-r--r--src/lib/elput/elput_private.h2
2 files changed, 29 insertions, 3 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 454b4a85de..1199a09798 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -881,6 +881,23 @@ _pointer_motion_send(Elput_Device *edev)
881} 881}
882 882
883static void 883static void
884_pointer_motion_relative_fake(struct libinput_event_pointer *event, double dx, double dy)
885{
886 Elput_Event_Pointer_Motion *ev;
887
888 ev = calloc(1, sizeof(Elput_Event_Pointer_Motion));
889 EINA_SAFETY_ON_NULL_RETURN(ev);
890
891 ev->time_usec = libinput_event_pointer_get_time_usec(event);
892 ev->dx = dx;
893 ev->dy = dy;
894 ev->dx_unaccel = dx;
895 ev->dy_unaccel = dy;
896
897 ecore_event_add(ELPUT_EVENT_POINTER_MOTION, ev, NULL, NULL);
898}
899
900static void
884_pointer_motion_relative(struct libinput_event_pointer *event) 901_pointer_motion_relative(struct libinput_event_pointer *event)
885{ 902{
886 Elput_Event_Pointer_Motion *ev; 903 Elput_Event_Pointer_Motion *ev;
@@ -937,6 +954,7 @@ _pointer_motion_abs(struct libinput_device *idev, struct libinput_event_pointer
937{ 954{
938 Elput_Device *edev; 955 Elput_Device *edev;
939 Elput_Pointer *ptr; 956 Elput_Pointer *ptr;
957 double x, y;
940 958
941 edev = libinput_device_get_user_data(idev); 959 edev = libinput_device_get_user_data(idev);
942 if (!edev) return EINA_FALSE; 960 if (!edev) return EINA_FALSE;
@@ -944,16 +962,22 @@ _pointer_motion_abs(struct libinput_device *idev, struct libinput_event_pointer
944 ptr = _evdev_pointer_get(edev->seat); 962 ptr = _evdev_pointer_get(edev->seat);
945 if (!ptr) return EINA_FALSE; 963 if (!ptr) return EINA_FALSE;
946 964
947 ptr->seat->pointer.x = 965 x = edev->absx;
966 edev->absx =
948 libinput_event_pointer_get_absolute_x_transformed(event, edev->ow); 967 libinput_event_pointer_get_absolute_x_transformed(event, edev->ow);
949 ptr->seat->pointer.y = 968 ptr->seat->pointer.x = edev->absx;
969
970 y = edev->absy;
971 edev->absy =
950 libinput_event_pointer_get_absolute_y_transformed(event, edev->oh); 972 libinput_event_pointer_get_absolute_y_transformed(event, edev->oh);
973 ptr->seat->pointer.y = edev->absy;
974
951 ptr->timestamp = libinput_event_pointer_get_time(event); 975 ptr->timestamp = libinput_event_pointer_get_time(event);
952 976
953 /* TODO: these needs to run a matrix transform based on output */ 977 /* TODO: these needs to run a matrix transform based on output */
954 978
955 _pointer_motion_send(edev); 979 _pointer_motion_send(edev);
956 _pointer_motion_relative(event); 980 _pointer_motion_relative_fake(event, edev->absx - x, edev->absy - y);
957 981
958 return EINA_TRUE; 982 return EINA_TRUE;
959} 983}
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 709871c368..f5bc425182 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -231,6 +231,8 @@ struct _Elput_Device
231 231
232 uint32_t ow, oh; 232 uint32_t ow, oh;
233 233
234 double absx, absy;
235
234 const char *path; 236 const char *path;
235 const char *output_name; 237 const char *output_name;
236 struct libinput_device *device; 238 struct libinput_device *device;