On Dec 20, 2007 12:36 PM, Nathan Ingersoll <[EMAIL PROTECTED]> wrote:
> I think that there was some consensus that the API to feed the objects
> events would be a good addition, but I don't think anyone got around
> to implementing it.

Last days I've tried to come up with such API, in
src/lib/evas_events.c. I did two
things mainly (1) refactor a little bit the code there; (2) add the
"public feeders" for mouse_up and mouse_down. Even if we don't get a
consensus about things in patch (2), I think after some review the
patch (1) is benefical. So I can commit patch (1) if it's OK. Please,
if any of you understand about src/lib/evas_events, review this patch
:-)


And now follows a long story (which might be of Dave's interest)... ;-)

My main motivation for giving a try doing this public API to "feeding"
events directly into Evas_Objects was the same as Dave, quoting him:

Dave wrote:
> I have a trasparent evas_object (big as all the container) used
> to grab mouse events. When you click & drag the  mouse I make the
> container scroll. The objects of the list also need mouse events
> so I used evas_object_repeat_events_set(cont->grabber, TRUE);
> to pass the mouse events.
>
> The problem is that I want to 'repeat' the events only when is not
> a dragging operation.
> In the grabber mouse,down callback I need to stop the propagation
> of the event to the object below...

Here's how I solved this once:

Python-etk binding has a List widget implementation (which need a lot
of "love" yet but works) to serve as example of creating new widgets
directly in Python. The renderers in the list (Edje objects) that
follow a special convention, they must have hit areas but don't use
the mouse events. The List itself (actually the "visible row") will
listen to these mouse events and dispatch accordingly.

In the end, an Edje renderer you just have to implement those methods
pressed(), clicked(), unpressed() which pass the "hit area" (the part)
as argument. So you can use your programs and process them correctly
(e.g.: if its a click in the part "button_area", emit the
"button_clicked" signal).

Notice: I can do things like "pressed" / "unpressed", that behaves
differrently for a non-kinetic-like list. For instance, if my row has
a text and a button, if I press the button [it will call pressed() in
my renderer] and move up up up, it will interpret this not as click,
but as a drag and call unpressed() properly, even if I didn't
unpressed the _mouse_ button. This allows you use sensitive areas to
drag.

But I'm having hard time figuring out something like this behaviour
being implemented with the "feeders" or an solution like "stop the
event processing if we return 0".

So, assuming that we have all the feeders (I can finish the missing
ones if people consider them worthy to have), how to reproduce this
pressed"/"unpressed"/"clicked" in a kinetic list? Ideas?

We could feed a MOUSE_OUT event to do that "unpressed" thing, but it's
a little strange since the mouse won't be OUT. And I'm not sure
whether DOWN/UP (in Edje) keep states and stuff like that. So we would
need to call UP too, but this can't trigger a CLICK.


Cheers,
  Caio Marcelo
From e008ce0b388e533f08f70f3a7699a114610cbe12 Mon Sep 17 00:00:00 2001
From: Caio Marcelo de Oliveira Filho <[EMAIL PROTECTED]>
Date: Fri, 4 Jan 2008 18:35:23 -0300
Subject: [PATCH] evas_events cleaning up, part 1

My focus is in the end have a good way to "feed" specific Evas_Objects with events, as previous
discussed by the folks in the mailing list.

- Extracting the functions that fill Evas_Event structures, this avoided a bit of repetition.
- Separating some functions to make easy creating public API event feeders per object.
---
 src/lib/canvas/evas_events.c |  520 +++++++++++++++++++-----------------------
 1 files changed, 236 insertions(+), 284 deletions(-)

diff --git a/src/lib/canvas/evas_events.c b/src/lib/canvas/evas_events.c
index af853e2..ba9bceb 100644
--- a/src/lib/canvas/evas_events.c
+++ b/src/lib/canvas/evas_events.c
@@ -10,7 +10,7 @@ evas_event_passes_through(Evas_Object *obj)
    if (obj->smart.parent)
      {
 	int par_pass;
-	
+
 	par_pass = evas_event_passes_through(obj->smart.parent);
 	obj->parent_cache_valid = 1;
 	obj->parent_pass_events = par_pass;
@@ -20,59 +20,72 @@ evas_event_passes_through(Evas_Object *obj)
 }
 
 static Evas_List *
-_evas_event_object_list_in_get(Evas *e, Evas_List *in, Evas_Object_List *list, Evas_Object *stop, int x, int y, int *no_rep)
+_evas_event_object_list_in_get(Evas *e, Evas_List *in, Evas_Object_List *list, Evas_Object *stop, int x, int y, int *no_rep);
+
+static Evas_List *
+_evas_event_object_list_in_get_by_object(Evas *e, Evas_List *in, Evas_Object *obj, Evas_Object *stop, int x, int y, int *no_rep)
 {
-   Evas_Object_List *l;
+   if (obj == stop)
+     {
+	*no_rep = 1;
+	return in;
+     }
 
-   if (!list) return in;
-   for (l = list->last; l; l = l->prev)
+   /* In all this cases an object (and its possible smart children)
+      is not suitable for receiving the event. */
+   if ((evas_event_passes_through(obj)) ||
+       (!obj->cur.visible) ||
+       (obj->delete_me) ||
+       (obj->clip.clipees) ||
+       (!evas_object_clippers_is_visible(obj)))
+     return in;
+
+   if (obj->smart.smart)
      {
-	Evas_Object *obj;
-	
-	obj = (Evas_Object *)l;
-	if (obj == stop)
+	int this_no_rep = 0;
+	in = _evas_event_object_list_in_get(e, in,
+					    obj->smart.contained,
+					    stop, x, y, &this_no_rep);
+	if (this_no_rep)
 	  {
 	     *no_rep = 1;
 	     return in;
 	  }
-	if (!evas_event_passes_through(obj))
+     }
+   else
+     {
+	if (evas_object_is_in_output_rect(obj, x, y, 1, 1) &&
+	    ((!obj->precise_is_inside) ||
+	     (evas_object_is_inside(obj, x, y))))
 	  {
-	     if ((obj->cur.visible) && (obj->delete_me == 0) &&
-		 (!obj->clip.clipees) &&
-		 (evas_object_clippers_is_visible(obj)))
+	     in = evas_list_append(in, obj);
+	     if (!obj->repeat_events)
 	       {
-		  if (obj->smart.smart)
-		    {
-		       int norep;
-		       
-		       norep = 0;
-		       in = _evas_event_object_list_in_get(e, in,
-							   obj->smart.contained,
-							   stop, x, y, &norep);
-		       if (norep)
-			 {
-			    *no_rep = 1;
-			    return in;
-			 }
-		    }
-		  else
-		    {
-		       if (evas_object_is_in_output_rect(obj, x, y, 1, 1) &&
-		           ((!obj->precise_is_inside) ||
-			    (evas_object_is_inside(obj, x, y))))
-			 {
-			    in = evas_list_append(in, obj);
-			    if (!obj->repeat_events)
-			      {
-				 *no_rep = 1;
-				 return in;
-			      }
-			 }
-		    }
+		  *no_rep = 1;
+		  return in;
 	       }
 	  }
      }
+
+   return in;
+}
+
+static Evas_List *
+_evas_event_object_list_in_get(Evas *e, Evas_List *in, Evas_Object_List *list, Evas_Object *stop, int x, int y, int *no_rep)
+{
+   Evas_Object_List *l;
    *no_rep = 0;
+
+   if (!list) return in;
+   for (l = list->last; l; l = l->prev)
+     {
+	Evas_Object *obj = (Evas_Object *)l;
+	in = _evas_event_object_list_in_get_by_object(e, in, obj, stop,
+						      x, y, no_rep);
+	if (*no_rep)
+	  return in;
+     }
+
    return in;
 }
 
@@ -107,6 +120,156 @@ evas_event_list_copy(Evas_List *list)
      new_l = evas_list_append(new_l, l->data);
    return new_l;
 }
