forked from enlightenment/efl
elput: handle double/triple click for pen events
This commit is contained in:
parent
03e23322d5
commit
140a3d668c
|
@ -793,6 +793,36 @@ _pointer_button_send(Elput_Device *edev, enum libinput_button_state state)
|
||||||
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
|
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_pointer_click_update(Elput_Pointer *ptr, unsigned int btn)
|
||||||
|
{
|
||||||
|
unsigned int current;
|
||||||
|
|
||||||
|
current = ptr->timestamp;
|
||||||
|
ptr->mouse.double_click = EINA_FALSE;
|
||||||
|
ptr->mouse.triple_click = EINA_FALSE;
|
||||||
|
|
||||||
|
if (((current - ptr->mouse.prev_time) <= ptr->mouse.threshold) &&
|
||||||
|
(btn == ptr->mouse.prev_button))
|
||||||
|
{
|
||||||
|
ptr->mouse.double_click = EINA_TRUE;
|
||||||
|
if (((current - ptr->mouse.last_time) <=
|
||||||
|
(2 * ptr->mouse.threshold)) &&
|
||||||
|
(btn == ptr->mouse.last_button))
|
||||||
|
{
|
||||||
|
ptr->mouse.triple_click = EINA_TRUE;
|
||||||
|
ptr->mouse.prev_time = 0;
|
||||||
|
ptr->mouse.last_time = 0;
|
||||||
|
current = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->mouse.last_time = ptr->mouse.prev_time;
|
||||||
|
ptr->mouse.prev_time = current;
|
||||||
|
ptr->mouse.last_button = ptr->mouse.prev_button;
|
||||||
|
ptr->mouse.prev_button = ptr->buttons;
|
||||||
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_pointer_button(struct libinput_device *idev, struct libinput_event_pointer *event)
|
_pointer_button(struct libinput_device *idev, struct libinput_event_pointer *event)
|
||||||
{
|
{
|
||||||
|
@ -825,34 +855,7 @@ _pointer_button(struct libinput_device *idev, struct libinput_event_pointer *eve
|
||||||
ptr->buttons = btn;
|
ptr->buttons = btn;
|
||||||
ptr->timestamp = libinput_event_pointer_get_time(event);
|
ptr->timestamp = libinput_event_pointer_get_time(event);
|
||||||
|
|
||||||
if (state)
|
if (state) _pointer_click_update(ptr, btn);
|
||||||
{
|
|
||||||
unsigned int current;
|
|
||||||
|
|
||||||
current = ptr->timestamp;
|
|
||||||
ptr->mouse.double_click = EINA_FALSE;
|
|
||||||
ptr->mouse.triple_click = EINA_FALSE;
|
|
||||||
|
|
||||||
if (((current - ptr->mouse.prev_time) <= ptr->mouse.threshold) &&
|
|
||||||
(btn == ptr->mouse.prev_button))
|
|
||||||
{
|
|
||||||
ptr->mouse.double_click = EINA_TRUE;
|
|
||||||
if (((current - ptr->mouse.last_time) <=
|
|
||||||
(2 * ptr->mouse.threshold)) &&
|
|
||||||
(btn == ptr->mouse.last_button))
|
|
||||||
{
|
|
||||||
ptr->mouse.triple_click = EINA_TRUE;
|
|
||||||
ptr->mouse.prev_time = 0;
|
|
||||||
ptr->mouse.last_time = 0;
|
|
||||||
current = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr->mouse.last_time = ptr->mouse.prev_time;
|
|
||||||
ptr->mouse.prev_time = current;
|
|
||||||
ptr->mouse.last_button = ptr->mouse.prev_button;
|
|
||||||
ptr->mouse.prev_button = ptr->buttons;
|
|
||||||
}
|
|
||||||
|
|
||||||
_pointer_button_send(edev, state);
|
_pointer_button_send(edev, state);
|
||||||
|
|
||||||
|
@ -1319,6 +1322,8 @@ _tablet_tool_tip(struct libinput_device *idev, struct libinput_event_tablet_tool
|
||||||
ptr->buttons = 1;
|
ptr->buttons = 1;
|
||||||
ptr->timestamp = libinput_event_tablet_tool_get_time(event);
|
ptr->timestamp = libinput_event_tablet_tool_get_time(event);
|
||||||
|
|
||||||
|
if (press[state]) _pointer_click_update(ptr, 1);
|
||||||
|
|
||||||
_pointer_button_send(dev, press[state]);
|
_pointer_button_send(dev, press[state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue