From bc07fc3294dd07df4f3a35dfe98aba99366fd110 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Fri, 28 Jun 2019 10:35:19 +0000 Subject: [PATCH] efl_ui_clickable: fix not to be clicked if pointer is processed If pointer is processed by a container in its POINTER_MOVE event callback, then clickable calls efl_ui_clickable_button_state_reset not to be clicked by efl_ui_clickable_unpress. e.g. Efl.Ui.Active_View.View_Manager_Scroll sets pointer processed in POINTER_MOVE event callback not to click button during scrolling. Reviewed-by: Marcel Hollerbach Differential Revision: https://phab.enlightenment.org/D9204 --- src/bin/elementary/test_ui_spotlight.c | 7 +++++++ src/lib/elementary/efl_ui_clickable_util.c | 19 +++++++++++++++++-- src/lib/elementary/efl_ui_spotlight_manager_scroll.c | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/bin/elementary/test_ui_spotlight.c b/src/bin/elementary/test_ui_spotlight.c index d7df562..589220b 100644 --- a/src/bin/elementary/test_ui_spotlight.c +++ b/src/bin/elementary/test_ui_spotlight.c @@ -58,6 +58,12 @@ typedef struct _Size_Params #define PAGE_NUM 3 +static void +page_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) +{ + printf("Button Page is clicked!\n"); +} + static Eo * view_add(View_Type p, Eo *parent) { @@ -95,6 +101,7 @@ view_add(View_Type p, Eo *parent) case BUTTON: page = efl_add(EFL_UI_BUTTON_CLASS, parent, efl_text_set(efl_added, "Button Page")); + efl_event_callback_add(page, EFL_UI_EVENT_CLICKED, page_clicked_cb, NULL); efl_gfx_hint_fill_set(page, EINA_TRUE, EINA_TRUE); break; diff --git a/src/lib/elementary/efl_ui_clickable_util.c b/src/lib/elementary/efl_ui_clickable_util.c index b11e0c5..3243b72 100644 --- a/src/lib/elementary/efl_ui_clickable_util.c +++ b/src/lib/elementary/efl_ui_clickable_util.c @@ -38,9 +38,24 @@ _on_mouse_out(void *data, efl_ui_clickable_button_state_reset(data, 1); } +static void +_theme_move_cb(void *data, const Efl_Event *ev EINA_UNUSED) +{ + Efl_Input_Pointer *pointer = ev->info; + + if (efl_input_processed_get(pointer)) + efl_ui_clickable_button_state_reset(data, 1); +} + +EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks, + {EFL_EVENT_POINTER_MOVE, _theme_move_cb}, +) + EOLIAN static void _efl_ui_clickable_util_bind_to_theme(Efl_Canvas_Layout *object, Efl_Ui_Clickable *clickable) { + efl_event_callback_array_add(object, bind_to_theme_callbacks(), clickable); + efl_layout_signal_callback_add(object, "efl,action,press", "*", clickable, _on_press_cb, NULL); efl_layout_signal_callback_add(object, "efl,action,unpress", "*", clickable, _on_unpress_cb, NULL); efl_layout_signal_callback_add(object, "efl,action,mouse_out", "*", clickable, _on_mouse_out, NULL); @@ -84,7 +99,7 @@ _unpress_cb(void *data, const Efl_Event *ev EINA_UNUSED) } } -EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks, +EFL_CALLBACKS_ARRAY_DEFINE(bind_to_object_callbacks, {EFL_EVENT_POINTER_DOWN, _press_cb}, {EFL_EVENT_POINTER_UP, _unpress_cb}, ) @@ -92,7 +107,7 @@ EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks, EOLIAN static void _efl_ui_clickable_util_bind_to_object(Efl_Input_Interface *object, Efl_Ui_Clickable *clickable) { - efl_event_callback_array_add(object, bind_to_theme_callbacks(), clickable); + efl_event_callback_array_add(object, bind_to_object_callbacks(), clickable); } diff --git a/src/lib/elementary/efl_ui_spotlight_manager_scroll.c b/src/lib/elementary/efl_ui_spotlight_manager_scroll.c index 4e64b81..1bc688b 100644 --- a/src/lib/elementary/efl_ui_spotlight_manager_scroll.c +++ b/src/lib/elementary/efl_ui_spotlight_manager_scroll.c @@ -127,6 +127,10 @@ _mouse_move_cb(void *data, pos = efl_input_pointer_position_get(ev); pos_y_diff = pd->mouse_move.mouse_start.x - pos.x; + //Set input processed not to cause clicked event to content button. + if (!efl_input_processed_get(ev)) + efl_input_processed_set(ev, EINA_TRUE); + pd->transition.active = EINA_TRUE; pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w; -- 2.7.4