+
+/**
+ * @internal
+ * Feeds an Evas_Object with a MOUSE_DOWN event.
+ */
+static void
+_evas_object_event_feed_mouse_down(Evas_Object *obj, Evas *e, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data)
+{
+   Evas_Event_Mouse_Down ev;
+
+   ev.button = b;
+   ev.output.x = e->pointer.x;
+   ev.output.y = e->pointer.y;
+   ev.canvas.x = e->pointer.x;
+   ev.canvas.y = e->pointer.y;
+   ev.data = (void *)data;
+   ev.modifiers = &(e->modifiers);
+   ev.locks = &(e->locks);
+   ev.flags = flags;
+   ev.timestamp = timestamp;
+
+   if (e->events_frozen <= 0)
+     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_DOWN, &ev);
+}
+
+/**
+ * @internal
+ * Feeds an Evas_Object with a MOUSE_UP event.
+ */
+static void
+_evas_object_event_feed_mouse_up(Evas_Object *obj, Evas *e, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data)
+{
+   Evas_Event_Mouse_Up ev;
+
+   ev.button = b;
+   ev.output.x = e->pointer.x;
+   ev.output.y = e->pointer.y;
+   ev.canvas.x = e->pointer.x;
+   ev.canvas.y = e->pointer.y;
+   ev.data = (void *)data;
+   ev.modifiers = &(e->modifiers);
+   ev.locks = &(e->locks);
+   ev.flags = flags;
+   ev.timestamp = timestamp;
+
+   if (e->events_frozen <= 0)
+     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_UP, &ev);
+}
+
+/**
+ * @internal
+ * Feeds an Evas_Object with a MOUSE_OUT event.
+ */
+static void
+_evas_object_event_feed_mouse_out(Evas_Object *obj, Evas *e, unsigned int timestamp, const void *data)
+{
+   Evas_Event_Mouse_Out ev;
+
+   obj->mouse_in = 0;
+   ev.buttons = e->pointer.button;
+   ev.output.x = e->pointer.x;
+   ev.output.y = e->pointer.y;
+   ev.canvas.x = e->pointer.x;
+   ev.canvas.y = e->pointer.y;
+   ev.data = (void *)data;
+   ev.modifiers = &(e->modifiers);
+   ev.locks = &(e->locks);
+   ev.timestamp = timestamp;
+
+   if (e->events_frozen <= 0)
+     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
+}
+
+/**
+ * @internal
+ * Feeds an Evas_Object with a MOUSE_IN event.
+ */
+static void
+_evas_object_event_feed_mouse_in(Evas_Object *obj, Evas *e, unsigned int timestamp, const void *data)
+{
+   Evas_Event_Mouse_In ev;
+
+   obj->mouse_in = 1;
+   ev.buttons = e->pointer.button;
+   ev.output.x = e->pointer.x;
+   ev.output.y = e->pointer.y;
+   ev.canvas.x = e->pointer.x;
+   ev.canvas.y = e->pointer.y;
+   ev.data = (void *)data;
+   ev.modifiers = &(e->modifiers);
+   ev.locks = &(e->locks);
+   ev.timestamp = timestamp;
+
+   if (e->events_frozen <= 0)
+     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_IN, &ev);
+}
+
+/**
+ * @internal
+ * Feeds an Evas_Object with a MOUSE_WHEEL event.
+ */
+static void
+_evas_object_event_feed_mouse_wheel(Evas_Object *obj, Evas *e, int direction, int z, unsigned int timestamp, const void *data)
+{
+   Evas_Event_Mouse_Wheel ev;
+
+   ev.direction = direction;
+   ev.z = z;
+   ev.output.x = e->pointer.x;
+   ev.output.y = e->pointer.y;
+   ev.canvas.x = e->pointer.x;
+   ev.canvas.y = e->pointer.y;
+   ev.data = (void *) data;
+   ev.modifiers = &(e->modifiers);
+   ev.locks = &(e->locks);
+   ev.timestamp = timestamp;
+
+   if (e->events_frozen <= 0)
+     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_WHEEL, &ev);
+}
+
+/**
+ * @internal
+ * Feeds an Evas_Object with a MOUSE_MOVE event.
+ */
+static void
+_evas_object_event_feed_mouse_move(Evas_Object *obj, Evas *e, int px, int py, unsigned int timestamp, const void *data)
+{
+   Evas_Event_Mouse_Move ev;
+
+   ev.buttons = e->pointer.button;
+   ev.cur.output.x = e->pointer.x;
+   ev.cur.output.y = e->pointer.y;
+   ev.cur.canvas.x = e->pointer.x;
+   ev.cur.canvas.y = e->pointer.y;
+   ev.prev.output.x = px;
+   ev.prev.output.y = py;
+   ev.prev.canvas.x = px;
+   ev.prev.canvas.y = py;
+   ev.data = (void *)data;
+   ev.modifiers = &(e->modifiers);
+   ev.locks = &(e->locks);
+   ev.timestamp = timestamp;
+
+   /* XXX: Put this if before? */
+   if (e->events_frozen <= 0)
+     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_MOVE, &ev);
+}
+
+
 /* public functions */
 
 /**
@@ -216,6 +379,12 @@ evas_event_freeze_get(Evas *e)
 }
 
 /**
+ * @defgroup Evas_Event_Feed_Group Evas Event Feed Functions
+ *
+ * Functions that are used to feed events in a canvas. Used by the engines.
+ */
+
+/**
  * To be documented.
  *
  * FIXME: To be fixed.
@@ -241,30 +410,14 @@ evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags, unsigned int
    copy = evas_event_list_copy(e->pointer.object.in);
    for (l = copy; l; l = l->next)
      {
-	Evas_Object *obj;
-	Evas_Event_Mouse_Down ev;
+	Evas_Object *obj = l->data;
 
-	obj = l->data;
 	if (obj->pointer_mode != EVAS_OBJECT_POINTER_MODE_NOGRAB)
 	  {
 	     obj->mouse_grabbed++;
 	     e->pointer.mouse_grabbed++;
 	  }
-
-	ev.button = b;
-	ev.output.x = e->pointer.x;
-	ev.output.y = e->pointer.y;
-	ev.canvas.x = e->pointer.x;
-	ev.canvas.y = e->pointer.y;
-////	ev.canvas.x = e->pointer.canvas_x;
-////	ev.canvas.y = e->pointer.canvas_y;
-	ev.data = (void *)data;
-	ev.modifiers = &(e->modifiers);
-	ev.locks = &(e->locks);
-	ev.flags = flags;
-	ev.timestamp = timestamp;
-	if (e->events_frozen <= 0)
-	  evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_DOWN, &ev);
+	_evas_object_event_feed_mouse_down(obj, e, b, flags, timestamp, data);
 	if (e->delete_me) break;
      }
    if (copy) copy = evas_list_free(copy);
@@ -293,13 +446,12 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t
 
    if (e->events_frozen > 0) return;
    e->last_timestamp = timestamp;
-   
+
    _evas_walk(e);
    copy = evas_event_list_copy(e->pointer.object.in);
    for (l = copy; l; l = l->next)
      {
 	Evas_Object *obj;
-	Evas_Event_Mouse_Up ev;
 
 	obj = l->data;
 	if ((obj->pointer_mode != EVAS_OBJECT_POINTER_MODE_NOGRAB) &&
@@ -308,20 +460,7 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t
 	     obj->mouse_grabbed--;
 	     e->pointer.mouse_grabbed--;
 	  }
-	ev.button = b;
-	ev.output.x = e->pointer.x;
-	ev.output.y = e->pointer.y;
-	ev.canvas.x = e->pointer.x;
-	ev.canvas.y = e->pointer.y;
-////	ev.canvas.x = e->pointer.canvas_x;
-////	ev.canvas.y = e->pointer.canvas_y;
-	ev.data = (void *)data;
-	ev.modifiers = &(e->modifiers);
-	ev.locks = &(e->locks);
-	ev.flags = flags;
-	ev.timestamp = timestamp;
-	if (e->events_frozen <= 0)
-	  evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_UP, &ev);
+	_evas_object_event_feed_mouse_up(obj, e, b, flags, timestamp, data);
 	if (e->delete_me) break;
      }
    if (copy) copy = evas_list_free(copy);
@@ -337,29 +476,11 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t
 	copy = evas_event_list_copy(e->pointer.object.in);
 	for (l = copy; l; l = l->next)
 	  {
-	     Evas_Object *obj;
+	     Evas_Object *obj = l->data;
+
+	     if ((!evas_list_find(ins, obj)) || (!e->pointer.inside))
+		  _evas_object_event_feed_mouse_out(obj, e, timestamp, data);
 
-	     obj = l->data;
-	     if ((!evas_list_find(ins, obj)) ||
-		 (!e->pointer.inside))
-	       {
-		  Evas_Event_Mouse_Out ev;
-
-		  obj->mouse_in = 0;
-		  ev.buttons = e->pointer.button;
-		  ev.output.x = e->pointer.x;
-		  ev.output.y = e->pointer.y;
-		  ev.canvas.x = e->pointer.x;
-		  ev.canvas.y = e->pointer.y;
-////		  ev.canvas.x = e->pointer.canvas_x;
-////		  ev.canvas.y = e->pointer.canvas_y;
-		  ev.data = (void *)data;
-		  ev.modifiers = &(e->modifiers);
-		  ev.locks = &(e->locks);
-		  ev.timestamp = timestamp;
-		  if (e->events_frozen <= 0)
-		    evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
-	       }
 	     if (e->delete_me) break;
 	  }
 	if (copy) copy = evas_list_free(copy);
@@ -367,29 +488,10 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t
 	  {
 	     for (l = ins; l; l = l->next)
 	       {
-		  Evas_Object *obj;
-
-		  obj = l->data;
+		  Evas_Object *obj = l->data;
 
 		  if (!evas_list_find(e->pointer.object.in, obj))
-		    {
-		       Evas_Event_Mouse_In ev;
-
-		       obj->mouse_in = 1;
-		       ev.buttons = e->pointer.button;
-		       ev.output.x = e->pointer.x;
-		       ev.output.y = e->pointer.y;
-		       ev.canvas.x = e->pointer.x;
-		       ev.canvas.y = e->pointer.y;
-////		       ev.canvas.x = e->pointer.canvas_x;
-////		       ev.canvas.y = e->pointer.canvas_y;
-		       ev.data = (void *)data;
-		       ev.modifiers = &(e->modifiers);
-		       ev.locks = &(e->locks);
-		       ev.timestamp = timestamp;
-		       if (e->events_frozen <= 0)
-			 evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_IN, &ev);
-		    }
+		       _evas_object_event_feed_mouse_in(obj, e, timestamp, data);
 		  if (e->delete_me) break;
 	       }
 	  }
@@ -436,26 +538,12 @@ evas_event_feed_mouse_wheel(Evas *e, int direction, int z, unsigned int timestam
 
    _evas_walk(e);
    copy = evas_event_list_copy(e->pointer.object.in);
-   
+
    for (l = copy; l; l = l->next)
      {
-	Evas_Event_Mouse_Wheel ev;
 	Evas_Object *obj = l->data;
-	
-	ev.direction = direction;
-	ev.z = z;
-	ev.output.x = e->pointer.x;
-	ev.output.y = e->pointer.y;
-	ev.canvas.x = e->pointer.x;
-	ev.canvas.y = e->pointer.y;
-////	ev.canvas.x = e->pointer.canvas_x;
-////	ev.canvas.y = e->pointer.canvas_y;
-	ev.data = (void *) data;
-	ev.modifiers = &(e->modifiers);
-	ev.locks = &(e->locks);
-	ev.timestamp = timestamp;
-	if (e->events_frozen <= 0)
-	  evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_WHEEL, &ev);
+	_evas_object_event_feed_mouse_wheel(obj, e, direction, z,
+					    timestamp, data);
 	if (e->delete_me) break;
      }
    if (copy) copy = evas_list_free(copy);
@@ -473,7 +561,6 @@ EAPI void
 evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const void *data)
 {
    int px, py;
-////   Evas_Coord pcx, pcy;
 
    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
    return;
@@ -481,18 +568,13 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const
 
    px = e->pointer.x;
    py = e->pointer.y;
-////   pcx = e->pointer.canvas_x;
-////   pcy = e->pointer.canvas_y;
 
    if (e->events_frozen > 0) return;
    e->last_timestamp = timestamp;
 
    e->pointer.x = x;
    e->pointer.y = y;
-////   e->pointer.canvas_x = x;
-////   e->pointer.canvas_y = y;
-////   e->pointer.canvas_x = evas_coord_screen_x_to_world(e, x);
-////   e->pointer.canvas_y = evas_coord_screen_y_to_world(e, y);
+
    if ((!e->pointer.inside) && (e->pointer.mouse_grabbed == 0)) return;
    _evas_walk(e);
    /* if our mouse button is grabbed to any objects */
