forked from enlightenment/enlightenment
Start xdnd integration.
shutdown dnd subsytem after modules. Cleanup drop handlers on module shutdown. SVN revision: 15242
This commit is contained in:
parent
b4106b7fe5
commit
b1041e45f7
|
@ -335,6 +335,26 @@ e_app_append(E_App *add, E_App *parent)
|
|||
_e_app_change(add, E_APP_ADD);
|
||||
}
|
||||
|
||||
void
|
||||
e_app_files_prepend_relative(Evas_List *files, E_App *before)
|
||||
{
|
||||
/* FIXME:
|
||||
* Parse all files
|
||||
* Put them in all
|
||||
* Change the .order file for before->parent
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
e_app_files_append(Evas_List *files, E_App *parent)
|
||||
{
|
||||
/* FIXME:
|
||||
* Parse all files
|
||||
* Put them in all
|
||||
* Change the .order file for before->parent
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
e_app_remove(E_App *remove)
|
||||
{
|
||||
|
|
|
@ -67,6 +67,8 @@ EAPI int e_app_starting_get(E_App *a);
|
|||
EAPI int e_app_running_get(E_App *a);
|
||||
EAPI void e_app_prepend_relative(E_App *add, E_App *before);
|
||||
EAPI void e_app_append(E_App *add, E_App *parent);
|
||||
EAPI void e_app_files_prepend_relative(Evas_List *files, E_App *before);
|
||||
EAPI void e_app_files_append(Evas_List *files, E_App *parent);
|
||||
EAPI void e_app_remove(E_App *remove);
|
||||
|
||||
EAPI void e_app_change_callback_add(void (*func) (void *data, E_App *a, E_App_Change ch), void *data);
|
||||
|
|
135
src/bin/e_dnd.c
135
src/bin/e_dnd.c
|
@ -3,6 +3,11 @@
|
|||
*/
|
||||
#include "e.h"
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Better system to let a drop target support several drop types
|
||||
*/
|
||||
|
||||
/* local subsystem functions */
|
||||
|
||||
static void _e_drag_free(E_Drag *drag);
|
||||
|
@ -18,6 +23,11 @@ static int _e_dnd_cb_event_dnd_selection(void *data, int type, void *event);
|
|||
|
||||
/* local subsystem globals */
|
||||
|
||||
typedef struct _XDnd {
|
||||
int x, y;
|
||||
void *data;
|
||||
} XDnd;
|
||||
|
||||
static Evas_List *_event_handlers = NULL;
|
||||
static Evas_List *_drop_handlers = NULL;
|
||||
|
||||
|
@ -26,6 +36,8 @@ static Ecore_X_Window _drag_win = 0;
|
|||
static Evas_List *_drag_list = NULL;
|
||||
static E_Drag *_drag_current = NULL;
|
||||
|
||||
static XDnd *_xdnd;
|
||||
|
||||
/* externally accessible functions */
|
||||
|
||||
int
|
||||
|
@ -285,8 +297,11 @@ e_drag_update(int x, int y)
|
|||
E_Event_Dnd_Move *move_ev;
|
||||
E_Event_Dnd_Leave *leave_ev;
|
||||
|
||||
e_drag_show(_drag_current);
|
||||
e_drag_move(_drag_current, x, y);
|
||||
if (_drag_current)
|
||||
{
|
||||
e_drag_show(_drag_current);
|
||||
e_drag_move(_drag_current, x, y);
|
||||
}
|
||||
|
||||
enter_ev = E_NEW(E_Event_Dnd_Enter, 1);
|
||||
enter_ev->x = x;
|
||||
|
@ -314,18 +329,18 @@ e_drag_update(int x, int y)
|
|||
if (!h->entered)
|
||||
{
|
||||
if (h->cb.enter)
|
||||
h->cb.enter(h->data, _drag_current->type, enter_ev);
|
||||
h->cb.enter(h->data, h->type, enter_ev);
|
||||
h->entered = 1;
|
||||
}
|
||||
if (h->cb.move)
|
||||
h->cb.move(h->data, _drag_current->type, move_ev);
|
||||
h->cb.move(h->data, h->type, move_ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->entered)
|
||||
{
|
||||
if (h->cb.leave)
|
||||
h->cb.leave(h->data, _drag_current->type, leave_ev);
|
||||
h->cb.leave(h->data, h->type, leave_ev);
|
||||
h->entered = 0;
|
||||
}
|
||||
}
|
||||
|
@ -343,15 +358,21 @@ e_drag_end(int x, int y)
|
|||
E_Event_Dnd_Drop *ev;
|
||||
int dropped;
|
||||
|
||||
e_drag_hide(_drag_current);
|
||||
if (_drag_current)
|
||||
{
|
||||
e_drag_hide(_drag_current);
|
||||
|
||||
ecore_x_pointer_ungrab();
|
||||
ecore_x_keyboard_ungrab();
|
||||
ecore_x_window_del(_drag_win);
|
||||
_drag_win = 0;
|
||||
ecore_x_pointer_ungrab();
|
||||
ecore_x_keyboard_ungrab();
|
||||
ecore_x_window_del(_drag_win);
|
||||
_drag_win = 0;
|
||||
}
|
||||
|
||||
ev = E_NEW(E_Event_Dnd_Drop, 1);
|
||||
ev->data = _drag_current->data;
|
||||
if (_drag_current)
|
||||
ev->data = _drag_current->data;
|
||||
else if (_xdnd)
|
||||
ev->data = _xdnd->data;
|
||||
ev->x = x;
|
||||
ev->y = y;
|
||||
|
||||
|
@ -368,14 +389,17 @@ e_drag_end(int x, int y)
|
|||
if ((h->cb.drop)
|
||||
&& E_INSIDE(x, y, h->x, h->y, h->w, h->h))
|
||||
{
|
||||
h->cb.drop(h->data, _drag_current->type, ev);
|
||||
h->cb.drop(h->data, h->type, ev);
|
||||
dropped = 1;
|
||||
}
|
||||
}
|
||||
if (_drag_current->cb.finished)
|
||||
_drag_current->cb.finished(_drag_current, dropped);
|
||||
e_object_del(E_OBJECT(_drag_current));
|
||||
_drag_current = NULL;
|
||||
if (_drag_current)
|
||||
{
|
||||
if (_drag_current->cb.finished)
|
||||
_drag_current->cb.finished(_drag_current, dropped);
|
||||
e_object_del(E_OBJECT(_drag_current));
|
||||
_drag_current = NULL;
|
||||
}
|
||||
|
||||
free(ev);
|
||||
}
|
||||
|
@ -421,6 +445,7 @@ e_drop_handler_geometry_set(E_Drop_Handler *handler, int x, int y, int w, int h)
|
|||
void
|
||||
e_drop_handler_del(E_Drop_Handler *handler)
|
||||
{
|
||||
_drop_handlers = evas_list_remove(_drop_handlers, handler);
|
||||
free(handler->type);
|
||||
free(handler);
|
||||
}
|
||||
|
@ -520,11 +545,29 @@ _e_dnd_cb_event_dnd_enter(void *data, int type, void *event)
|
|||
{
|
||||
Ecore_X_Event_Xdnd_Enter *ev;
|
||||
E_Container *con;
|
||||
Evas_List *l;
|
||||
int i;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
printf("Xdnd enter\n");
|
||||
for (i = 0; i < ev->num_types; i++)
|
||||
{
|
||||
printf("type: %s\n", ev->types[i]);
|
||||
/* FIXME: Maybe we want to get something else then files dropped? */
|
||||
if (strcmp("text/uri-list", ev->types[i]))
|
||||
continue;
|
||||
for (l = _drop_handlers; l; l = l->next)
|
||||
{
|
||||
E_Drop_Handler *h;
|
||||
|
||||
h = l->data;
|
||||
|
||||
h->active = !strcmp(h->type, "enlightenment/x-file");
|
||||
h->entered = 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -546,27 +589,38 @@ _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;
|
||||
Evas_List *l;
|
||||
|
||||
int active;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
printf("Xdnd pos\n");
|
||||
|
||||
#if 0
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = 0;
|
||||
rect.height = 0;
|
||||
|
||||
for (l = _drop_handlers; l; l = l->next)
|
||||
{
|
||||
E_Drop_Handler *h;
|
||||
|
||||
h = l->data;
|
||||
|
||||
if ((x >= h->x) && (x < h->x + h->w) && (y >= h->y) && (y < h->y + h->h)
|
||||
&& (!strcmp(h->type, drag_type)))
|
||||
{
|
||||
h->func(h->data, drag_type, ev);
|
||||
}
|
||||
if (h->active)
|
||||
active = 1;
|
||||
}
|
||||
#endif
|
||||
if (!active)
|
||||
{
|
||||
ecore_x_dnd_send_status(0, 0, rect, ECORE_X_DND_ACTION_PRIVATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
e_drag_update(ev->position.x, ev->position.y);
|
||||
|
||||
ecore_x_dnd_send_status(1, 0, rect, ECORE_X_DND_ACTION_PRIVATE);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -580,6 +634,12 @@ _e_dnd_cb_event_dnd_drop(void *data, int type, void *event)
|
|||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
printf("Xdnd drop\n");
|
||||
|
||||
ecore_x_selection_xdnd_request(ev->win, "text/uri-list");
|
||||
|
||||
_xdnd = E_NEW(XDnd, 1);
|
||||
_xdnd->x = ev->position.x;
|
||||
_xdnd->y = ev->position.y;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -587,11 +647,34 @@ static int
|
|||
_e_dnd_cb_event_dnd_selection(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Selection_Notify *ev;
|
||||
Ecore_X_Selection_Data_Files *files;
|
||||
E_Container *con;
|
||||
Evas_List *l = NULL;
|
||||
int i;
|
||||
|
||||
ev = event;
|
||||
con = data;
|
||||
if (con->bg_win != ev->win) return 1;
|
||||
if ((con->bg_win != ev->win) ||
|
||||
(ev->selection != ECORE_X_SELECTION_XDND)) return 1;
|
||||
printf("Xdnd selection\n");
|
||||
|
||||
files = ev->data;
|
||||
for (i = 0; i < files->num_files; i++)
|
||||
{
|
||||
printf("files: %s\n", files->files[i]);
|
||||
/* FIXME:
|
||||
* Remove file:///
|
||||
* If ftp:// or http:// use curl/wget
|
||||
* else, drop it...
|
||||
l = evas_list_append(l, files->files[i]);
|
||||
*/
|
||||
}
|
||||
|
||||
_xdnd->data = l;
|
||||
e_drag_end(_xdnd->x, _xdnd->y);
|
||||
evas_list_free(l);
|
||||
ecore_x_dnd_send_finished();
|
||||
free(_xdnd);
|
||||
_xdnd = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -397,13 +397,6 @@ main(int argc, char **argv)
|
|||
_e_main_shutdown(-1);
|
||||
}
|
||||
_e_main_shutdown_push(e_msg_shutdown);
|
||||
/* setup module loading etc */
|
||||
if (!e_module_init())
|
||||
{
|
||||
e_error_message_show(_("Enlightenment cannot set up its module system."));
|
||||
_e_main_shutdown(-1);
|
||||
}
|
||||
_e_main_shutdown_push(e_module_shutdown);
|
||||
/* setup dnd */
|
||||
if (!e_dnd_init())
|
||||
{
|
||||
|
@ -411,6 +404,13 @@ main(int argc, char **argv)
|
|||
_e_main_shutdown(-1);
|
||||
}
|
||||
_e_main_shutdown_push(e_dnd_shutdown);
|
||||
/* setup module loading etc */
|
||||
if (!e_module_init())
|
||||
{
|
||||
e_error_message_show(_("Enlightenment cannot set up its module system."));
|
||||
_e_main_shutdown(-1);
|
||||
}
|
||||
_e_main_shutdown_push(e_module_shutdown);
|
||||
/* setup winlist */
|
||||
if (!e_winlist_init())
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include <math.h>
|
||||
|
||||
/* TODO List:
|
||||
*
|
||||
|
@ -72,7 +71,8 @@ static int _ibar_bar_cb_animator(void *data);
|
|||
static void _ibar_bar_cb_enter(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_move(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_leave(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_drop(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_drop_eapp(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_drop_file(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_finished(E_Drag *drag, int dropped);
|
||||
|
||||
static void _ibar_icon_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
|
||||
|
@ -500,13 +500,20 @@ _ibar_bar_new(IBar *ib, E_Container *con)
|
|||
ibb->icon_inset.b = 100 - (y + h);
|
||||
evas_object_del(o);
|
||||
|
||||
ibb->drop_handler = e_drop_handler_add(ibb,
|
||||
_ibar_bar_cb_enter, _ibar_bar_cb_move,
|
||||
_ibar_bar_cb_leave, _ibar_bar_cb_drop,
|
||||
"enlightenment/eapp",
|
||||
ibb->x + ibb->bar_inset.l, ibb->y + ibb->bar_inset.t,
|
||||
ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r),
|
||||
ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b));
|
||||
ibb->drop_eapp = e_drop_handler_add(ibb,
|
||||
_ibar_bar_cb_enter, _ibar_bar_cb_move,
|
||||
_ibar_bar_cb_leave, _ibar_bar_cb_drop_eapp,
|
||||
"enlightenment/eapp",
|
||||
ibb->x + ibb->bar_inset.l, ibb->y + ibb->bar_inset.t,
|
||||
ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r),
|
||||
ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b));
|
||||
ibb->drop_file = e_drop_handler_add(ibb,
|
||||
_ibar_bar_cb_enter, _ibar_bar_cb_move,
|
||||
_ibar_bar_cb_leave, _ibar_bar_cb_drop_file,
|
||||
"enlightenment/x-file",
|
||||
ibb->x + ibb->bar_inset.l, ibb->y + ibb->bar_inset.t,
|
||||
ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r),
|
||||
ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b));
|
||||
|
||||
ibb->gmc = e_gadman_client_new(ibb->con->gadman);
|
||||
e_gadman_client_domain_set(ibb->gmc, "module.ibar", bar_count++);
|
||||
|
@ -547,6 +554,9 @@ _ibar_bar_free(IBar_Bar *ibb)
|
|||
while (ibb->icons)
|
||||
_ibar_icon_free(ibb->icons->data);
|
||||
|
||||
e_drop_handler_del(ibb->drop_eapp);
|
||||
e_drop_handler_del(ibb->drop_file);
|
||||
|
||||
if (ibb->timer) ecore_timer_del(ibb->timer);
|
||||
if (ibb->animator) ecore_animator_del(ibb->animator);
|
||||
evas_object_del(ibb->bar_object);
|
||||
|
@ -1542,7 +1552,7 @@ _ibar_bar_cb_leave(void *data, const char *type, void *event)
|
|||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_drop(void *data, const char *type, void *event)
|
||||
_ibar_bar_cb_drop_eapp(void *data, const char *type, void *event)
|
||||
{
|
||||
E_Event_Dnd_Drop *ev;
|
||||
E_App *app;
|
||||
|
@ -1576,6 +1586,41 @@ _ibar_bar_cb_drop(void *data, const char *type, void *event)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_drop_file(void *data, const char *type, void *event)
|
||||
{
|
||||
E_Event_Dnd_Drop *ev;
|
||||
IBar_Bar *ibb;
|
||||
IBar_Icon *ic;
|
||||
Evas_List *l;
|
||||
|
||||
ev = event;
|
||||
ibb = data;
|
||||
l = ev->data;
|
||||
|
||||
/* add dropped element */
|
||||
ic = _ibar_icon_pos_find(ibb, ev->x, ev->y);
|
||||
|
||||
/* remove drag marker */
|
||||
e_box_freeze(ibb->box_object);
|
||||
e_box_unpack(ibb->drag_object);
|
||||
evas_object_del(ibb->drag_object);
|
||||
e_box_thaw(ibb->box_object);
|
||||
|
||||
_ibar_bar_frame_resize(ibb);
|
||||
|
||||
if (ic)
|
||||
{
|
||||
/* Add new eapp before this icon */
|
||||
e_app_files_prepend_relative(l, ic->app);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add at the end */
|
||||
e_app_files_append(l, ibb->ibar->apps);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_finished(E_Drag *drag, int dropped)
|
||||
{
|
||||
|
@ -1606,7 +1651,11 @@ _ibar_bar_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change
|
|||
_ibar_bar_follower_reset(ibb);
|
||||
_ibar_bar_timer_handle(ibb);
|
||||
|
||||
e_drop_handler_geometry_set(ibb->drop_handler,
|
||||
e_drop_handler_geometry_set(ibb->drop_eapp,
|
||||
ibb->x + ibb->bar_inset.l, ibb->y + ibb->bar_inset.t,
|
||||
ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r),
|
||||
ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b));
|
||||
e_drop_handler_geometry_set(ibb->drop_file,
|
||||
ibb->x + ibb->bar_inset.l, ibb->y + ibb->bar_inset.t,
|
||||
ibb->w - (ibb->bar_inset.l + ibb->bar_inset.r),
|
||||
ibb->h - (ibb->bar_inset.t + ibb->bar_inset.b));
|
||||
|
|
|
@ -71,7 +71,8 @@ struct _IBar_Bar
|
|||
|
||||
Config_Bar *conf;
|
||||
|
||||
E_Drop_Handler *drop_handler;
|
||||
E_Drop_Handler *drop_eapp;
|
||||
E_Drop_Handler *drop_file;
|
||||
};
|
||||
|
||||
struct _IBar_Icon
|
||||
|
|
|
@ -713,6 +713,7 @@ _ibox_box_frame_resize(IBox_Box *ibb)
|
|||
e_box_min_size_get(ibb->item_object, &w, &h);
|
||||
else
|
||||
{
|
||||
/* FIXME: This isn't correct with FIXED_WIDTH! */
|
||||
w = ibb->ibox->conf->iconsize + ibb->icon_inset.l + ibb->icon_inset.r;
|
||||
h = ibb->ibox->conf->iconsize + ibb->icon_inset.t + ibb->icon_inset.b;
|
||||
}
|
||||
|
|
|
@ -390,6 +390,8 @@ _pager_face_free(Pager_Face *face)
|
|||
e_gadman_client_save(face->gmc);
|
||||
e_object_del(E_OBJECT(face->gmc));
|
||||
|
||||
e_drop_handler_del(face->drop_handler);
|
||||
|
||||
_pager_face_zone_unset(face);
|
||||
ecore_event_handler_del(face->ev_handler_border_resize);
|
||||
ecore_event_handler_del(face->ev_handler_border_move);
|
||||
|
|
Loading…
Reference in New Issue