From df65a16620fd5415bf0d8315d08729e6da738432 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 28 Jun 2016 09:01:38 -0400 Subject: [PATCH] ecore-wl2: Prevent duplicated mouse up events If you touch downs and ups about all of fingers, that is sufficient condition to call ecore_wl_input_ungrab(). And then one mouse up event is generated from that function. So if you set a callback about ECORE_EVENT_MOUSE_BUTTON_UP, you can watch two mouse up events are occurred. This is a port of the patch for Ecore_Wayland library (deprecated) to the newer Ecore_Wl2 library. ref D4112 @fix Signed-off-by: Chris Michael --- src/lib/ecore_wl2/ecore_wl2_input.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 7a5899f..30573ea 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -476,12 +476,13 @@ _ecore_wl2_input_grab(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, unsigned void _ecore_wl2_input_ungrab(Ecore_Wl2_Input *input) { - if ((input->grab.window) && (input->grab.button)) + if ((input->grab.window) && (input->grab.button) && (input->grab.count)) _ecore_wl2_input_mouse_up_send(input, input->grab.window, 0, input->grab.button, input->grab.timestamp); input->grab.window = NULL; input->grab.button = 0; + input->grab.count = 0; } static void @@ -590,7 +591,8 @@ _pointer_cb_button(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned if (state == WL_POINTER_BUTTON_STATE_PRESSED) { - if ((input->focus.pointer) && (!input->grab.window)) + if ((input->focus.pointer) && + (!input->grab.window) && (!input->grab.count)) { _ecore_wl2_input_grab(input, input->focus.pointer, button); input->grab.timestamp = timestamp; @@ -599,14 +601,19 @@ _pointer_cb_button(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned if (input->focus.pointer) _ecore_wl2_input_mouse_down_send(input, input->focus.pointer, 0, button, timestamp); + + input->grab.count++; } else { - if ((input->grab.window) && (input->grab.button == button)) - _ecore_wl2_input_ungrab(input); - else if (input->focus.pointer) + if (input->focus.pointer) _ecore_wl2_input_mouse_up_send(input, input->focus.pointer, 0, button, timestamp); + + if (input->grab.count) input->grab.count--; + if ((input->grab.window) && (input->grab.button == button) && + (!input->grab.count)) + _ecore_wl2_input_ungrab(input); } } @@ -990,11 +997,13 @@ _touch_cb_up(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial input->timestamp = timestamp; input->display->serial = serial; - if ((input->grab.window) && (input->grab.button == BTN_LEFT)) + _ecore_wl2_input_mouse_up_send(input, input->focus.touch, id, + BTN_LEFT, timestamp); + + if (input->grab.count) input->grab.count--; + if ((input->grab.window) && (input->grab.button == BTN_LEFT) && + (!input->grab.count)) _ecore_wl2_input_ungrab(input); - else - _ecore_wl2_input_mouse_up_send(input, input->focus.touch, id, - BTN_LEFT, timestamp); } static void -- 2.7.4