Improve documentation for Evas, Ecore, Edje and Elementary.
[profile/ivi/evas.git] / src / lib / canvas / evas_events.c
1 #include "evas_common.h"
2 #include "evas_private.h"
3
4 static Eina_List *
5 _evas_event_object_list_in_get(Evas *e, Eina_List *in, const Eina_Inlist *list, Evas_Object *stop, int x, int y, int *no_rep)
6 {
7    Evas_Object *obj;
8
9    if (!list) return in;
10    EINA_INLIST_REVERSE_FOREACH(list, obj)
11      {
12         if (obj == stop)
13           {
14              *no_rep = 1;
15              return in;
16           }
17         if (!evas_event_passes_through(obj))
18           {
19              if ((obj->cur.visible) && (obj->delete_me == 0) &&
20                  (!obj->clip.clipees) &&
21                  (evas_object_clippers_is_visible(obj)))
22                {
23                   if (obj->smart.smart)
24                     {
25                        int norep;
26
27                        norep = 0;
28                        in = _evas_event_object_list_in_get(e, in,
29                                                            evas_object_smart_members_get_direct(obj),
30                                                            stop, x, y, &norep);
31                        if (norep)
32                          {
33                             *no_rep = 1;
34                             return in;
35                          }
36                     }
37                   else
38                     {
39                        if (evas_object_is_in_output_rect(obj, x, y, 1, 1) &&
40                            ((!obj->precise_is_inside) ||
41                             (evas_object_is_inside(obj, x, y))))
42                          {
43                             in = eina_list_append(in, obj);
44                             if (!obj->repeat_events)
45                               {
46                                  *no_rep = 1;
47                                  return in;
48                               }
49                          }
50                     }
51                }
52           }
53      }
54    *no_rep = 0;
55    return in;
56 }
57
58 Eina_List *
59 evas_event_objects_event_list(Evas *e, Evas_Object *stop, int x, int y)
60 {
61    Evas_Layer *lay;
62    Eina_List *in = NULL;
63
64    if (!e->layers) return NULL;
65    EINA_INLIST_REVERSE_FOREACH((EINA_INLIST_GET(e->layers)), lay)
66      {
67         int norep;
68
69         norep = 0;
70         in = _evas_event_object_list_in_get(e, in, EINA_INLIST_GET(lay->objects), stop,
71                                             x, y, &norep);
72         if (norep) return in;
73      }
74    return in;
75 }
76
77 static Eina_List *evas_event_list_copy(Eina_List *list);
78 static Eina_List *
79 evas_event_list_copy(Eina_List *list)
80 {
81    Eina_List *l, *new_l = NULL;
82    const void *data;
83
84    EINA_LIST_FOREACH(list, l, data)
85      new_l = eina_list_append(new_l, data);
86    return new_l;
87 }
88 /* public functions */
89
90 /**
91  * @defgroup Evas_Event_Freezing_Group Evas Event Freezing Functions
92  *
93  * Functions that deal with the freezing of event processing of an
94  * evas.
95  */
96
97 /**
98  * Freeze all event processing.
99  * @param e The canvas to freeze event processing on.
100  *
101  * This function will indicate to evas that the canvas @p e is to have
102  * all event processing frozen until a matching evas_event_thaw()
103  * function is called on the same canvas. Every freeze call must be
104  * matched by a thaw call in order to completely thaw out a canvas.
105  *
106  * Example:
107  * @code
108  * extern Evas *evas;
109  * extern Evas_Object *object;
110  *
111  * evas_event_freeze(evas);
112  * evas_object_move(object, 50, 100);
113  * evas_object_resize(object, 200, 200);
114  * evas_event_thaw(evas);
115  * @endcode
116  * @ingroup Evas_Event_Freezing_Group
117  */
118 EAPI void
119 evas_event_freeze(Evas *e)
120 {
121    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
122    return;
123    MAGIC_CHECK_END();
124    e->events_frozen++;
125 }
126
127 /**
128  * Thaw a canvas out after freezing.
129  *
130  * @param e The canvas to thaw out.
131  *
132  * This will thaw out a canvas after a matching evas_event_freeze()
133  * call. If this call completely thaws out a canvas, events will start
134  * being processed again after this call, but this call will not
135  * invole any "missed" events to be evaluated.
136  *
137  * See evas_event_freeze() for an example.
138  * @ingroup Evas_Event_Freezing_Group
139  */
140 EAPI void
141 evas_event_thaw(Evas *e)
142 {
143    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
144    return;
145    MAGIC_CHECK_END();
146    e->events_frozen--;
147    if (e->events_frozen == 0)
148      {
149         Evas_Layer *lay;
150
151         EINA_INLIST_FOREACH((EINA_INLIST_GET(e->layers)), lay)
152           {
153              Evas_Object *obj;
154
155              EINA_INLIST_FOREACH(lay->objects, obj)
156                {
157                   evas_object_clip_recalc(obj);
158                   evas_object_recalc_clippees(obj);
159                }
160           }
161      }
162    if (e->events_frozen < 0)
163      evas_debug_generic("  Thaw of events when already thawed!!!\n");
164 }
165
166 /**
167  * Return the freeze count of a given canvas.
168  * @param e The canvas to fetch the freeze count from.
169  *
170  * This returns the number of times the canvas has been told to freeze
171  * events.  It is possible to call evas_event_freeze() multiple times,
172  * and these must be matched by evas_event_thaw() calls. This call
173  * allows the program to discover just how many times things have been
174  * frozen in case it may want to break out of a deep freeze state
175  * where the count is high.
176  *
177  * Example:
178  * @code
179  * extern Evas *evas;
180  *
181  * while (evas_event_freeze_get(evas) > 0) evas_event_thaw(evas);
182  * @endcode
183  * @ingroup Evas_Event_Freezing_Group
184  */
185 EAPI int
186 evas_event_freeze_get(const Evas *e)
187 {
188    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
189    return 0;
190    MAGIC_CHECK_END();
191    return e->events_frozen;
192 }
193
194
195 /**
196  * Mouse down event feed.
197  *
198  * @param e The given canvas pointer.
199  * @param b The button number.
200  * @param flags The evas button flags.
201  * @param timestamp The timestamp of the mouse down event.
202  * @param data The data for canvas.
203  *
204  * This function will set some evas properties that is necessary when
205  * the mouse button is pressed. It prepares information to be treated
206  * by the callback function.
207  *
208  */
209 EAPI void
210 evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data)
211 {
212    Eina_List *l, *copy;
213    Evas_Event_Mouse_Down ev;
214    Evas_Object *obj;
215
216    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
217    return;
218    MAGIC_CHECK_END();
219
220    if ((b < 1) || (b > 32)) return;
221
222    e->pointer.button |= (1 << (b - 1));
223
224    if (e->events_frozen > 0) return;
225    e->last_timestamp = timestamp;
226
227    ev.button = b;
228    ev.output.x = e->pointer.x;
229    ev.output.y = e->pointer.y;
230    ev.canvas.x = e->pointer.x;
231    ev.canvas.y = e->pointer.y;
232    ev.data = (void *)data;
233    ev.modifiers = &(e->modifiers);
234    ev.locks = &(e->locks);
235    ev.flags = flags;
236    ev.timestamp = timestamp;
237    ev.event_flags = EVAS_EVENT_FLAG_NONE;
238
239    _evas_walk(e);
240    copy = evas_event_list_copy(e->pointer.object.in);
241    EINA_LIST_FOREACH(copy, l, obj)
242      {
243         if (obj->pointer_mode != EVAS_OBJECT_POINTER_MODE_NOGRAB)
244           {
245              obj->mouse_grabbed++;
246              e->pointer.mouse_grabbed++;
247           }
248
249         if (e->events_frozen <= 0)
250           evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_DOWN, &ev);
251         if (e->delete_me) break;
252      }
253    if (copy) eina_list_free(copy);
254    e->last_mouse_down_counter++;
255    _evas_unwalk(e);
256 }
257
258 /**
259  * Mouse up event feed.
260  *
261  * @param e The given canvas pointer.
262  * @param b The button number.
263  * @param flags evas button flags.
264  * @param timestamp The timestamp of the mouse up event.
265  * @param data The data for canvas.
266  *
267  * This function will set some evas properties that is necessary when
268  * the mouse button is released. It prepares information to be treated
269  * by the callback function.
270  *
271  */
272 EAPI void
273 evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int timestamp, const void *data)
274 {
275    Eina_List *l, *copy;
276
277    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
278    return;
279    MAGIC_CHECK_END();
280
281    if ((b < 1) || (b > 32)) return;
282
283    e->pointer.button &= ~(1 << (b - 1));
284
285    if (e->events_frozen > 0) return;
286    e->last_timestamp = timestamp;
287
288      {
289         Evas_Event_Mouse_Up ev;
290         Evas_Object *obj;
291
292         ev.button = b;
293         ev.output.x = e->pointer.x;
294         ev.output.y = e->pointer.y;
295         ev.canvas.x = e->pointer.x;
296         ev.canvas.y = e->pointer.y;
297         ev.data = (void *)data;
298         ev.modifiers = &(e->modifiers);
299         ev.locks = &(e->locks);
300         ev.flags = flags;
301         ev.timestamp = timestamp;
302         ev.event_flags = EVAS_EVENT_FLAG_NONE;
303
304         _evas_walk(e);
305         copy = evas_event_list_copy(e->pointer.object.in);
306         EINA_LIST_FOREACH(copy, l, obj)
307           {
308              if ((obj->pointer_mode != EVAS_OBJECT_POINTER_MODE_NOGRAB) &&
309                  (obj->mouse_in) && (obj->mouse_grabbed > 0))
310                {
311                   obj->mouse_grabbed--;
312                   e->pointer.mouse_grabbed--;
313                }
314              if (e->events_frozen <= 0)
315                evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_UP, &ev);
316              if (e->delete_me) break;
317           }
318         if (copy) copy = eina_list_free(copy);
319         e->last_mouse_up_counter++;
320      }
321
322    if (!e->pointer.button)
323      {
324         Eina_List *ins;
325         Eina_List *l;
326           {
327              Evas_Event_Mouse_Out ev;
328              Evas_Object *obj;
329
330              ev.buttons = e->pointer.button;
331              ev.output.x = e->pointer.x;
332              ev.output.y = e->pointer.y;
333              ev.canvas.x = e->pointer.x;
334              ev.canvas.y = e->pointer.y;
335              ev.data = (void *)data;
336              ev.modifiers = &(e->modifiers);
337              ev.locks = &(e->locks);
338              ev.timestamp = timestamp;
339              ev.event_flags = EVAS_EVENT_FLAG_NONE;
340
341              /* get new list of ins */
342              ins = evas_event_objects_event_list(e, NULL, e->pointer.x, e->pointer.y);
343              /* go thru old list of in objects */
344              copy = evas_event_list_copy(e->pointer.object.in);
345              EINA_LIST_FOREACH(copy, l, obj)
346                {
347                   if ((!eina_list_data_find(ins, obj)) ||
348                       (!e->pointer.inside))
349                     {
350
351                        obj->mouse_in = 0;
352                        if (e->events_frozen <= 0)
353                          evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
354                     }
355                   if (e->delete_me) break;
356                }
357           }
358         if (copy) copy = eina_list_free(copy);
359         if (e->pointer.inside)
360           {
361              Evas_Event_Mouse_In ev;
362              Evas_Object *obj;
363
364              ev.buttons = e->pointer.button;
365              ev.output.x = e->pointer.x;
366              ev.output.y = e->pointer.y;
367              ev.canvas.x = e->pointer.x;
368              ev.canvas.y = e->pointer.y;
369              ev.data = (void *)data;
370              ev.modifiers = &(e->modifiers);
371              ev.locks = &(e->locks);
372              ev.timestamp = timestamp;
373              ev.event_flags = EVAS_EVENT_FLAG_NONE;
374
375              EINA_LIST_FOREACH(ins, l, obj)
376                {
377                   if (!eina_list_data_find(e->pointer.object.in, obj))
378                     {
379
380                        obj->mouse_in = 1;
381                        if (e->events_frozen <= 0)
382                          evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_IN, &ev);
383                     }
384                   if (e->delete_me) break;
385                }
386           }
387         else
388           {
389              ins = eina_list_free(ins);
390           }
391         /* free our old list of ins */
392         e->pointer.object.in = eina_list_free(e->pointer.object.in);
393         /* and set up the new one */
394         e->pointer.object.in = ins;
395         if (e->pointer.inside)
396           evas_event_feed_mouse_move(e, e->pointer.x, e->pointer.y, timestamp, data);
397      }
398
399    if (e->pointer.mouse_grabbed < 0)
400      {
401         fprintf(stderr, "BUG? e->pointer.mouse_grabbed (=%d) < 0!\n",
402                 e->pointer.mouse_grabbed);
403      }
404
405    if ((e->pointer.button == 0) && (e->pointer.mouse_grabbed != 0))
406      {
407         printf("restore to 0 grabs (from %i)\n", e->pointer.mouse_grabbed);
408         e->pointer.mouse_grabbed = 0;
409      }
410    _evas_unwalk(e);
411 }
412
413
414 /**
415  * Mouse cancel event feed.
416  *
417  * @param e The given canvas pointer.
418  * @param timestamp The timestamp of the mouse up event.
419  * @param data The data for canvas.
420  *
421  * This function will call evas_event_feed_mouse_up() when a
422  * mouse cancel event happens.
423  *
424  */
425 EAPI void
426 evas_event_feed_mouse_cancel(Evas *e, unsigned int timestamp, const void *data)
427 {
428    int i;
429
430    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
431    return;
432    MAGIC_CHECK_END();
433
434    if (e->events_frozen > 0) return;
435
436    _evas_walk(e);
437    for (i = 0; i < 32; i++)
438      {
439         if ((e->pointer.button & (1 << i)))
440           evas_event_feed_mouse_up(e, i + 1, 0, timestamp, data);
441      }
442    _evas_unwalk(e);
443 }
444
445 /**
446  * Mouse wheel event feed.
447  *
448  * @param e The given canvas pointer.
449  * @param direction The wheel mouse direction.
450  * @param z How much mouse wheel was scrolled up or down.
451  * @param timestamp The timestamp of the mouse up event.
452  * @param data The data for canvas.
453  *
454  * This function will set some evas properties that is necessary when
455  * the mouse wheel is scrolled up or down. It prepares information to
456  * be treated by the callback function.
457  *
458  */
459 EAPI void
460 evas_event_feed_mouse_wheel(Evas *e, int direction, int z, unsigned int timestamp, const void *data)
461 {
462    Eina_List *l, *copy;
463    Evas_Event_Mouse_Wheel ev;
464    Evas_Object *obj;
465
466    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
467    return;
468    MAGIC_CHECK_END();
469
470    if (e->events_frozen > 0) return;
471    e->last_timestamp = timestamp;
472
473    ev.direction = direction;
474    ev.z = z;
475    ev.output.x = e->pointer.x;
476    ev.output.y = e->pointer.y;
477    ev.canvas.x = e->pointer.x;
478    ev.canvas.y = e->pointer.y;
479    ev.data = (void *) data;
480    ev.modifiers = &(e->modifiers);
481    ev.locks = &(e->locks);
482    ev.timestamp = timestamp;
483    ev.event_flags = EVAS_EVENT_FLAG_NONE;
484
485    _evas_walk(e);
486    copy = evas_event_list_copy(e->pointer.object.in);
487
488    EINA_LIST_FOREACH(copy, l, obj)
489      {
490         if (e->events_frozen <= 0)
491           evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_WHEEL, &ev);
492         if (e->delete_me) break;
493      }
494    if (copy) copy = eina_list_free(copy);
495
496    _evas_unwalk(e);
497 }
498
499 /**
500  * Mouse move event feed.
501  *
502  * @param e The given canvas pointer.
503  * @param x The horizontal position of the mouse pointer.
504  * @param y The vertical position of the mouse pointer.
505  * @param timestamp The timestamp of the mouse up event.
506  * @param data The data for canvas.
507  *
508  * This function will set some evas properties that is necessary when
509  * the mouse is moved from its last position. It prepares information
510  * to be treated by the callback function.
511  *
512  */
513 EAPI void
514 evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const void *data)
515 {
516    int px, py;
517 ////   Evas_Coord pcx, pcy;
518
519    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
520    return;
521    MAGIC_CHECK_END();
522
523    px = e->pointer.x;
524    py = e->pointer.y;
525 ////   pcx = e->pointer.canvas_x;
526 ////   pcy = e->pointer.canvas_y;
527
528    if (e->events_frozen > 0) return;
529    e->last_timestamp = timestamp;
530
531    e->pointer.x = x;
532    e->pointer.y = y;
533 ////   e->pointer.canvas_x = x;
534 ////   e->pointer.canvas_y = y;
535 ////   e->pointer.canvas_x = evas_coord_screen_x_to_world(e, x);
536 ////   e->pointer.canvas_y = evas_coord_screen_y_to_world(e, y);
537    if ((!e->pointer.inside) && (e->pointer.mouse_grabbed == 0)) return;
538    _evas_walk(e);
539    /* if our mouse button is grabbed to any objects */
540    if (e->pointer.mouse_grabbed > 0)
541      {
542         /* go thru old list of in objects */
543         Eina_List *outs = NULL;
544         Eina_List *l, *copy;
545
546           {
547              Evas_Event_Mouse_Move ev;
548              Evas_Object *obj;
549
550              ev.buttons = e->pointer.button;
551              ev.cur.output.x = e->pointer.x;
552              ev.cur.output.y = e->pointer.y;
553              ev.cur.canvas.x = e->pointer.x;
554              ev.cur.canvas.y = e->pointer.y;
555              ev.prev.output.x = px;
556              ev.prev.output.y = py;
557              ev.prev.canvas.x = px;
558              ev.prev.canvas.y = py;
559              ev.data = (void *)data;
560              ev.modifiers = &(e->modifiers);
561              ev.locks = &(e->locks);
562              ev.timestamp = timestamp;
563              ev.event_flags = EVAS_EVENT_FLAG_NONE;
564              copy = evas_event_list_copy(e->pointer.object.in);
565              EINA_LIST_FOREACH(copy, l, obj)
566                {
567                   if ((obj->cur.visible) &&
568                       (evas_object_clippers_is_visible(obj)) &&
569                       (!evas_event_passes_through(obj)) &&
570                       (!obj->clip.clipees))
571                     {
572                        if ((px != x) || (py != y))
573                          {
574                             if (e->events_frozen <= 0)
575                               evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_MOVE, &ev);
576                          }
577                     }
578                   else
579                     outs = eina_list_append(outs, obj);
580                   if (e->delete_me) break;
581                }
582           }
583           {
584              Evas_Event_Mouse_Out ev;
585
586              ev.buttons = e->pointer.button;
587              ev.output.x = e->pointer.x;
588              ev.output.y = e->pointer.y;
589              ev.canvas.x = e->pointer.x;
590              ev.canvas.y = e->pointer.y;
591              ev.data = (void *)data;
592              ev.modifiers = &(e->modifiers);
593              ev.locks = &(e->locks);
594              ev.timestamp = timestamp;
595              ev.event_flags = EVAS_EVENT_FLAG_NONE;
596
597              if (copy) copy = eina_list_free(copy);
598              while (outs)
599                {
600                   Evas_Object *obj;
601
602                   obj = outs->data;
603                   outs = eina_list_remove(outs, obj);
604                   if ((obj->mouse_grabbed == 0) && (!e->delete_me))
605                     {
606                        e->pointer.object.in = eina_list_remove(e->pointer.object.in, obj);
607                          {
608                             obj->mouse_in = 0;
609                             if (e->events_frozen <= 0)
610                               evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
611                          }
612                     }
613                }
614           }
615      }
616    else
617      {
618         Eina_List *ins;
619         Eina_List *l, *copy;
620         Evas_Event_Mouse_Move ev;
621         Evas_Event_Mouse_Out ev2;
622         Evas_Event_Mouse_In ev3;
623         Evas_Object *obj;
624
625         ev.buttons = e->pointer.button;
626         ev.cur.output.x = e->pointer.x;
627         ev.cur.output.y = e->pointer.y;
628         ev.cur.canvas.x = e->pointer.x;
629         ev.cur.canvas.y = e->pointer.y;
630         ev.prev.output.x = px;
631         ev.prev.output.y = py;
632         ev.prev.canvas.x = px;
633         ev.prev.canvas.y = py;
634         ev.data = (void *)data;
635         ev.modifiers = &(e->modifiers);
636         ev.locks = &(e->locks);
637         ev.timestamp = timestamp;
638         ev.event_flags = EVAS_EVENT_FLAG_NONE;
639
640         ev2.buttons = e->pointer.button;
641         ev2.output.x = e->pointer.x;
642         ev2.output.y = e->pointer.y;
643         ev2.canvas.x = e->pointer.x;
644         ev2.canvas.y = e->pointer.y;
645         ev2.data = (void *)data;
646         ev2.modifiers = &(e->modifiers);
647         ev2.locks = &(e->locks);
648         ev2.timestamp = timestamp;
649         ev2.event_flags = EVAS_EVENT_FLAG_NONE;
650
651         ev3.buttons = e->pointer.button;
652         ev3.output.x = e->pointer.x;
653         ev3.output.y = e->pointer.y;
654         ev3.canvas.x = e->pointer.x;
655         ev3.canvas.y = e->pointer.y;
656         ev3.data = (void *)data;
657         ev3.modifiers = &(e->modifiers);
658         ev3.locks = &(e->locks);
659         ev3.timestamp = timestamp;
660         ev3.event_flags = EVAS_EVENT_FLAG_NONE;
661
662         /* get all new in objects */
663         ins = evas_event_objects_event_list(e, NULL, x, y);
664         /* go thru old list of in objects */
665         copy = evas_event_list_copy(e->pointer.object.in);
666         EINA_LIST_FOREACH(copy, l, obj)
667           {
668              /* if its under the pointer and its visible and its in the new */
669              /* in list */
670 // FIXME: i don't think we need this
671 //           evas_object_clip_recalc(obj);
672              if (evas_object_is_in_output_rect(obj, x, y, 1, 1) &&
673                  (obj->cur.visible) &&
674                  (evas_object_clippers_is_visible(obj)) &&
675                  (eina_list_data_find(ins, obj)) &&
676                  (!evas_event_passes_through(obj)) &&
677                  (!obj->clip.clipees) &&
678                  ((!obj->precise_is_inside) ||
679                   (evas_object_is_inside(obj, x, y))))
680                {
681                   if ((px != x) || (py != y))
682                     {
683                        if (e->events_frozen <= 0)
684                          evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_MOVE, &ev);
685                     }
686                }
687              /* otherwise it has left the object */
688              else
689                {
690                   obj->mouse_in = 0;
691                   if (e->events_frozen <= 0)
692                     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev2);
693                }
694              if (e->delete_me) break;
695           }
696         if (copy) copy = eina_list_free(copy);
697         /* go thru our current list of ins */
698         EINA_LIST_FOREACH(ins, l, obj)
699           {
700              /* if its not in the old list of ins send an enter event */
701              if (!eina_list_data_find(e->pointer.object.in, obj))
702                {
703                   obj->mouse_in = 1;
704
705                   if (e->events_frozen <= 0)
706                     evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_IN, &ev3);
707                }
708              if (e->delete_me) break;
709           }
710         /* free our old list of ins */
711         eina_list_free(e->pointer.object.in);
712         /* and set up the new one */
713         e->pointer.object.in = ins;
714      }
715    _evas_unwalk(e);
716 }
717
718 /**
719  * Mouse in event feed.
720  *
721  * @param e The given canvas pointer.
722  * @param timestamp The timestamp of the mouse up event.
723  * @param data The data for canvas.
724  *
725  * This function will set some evas properties that is necessary when
726  * the mouse in event happens. It prepares information to be treated
727  * by the callback function.
728  *
729  */
730 EAPI void
731 evas_event_feed_mouse_in(Evas *e, unsigned int timestamp, const void *data)
732 {
733    Eina_List *ins;
734    Eina_List *l;
735    Evas_Event_Mouse_In ev;
736    Evas_Object *obj;
737
738    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
739    return;
740    MAGIC_CHECK_END();
741    e->pointer.inside = 1;
742
743    if (e->events_frozen > 0) return;
744    e->last_timestamp = timestamp;
745
746    if (e->pointer.mouse_grabbed != 0) return;
747
748    ev.buttons = e->pointer.button;
749    ev.output.x = e->pointer.x;
750    ev.output.y = e->pointer.y;
751    ev.canvas.x = e->pointer.x;
752    ev.canvas.y = e->pointer.y;
753    ev.data = (void *)data;
754    ev.modifiers = &(e->modifiers);
755    ev.locks = &(e->locks);
756    ev.timestamp = timestamp;
757    ev.event_flags = EVAS_EVENT_FLAG_NONE;
758
759    _evas_walk(e);
760    /* get new list of ins */
761    ins = evas_event_objects_event_list(e, NULL, e->pointer.x, e->pointer.y);
762    EINA_LIST_FOREACH(ins, l, obj)
763      {
764         if (!eina_list_data_find(e->pointer.object.in, obj))
765           {
766
767              obj->mouse_in = 1;
768              if (e->events_frozen <= 0)
769                evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_IN, &ev);
770           }
771         if (e->delete_me) break;
772      }
773    /* free our old list of ins */
774    e->pointer.object.in = eina_list_free(e->pointer.object.in);
775    /* and set up the new one */
776    e->pointer.object.in = ins;
777    evas_event_feed_mouse_move(e, e->pointer.x, e->pointer.y, timestamp, data);
778    _evas_unwalk(e);
779 }
780
781 /**
782  * Mouse out event feed.
783  *
784  * @param e The given canvas pointer.
785  * @param timestamp Timestamp of the mouse up event.
786  * @param data The data for canvas.
787  *
788  * This function will set some evas properties that is necessary when
789  * the mouse out event happens. It prepares information to be treated
790  * by the callback function.
791  *
792  */
793 EAPI void
794 evas_event_feed_mouse_out(Evas *e, unsigned int timestamp, const void *data)
795 {
796    Evas_Event_Mouse_Out ev;
797
798    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
799    return;
800    MAGIC_CHECK_END();
801    e->pointer.inside = 0;
802
803    if (e->events_frozen > 0) return;
804    e->last_timestamp = timestamp;
805
806    ev.buttons = e->pointer.button;
807    ev.output.x = e->pointer.x;
808    ev.output.y = e->pointer.y;
809    ev.canvas.x = e->pointer.x;
810    ev.canvas.y = e->pointer.y;
811    ev.data = (void *)data;
812    ev.modifiers = &(e->modifiers);
813    ev.locks = &(e->locks);
814    ev.timestamp = timestamp;
815    ev.event_flags = EVAS_EVENT_FLAG_NONE;
816
817    _evas_walk(e);
818    /* if our mouse button is grabbed to any objects */
819    if (e->pointer.mouse_grabbed == 0)
820      {
821         /* go thru old list of in objects */
822         Eina_List *l, *copy;
823         Evas_Object *obj;
824
825         copy = evas_event_list_copy(e->pointer.object.in);
826         EINA_LIST_FOREACH(copy, l, obj)
827           {
828             obj->mouse_in = 0;
829             if (e->events_frozen <= 0)
830               evas_object_event_callback_call(obj, EVAS_CALLBACK_MOUSE_OUT, &ev);
831
832             if (e->delete_me) break;
833           }
834         if (copy) copy = eina_list_free(copy);
835         /* free our old list of ins */
836         e->pointer.object.in =  eina_list_free(e->pointer.object.in);
837      }
838    _evas_unwalk(e);
839 }
840
841 /**
842  * Key down event feed
843  *
844  * @param e The canvas to thaw out
845  * @param keyname  Name of the key
846  * @param key The key pressed.
847  * @param string A String
848  * @param compose The compose string
849  * @param timestamp Timestamp of the mouse up event
850  * @param data Data for canvas.
851  *
852  * This function will set some evas properties that is necessary when
853  * a key is pressed. It prepares information to be treated by the
854  * callback function.
855  *
856  */
857 EAPI void
858 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)
859 {
860    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
861    return;
862    MAGIC_CHECK_END();
863    if (!keyname) return;
864    if (e->events_frozen > 0) return;
865    e->last_timestamp = timestamp;
866    _evas_walk(e);
867      {
868         Evas_Event_Key_Down ev;
869         int exclusive;
870
871         exclusive = 0;
872         ev.keyname = (char *)keyname;
873         ev.data = (void *)data;
874         ev.modifiers = &(e->modifiers);
875         ev.locks = &(e->locks);
876         ev.key = key;
877         ev.string = string;
878         ev.compose = compose;
879         ev.timestamp = timestamp;
880         ev.event_flags = EVAS_EVENT_FLAG_NONE;
881         if (e->grabs)
882           {
883              Eina_List *l;
884              Evas_Key_Grab *g;
885
886              e->walking_grabs++;
887              EINA_LIST_FOREACH(e->grabs, l, g)
888                {
889                   if (g->just_added)
890                     {
891                        g->just_added = 0;
892                        continue;
893                     }
894                   if (g->delete_me) continue;
895                   if (((e->modifiers.mask & g->modifiers) ||
896                        (g->modifiers == e->modifiers.mask)) &&
897                       (!strcmp(keyname, g->keyname)))
898                     {
899                        if (!(e->modifiers.mask & g->not_modifiers))
900                          {
901                             if (e->events_frozen <= 0)
902                               evas_object_event_callback_call(g->object, EVAS_CALLBACK_KEY_DOWN, &ev);
903                             if (g->exclusive) exclusive = 1;
904                          }
905                     }
906                   if (e->delete_me) break;
907                }
908              e->walking_grabs--;
909              if (e->walking_grabs <= 0)
910                {
911                   while (e->delete_grabs > 0)
912                     {
913                        e->delete_grabs--;
914                        for (l = e->grabs; l;)
915                          {
916                             g = eina_list_data_get(l);
917                             l = eina_list_next(l);
918                             if (g->delete_me)
919                               evas_key_grab_free(g->object, g->keyname, g->modifiers, g->not_modifiers);
920                          }
921                     }
922                }
923           }
924         if ((e->focused) && (!exclusive))
925           {
926              if (e->events_frozen <= 0)
927                evas_object_event_callback_call(e->focused, EVAS_CALLBACK_KEY_DOWN, &ev);
928           }
929      }
930    _evas_unwalk(e);
931 }
932
933 /**
934  * Key up event feed
935  *
936  * @param e The canvas to thaw out
937  * @param keyname  Name of the key
938  * @param key The key released.
939  * @param string string
940  * @param compose compose
941  * @param timestamp Timestamp of the mouse up event
942  * @param data Data for canvas.
943  *
944  * This function will set some evas properties that is necessary when
945  * a key is released. It prepares information to be treated by the
946  * callback function.
947  *
948  */
949 EAPI void
950 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)
951 {
952    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
953    return;
954    MAGIC_CHECK_END();
955    if (!keyname) return;
956    if (e->events_frozen > 0) return;
957    e->last_timestamp = timestamp;
958    _evas_walk(e);
959      {
960         Evas_Event_Key_Up ev;
961         int exclusive;
962
963         exclusive = 0;
964         ev.keyname = (char *)keyname;
965         ev.data = (void *)data;
966         ev.modifiers = &(e->modifiers);
967         ev.locks = &(e->locks);
968         ev.key = key;
969         ev.string = string;
970         ev.compose = compose;
971         ev.timestamp = timestamp;
972         ev.event_flags = EVAS_EVENT_FLAG_NONE;
973         if (e->grabs)
974           {
975              Eina_List *l;
976              Evas_Key_Grab *g;
977
978              e->walking_grabs++;
979              EINA_LIST_FOREACH(e->grabs, l, g)
980                {
981                   if (g->just_added)
982                     {
983                        g->just_added = 0;
984                        continue;
985                     }
986                   if (g->delete_me) continue;
987                   if (((e->modifiers.mask & g->modifiers) ||
988                        (g->modifiers == e->modifiers.mask)) &&
989                       (!((e->modifiers.mask & g->not_modifiers) ||
990                          (g->not_modifiers == ~e->modifiers.mask))) &&
991                       (!strcmp(keyname, g->keyname)))
992                     {
993                        if (e->events_frozen <= 0)
994                          evas_object_event_callback_call(g->object, EVAS_CALLBACK_KEY_UP, &ev);
995                        if (g->exclusive) exclusive = 1;
996                     }
997                   if (e->delete_me) break;
998                }
999              e->walking_grabs--;
1000              if (e->walking_grabs <= 0)
1001                {
1002                   while (e->delete_grabs > 0)
1003                     {
1004                        Eina_List *l, *l_next;
1005                        Evas_Key_Grab *g;
1006
1007                        e->delete_grabs--;
1008                        EINA_LIST_FOREACH_SAFE(e->grabs, l, l_next, g)
1009                          {
1010                             if (g->delete_me)
1011                               evas_key_grab_free(g->object, g->keyname, g->modifiers, g->not_modifiers);
1012                          }
1013                     }
1014                }
1015           }
1016         if ((e->focused) && (!exclusive))
1017           {
1018              if (e->events_frozen <= 0)
1019                evas_object_event_callback_call(e->focused, EVAS_CALLBACK_KEY_UP, &ev);
1020           }
1021      }
1022    _evas_unwalk(e);
1023 }
1024
1025 /**
1026  * Hold event feed
1027  *
1028  * @param e The given canvas pointer.
1029  * @param hold The hold.
1030  * @param timestamp The timestamp of the mouse up event.
1031  * @param data The data for canvas.
1032  *
1033  * This function makes the object to stop sending events.
1034  *
1035  */
1036 EAPI void
1037 evas_event_feed_hold(Evas *e, int hold, unsigned int timestamp, const void *data)
1038 {
1039    Eina_List *l, *copy;
1040    Evas_Event_Hold ev;
1041    Evas_Object *obj;
1042
1043    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1044    return;
1045    MAGIC_CHECK_END();
1046
1047    if (e->events_frozen > 0) return;
1048    e->last_timestamp = timestamp;
1049
1050    ev.hold = hold;
1051    ev.data = (void *)data;
1052    ev.timestamp = timestamp;
1053    ev.event_flags = EVAS_EVENT_FLAG_NONE;
1054
1055    _evas_walk(e);
1056    copy = evas_event_list_copy(e->pointer.object.in);
1057    EINA_LIST_FOREACH(copy, l, obj)
1058      {
1059         if (e->events_frozen <= 0)
1060           evas_object_event_callback_call(obj, EVAS_CALLBACK_HOLD, &ev);
1061         if (e->delete_me) break;
1062      }
1063    if (copy) copy = eina_list_free(copy);
1064    _evas_unwalk(e);
1065 }
1066
1067
1068 /**
1069  * @addtogroup Evas_Object_Group
1070  * @{
1071  */
1072
1073 /**
1074  * Set an object's pass events state.
1075  * @param obj the evas object
1076  * @param pass whether to pass events or not
1077  *
1078  * If @p pass is true, this will cause events on @p obj to be ignored.
1079  * They will be triggered on the next lower object (that is not set to
1080  * pass events) instead.
1081  *
1082  * If @p pass is false, events will be processed as normal.
1083  *
1084  * @ingroup Evas_Object_Event_Flags_Group
1085  */
1086 EAPI void
1087 evas_object_pass_events_set(Evas_Object *obj, Eina_Bool pass)
1088 {
1089    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1090    return;
1091    MAGIC_CHECK_END();
1092    obj->pass_events = pass;
1093    evas_object_smart_member_cache_invalidate(obj);
1094    if (evas_object_is_in_output_rect(obj,
1095                                      obj->layer->evas->pointer.x,
1096                                      obj->layer->evas->pointer.y, 1, 1) &&
1097        ((!obj->precise_is_inside) ||
1098         (evas_object_is_inside(obj,
1099                                obj->layer->evas->pointer.x,
1100                                obj->layer->evas->pointer.y))))
1101      evas_event_feed_mouse_move(obj->layer->evas,
1102                                 obj->layer->evas->pointer.x,
1103                                 obj->layer->evas->pointer.y,
1104                                 obj->layer->evas->last_timestamp,
1105                                 NULL);
1106 }
1107
1108 /**
1109  * Determine whether an object is set to pass events.
1110  * @param obj
1111  * @return pass events state
1112  *
1113  * @ingroup Evas_Object_Event_Flags_Group
1114  */
1115 EAPI Eina_Bool
1116 evas_object_pass_events_get(const Evas_Object *obj)
1117 {
1118    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1119    return 0;
1120    MAGIC_CHECK_END();
1121    return obj->pass_events;
1122 }
1123
1124 /**
1125  * Set an object's repeat events state.
1126  * @param obj the object
1127  * @param repeat wheter to repeat events or not
1128  *
1129  * If @p repeat is true, this will cause events on @p obj to trigger
1130  * callbacks, but also to be repeated on the next lower object in the
1131  * stack.
1132  *
1133  * If @p repeat is false, events occuring on @p obj will be processed
1134  * normally.
1135  *
1136  * @ingroup Evas_Object_Event_Flags_Group
1137  */
1138 EAPI void
1139 evas_object_repeat_events_set(Evas_Object *obj, Eina_Bool repeat)
1140 {
1141    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1142    return;
1143    MAGIC_CHECK_END();
1144    obj->repeat_events = repeat;
1145    if (evas_object_is_in_output_rect(obj,
1146                                      obj->layer->evas->pointer.x,
1147                                      obj->layer->evas->pointer.y, 1, 1) &&
1148        ((!obj->precise_is_inside) ||
1149         (evas_object_is_inside(obj,
1150                                obj->layer->evas->pointer.x,
1151                                obj->layer->evas->pointer.y))))
1152      evas_event_feed_mouse_move(obj->layer->evas,
1153                                 obj->layer->evas->pointer.x,
1154                                 obj->layer->evas->pointer.y,
1155                                 obj->layer->evas->last_timestamp,
1156                                 NULL);
1157 }
1158
1159 /**
1160  * Determine whether an object is set to repeat events.
1161  * @param obj
1162  * @return repeat events state
1163  *
1164  * @ingroup Evas_Object_Event_Flags_Group
1165  */
1166 EAPI Eina_Bool
1167 evas_object_repeat_events_get(const Evas_Object *obj)
1168 {
1169    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1170    return 0;
1171    MAGIC_CHECK_END();
1172    return obj->repeat_events;
1173 }
1174
1175 /**
1176  * Set whether events on a smart member object should propagate to its
1177  * parent.
1178  *
1179  * @param obj the smart member object
1180  * @param prop wheter to propagate events or not
1181  *
1182  * This function has no effect if @p obj is not a member of a smart
1183  * object.
1184  *
1185  * If @p prop is true, events occuring on this object will propagate on
1186  * to the smart object of which @p obj is a member.
1187  *
1188  * If @p prop is false, events for which callbacks are set on the member
1189  * object, @p obj, will not be passed on to the parent smart object.
1190  *
1191  * The default value is true.
1192  * @ingroup Evas_Object_Event_Flags_Group
1193  */
1194 EAPI void
1195 evas_object_propagate_events_set(Evas_Object *obj, Eina_Bool prop)
1196 {
1197    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1198    return;
1199    MAGIC_CHECK_END();
1200    obj->no_propagate = !prop;
1201 }
1202
1203 /**
1204  * Determine whether an object is set to propagate events.
1205  * @param obj
1206  * @return propogate events state
1207  *
1208  * @ingroup Evas_Object_Event_Flags_Group
1209  */
1210 EAPI Eina_Bool
1211 evas_object_propagate_events_get(const Evas_Object *obj)
1212 {
1213    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1214    return 0;
1215    MAGIC_CHECK_END();
1216    return !(obj->no_propagate);
1217 }
1218
1219 /**
1220  * @}
1221  */
1222
1223 /**
1224  * Set pointer behavior.
1225  *
1226  * @param obj
1227  * @param setting desired behavior.
1228  *
1229  * This function has direct effect on event callbacks related to
1230  * mouse.
1231  *
1232  * If @p setting is EVAS_OBJECT_POINTER_MODE_AUTOGRAB, then when mouse
1233  * is down at this object, events will be restricted to it as source,
1234  * mouse moves, for example, will be emitted even if outside this
1235  * object area.
1236  *
1237  * If @p setting is EVAS_OBJECT_POINTER_MODE_NOGRAB, then events will
1238  * be emitted just when inside this object area.
1239  *
1240  * The default value is EVAS_OBJECT_POINTER_MODE_AUTOGRAB.
1241  */
1242 EAPI void
1243 evas_object_pointer_mode_set(Evas_Object *obj, Evas_Object_Pointer_Mode setting)
1244 {
1245    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1246    return;
1247    MAGIC_CHECK_END();
1248    obj->pointer_mode = setting;
1249 }
1250
1251 /**
1252  * Determine how pointer will behave.
1253  * @param obj
1254  * @return pointer behavior.
1255  */
1256 EAPI Evas_Object_Pointer_Mode
1257 evas_object_pointer_mode_get(const Evas_Object *obj)
1258 {
1259    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
1260    return 0;
1261    MAGIC_CHECK_END();
1262    return obj->pointer_mode;
1263 }