From: Enlightenment C. <no...@cv...> - 2006-08-10 12:48:21
|
Enlightenment CVS committal Author : sebastid Project : e17 Module : apps/e Dir : e17/apps/e/src/bin Modified Files: e_dnd.c e_dnd.h e_shelf.c Log Message: Xdnd files from fm to ibar works again. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_dnd.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -3 -r1.46 -r1.47 --- e_dnd.c 10 Aug 2006 14:36:59 -0000 1.46 +++ e_dnd.c 10 Aug 2006 17:48:17 -0000 1.47 @@ -35,6 +35,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } } + 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 @@ _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 @@ _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 @@ _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 @@ _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 @@ _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)) @@ -1052,4 +1089,24 @@ free(_xdnd); _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; } =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_dnd.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- e_dnd.h 9 Nov 2005 10:58:09 -0000 1.24 +++ e_dnd.h 10 Aug 2006 17:48:17 -0000 1.25 @@ -126,6 +126,7 @@ 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 =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_shelf.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- e_shelf.c 27 Jul 2006 06:21:15 -0000 1.33 +++ e_shelf.c 10 Aug 2006 17:48:17 -0000 1.34 @@ -98,12 +98,14 @@ 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_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 @@ 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); } |