@@ -514,29 +596,7 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const
 		 (!obj->clip.clipees))
 	       {
 		  if ((px != x) || (py != y))
-		    {
-		       Evas_Event_Mouse_Move ev;
-
-		       ev.buttons = e->pointer.button;
-		       ev.cur.output.x = e->pointer.x;
-		       ev.cur.output.y = e->pointer.y;
-		       ev.cur.canvas.x = e->pointer.x;
-		       ev.cur.canvas.y = e->pointer.y;
-////		       ev.cur.canvas.x = e->pointer.canvas_x;
-////		       ev.cur.canvas.y = e->pointer.canvas_y;
-		       ev.prev.output.x = px;
-		       ev.prev.output.y = py;
-		       ev.prev.canvas.x = px;
-		       ev.prev.canvas.y = py;
-////		       ev.prev.canvas.x = pcx;
-////		       ev.prev.canvas.y = pcy;
-		       ev.data = (void *)data;
-		       ev.modifiers = &(e->modifiers);
-		       ev.locks = &(e->locks);
-		       ev.timestamp = timestamp;
-		       if (e->events_frozen <= 0)
-			 evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_MOVE, &ev);
-		    }
+		    _evas_object_event_feed_mouse_move(obj, e, px, py, timestamp, data);
 	       }
 	     else
 	       outs = evas_list_append(outs, obj);
