From b92b546d3678937a5858fd4da73c000b4eff1dbf Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Wed, 17 Oct 2018 12:17:10 +0100 Subject: [PATCH] e menu - allow hold mode to be turned off hold mode is where if u hold mosue down menu stays only as long as mouse is held down... then dismissed on up. doesnt work well when youa re trying to overload a single click with longpresses and so on - optionally turn it off. used in gadgets. --- src/bin/e_bryce.c | 2 ++ src/bin/e_gadget.c | 2 ++ src/bin/e_menu.c | 23 +++++++++++++++++++++++ src/bin/e_menu.h | 2 ++ 4 files changed, 29 insertions(+) diff --git a/src/bin/e_bryce.c b/src/bin/e_bryce.c index 6a19e2a4b..5e69f51ed 100644 --- a/src/bin/e_bryce.c +++ b/src/bin/e_bryce.c @@ -847,6 +847,7 @@ _bryce_owner_menu(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) e_menu_item_label_set(mi, _("Gadget Bar")); subm = e_menu_new(); + e_menu_hold_mode_set(subm, EINA_FALSE); e_menu_item_submenu_set(mi, subm); e_object_unref(E_OBJECT(subm)); @@ -1047,6 +1048,7 @@ _bryce_menu(Bryce *b, Evas_Object *g) int x = 0, y = 0, w = 1, h = 1; m = e_menu_new(); + e_menu_hold_mode_set(m, EINA_FALSE); _bryce_menu_populate(b, m, g); if (g) evas_object_geometry_get(g, &x, &y, &w, &h); diff --git a/src/bin/e_gadget.c b/src/bin/e_gadget.c index 3a6c6f67c..e28e066f6 100644 --- a/src/bin/e_gadget.c +++ b/src/bin/e_gadget.c @@ -1316,6 +1316,7 @@ _gadget_menu(Evas_Object *g, unsigned int timestamp) _gadget_popups_clear(zgc); zgc->menu = e_menu_new(); + e_menu_hold_mode_set(zgc->menu, EINA_FALSE); if (zgc->type) { char buf[1024]; @@ -1338,6 +1339,7 @@ _gadget_menu(Evas_Object *g, unsigned int timestamp) e_menu_item_separator_set(mi, 1); } subm = e_menu_new(); + e_menu_hold_mode_set(subm, EINA_FALSE); evas_object_smart_callback_call(zgc->site->layout, "gadget_site_style_menu", subm); if (e_object_data_get(E_OBJECT(subm))) { diff --git a/src/bin/e_menu.c b/src/bin/e_menu.c index ea1d9c0e8..ddff48586 100644 --- a/src/bin/e_menu.c +++ b/src/bin/e_menu.c @@ -210,9 +210,18 @@ e_menu_new(void) m->cur.w = 1; m->cur.h = 1; m->category = NULL; + m->hold_mode = EINA_TRUE; return m; } +E_API void +e_menu_hold_mode_set(E_Menu *m, Eina_Bool hold_mode) +{ + E_OBJECT_CHECK(m); + E_OBJECT_TYPE_CHECK(m, E_MENU_TYPE); + m->hold_mode = hold_mode; +} + E_API void e_menu_activate_key(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir) { @@ -2780,6 +2789,8 @@ static Eina_Bool _e_menu_cb_mouse_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Event_Mouse_Button *ev; + E_Menu *m; + Eina_List *l; unsigned int t; int ret = 0; @@ -2787,6 +2798,18 @@ _e_menu_cb_mouse_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) ev = event; if (ev->window != _e_menu_win) return ECORE_CALLBACK_RENEW; + if (!_e_menu_activate_floating) + { + EINA_LIST_FOREACH(_e_active_menus, l, m) + { + if (!m->hold_mode) + { + _e_menu_activate_floating = 1; + return ECORE_CALLBACK_PASS_ON; + } + } + } + t = ev->timestamp - _e_menu_activate_time; if ((_e_menu_activate_time != 0) && (t < (e_config->menus_click_drag_timeout * 1000))) diff --git a/src/bin/e_menu.h b/src/bin/e_menu.h index 7ffc035f6..8d6664fcc 100644 --- a/src/bin/e_menu.h +++ b/src/bin/e_menu.h @@ -71,6 +71,7 @@ struct _E_Menu Eina_Bool pending_new_submenu E_BITFIELD; Eina_Bool have_submenu E_BITFIELD; Eina_Bool in_active_list E_BITFIELD; + Eina_Bool hold_mode E_BITFIELD; }; struct _E_Menu_Item @@ -156,6 +157,7 @@ EINTERN int e_menu_shutdown(void); E_API void e_menu_hide_all(void); E_API E_Menu *e_menu_new(void); +E_API void e_menu_hold_mode_set(E_Menu *m, Eina_Bool hold_mode); E_API void e_menu_activate_key(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir); E_API void e_menu_activate_mouse(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir, unsigned int activate_time); E_API void e_menu_activate(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir);