forked from enlightenment/enlightenment
Some cleanup and beginning of internal dnd in E. You can drag the icon from
a window to the pager and get a nice message :) SVN revision: 14314
This commit is contained in:
parent
aa3bd0c5fd
commit
c43e391779
|
@ -1132,6 +1132,12 @@ group {
|
|||
source: "icon";
|
||||
action: SIGNAL_EMIT "action" "menu";
|
||||
}
|
||||
program {
|
||||
name: "menu_action_icon4";
|
||||
signal: "mouse,down,1";
|
||||
source: "icon";
|
||||
action: SIGNAL_EMIT "drag" "start";
|
||||
}
|
||||
program {
|
||||
name: "menu_action_title3";
|
||||
signal: "mouse,clicked,3";
|
||||
|
|
|
@ -46,7 +46,8 @@ e_layout.h \
|
|||
e_test.h \
|
||||
e_font.h \
|
||||
e_intl.h \
|
||||
e_theme.h
|
||||
e_theme.h \
|
||||
e_dnd.h
|
||||
|
||||
enlightenment_SOURCES = \
|
||||
e_main.c \
|
||||
|
@ -86,6 +87,7 @@ e_test.c \
|
|||
e_font.c \
|
||||
e_intl.c \
|
||||
e_theme.c \
|
||||
e_dnd.c \
|
||||
$(ENLIGHTENMENTHEADERS)
|
||||
|
||||
enlightenment_LDFLAGS = -export-dynamic @e_libs@ @dlopen_libs@
|
||||
|
|
|
@ -49,6 +49,7 @@ static void _e_border_cb_signal_resize_bl_start(void *data, Evas_Object *obj, co
|
|||
static void _e_border_cb_signal_resize_l_start(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _e_border_cb_signal_resize_stop(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _e_border_cb_signal_action(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _e_border_cb_signal_drag(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static int _e_border_cb_mouse_in(void *data, int type, void *event);
|
||||
static int _e_border_cb_mouse_out(void *data, int type, void *event);
|
||||
static int _e_border_cb_mouse_down(void *data, int type, void *event);
|
||||
|
@ -75,10 +76,6 @@ static void _e_border_menu_cb_stick(void *data, E_Menu *m, E_Menu_Item *mi);
|
|||
static void _e_border_menu_sendto_pre_cb(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_border_menu_sendto_cb(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
|
||||
static void _e_border_icon_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_border_icon_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_border_icon_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
|
||||
static void _e_border_event_border_add_free(void *data, void *ev);
|
||||
static void _e_border_event_border_remove_free(void *data, void *ev);
|
||||
static void _e_border_event_border_zone_set_free(void *data, void *ev);
|
||||
|
@ -1950,6 +1947,28 @@ _e_border_cb_signal_action(void *data, Evas_Object *obj, const char *emission, c
|
|||
|
||||
}
|
||||
|
||||
static void
|
||||
_e_border_cb_signal_drag(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
E_Border *bd;
|
||||
|
||||
bd = data;
|
||||
|
||||
printf("drag_start\n");
|
||||
if ((bd->client.icccm.name) && (bd->client.icccm.class))
|
||||
{
|
||||
E_App *a;
|
||||
|
||||
a = e_app_window_name_class_find(bd->client.icccm.name,
|
||||
bd->client.icccm.class);
|
||||
if (a)
|
||||
{
|
||||
e_drag_start(bd->zone, "enlightenment/border", bd,
|
||||
a->path, "icon");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_e_border_cb_mouse_in(void *data, int type, void *event)
|
||||
{
|
||||
|
@ -2422,11 +2441,6 @@ _e_border_eval(E_Border *bd)
|
|||
{
|
||||
evas_object_show(bd->icon_object);
|
||||
edje_object_part_swallow(bd->bg_object, "icon_swallow", bd->icon_object);
|
||||
#if 0
|
||||
evas_object_callback_add(bd->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_border_icon_cb_mouse_down, bd);
|
||||
evas_object_callback_add(bd->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_border_icon_cb_mouse_up, bd);
|
||||
evas_object_callback_add(bd->icon_object, EVAS_CALLBACK_MOUSE_MOVE, _e_border_icon_cb_mouse_move, bd);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2733,6 +2747,8 @@ _e_border_eval(E_Border *bd)
|
|||
_e_border_cb_signal_resize_stop, bd);
|
||||
edje_object_signal_callback_add(o, "action", "*",
|
||||
_e_border_cb_signal_action, bd);
|
||||
edje_object_signal_callback_add(o, "drag", "*",
|
||||
_e_border_cb_signal_drag, bd);
|
||||
if (bd->focused)
|
||||
edje_object_signal_emit(bd->bg_object, "active", "");
|
||||
evas_object_move(o, 0, 0);
|
||||
|
@ -3688,38 +3704,6 @@ _e_border_menu_sendto_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_border_icon_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
E_Border *bd;
|
||||
Evas_Event_Mouse_Down *ev;
|
||||
|
||||
ev = event_info;
|
||||
bd = data;
|
||||
|
||||
if (ev->button != 2)
|
||||
return;
|
||||
if (ev->flags != EVAS_BUTTON_NONE)
|
||||
return;
|
||||
if (ev->modifiers)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
ecore_x_dnd_type_set(win, "enlightenment/border", 1);
|
||||
ecore_x_dnd_begin(win, bd->win, sizeof(bd->win));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
_e_border_icon_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_e_border_icon_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_e_border_event_border_resize_free(void *data, void *ev)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "e.h"
|
||||
|
||||
static Evas_List *event_handlers = NULL;
|
||||
static Evas_List *dnd_handlers = NULL;
|
||||
|
||||
static Ecore_X_Window drag_win;
|
||||
static Ecore_Evas *drag_ee = NULL;
|
||||
static Evas_Object *drag_obj;
|
||||
|
||||
static char *drag_type;
|
||||
static void *drag_data;
|
||||
|
||||
static int _e_dnd_cb_mouse_up(void *data, int type, void *event);
|
||||
static int _e_dnd_cb_mouse_move(void *data, int type, void *event);
|
||||
|
||||
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));
|
||||
event_handlers = evas_list_append(event_handlers, ecore_event_handler_add(ECORE_X_EVENT_MOUSE_MOVE, _e_dnd_cb_mouse_move, NULL));
|
||||
|
||||
for (l = e_manager_list(); l; l = l->next)
|
||||
{
|
||||
man = l->data;
|
||||
|
||||
for (l2 = man->containers; l2; l2 = l2->next)
|
||||
{
|
||||
con = l2->data;
|
||||
|
||||
#if 0
|
||||
e_hints_window_visible_set(con->bg_win);
|
||||
ecore_x_dnd_aware_set(con->bg_win, 1);
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, _e_dnd_cb_event_dnd_drop , eb);
|
||||
ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, _e_dnd_cb_event_dnd_position, eb);
|
||||
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, _e_dnd_cb_event_dnd_selection, eb);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
e_dnd_shutdown(void)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for (l = event_handlers; l; l = l->next)
|
||||
{
|
||||
Ecore_Event_Handler *h;
|
||||
|
||||
h = l->data;
|
||||
ecore_event_handler_del(h);
|
||||
}
|
||||
evas_list_free(event_handlers);
|
||||
event_handlers = NULL;
|
||||
|
||||
for (l = dnd_handlers; l; l = l->next)
|
||||
{
|
||||
E_DND_Handler *h;
|
||||
|
||||
h = l->data;
|
||||
e_dnd_handler_del(h);
|
||||
}
|
||||
evas_list_free(dnd_handlers);
|
||||
dnd_handlers = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
e_drag_start(E_Zone *zone, const char *type, void *data, const char *icon_path, const char *icon)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
drag_win = ecore_x_window_input_new(zone->container->win,
|
||||
zone->x, zone->y,
|
||||
zone->w, zone->h);
|
||||
ecore_x_window_show(drag_win);
|
||||
ecore_x_pointer_confine_grab(drag_win);
|
||||
ecore_x_keyboard_grab(drag_win);
|
||||
|
||||
if (drag_ee)
|
||||
{
|
||||
e_canvas_del(drag_ee);
|
||||
ecore_evas_free(drag_ee);
|
||||
}
|
||||
|
||||
drag_ee = ecore_evas_software_x11_new(NULL, zone->container->manager->win,
|
||||
0, 0, 10, 10);
|
||||
ecore_evas_override_set(drag_ee, 1);
|
||||
ecore_evas_software_x11_direct_resize_set(drag_ee, 1);
|
||||
ecore_evas_shaped_set(drag_ee, 1);
|
||||
e_canvas_add(drag_ee);
|
||||
ecore_evas_borderless_set(drag_ee, 1);
|
||||
ecore_evas_layer_set(drag_ee, 255);
|
||||
|
||||
drag_obj = edje_object_add(ecore_evas_get(drag_ee));
|
||||
edje_object_file_set(drag_obj, icon_path, icon);
|
||||
|
||||
w = h = 24;
|
||||
evas_object_move(drag_obj, 0, 0);
|
||||
evas_object_resize(drag_obj, w, h);
|
||||
|
||||
ecore_evas_resize(drag_ee, w, h);
|
||||
|
||||
drag_type = strdup(type);
|
||||
drag_data = data;
|
||||
}
|
||||
|
||||
void
|
||||
e_drag_update(int x, int y)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
if (!drag_ee) return;
|
||||
|
||||
evas_object_geometry_get(drag_obj, NULL, NULL, &w, &h);
|
||||
evas_object_show(drag_obj);
|
||||
ecore_evas_show(drag_ee);
|
||||
|
||||
ecore_evas_move(drag_ee, x - (w / 2), y - (h / 2));
|
||||
}
|
||||
|
||||
void
|
||||
e_drag_end(int x, int y)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
printf("drag_end\n");
|
||||
|
||||
evas_object_del(drag_obj);
|
||||
if (drag_ee)
|
||||
{
|
||||
e_canvas_del(drag_ee);
|
||||
ecore_evas_free(drag_ee);
|
||||
drag_ee = NULL;
|
||||
}
|
||||
ecore_x_pointer_ungrab();
|
||||
ecore_x_keyboard_ungrab();
|
||||
ecore_x_window_del(drag_win);
|
||||
|
||||
for (l = dnd_handlers; l; l = l->next)
|
||||
{
|
||||
E_DND_Handler *h;
|
||||
|
||||
h = l->data;
|
||||
|
||||
printf("pos: %d %d\n", x, y);
|
||||
printf("pos: %d %d %d %d", h->x, h->y, h->w, h->y);
|
||||
printf("data: %s %s\n", h->type, drag_type);
|
||||
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, drag_data);
|
||||
}
|
||||
}
|
||||
|
||||
free(drag_type);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
E_DND_Handler *handler;
|
||||
|
||||
handler = E_NEW(E_DND_Handler, 1);
|
||||
if (!handler) return NULL;
|
||||
|
||||
handler->data = data;
|
||||
handler->func = func;
|
||||
handler->type = strdup(type);
|
||||
handler->x = x;
|
||||
handler->y = y;
|
||||
handler->w = w;
|
||||
handler->h = h;
|
||||
|
||||
dnd_handlers = evas_list_append(dnd_handlers, handler);
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
void
|
||||
e_dnd_handler_del(E_DND_Handler *handler)
|
||||
{
|
||||
free(handler->type);
|
||||
free(handler);
|
||||
}
|
||||
|
||||
static int
|
||||
_e_dnd_cb_mouse_up(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Mouse_Button_Up *ev;
|
||||
|
||||
ev = event;
|
||||
if (ev->win != drag_win) return 1;
|
||||
|
||||
e_drag_end(ev->x, ev->y);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_e_dnd_cb_mouse_move(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Mouse_Move *ev;
|
||||
|
||||
ev = event;
|
||||
if (ev->win != drag_win) return 1;
|
||||
|
||||
e_drag_update(ev->x, ev->y);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_DND_Handler E_DND_Handler;
|
||||
|
||||
#else
|
||||
#ifndef E_DND_H
|
||||
#define E_DND_H
|
||||
|
||||
struct _E_DND_Handler
|
||||
{
|
||||
void *data;
|
||||
void (*func)(void *data, const char *type, void *drop);
|
||||
char *type;
|
||||
int x, y, w, h;
|
||||
};
|
||||
|
||||
EAPI int e_dnd_init(void);
|
||||
EAPI int e_dnd_shutdown(void);
|
||||
|
||||
EAPI void e_drag_start(E_Zone *zone, const char *type, void *data, const char *icon_path, const char *icon);
|
||||
EAPI void e_drag_update(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 void e_dnd_handler_del(E_DND_Handler *handler);
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -36,3 +36,4 @@
|
|||
#include "e_font.h"
|
||||
#include "e_intl.h"
|
||||
#include "e_theme.h"
|
||||
#include "e_dnd.h"
|
||||
|
|
|
@ -271,7 +271,7 @@ main(int argc, char **argv)
|
|||
_e_main_shutdown_push(e_font_shutdown);
|
||||
e_font_apply();
|
||||
e_canvas_recache();
|
||||
|
||||
|
||||
/* setup init status window/screen */
|
||||
if (!e_init_init())
|
||||
{
|
||||
|
@ -326,6 +326,14 @@ main(int argc, char **argv)
|
|||
_e_main_shutdown(-1);
|
||||
}
|
||||
_e_main_shutdown_push(e_module_shutdown);
|
||||
|
||||
/* setup dnd */
|
||||
if (!e_dnd_init())
|
||||
{
|
||||
e_error_message_show(_("Enlightenment cannot set up its dnd system."));
|
||||
_e_main_shutdown(-1);
|
||||
}
|
||||
_e_main_shutdown_push(e_dnd_shutdown);
|
||||
|
||||
if (!nowelcome)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ e_theme_init(void)
|
|||
e_theme_file_set("base/theme/menus", "default.edj");
|
||||
e_theme_file_set("base/theme/error", "default.edj");
|
||||
e_theme_file_set("base/theme/gadman", "default.edj");
|
||||
e_theme_file_set("base/theme/dnd", "default.edj");
|
||||
e_theme_file_set("base/theme/modules", "default.edj");
|
||||
e_theme_file_set("base/theme/modules/pager", "default.edj");
|
||||
e_theme_file_set("base/theme/modules/ibar", "default.edj");
|
||||
|
|
|
@ -291,10 +291,11 @@ _e_zone_free(E_Zone *zone)
|
|||
{
|
||||
Ecore_Event_Handler *h;
|
||||
|
||||
h = l->next;
|
||||
h = l->data;
|
||||
ecore_event_handler_del(h);
|
||||
}
|
||||
evas_list_free(zone->handlers);
|
||||
zone->handlers = NULL;
|
||||
|
||||
con = zone->container;
|
||||
if (zone->name) free(zone->name);
|
||||
|
|
|
@ -62,6 +62,8 @@ 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_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 int _pager_count;
|
||||
|
||||
static E_Config_DD *_conf_edd;
|
||||
|
@ -338,6 +340,9 @@ _pager_face_new(E_Zone *zone)
|
|||
e_table_homogenous_set(o, 1);
|
||||
edje_object_part_swallow(face->pager_object, "items", face->table_object);
|
||||
evas_object_show(o);
|
||||
|
||||
face->dnd_handler = e_dnd_handler_add(face, _pager_dnd_cb, "enlightenment/border",
|
||||
face->fx, face->fy, face->fw, face->fh);
|
||||
|
||||
face->gmc = e_gadman_client_new(zone->container->gadman);
|
||||
_pager_face_zone_set(face, zone);
|
||||
|
@ -549,6 +554,7 @@ _pager_desk_new(Pager_Face *face, E_Desk *desk, int xpos, int ypos)
|
|||
if (pw)
|
||||
pd->wins = evas_list_append(pd->wins, pw);
|
||||
}
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
|
@ -709,10 +715,10 @@ _pager_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change chan
|
|||
|
||||
face = data;
|
||||
e_gadman_client_geometry_get(face->gmc, &x, &y, &w, &h);
|
||||
face->fx = x;
|
||||
face->fy = y;
|
||||
face->fw = w;
|
||||
face->fh = h;
|
||||
face->dnd_handler->x = face->fx = x;
|
||||
face->dnd_handler->y = face->fy = y;
|
||||
face->dnd_handler->w = face->fw = w;
|
||||
face->dnd_handler->h = face->fh = h;
|
||||
switch (change)
|
||||
{
|
||||
case E_GADMAN_CHANGE_MOVE_RESIZE:
|
||||
|
@ -1355,3 +1361,9 @@ _pager_desk_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_C
|
|||
evas_object_resize(o, w, h);
|
||||
evas_object_resize(desk->event_object, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_pager_dnd_cb(void *data, const char *type, void *drop)
|
||||
{
|
||||
printf("We have a drop!\n");
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ struct _Pager_Face
|
|||
Ecore_Event_Handler *ev_handler_zone_desk_count_set;
|
||||
Ecore_Event_Handler *ev_handler_desk_show;
|
||||
Ecore_Event_Handler *ev_handler_container_resize;
|
||||
|
||||
E_DND_Handler *dnd_handler;
|
||||
};
|
||||
|
||||
struct _Pager_Desk
|
||||
|
|
Loading…
Reference in New Issue