fix edge bindings to work if you add other bindings to corners other
authorCarsten Haitzler <raster@rasterman.com>
Mon, 30 Apr 2012 12:29:34 +0000 (12:29 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Mon, 30 Apr 2012 12:29:34 +0000 (12:29 +0000)
than edge flips.

SVN revision: 70558

src/bin/e_bindings.c
src/bin/e_bindings.h
src/bin/e_zone.c

index 2c084f0..f44f736 100644 (file)
@@ -532,6 +532,25 @@ e_bindings_edge_flippable_get(E_Zone_Edge edge)
    return EINA_FALSE;
 }
 
+EAPI Eina_Bool
+e_bindings_edge_non_flippable_get(E_Zone_Edge edge)
+{
+   E_Binding_Edge *bind;
+   Eina_List *l;
+
+   EINA_LIST_FOREACH(edge_bindings, l, bind)
+     {
+        if ((bind->edge == edge) && (bind->action))
+          {
+             if ((!strcmp(bind->action, "desk_flip_in_direction")) ||
+                 (!strcmp(bind->action, "desk_flip_by")))
+                continue;
+             return EINA_TRUE;
+          }
+     }
+   return EINA_FALSE;
+}
+
 EAPI E_Binding_Edge *
 e_bindings_edge_get(const char *action, E_Zone_Edge edge, Eina_Bool click)
 {
index a5e764d..afc649b 100644 (file)
@@ -125,6 +125,7 @@ EAPI E_Action   *e_bindings_key_up_event_find(E_Binding_Context ctxt, Ecore_Even
 
 EAPI void        e_bindings_edge_add(E_Binding_Context ctxt, E_Zone_Edge edge, E_Binding_Modifier mod, int any_mod, const char *action, const char *params, float delay);
 EAPI Eina_Bool   e_bindings_edge_flippable_get(E_Zone_Edge edge);
+EAPI Eina_Bool   e_bindings_edge_non_flippable_get(E_Zone_Edge edge);
 EAPI E_Binding_Edge *e_bindings_edge_get(const char *action, E_Zone_Edge edge, Eina_Bool click);
 EAPI void        e_bindings_edge_del(E_Binding_Context ctxt, E_Zone_Edge edge, E_Binding_Modifier mod, int any_mod, const char *action, const char *params, float delay);
 EAPI E_Action   *e_bindings_edge_in_event_handle(E_Binding_Context ctxt, E_Object *obj, E_Event_Zone_Edge *ev);
index 8572ee1..0a84b3e 100644 (file)
@@ -840,102 +840,53 @@ e_zone_edge_disable(void)
 EAPI void
 e_zone_edges_desk_flip_capable(E_Zone *zone, Eina_Bool l, Eina_Bool r, Eina_Bool t, Eina_Bool b)
 {
-   if (l)
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_LEFT))
-          {
-             if (zone->edge.left) ecore_x_window_show(zone->edge.left);
-          }
-     }
-   else
-     {
-        if (zone->edge.left) ecore_x_window_hide(zone->edge.left);
-     }
-   if (r)
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_RIGHT))
-          {
-             if (zone->edge.right) ecore_x_window_show(zone->edge.right);
-          }
-     }
-   else
-     {
-        if (zone->edge.right) ecore_x_window_hide(zone->edge.right);
-     }
-   if (t)
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_TOP))
-          {
-             if (zone->edge.top) ecore_x_window_show(zone->edge.top);
-          }
-     }
-   else
-     {
-        if (zone->edge.top) ecore_x_window_hide(zone->edge.top);
-     }
-   if (b)
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_BOTTOM))
-          {
-             if (zone->edge.bottom) ecore_x_window_show(zone->edge.bottom);
-          }
-     }
-   else
-     {
-        if (zone->edge.bottom) ecore_x_window_hide(zone->edge.bottom);
-     }
-   if ((!l) && (!t))
-     {
-        if (zone->corner.left_top) ecore_x_window_hide(zone->corner.left_top);
-        if (zone->corner.top_left) ecore_x_window_hide(zone->corner.top_left);
-     }
-   else
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_TOP_LEFT))
-          {
-             if (zone->corner.left_top) ecore_x_window_show(zone->corner.left_top);
-             if (zone->corner.top_left) ecore_x_window_show(zone->corner.top_left);
-          }
-     }
-   if ((!r) && (!t))
-     {
-        if (zone->corner.right_top) ecore_x_window_hide(zone->corner.right_top);
-        if (zone->corner.top_right) ecore_x_window_hide(zone->corner.top_right);
-     }
-   else
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_TOP_RIGHT))
-          {
-             if (zone->corner.right_top) ecore_x_window_show(zone->corner.right_top);
-             if (zone->corner.top_right) ecore_x_window_show(zone->corner.top_right);
-          }
-     }
-   if ((!l) && (!b))
-     {
-        if (zone->corner.left_bottom) ecore_x_window_hide(zone->corner.left_bottom);
-        if (zone->corner.bottom_left) ecore_x_window_hide(zone->corner.bottom_left);
-     }
-   else
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_BOTTOM_LEFT))
-          {
-             if (zone->corner.left_bottom) ecore_x_window_show(zone->corner.left_bottom);
-             if (zone->corner.bottom_left) ecore_x_window_show(zone->corner.bottom_left);
-          }
-     }
-   if ((!r) && (!b))
-     {
-        if (zone->corner.right_bottom) ecore_x_window_hide(zone->corner.right_bottom);
-        if (zone->corner.bottom_right) ecore_x_window_hide(zone->corner.bottom_right);
-     }
-   else
-     {
-        if (e_bindings_edge_flippable_get(E_ZONE_EDGE_BOTTOM_RIGHT))
-          {
-             if (zone->corner.right_bottom) ecore_x_window_show(zone->corner.right_bottom);
-             if (zone->corner.bottom_right) ecore_x_window_show(zone->corner.bottom_right);
-          }
-     }
+#define NEED_FLIP_EDGE(x) \
+   (e_bindings_edge_flippable_get(x) || e_bindings_edge_non_flippable_get(x))
+#define NEED_EDGE(x) \
+   (e_bindings_edge_non_flippable_get(x))
+#define CHECK_EDGE(v, ed, win) \
+   do { \
+      if (v) { \
+         if (NEED_FLIP_EDGE(ed)) { if (zone->edge.win) ecore_x_window_show(zone->edge.win); } \
+         else if (zone->edge.win) ecore_x_window_hide(zone->edge.win); \
+      } \
+      else { \
+         if (NEED_EDGE(ed)) { if (zone->edge.win) ecore_x_window_show(zone->edge.win); } \
+         else if (zone->edge.win) ecore_x_window_hide(zone->edge.win); \
+      } \
+   } while (0)
+
+   CHECK_EDGE(l, E_ZONE_EDGE_LEFT, left);
+   CHECK_EDGE(r, E_ZONE_EDGE_RIGHT, right);
+   CHECK_EDGE(t, E_ZONE_EDGE_TOP, top);
+   CHECK_EDGE(b, E_ZONE_EDGE_BOTTOM, bottom);
+
+#define CHECK_CORNER(v1, v2, ed, win1, win2) \
+   if ((!v1) && (!v2)) { \
+      if (NEED_EDGE(ed)) { \
+         if (zone->corner.win1) ecore_x_window_show(zone->corner.win1); \
+         if (zone->corner.win2) ecore_x_window_show(zone->corner.win2); \
+      } \
+      else { \
+         if (zone->corner.win1) ecore_x_window_hide(zone->corner.win1); \
+         if (zone->corner.win2) ecore_x_window_hide(zone->corner.win2); \
+      } \
+   } \
+   else { \
+      if (NEED_FLIP_EDGE(ed)) { \
+         if (zone->corner.win1) ecore_x_window_show(zone->corner.win1); \
+         if (zone->corner.win2) ecore_x_window_show(zone->corner.win2); \
+      } \
+      else { \
+         if (zone->corner.win1) ecore_x_window_hide(zone->corner.win1); \
+         if (zone->corner.win2) ecore_x_window_hide(zone->corner.win2); \
+      } \
+   }
+
+   CHECK_CORNER(l, t, E_ZONE_EDGE_TOP_LEFT, left_top, top_left);
+   CHECK_CORNER(r, t, E_ZONE_EDGE_TOP_RIGHT, right_top, top_right);
+   CHECK_CORNER(l, b, E_ZONE_EDGE_BOTTOM_LEFT, left_bottom, bottom_left);
+   CHECK_CORNER(r, b, E_ZONE_EDGE_BOTTOM_RIGHT, right_bottom, bottom_right);
 }
 
 EAPI Eina_Bool