From 145e0ce3537af8e582dfa2bbb8528289ca03c2fe Mon Sep 17 00:00:00 2001 From: englebass Date: Sun, 17 Aug 2008 18:12:23 +0000 Subject: [PATCH] source action patches from Fedor Gusev git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@35519 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_x/Ecore_X.h | 2 ++ src/lib/ecore_x/xcb/ecore_xcb_dnd.c | 20 ++++++++++++++++++++ src/lib/ecore_x/xcb/ecore_xcb_private.h | 5 +++++ src/lib/ecore_x/xlib/ecore_x_dnd.c | 23 ++++++++++++++++++++++- src/lib/ecore_x/xlib/ecore_x_private.h | 5 +++++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h index 050e9bc..1a37ec0 100644 --- a/src/lib/ecore_x/Ecore_X.h +++ b/src/lib/ecore_x/Ecore_X.h @@ -1078,6 +1078,8 @@ EAPI int ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *da EAPI int ecore_x_dnd_drop(void); EAPI void ecore_x_dnd_send_status(int will_accept, int suppress, Ecore_X_Rectangle rectangle, Ecore_X_Atom action); EAPI void ecore_x_dnd_send_finished(void); +EAPI void ecore_x_dnd_source_action_set(Ecore_X_Atom action); +EAPI Ecore_X_Atom ecore_x_dnd_source_action_get(void); EAPI Ecore_X_Window ecore_x_window_new(Ecore_X_Window parent, int x, int y, int w, int h); EAPI Ecore_X_Window ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h); diff --git a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c b/src/lib/ecore_x/xcb/ecore_xcb_dnd.c index b270d3d..6419e46 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_dnd.c @@ -30,6 +30,7 @@ _ecore_x_dnd_init(void) _source->win = XCB_NONE; _source->dest = XCB_NONE; _source->state = ECORE_X_DND_SOURCE_IDLE; + _source->prev.window = 0; _target = calloc(1, sizeof(Ecore_X_DND_Target)); _target->win = XCB_NONE; @@ -485,6 +486,7 @@ ecore_x_dnd_begin(Ecore_X_Window source, ecore_x_window_ignore_set(_source->win, 1); _source->state = ECORE_X_DND_SOURCE_DRAGGING; _source->time = _ecore_xcb_event_last_time; + _source->prev.window = 0; /* Default Accepted Action: ask */ _source->action = ECORE_X_ATOM_XDND_ACTION_COPY; @@ -532,6 +534,7 @@ ecore_x_dnd_drop(void) } ecore_x_window_ignore_set(_source->win, 0); + _source->prev.window = 0; _source->dest = XCB_NONE; return status; @@ -611,6 +614,20 @@ ecore_x_dnd_send_finished(void) } void +ecore_x_dnd_source_action_set(Ecore_X_Atom action) +{ + _source->action = action; + if (_source->prev.window) + _ecore_x_dnd_drag(_source->prev.window, _source->prev.x, _source->prev.y); +} + +Ecore_X_Atom +ecore_x_dnd_source_action_get(void) +{ + return _source->action; +} + +void _ecore_x_dnd_drag(Ecore_X_Window root, int x, int y) @@ -747,5 +764,8 @@ _ecore_x_dnd_drag(Ecore_X_Window root, } } + _source->prev.x = x; + _source->prev.y = y; + _source->prev.window = root; _source->dest = win; } diff --git a/src/lib/ecore_x/xcb/ecore_xcb_private.h b/src/lib/ecore_x/xcb/ecore_xcb_private.h index 180010c..ef8dc2c 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_private.h +++ b/src/lib/ecore_x/xcb/ecore_xcb_private.h @@ -107,6 +107,11 @@ typedef struct _Ecore_X_DND_Source unsigned short width, height; } rectangle; + struct { + Ecore_X_Window window; + int x, y; + } prev; + Ecore_X_Time time; Ecore_X_Atom action, accepted_action; diff --git a/src/lib/ecore_x/xlib/ecore_x_dnd.c b/src/lib/ecore_x/xlib/ecore_x_dnd.c index 61a64df..b84a443 100644 --- a/src/lib/ecore_x/xlib/ecore_x_dnd.c +++ b/src/lib/ecore_x/xlib/ecore_x_dnd.c @@ -35,6 +35,7 @@ _ecore_x_dnd_init(void) _source->win = None; _source->dest = None; _source->state = ECORE_X_DND_SOURCE_IDLE; + _source->prev.window = 0; _target = calloc(1, sizeof(Ecore_X_DND_Target)); _target->win = None; @@ -335,6 +336,7 @@ ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size) ecore_x_window_ignore_set(_source->win, 1); _source->state = ECORE_X_DND_SOURCE_DRAGGING; _source->time = _ecore_x_event_last_time; + _source->prev.window = 0; /* Default Accepted Action: move */ _source->action = ECORE_X_ATOM_XDND_ACTION_MOVE; @@ -384,6 +386,8 @@ ecore_x_dnd_drop(void) } ecore_x_window_ignore_set(_source->win, 0); + _source->prev.window = 0; + return status; } @@ -462,6 +466,20 @@ ecore_x_dnd_send_finished(void) } void +ecore_x_dnd_source_action_set(Ecore_X_Atom action) +{ + _source->action = action; + if (_source->prev.window) + _ecore_x_dnd_drag(_source->prev.window, _source->prev.x, _source->prev.y); +} + +Ecore_X_Atom +ecore_x_dnd_source_action_get(void) +{ + return _source->action; +} + +void _ecore_x_dnd_drag(Ecore_X_Window root, int x, int y) { XEvent xev; @@ -560,9 +578,12 @@ _ecore_x_dnd_drag(Ecore_X_Window root, int x, int y) xev.xclient.data.l[4] = _source->action; /* Version 2, Needs to be pre-set */ XSendEvent(_ecore_x_disp, win, False, 0, &xev); - _source->await_status = 1; + _source->await_status = 1; } } + _source->prev.x = x; + _source->prev.y = y; + _source->prev.window = root; _source->dest = win; } diff --git a/src/lib/ecore_x/xlib/ecore_x_private.h b/src/lib/ecore_x/xlib/ecore_x_private.h index 9fcb649..4baefa5 100644 --- a/src/lib/ecore_x/xlib/ecore_x_private.h +++ b/src/lib/ecore_x/xlib/ecore_x_private.h @@ -103,6 +103,11 @@ typedef struct _Ecore_X_DND_Source unsigned short width, height; } rectangle; + struct { + Ecore_X_Window window; + int x, y; + } prev; + Time time; Ecore_X_Atom action, accepted_action; -- 2.7.4