@@ -552,24 +612,7 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const
 	     if ((!obj->mouse_grabbed) && (!e->delete_me))
 	       {
 		  e->pointer.object.in = evas_list_remove(e->pointer.object.in, obj);
-		    {
-		       Evas_Event_Mouse_Out ev;
-
-		       obj->mouse_in = 0;
-		       ev.buttons = e->pointer.button;
-		       ev.output.x = e->pointer.x;
-		       ev.output.y = e->pointer.y;
-		       ev.canvas.x = e->pointer.x;
-		       ev.canvas.y = e->pointer.y;
-////		       ev.canvas.x = e->pointer.canvas_x;
-////		       ev.canvas.y = e->pointer.canvas_y;
-		       ev.data = (void *)data;
-		       ev.modifiers = &(e->modifiers);
-		       ev.locks = &(e->locks);
-		       ev.timestamp = timestamp;
-		       if (e->events_frozen <= 0)
-			 evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
-		    }
+		  _evas_object_event_feed_mouse_out(obj, e, timestamp, data);
 	       }
 	  }
      }
@@ -601,49 +644,12 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const
 		  (evas_object_is_inside(obj, x, y))))
 	       {
 		  if ((px != x) || (py != y))
-		    {
-		       Evas_Event_Mouse_Move ev;
-
-		       ev.buttons = e->pointer.button;
-		       ev.cur.output.x = e->pointer.x;
-		       ev.cur.output.y = e->pointer.y;
-		       ev.cur.canvas.x = e->pointer.x;
-		       ev.cur.canvas.y = e->pointer.y;
-////		       ev.cur.canvas.x = e->pointer.canvas_x;
-////		       ev.cur.canvas.y = e->pointer.canvas_y;
-		       ev.prev.output.x = px;
-		       ev.prev.output.y = py;
-		       ev.prev.canvas.x = px;
-		       ev.prev.canvas.y = py;
-////		       ev.prev.canvas.x = pcx;
-////		       ev.prev.canvas.y = pcy;
-		       ev.data = (void *)data;
-		       ev.modifiers = &(e->modifiers);
-		       ev.locks = &(e->locks);
-		       ev.timestamp = timestamp;
-		       if (e->events_frozen <= 0)
-			 evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_MOVE, &ev);
-		    }
+		    _evas_object_event_feed_mouse_move(obj, e, px, py, timestamp, data);
 	       }
 	     /* otherwise it has left the object */
 	     else
 	       {
-		  Evas_Event_Mouse_Out ev;
-
-		  obj->mouse_in = 0;
-		  ev.buttons = e->pointer.button;
-		  ev.output.x = e->pointer.x;
-		  ev.output.y = e->pointer.y;
-		  ev.canvas.x = e->pointer.x;
-		  ev.canvas.y = e->pointer.y;
-////		  ev.canvas.x = e->pointer.canvas_x;
-////		  ev.canvas.y = e->pointer.canvas_y;
-		  ev.data = (void *)data;
-		  ev.modifiers = &(e->modifiers);
-		  ev.locks = &(e->locks);
-		  ev.timestamp = timestamp;
-		  if (e->events_frozen <= 0)
-		    evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
+		  _evas_object_event_feed_mouse_out(obj, e, timestamp, data);
 	       }
 	     if (e->delete_me) break;
 	  }
