summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <juyung.seo@samsung.com>2014-03-01 15:50:07 +0900
committerDaniel Juyung Seo <juyung.seo@samsung.com>2014-03-01 15:55:03 +0900
commit1c0b42d2664ea021b1f9e5abff0a9e0af22a74db (patch)
treef8a80830898d362a6fa4e9af95f20a8f03712487
parent74c0cea1ec69136e9c7111be7248744e9e704870 (diff)
downloadelementary-1c0b42d2664ea021b1f9e5abff0a9e0af22a74db.tar.gz
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.
-rw-r--r--src/lib/elm_macros.h3
-rw-r--r--src/lib/elm_widget.c18
2 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/elm_macros.h b/src/lib/elm_macros.h
index 906b8836f..176ef4742 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 20ce48f10..8a2a70b77 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;
- }
}
}