2000-09-26 12:16:48 -07:00
|
|
|
#include "Evas_private.h"
|
2000-07-31 11:06:21 -07:00
|
|
|
#include "Evas.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2000-08-14 14:49:03 -07:00
|
|
|
int
|
|
|
|
_evas_point_in_object(Evas e, Evas_Object o, int x, int y)
|
|
|
|
{
|
|
|
|
int ox, oy, ow, oh;
|
2000-09-27 08:14:06 -07:00
|
|
|
|
|
|
|
if (o->delete_me) return 0;
|
2000-08-14 14:49:03 -07:00
|
|
|
_evas_object_get_current_translated_coords(e, o, &ox, &oy, &ow, &oh);
|
|
|
|
if ((x >= ox) && (x < (ox + ow)) && (y >= oy) && (y < (oy + oh)))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Object
|
|
|
|
_evas_highest_object_at_point(Evas e, int x, int y)
|
|
|
|
{
|
|
|
|
Evas_List l, ll;
|
|
|
|
Evas_Layer layer;
|
|
|
|
Evas_Object o;
|
|
|
|
|
|
|
|
o = NULL;
|
|
|
|
for (l = e->layers; l ; l = l->next)
|
|
|
|
{
|
|
|
|
layer = l->data;
|
|
|
|
|
|
|
|
for (ll = layer->objects; ll; ll = ll->next)
|
|
|
|
{
|
2000-08-20 00:13:31 -07:00
|
|
|
Evas_Object ob;
|
|
|
|
|
|
|
|
ob = ll->data;
|
2000-09-27 08:14:06 -07:00
|
|
|
if ((ob->current.visible) && (!ob->pass_events) && (!ob->delete_me))
|
2000-08-20 00:13:31 -07:00
|
|
|
{
|
2000-08-20 14:49:41 -07:00
|
|
|
if (_evas_point_in_object(e, ob, x, y))
|
2000-10-26 15:47:33 -07:00
|
|
|
{
|
|
|
|
o = ob;
|
|
|
|
}
|
2000-08-20 00:13:31 -07:00
|
|
|
}
|
2000-08-14 14:49:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_List
|
|
|
|
_evas_objects_at_point(Evas e, int x, int y)
|
|
|
|
{
|
|
|
|
Evas_List l, ll, objs;
|
|
|
|
Evas_Layer layer;
|
|
|
|
|
|
|
|
objs = NULL;
|
|
|
|
for (l = e->layers; l ; l = l->next)
|
|
|
|
{
|
|
|
|
layer = l->data;
|
|
|
|
|
|
|
|
for (ll = layer->objects; ll; ll = ll->next)
|
|
|
|
{
|
2000-08-20 00:13:31 -07:00
|
|
|
Evas_Object ob;
|
|
|
|
|
|
|
|
ob = ll->data;
|
2000-09-27 08:14:06 -07:00
|
|
|
if ((ob->current.visible) && (!ob->pass_events) && (!ob->delete_me))
|
2000-08-20 00:13:31 -07:00
|
|
|
{
|
|
|
|
if (_evas_point_in_object(e, ll->data, x, y))
|
|
|
|
objs = evas_list_prepend(objs, ll->data);
|
|
|
|
}
|
2000-08-14 14:49:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return objs;
|
|
|
|
}
|
2000-10-31 10:15:11 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
evas_ungrab_button(Evas e)
|
|
|
|
{
|
|
|
|
if (e->mouse.button_object)
|
|
|
|
e->mouse.button_object = NULL;
|
|
|
|
e->mouse.buttons = 0;
|
|
|
|
}
|
|
|
|
|
2000-07-31 11:06:21 -07:00
|
|
|
/* events */
|
|
|
|
void
|
|
|
|
evas_event_button_down(Evas e, int x, int y, int b)
|
|
|
|
{
|
2000-08-20 00:13:31 -07:00
|
|
|
Evas_Object o;
|
|
|
|
|
2000-09-27 08:14:06 -07:00
|
|
|
if (!e) return;
|
2000-08-20 14:49:41 -07:00
|
|
|
if ((b < 1) || (b > 32)) return;
|
|
|
|
if (!e->mouse.buttons)
|
|
|
|
{
|
2000-10-26 15:47:33 -07:00
|
|
|
o = _evas_highest_object_at_point(e, x, y);
|
2000-08-20 14:49:41 -07:00
|
|
|
e->mouse.button_object = o;
|
|
|
|
}
|
2000-08-14 14:49:03 -07:00
|
|
|
e->mouse.buttons |= (1 << (b - 1));
|
2000-08-20 00:13:31 -07:00
|
|
|
e->mouse.x = x;
|
|
|
|
e->mouse.y = y;
|
2000-08-20 14:49:41 -07:00
|
|
|
if (e->mouse.button_object)
|
|
|
|
_evas_callback_call(e, e->mouse.button_object, CALLBACK_MOUSE_DOWN,
|
|
|
|
b, x, y);
|
2000-07-31 11:06:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_event_button_up(Evas e, int x, int y, int b)
|
|
|
|
{
|
2000-08-20 00:13:31 -07:00
|
|
|
Evas_Object o;
|
|
|
|
|
2000-09-27 08:14:06 -07:00
|
|
|
if (!e) return;
|
2000-08-20 14:49:41 -07:00
|
|
|
if ((b < 1) || (b > 32)) return;
|
2000-08-14 14:49:03 -07:00
|
|
|
e->mouse.buttons &= ~(1 << (b - 1));
|
2000-08-20 00:13:31 -07:00
|
|
|
e->mouse.x = x;
|
|
|
|
e->mouse.y = y;
|
2000-08-20 14:49:41 -07:00
|
|
|
if (e->mouse.button_object)
|
|
|
|
_evas_callback_call(e, e->mouse.button_object, CALLBACK_MOUSE_UP,
|
|
|
|
b, x, y);
|
2000-10-31 10:15:11 -08:00
|
|
|
else if (e->mouse.object)
|
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_UP,
|
|
|
|
b, x, y);
|
2000-09-21 18:12:52 -07:00
|
|
|
if (!e->mouse.buttons)
|
|
|
|
{
|
2000-10-17 09:29:59 -07:00
|
|
|
if ((e->mouse.button_object) &&
|
|
|
|
(e->mouse.object != e->mouse.button_object))
|
2000-09-21 18:12:52 -07:00
|
|
|
_evas_callback_call(e, e->mouse.button_object, CALLBACK_MOUSE_OUT,
|
2000-10-26 15:47:33 -07:00
|
|
|
e->mouse.buttons, x, y);
|
2000-09-21 18:12:52 -07:00
|
|
|
e->mouse.button_object = NULL;
|
|
|
|
}
|
2000-07-31 11:06:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_event_move(Evas e, int x, int y)
|
|
|
|
{
|
2000-08-20 00:13:31 -07:00
|
|
|
Evas_Object o;
|
2000-08-20 14:49:41 -07:00
|
|
|
|
2000-09-27 08:14:06 -07:00
|
|
|
if (!e) return;
|
2000-09-21 18:12:52 -07:00
|
|
|
o = _evas_highest_object_at_point(e, e->mouse.x, e->mouse.y);
|
|
|
|
if (o != e->mouse.object)
|
2000-08-20 14:49:41 -07:00
|
|
|
{
|
2000-09-21 18:12:52 -07:00
|
|
|
if (e->mouse.object)
|
2000-08-20 14:49:41 -07:00
|
|
|
{
|
2000-09-21 18:12:52 -07:00
|
|
|
if (!e->mouse.button_object)
|
2000-09-25 12:47:44 -07:00
|
|
|
{
|
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_OUT,
|
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_evas_callback_call(e, e->mouse.button_object, CALLBACK_MOUSE_MOVE,
|
2000-09-21 18:12:52 -07:00
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
}
|
2000-08-20 14:49:41 -07:00
|
|
|
e->mouse.x = x;
|
|
|
|
e->mouse.y = y;
|
2000-09-21 18:12:52 -07:00
|
|
|
e->mouse.object = o;
|
2000-08-20 14:49:41 -07:00
|
|
|
if (e->mouse.object)
|
2000-09-21 18:12:52 -07:00
|
|
|
{
|
|
|
|
if (!e->mouse.button_object)
|
2000-09-25 12:47:44 -07:00
|
|
|
{
|
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_IN,
|
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
}
|
2000-09-21 18:12:52 -07:00
|
|
|
}
|
2000-08-20 14:49:41 -07:00
|
|
|
return;
|
2000-09-21 18:12:52 -07:00
|
|
|
}
|
2000-08-14 14:49:03 -07:00
|
|
|
e->mouse.x = x;
|
|
|
|
e->mouse.y = y;
|
2000-09-25 12:47:44 -07:00
|
|
|
if (e->mouse.button_object)
|
|
|
|
_evas_callback_call(e, e->mouse.button_object, CALLBACK_MOUSE_MOVE,
|
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
else if (e->mouse.object)
|
2000-09-21 18:12:52 -07:00
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
2000-08-20 14:49:41 -07:00
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
2000-07-31 11:06:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_event_enter(Evas e)
|
|
|
|
{
|
2000-09-27 08:14:06 -07:00
|
|
|
if (!e) return;
|
2000-08-14 14:49:03 -07:00
|
|
|
e->mouse.in = 1;
|
2000-07-31 11:06:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_event_leave(Evas e)
|
|
|
|
{
|
2000-09-27 08:14:06 -07:00
|
|
|
if (!e) return;
|
2000-08-14 14:49:03 -07:00
|
|
|
e->mouse.in = 0;
|
2000-11-04 11:17:57 -08:00
|
|
|
if ((e->mouse.object) && (!e->mouse.button_object))
|
|
|
|
{
|
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_MOVE,
|
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
_evas_callback_call(e, e->mouse.object, CALLBACK_MOUSE_OUT,
|
|
|
|
e->mouse.buttons, e->mouse.x, e->mouse.y);
|
|
|
|
e->mouse.object = NULL;
|
|
|
|
}
|
2000-07-31 11:06:21 -07:00
|
|
|
}
|
2000-08-20 00:13:31 -07:00
|
|
|
|
|
|
|
Evas_Object
|
|
|
|
evas_get_object_under_mouse(Evas e)
|
|
|
|
{
|
2000-09-27 08:14:06 -07:00
|
|
|
if (!e) return NULL;
|
2000-08-20 00:13:31 -07:00
|
|
|
return _evas_highest_object_at_point(e, e->mouse.x, e->mouse.y);
|
|
|
|
}
|
2000-10-13 11:00:48 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
evas_pointer_in(Evas e)
|
|
|
|
{
|
|
|
|
if (!e) return 0;
|
|
|
|
return e->mouse.in;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_pointer_pos(Evas e, int *x, int *y)
|
|
|
|
{
|
|
|
|
if (!e) return;
|
|
|
|
if (x) *x = e->mouse.x;
|
|
|
|
if (y) *y = e->mouse.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evas_pointer_buttons(Evas e)
|
|
|
|
{
|
|
|
|
if (!e) return 0;
|
|
|
|
return e->mouse.buttons;
|
|
|
|
}
|
2000-10-13 20:41:11 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
evas_pinter_ungrab(Evas e)
|
|
|
|
{
|
|
|
|
e->mouse.buttons = 0;
|
|
|
|
e->mouse.button_object = NULL;
|
|
|
|
}
|