discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=fe5d2e6e61747e27292339b01c8b5f9193ecad62

commit fe5d2e6e61747e27292339b01c8b5f9193ecad62
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Wed Feb 3 17:58:34 2016 -0500

    add bool return for mouse-based E_Action callbacks
    
    in many cases, a mouse action's callback will fail to execute as a result 
of multiple
    objects being under the pointer at the time of the event. in this case,
    the callback should be able to determine whether action callback processing 
should
    continue.
    
    as an example, when attempting to execute an action which only activates for
    client objects, if the passed object is not a client then the callback 
should return
    false to indicate that it was not able to perform the action for the given 
object,
    allowing further actions to be attempted on this object
---
 src/bin/e_actions.c               | 75 ++++++++++++++++++++-------------------
 src/bin/e_actions.h               |  6 ++--
 src/bin/e_bindings.c              | 58 +++++++++++++++++++-----------
 src/modules/clock/e_mod_main.c    |  3 +-
 src/modules/tiling/e_mod_tiling.c | 18 +++++-----
 src/modules/winlist/e_mod_main.c  | 18 +++++-----
 6 files changed, 101 insertions(+), 77 deletions(-)

diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c
index d7c2682..b3ff169 100644
--- a/src/bin/e_actions.c
+++ b/src/bin/e_actions.c
@@ -15,7 +15,7 @@
      if (act) act->func.go_mouse = _e_actions_act_##name##_go_mouse;  \
   }
 #define ACT_FN_GO_MOUSE(act, use) \
-  static void _e_actions_act_##act##_go_mouse(E_Object * obj EINA_UNUSED, 
const char *params use, E_Binding_Event_Mouse_Button * ev EINA_UNUSED)
+  static Eina_Bool _e_actions_act_##act##_go_mouse(E_Object * obj EINA_UNUSED, 
const char *params use, E_Binding_Event_Mouse_Button * ev EINA_UNUSED)
 
 #define ACT_GO_WHEEL(name)                                            \
   {                                                                   \
@@ -23,7 +23,7 @@
      if (act) act->func.go_wheel = _e_actions_act_##name##_go_wheel;  \
   }
 #define ACT_FN_GO_WHEEL(act, use) \
-  static void _e_actions_act_##act##_go_wheel(E_Object * obj EINA_UNUSED, 
const char *params use, E_Binding_Event_Wheel * ev EINA_UNUSED)
+  static Eina_Bool _e_actions_act_##act##_go_wheel(E_Object * obj EINA_UNUSED, 
const char *params use, E_Binding_Event_Wheel * ev EINA_UNUSED)
 
 #define ACT_GO_EDGE(name)                                           \
   {                                                                 \
@@ -63,7 +63,7 @@
      if (act) act->func.end_mouse = _e_actions_act_##name##_end_mouse;  \
   }
 #define ACT_FN_END_MOUSE(act, use) \
