summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-05-26 16:34:10 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-05-26 16:27:42 -0400
commit140a3d668c88f1d1d3e2047b1434770ac5927f25 (patch)
tree7b07a8801f00b4587fe18974437541fc6c2c382e
parent03e23322d59c697ebc8b36f82693eddfc753d07d (diff)
elput: handle double/triple click for pen events
-rw-r--r--src/lib/elput/elput_evdev.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 98f8c472a9..56aa78135b 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -793,6 +793,36 @@ _pointer_button_send(Elput_Device *edev, enum libinput_button_state state)
793 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); 793 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
794} 794}
795 795
796static void
797_pointer_click_update(Elput_Pointer *ptr, unsigned int btn)
798{
799 unsigned int current;
800
801 current = ptr->timestamp;
802 ptr->mouse.double_click = EINA_FALSE;
803 ptr->mouse.triple_click = EINA_FALSE;
804
805 if (((current - ptr->mouse.prev_time) <= ptr->mouse.threshold) &&
806 (btn == ptr->mouse.prev_button))
807 {
808 ptr->mouse.double_click = EINA_TRUE;
809 if (((current - ptr->mouse.last_time) <=
810 (2 * ptr->mouse.threshold)) &&
811 (btn == ptr->mouse.last_button))
812 {
813 ptr->mouse.triple_click = EINA_TRUE;
814 ptr->mouse.prev_time = 0;
815 ptr->mouse.last_time = 0;
816 current = 0;
817 }
818 }
819
820 ptr->mouse.last_time = ptr->mouse.prev_time;
821 ptr->mouse.prev_time = current;
822 ptr->mouse.last_button = ptr->mouse.prev_button;
823 ptr->mouse.prev_button = ptr->buttons;
824}
825
796static Eina_Bool 826static Eina_Bool
797_pointer_button(struct libinput_device *idev, struct libinput_event_pointer *event) 827_pointer_button(struct libinput_device *idev, struct libinput_event_pointer *event)
798{ 828{
@@ -825,34 +855,7 @@ _pointer_button(struct libinput_device *idev, struct libinput_event_pointer *eve
825 ptr->buttons = btn; 855 ptr->buttons = btn;
826 ptr->timestamp = libinput_event_pointer_get_time(event); 856 ptr->timestamp = libinput_event_pointer_get_time(event);
827 857
828 if (state) 858 if (state) _pointer_click_update(ptr, btn);
829 {
830 unsigned int current;
831
832 current = ptr->timestamp;
833 ptr->mouse.double_click = EINA_FALSE;
834 ptr->mouse.triple_click = EINA_FALSE;
835
836 if (((current - ptr->mouse.prev_time) <= ptr->mouse.threshold) &&
837 (btn == ptr->mouse.prev_button))
838 {
839 ptr->mouse.double_click = EINA_TRUE;
840 if (((current - ptr->mouse.last_time) <=
841 (2 * ptr->mouse.threshold)) &&
842 (btn == ptr->mouse.last_button))
843 {
844 ptr->mouse.triple_click = EINA_TRUE;
845 ptr->mouse.prev_time = 0;
846 ptr->mouse.last_time = 0;
847 current = 0;
848 }
849 }
850
851 ptr->mouse.last_time = ptr->mouse.prev_time;
852 ptr->mouse.prev_time = current;
853 ptr->mouse.last_button = ptr->mouse.prev_button;
854 ptr->mouse.prev_button = ptr->buttons;
855 }
856 859
857 _pointer_button_send(edev, state); 860 _pointer_button_send(edev, state);
858 861
@@ -1319,6 +1322,8 @@ _tablet_tool_tip(struct libinput_device *idev, struct libinput_event_tablet_tool
1319 ptr->buttons = 1; 1322 ptr->buttons = 1;
1320 ptr->timestamp = libinput_event_tablet_tool_get_time(event); 1323 ptr->timestamp = libinput_event_tablet_tool_get_time(event);
1321 1324
1325 if (press[state]) _pointer_click_update(ptr, 1);
1326
1322 _pointer_button_send(dev, press[state]); 1327 _pointer_button_send(dev, press[state]);
1323} 1328}
1324 1329