seoz pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=1c0b42d2664ea021b1f9e5abff0a9e0af22a74db

commit 1c0b42d2664ea021b1f9e5abff0a9e0af22a74db
Author: Daniel Juyung Seo <[email protected]>
Date:   Sat Mar 1 15:50:07 2014 +0900

    focus: Refactor mouse tracking code for focus.
    
    - Reduced the if statement depth.
    - Introduced new macro ELM_RECTS_POINT_OUT that checks if the point(xx,
    yy) stays out of the rectangle(x, y, w, h) area.
---
 src/lib/elm_macros.h |  3 +++
 src/lib/elm_widget.c | 18 ++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/lib/elm_macros.h b/src/lib/elm_macros.h
index 906b883..176ef47 100644
--- a/src/lib/elm_macros.h
+++ b/src/lib/elm_macros.h
@@ -1,3 +1,6 @@
 /* handy macros */
 #define ELM_RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) 
&& ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
 #define ELM_PI 3.14159265358979323846
+
+// checks if the point(xx, yy) stays out of the rectangle(x, y, w, h) area.
+#define ELM_RECTS_POINT_OUT(x, y, w, h, xx, yy) (((xx) < (x)) || ((yy) < (y)) 
|| ((xx) > ((x) + (w))) || ((yy) > ((y) + (h))))
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 20ce48f..8a2a70b 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -237,18 +237,16 @@ _obj_mouse_move(void *data,
 {
    ELM_WIDGET_DATA_GET(data, sd);
    Evas_Event_Mouse_Move *ev = event_info;
-   if (sd->still_in)
+   if (!sd->still_in) return;
+
+   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+     sd->still_in = EINA_FALSE;
+   else
      {
-        if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+        Evas_Coord x, y, w, h;
+        evas_object_geometry_get(obj, &x, &y, &w, &h);
+        if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, 
ev->cur.canvas.y))
           sd->still_in = EINA_FALSE;
-        else
-          {
-             Evas_Coord x, y, w, h;
-             evas_object_geometry_get(obj, &x, &y, &w, &h);
-             if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
-                 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + 
h)))
-               sd->still_in = EINA_FALSE;
-          }
      }
 }
 

-- 


Reply via email to