From 4c8cb9d73a17594fcb8da1912f728202c5e969a4 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Thu, 9 Jul 2015 17:38:58 +0900 Subject: [PATCH] timeout_handler: add function for enable/disable handler Change-Id: I45dc8113dd9e5b8d8f336476c1753966849910a0 Signed-off-by: Minkyu Kang --- include/util/timeout_handler.h | 2 ++ src/util/timeout_handler.c | 18 ++++++++++++++++++ src/view/viewer.c | 3 +++ 3 files changed, 23 insertions(+) diff --git a/include/util/timeout_handler.h b/include/util/timeout_handler.h index 29dd6e1..5cd0aab 100644 --- a/include/util/timeout_handler.h +++ b/include/util/timeout_handler.h @@ -29,4 +29,6 @@ void timeout_handler_fini(struct timeout_handler *handle); void timeout_handler_reset(struct timeout_handler *handle); +void timeout_handler_enable(struct timeout_handler *handle, bool enable); + #endif diff --git a/src/util/timeout_handler.c b/src/util/timeout_handler.c index 4d73de1..dce195f 100644 --- a/src/util/timeout_handler.c +++ b/src/util/timeout_handler.c @@ -31,6 +31,7 @@ struct timeout_handler { void *timeout_data; double timeout; + bool enable; }; static Eina_Bool _timer_cb(void *data) @@ -42,6 +43,9 @@ static Eina_Bool _timer_cb(void *data) handle = data; + if (!handle->enable) + return ECORE_CALLBACK_CANCEL; + handle->timeout_cb(handle->timeout_data, 0, NULL); handle->timer = NULL; @@ -57,6 +61,9 @@ static Eina_Bool _event_occured(void *data, int type, void *event) handle = data; + if (!handle->enable) + return ECORE_CALLBACK_PASS_ON; + handle->event_cb(handle->event_data, type, event); timeout_handler_reset(handle); @@ -64,6 +71,16 @@ static Eina_Bool _event_occured(void *data, int type, void *event) return ECORE_CALLBACK_PASS_ON; } +void timeout_handler_enable(struct timeout_handler *handle, bool enable) +{ + handle->enable = enable; + + if (!enable) { + ecore_timer_del(handle->timer); + handle->timer = NULL; + } +} + void timeout_handler_reset(struct timeout_handler *handle) { if (!handle) { @@ -117,6 +134,7 @@ struct timeout_handler *timeout_handler_init(double timeout, handle->timeout_cb = timeout_cb; handle->timeout_data = timeout_data; handle->timeout = timeout; + handle->enable = false; return handle; diff --git a/src/view/viewer.c b/src/view/viewer.c index 8adbea9..e3a9a8a 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -886,6 +886,7 @@ static void _show(void *view_data) _viewer_show(priv, DIR_NONE); + timeout_handler_enable(priv->timeout, true); timeout_handler_reset(priv->timeout); evas_object_show(priv->base); @@ -904,6 +905,8 @@ static void _hide(void *view_data) _viewer_hide(priv); + timeout_handler_enable(priv->timeout, false); + evas_object_hide(priv->base); } -- 2.7.4