@@ -651,29 +657,12 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const
 	/* go thru our current list of ins */
 	for (l = ins; l; l = l->next)
 	  {
-	     Evas_Object *obj;
+	     Evas_Object *obj = l->data;
 
-	     obj = l->data;
 	     /* if its not in the old list of ins send an enter event */
 	     if (!evas_list_find(e->pointer.object.in, obj))
-	       {
-		  Evas_Event_Mouse_In ev;
-
-		  obj->mouse_in = 1;
-		  ev.buttons = e->pointer.button;
-		  ev.output.x = e->pointer.x;
-		  ev.output.y = e->pointer.y;
-		  ev.canvas.x = e->pointer.x;
-		  ev.canvas.y = e->pointer.y;
-////		  ev.canvas.x = e->pointer.canvas_x;
-////		  ev.canvas.y = e->pointer.canvas_y;
-		  ev.data = (void *)data;
-		  ev.modifiers = &(e->modifiers);
-		  ev.locks = &(e->locks);
-		  ev.timestamp = timestamp;
-		  if (e->events_frozen <= 0)
-		    evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_IN, &ev);
-	       }
+	       _evas_object_event_feed_mouse_in(obj, e, timestamp, data);
+
 	     if (e->delete_me) break;
 	  }
 	/* free our old list of ins */
