forked from enlightenment/enlightenment
Xdnd files from fm to ibar works again.
SVN revision: 24540
This commit is contained in:
parent
758ac80a8e
commit
fe296600bb
175
src/bin/e_dnd.c
175
src/bin/e_dnd.c
|
@ -35,6 +35,8 @@ static int _e_dnd_cb_event_dnd_finished(void *data, int type, void *event);
|
|||
static int _e_dnd_cb_event_dnd_drop(void *data, int type, void *event);
|
||||
static int _e_dnd_cb_event_dnd_selection(void *data, int type, void *event);
|
||||
|
||||
static char *_e_dnd_winid_str_get(Ecore_X_Window win);
|
||||
|
||||
/* local subsystem globals */
|
||||
|
||||
typedef struct _XDnd XDnd;
|
||||
|
@ -48,6 +50,7 @@ struct _XDnd
|
|||
|
||||
static Evas_List *_event_handlers = NULL;
|
||||
static Evas_List *_drop_handlers = NULL;
|
||||
static Evas_Hash *_drop_win_hash = NULL;
|
||||
|
||||
static Ecore_X_Window _drag_win = 0;
|
||||
|
||||
|
@ -61,10 +64,6 @@ static XDnd *_xdnd;
|
|||
EAPI int
|
||||
e_dnd_init(void)
|
||||
{
|
||||
Evas_List *l, *l2;
|
||||
E_Manager *man;
|
||||
E_Container *con;
|
||||
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_UP,
|
||||
_e_dnd_cb_mouse_up, NULL));
|
||||
|
@ -75,45 +74,27 @@ e_dnd_init(void)
|
|||
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHAPE,
|
||||
_e_dnd_cb_window_shape, NULL));
|
||||
|
||||
for (l = e_manager_list(); l; l = l->next)
|
||||
{
|
||||
man = l->data;
|
||||
|
||||
for (l2 = man->containers; l2; l2 = l2->next)
|
||||
{
|
||||
con = l2->data;
|
||||
|
||||
ecore_x_dnd_aware_set(con->bg_win, 1);
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_ENTER,
|
||||
_e_dnd_cb_event_dnd_enter,
|
||||
con));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_LEAVE,
|
||||
_e_dnd_cb_event_dnd_leave,
|
||||
con));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION,
|
||||
_e_dnd_cb_event_dnd_position,
|
||||
con));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_STATUS,
|
||||
_e_dnd_cb_event_dnd_status,
|
||||
con));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_FINISHED,
|
||||
_e_dnd_cb_event_dnd_finished,
|
||||
con));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP,
|
||||
_e_dnd_cb_event_dnd_drop,
|
||||
con));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
|
||||
_e_dnd_cb_event_dnd_selection,
|
||||
con));
|
||||
}
|
||||
}
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_ENTER,
|
||||
_e_dnd_cb_event_dnd_enter, NULL));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_LEAVE,
|
||||
_e_dnd_cb_event_dnd_leave, NULL));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION,
|
||||
_e_dnd_cb_event_dnd_position, NULL));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_STATUS,
|
||||
_e_dnd_cb_event_dnd_status, NULL));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_FINISHED,
|
||||
_e_dnd_cb_event_dnd_finished, NULL));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP,
|
||||
_e_dnd_cb_event_dnd_drop, NULL));
|
||||
_event_handlers = evas_list_append(_event_handlers,
|
||||
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
|
||||
_e_dnd_cb_event_dnd_selection, NULL));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -140,6 +121,7 @@ e_dnd_shutdown(void)
|
|||
evas_list_free(_event_handlers);
|
||||
_event_handlers = NULL;
|
||||
|
||||
evas_hash_free(_drop_win_hash);
|
||||
for (l = _drop_handlers; l; l = l->next)
|
||||
{
|
||||
E_Drop_Handler *h;
|
||||
|
@ -373,6 +355,27 @@ e_drop_handler_del(E_Drop_Handler *handler)
|
|||
free(handler);
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_drop_xdnd_register_set(Ecore_X_Window win, int reg)
|
||||
{
|
||||
const char *id;
|
||||
|
||||
id = _e_dnd_winid_str_get(win);
|
||||
if (reg)
|
||||
{
|
||||
if (!evas_hash_find(_drop_win_hash, id))
|
||||
{
|
||||
ecore_x_dnd_aware_set(win, 1);
|
||||
_drop_win_hash = evas_hash_add(_drop_win_hash, id, (void *)1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ecore_x_dnd_aware_set(win, 0);
|
||||
_drop_win_hash = evas_hash_del(_drop_win_hash, id, (void *) 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_drag_idler_before(void)
|
||||
|
@ -538,6 +541,39 @@ _e_drag_update(int x, int y)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (_xdnd)
|
||||
{
|
||||
for (l = _drop_handlers; l; l = l->next)
|
||||
{
|
||||
E_Drop_Handler *h;
|
||||
|
||||
h = l->data;
|
||||
|
||||
if (!h->active)
|
||||
continue;
|
||||
|
||||
if (E_INSIDE(x, y, h->x, h->y, h->w, h->h))
|
||||
{
|
||||
if (!h->entered)
|
||||
{
|
||||
if (h->cb.enter)
|
||||
h->cb.enter(h->cb.data, _xdnd->type, enter_ev);
|
||||
h->entered = 1;
|
||||
}
|
||||
if (h->cb.move)
|
||||
h->cb.move(h->cb.data, _xdnd->type, move_ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->entered)
|
||||
{
|
||||
if (h->cb.leave)
|
||||
h->cb.leave(h->cb.data, _xdnd->type, leave_ev);
|
||||
h->entered = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(enter_ev);
|
||||
free(move_ev);
|
||||
free(leave_ev);
|
||||
|
@ -774,14 +810,14 @@ static int
|
|||
_e_dnd_cb_event_dnd_enter(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Enter *ev;
|
||||
E_Container *con;
|
||||
const char *id;
|
||||
Evas_List *l;
|
||||
int i, j;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
if (ev->source == _drag_win) return 1;
|
||||
id = _e_dnd_winid_str_get(ev->win);
|
||||
if (!evas_hash_find(_drop_win_hash, id)) return 1;
|
||||
printf("Xdnd enter\n");
|
||||
for (l = _drop_handlers; l; l = l->next)
|
||||
{
|
||||
|
@ -841,14 +877,15 @@ static int
|
|||
_e_dnd_cb_event_dnd_leave(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Leave *ev;
|
||||
E_Container *con;
|
||||
E_Event_Dnd_Leave *leave_ev;
|
||||
const char *id;
|
||||
Evas_List *l;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
|
||||
if (ev->source == _drag_win) return 1;
|
||||
id = _e_dnd_winid_str_get(ev->win);
|
||||
if (!evas_hash_find(_drop_win_hash, id)) return 1;
|
||||
printf("Xdnd leave\n");
|
||||
|
||||
leave_ev = E_NEW(E_Event_Dnd_Leave, 1);
|
||||
|
@ -887,16 +924,16 @@ static int
|
|||
_e_dnd_cb_event_dnd_position(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Position *ev;
|
||||
E_Container *con;
|
||||
Ecore_X_Rectangle rect;
|
||||
const char *id;
|
||||
Evas_List *l;
|
||||
|
||||
int active;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
if (ev->source == _drag_win) return 1;
|
||||
id = _e_dnd_winid_str_get(ev->win);
|
||||
if (!evas_hash_find(_drop_win_hash, id)) return 1;
|
||||
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
|
@ -962,12 +999,12 @@ static int
|
|||
_e_dnd_cb_event_dnd_drop(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Xdnd_Drop *ev;
|
||||
E_Container *con;
|
||||
const char *id;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
if (ev->source == _drag_win) return 1;
|
||||
id = _e_dnd_winid_str_get(ev->win);
|
||||
if (!evas_hash_find(_drop_win_hash, id)) return 1;
|
||||
printf("Xdnd drop\n");
|
||||
|
||||
ecore_x_selection_xdnd_request(ev->win, _xdnd->type);
|
||||
|
@ -981,13 +1018,13 @@ static int
|
|||
_e_dnd_cb_event_dnd_selection(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Selection_Notify *ev;
|
||||
E_Container *con;
|
||||
const char *id;
|
||||
int i;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if ((con->bg_win != ev->win) ||
|
||||
(ev->selection != ECORE_X_SELECTION_XDND)) return 1;
|
||||
id = _e_dnd_winid_str_get(ev->win);
|
||||
if (!evas_hash_find(_drop_win_hash, id)) return 1;
|
||||
if (ev->selection != ECORE_X_SELECTION_XDND) return 1;
|
||||
printf("Xdnd selection\n");
|
||||
|
||||
if (!strcmp("text/uri-list", _xdnd->type))
|
||||
|
@ -1053,3 +1090,23 @@ _e_dnd_cb_event_dnd_selection(void *data, int type, void *event)
|
|||
_xdnd = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char *
|
||||
_e_dnd_winid_str_get(Ecore_X_Window win)
|
||||
{
|
||||
const char *vals = "qWeRtYuIoP5-$&<~";
|
||||
static char id[9];
|
||||
unsigned int val;
|
||||
|
||||
val = (unsigned int)win;
|
||||
id[0] = vals[(val >> 28) & 0xf];
|
||||
id[1] = vals[(val >> 24) & 0xf];
|
||||
id[2] = vals[(val >> 20) & 0xf];
|
||||
id[3] = vals[(val >> 16) & 0xf];
|
||||
id[4] = vals[(val >> 12) & 0xf];
|
||||
id[5] = vals[(val >> 8) & 0xf];
|
||||
id[6] = vals[(val >> 4) & 0xf];
|
||||
id[7] = vals[(val ) & 0xf];
|
||||
id[8] = 0;
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ EAPI E_Drop_Handler *e_drop_handler_add(void *data,
|
|||
int x, int y, int w, int h);
|
||||
EAPI void e_drop_handler_geometry_set(E_Drop_Handler *handler, int x, int y, int w, int h);
|
||||
EAPI void e_drop_handler_del(E_Drop_Handler *handler);
|
||||
EAPI int e_drop_xdnd_register_set(Ecore_X_Window win, int reg);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -98,12 +98,14 @@ e_shelf_zone_new(E_Zone *zone, const char *name, const char *style, int popup, i
|
|||
if (popup)
|
||||
{
|
||||
es->popup = e_popup_new(zone, es->x, es->y, es->w, es->h);
|
||||
e_drop_xdnd_register_set(es->popup->evas_win, 1);
|
||||
e_popup_layer_set(es->popup, layer);
|
||||
es->ee = es->popup->ecore_evas;
|
||||
es->evas = es->popup->evas;
|
||||
}
|
||||
else
|
||||
{
|
||||
e_drop_xdnd_register_set(zone->container->bg_win, 1);
|
||||
es->ee = zone->container->bg_ecore_evas;
|
||||
es->evas = zone->container->bg_evas;
|
||||
}
|
||||
|
@ -480,11 +482,11 @@ e_shelf_popup_set(E_Shelf *es, int popup)
|
|||
E_OBJECT_TYPE_CHECK(es, E_SHELF_TYPE);
|
||||
|
||||
if (!es->cfg) return;
|
||||
if (es->popup)
|
||||
e_object_del(E_OBJECT(es->popup));
|
||||
if (es->popup) e_object_del(E_OBJECT(es->popup));
|
||||
if (popup)
|
||||
{
|
||||
es->popup = e_popup_new(es->zone, es->x, es->y, es->w, es->h);
|
||||
e_drop_xdnd_register_set(es->popup->evas_win, 1);
|
||||
e_popup_layer_set(es->popup, es->cfg->layer);
|
||||
es->ee = es->popup->ecore_evas;
|
||||
es->evas = es->popup->evas;
|
||||
|
@ -518,7 +520,11 @@ _e_shelf_free(E_Shelf *es)
|
|||
evas_stringshare_del(es->style);
|
||||
evas_object_del(es->o_event);
|
||||
evas_object_del(es->o_base);
|
||||
if (es->popup) e_object_del(E_OBJECT(es->popup));
|
||||
if (es->popup)
|
||||
{
|
||||
e_drop_xdnd_register_set(es->popup->evas_win, 0);
|
||||
e_object_del(E_OBJECT(es->popup));
|
||||
}
|
||||
free(es);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue