SVN revision: 14324
This commit is contained in:
sebastid 2005-04-24 16:04:20 +00:00 committed by sebastid
parent b4fee75d32
commit 15996823aa
5 changed files with 46 additions and 75 deletions

View File

@ -4,7 +4,7 @@
#include "e.h" #include "e.h"
static Evas_List *event_handlers = NULL; static Evas_List *event_handlers = NULL;
static Evas_List *dnd_handlers = NULL; static Evas_List *drop_handlers = NULL;
static Ecore_X_Window drag_win; static Ecore_X_Window drag_win;
static Ecore_Evas *drag_ee = NULL; static Ecore_Evas *drag_ee = NULL;
@ -61,15 +61,15 @@ e_dnd_shutdown(void)
evas_list_free(event_handlers); evas_list_free(event_handlers);
event_handlers = NULL; event_handlers = NULL;
for (l = dnd_handlers; l; l = l->next) for (l = drop_handlers; l; l = l->next)
{ {
E_DND_Handler *h; E_Drop_Handler *h;
h = l->data; h = l->data;
e_dnd_handler_del(h); e_drop_handler_del(h);
} }
evas_list_free(dnd_handlers); evas_list_free(drop_handlers);
dnd_handlers = NULL; drop_handlers = NULL;
return 1; return 1;
} }
@ -146,9 +146,9 @@ e_drag_end(int x, int y)
ecore_x_keyboard_ungrab(); ecore_x_keyboard_ungrab();
ecore_x_window_del(drag_win); ecore_x_window_del(drag_win);
for (l = dnd_handlers; l; l = l->next) for (l = drop_handlers; l; l = l->next)
{ {
E_DND_Handler *h; E_Drop_Handler *h;
h = l->data; h = l->data;
@ -163,14 +163,16 @@ e_drag_end(int x, int y)
} }
free(drag_type); free(drag_type);
drag_type = NULL;
drag_data = NULL;
} }
E_DND_Handler * E_Drop_Handler *
e_dnd_handler_add(void *data, void (*func)(void *data, const char *type, void *drop), const char *type, int x, int y, int w, int h) e_drop_handler_add(void *data, void (*func)(void *data, const char *type, void *drop), const char *type, int x, int y, int w, int h)
{ {
E_DND_Handler *handler; E_Drop_Handler *handler;
handler = E_NEW(E_DND_Handler, 1); handler = E_NEW(E_Drop_Handler, 1);
if (!handler) return NULL; if (!handler) return NULL;
handler->data = data; handler->data = data;
@ -181,13 +183,13 @@ e_dnd_handler_add(void *data, void (*func)(void *data, const char *type, void *d
handler->w = w; handler->w = w;
handler->h = h; handler->h = h;
dnd_handlers = evas_list_append(dnd_handlers, handler); drop_handlers = evas_list_append(drop_handlers, handler);
return handler; return handler;
} }
void void
e_dnd_handler_del(E_DND_Handler *handler) e_drop_handler_del(E_Drop_Handler *handler)
{ {
free(handler->type); free(handler->type);
free(handler); free(handler);

View File

@ -4,13 +4,13 @@
#ifdef E_TYPEDEFS #ifdef E_TYPEDEFS
typedef struct _E_DND_Handler E_DND_Handler; typedef struct _E_Drop_Handler E_Drop_Handler;
#else #else
#ifndef E_DND_H #ifndef E_DND_H
#define E_DND_H #define E_DND_H
struct _E_DND_Handler struct _E_Drop_Handler
{ {
void *data; void *data;
void (*func)(void *data, const char *type, void *drop); void (*func)(void *data, const char *type, void *drop);
@ -25,8 +25,8 @@ EAPI void e_drag_start(E_Zone *zone, const char *type, void *data, const char *i
EAPI void e_drag_update(int x, int y); EAPI void e_drag_update(int x, int y);
EAPI void e_drag_end(int x, int y); EAPI void e_drag_end(int x, int y);
EAPI E_DND_Handler *e_dnd_handler_add(void *data, void (*func)(void *data, const char *type, void *drop), const char *type, int x, int y, int w, int h); EAPI E_Drop_Handler *e_drop_handler_add(void *data, void (*func)(void *data, const char *type, void *drop), const char *type, int x, int y, int w, int h);
EAPI void e_dnd_handler_del(E_DND_Handler *handler); EAPI void e_drop_handler_del(E_Drop_Handler *handler);
#endif #endif
#endif #endif

View File

@ -17,13 +17,14 @@ static int _e_zone_cb_mouse_in(void *data, int type, void *event);
static int _e_zone_cb_mouse_out(void *data, int type, void *event); static int _e_zone_cb_mouse_out(void *data, int type, void *event);
static int _e_zone_cb_timer(void *data); static int _e_zone_cb_timer(void *data);
static void _e_zone_update_flip(E_Zone *zone); static void _e_zone_update_flip(E_Zone *zone);
static int _e_zone_flip_up(E_Zone *zone, int x, int y);
static int _e_zone_flip_right(E_Zone *zone, int x, int y);
static int _e_zone_flip_down(E_Zone *zone, int x, int y);
static int _e_zone_flip_left(E_Zone *zone, int x, int y);
int E_EVENT_ZONE_DESK_COUNT_SET = 0; int E_EVENT_ZONE_DESK_COUNT_SET = 0;
#define E_ZONE_FLIP_UP(zone) ((zone)->desk_y_current > 0)
#define E_ZONE_FLIP_RIGHT(zone) (((zone)->desk_x_current + 1) < (zone)->desk_x_count)
#define E_ZONE_FLIP_DOWN(zone) (((zone)->desk_y_current + 1) < (zone)->desk_y_count)
#define E_ZONE_FLIP_LEFT(zone) ((zone)->desk_x_current > 0)
int int
e_zone_init(void) e_zone_init(void)
{ {
@ -238,7 +239,7 @@ e_zone_bg_reconfigure(E_Zone *zone)
void void
e_zone_flip_coords_handle(E_Zone *zone, int x, int y) e_zone_flip_coords_handle(E_Zone *zone, int x, int y)
{ {
if ((y == 0) && _e_zone_flip_up(zone, x, y)) if ((y == 0) && E_ZONE_FLIP_UP(zone))
{ {
/* top */ /* top */
if (zone->flip.timer) if (zone->flip.timer)
@ -246,7 +247,7 @@ e_zone_flip_coords_handle(E_Zone *zone, int x, int y)
zone->flip.timer = ecore_timer_add(0.5, _e_zone_cb_timer, zone); zone->flip.timer = ecore_timer_add(0.5, _e_zone_cb_timer, zone);
zone->flip.direction = E_DIRECTION_UP; zone->flip.direction = E_DIRECTION_UP;
} }
else if ((x == (zone->w - 1)) && _e_zone_flip_right(zone, x, y)) else if ((x == (zone->w - 1)) && E_ZONE_FLIP_RIGHT(zone))
{ {
/* right */ /* right */
if (zone->flip.timer) if (zone->flip.timer)
@ -254,7 +255,7 @@ e_zone_flip_coords_handle(E_Zone *zone, int x, int y)
zone->flip.timer = ecore_timer_add(0.5, _e_zone_cb_timer, zone); zone->flip.timer = ecore_timer_add(0.5, _e_zone_cb_timer, zone);
zone->flip.direction = E_DIRECTION_RIGHT; zone->flip.direction = E_DIRECTION_RIGHT;
} }
else if ((y == (zone->h - 1)) && _e_zone_flip_down(zone, x, y)) else if ((y == (zone->h - 1)) && E_ZONE_FLIP_DOWN(zone))
{ {
/* bottom */ /* bottom */
if (zone->flip.timer) if (zone->flip.timer)
@ -262,7 +263,7 @@ e_zone_flip_coords_handle(E_Zone *zone, int x, int y)
zone->flip.timer = ecore_timer_add(0.5, _e_zone_cb_timer, zone); zone->flip.timer = ecore_timer_add(0.5, _e_zone_cb_timer, zone);
zone->flip.direction = E_DIRECTION_DOWN; zone->flip.direction = E_DIRECTION_DOWN;
} }
else if ((x == 0) && _e_zone_flip_left(zone, x, y)) else if ((x == 0) && E_ZONE_FLIP_LEFT(zone))
{ {
/* left */ /* left */
if (zone->flip.timer) if (zone->flip.timer)
@ -572,7 +573,7 @@ _e_zone_cb_timer(void *data)
switch (zone->flip.direction) switch (zone->flip.direction)
{ {
case E_DIRECTION_UP: case E_DIRECTION_UP:
if (_e_zone_flip_up(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_UP(zone))
{ {
desk = e_desk_at_xy_get(zone, zone->desk_x_current, zone->desk_y_current - 1); desk = e_desk_at_xy_get(zone, zone->desk_x_current, zone->desk_y_current - 1);
if (desk) if (desk)
@ -584,7 +585,7 @@ _e_zone_cb_timer(void *data)
} }
break; break;
case E_DIRECTION_RIGHT: case E_DIRECTION_RIGHT:
if (_e_zone_flip_right(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_RIGHT(zone))
{ {
desk = e_desk_at_xy_get(zone, zone->desk_x_current + 1, zone->desk_y_current); desk = e_desk_at_xy_get(zone, zone->desk_x_current + 1, zone->desk_y_current);
if (desk) if (desk)
@ -596,7 +597,7 @@ _e_zone_cb_timer(void *data)
} }
break; break;
case E_DIRECTION_DOWN: case E_DIRECTION_DOWN:
if (_e_zone_flip_down(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_DOWN(zone))
{ {
desk = e_desk_at_xy_get(zone, zone->desk_x_current, zone->desk_y_current + 1); desk = e_desk_at_xy_get(zone, zone->desk_x_current, zone->desk_y_current + 1);
if (desk) if (desk)
@ -608,7 +609,7 @@ _e_zone_cb_timer(void *data)
} }
break; break;
case E_DIRECTION_LEFT: case E_DIRECTION_LEFT:
if (_e_zone_flip_left(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_LEFT(zone))
{ {
desk = e_desk_at_xy_get(zone, zone->desk_x_current - 1, zone->desk_y_current); desk = e_desk_at_xy_get(zone, zone->desk_x_current - 1, zone->desk_y_current);
if (desk) if (desk)
@ -630,55 +631,23 @@ static void
_e_zone_update_flip(E_Zone *zone) _e_zone_update_flip(E_Zone *zone)
{ {
if (_e_zone_flip_up(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_UP(zone))
ecore_x_window_show(zone->flip.top); ecore_x_window_show(zone->flip.top);
else else
ecore_x_window_hide(zone->flip.top); ecore_x_window_hide(zone->flip.top);
if (_e_zone_flip_right(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_RIGHT(zone))
ecore_x_window_show(zone->flip.right); ecore_x_window_show(zone->flip.right);
else else
ecore_x_window_hide(zone->flip.right); ecore_x_window_hide(zone->flip.right);
if (_e_zone_flip_down(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_DOWN(zone))
ecore_x_window_show(zone->flip.bottom); ecore_x_window_show(zone->flip.bottom);
else else
ecore_x_window_hide(zone->flip.bottom); ecore_x_window_hide(zone->flip.bottom);
if (_e_zone_flip_left(zone, zone->desk_x_current, zone->desk_y_current)) if (E_ZONE_FLIP_LEFT(zone))
ecore_x_window_show(zone->flip.left); ecore_x_window_show(zone->flip.left);
else else
ecore_x_window_hide(zone->flip.left); ecore_x_window_hide(zone->flip.left);
} }
static int
_e_zone_flip_up(E_Zone *zone, int x, int y)
{
if (zone->desk_y_current > 0)
return 1;
return 0;
}
static int
_e_zone_flip_right(E_Zone *zone, int x, int y)
{
if ((zone->desk_x_current + 1) < zone->desk_x_count)
return 1;
return 0;
}
static int
_e_zone_flip_down(E_Zone *zone, int x, int y)
{
if ((zone->desk_y_current + 1) < zone->desk_y_count)
return 1;
return 0;
}
static int
_e_zone_flip_left(E_Zone *zone, int x, int y)
{
if (zone->desk_x_current > 0)
return 1;
return 0;
}

View File

@ -62,7 +62,7 @@ static void _pager_desk_cb_mouse_move(void *data, Evas *e, Evas_Object *o
static void _pager_desk_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y); static void _pager_desk_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
static void _pager_desk_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h); static void _pager_desk_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
static void _pager_dnd_cb(void *data, const char *type, void *drop); static void _pager_drop_cb(void *data, const char *type, void *drop);
static int _pager_count; static int _pager_count;
@ -341,8 +341,8 @@ _pager_face_new(E_Zone *zone)
edje_object_part_swallow(face->pager_object, "items", face->table_object); edje_object_part_swallow(face->pager_object, "items", face->table_object);
evas_object_show(o); evas_object_show(o);
face->dnd_handler = e_dnd_handler_add(face, _pager_dnd_cb, "enlightenment/border", face->drop_handler = e_drop_handler_add(face, _pager_drop_cb, "enlightenment/border",
face->fx, face->fy, face->fw, face->fh); face->fx, face->fy, face->fw, face->fh);
face->gmc = e_gadman_client_new(zone->container->gadman); face->gmc = e_gadman_client_new(zone->container->gadman);
_pager_face_zone_set(face, zone); _pager_face_zone_set(face, zone);
@ -715,10 +715,10 @@ _pager_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change chan
face = data; face = data;
e_gadman_client_geometry_get(face->gmc, &x, &y, &w, &h); e_gadman_client_geometry_get(face->gmc, &x, &y, &w, &h);
face->dnd_handler->x = face->fx = x; face->drop_handler->x = face->fx = x;
face->dnd_handler->y = face->fy = y; face->drop_handler->y = face->fy = y;
face->dnd_handler->w = face->fw = w; face->drop_handler->w = face->fw = w;
face->dnd_handler->h = face->fh = h; face->drop_handler->h = face->fh = h;
switch (change) switch (change)
{ {
case E_GADMAN_CHANGE_MOVE_RESIZE: case E_GADMAN_CHANGE_MOVE_RESIZE:
@ -1363,7 +1363,7 @@ _pager_desk_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_C
} }
static void static void
_pager_dnd_cb(void *data, const char *type, void *drop) _pager_drop_cb(void *data, const char *type, void *drop)
{ {
printf("We have a drop!\n"); printf("We have a drop!\n");
} }

View File

@ -75,7 +75,7 @@ struct _Pager_Face
Ecore_Event_Handler *ev_handler_desk_show; Ecore_Event_Handler *ev_handler_desk_show;
Ecore_Event_Handler *ev_handler_container_resize; Ecore_Event_Handler *ev_handler_container_resize;
E_DND_Handler *dnd_handler; E_Drop_Handler *drop_handler;
}; };
struct _Pager_Desk struct _Pager_Desk