-  static void _e_actions_act_##act##_end_mouse(E_Object * obj EINA_UNUSED, 
const char *params use, E_Binding_Event_Mouse_Button * ev EINA_UNUSED)
+  static Eina_Bool _e_actions_act_##act##_end_mouse(E_Object * obj 
EINA_UNUSED, const char *params use, E_Binding_Event_Mouse_Button * ev 
EINA_UNUSED)
 
 #define ACT_END_KEY(name)                                           \
   {                                                                 \
@@ -103,9 +103,10 @@ ACT_FN_GO(window_move, EINA_UNUSED)
 ACT_FN_GO_MOUSE(window_move, EINA_UNUSED)
 {
    if (!obj) obj = E_OBJECT(e_client_focused_get());
-   if (!obj) return;
-   if (obj->type != E_CLIENT_TYPE) return;
+   if (!obj) return EINA_FALSE;
+   if (obj->type != E_CLIENT_TYPE) return EINA_FALSE;
    e_client_act_move_begin((E_Client *)obj, ev);
+   return EINA_TRUE;
 }
 
 ACT_FN_GO_SIGNAL(window_move, )
@@ -136,9 +137,10 @@ ACT_FN_END(window_move, EINA_UNUSED)
 ACT_FN_END_MOUSE(window_move, EINA_UNUSED)
 {
    if (!obj) obj = E_OBJECT(e_client_focused_get());
-   if (!obj) return;
-   if (obj->type != E_CLIENT_TYPE) return;
+   if (!obj) return EINA_FALSE;
+   if (obj->type != E_CLIENT_TYPE) return EINA_FALSE;
    e_client_act_move_end((E_Client *)obj, ev);
+   return EINA_TRUE;
 }
 
 ACT_FN_GO_KEY(window_move, EINA_UNUSED, EINA_UNUSED)
@@ -167,10 +169,11 @@ ACT_FN_GO(window_resize, EINA_UNUSED)
 ACT_FN_GO_MOUSE(window_resize, EINA_UNUSED)
 {
    if (!obj) obj = E_OBJECT(e_client_focused_get());
-   if (!obj) return;
-   if (obj->type != E_CLIENT_TYPE) return;
+   if (!obj) return EINA_FALSE;
+   if (obj->type != E_CLIENT_TYPE) return EINA_FALSE;
    if (!((E_Client *)obj)->lock_user_size)
      e_client_act_resize_begin((E_Client *)obj, ev);
+   return EINA_TRUE;
 }
 
 ACT_FN_GO_SIGNAL(window_resize, )
@@ -204,9 +207,10 @@ ACT_FN_END(window_resize, EINA_UNUSED)
 ACT_FN_END_MOUSE(window_resize, EINA_UNUSED)
 {
    if (!obj) obj = E_OBJECT(e_client_focused_get());
-   if (!obj) return;
-   if (obj->type != E_CLIENT_TYPE) return;
+   if (!obj) return EINA_FALSE;
+   if (obj->type != E_CLIENT_TYPE) return EINA_FALSE;
    e_client_act_resize_end((E_Client *)obj, ev);
+   return EINA_TRUE;
 }
 
 ACT_FN_GO_KEY(window_resize, EINA_UNUSED, EINA_UNUSED)
@@ -238,13 +242,14 @@ ACT_FN_GO(window_menu, EINA_UNUSED)
 ACT_FN_GO_MOUSE(window_menu, EINA_UNUSED)
 {
    if (!obj) obj = E_OBJECT(e_client_focused_get());
-   if (!obj) return;
+   if (!obj) return EINA_FALSE;
    if (obj->type != E_CLIENT_TYPE)
      {
         obj = E_OBJECT(e_client_focused_get());
-        if (!obj) return;
+        if (!obj) return EINA_FALSE;
      }
    e_client_act_menu_begin((E_Client *)obj, ev, 0);
+   return EINA_TRUE;
 }
 
 ACT_FN_GO_KEY(window_menu, EINA_UNUSED, EINA_UNUSED)
@@ -1909,31 +1914,24 @@ ACT_FN_GO(menu_show, )
 ACT_FN_GO_MOUSE(menu_show, )
 {
    E_Zone *zone;
+   E_Menu *m = NULL;
+   int x, y;
 
    /* menu is active - abort */
-   if (e_comp_util_kbd_grabbed() || e_comp_util_mouse_grabbed()) return;
+   if (e_comp_util_kbd_grabbed() || e_comp_util_mouse_grabbed()) return 
EINA_TRUE;
    zone = _e_actions_zone_get(obj);
-   if (zone)
-     {
-        if (params)
-          {
-             E_Menu *m = NULL;
-
-             m = _e_actions_menu_find(params);
-             if (m)
-               {
-                  int x, y;
-
-                  /* FIXME: this is a bit of a hack... setting m->c - bad hack 
*/
-                  m->zone = zone;
-                  x = ev->canvas.x;
-                  y = ev->canvas.y;
-                  e_menu_post_deactivate_callback_set(m, 
_e_actions_cb_menu_end, NULL);
-                  e_menu_activate_mouse(m, zone, x, y, 1, 1,
-                                        E_MENU_POP_DIRECTION_DOWN, 
ev->timestamp);
-               }
-          }
-     }
+   if (!zone) return EINA_TRUE;
+   if (!params) return EINA_TRUE;
+   m = _e_actions_menu_find(params);
+   if (!m) return EINA_TRUE;
+   /* FIXME: this is a bit of a hack... setting m->zone - bad hack */
+   m->zone = zone;
+   x = ev->canvas.x;
+   y = ev->canvas.y;
+   e_menu_post_deactivate_callback_set(m, _e_actions_cb_menu_end, NULL);
+   e_menu_activate_mouse(m, zone, x, y, 1, 1,
+                         E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+   return EINA_TRUE;
 }
 
 ACT_FN_GO_KEY(menu_show, , EINA_UNUSED)
@@ -2866,6 +2864,7 @@ ACT_FN_GO_KEY(delayed_action, , )
 ACT_FN_GO_MOUSE(delayed_action, )
 {
    _delayed_action_mouse_add(obj, params, ev);
+   return EINA_TRUE;
 }
 
 ACT_FN_END_KEY(delayed_action, )
@@ -2876,6 +2875,7 @@ ACT_FN_END_KEY(delayed_action, )
 ACT_FN_END_MOUSE(delayed_action, )
 {
    _delayed_action_mouse_del(obj, params, ev);
+   return EINA_TRUE;
 }
 
 ACT_FN_GO(dim_screen, EINA_UNUSED)
@@ -2956,7 +2956,7 @@ ACT_FN_GO_MOUSE(mouse_to_key, )
    };
    int modifiers = 0, mod = 0;
 
-   if ((!params) || (!params[0]) || (params[0] == '+')) return;
+   if ((!params) || (!params[0]) || (params[0] == '+')) return EINA_TRUE;
    for (p = params; p; p = nextp)
      {
         const char **m;
@@ -2975,7 +2975,7 @@ ACT_FN_GO_MOUSE(mouse_to_key, )
      key++;
    else
      key = params;
-   if (!key[0]) return;
+   if (!key[0]) return EINA_TRUE;
 
    mod |= (ECORE_EVENT_MODIFIER_SHIFT * !!(modifiers & 
E_BINDING_MODIFIER_SHIFT));
    mod |= (ECORE_EVENT_MODIFIER_CTRL * !!(modifiers & 
E_BINDING_MODIFIER_CTRL));
@@ -2984,6 +2984,7 @@ ACT_FN_GO_MOUSE(mouse_to_key, )
    mod |= (ECORE_EVENT_MODIFIER_ALTGR * !!(modifiers & 
E_BINDING_MODIFIER_ALTGR));
    e_comp_wl_input_keyboard_event_generate(key, mod, 0);
    e_comp_wl_input_keyboard_event_generate(key, mod, 1);
+   return EINA_TRUE;
 }
 #endif
 
diff --git a/src/bin/e_actions.h b/src/bin/e_actions.h
index 2b8fe80..66f6709 100644
--- a/src/bin/e_actions.h
+++ b/src/bin/e_actions.h
@@ -18,14 +18,14 @@ struct _E_Action
    struct
    {
       void (*go)(E_Object *obj, const char *params);
-      void (*go_mouse)(E_Object *obj, const char *params, 
E_Binding_Event_Mouse_Button *ev);
-      void (*go_wheel)(E_Object *obj, const char *params, 
E_Binding_Event_Wheel *ev);
+      Eina_Bool (*go_mouse)(E_Object *obj, const char *params, 
E_Binding_Event_Mouse_Button *ev);
+      Eina_Bool (*go_wheel)(E_Object *obj, const char *params, 
E_Binding_Event_Wheel *ev);
       void (*go_edge)(E_Object *obj, const char *params, E_Event_Zone_Edge 
*ev);
       void (*go_key)(E_Object *obj, const char *params, Ecore_Event_Key *ev);
       void (*go_signal)(E_Object *obj, const char *params, const char *sig, 
const char *src);
       void (*go_acpi)(E_Object *obj, const char *params, E_Event_Acpi *ev);
       void (*end)(E_Object *obj, const char *params);
-      void (*end_mouse)(E_Object *obj, const char *params, 
E_Binding_Event_Mouse_Button *ev);
+      Eina_Bool (*end_mouse)(E_Object *obj, const char *params, 
E_Binding_Event_Mouse_Button *ev);
       void (*end_key)(E_Object *obj, const char *params, Ecore_Event_Key *ev);
    } func;
 };
