From: duna.oh Date: Thu, 15 Jun 2023 00:08:58 +0000 (+0900) Subject: e_service_gesture: add 'use_cleanup_timer' config in gesture_service X-Git-Tag: accepted/tizen/7.0/unified/20230628.014031~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F294792%2F1;p=platform%2Fupstream%2Fenlightenment.git e_service_gesture: add 'use_cleanup_timer' config in gesture_service configuration added - use_cleanup_timer: use timer to cleanup gestures - cleanup_time: wait for gesture ends after started (60 sec by default) Change-Id: I9629f5b5ba3c05542bbff8a17268ed867611ffe0 --- diff --git a/src/bin/e_config.c b/src/bin/e_config.c index 74e849a9ca..fde678bdca 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -304,6 +304,8 @@ _e_config_edd_init(Eina_Bool old) E_CONFIG_VAL(D, T, qp_handler.alpha, INT); E_CONFIG_VAL(D, T, gesture_service.wait_time, DOUBLE); E_CONFIG_VAL(D, T, gesture_service.wait_dist, INT); + E_CONFIG_VAL(D, T, gesture_service.use_cleanup_timer, INT); + E_CONFIG_VAL(D, T, gesture_service.cleanup_time, INT); E_CONFIG_VAL(D, T, configured_output_resolution.use, UCHAR); E_CONFIG_VAL(D, T, configured_output_resolution.w, INT); E_CONFIG_VAL(D, T, configured_output_resolution.h, INT); @@ -571,6 +573,7 @@ e_config_load(void) E_CONFIG_LIMIT(e_config->qp_use_bg_rect, 0, 1); E_CONFIG_LIMIT(e_config->qp_handler.use_alpha, 0, 1); E_CONFIG_LIMIT(e_config->qp_handler.alpha, 0, 255); + E_CONFIG_LIMIT(e_config->gesture_service.use_cleanup_timer, 0, 1); E_CONFIG_LIMIT(e_config->configured_output_resolution.use, 0, 1); E_CONFIG_LIMIT(e_config->global_object_not_provide.launch_effect, 0, 1); E_CONFIG_LIMIT(e_config->use_thread_max_cpu, 0, 1); diff --git a/src/bin/e_config.h b/src/bin/e_config.h index 87aa4e3694..1ba56c9f9b 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -238,10 +238,14 @@ struct _E_Config // But each devices has different touch sensitivity, so make these values configurable. // wait_time: waiting times set fingers are come // wait_dist: if current touched fingers are moving sufficiently, stop waiting other fingers + // use_cleanup_timer: use timer to cleanup gestures + // cleanup_time: wait for gesture ends after started struct { double wait_time; // default value is 0.1(sec) int wait_dist; + int use_cleanup_timer; + int cleanup_time; } gesture_service; // Configured output resolution diff --git a/src/bin/services/e_service_gesture.c b/src/bin/services/e_service_gesture.c index e669bbf952..d94353456e 100644 --- a/src/bin/services/e_service_gesture.c +++ b/src/bin/services/e_service_gesture.c @@ -47,6 +47,9 @@ struct _E_Policy_Gesture E_Policy_Gesture_End_Cb end; void *data; } cb; + + int cleanup_time; + Ecore_Timer *cleanup_timer; }; static void @@ -254,6 +257,38 @@ _gesture_waiting_timer(void *data) return ECORE_CALLBACK_CANCEL; } +static Eina_Bool +_gesture_cleanup_timer(void *data) +{ + int cx = 0, cy = 0; + E_Policy_Gesture *gesture = data; + unsigned int timestamp; + + E_FREE_FUNC(gesture->cleanup_timer, ecore_timer_del); + + WRN("cleanup_timer TIMEOUT: set_fingers: 0x%x, pressed: %d(0x%x)", + gesture->set_fingers, gesture->pressed_fingers, (1 << gesture->pressed_fingers)); + + timestamp = (int)(ecore_time_get() * 1000); + _gesture_util_center_cur_point_get(gesture, &cx, &cy); + _gesture_check(gesture, gesture->obj, cx, cy, timestamp); + WRN("cleanup_timer gesture->status: %d cx: %d, cy: %d", gesture->status, cx, cy); + if (gesture->status == POL_GESTURE_STATUS_ACTIVE) + { + if (gesture->cb.end) + { + gesture->cb.end(gesture->cb.data, gesture->obj, gesture->gesture_fingers, cx, cy, timestamp); + } + } + + for (int i = 0; i < gesture->pressed_fingers; i++) + gesture->touch_info[i].pressed = EINA_FALSE; + + _gesture_cleanup(gesture); + + return ECORE_CALLBACK_CANCEL; +} + static void _gesture_touch_up(E_Policy_Gesture *gesture, Evas_Object *obj, int idx, int x, int y, int timestamp) { @@ -421,6 +456,11 @@ _gesture_obj_cb_mouse_up(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, v gesture->pressed_fingers--; _gesture_touch_up(gesture, obj, 0, ev->canvas.x, ev->canvas.y, ev->timestamp); + + if (e_config->gesture_service.use_cleanup_timer) + { + E_FREE_FUNC(gesture->cleanup_timer, ecore_timer_del); + } } static void @@ -442,7 +482,14 @@ _gesture_obj_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, Evas_Event_Mouse_Down *ev = event; gesture->pressed_fingers++; + _gesture_touch_down(data, obj, 0, ev->canvas.x, ev->canvas.y, ev->timestamp); + + if (e_config->gesture_service.use_cleanup_timer) + { + E_FREE_FUNC(gesture->cleanup_timer, ecore_timer_del); + gesture->cleanup_timer = ecore_timer_add(gesture->cleanup_time, _gesture_cleanup_timer, (void *)gesture); + } } static void @@ -524,7 +571,7 @@ e_service_gesture_add(Evas_Object *obj, E_Policy_Gesture_Type type, int nfingers gesture->type = type; gesture->set_fingers |= 1 << nfingers; - // attempt to get wait_time and wait_dist to config file. + // attempt to get wait_time, wait_dist and cleanup_time from config file. // but if failed, set default VALUE if (e_config) { @@ -532,6 +579,8 @@ e_service_gesture_add(Evas_Object *obj, E_Policy_Gesture_Type type, int nfingers gesture->wait_time = e_config->gesture_service.wait_time; if (e_config->gesture_service.wait_dist) gesture->wait_dist = e_config->gesture_service.wait_dist; + if (e_config->gesture_service.use_cleanup_timer) + gesture->cleanup_time = e_config->gesture_service.cleanup_time ?: 60; } if (!gesture->wait_time) gesture->wait_time = 0.1; @@ -583,6 +632,7 @@ e_service_gesture_del(E_Policy_Gesture *gesture) evas_object_data_del(gesture->obj, E_SERVICE_GESTURE_KEY); E_FREE_FUNC(gesture->waiting_timer, ecore_timer_del); + E_FREE_FUNC(gesture->cleanup_timer, ecore_timer_del); free(gesture); }