From aee186b4f3fdc27b5fe6ac13238e517f4f02fe15 Mon Sep 17 00:00:00 2001 From: "jhyuni.kang" Date: Tue, 12 May 2015 08:57:03 -0400 Subject: [PATCH] ecore-wayland: Add a grab_count variable for synchronization wl_input_grab/ungrab with pointer and touch event Summary: The touch screen device generates touch events. But in some special enviroments, a first finger will be matched to a pointer event(not touch event). And other fingers (second, third, ...) will be matched touch events. In that case ecore_wl_input_ungrab() is called abnormally. A first finger pressed, _ecore_wl_input_cb_pointer_button() call ecore_wl_input_grab(). A second finger pressed, _ecore_wl_input_cb_touch_down() is called but not grab. But when a second finger is released, _ecore_wl_input_cb_touch_up() call ecore_wl_input_ungrab() So ungrab function generate two mouse up events and a first finger is released. In other case, first finger pressed -> second finger pressed -> first finger release. That case when a first finger released a second finger release event is generated. So after that application doesn't get a release event about a second finger when a second finger is really released. I think in a multitouch case, ungrab function will be called when a all finger are released. So I add a grab_count variable for count currently touched fingers. And only called a ungrab funtion all fingers are released. Test Plan: In a touch screen supported multitouch, press two or more fingers and release. And watch events generation. Reviewers: raster, devilhorns Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2481 --- src/lib/ecore_wayland/ecore_wl_input.c | 28 +++++++++++++++++------- src/lib/ecore_wayland/ecore_wl_private.h | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c index b0297e9c14..294121fd1e 100755 --- a/src/lib/ecore_wayland/ecore_wl_input.c +++ b/src/lib/ecore_wayland/ecore_wl_input.c @@ -583,7 +583,7 @@ _ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer EINA_UN if (state) { - if ((input->pointer_focus) && (!input->grab)) + if ((input->pointer_focus) && (!input->grab) && (!input->grab_count)) { ecore_wl_input_grab(input, input->pointer_focus, button); input->grab_timestamp = timestamp; @@ -592,6 +592,7 @@ _ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer EINA_UN if (input->pointer_focus) _ecore_wl_input_mouse_down_send(input, input->pointer_focus, 0, button, timestamp); + input->grab_count++; } else { @@ -599,7 +600,10 @@ _ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer EINA_UN _ecore_wl_input_mouse_up_send(input, input->pointer_focus, 0, button, timestamp); - if ((input->grab) && (input->grab_button == button) && (!state)) + input->grab_count--; + if (input->grab_count < 0) + input->grab_count = 0; + if ((input->grab) && (input->grab_button == button) && (!state) && (!input->grab_count)) ecore_wl_input_ungrab(input); } @@ -1074,16 +1078,21 @@ _ecore_wl_input_cb_touch_down(void *data, struct wl_touch *touch EINA_UNUSED, un input->sx = wl_fixed_to_int(x); input->sy = wl_fixed_to_int(y); - _ecore_wl_input_mouse_move_send(input, input->touch_focus, timestamp, id); - _ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y); - if ((input->touch_focus) && (!input->grab)) + //_ecore_wl_input_mouse_move_send(input, input->touch_focus, timestamp, id); + if (!input->grab_count) { - ecore_wl_input_grab(input, input->touch_focus, BTN_LEFT); - input->grab_timestamp = timestamp; + _ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y); + if ((input->touch_focus) && (!input->grab)) + { + ecore_wl_input_grab(input, input->touch_focus, BTN_LEFT); + input->grab_timestamp = timestamp; + } } _ecore_wl_input_mouse_down_send(input, input->touch_focus, id, BTN_LEFT, timestamp); + + input->grab_count++; } static void @@ -1100,7 +1109,10 @@ _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch EINA_UNUSED, unsi input->display->serial = serial; _ecore_wl_input_mouse_up_send(input, input->touch_focus, id, BTN_LEFT, timestamp); - if ((input->grab) && (input->grab_button == BTN_LEFT)) + input->grab_count--; + if (input->grab_count < 0) + input->grab_count = 0; + if ((input->grab) && (input->grab_button == BTN_LEFT) && (!input->grab_count)) ecore_wl_input_ungrab(input); } diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h index 77c12dbdf6..c54b157c1f 100644 --- a/src/lib/ecore_wayland/ecore_wl_private.h +++ b/src/lib/ecore_wayland/ecore_wl_private.h @@ -209,6 +209,7 @@ struct _Ecore_Wl_Input Ecore_Wl_Window *grab; unsigned int grab_button; unsigned int grab_timestamp; + unsigned int grab_count; Ecore_Wl_Dnd_Source *drag_source; Ecore_Wl_Dnd_Source *selection_source;