diff --git a/src/bin/e_bindings.c b/src/bin/e_bindings.c
index 9d294c1..e75b00d 100644
--- a/src/bin/e_bindings.c
+++ b/src/bin/e_bindings.c
@@ -423,10 +423,13 @@ E_API E_Action *
 e_bindings_mouse_button_find(E_Binding_Context ctxt, 
E_Binding_Event_Mouse_Button *ev, E_Binding_Mouse **bind_ret)
 {
    E_Binding_Mouse *binding;
-   Eina_List *l;
+   Eina_List *start = NULL, *l;
    E_Action *act = NULL;
 
-   EINA_LIST_FOREACH(mouse_bindings, l, binding)
+   if (bind_ret && *bind_ret)
+     start = eina_list_data_find_list(mouse_bindings, *bind_ret);
+   if (start) start = start->next;
+   EINA_LIST_FOREACH(start ?: mouse_bindings, l, binding)
      {
         if ((binding->button == (int)ev->button) &&
             ((binding->any_mod) || (binding->mod == ev->modifiers)))
@@ -446,17 +449,21 @@ E_API E_Action *
 e_bindings_mouse_down_event_handle(E_Binding_Context ctxt, E_Object *obj, 
E_Binding_Event_Mouse_Button *ev)
 {
    E_Action *act;
-   E_Binding_Mouse *binding;
+   E_Binding_Mouse *binding = NULL;
 
    if (bindings_disabled) return NULL;
-   act = e_bindings_mouse_button_find(ctxt, ev, &binding);
-   if (act)
+   while (1)
      {
+        act = e_bindings_mouse_button_find(ctxt, ev, &binding);
+        if (!act) break;
         if (act->func.go_mouse)
-          act->func.go_mouse(obj, binding->params, ev);
+          {
+             if (!act->func.go_mouse(obj, binding->params, ev))
+               continue;
+          }
         else if (act->func.go)
           act->func.go(obj, binding->params);
-        return act;
+        break;
      }
    return act;
 }
@@ -488,14 +495,18 @@ e_bindings_mouse_up_event_handle(E_Binding_Context ctxt, 
E_Object *obj, E_Bindin
    E_Binding_Mouse *binding;
 
    if (bindings_disabled) return NULL;
-   act = e_bindings_mouse_button_find(ctxt, ev, &binding);
-   if (act)
+   while (1)
      {
-        if (act->func.end_mouse)
-          act->func.end_mouse(obj, binding->params, ev);
-        else if (act->func.end)
-          act->func.end(obj, binding->params);
-        return act;
+        act = e_bindings_mouse_button_find(ctxt, ev, &binding);
+        if (!act) break;
+        if (act->func.go_mouse)
+          {
+             if (!act->func.go_mouse(obj, binding->params, ev))
+               continue;
+          }
+        else if (act->func.go)
+          act->func.go(obj, binding->params);
+        break;
      }
    return act;
 }
@@ -1171,10 +1182,13 @@ E_API E_Action *
 e_bindings_wheel_find(E_Binding_Context ctxt, E_Binding_Event_Wheel *ev, 
E_Binding_Wheel **bind_ret)
 {
    E_Binding_Wheel *binding;
-   Eina_List *l;
+   Eina_List *start = NULL, *l;
    E_Action *act = NULL;
 
-   EINA_LIST_FOREACH(wheel_bindings, l, binding)
+   if (bind_ret && *bind_ret)
+     start = eina_list_data_find_list(wheel_bindings, *bind_ret);
+   if (start) start = start->next;
+   EINA_LIST_FOREACH(start ?: wheel_bindings, l, binding)
      {
         if ((binding->direction == ev->direction) &&
             (((binding->z < 0) && (ev->z < 0)) || ((binding->z > 0) && (ev->z 
> 0))) &&
@@ -1198,14 +1212,18 @@ e_bindings_wheel_event_handle(E_Binding_Context ctxt, 
E_Object *obj, E_Binding_E
    E_Binding_Wheel *binding;
 
    if (bindings_disabled) return NULL;
-   act = e_bindings_wheel_find(ctxt, ev, &binding);
-   if (act)
+   while (1)
      {
+        act = e_bindings_wheel_find(ctxt, ev, &binding);
+        if (!act) break;
         if (act->func.go_wheel)
-          act->func.go_wheel(obj, binding->params, ev);
+          {
+             if (!act->func.go_wheel(obj, binding->params, ev))
+               continue;
+          }
         else if (act->func.go)
           act->func.go(obj, binding->params);
-        return act;
+        break;
      }
    return act;
 }
diff --git a/src/modules/clock/e_mod_main.c b/src/modules/clock/e_mod_main.c
index 37ce048..b2356a6 100644
--- a/src/modules/clock/e_mod_main.c
+++ b/src/modules/clock/e_mod_main.c
@@ -771,10 +771,11 @@ _e_mod_action_cb_key(E_Object *obj EINA_UNUSED, const 
char *params, Ecore_Event_
    _e_mod_action(params);
 }
 
-static void
+static Eina_Bool
 _e_mod_action_cb_mouse(E_Object *obj EINA_UNUSED, const char *params, 
E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
 {
    _e_mod_action(params);
+   return EINA_TRUE;
 }
 
 static Eina_Bool
diff --git a/src/modules/tiling/e_mod_tiling.c 
b/src/modules/tiling/e_mod_tiling.c
index 914d278..3b3565e 100644
--- a/src/modules/tiling/e_mod_tiling.c
+++ b/src/modules/tiling/e_mod_tiling.c
@@ -708,7 +708,7 @@ _e_mod_action_toggle_floating_cb(E_Object *obj EINA_UNUSED,
 
 static E_Client *_go_mouse_client = NULL;
 
-static void
+static Eina_Bool
 _e_mod_action_swap_window_go_mouse(E_Object *obj EINA_UNUSED,
                                    const char *params EINA_UNUSED,
                                    E_Binding_Event_Mouse_Button *ev 
EINA_UNUSED)
@@ -718,12 +718,13 @@ _e_mod_action_swap_window_go_mouse(E_Object *obj 
EINA_UNUSED,
    Client_Extra *extra = tiling_entry_func(ec);
 
    if (!extra || !extra->tiled)
-     return;
+     return EINA_FALSE;
 
    _go_mouse_client = ec;
+   return EINA_TRUE;
 }
 
-static void
+static Eina_Bool
 _e_mod_action_swap_window_end_mouse(E_Object *obj EINA_UNUSED,
                                     const char *params EINA_UNUSED,
                                     E_Binding_Event_Mouse_Button *ev 
EINA_UNUSED)
@@ -734,33 +735,34 @@ _e_mod_action_swap_window_end_mouse(E_Object *obj 
EINA_UNUSED,
    _go_mouse_client = NULL;
 
    if (!first_ec)
-     return;
+     return EINA_FALSE;
 
    Client_Extra *extra = tiling_entry_func(ec);
 
    if (!extra || !extra->tiled)
-     return;
+     return EINA_FALSE;
 
    /* XXX: Only support swap on the first desk for now. */
    if (ec->desk != first_ec->desk)
-     return;
+     return EINA_FALSE;
 
    Window_Tree *item, *first_item;
 
    item = tiling_window_tree_client_find(_G.tinfo->tree, ec);
 
    if (!item)
-     return;
+     return EINA_FALSE;
 
    first_item = tiling_window_tree_client_find(_G.tinfo->tree, first_ec);
 
    if (!first_item)
-     return;
+     return EINA_FALSE;
 
    item->client = first_ec;
    first_item->client = ec;
 
    _reapply_tree();
+   return EINA_TRUE;
 }
 
 static void
diff --git a/src/modules/winlist/e_mod_main.c b/src/modules/winlist/e_mod_main.c
index 2b17e34..bd2a3a3 100644
--- a/src/modules/winlist/e_mod_main.c
+++ b/src/modules/winlist/e_mod_main.c
@@ -3,7 +3,7 @@
 
 /* actual module specifics */
 static void _e_mod_action_winlist_cb(E_Object *obj, const char *params);
-static void _e_mod_action_winlist_mouse_cb(E_Object *obj, const char *params, 
E_Binding_Event_Mouse_Button *ev);
+static Eina_Bool _e_mod_action_winlist_mouse_cb(E_Object *obj, const char 
*params, E_Binding_Event_Mouse_Button *ev);
 static void _e_mod_action_winlist_key_cb(E_Object *obj, const char *params, 
Ecore_Event_Key *ev);
 static void _e_mod_action_winlist_edge_cb(E_Object *obj, const char *params, 
E_Event_Zone_Edge *ev);
 static void _e_mod_action_winlist_signal_cb(E_Object *obj, const char *params, 
const char *sig, const char *src);
@@ -106,7 +106,7 @@ e_modapi_save(E_Module *m EINA_UNUSED)
 }
 
 /* action callback */
-static void
+static Eina_Bool
 _e_mod_action_winlist_cb_helper(E_Object *obj EINA_UNUSED, const char *params, 
int modifiers, E_Winlist_Activate_Type type)
 {
    E_Zone *zone = NULL;
@@ -116,7 +116,7 @@ _e_mod_action_winlist_cb_helper(E_Object *obj EINA_UNUSED, 
const char *params, i
    Eina_Bool ok = EINA_TRUE;
 
    zone = e_zone_current_get();
-   if (!zone) return;
+   if (!zone) return EINA_FALSE;
    if (params)
      {
         if (!strcmp(params, "next"))
@@ -139,7 +139,7 @@ _e_mod_action_winlist_cb_helper(E_Object *obj EINA_UNUSED, 
const char *params, i
           udlr = 2;
         else if (!strcmp(params, "right"))
           udlr = 3;
-        else return;
+        else return EINA_FALSE;
      }
    else
      direction = 1;
@@ -147,9 +147,9 @@ _e_mod_action_winlist_cb_helper(E_Object *obj EINA_UNUSED, 
const char *params, i
      ok = !e_winlist_show(zone, filter);
    if (!ok)
      {
-        if (!type) return;
+        if (!type) return EINA_FALSE;
         e_winlist_modifiers_set(modifiers, type);
-        return;
+        return EINA_TRUE;
      }
    if (direction == 1)
      e_winlist_next();
@@ -157,6 +157,7 @@ _e_mod_action_winlist_cb_helper(E_Object *obj EINA_UNUSED, 
const char *params, i
      e_winlist_prev();
    else
      e_winlist_direction_select(zone, udlr);
+   return EINA_TRUE;
 }
 
 static void
@@ -165,10 +166,11 @@ _e_mod_action_winlist_cb(E_Object *obj, const char 
*params)
    _e_mod_action_winlist_cb_helper(obj, params, 0, 0);
 }
 
-static void
+static Eina_Bool
 _e_mod_action_winlist_mouse_cb(E_Object *obj, const char *params, 
E_Binding_Event_Mouse_Button *ev)
 {
-   _e_mod_action_winlist_cb_helper(obj, params, 
e_bindings_modifiers_to_ecore_convert(ev->modifiers), 
E_WINLIST_ACTIVATE_TYPE_MOUSE);
+   return _e_mod_action_winlist_cb_helper(obj, params,
+     e_bindings_modifiers_to_ecore_convert(ev->modifiers), 
E_WINLIST_ACTIVATE_TYPE_MOUSE);
 }
 
 static void

-- 


Reply via email to