From a0dd6ef2377db0093323a975e944b413a8175355 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Thu, 7 Apr 2016 14:29:02 +0900 Subject: [PATCH 01/16] Enable default single finger gesture - Convert single finger gesture to Back Key - This will be changed to configuration Change-Id: I779d50c9fac6293704f88f81d79b6dd47c2b3d34 --- src/Makefile.am | 3 +- src/e_mod_gesture_device.c | 164 +++++++++++++++++++++++++++++++++++++++++++++ src/e_mod_gesture_events.c | 94 ++++++++++++++------------ src/e_mod_main.c | 11 +++ src/e_mod_main.h | 26 ++++++- 5 files changed, 251 insertions(+), 47 deletions(-) create mode 100644 src/e_mod_gesture_device.c diff --git a/src/Makefile.am b/src/Makefile.am index 59ac035..563afca 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,8 @@ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH pkg_LTLIBRARIES = module.la module_la_SOURCES = e_mod_main.c \ e_mod_main.h \ - e_mod_gesture_events.c + e_mod_gesture_events.c \ + e_mod_gesture_device.c module_la_CFLAGS = @ENLIGHTENMENT_CFLAGS@ @WAYLAND_CFLAGS@ -DHAVE_WAYLAND_ONLY module_la_LDFLAGS = -module -avoid-version @WAYLAND_LIBS@ @ENLIGHTENMENT_LIBS@ diff --git a/src/e_mod_gesture_device.c b/src/e_mod_gesture_device.c new file mode 100644 index 0000000..38aa14b --- /dev/null +++ b/src/e_mod_gesture_device.c @@ -0,0 +1,164 @@ +#define E_COMP_WL +#include "e_mod_main.h" +#include +#include + +static void +_e_gesture_device_keydev_create(void) +{ + int uinp_fd = -1; + struct uinput_user_dev uinp; + int ret = 0; + + uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY); + if ( uinp_fd < 0) + { + GTWRN("Failed to open /dev/uinput: (%d)\n", uinp_fd); + return; + } + + memset(&uinp, 0, sizeof(struct uinput_user_dev)); + strncpy(uinp.name, E_GESTURE_KEYBOARD_NAME, UINPUT_MAX_NAME_SIZE); + uinp.id.version = 4; + uinp.id.bustype = BUS_USB; + + ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY); + ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN); + ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC); + + ioctl(uinp_fd, UI_SET_KEYBIT, KEY_BACK); + + ret = write(uinp_fd, &uinp, sizeof(struct uinput_user_dev)); + if (ret < 0) + { + GTWRN("Failed to write UINPUT device\n"); + close(uinp_fd); + return; + } + if (ioctl(uinp_fd, UI_DEV_CREATE)) + { + GTWRN("Unable to create UINPUT device\n"); + close(uinp_fd); + return; + } + + gesture->device.uinp_fd = uinp_fd; +} + +void +e_gesture_device_keydev_set(char *option) +{ + if (!option) + { + _e_gesture_device_keydev_create(); + gesture->device.kbd_name = strdup(E_GESTURE_KEYBOARD_NAME); + } + else if (strncmp(option, "Any", sizeof("Any"))) + { + gesture->device.kbd_name = strdup(option); + } +} + +Ecore_Device * +_e_gesture_device_ecore_device_get(char *path, unsigned int clas) +{ + const Eina_List *dev_list = NULL; + const Eina_List *l; + Ecore_Device *dev = NULL; + const char *identifier; + + if (!path) return NULL; + + dev_list = ecore_device_list(); + if (!dev_list) return NULL; + EINA_LIST_FOREACH(dev_list, l, dev) + { + if (!dev) continue; + GTINF("dev: %s\n", ecore_device_name_get(dev)); + identifier = ecore_device_identifier_get(dev); + if (!identifier) continue; + if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path))) + return dev; + } + + return NULL; +} + +Eina_Bool +e_gesture_device_add(Ecore_Event_Device_Info *ev) +{ + if (ev->clas == ECORE_DEVICE_CLASS_TOUCH) + { + gesture->device.touch_devices = eina_list_append(gesture->device.touch_devices, ev->identifier); + GTINF("%s(%s) device is touch device: add list\n", ev->name, ev->identifier); + } + if ((!gesture->device.kbd_identifier) && + (ev->clas == ECORE_DEVICE_CLASS_KEYBOARD)) + { + if (gesture->device.kbd_name) + { + if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name))) + { + GTINF("%s(%s) device is key generated device in gesture\n", ev->name, ev->identifier); + gesture->device.kbd_identifier = strdup(ev->identifier); + gesture->device.kbd_device = _e_gesture_device_ecore_device_get(gesture->device.kbd_identifier, ECORE_DEVICE_CLASS_KEYBOARD); + } + } + else + { + GTINF("%s(%s) device is key generated device in gesture\n", ev->name, ev->identifier); + gesture->device.kbd_name = strdup(ev->name); + gesture->device.kbd_identifier = strdup(ev->identifier); + gesture->device.kbd_device = _e_gesture_device_ecore_device_get(gesture->device.kbd_identifier, ECORE_DEVICE_CLASS_KEYBOARD); + } + } + return EINA_TRUE; +} + +Eina_Bool +e_gesture_device_del(Ecore_Event_Device_Info *ev) +{ + Eina_List *l, *l_next; + char *data; + + if (ev->clas == ECORE_DEVICE_CLASS_TOUCH) + { + EINA_LIST_FOREACH_SAFE(gesture->device.touch_devices, l, l_next, data) + { + if (!strncmp(data, ev->identifier, strlen(ev->identifier))) + { + GTINF("%s(%s) device is touch device: remove list\n", ev->name, ev->identifier); + gesture->device.touch_devices = eina_list_remove(gesture->device.touch_devices, data); + E_FREE(data); + } + } + } + if ((gesture->device.kbd_identifier) && + (ev->clas == ECORE_DEVICE_CLASS_KEYBOARD)) + { + if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name))) + { + GTWRN("Gesture keyboard device(%s) is disconnected. Gesture cannot create key events\n", gesture->device.kbd_name); + E_FREE(gesture->device.kbd_identifier); + E_FREE(gesture->device.kbd_name); + } + } + return EINA_TRUE; +} + +Eina_Bool +e_gesture_is_touch_device(const Ecore_Device *dev) +{ + if (ecore_device_class_get(dev) == ECORE_DEVICE_CLASS_TOUCH) + return EINA_TRUE; + + return EINA_FALSE; +} + +void +e_gesture_device_shutdown(void) +{ + E_FREE(gesture->device.kbd_identifier); + E_FREE(gesture->device.kbd_name); + gesture->device.touch_devices = eina_list_free(gesture->device.touch_devices); +} diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index 72231e5..5492964 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -24,26 +24,44 @@ _e_gesture_swipe_cancel(void) gesture->gesture_filter |= TIZEN_GESTURE_TYPE_SWIPE; } -static Eina_Bool -_e_gesture_is_touch_device(Ecore_Device *dev) +static void +_e_gesture_keyevent_free(void *data EINA_UNUSED, void *ev) { - Eina_List *l; - char *data; - const char *identifier; + Ecore_Event_Key *e = ev; - EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE); + eina_stringshare_del(e->keyname); + eina_stringshare_del(e->key); + eina_stringshare_del(e->compose); - identifier = ecore_device_identifier_get(dev); - if (!identifier) return EINA_FALSE; + E_FREE(e); +} - EINA_LIST_FOREACH(gesture->touch_devices, l, data) - { - if (!strncmp(data, identifier, strlen(identifier))) - { - return EINA_TRUE; - } - } - return EINA_FALSE; +/* Optional: This function is currently used to generate back key. + * But how about change this function to generate every key? + * _e_gesture_send_key(char *keyname, Eina_Bool pressed) + */ +static void +_e_gesture_send_back_key(Eina_Bool pressed) +{ + Ecore_Event_Key *ev; + + EINA_SAFETY_ON_NULL_RETURN(e_comp_wl->xkb.keymap); + + ev = E_NEW(Ecore_Event_Key, 1); + EINA_SAFETY_ON_NULL_RETURN(ev); + + ev->key = (char *)eina_stringshare_add("XF86Back"); + ev->keyname = (char *)eina_stringshare_add(ev->key); + ev->compose = (char *)eina_stringshare_add(ev->key); + ev->timestamp = (int)(ecore_time_get()*1000); + ev->same_screen = 1; + ev->keycode = E_GESTURE_SWIPE_BACK_KEY; + ev->dev = gesture->device.kbd_device; + + if (pressed) + ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, _e_gesture_keyevent_free, NULL); + else + ecore_event_add(ECORE_EVENT_KEY_UP, ev, _e_gesture_keyevent_free, NULL); } static void @@ -51,6 +69,7 @@ _e_gesture_send_swipe(int fingers, int x, int y, int direction, struct wl_client { enum tizen_gesture_direction dir = 0; Ecore_Event_Mouse_Button *ev_cancel; + switch (direction) { case E_GESTURE_DIRECTION_DOWN: @@ -76,46 +95,33 @@ _e_gesture_send_swipe(int fingers, int x, int y, int direction, struct wl_client ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, ev_cancel, NULL, NULL); GTINF("Send swipe gesture (direction: %d) to client: %p\n", dir, client); + + if (E_GESTURE_SWIPE_BACK_DEFAULT_ENABLE && + direction == E_GESTURE_DIRECTION_DOWN) + { + _e_gesture_send_back_key(EINA_TRUE); + _e_gesture_send_back_key(EINA_FALSE); + goto finish; + } tizen_gesture_send_swipe(res, fingers, TIZEN_GESTURE_MODE_DONE, x, y, dir); _e_gesture_swipe_cancel(); +finish: + _e_gesture_swipe_cancel(); gesture->gesture_events.recognized_gesture |= TIZEN_GESTURE_TYPE_SWIPE; } static Eina_Bool _e_gesture_process_device_add(void *event) { - Ecore_Event_Device_Info *ev = event; - - if (ev->clas == ECORE_DEVICE_CLASS_TOUCH) - { - gesture->touch_devices = eina_list_append(gesture->touch_devices, ev->identifier); - GTINF("%s(%s) device is touch device: add list\n", ev->name, ev->identifier); - } - return EINA_TRUE; + return e_gesture_device_add(event); } static Eina_Bool _e_gesture_process_device_del(void *event) { - Ecore_Event_Device_Info *ev = event; - Eina_List *l, *l_next; - char *data; - - if (ev->clas == ECORE_DEVICE_CLASS_TOUCH) - { - EINA_LIST_FOREACH_SAFE(gesture->touch_devices, l, l_next, data) - { - if (!strncmp(data, ev->identifier, strlen(ev->identifier))) - { - GTINF("%s(%s) device is touch device: remove list\n", ev->name, ev->identifier); - gesture->touch_devices = eina_list_remove(gesture->touch_devices, data); - E_FREE(data); - } - } - } - return EINA_TRUE; + return e_gesture_device_del(event); } static Eina_Bool @@ -284,7 +290,7 @@ _e_gesture_process_mouse_button_down(void *event) { return EINA_TRUE; } - if (_e_gesture_is_touch_device(ev->dev) == EINA_FALSE) + if (e_gesture_is_touch_device(ev->dev) == EINA_FALSE) { return EINA_TRUE; } @@ -327,7 +333,7 @@ _e_gesture_process_mouse_button_up(void *event) { return EINA_TRUE; } - if (_e_gesture_is_touch_device(ev->dev) == EINA_FALSE) + if (e_gesture_is_touch_device(ev->dev) == EINA_FALSE) { return EINA_TRUE; } @@ -355,7 +361,7 @@ _e_gesture_process_mouse_move(void *event) { return EINA_TRUE; } - if (_e_gesture_is_touch_device(ev->dev) == EINA_FALSE) + if (e_gesture_is_touch_device(ev->dev) == EINA_FALSE) { return EINA_TRUE; } diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 949c45e..529a02f 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -352,6 +352,16 @@ _e_gesture_init(E_Module *m) gesture->gesture_filter = E_GESTURE_TYPE_MAX; + if (E_GESTURE_SWIPE_BACK_DEFAULT_ENABLE) + { + gesture->grabbed_gesture |= TIZEN_GESTURE_TYPE_SWIPE; + gesture->gesture_events.swipes.fingers[1].enabled = EINA_TRUE; + gesture->gesture_events.swipes.fingers[1].direction[E_GESTURE_DIRECTION_DOWN].client = (void *)0x1; + gesture->gesture_events.swipes.fingers[1].direction[E_GESTURE_DIRECTION_DOWN].res = (void *)0x1; + } + + e_gesture_device_keydev_set(E_GESTURE_KEYBOARD_DEVICE); + return m; err: @@ -370,6 +380,7 @@ e_modapi_init(E_Module *m) E_API int e_modapi_shutdown(E_Module *m) { + e_gesture_device_shutdown(); return 1; } diff --git a/src/e_mod_main.h b/src/e_mod_main.h index fddbf43..6fca7ef 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -1,8 +1,8 @@ #ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H -#include #include +#include #include #define GTERR(msg, ARG...) ERR("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) @@ -13,14 +13,20 @@ #define E_GESTURE_FINGER_MAX 3 #define E_GESTURE_TYPE_MAX TIZEN_GESTURE_TYPE_SWIPE+1 #define E_GESTURE_TYPE_ALL TIZEN_GESTURE_TYPE_SWIPE +#define E_GESTURE_KEYBOARD_NAME "Gesture Keyboard" /* FIX ME: Set values in contiguration file, do not use definition */ +#define E_GESTURE_KEYBOARD_DEVICE "Any" + #define E_GESTURE_SWIPE_DONE_TIME 0.5 #define E_GESTURE_SWIPE_START_TIME 0.01 #define E_GESTURE_SWIPE_START_AREA 50 #define E_GESTURE_SWIPE_DIFF_FAIL 100 #define E_GESTURE_SWIPE_DIFF_SUCCESS 300 +/* FIX ME: Key code will be get from keymap */ #define E_GESTURE_SWIPE_COMBINE_KEY 124 +#define E_GESTURE_SWIPE_BACK_KEY 166 +#define E_GESTURE_SWIPE_BACK_DEFAULT_ENABLE EINA_TRUE #define ABS(x) ((x)>0)?(x):-(x) @@ -82,6 +88,7 @@ struct _E_Gesture_Event_Swipe E_Gesture_Direction direction; unsigned int combined_keycode; + unsigned int back_keycode; unsigned int enabled_finger; Ecore_Timer *start_timer; @@ -104,7 +111,14 @@ struct _E_Gesture Eina_List *handlers; Eina_List *grab_client_list; - Eina_List *touch_devices; + struct + { + Eina_List *touch_devices; + int uinp_fd; + char *kbd_identifier; + char *kbd_name; + Ecore_Device *kbd_device; + }device; unsigned int grabbed_gesture; E_Gesture_Event gesture_events; @@ -121,4 +135,12 @@ E_API int e_modapi_save(E_Module *m); Eina_Bool e_gesture_process_events(void *event, int type); int e_gesture_type_convert(uint32_t type); + +/* Device control */ +void e_gesture_device_shutdown(void); +Eina_Bool e_gesture_device_add(Ecore_Event_Device_Info *ev); +Eina_Bool e_gesture_device_del(Ecore_Event_Device_Info *ev); +Eina_Bool e_gesture_is_touch_device(const Ecore_Device *dev); +void e_gesture_device_keydev_set(char *option); + #endif -- 2.7.4 From 25905450a1935f007eb3a255482489466921529a Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Wed, 20 Apr 2016 14:17:39 +0900 Subject: [PATCH 02/16] Enable/disable gesture and swipe back key by config file and aux hint Change-Id: Idadfafe8ec3f44bb6b648d7dd357154368a5e6ff --- src/Makefile.am | 3 +- src/e_mod_gesture_conf.c | 61 ++++++++++++++++++++++++++++++++++++++ src/e_mod_gesture_events.c | 46 +++++++++++++++------------- src/e_mod_main.c | 74 ++++++++++++++++++++++++++++++++++++++++++---- src/e_mod_main.h | 31 +++++++++++++++++++ 5 files changed, 188 insertions(+), 27 deletions(-) create mode 100644 src/e_mod_gesture_conf.c diff --git a/src/Makefile.am b/src/Makefile.am index 563afca..75ef645 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,8 @@ pkg_LTLIBRARIES = module.la module_la_SOURCES = e_mod_main.c \ e_mod_main.h \ e_mod_gesture_events.c \ - e_mod_gesture_device.c + e_mod_gesture_device.c \ + e_mod_gesture_conf.c module_la_CFLAGS = @ENLIGHTENMENT_CFLAGS@ @WAYLAND_CFLAGS@ -DHAVE_WAYLAND_ONLY module_la_LDFLAGS = -module -avoid-version @WAYLAND_LIBS@ @ENLIGHTENMENT_LIBS@ diff --git a/src/e_mod_gesture_conf.c b/src/e_mod_gesture_conf.c new file mode 100644 index 0000000..beb0422 --- /dev/null +++ b/src/e_mod_gesture_conf.c @@ -0,0 +1,61 @@ +#define E_COMP_WL +#include "e_mod_main.h" + +void +_e_gesture_conf_value_check(E_Gesture_Config_Data* gconfig) +{ + E_Gesture_Conf_Edd *conf; + if (!gconfig->conf) gconfig->conf = E_NEW(E_Gesture_Conf_Edd, 1); + EINA_SAFETY_ON_NULL_RETURN(gconfig->conf); + + conf = gconfig->conf; + if (!conf->key_device_name) conf->key_device_name = strdup(E_GESTURE_KEYBOARD_DEVICE); + if (conf->swipe.time_done <= 0.0) conf->swipe.time_done = E_GESTURE_SWIPE_DONE_TIME; + if (conf->swipe.time_begin <= 0.0) conf->swipe.time_begin = E_GESTURE_SWIPE_START_TIME; + if (conf->swipe.area_offset <= 0) conf->swipe.area_offset = E_GESTURE_SWIPE_START_AREA; + if (conf->swipe.min_length <= 0) conf->swipe.min_length = E_GESTURE_SWIPE_DIFF_FAIL; + if (conf->swipe.max_length <= 0) conf->swipe.max_length = E_GESTURE_SWIPE_DIFF_SUCCESS; + if (conf->swipe.compose_key <= 0) conf->swipe.compose_key = E_GESTURE_SWIPE_COMBINE_KEY; + if (conf->swipe.back_key <= 0) conf->swipe.back_key = E_GESTURE_SWIPE_BACK_KEY; +} + +void +e_gesture_conf_init(E_Gesture_Config_Data *gconfig) +{ + gconfig->conf_edd = E_CONFIG_DD_NEW("Gesture_Config", E_Gesture_Conf_Edd); +#undef T +#undef D +#define T E_Gesture_Conf_Edd +#define D gconfig->conf_edd + E_CONFIG_VAL(D, T, key_device_name, STR); + E_CONFIG_VAL(D, T, swipe.time_done, DOUBLE); + E_CONFIG_VAL(D, T, swipe.time_begin, DOUBLE); + E_CONFIG_VAL(D, T, swipe.area_offset, INT); + E_CONFIG_VAL(D, T, swipe.min_length, INT); + E_CONFIG_VAL(D, T, swipe.max_length, INT); + E_CONFIG_VAL(D, T, swipe.compose_key, INT); + E_CONFIG_VAL(D, T, swipe.back_key, INT); + E_CONFIG_VAL(D, T, swipe.default_enable_back, CHAR); + +#undef T +#undef D + gconfig->conf = e_config_domain_load("module.gesture", gconfig->conf_edd); + + if (!gconfig->conf) + { + GTWRN("Failed to find module.keyrouter config file.\n"); + } + _e_gesture_conf_value_check(gconfig); +} + +void +e_gesture_conf_deinit(E_Gesture_Config_Data *gconfig) +{ + if (gconfig->conf) + { + E_FREE(gconfig->conf->key_device_name); + E_FREE(gconfig->conf); + } + E_CONFIG_DD_FREE(gconfig->conf_edd); + E_FREE(gconfig); +} diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index 5492964..b0548b8 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -44,6 +44,7 @@ static void _e_gesture_send_back_key(Eina_Bool pressed) { Ecore_Event_Key *ev; + E_Gesture_Conf_Edd *conf = gesture->config->conf; EINA_SAFETY_ON_NULL_RETURN(e_comp_wl->xkb.keymap); @@ -55,7 +56,7 @@ _e_gesture_send_back_key(Eina_Bool pressed) ev->compose = (char *)eina_stringshare_add(ev->key); ev->timestamp = (int)(ecore_time_get()*1000); ev->same_screen = 1; - ev->keycode = E_GESTURE_SWIPE_BACK_KEY; + ev->keycode = conf->swipe.back_key; ev->dev = gesture->device.kbd_device; if (pressed) @@ -69,6 +70,7 @@ _e_gesture_send_swipe(int fingers, int x, int y, int direction, struct wl_client { enum tizen_gesture_direction dir = 0; Ecore_Event_Mouse_Button *ev_cancel; + E_Gesture_Conf_Edd *conf = gesture->config->conf; switch (direction) { @@ -96,7 +98,7 @@ _e_gesture_send_swipe(int fingers, int x, int y, int direction, struct wl_client GTINF("Send swipe gesture (direction: %d) to client: %p\n", dir, client); - if (E_GESTURE_SWIPE_BACK_DEFAULT_ENABLE && + if (conf->swipe.default_enable_back && direction == E_GESTURE_DIRECTION_DOWN) { _e_gesture_send_back_key(EINA_TRUE); @@ -163,6 +165,7 @@ static void _e_gesture_process_swipe_down(Ecore_Event_Mouse_Button *ev) { E_Gesture_Event_Swipe *swipes = &gesture->gesture_events.swipes; + E_Gesture_Conf_Edd *conf = gesture->config->conf; int i; unsigned int idx = ev->multi.device+1; @@ -176,17 +179,17 @@ _e_gesture_process_swipe_down(Ecore_Event_Mouse_Button *ev) } } - if (ev->y < E_GESTURE_SWIPE_START_AREA) + if (ev->y < conf->swipe.area_offset) swipes->direction = E_GESTURE_DIRECTION_DOWN; - else if (ev->y > e_comp->h - E_GESTURE_SWIPE_START_AREA) + else if (ev->y > e_comp->h - conf->swipe.area_offset) swipes->direction = E_GESTURE_DIRECTION_UP; - else if (ev->x < E_GESTURE_SWIPE_START_AREA) + else if (ev->x < conf->swipe.area_offset) swipes->direction = E_GESTURE_DIRECTION_RIGHT; - else if (ev->x > e_comp->w - E_GESTURE_SWIPE_START_AREA) + else if (ev->x > e_comp->w - conf->swipe.area_offset) swipes->direction = E_GESTURE_DIRECTION_LEFT; if (swipes->direction != E_GESTURE_DIRECTION_DOWN && - !((swipes->combined_keycode == E_GESTURE_SWIPE_COMBINE_KEY) && swipes->direction == E_GESTURE_DIRECTION_RIGHT)) + !((swipes->combined_keycode == conf->swipe.compose_key) && swipes->direction == E_GESTURE_DIRECTION_RIGHT)) { _e_gesture_swipe_cancel(); } @@ -194,8 +197,8 @@ _e_gesture_process_swipe_down(Ecore_Event_Mouse_Button *ev) { swipes->fingers[idx].start.x = ev->x; swipes->fingers[idx].start.y = ev->y; - swipes->start_timer = ecore_timer_add(E_GESTURE_SWIPE_START_TIME, _e_gesture_timer_swipe_start, NULL); - swipes->done_timer = ecore_timer_add(E_GESTURE_SWIPE_DONE_TIME, _e_gesture_timer_swipe_done, NULL); + swipes->start_timer = ecore_timer_add(conf->swipe.time_begin, _e_gesture_timer_swipe_start, NULL); + swipes->done_timer = ecore_timer_add(conf->swipe.time_done, _e_gesture_timer_swipe_done, NULL); } } else @@ -212,6 +215,7 @@ static void _e_gesture_process_swipe_move(Ecore_Event_Mouse_Move *ev) { E_Gesture_Event_Swipe *swipes = &gesture->gesture_events.swipes; + E_Gesture_Conf_Edd *conf = gesture->config->conf; Coords diff; unsigned int idx = ev->multi.device+1; @@ -224,45 +228,45 @@ _e_gesture_process_swipe_move(Ecore_Event_Mouse_Move *ev) switch(swipes->direction) { case E_GESTURE_DIRECTION_DOWN: - if (diff.x > E_GESTURE_SWIPE_DIFF_FAIL) + if (diff.x > conf->swipe.min_length) { _e_gesture_swipe_cancel(); break; } - if (diff.y > E_GESTURE_SWIPE_DIFF_SUCCESS) + if (diff.y > conf->swipe.max_length) { _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_DOWN].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_DOWN].res); } break; case E_GESTURE_DIRECTION_LEFT: - if (diff.y > E_GESTURE_SWIPE_DIFF_FAIL) + if (diff.y > conf->swipe.min_length) { _e_gesture_swipe_cancel(); break; } - if (diff.x > E_GESTURE_SWIPE_DIFF_SUCCESS) + if (diff.x > conf->swipe.max_length) { _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_LEFT].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_LEFT].res); } break; case E_GESTURE_DIRECTION_UP: - if (diff.x > E_GESTURE_SWIPE_DIFF_FAIL) + if (diff.x > conf->swipe.min_length) { _e_gesture_swipe_cancel(); break; } - if (diff.y > E_GESTURE_SWIPE_DIFF_SUCCESS) + if (diff.y > conf->swipe.max_length) { _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_UP].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_UP].res); } break; case E_GESTURE_DIRECTION_RIGHT: - if (diff.y > E_GESTURE_SWIPE_DIFF_FAIL) + if (diff.y > conf->swipe.min_length) { _e_gesture_swipe_cancel(); break; } - if (diff.x > E_GESTURE_SWIPE_DIFF_SUCCESS) + if (diff.x > conf->swipe.max_length) { _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_RIGHT].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_RIGHT].res); } @@ -383,10 +387,11 @@ static Eina_Bool _e_gesture_process_key_down(void *event) { Ecore_Event_Key *ev = event; + E_Gesture_Conf_Edd *conf = gesture->config->conf; - if (ev->keycode == E_GESTURE_SWIPE_COMBINE_KEY) + if (ev->keycode == conf->swipe.compose_key) { - gesture->gesture_events.swipes.combined_keycode = E_GESTURE_SWIPE_COMBINE_KEY; + gesture->gesture_events.swipes.combined_keycode = conf->swipe.compose_key; } return EINA_TRUE; @@ -396,8 +401,9 @@ static Eina_Bool _e_gesture_process_key_up(void *event) { Ecore_Event_Key *ev = event; + E_Gesture_Conf_Edd *conf = gesture->config->conf; - if (ev->keycode == E_GESTURE_SWIPE_COMBINE_KEY) + if (ev->keycode == conf->swipe.compose_key) { gesture->gesture_events.swipes.combined_keycode = 0; } diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 529a02f..d5c4f88 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -5,7 +5,7 @@ E_GesturePtr gesture = NULL; E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Gesture Module of Window Manager" }; -static void *_e_gesture_init(E_Module *m); +static E_Gesture_Config_Data *_e_gesture_init(E_Module *m); static void _e_gesture_init_handlers(void); @@ -318,15 +318,51 @@ _e_gesture_event_filter(void *data, void *loop_data EINA_UNUSED, int type, void return e_gesture_process_events(event, type); } +static Eina_Bool +_e_gesture_cb_client_focus_in(void *data, int type, void *event) +{ + E_Client *ec; + E_Comp_Wl_Aux_Hint *hint; + Eina_List *l; + Eina_Bool gesture_disable = EINA_FALSE; + E_Event_Client *ev = (E_Event_Client *)event; + + EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); + ec = ev->ec; + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_PASS_ON); + EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, ECORE_CALLBACK_PASS_ON); + + if (ec->gesture_disable && gesture->enable) + { + GTINF("Disable gesture\n"); + ecore_event_filter_del(gesture->ef_handler); + gesture->ef_handler = NULL; + gesture->enable = EINA_FALSE; + } + else if (!ec->gesture_disable && !gesture->enable) + { + GTINF("enable gesture\n"); + gesture->ef_handler = ecore_event_filter_add(NULL, _e_gesture_event_filter, NULL, NULL); + gesture->enable = EINA_TRUE; + } + + return ECORE_CALLBACK_PASS_ON; +} + static void _e_gesture_init_handlers(void) { gesture->ef_handler = ecore_event_filter_add(NULL, _e_gesture_event_filter, NULL, NULL); + + gesture->handlers = eina_list_append(gesture->handlers, + ecore_event_handler_add(E_EVENT_CLIENT_FOCUS_IN, + _e_gesture_cb_client_focus_in, NULL)); } -static void * +static E_Gesture_Config_Data * _e_gesture_init(E_Module *m) { + E_Gesture_Config_Data *gconfig = NULL; gesture = E_NEW(E_Gesture, 1); if (!gesture) @@ -341,8 +377,25 @@ _e_gesture_init(E_Module *m) goto err; } - /* Add filtering mechanism */ + /* Add filtering mechanism + * FIXME: Add handlers after first gesture is grabbed + */ _e_gesture_init_handlers(); + + /* Init config */ + gconfig = E_NEW(E_Gesture_Config_Data, 1); + EINA_SAFETY_ON_NULL_GOTO(gconfig, err); + gconfig->module = m; + + e_gesture_conf_init(gconfig); + EINA_SAFETY_ON_NULL_GOTO(gconfig->conf, err); + gesture->config = gconfig; + + GTDBG("config value\n"); + GTDBG("keyboard: %s, time_done: %lf, time_begin: %lf\n", gconfig->conf->key_device_name, gconfig->conf->swipe.time_done, gconfig->conf->swipe.time_begin); + GTDBG("area_offset: %d, min_length: %d, max_length: %d\n", gconfig->conf->swipe.area_offset, gconfig->conf->swipe.min_length, gconfig->conf->swipe.max_length); + GTDBG("compose key: %d, back: %d, default: %d\n", gconfig->conf->swipe.compose_key, gconfig->conf->swipe.back_key, gconfig->conf->swipe.default_enable_back); + gesture->global = wl_global_create(e_comp_wl->wl.disp, &tizen_gesture_interface, 1, gesture, _e_gesture_cb_bind); if (!gesture->global) { @@ -352,7 +405,7 @@ _e_gesture_init(E_Module *m) gesture->gesture_filter = E_GESTURE_TYPE_MAX; - if (E_GESTURE_SWIPE_BACK_DEFAULT_ENABLE) + if (gconfig->conf->swipe.default_enable_back) { gesture->grabbed_gesture |= TIZEN_GESTURE_TYPE_SWIPE; gesture->gesture_events.swipes.fingers[1].enabled = EINA_TRUE; @@ -360,11 +413,14 @@ _e_gesture_init(E_Module *m) gesture->gesture_events.swipes.fingers[1].direction[E_GESTURE_DIRECTION_DOWN].res = (void *)0x1; } - e_gesture_device_keydev_set(E_GESTURE_KEYBOARD_DEVICE); + e_gesture_device_keydev_set(gesture->config->conf->key_device_name); + + gesture->enable = EINA_TRUE; - return m; + return gconfig; err: + if (gconfig) e_gesture_conf_deinit(gconfig); if (gesture && gesture->ef_handler) ecore_event_filter_del(gesture->ef_handler); if (gesture) E_FREE(gesture); @@ -380,6 +436,8 @@ e_modapi_init(E_Module *m) E_API int e_modapi_shutdown(E_Module *m) { + E_Gesture_Config_Data *gconfig = m->data; + e_gesture_conf_deinit(gconfig); e_gesture_device_shutdown(); return 1; } @@ -388,6 +446,10 @@ E_API int e_modapi_save(E_Module *m) { /* Save something to be kept */ + E_Gesture_Config_Data *gconfig = m->data; + e_config_domain_save("module.gesture", + gconfig->conf_edd, + gconfig->conf); return 1; } diff --git a/src/e_mod_main.h b/src/e_mod_main.h index 6fca7ef..2f552f4 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -37,6 +37,8 @@ typedef struct _E_Gesture_Event_Swipe E_Gesture_Event_Swipe; typedef struct _E_Gesture_Event_Swipe_Finger E_Gesture_Event_Swipe_Finger; typedef struct _E_Gesture_Event_Swipe_Finger_Direction E_Gesture_Event_Swipe_Finger_Direction; typedef struct _E_Gesture_Grabbed_Client E_Gesture_Grabbed_Client; +typedef struct _E_Gesture_Conf_Edd E_Gesture_Conf_Edd; +typedef struct _E_Gesture_Config_Data E_Gesture_Config_Data; typedef struct _Coords Coords; @@ -59,6 +61,29 @@ struct _Coords int x, y; }; +struct _E_Gesture_Conf_Edd +{ + char *key_device_name; + struct + { + double time_done; + double time_begin; + int area_offset; + int min_length; + int max_length; + int compose_key; + int back_key; + Eina_Bool default_enable_back; + } swipe; +}; + +struct _E_Gesture_Config_Data +{ + E_Module *module; + E_Config_DD *conf_edd; + E_Gesture_Conf_Edd *conf; +}; + struct _E_Gesture_Event_Swipe_Finger_Direction { struct wl_client *client; @@ -106,6 +131,8 @@ struct _E_Gesture_Event struct _E_Gesture { struct wl_global *global; + E_Gesture_Config_Data *config; + Eina_Bool enable; Ecore_Event_Filter *ef_handler; Eina_List *handlers; @@ -136,6 +163,10 @@ E_API int e_modapi_save(E_Module *m); Eina_Bool e_gesture_process_events(void *event, int type); int e_gesture_type_convert(uint32_t type); +/* Config */ +void e_gesture_conf_init(E_Gesture_Config_Data *gconfig); +void e_gesture_conf_deinit(E_Gesture_Config_Data *gconfig); + /* Device control */ void e_gesture_device_shutdown(void); Eina_Bool e_gesture_device_add(Ecore_Event_Device_Info *ev); -- 2.7.4 From 8167ee4493c7b0229e0895626c5a365a2d515d33 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Fri, 24 Jun 2016 15:01:41 +0900 Subject: [PATCH 03/16] Fix build warnings Change-Id: Ia4339faa2bcd83a3c4f134d4108926c0e343acce --- src/e_mod_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index d5c4f88..41999b1 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -322,9 +322,6 @@ static Eina_Bool _e_gesture_cb_client_focus_in(void *data, int type, void *event) { E_Client *ec; - E_Comp_Wl_Aux_Hint *hint; - Eina_List *l; - Eina_Bool gesture_disable = EINA_FALSE; E_Event_Client *ev = (E_Event_Client *)event; EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); -- 2.7.4 From f7e457cd58f3f563518174440628b96f562e9536 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Wed, 6 Jul 2016 16:32:31 +0900 Subject: [PATCH 04/16] Clear flags when all fingers are released Change-Id: I3e931c3cfe097722eb49adcd2aecb4f6d5276263 --- src/e_mod_gesture_events.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index b0548b8..076166e 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -303,11 +303,6 @@ _e_gesture_process_mouse_button_down(void *event) return EINA_TRUE; } - if (gesture->gesture_events.num_pressed == 1) - { - gesture->gesture_events.recognized_gesture = 0x0; - } - if (gesture->gesture_events.recognized_gesture) { return EINA_FALSE; @@ -344,6 +339,10 @@ _e_gesture_process_mouse_button_up(void *event) if (gesture->gesture_events.recognized_gesture) { + if (gesture->gesture_events.num_pressed == 0) + { + gesture->gesture_events.recognized_gesture = 0x0; + } return EINA_FALSE; } -- 2.7.4 From 405534372c50a78392258ccd7adbe0c9533c1aa6 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Mon, 28 Nov 2016 17:47:46 +0900 Subject: [PATCH 05/16] Enable/Disable the gesture module after all finger is released Change-Id: If8c9f8a3cb3fbae4a83457b304a200402a8458dc --- src/e_mod_gesture_events.c | 18 +++++++++++++++++- src/e_mod_main.c | 30 +++++++++++++++++++++++------- src/e_mod_main.h | 2 ++ 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index 076166e..6004cf0 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -326,8 +326,12 @@ _e_gesture_process_mouse_button_up(void *event) { Ecore_Event_Mouse_Button *ev = event; - gesture->gesture_events.num_pressed--; + if (gesture->gesture_events.num_pressed == 0) + { + return EINA_TRUE; + } + gesture->gesture_events.num_pressed--; if (!gesture->grabbed_gesture) { return EINA_TRUE; @@ -342,6 +346,14 @@ _e_gesture_process_mouse_button_up(void *event) if (gesture->gesture_events.num_pressed == 0) { gesture->gesture_events.recognized_gesture = 0x0; + if (gesture->enable) + { + e_gesture_event_filter_enable(EINA_TRUE); + } + else + { + e_gesture_event_filter_enable(EINA_FALSE); + } } return EINA_FALSE; } @@ -360,6 +372,10 @@ _e_gesture_process_mouse_move(void *event) { Ecore_Event_Mouse_Move *ev = event; + if (gesture->gesture_events.num_pressed == 0) + { + return EINA_TRUE; + } if (!gesture->grabbed_gesture) { return EINA_TRUE; diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 41999b1..e32d6d1 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -308,12 +308,11 @@ _e_gesture_cb_bind(struct wl_client *client, void *data, uint32_t version, uint3 wl_resource_set_implementation(resource, &_e_gesture_implementation, gesture_instance, _e_gesture_cb_destory); } - - static Eina_Bool _e_gesture_event_filter(void *data, void *loop_data EINA_UNUSED, int type, void *event) { (void) data; + if (!gesture->enable) return EINA_TRUE; return e_gesture_process_events(event, type); } @@ -331,18 +330,20 @@ _e_gesture_cb_client_focus_in(void *data, int type, void *event) if (ec->gesture_disable && gesture->enable) { - GTINF("Disable gesture\n"); - ecore_event_filter_del(gesture->ef_handler); - gesture->ef_handler = NULL; + GTINF("Gesture disabled window\n"); gesture->enable = EINA_FALSE; } else if (!ec->gesture_disable && !gesture->enable) { - GTINF("enable gesture\n"); - gesture->ef_handler = ecore_event_filter_add(NULL, _e_gesture_event_filter, NULL, NULL); + GTINF("Gesture enabled window\n"); gesture->enable = EINA_TRUE; } + if (gesture->gesture_events.num_pressed == 0) + { + e_gesture_event_filter_enable(gesture->enable); + } + return ECORE_CALLBACK_PASS_ON; } @@ -498,3 +499,18 @@ out: } } } + +void +e_gesture_event_filter_enable(Eina_Bool enabled) +{ + if (enabled && !gesture->enable) + { + GTINF("Gestures will be enabled by for now.\n"); + gesture->enable = EINA_TRUE; + } + else if (!enabled && gesture->enable) + { + GTINF("Gestures will be enabled from now.\n"); + gesture->enable = EINA_FALSE; + } +} \ No newline at end of file diff --git a/src/e_mod_main.h b/src/e_mod_main.h index 2f552f4..7d8e2d3 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -174,4 +174,6 @@ Eina_Bool e_gesture_device_del(Ecore_Event_Device_Info *ev); Eina_Bool e_gesture_is_touch_device(const Ecore_Device *dev); void e_gesture_device_keydev_set(char *option); +void e_gesture_event_filter_enable(Eina_Bool enabled); + #endif -- 2.7.4 From 4bc34fed50806392aef82cd84c0322dfb282b72b Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 28 Nov 2016 18:54:55 +0900 Subject: [PATCH 06/16] Packaging: version up to 0.1.1 Change-Id: I02d1dab7c05165f6878171142fd299f036a01fdc --- packaging/e-mod-tizen-gesture.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/e-mod-tizen-gesture.spec b/packaging/e-mod-tizen-gesture.spec index c443906..d3b41d9 100644 --- a/packaging/e-mod-tizen-gesture.spec +++ b/packaging/e-mod-tizen-gesture.spec @@ -2,7 +2,7 @@ %bcond_with wayland Name: e-mod-tizen-gesture -Version: 0.1.0 +Version: 0.1.1 Release: 1 Summary: The Enlightenment Gesture Module for Tizen URL: http://www.enlightenment.org -- 2.7.4 From 75c85ae7b5aa61e90ecf1bc26731d5deda00b8c9 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Mon, 5 Dec 2016 16:03:14 +0900 Subject: [PATCH 07/16] Do not change enable/disable directly when focus window is changed Change-Id: I6832381040591e21b02f526e494bb33c78290bde --- src/e_mod_gesture_events.c | 4 ++-- src/e_mod_main.c | 6 +++--- src/e_mod_main.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index 6004cf0..e03280d 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -346,11 +346,11 @@ _e_gesture_process_mouse_button_up(void *event) if (gesture->gesture_events.num_pressed == 0) { gesture->gesture_events.recognized_gesture = 0x0; - if (gesture->enable) + if (!gesture->enable && gesture->enabled_window) { e_gesture_event_filter_enable(EINA_TRUE); } - else + else if (gesture->enable && !gesture->enabled_window) { e_gesture_event_filter_enable(EINA_FALSE); } diff --git a/src/e_mod_main.c b/src/e_mod_main.c index e32d6d1..e0c24bf 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -331,17 +331,17 @@ _e_gesture_cb_client_focus_in(void *data, int type, void *event) if (ec->gesture_disable && gesture->enable) { GTINF("Gesture disabled window\n"); - gesture->enable = EINA_FALSE; + gesture->enabled_window = EINA_FALSE; } else if (!ec->gesture_disable && !gesture->enable) { GTINF("Gesture enabled window\n"); - gesture->enable = EINA_TRUE; + gesture->enabled_window = EINA_TRUE; } if (gesture->gesture_events.num_pressed == 0) { - e_gesture_event_filter_enable(gesture->enable); + e_gesture_event_filter_enable(gesture->enabled_window); } return ECORE_CALLBACK_PASS_ON; diff --git a/src/e_mod_main.h b/src/e_mod_main.h index 7d8e2d3..62b8d21 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -133,6 +133,7 @@ struct _E_Gesture struct wl_global *global; E_Gesture_Config_Data *config; Eina_Bool enable; + Eina_Bool enabled_window; Ecore_Event_Filter *ef_handler; Eina_List *handlers; -- 2.7.4 From 377a304b2c71efc3032f87d64972aab44dd4f1e6 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Mon, 5 Dec 2016 20:33:40 +0900 Subject: [PATCH 08/16] Modify swipe to edge_swipe Change-Id: Ie1671eecade977c40c15857685dd7002b07badaa --- src/e_mod_gesture_conf.c | 31 ++-- src/e_mod_gesture_device.c | 8 +- src/e_mod_gesture_events.c | 445 +++++++++++++++++++++++++++++++-------------- src/e_mod_main.c | 223 ++++++++++++----------- src/e_mod_main.h | 87 +++++---- 5 files changed, 498 insertions(+), 296 deletions(-) diff --git a/src/e_mod_gesture_conf.c b/src/e_mod_gesture_conf.c index beb0422..4a7fe80 100644 --- a/src/e_mod_gesture_conf.c +++ b/src/e_mod_gesture_conf.c @@ -10,13 +10,13 @@ _e_gesture_conf_value_check(E_Gesture_Config_Data* gconfig) conf = gconfig->conf; if (!conf->key_device_name) conf->key_device_name = strdup(E_GESTURE_KEYBOARD_DEVICE); - if (conf->swipe.time_done <= 0.0) conf->swipe.time_done = E_GESTURE_SWIPE_DONE_TIME; - if (conf->swipe.time_begin <= 0.0) conf->swipe.time_begin = E_GESTURE_SWIPE_START_TIME; - if (conf->swipe.area_offset <= 0) conf->swipe.area_offset = E_GESTURE_SWIPE_START_AREA; - if (conf->swipe.min_length <= 0) conf->swipe.min_length = E_GESTURE_SWIPE_DIFF_FAIL; - if (conf->swipe.max_length <= 0) conf->swipe.max_length = E_GESTURE_SWIPE_DIFF_SUCCESS; - if (conf->swipe.compose_key <= 0) conf->swipe.compose_key = E_GESTURE_SWIPE_COMBINE_KEY; - if (conf->swipe.back_key <= 0) conf->swipe.back_key = E_GESTURE_SWIPE_BACK_KEY; + if (conf->edge_swipe.time_done <= 0.0) conf->edge_swipe.time_done = E_GESTURE_EDGE_SWIPE_DONE_TIME; + if (conf->edge_swipe.time_begin <= 0.0) conf->edge_swipe.time_begin = E_GESTURE_EDGE_SWIPE_START_TIME; + if (conf->edge_swipe.area_offset <= 0) conf->edge_swipe.area_offset = E_GESTURE_EDGE_SWIPE_START_AREA; + if (conf->edge_swipe.min_length <= 0) conf->edge_swipe.min_length = E_GESTURE_EDGE_SWIPE_DIFF_FAIL; + if (conf->edge_swipe.max_length <= 0) conf->edge_swipe.max_length = E_GESTURE_EDGE_SWIPE_DIFF_SUCCESS; + if (conf->edge_swipe.compose_key <= 0) conf->edge_swipe.compose_key = E_GESTURE_EDGE_SWIPE_COMBINE_KEY; + if (conf->edge_swipe.back_key <= 0) conf->edge_swipe.back_key = E_GESTURE_EDGE_SWIPE_BACK_KEY; } void @@ -28,14 +28,15 @@ e_gesture_conf_init(E_Gesture_Config_Data *gconfig) #define T E_Gesture_Conf_Edd #define D gconfig->conf_edd E_CONFIG_VAL(D, T, key_device_name, STR); - E_CONFIG_VAL(D, T, swipe.time_done, DOUBLE); - E_CONFIG_VAL(D, T, swipe.time_begin, DOUBLE); - E_CONFIG_VAL(D, T, swipe.area_offset, INT); - E_CONFIG_VAL(D, T, swipe.min_length, INT); - E_CONFIG_VAL(D, T, swipe.max_length, INT); - E_CONFIG_VAL(D, T, swipe.compose_key, INT); - E_CONFIG_VAL(D, T, swipe.back_key, INT); - E_CONFIG_VAL(D, T, swipe.default_enable_back, CHAR); + E_CONFIG_VAL(D, T, edge_swipe.time_done, DOUBLE); + E_CONFIG_VAL(D, T, edge_swipe.time_begin, DOUBLE); + E_CONFIG_VAL(D, T, edge_swipe.area_offset, INT); + E_CONFIG_VAL(D, T, edge_swipe.min_length, INT); + E_CONFIG_VAL(D, T, edge_swipe.max_length, INT); + E_CONFIG_VAL(D, T, edge_swipe.compose_key, INT); + E_CONFIG_VAL(D, T, edge_swipe.back_key, INT); + E_CONFIG_VAL(D, T, edge_swipe.default_enable_back, CHAR); + E_CONFIG_VAL(D, T, edge_swipe.event_keep, CHAR); #undef T #undef D diff --git a/src/e_mod_gesture_device.c b/src/e_mod_gesture_device.c index 38aa14b..25b5446 100644 --- a/src/e_mod_gesture_device.c +++ b/src/e_mod_gesture_device.c @@ -84,7 +84,7 @@ _e_gesture_device_ecore_device_get(char *path, unsigned int clas) return NULL; } -Eina_Bool +E_Gesture_Event_State e_gesture_device_add(Ecore_Event_Device_Info *ev) { if (ev->clas == ECORE_DEVICE_CLASS_TOUCH) @@ -112,10 +112,10 @@ e_gesture_device_add(Ecore_Event_Device_Info *ev) gesture->device.kbd_device = _e_gesture_device_ecore_device_get(gesture->device.kbd_identifier, ECORE_DEVICE_CLASS_KEYBOARD); } } - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } -Eina_Bool +E_Gesture_Event_State e_gesture_device_del(Ecore_Event_Device_Info *ev) { Eina_List *l, *l_next; @@ -143,7 +143,7 @@ e_gesture_device_del(Ecore_Event_Device_Info *ev) E_FREE(gesture->device.kbd_name); } } - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } Eina_Bool diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index e03280d..a72ea62 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -2,26 +2,144 @@ #include "e_mod_main.h" #include +#ifdef _E_GESTURE_DEBUG_ +static char * +_e_gesture_event_type_print(int type) +{ + if (type == ECORE_EVENT_KEY_DOWN) return "KeyDown"; + else if (type == ECORE_EVENT_KEY_UP) return "KeyUp"; + else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) return "MouseDown"; + else if (type == ECORE_EVENT_MOUSE_BUTTON_UP) return "MouseUp"; + else if (type == ECORE_EVENT_MOUSE_MOVE) return "MouseMove"; + else return "Unknown"; +} + +static void +_e_gesture_event_print(void) +{ + Eina_List *l; + E_Gesture_Event_Info *data; + int c = 0; + + EINA_LIST_FOREACH(gesture->event_queue, l, data) + { + GTERR("[%d]%s event is queue\n", ++c, _e_gesture_event_type_print(data->type)); + } +} +#endif //_E_GESTURE_DEBUG_ + +static void +_e_gesture_event_queue(int type, void *event) +{ + E_Gesture_Event_Info *e_info = NULL; + e_info = E_NEW(E_Gesture_Event_Info, 1); + EINA_SAFETY_ON_NULL_RETURN(e_info); + + if (type == ECORE_EVENT_KEY_DOWN || + type == ECORE_EVENT_KEY_UP) + { + e_info->event = E_NEW(Ecore_Event_Key, 1); + e_info->type = type; + memcpy(e_info->event, event, sizeof(Ecore_Event_Key)); + } + else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN || + type == ECORE_EVENT_MOUSE_BUTTON_UP) + { + e_info->event = E_NEW(Ecore_Event_Mouse_Button, 1); + e_info->type = type; + memcpy(e_info->event, event, sizeof(Ecore_Event_Mouse_Button)); + } + else if (type == ECORE_EVENT_MOUSE_MOVE) + { + e_info->event = E_NEW(Ecore_Event_Mouse_Move, 1); + e_info->type = type; + memcpy(e_info->event, event, sizeof(Ecore_Event_Mouse_Move)); + } + else goto error; + + gesture->event_queue = eina_list_append(gesture->event_queue, e_info); + return; + +error: + if (e_info->event) E_FREE(e_info->event); + if (e_info) E_FREE(e_info); +} + +static void +_e_gesture_event_flush(void) +{ + Eina_List *l, *l_next; + E_Gesture_Event_Info *data; + + if (gesture->event_state == E_GESTURE_EVENT_STATE_IGNORE || + gesture->gesture_events.recognized_gesture) return; + + gesture->event_state = E_GESTURE_EVENT_STATE_PROPAGATE; + + EINA_LIST_FOREACH_SAFE(gesture->event_queue, l, l_next, data) + { + if (data->type == ECORE_EVENT_MOUSE_BUTTON_DOWN) + { + ecore_event_evas_mouse_button_down(NULL, ECORE_EVENT_MOUSE_BUTTON_DOWN, data->event); + } + else if (data->type == ECORE_EVENT_MOUSE_BUTTON_UP) + { + ecore_event_evas_mouse_button_up(NULL, ECORE_EVENT_MOUSE_BUTTON_UP, data->event); + } + else if (data->type == ECORE_EVENT_MOUSE_MOVE) + { + ecore_event_evas_mouse_move(NULL, ECORE_EVENT_MOUSE_MOVE, data->event); + } + else if (data->type == ECORE_EVENT_KEY_DOWN) + { + ecore_event_evas_key_down(NULL, ECORE_EVENT_KEY_DOWN, data->event); + } + else if (data->type == ECORE_EVENT_KEY_UP) + { + ecore_event_evas_key_up(NULL, ECORE_EVENT_KEY_UP, data->event); + } + E_FREE(data->event); + E_FREE(data); + gesture->event_queue = eina_list_remove_list(gesture->event_queue, l); + } +} + +static void +_e_gesture_event_drop(void) +{ + Eina_List *l, *l_next; + E_Gesture_Event_Info *data; + + gesture->event_state = E_GESTURE_EVENT_STATE_IGNORE; + + EINA_LIST_FOREACH_SAFE(gesture->event_queue, l, l_next, data) + { + E_FREE(data->event); + E_FREE(data); + gesture->event_queue = eina_list_remove_list(gesture->event_queue, l); + } +} + static void -_e_gesture_swipe_cancel(void) +_e_gesture_edge_swipe_cancel(void) { - E_Gesture_Event_Swipe *swipes = &gesture->gesture_events.swipes; + E_Gesture_Event_Edge_Swipe *edge_swipes = &gesture->gesture_events.edge_swipes; - if (swipes->start_timer) + if (edge_swipes->start_timer) { - ecore_timer_del(swipes->start_timer); - swipes->start_timer = NULL; + ecore_timer_del(edge_swipes->start_timer); + edge_swipes->start_timer = NULL; } - if (swipes->done_timer) + if (edge_swipes->done_timer) { - ecore_timer_del(swipes->done_timer); - swipes->done_timer = NULL; + ecore_timer_del(edge_swipes->done_timer); + edge_swipes->done_timer = NULL; } - swipes->enabled_finger = 0x0; - swipes->direction = E_GESTURE_DIRECTION_NONE; + edge_swipes->enabled_finger = 0x0; + edge_swipes->edge = E_GESTURE_EDGE_NONE; - gesture->gesture_filter |= TIZEN_GESTURE_TYPE_SWIPE; + gesture->gesture_filter |= TIZEN_GESTURE_TYPE_EDGE_SWIPE; } static void @@ -56,7 +174,7 @@ _e_gesture_send_back_key(Eina_Bool pressed) ev->compose = (char *)eina_stringshare_add(ev->key); ev->timestamp = (int)(ecore_time_get()*1000); ev->same_screen = 1; - ev->keycode = conf->swipe.back_key; + ev->keycode = conf->edge_swipe.back_key; ev->dev = gesture->device.kbd_device; if (pressed) @@ -66,105 +184,116 @@ _e_gesture_send_back_key(Eina_Bool pressed) } static void -_e_gesture_send_swipe(int fingers, int x, int y, int direction, struct wl_client *client, struct wl_resource *res) +_e_gesture_send_edge_swipe(int fingers, int x, int y, int edge, struct wl_client *client, struct wl_resource *res) { - enum tizen_gesture_direction dir = 0; + enum tizen_gesture_edge dir = 0; Ecore_Event_Mouse_Button *ev_cancel; E_Gesture_Conf_Edd *conf = gesture->config->conf; + E_Gesture_Event_Edge_Swipe *edge_swipes = &gesture->gesture_events.edge_swipes; - switch (direction) + switch (edge) { - case E_GESTURE_DIRECTION_DOWN: - dir = TIZEN_GESTURE_DIRECTION_DOWN; + case E_GESTURE_EDGE_TOP: + dir = TIZEN_GESTURE_EDGE_TOP; break; - case E_GESTURE_DIRECTION_LEFT: - dir = TIZEN_GESTURE_DIRECTION_LEFT; + case E_GESTURE_EDGE_LEFT: + dir = TIZEN_GESTURE_EDGE_LEFT; break; - case E_GESTURE_DIRECTION_UP: - dir = TIZEN_GESTURE_DIRECTION_UP; + case E_GESTURE_EDGE_BOTTOM: + dir = TIZEN_GESTURE_EDGE_BOTTOM; break; - case E_GESTURE_DIRECTION_RIGHT: - dir = TIZEN_GESTURE_DIRECTION_RIGHT; + case E_GESTURE_EDGE_RIGHT: + dir = TIZEN_GESTURE_EDGE_RIGHT; break; } - ev_cancel = E_NEW(Ecore_Event_Mouse_Button, 1); - EINA_SAFETY_ON_NULL_RETURN(ev_cancel); + if (edge_swipes->event_keep) + { + _e_gesture_event_drop(); + } + else + { + ev_cancel = E_NEW(Ecore_Event_Mouse_Button, 1); + EINA_SAFETY_ON_NULL_RETURN(ev_cancel); - ev_cancel->timestamp = (int)(ecore_time_get()*1000); - ev_cancel->same_screen = 1; + ev_cancel->timestamp = (int)(ecore_time_get()*1000); + ev_cancel->same_screen = 1; - ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, ev_cancel, NULL, NULL); + ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, ev_cancel, NULL, NULL); + } - GTINF("Send swipe gesture (direction: %d) to client: %p\n", dir, client); + GTINF("Send edge_swipe gesture (edge: %d) to client: %p\n", dir, client); - if (conf->swipe.default_enable_back && - direction == E_GESTURE_DIRECTION_DOWN) + if (conf->edge_swipe.default_enable_back && + edge == E_GESTURE_EDGE_TOP) { _e_gesture_send_back_key(EINA_TRUE); _e_gesture_send_back_key(EINA_FALSE); goto finish; } - tizen_gesture_send_swipe(res, fingers, TIZEN_GESTURE_MODE_DONE, x, y, dir); - _e_gesture_swipe_cancel(); + tizen_gesture_send_edge_swipe(res, fingers, TIZEN_GESTURE_MODE_DONE, x, y, dir); finish: - _e_gesture_swipe_cancel(); - gesture->gesture_events.recognized_gesture |= TIZEN_GESTURE_TYPE_SWIPE; + _e_gesture_edge_swipe_cancel(); + gesture->gesture_events.recognized_gesture |= TIZEN_GESTURE_TYPE_EDGE_SWIPE; } -static Eina_Bool +static E_Gesture_Event_State _e_gesture_process_device_add(void *event) { return e_gesture_device_add(event); } -static Eina_Bool +static E_Gesture_Event_State _e_gesture_process_device_del(void *event) { return e_gesture_device_del(event); } static Eina_Bool -_e_gesture_timer_swipe_start(void *data) +_e_gesture_timer_edge_swipe_start(void *data) { - E_Gesture_Event_Swipe *swipes = &gesture->gesture_events.swipes; + E_Gesture_Event_Edge_Swipe *edge_swipes = &gesture->gesture_events.edge_swipes; int idx = gesture->gesture_events.num_pressed; int i; - GTDBG("Swipe start timer is expired. Currently alived swipe fingers: 0x%x\n", swipes->enabled_finger); + GTDBG("Edge_Swipe start timer is expired. Currently alived edge_swipe fingers: 0x%x\n", edge_swipes->enabled_finger); for (i = E_GESTURE_FINGER_MAX; i > idx; i--) { - swipes->enabled_finger &= ~(1 << i); + edge_swipes->enabled_finger &= ~(1 << i); } - if ((swipes->direction == E_GESTURE_DIRECTION_DOWN && !swipes->fingers[idx].direction[E_GESTURE_DIRECTION_DOWN].client) || - (swipes->direction == E_GESTURE_DIRECTION_LEFT && !swipes->fingers[idx].direction[E_GESTURE_DIRECTION_LEFT].client) || - (swipes->direction == E_GESTURE_DIRECTION_UP && !swipes->fingers[idx].direction[E_GESTURE_DIRECTION_UP].client) || - (swipes->direction == E_GESTURE_DIRECTION_RIGHT && !swipes->fingers[idx].direction[E_GESTURE_DIRECTION_RIGHT].client)) + if ((edge_swipes->edge == E_GESTURE_EDGE_TOP && !edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_TOP].client) || + (edge_swipes->edge == E_GESTURE_EDGE_LEFT && !edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_LEFT].client) || + (edge_swipes->edge == E_GESTURE_EDGE_BOTTOM && !edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_BOTTOM].client) || + (edge_swipes->edge == E_GESTURE_EDGE_RIGHT && !edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_RIGHT].client)) { - _e_gesture_swipe_cancel(); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); } return ECORE_CALLBACK_CANCEL; } static Eina_Bool -_e_gesture_timer_swipe_done(void *data) +_e_gesture_timer_edge_swipe_done(void *data) { - E_Gesture_Event_Swipe *swipes = &gesture->gesture_events.swipes; + E_Gesture_Event_Edge_Swipe *edge_swipes = &gesture->gesture_events.edge_swipes; - GTDBG("Swipe done timer is expired. Currently alived swipe fingers: 0x%x\n", swipes->enabled_finger); + GTDBG("Edge_Swipe done timer is expired. Currently alived edge_swipe fingers: 0x%x\n", edge_swipes->enabled_finger); - _e_gesture_swipe_cancel(); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); return ECORE_CALLBACK_CANCEL; } static void -_e_gesture_process_swipe_down(Ecore_Event_Mouse_Button *ev) +_e_gesture_process_edge_swipe_down(Ecore_Event_Mouse_Button *ev) { - E_Gesture_Event_Swipe *swipes = &gesture->gesture_events.swipes; + E_Gesture_Event_Edge_Swipe *edge_swipes = &gesture->gesture_events.edge_swipes; E_Gesture_Conf_Edd *conf = gesture->config->conf; int i; unsigned int idx = ev->multi.device+1; @@ -173,117 +302,129 @@ _e_gesture_process_swipe_down(Ecore_Event_Mouse_Button *ev) { for (i = 0; i < E_GESTURE_FINGER_MAX+1; i++) { - if (swipes->fingers[i].enabled) + if (edge_swipes->fingers[i].enabled) { - swipes->enabled_finger |= (1 << i); + edge_swipes->enabled_finger |= (1 << i); } } - if (ev->y < conf->swipe.area_offset) - swipes->direction = E_GESTURE_DIRECTION_DOWN; - else if (ev->y > e_comp->h - conf->swipe.area_offset) - swipes->direction = E_GESTURE_DIRECTION_UP; - else if (ev->x < conf->swipe.area_offset) - swipes->direction = E_GESTURE_DIRECTION_RIGHT; - else if (ev->x > e_comp->w - conf->swipe.area_offset) - swipes->direction = E_GESTURE_DIRECTION_LEFT; - - if (swipes->direction != E_GESTURE_DIRECTION_DOWN && - !((swipes->combined_keycode == conf->swipe.compose_key) && swipes->direction == E_GESTURE_DIRECTION_RIGHT)) - { - _e_gesture_swipe_cancel(); - } + if (ev->y < conf->edge_swipe.area_offset) + edge_swipes->edge = E_GESTURE_EDGE_TOP; + else if (ev->y > e_comp->h - conf->edge_swipe.area_offset) + edge_swipes->edge = E_GESTURE_EDGE_BOTTOM; + else if (ev->x < conf->edge_swipe.area_offset) + edge_swipes->edge = E_GESTURE_EDGE_RIGHT; + else if (ev->x > e_comp->w - conf->edge_swipe.area_offset) + edge_swipes->edge = E_GESTURE_EDGE_LEFT; else { - swipes->fingers[idx].start.x = ev->x; - swipes->fingers[idx].start.y = ev->y; - swipes->start_timer = ecore_timer_add(conf->swipe.time_begin, _e_gesture_timer_swipe_start, NULL); - swipes->done_timer = ecore_timer_add(conf->swipe.time_done, _e_gesture_timer_swipe_done, NULL); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); } + + edge_swipes->fingers[idx].start.x = ev->x; + edge_swipes->fingers[idx].start.y = ev->y; + edge_swipes->start_timer = ecore_timer_add(conf->edge_swipe.time_begin, _e_gesture_timer_edge_swipe_start, NULL); + edge_swipes->done_timer = ecore_timer_add(conf->edge_swipe.time_done, _e_gesture_timer_edge_swipe_done, NULL); } else { - swipes->enabled_finger &= ~(1 << (gesture->gesture_events.num_pressed - 1)); - if (swipes->start_timer == NULL) + edge_swipes->enabled_finger &= ~(1 << (gesture->gesture_events.num_pressed - 1)); + if (edge_swipes->start_timer == NULL) { - _e_gesture_swipe_cancel(); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); } } } static void -_e_gesture_process_swipe_move(Ecore_Event_Mouse_Move *ev) +_e_gesture_process_edge_swipe_move(Ecore_Event_Mouse_Move *ev) { - E_Gesture_Event_Swipe *swipes = &gesture->gesture_events.swipes; + E_Gesture_Event_Edge_Swipe *edge_swipes = &gesture->gesture_events.edge_swipes; E_Gesture_Conf_Edd *conf = gesture->config->conf; Coords diff; unsigned int idx = ev->multi.device+1; - if (!(swipes->enabled_finger & (1 << idx))) + if (!(edge_swipes->enabled_finger & (1 << idx))) return; - diff.x = ABS(swipes->fingers[idx].start.x - ev->x); - diff.y = ABS(swipes->fingers[idx].start.y - ev->y); + diff.x = ABS(edge_swipes->fingers[idx].start.x - ev->x); + diff.y = ABS(edge_swipes->fingers[idx].start.y - ev->y); - switch(swipes->direction) + switch(edge_swipes->edge) { - case E_GESTURE_DIRECTION_DOWN: - if (diff.x > conf->swipe.min_length) + case E_GESTURE_EDGE_TOP: + if (diff.x > conf->edge_swipe.min_length) { - _e_gesture_swipe_cancel(); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); break; } - if (diff.y > conf->swipe.max_length) + if (diff.y > conf->edge_swipe.max_length) { - _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_DOWN].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_DOWN].res); + _e_gesture_send_edge_swipe(idx, edge_swipes->fingers[idx].start.x, edge_swipes->fingers[idx].start.y, edge_swipes->edge, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_TOP].client, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_TOP].res); } break; - case E_GESTURE_DIRECTION_LEFT: - if (diff.y > conf->swipe.min_length) + case E_GESTURE_EDGE_LEFT: + if (diff.y > conf->edge_swipe.min_length) { - _e_gesture_swipe_cancel(); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); break; } - if (diff.x > conf->swipe.max_length) + if (diff.x > conf->edge_swipe.max_length) { - _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_LEFT].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_LEFT].res); + _e_gesture_send_edge_swipe(idx, edge_swipes->fingers[idx].start.x, edge_swipes->fingers[idx].start.y, edge_swipes->edge, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_LEFT].client, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_LEFT].res); } break; - case E_GESTURE_DIRECTION_UP: - if (diff.x > conf->swipe.min_length) + case E_GESTURE_EDGE_BOTTOM: + if (diff.x > conf->edge_swipe.min_length) { - _e_gesture_swipe_cancel(); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); break; } - if (diff.y > conf->swipe.max_length) + if (diff.y > conf->edge_swipe.max_length) { - _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_UP].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_UP].res); + _e_gesture_send_edge_swipe(idx, edge_swipes->fingers[idx].start.x, edge_swipes->fingers[idx].start.y, edge_swipes->edge, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_BOTTOM].client, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_BOTTOM].res); } break; - case E_GESTURE_DIRECTION_RIGHT: - if (diff.y > conf->swipe.min_length) + case E_GESTURE_EDGE_RIGHT: + if (diff.y > conf->edge_swipe.min_length) { - _e_gesture_swipe_cancel(); + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); break; } - if (diff.x > conf->swipe.max_length) + if (diff.x > conf->edge_swipe.max_length) { - _e_gesture_send_swipe(idx, swipes->fingers[idx].start.x, swipes->fingers[idx].start.y, swipes->direction, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_RIGHT].client, swipes->fingers[idx].direction[E_GESTURE_DIRECTION_RIGHT].res); + _e_gesture_send_edge_swipe(idx, edge_swipes->fingers[idx].start.x, edge_swipes->fingers[idx].start.y, edge_swipes->edge, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_RIGHT].client, edge_swipes->fingers[idx].edge[E_GESTURE_EDGE_RIGHT].res); } break; default: - GTWRN("Invalid direction(%d)\n", swipes->direction); + GTWRN("Invalid edge(%d)\n", edge_swipes->edge); break; } } static void -_e_gesture_process_swipe_up(Ecore_Event_Mouse_Button *ev) +_e_gesture_process_edge_swipe_up(Ecore_Event_Mouse_Button *ev) { - _e_gesture_swipe_cancel(); + E_Gesture_Event_Edge_Swipe *edge_swipes = &gesture->gesture_events.edge_swipes; + + if (edge_swipes->event_keep) + _e_gesture_event_flush(); + _e_gesture_edge_swipe_cancel(); } -static Eina_Bool +static E_Gesture_Event_State _e_gesture_process_mouse_button_down(void *event) { Ecore_Event_Mouse_Button *ev = event; @@ -292,36 +433,39 @@ _e_gesture_process_mouse_button_down(void *event) if (!gesture->grabbed_gesture) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } if (e_gesture_is_touch_device(ev->dev) == EINA_FALSE) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } if (ev->multi.device > E_GESTURE_FINGER_MAX) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } if (gesture->gesture_events.recognized_gesture) { - return EINA_FALSE; + return E_GESTURE_EVENT_STATE_IGNORE; } if (gesture->gesture_events.num_pressed == 1) { - gesture->gesture_filter = E_GESTURE_TYPE_ALL & ~gesture->grabbed_gesture; + if (gesture->gesture_filter == E_GESTURE_TYPE_ALL) + { + gesture->event_state = E_GESTURE_EVENT_STATE_PROPAGATE; + } } - if (!(gesture->gesture_filter & TIZEN_GESTURE_TYPE_SWIPE)) + if (!(gesture->gesture_filter & TIZEN_GESTURE_TYPE_EDGE_SWIPE)) { - _e_gesture_process_swipe_down(ev); + _e_gesture_process_edge_swipe_down(ev); } - return EINA_TRUE; + return gesture->event_state; } -static Eina_Bool +static E_Gesture_Event_State _e_gesture_process_mouse_button_up(void *event) { Ecore_Event_Mouse_Button *ev = event; @@ -334,11 +478,11 @@ _e_gesture_process_mouse_button_up(void *event) gesture->gesture_events.num_pressed--; if (!gesture->grabbed_gesture) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } if (e_gesture_is_touch_device(ev->dev) == EINA_FALSE) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } if (gesture->gesture_events.recognized_gesture) @@ -355,19 +499,19 @@ _e_gesture_process_mouse_button_up(void *event) e_gesture_event_filter_enable(EINA_FALSE); } } - return EINA_FALSE; + return E_GESTURE_EVENT_STATE_IGNORE; } - if (!(gesture->gesture_filter & TIZEN_GESTURE_TYPE_SWIPE)) + if (!(gesture->gesture_filter & TIZEN_GESTURE_TYPE_EDGE_SWIPE)) { - _e_gesture_process_swipe_up(ev); + _e_gesture_process_edge_swipe_up(ev); } - return EINA_TRUE; + return gesture->event_state; } -static Eina_Bool +static E_Gesture_Event_State _e_gesture_process_mouse_move(void *event) { Ecore_Event_Mouse_Move *ev = event; @@ -378,59 +522,60 @@ _e_gesture_process_mouse_move(void *event) } if (!gesture->grabbed_gesture) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } if (e_gesture_is_touch_device(ev->dev) == EINA_FALSE) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } if (gesture->gesture_events.recognized_gesture) { - return EINA_FALSE; + return E_GESTURE_EVENT_STATE_IGNORE; } - if (!(gesture->gesture_filter & TIZEN_GESTURE_TYPE_SWIPE)) + if (!(gesture->gesture_filter & TIZEN_GESTURE_TYPE_EDGE_SWIPE)) { - _e_gesture_process_swipe_move(ev); + _e_gesture_process_edge_swipe_move(ev); } - return EINA_TRUE; + return gesture->event_state; } -static Eina_Bool +static E_Gesture_Event_State _e_gesture_process_key_down(void *event) { Ecore_Event_Key *ev = event; E_Gesture_Conf_Edd *conf = gesture->config->conf; - if (ev->keycode == conf->swipe.compose_key) + if (ev->keycode == conf->edge_swipe.compose_key) { - gesture->gesture_events.swipes.combined_keycode = conf->swipe.compose_key; + gesture->gesture_events.edge_swipes.combined_keycode = conf->edge_swipe.compose_key; } - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } -static Eina_Bool +static E_Gesture_Event_State _e_gesture_process_key_up(void *event) { Ecore_Event_Key *ev = event; E_Gesture_Conf_Edd *conf = gesture->config->conf; - if (ev->keycode == conf->swipe.compose_key) + if (ev->keycode == conf->edge_swipe.compose_key) { - gesture->gesture_events.swipes.combined_keycode = 0; + gesture->gesture_events.edge_swipes.combined_keycode = 0; } - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } /* Function for checking the existing grab for a key and sending key event(s) */ Eina_Bool e_gesture_process_events(void *event, int type) { - Eina_Bool res = EINA_TRUE; + E_Gesture_Event_State res = E_GESTURE_EVENT_STATE_PROPAGATE; + Eina_Bool ret = EINA_TRUE; if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) res = _e_gesture_process_mouse_button_down(event); @@ -446,6 +591,32 @@ e_gesture_process_events(void *event, int type) res = _e_gesture_process_device_add(event); else if (type == ECORE_EVENT_DEVICE_DEL) res = _e_gesture_process_device_del(event); + else return ret; + + switch (res) + { + case E_GESTURE_EVENT_STATE_PROPAGATE: + ret = EINA_TRUE; + break; + case E_GESTURE_EVENT_STATE_KEEP: + _e_gesture_event_queue(type, event); + ret = EINA_FALSE; + break; + case E_GESTURE_EVENT_STATE_IGNORE: + ret = EINA_FALSE; + break; + default: + return ret; + } + + if (gesture->gesture_events.num_pressed == 0&& + type == ECORE_EVENT_MOUSE_BUTTON_UP) + { + if ((gesture->grabbed_gesture & TIZEN_GESTURE_TYPE_EDGE_SWIPE) && + gesture->gesture_events.edge_swipes.event_keep) + gesture->event_state = E_GESTURE_EVENT_STATE_KEEP; + gesture->gesture_filter = E_GESTURE_TYPE_ALL & ~gesture->grabbed_gesture; + } - return res; + return ret; } diff --git a/src/e_mod_main.c b/src/e_mod_main.c index e0c24bf..95035cc 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -12,21 +12,21 @@ static void _e_gesture_init_handlers(void); static void _e_gesture_wl_client_cb_destroy(struct wl_listener *l, void *data); static void -_e_gesture_swipe_set_client_to_list(struct wl_client *client, E_Gesture_Event_Swipe_Finger *fingers, unsigned int direction) +_e_gesture_edge_swipe_set_client_to_list(struct wl_client *client, E_Gesture_Event_Edge_Swipe_Finger *fingers, unsigned int edge) { - if (direction & TIZEN_GESTURE_DIRECTION_DOWN) - fingers->direction[E_GESTURE_DIRECTION_DOWN].client = client; - if (direction & TIZEN_GESTURE_DIRECTION_LEFT) - fingers->direction[E_GESTURE_DIRECTION_LEFT].client = client; - if (direction & TIZEN_GESTURE_DIRECTION_UP) - fingers->direction[E_GESTURE_DIRECTION_UP].client = client; - if (direction & TIZEN_GESTURE_DIRECTION_RIGHT) - fingers->direction[E_GESTURE_DIRECTION_RIGHT].client = client; + if (edge & TIZEN_GESTURE_EDGE_TOP) + fingers->edge[E_GESTURE_EDGE_TOP].client = client; + if (edge & TIZEN_GESTURE_EDGE_RIGHT) + fingers->edge[E_GESTURE_EDGE_RIGHT].client = client; + if (edge & TIZEN_GESTURE_EDGE_BOTTOM) + fingers->edge[E_GESTURE_EDGE_BOTTOM].client = client; + if (edge & TIZEN_GESTURE_EDGE_LEFT) + fingers->edge[E_GESTURE_EDGE_LEFT].client = client; } /* Function for registering wl_client destroy listener */ int -e_gesture_add_client_destroy_listener(struct wl_client *client, int mode EINA_UNUSED, int num_of_fingers, unsigned int direction) +e_gesture_add_client_destroy_listener(struct wl_client *client, int mode EINA_UNUSED, int fingers, unsigned int edge) { struct wl_listener *destroy_listener = NULL; Eina_List *l; @@ -36,7 +36,7 @@ e_gesture_add_client_destroy_listener(struct wl_client *client, int mode EINA_UN { if (data->client == client) { - _e_gesture_swipe_set_client_to_list(client, &data->swipe_fingers[num_of_fingers], direction); + _e_gesture_edge_swipe_set_client_to_list(client, &data->edge_swipe_fingers[fingers], edge); return TIZEN_GESTURE_ERROR_NONE; } @@ -60,7 +60,7 @@ e_gesture_add_client_destroy_listener(struct wl_client *client, int mode EINA_UN wl_client_add_destroy_listener(client, destroy_listener); grabbed_client->client = client; grabbed_client->destroy_listener = destroy_listener; - _e_gesture_swipe_set_client_to_list(client, &grabbed_client->swipe_fingers[num_of_fingers], direction); + _e_gesture_edge_swipe_set_client_to_list(client, &grabbed_client->edge_swipe_fingers[fingers], edge); gesture->grab_client_list = eina_list_append(gesture->grab_client_list, grabbed_client); @@ -68,7 +68,7 @@ e_gesture_add_client_destroy_listener(struct wl_client *client, int mode EINA_UN } static void -_e_gesture_remove_client_destroy_listener(struct wl_client *client, unsigned int num_of_fingers, unsigned int direction) +_e_gesture_remove_client_destroy_listener(struct wl_client *client, unsigned int fingers, unsigned int edge) { Eina_List *l, *l_next; E_Gesture_Grabbed_Client *data; @@ -78,14 +78,14 @@ _e_gesture_remove_client_destroy_listener(struct wl_client *client, unsigned int { if (data->client == client) { - _e_gesture_swipe_set_client_to_list(NULL, &data->swipe_fingers[num_of_fingers], direction); + _e_gesture_edge_swipe_set_client_to_list(NULL, &data->edge_swipe_fingers[fingers], edge); for (i = 0; i < E_GESTURE_FINGER_MAX+1; i++) { - if (data->swipe_fingers[i].direction[E_GESTURE_DIRECTION_DOWN].client || - data->swipe_fingers[i].direction[E_GESTURE_DIRECTION_LEFT].client || - data->swipe_fingers[i].direction[E_GESTURE_DIRECTION_UP].client || - data->swipe_fingers[i].direction[E_GESTURE_DIRECTION_RIGHT].client) + if (data->edge_swipe_fingers[i].edge[E_GESTURE_EDGE_TOP].client || + data->edge_swipe_fingers[i].edge[E_GESTURE_EDGE_RIGHT].client || + data->edge_swipe_fingers[i].edge[E_GESTURE_EDGE_BOTTOM].client || + data->edge_swipe_fingers[i].edge[E_GESTURE_EDGE_LEFT].client) { return; } @@ -99,185 +99,187 @@ _e_gesture_remove_client_destroy_listener(struct wl_client *client, unsigned int } static void -_e_gesture_cb_grab_swipe(struct wl_client *client, +_e_gesture_cb_grab_edge_swipe(struct wl_client *client, struct wl_resource *resource, - uint32_t num_of_fingers, uint32_t direction) + uint32_t fingers, uint32_t edge) { E_Gesture_Event *gev; - unsigned int grabbed_direction = 0x0; + unsigned int grabbed_edge = 0x0; - GTINF("client %p is request grab gesture, fingers: %d, direction: 0x%x\n", client, num_of_fingers, direction); - if (num_of_fingers > E_GESTURE_FINGER_MAX) + GTINF("client %p is request grab gesture, fingers: %d, edge: 0x%x\n", client, fingers, edge); + if (fingers > E_GESTURE_FINGER_MAX) { - GTWRN("Do not support %d fingers (max: %d)\n", num_of_fingers, E_GESTURE_FINGER_MAX); - tizen_gesture_send_grab_swipe_notify(resource, num_of_fingers, direction, TIZEN_GESTURE_ERROR_INVALID_DATA); + GTWRN("Do not support %d fingers (max: %d)\n", fingers, E_GESTURE_FINGER_MAX); + tizen_gesture_send_grab_edge_swipe_notify(resource, fingers, edge, TIZEN_GESTURE_ERROR_INVALID_DATA); goto out; } gev = &gesture->gesture_events; - if (direction & TIZEN_GESTURE_DIRECTION_DOWN) + if (edge & TIZEN_GESTURE_EDGE_TOP) { - if (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_DOWN].client) + if (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_TOP].client) { - grabbed_direction |= TIZEN_GESTURE_DIRECTION_DOWN; + grabbed_edge |= TIZEN_GESTURE_EDGE_TOP; } else { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_DOWN].client = client; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_DOWN].res = resource; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_TOP].client = client; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_TOP].res = resource; } } - if (direction & TIZEN_GESTURE_DIRECTION_LEFT) + if (edge & TIZEN_GESTURE_EDGE_RIGHT) { - if (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_LEFT].client) + if (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_RIGHT].client) { - grabbed_direction |= TIZEN_GESTURE_DIRECTION_LEFT; + grabbed_edge |= TIZEN_GESTURE_EDGE_RIGHT; } else { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_LEFT].client = client; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_LEFT].res = resource; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_RIGHT].client = client; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_RIGHT].res = resource; } } - if (direction & TIZEN_GESTURE_DIRECTION_UP) + if (edge & TIZEN_GESTURE_EDGE_BOTTOM) { - if (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_UP].client) + if (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_BOTTOM].client) { - grabbed_direction |= TIZEN_GESTURE_DIRECTION_UP; + grabbed_edge |= TIZEN_GESTURE_EDGE_BOTTOM; } else { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_UP].client = client; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_UP].res = resource; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_BOTTOM].client = client; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_BOTTOM].res = resource; } } - if (direction & TIZEN_GESTURE_DIRECTION_RIGHT) + if (edge & TIZEN_GESTURE_EDGE_LEFT) { - if (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_RIGHT].client) + if (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_LEFT].client) { - grabbed_direction |= TIZEN_GESTURE_DIRECTION_RIGHT; + grabbed_edge |= TIZEN_GESTURE_EDGE_LEFT; } else { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_RIGHT].client = client; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_RIGHT].res = resource; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_LEFT].client = client; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_LEFT].res = resource; } } - if (grabbed_direction) - tizen_gesture_send_grab_swipe_notify(resource, num_of_fingers, grabbed_direction, TIZEN_GESTURE_ERROR_GRABBED_ALREADY); + if (grabbed_edge) + tizen_gesture_send_grab_edge_swipe_notify(resource, fingers, grabbed_edge, TIZEN_GESTURE_ERROR_GRABBED_ALREADY); - e_gesture_add_client_destroy_listener(client, TIZEN_GESTURE_TYPE_SWIPE, num_of_fingers, direction & ~grabbed_direction); - gesture->grabbed_gesture |= TIZEN_GESTURE_TYPE_SWIPE; - gev->swipes.fingers[num_of_fingers].enabled = EINA_TRUE; + e_gesture_add_client_destroy_listener(client, TIZEN_GESTURE_TYPE_EDGE_SWIPE, fingers, edge & ~grabbed_edge); + gesture->grabbed_gesture |= TIZEN_GESTURE_TYPE_EDGE_SWIPE; + gev->edge_swipes.fingers[fingers].enabled = EINA_TRUE; + if (gev->edge_swipes.event_keep) gesture->event_state = E_GESTURE_EVENT_STATE_KEEP; - if (!grabbed_direction) - tizen_gesture_send_grab_swipe_notify(resource, num_of_fingers, direction, TIZEN_GESTURE_ERROR_NONE); + if (!grabbed_edge) + tizen_gesture_send_grab_edge_swipe_notify(resource, fingers, edge, TIZEN_GESTURE_ERROR_NONE); out: return; } static void -_e_gesture_cb_ungrab_swipe(struct wl_client *client, +_e_gesture_cb_ungrab_edge_swipe(struct wl_client *client, struct wl_resource *resouce, - uint32_t num_of_fingers, uint32_t direction) + uint32_t fingers, uint32_t edge) { int i, j; E_Gesture_Event *gev; - unsigned int ungrabbed_direction = 0x0; + unsigned int ungrabbed_edge = 0x0; int ret = TIZEN_GESTURE_ERROR_NONE; - GTINF("client %p is request ungrab swipe gesture, fingers: %d, direction: 0x%x, client: %p\n", client, num_of_fingers, direction, gesture->gesture_events.swipes.fingers[0].direction[3].client); + GTINF("client %p is request ungrab edge swipe gesture, fingers: %d, edge: 0x%x, client: %p\n", client, fingers, edge, gesture->gesture_events.edge_swipes.fingers[0].edge[3].client); - if (num_of_fingers > E_GESTURE_FINGER_MAX) + if (fingers > E_GESTURE_FINGER_MAX) { - GTWRN("Do not support %d fingers (max: %d)\n", num_of_fingers, E_GESTURE_FINGER_MAX); + GTWRN("Do not support %d fingers (max: %d)\n", fingers, E_GESTURE_FINGER_MAX); ret = TIZEN_GESTURE_ERROR_INVALID_DATA; goto finish; } gev = &gesture->gesture_events; - if (direction & TIZEN_GESTURE_DIRECTION_DOWN) + if (edge & TIZEN_GESTURE_EDGE_TOP) { - if ((gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_DOWN].client) && - (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_DOWN].client == client)) + if ((gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_TOP].client) && + (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_TOP].client == client)) { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_DOWN].client = NULL; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_DOWN].res = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_TOP].client = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_TOP].res = NULL; } else { - ungrabbed_direction |= TIZEN_GESTURE_DIRECTION_DOWN; + ungrabbed_edge |= TIZEN_GESTURE_EDGE_TOP; } } - if (direction & TIZEN_GESTURE_DIRECTION_LEFT) + if (edge & TIZEN_GESTURE_EDGE_RIGHT) { - if ((gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_LEFT].client) && - (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_LEFT].client == client)) + if ((gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_RIGHT].client) && + (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_RIGHT].client == client)) { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_LEFT].client = NULL; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_LEFT].res = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_RIGHT].client = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_RIGHT].res = NULL; } else { - ungrabbed_direction |= TIZEN_GESTURE_DIRECTION_LEFT; + ungrabbed_edge |= TIZEN_GESTURE_EDGE_RIGHT; } } - if (direction & TIZEN_GESTURE_DIRECTION_UP) + if (edge & TIZEN_GESTURE_EDGE_BOTTOM) { - if ((gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_UP].client) && - (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_UP].client == client)) + if ((gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_BOTTOM].client) && + (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_BOTTOM].client == client)) { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_UP].client = NULL; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_UP].res = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_BOTTOM].client = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_BOTTOM].res = NULL; } else { - ungrabbed_direction |= TIZEN_GESTURE_DIRECTION_UP; + ungrabbed_edge |= TIZEN_GESTURE_EDGE_BOTTOM; } } - if (direction & TIZEN_GESTURE_DIRECTION_RIGHT) + if (edge & TIZEN_GESTURE_EDGE_LEFT) { - if ((gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_RIGHT].client) && - (gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_RIGHT].client == client)) + if ((gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_LEFT].client) && + (gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_LEFT].client == client)) { - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_RIGHT].client = NULL; - gev->swipes.fingers[num_of_fingers].direction[E_GESTURE_DIRECTION_RIGHT].res = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_LEFT].client = NULL; + gev->edge_swipes.fingers[fingers].edge[E_GESTURE_EDGE_LEFT].res = NULL; } else { - ungrabbed_direction |= TIZEN_GESTURE_DIRECTION_RIGHT; + ungrabbed_edge |= TIZEN_GESTURE_EDGE_LEFT; } } - if (direction & ~ungrabbed_direction) + if (edge & ~ungrabbed_edge) { - _e_gesture_remove_client_destroy_listener(client, num_of_fingers, direction & ~ungrabbed_direction); + _e_gesture_remove_client_destroy_listener(client, fingers, edge & ~ungrabbed_edge); for (i = 0; i < E_GESTURE_FINGER_MAX+1; i++) { - for (j = 0; j < E_GESTURE_DIRECTION_MAX+1; j++) + for (j = 0; j < E_GESTURE_EDGE_MAX+1; j++) { - if (gev->swipes.fingers[i].direction[j].client) + if (gev->edge_swipes.fingers[i].edge[j].client) { goto finish; } } - gev->swipes.fingers[i].enabled = EINA_FALSE; + gev->edge_swipes.fingers[i].enabled = EINA_FALSE; } - gesture->grabbed_gesture &= ~TIZEN_GESTURE_TYPE_SWIPE; + gesture->grabbed_gesture &= ~TIZEN_GESTURE_TYPE_EDGE_SWIPE; + if (gev->edge_swipes.event_keep) gesture->event_state = E_GESTURE_EVENT_STATE_PROPAGATE; } finish: - tizen_gesture_send_grab_swipe_notify(resouce, num_of_fingers, direction, ret); + tizen_gesture_send_grab_edge_swipe_notify(resouce, fingers, edge, ret); return; } static const struct tizen_gesture_interface _e_gesture_implementation = { - _e_gesture_cb_grab_swipe, - _e_gesture_cb_ungrab_swipe + _e_gesture_cb_grab_edge_swipe, + _e_gesture_cb_ungrab_edge_swipe }; /* tizen_gesture global object destroy function */ @@ -390,9 +392,9 @@ _e_gesture_init(E_Module *m) gesture->config = gconfig; GTDBG("config value\n"); - GTDBG("keyboard: %s, time_done: %lf, time_begin: %lf\n", gconfig->conf->key_device_name, gconfig->conf->swipe.time_done, gconfig->conf->swipe.time_begin); - GTDBG("area_offset: %d, min_length: %d, max_length: %d\n", gconfig->conf->swipe.area_offset, gconfig->conf->swipe.min_length, gconfig->conf->swipe.max_length); - GTDBG("compose key: %d, back: %d, default: %d\n", gconfig->conf->swipe.compose_key, gconfig->conf->swipe.back_key, gconfig->conf->swipe.default_enable_back); + GTDBG("keyboard: %s, time_done: %lf, time_begin: %lf\n", gconfig->conf->key_device_name, gconfig->conf->edge_swipe.time_done, gconfig->conf->edge_swipe.time_begin); + GTDBG("area_offset: %d, min_length: %d, max_length: %d\n", gconfig->conf->edge_swipe.area_offset, gconfig->conf->edge_swipe.min_length, gconfig->conf->edge_swipe.max_length); + GTDBG("compose key: %d, back: %d, default: %d\n", gconfig->conf->edge_swipe.compose_key, gconfig->conf->edge_swipe.back_key, gconfig->conf->edge_swipe.default_enable_back); gesture->global = wl_global_create(e_comp_wl->wl.disp, &tizen_gesture_interface, 1, gesture, _e_gesture_cb_bind); if (!gesture->global) @@ -403,12 +405,17 @@ _e_gesture_init(E_Module *m) gesture->gesture_filter = E_GESTURE_TYPE_MAX; - if (gconfig->conf->swipe.default_enable_back) + gesture->gesture_events.edge_swipes.event_keep = gconfig->conf->edge_swipe.event_keep; + if (gconfig->conf->edge_swipe.default_enable_back) { - gesture->grabbed_gesture |= TIZEN_GESTURE_TYPE_SWIPE; - gesture->gesture_events.swipes.fingers[1].enabled = EINA_TRUE; - gesture->gesture_events.swipes.fingers[1].direction[E_GESTURE_DIRECTION_DOWN].client = (void *)0x1; - gesture->gesture_events.swipes.fingers[1].direction[E_GESTURE_DIRECTION_DOWN].res = (void *)0x1; + gesture->grabbed_gesture |= TIZEN_GESTURE_TYPE_EDGE_SWIPE; + gesture->gesture_events.edge_swipes.fingers[1].enabled = EINA_TRUE; + gesture->gesture_events.edge_swipes.fingers[1].edge[E_GESTURE_EDGE_TOP].client = (void *)0x1; + gesture->gesture_events.edge_swipes.fingers[1].edge[E_GESTURE_EDGE_TOP].res = (void *)0x1; + if (gesture->gesture_events.edge_swipes.event_keep) + { + gesture->event_state = E_GESTURE_EVENT_STATE_KEEP; + } } e_gesture_device_keydev_set(gesture->config->conf->key_device_name); @@ -459,32 +466,32 @@ _e_gesture_wl_client_cb_destroy(struct wl_listener *l, void *data) Eina_List *l_list, *l_next; E_Gesture_Grabbed_Client *client_data; - if (gesture->grabbed_gesture & TIZEN_GESTURE_TYPE_SWIPE) + if (gesture->grabbed_gesture & TIZEN_GESTURE_TYPE_EDGE_SWIPE) { for (i = 0; i < E_GESTURE_FINGER_MAX+1; i++) { - for (j = 0; j < E_GESTURE_DIRECTION_MAX+1; j++) + for (j = 0; j < E_GESTURE_EDGE_MAX+1; j++) { - if (gesture->gesture_events.swipes.fingers[i].direction[j].client == client) + if (gesture->gesture_events.edge_swipes.fingers[i].edge[j].client == client) { - gesture->gesture_events.swipes.fingers[i].direction[j].client = NULL; - gesture->gesture_events.swipes.fingers[i].direction[j].res = NULL; + gesture->gesture_events.edge_swipes.fingers[i].edge[j].client = NULL; + gesture->gesture_events.edge_swipes.fingers[i].edge[j].res = NULL; } } } for (i = 0; i < E_GESTURE_FINGER_MAX+1; i++) { - for (j = 0; j < E_GESTURE_DIRECTION_MAX+1; j++) + for (j = 0; j < E_GESTURE_EDGE_MAX+1; j++) { - if (gesture->gesture_events.swipes.fingers[i].direction[j].client) + if (gesture->gesture_events.edge_swipes.fingers[i].edge[j].client) { goto out; } } - gesture->gesture_events.swipes.fingers[i].enabled = EINA_FALSE; + gesture->gesture_events.edge_swipes.fingers[i].enabled = EINA_FALSE; } - gesture->grabbed_gesture &= ~TIZEN_GESTURE_TYPE_SWIPE; + gesture->grabbed_gesture &= ~TIZEN_GESTURE_TYPE_EDGE_SWIPE; } out: diff --git a/src/e_mod_main.h b/src/e_mod_main.h index 62b8d21..9179932 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -4,6 +4,7 @@ #include #include #include +#include #define GTERR(msg, ARG...) ERR("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) #define GTWRN(msg, ARG...) WRN("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) @@ -11,49 +12,59 @@ #define GTDBG(msg, ARG...) DBG("[tizen_gesture][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) #define E_GESTURE_FINGER_MAX 3 -#define E_GESTURE_TYPE_MAX TIZEN_GESTURE_TYPE_SWIPE+1 -#define E_GESTURE_TYPE_ALL TIZEN_GESTURE_TYPE_SWIPE +#define E_GESTURE_TYPE_MAX TIZEN_GESTURE_TYPE_EDGE_SWIPE+1 +#define E_GESTURE_TYPE_ALL TIZEN_GESTURE_TYPE_EDGE_SWIPE #define E_GESTURE_KEYBOARD_NAME "Gesture Keyboard" /* FIX ME: Set values in contiguration file, do not use definition */ #define E_GESTURE_KEYBOARD_DEVICE "Any" -#define E_GESTURE_SWIPE_DONE_TIME 0.5 -#define E_GESTURE_SWIPE_START_TIME 0.01 -#define E_GESTURE_SWIPE_START_AREA 50 -#define E_GESTURE_SWIPE_DIFF_FAIL 100 -#define E_GESTURE_SWIPE_DIFF_SUCCESS 300 +#define E_GESTURE_EDGE_SWIPE_DONE_TIME 0.5 +#define E_GESTURE_EDGE_SWIPE_START_TIME 0.01 +#define E_GESTURE_EDGE_SWIPE_START_AREA 50 +#define E_GESTURE_EDGE_SWIPE_DIFF_FAIL 100 +#define E_GESTURE_EDGE_SWIPE_DIFF_SUCCESS 300 /* FIX ME: Key code will be get from keymap */ -#define E_GESTURE_SWIPE_COMBINE_KEY 124 -#define E_GESTURE_SWIPE_BACK_KEY 166 -#define E_GESTURE_SWIPE_BACK_DEFAULT_ENABLE EINA_TRUE +#define E_GESTURE_EDGE_SWIPE_COMBINE_KEY 124 +#define E_GESTURE_EDGE_SWIPE_BACK_KEY 166 +#define E_GESTURE_EDGE_SWIPE_BACK_DEFAULT_ENABLE EINA_TRUE #define ABS(x) ((x)>0)?(x):-(x) typedef struct _E_Gesture E_Gesture; typedef struct _E_Gesture* E_GesturePtr; typedef struct _E_Gesture_Event E_Gesture_Event; -typedef struct _E_Gesture_Event_Swipe E_Gesture_Event_Swipe; -typedef struct _E_Gesture_Event_Swipe_Finger E_Gesture_Event_Swipe_Finger; -typedef struct _E_Gesture_Event_Swipe_Finger_Direction E_Gesture_Event_Swipe_Finger_Direction; +typedef struct _E_Gesture_Event_Edge_Swipe E_Gesture_Event_Edge_Swipe; +typedef struct _E_Gesture_Event_Edge_Swipe_Finger E_Gesture_Event_Edge_Swipe_Finger; +typedef struct _E_Gesture_Event_Edge_Swipe_Finger_Edge E_Gesture_Event_Edge_Swipe_Finger_Edge; typedef struct _E_Gesture_Grabbed_Client E_Gesture_Grabbed_Client; typedef struct _E_Gesture_Conf_Edd E_Gesture_Conf_Edd; typedef struct _E_Gesture_Config_Data E_Gesture_Config_Data; typedef struct _Coords Coords; +typedef struct _E_Gesture_Event_Info E_Gesture_Event_Info; -typedef enum _E_Gesture_Direction E_Gesture_Direction; +typedef enum _E_Gesture_Edge E_Gesture_Edge; +typedef enum _E_Gesture_Event_State E_Gesture_Event_State; extern E_GesturePtr gesture; -#define E_GESTURE_DIRECTION_MAX 4 -enum _E_Gesture_Direction +#define E_GESTURE_EDGE_MAX 4 + +enum _E_Gesture_Edge { - E_GESTURE_DIRECTION_NONE, - E_GESTURE_DIRECTION_DOWN, //Start point is North - E_GESTURE_DIRECTION_LEFT, // Start point is East - E_GESTURE_DIRECTION_UP, // Start point is South - E_GESTURE_DIRECTION_RIGHT // Start point is West + E_GESTURE_EDGE_NONE, + E_GESTURE_EDGE_TOP, + E_GESTURE_EDGE_RIGHT, + E_GESTURE_EDGE_BOTTOM, + E_GESTURE_EDGE_LEFT +}; + +enum _E_Gesture_Event_State +{ + E_GESTURE_EVENT_STATE_PROPAGATE, + E_GESTURE_EVENT_STATE_KEEP, + E_GESTURE_EVENT_STATE_IGNORE }; struct _Coords @@ -61,6 +72,12 @@ struct _Coords int x, y; }; +struct _E_Gesture_Event_Info +{ + int type; + void *event; +}; + struct _E_Gesture_Conf_Edd { char *key_device_name; @@ -74,7 +91,8 @@ struct _E_Gesture_Conf_Edd int compose_key; int back_key; Eina_Bool default_enable_back; - } swipe; + Eina_Bool event_keep; + } edge_swipe; }; struct _E_Gesture_Config_Data @@ -84,17 +102,17 @@ struct _E_Gesture_Config_Data E_Gesture_Conf_Edd *conf; }; -struct _E_Gesture_Event_Swipe_Finger_Direction +struct _E_Gesture_Event_Edge_Swipe_Finger_Edge { struct wl_client *client; struct wl_resource *res; }; -struct _E_Gesture_Event_Swipe_Finger +struct _E_Gesture_Event_Edge_Swipe_Finger { Coords start; Eina_Bool enabled; - E_Gesture_Event_Swipe_Finger_Direction direction[E_GESTURE_DIRECTION_MAX+1]; + E_Gesture_Event_Edge_Swipe_Finger_Edge edge[E_GESTURE_EDGE_MAX+1]; }; struct _E_Gesture_Grabbed_Client @@ -102,15 +120,15 @@ struct _E_Gesture_Grabbed_Client struct wl_client *client; struct wl_listener *destroy_listener; - E_Gesture_Event_Swipe_Finger swipe_fingers[E_GESTURE_FINGER_MAX+1]; + E_Gesture_Event_Edge_Swipe_Finger edge_swipe_fingers[E_GESTURE_FINGER_MAX+1]; }; -struct _E_Gesture_Event_Swipe +struct _E_Gesture_Event_Edge_Swipe { - E_Gesture_Event_Swipe_Finger fingers[E_GESTURE_FINGER_MAX+1]; + E_Gesture_Event_Edge_Swipe_Finger fingers[E_GESTURE_FINGER_MAX+1]; - E_Gesture_Direction direction; + unsigned int edge; unsigned int combined_keycode; unsigned int back_keycode; @@ -118,11 +136,13 @@ struct _E_Gesture_Event_Swipe unsigned int enabled_finger; Ecore_Timer *start_timer; Ecore_Timer *done_timer; + + Eina_Bool event_keep; }; struct _E_Gesture_Event { - E_Gesture_Event_Swipe swipes; + E_Gesture_Event_Edge_Swipe edge_swipes; int num_pressed; Eina_Bool recognized_gesture; @@ -150,6 +170,9 @@ struct _E_Gesture unsigned int grabbed_gesture; E_Gesture_Event gesture_events; + E_Gesture_Event_State event_state; + + Eina_List *event_queue; unsigned int gesture_filter; unsigned int gesture_recognized; @@ -170,8 +193,8 @@ void e_gesture_conf_deinit(E_Gesture_Config_Data *gconfig); /* Device control */ void e_gesture_device_shutdown(void); -Eina_Bool e_gesture_device_add(Ecore_Event_Device_Info *ev); -Eina_Bool e_gesture_device_del(Ecore_Event_Device_Info *ev); +E_Gesture_Event_State e_gesture_device_add(Ecore_Event_Device_Info *ev); +E_Gesture_Event_State e_gesture_device_del(Ecore_Event_Device_Info *ev); Eina_Bool e_gesture_is_touch_device(const Ecore_Device *dev); void e_gesture_device_keydev_set(char *option); -- 2.7.4 From cbe53e5431851588751c106996ea0d0144f488ad Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 6 Dec 2016 14:35:10 +0900 Subject: [PATCH 09/16] Packaging : update version to 0.1.2 Change-Id: Iee00d96b653e90648ed2ba67644dc63ce27249f6 Signed-off-by: Sung-Jin Park --- packaging/e-mod-tizen-gesture.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/e-mod-tizen-gesture.spec b/packaging/e-mod-tizen-gesture.spec index d3b41d9..f515751 100644 --- a/packaging/e-mod-tizen-gesture.spec +++ b/packaging/e-mod-tizen-gesture.spec @@ -2,7 +2,7 @@ %bcond_with wayland Name: e-mod-tizen-gesture -Version: 0.1.1 +Version: 0.1.2 Release: 1 Summary: The Enlightenment Gesture Module for Tizen URL: http://www.enlightenment.org -- 2.7.4 From d5b36ea4f47ea87c6d1a78c2259c8d8e528b3811 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Wed, 7 Dec 2016 11:01:32 +0900 Subject: [PATCH 10/16] Fix a invalid return value Change-Id: Ide2683edc4d771437d0ac457b6e8349e55f5201c --- src/e_mod_gesture_events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index a72ea62..d91d31b 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -472,7 +472,7 @@ _e_gesture_process_mouse_button_up(void *event) if (gesture->gesture_events.num_pressed == 0) { - return EINA_TRUE; + return E_GESTURE_EVENT_STATE_PROPAGATE; } gesture->gesture_events.num_pressed--; @@ -518,7 +518,7 @@ _e_gesture_process_mouse_move(void *event) if (gesture->gesture_events.num_pressed == 0) { - return EINA_TRUE; + return gesture->event_state; } if (!gesture->grabbed_gesture) { -- 2.7.4 From 9eb1538aa133cb0afa3469d32ab9dbae4ff5ceeb Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 16 Dec 2016 11:36:48 +0900 Subject: [PATCH 11/16] aux hint hook added to enable/disable global gesture(s) for each e client Change-Id: I63bc479805bac9e4899c45f80063e16b53f27166 --- src/e_mod_main.c | 47 ++++++++++++++++++++++++++++++++++------------- src/e_mod_main.h | 1 + 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 95035cc..a7c7d95 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -319,17 +319,9 @@ _e_gesture_event_filter(void *data, void *loop_data EINA_UNUSED, int type, void return e_gesture_process_events(event, type); } -static Eina_Bool -_e_gesture_cb_client_focus_in(void *data, int type, void *event) +static void +_e_gesture_window_gesture_disabled_change(E_Client *ec) { - E_Client *ec; - E_Event_Client *ev = (E_Event_Client *)event; - - EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); - ec = ev->ec; - EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_PASS_ON); - EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, ECORE_CALLBACK_PASS_ON); - if (ec->gesture_disable && gesture->enable) { GTINF("Gesture disabled window\n"); @@ -345,11 +337,40 @@ _e_gesture_cb_client_focus_in(void *data, int type, void *event) { e_gesture_event_filter_enable(gesture->enabled_window); } +} + +static Eina_Bool +_e_gesture_cb_client_focus_in(void *data, int type, void *event) +{ + E_Client *ec; + E_Event_Client *ev = (E_Event_Client *)event; + + EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); + ec = ev->ec; + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_PASS_ON); + EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, ECORE_CALLBACK_PASS_ON); + + _e_gesture_window_gesture_disabled_change(ec); return ECORE_CALLBACK_PASS_ON; } static void +_e_gesture_cb_aux_hint_change(void *data EINA_UNUSED, E_Client *ec) +{ + E_Comp_Wl_Aux_Hint *hint; + Eina_List *l; + + if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return; + if (!ec->comp_data->aux_hint.changed) return; + + /* Return if the aux hint change didn't happen to the focused ec */ + if (ec != e_client_focused_get()) return; + + _e_gesture_window_gesture_disabled_change(ec); +} + +static void _e_gesture_init_handlers(void) { gesture->ef_handler = ecore_event_filter_add(NULL, _e_gesture_event_filter, NULL, NULL); @@ -377,7 +398,7 @@ _e_gesture_init(E_Module *m) goto err; } - /* Add filtering mechanism + /* Add filtering mechanism * FIXME: Add handlers after first gesture is grabbed */ _e_gesture_init_handlers(); @@ -419,7 +440,7 @@ _e_gesture_init(E_Module *m) } e_gesture_device_keydev_set(gesture->config->conf->key_device_name); - + e_client_hook_add(E_CLIENT_HOOK_AUX_HINT_CHANGE, _e_gesture_cb_aux_hint_change, NULL); gesture->enable = EINA_TRUE; return gconfig; @@ -520,4 +541,4 @@ e_gesture_event_filter_enable(Eina_Bool enabled) GTINF("Gestures will be enabled from now.\n"); gesture->enable = EINA_FALSE; } -} \ No newline at end of file +} diff --git a/src/e_mod_main.h b/src/e_mod_main.h index 9179932..bd894d5 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -15,6 +15,7 @@ #define E_GESTURE_TYPE_MAX TIZEN_GESTURE_TYPE_EDGE_SWIPE+1 #define E_GESTURE_TYPE_ALL TIZEN_GESTURE_TYPE_EDGE_SWIPE #define E_GESTURE_KEYBOARD_NAME "Gesture Keyboard" +#define E_GESTURE_AUX_HINT_GESTURE_DISABLE "wm.policy.win.gesture.disable" /* FIX ME: Set values in contiguration file, do not use definition */ #define E_GESTURE_KEYBOARD_DEVICE "Any" -- 2.7.4 From cdac1cfc95eb2f84e130cb26a718ea944474c15f Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Fri, 16 Dec 2016 15:16:13 +0900 Subject: [PATCH 12/16] Deinitialize handlers and hooks Change-Id: I6779e86cd1606c56600d66e54b87c3ff83df51cf --- src/e_mod_main.c | 28 ++++++++++++++++++++++++---- src/e_mod_main.h | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index a7c7d95..4f5ca3b 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -358,9 +358,6 @@ _e_gesture_cb_client_focus_in(void *data, int type, void *event) static void _e_gesture_cb_aux_hint_change(void *data EINA_UNUSED, E_Client *ec) { - E_Comp_Wl_Aux_Hint *hint; - Eina_List *l; - if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return; if (!ec->comp_data->aux_hint.changed) return; @@ -378,6 +375,29 @@ _e_gesture_init_handlers(void) gesture->handlers = eina_list_append(gesture->handlers, ecore_event_handler_add(E_EVENT_CLIENT_FOCUS_IN, _e_gesture_cb_client_focus_in, NULL)); + + gesture->hooks = eina_list_append(gesture->hooks, + e_client_hook_add(E_CLIENT_HOOK_AUX_HINT_CHANGE, + _e_gesture_cb_aux_hint_change, NULL)); +} + +static void +_e_gesture_deinit_handlers(void) +{ + Ecore_Event_Handler *event_handler; + E_Client_Hook *hook; + + ecore_event_filter_del(gesture->ef_handler); + + EINA_LIST_FREE(gesture->handlers, event_handler) + { + ecore_event_handler_del(event_handler); + } + + EINA_LIST_FREE(gesture->hooks, hook) + { + e_client_hook_del(hook); + } } static E_Gesture_Config_Data * @@ -440,7 +460,6 @@ _e_gesture_init(E_Module *m) } e_gesture_device_keydev_set(gesture->config->conf->key_device_name); - e_client_hook_add(E_CLIENT_HOOK_AUX_HINT_CHANGE, _e_gesture_cb_aux_hint_change, NULL); gesture->enable = EINA_TRUE; return gconfig; @@ -465,6 +484,7 @@ e_modapi_shutdown(E_Module *m) E_Gesture_Config_Data *gconfig = m->data; e_gesture_conf_deinit(gconfig); e_gesture_device_shutdown(); + _e_gesture_deinit_handlers(); return 1; } diff --git a/src/e_mod_main.h b/src/e_mod_main.h index bd894d5..da12291 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -159,6 +159,7 @@ struct _E_Gesture Ecore_Event_Filter *ef_handler; Eina_List *handlers; Eina_List *grab_client_list; + Eina_List *hooks; struct { -- 2.7.4 From d34ed57a8e14e6d5b36004ed203778da2d17c5c9 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 16 Dec 2016 15:25:44 +0900 Subject: [PATCH 13/16] Packaging : update version to 0.1.3 Change-Id: Ifbee3868eaf6a2d8226c0034b0a459d4b56916ed Signed-off-by: Sung-Jin Park --- packaging/e-mod-tizen-gesture.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/e-mod-tizen-gesture.spec b/packaging/e-mod-tizen-gesture.spec index f515751..ad6effa 100644 --- a/packaging/e-mod-tizen-gesture.spec +++ b/packaging/e-mod-tizen-gesture.spec @@ -2,7 +2,7 @@ %bcond_with wayland Name: e-mod-tizen-gesture -Version: 0.1.2 +Version: 0.1.3 Release: 1 Summary: The Enlightenment Gesture Module for Tizen URL: http://www.enlightenment.org -- 2.7.4 From 9d7d02ddfeb55ce30a89eeda8755674c0032757c Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Fri, 30 Dec 2016 15:42:35 +0900 Subject: [PATCH 14/16] Accept all of gesture disable request from quickpanel Change-Id: Ieb3a020e8c050acca5c0c3951a66e5393f47009f --- configure.ac | 3 ++- packaging/e-mod-tizen-gesture.spec | 1 + src/e_mod_gesture_events.c | 28 +++++++--------------------- src/e_mod_main.c | 32 +++++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index c1e5180..56fca6d 100644 --- a/configure.ac +++ b/configure.ac @@ -64,7 +64,8 @@ dnl ======================================================================== # checks for pkg-config dnl ======================================================================== PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment, - dlog]) + dlog, + tzsh-server]) ENLIGHTENMENT_CFLAGS="${ENLIGHTENMENT_CFLAGS} -D_GNU_SOURCE " AC_SUBST(ENLIGHTENMENT_CFLAGS) AC_SUBST(ENLIGHTENMENT_LIBS) diff --git a/packaging/e-mod-tizen-gesture.spec b/packaging/e-mod-tizen-gesture.spec index ad6effa..aed0333 100644 --- a/packaging/e-mod-tizen-gesture.spec +++ b/packaging/e-mod-tizen-gesture.spec @@ -14,6 +14,7 @@ BuildRequires: gettext BuildRequires: pkgconfig(wayland-server) BuildRequires: pkgconfig(tizen-extension-server) BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(tzsh-server) %global TZ_SYS_RO_SHARE %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share} diff --git a/src/e_mod_gesture_events.c b/src/e_mod_gesture_events.c index d91d31b..6627b5c 100644 --- a/src/e_mod_gesture_events.c +++ b/src/e_mod_gesture_events.c @@ -322,11 +322,13 @@ _e_gesture_process_edge_swipe_down(Ecore_Event_Mouse_Button *ev) _e_gesture_event_flush(); _e_gesture_edge_swipe_cancel(); } - - edge_swipes->fingers[idx].start.x = ev->x; - edge_swipes->fingers[idx].start.y = ev->y; - edge_swipes->start_timer = ecore_timer_add(conf->edge_swipe.time_begin, _e_gesture_timer_edge_swipe_start, NULL); - edge_swipes->done_timer = ecore_timer_add(conf->edge_swipe.time_done, _e_gesture_timer_edge_swipe_done, NULL); + if (edge_swipes->edge != E_GESTURE_EDGE_NONE) + { + edge_swipes->fingers[idx].start.x = ev->x; + edge_swipes->fingers[idx].start.y = ev->y; + edge_swipes->start_timer = ecore_timer_add(conf->edge_swipe.time_begin, _e_gesture_timer_edge_swipe_start, NULL); + edge_swipes->done_timer = ecore_timer_add(conf->edge_swipe.time_done, _e_gesture_timer_edge_swipe_done, NULL); + } } else { @@ -429,8 +431,6 @@ _e_gesture_process_mouse_button_down(void *event) { Ecore_Event_Mouse_Button *ev = event; - gesture->gesture_events.num_pressed++; - if (!gesture->grabbed_gesture) { return E_GESTURE_EVENT_STATE_PROPAGATE; @@ -470,12 +470,6 @@ _e_gesture_process_mouse_button_up(void *event) { Ecore_Event_Mouse_Button *ev = event; - if (gesture->gesture_events.num_pressed == 0) - { - return E_GESTURE_EVENT_STATE_PROPAGATE; - } - - gesture->gesture_events.num_pressed--; if (!gesture->grabbed_gesture) { return E_GESTURE_EVENT_STATE_PROPAGATE; @@ -490,14 +484,6 @@ _e_gesture_process_mouse_button_up(void *event) if (gesture->gesture_events.num_pressed == 0) { gesture->gesture_events.recognized_gesture = 0x0; - if (!gesture->enable && gesture->enabled_window) - { - e_gesture_event_filter_enable(EINA_TRUE); - } - else if (gesture->enable && !gesture->enabled_window) - { - e_gesture_event_filter_enable(EINA_FALSE); - } } return E_GESTURE_EVENT_STATE_IGNORE; } diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 4f5ca3b..c2ad892 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -1,6 +1,7 @@ #define E_COMP_WL #include "e_mod_main.h" #include +#include "e_service_quickpanel.h" E_GesturePtr gesture = NULL; E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Gesture Module of Window Manager" }; @@ -314,6 +315,30 @@ static Eina_Bool _e_gesture_event_filter(void *data, void *loop_data EINA_UNUSED, int type, void *event) { (void) data; + + if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) + { + gesture->gesture_events.num_pressed++; + } + else if (type == ECORE_EVENT_MOUSE_BUTTON_UP) + { + gesture->gesture_events.num_pressed--; + if (gesture->gesture_events.num_pressed < 0) + gesture->gesture_events.num_pressed = 0; + if (gesture->gesture_events.num_pressed == 0) + { + if (!gesture->enable && gesture->enabled_window) + { + e_gesture_event_filter_enable(EINA_TRUE); + return EINA_TRUE; + } + else if (gesture->enable && !gesture->enabled_window) + { + e_gesture_event_filter_enable(EINA_FALSE); + return e_gesture_process_events(event, type); + } + } + } if (!gesture->enable) return EINA_TRUE; return e_gesture_process_events(event, type); @@ -358,11 +383,16 @@ _e_gesture_cb_client_focus_in(void *data, int type, void *event) static void _e_gesture_cb_aux_hint_change(void *data EINA_UNUSED, E_Client *ec) { + E_Client *qp_ec; if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return; if (!ec->comp_data->aux_hint.changed) return; + qp_ec = e_service_quickpanel_client_get(); + /* Return if the aux hint change didn't happen to the focused ec */ - if (ec != e_client_focused_get()) return; + if ((ec != qp_ec) && + (ec != e_client_focused_get())) + return; _e_gesture_window_gesture_disabled_change(ec); } -- 2.7.4 From 5b839c704cfe4a83a58fa0ee25066f13ac98af33 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 5 Jan 2017 13:10:52 +0900 Subject: [PATCH 15/16] Packaging : update version to 0.1.4 Change-Id: Id7084952a4f23e93a6d50620fc2f7ca0d3a68924 --- packaging/e-mod-tizen-gesture.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/e-mod-tizen-gesture.spec b/packaging/e-mod-tizen-gesture.spec index aed0333..5a1e11e 100644 --- a/packaging/e-mod-tizen-gesture.spec +++ b/packaging/e-mod-tizen-gesture.spec @@ -2,7 +2,7 @@ %bcond_with wayland Name: e-mod-tizen-gesture -Version: 0.1.3 +Version: 0.1.4 Release: 1 Summary: The Enlightenment Gesture Module for Tizen URL: http://www.enlightenment.org -- 2.7.4 From 9e9b21c98d9451a4333f77787f7b67c539e7534e Mon Sep 17 00:00:00 2001 From: Minsu Han Date: Tue, 7 Feb 2017 09:24:21 +0900 Subject: [PATCH 16/16] Fix double free issue. To append device.touch_devices list in e_gesture_device_add(), we should use strdup(). If not, in e_gesture_device_del() we have chance to meet the crash. Change-Id: Ic78fc74cb925a2e83a5f2dccb1668d71fa5c1795 Signed-off-by: Minsu Han --- src/e_mod_gesture_device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/e_mod_gesture_device.c b/src/e_mod_gesture_device.c index 25b5446..6e26af3 100644 --- a/src/e_mod_gesture_device.c +++ b/src/e_mod_gesture_device.c @@ -89,7 +89,9 @@ e_gesture_device_add(Ecore_Event_Device_Info *ev) { if (ev->clas == ECORE_DEVICE_CLASS_TOUCH) { - gesture->device.touch_devices = eina_list_append(gesture->device.touch_devices, ev->identifier); + char *id; + id = strdup(ev->identifier); + gesture->device.touch_devices = eina_list_append(gesture->device.touch_devices, id); GTINF("%s(%s) device is touch device: add list\n", ev->name, ev->identifier); } if ((!gesture->device.kbd_identifier) && -- 2.7.4