@@ -711,29 +700,11 @@ evas_event_feed_mouse_in(Evas *e, unsigned int timestamp, const void *data)
    ins = evas_event_objects_event_list(e, NULL, e->pointer.x, e->pointer.y);
    for (l = ins; l; l = l->next)
      {
-	Evas_Object *obj;
-
-	obj = l->data;
+	Evas_Object *obj = l->data;
 
 	if (!evas_list_find(e->pointer.object.in, obj))
-	  {
-	     Evas_Event_Mouse_In ev;
-
-	     obj->mouse_in = 1;
-	     ev.buttons = e->pointer.button;
-	     ev.output.x = e->pointer.x;
-	     ev.output.y = e->pointer.y;
-	     ev.canvas.x = e->pointer.x;
-	     ev.canvas.y = e->pointer.y;
-////	     ev.canvas.x = e->pointer.canvas_x;
-////	     ev.canvas.y = e->pointer.canvas_y;
-	     ev.data = (void *)data;
-	     ev.modifiers = &(e->modifiers);
-	     ev.locks = &(e->locks);
-	     ev.timestamp = timestamp;
-	     if (e->events_frozen <= 0)
-	       evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_IN, &ev);
-	  }
+	  _evas_object_event_feed_mouse_in(obj, e, timestamp, data);
+
 	if (e->delete_me) break;
      }
    /* free our old list of ins */
@@ -771,27 +742,8 @@ evas_event_feed_mouse_out(Evas *e, unsigned int timestamp, const void *data)
 	copy = evas_event_list_copy(e->pointer.object.in);
 	for (l = copy; l; l = l->next)
 	  {
-	     Evas_Object *obj;
-
-	     obj = l->data;
-	       {
-		  Evas_Event_Mouse_Out ev;
-
-		  obj->mouse_in = 0;
-		  ev.buttons = e->pointer.button;
-		  ev.output.x = e->pointer.x;
-		  ev.output.y = e->pointer.y;
-		  ev.canvas.x = e->pointer.x;
-		  ev.canvas.y = e->pointer.y;
-////		  ev.canvas.x = e->pointer.canvas_x;
-////		  ev.canvas.y = e->pointer.canvas_y;
-		  ev.data = (void *)data;
-		  ev.modifiers = &(e->modifiers);
-		  ev.locks = &(e->locks);
-		  ev.timestamp = timestamp;
-		  if (e->events_frozen <= 0)
-		    evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
-	       }
+	     Evas_Object *obj = l->data;
+	     _evas_object_event_feed_mouse_out(obj, e, timestamp, data);
 	     if (e->delete_me) break;
 	  }
 	if (copy) copy = evas_list_free(copy);
-- 
1.5.4.rc2.17.g257f

From 9d9e689d63c304a928aea52b3f760490798abf65 Mon Sep 17 00:00:00 2001
From: Caio Marcelo de Oliveira Filho <[EMAIL PROTECTED]>
Date: Mon, 7 Jan 2008 16:24:31 -0300
Subject: [PATCH] evas events, adding evas_object_event_feed_mouse_(down|up)

Public functions for feeding Evas_Objects directly with events. It check if the
event makes sense (like the mouse coordinates are inside the object boundaries),
doing the "right thing" also for Smart objects.
---
 src/lib/Evas.h               |    3 ++
 src/lib/canvas/evas_events.c |   83 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/src/lib/Evas.h b/src/lib/Evas.h
index 18864ce..a4e7c4a 100644
--- a/src/lib/Evas.h
+++ b/src/lib/Evas.h
@@ -741,6 +741,9 @@ extern "C" {
    EAPI void              evas_event_feed_key_down          (Evas *e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data);
    EAPI void              evas_event_feed_key_up            (Evas *e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data);
 
+   EAPI void              evas_object_event_feed_mouse_down (Evas_Object *obj, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data);
+   EAPI void              evas_object_event_feed_mouse_up   (Evas_Object *obj, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data);
+
    EAPI void              evas_object_focus_set             (Evas_Object *obj, Evas_Bool focus);
    EAPI Evas_Bool         evas_object_focus_get             (Evas_Object *obj);
 
diff --git a/src/lib/canvas/evas_events.c b/src/lib/canvas/evas_events.c
index ba9bceb..70a9049 100644
--- a/src/lib/canvas/evas_events.c
+++ b/src/lib/canvas/evas_events.c
@@ -927,6 +927,89 @@ evas_event_feed_key_up(Evas *e, const char *keyname, const char *key, const char
 }
 
 /**
+ * @defgroup Evas_Object_Event_Feed_Group Evas Object Event Feed Functions
+ *
+ * Functions that are used to feed events directly into Evas Objects.
+ */
+
+/**
+ * Feeds an Evas_Object with a MOUSE_DOWN event.
+ */
+EAPI void
+evas_object_event_feed_mouse_down(Evas_Object *obj, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data)
+{
+   Evas *e;
+   Evas_List *l, *targets = NULL;
+
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return;
+   MAGIC_CHECK_END();
+
+   e = evas_object_evas_get(obj);
+
+   if ((b < 1) || (b > 32)) return;
+
+   e->pointer.button |= (1 << (b - 1));
+
+   if (e->events_frozen > 0) return;
+   e->last_timestamp = timestamp;
+
+   _evas_walk(e);
+   int no_rep = 0;
+   targets = _evas_event_object_list_in_get_by_object(e, targets, obj, NULL, e->pointer.x, e->pointer.y, &no_rep);
+
+   for (l = targets; l; l = l->next)
+     {
+	Evas_Object *o = l->data;
+	_evas_object_event_feed_mouse_down(o, e, b, flags, timestamp, data);
+	if (e->delete_me) break;
+     }
+
+   if (targets) targets = evas_list_free(targets);
+   e->last_mouse_down_counter++;
+   _evas_unwalk(e);
+}
+
+/**
+ * Feeds an Evas_Object with a MOUSE_UP event.
+ */
+EAPI void
+evas_object_event_feed_mouse_up(Evas_Object *obj, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data)
+{
+   Evas *e;
+   Evas_List *l, *targets = NULL;
+
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return;
+   MAGIC_CHECK_END();
+
+   e = evas_object_evas_get(obj);
+
+   if ((b < 1) || (b > 32)) return;
+
+   e->pointer.button |= (1 << (b - 1));
+
+   if (e->events_frozen > 0) return;
+   e->last_timestamp = timestamp;
+
+   _evas_walk(e);
+   int no_rep = 0;
+   targets = _evas_event_object_list_in_get_by_object(e, targets, obj, NULL, e->pointer.x, e->pointer.y, &no_rep);
+
+   for (l = targets; l; l = l->next)
+     {
+	Evas_Object *o = l->data;
+	_evas_object_event_feed_mouse_up(o, e, b, flags, timestamp, data);
+	if (e->delete_me) break;
+     }
+
+   if (targets) targets = evas_list_free(targets);
+   e->last_mouse_up_counter++;
+   _evas_unwalk(e);
+}
+
+
+/**
  * @defgroup Evas_Object_Event_Flags_Group Evas Object Event Flag Functions
  *
  * Functions that deal with how events on an Evas Object are processed.
-- 
1.5.4.rc2.17.g257f

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to