SVN revision: 13872
This commit is contained in:
sebastid 2005-03-23 10:53:34 +00:00 committed by sebastid
parent 308789fc4a
commit 90eccc9123
5 changed files with 415 additions and 386 deletions

View File

@ -456,6 +456,9 @@ struct _Ecore_X_Event_Xdnd_Enter
{ {
Ecore_X_Window win, source; Ecore_X_Window win, source;
Ecore_X_Time time; Ecore_X_Time time;
char **types;
int num_types;
}; };
struct _Ecore_X_Event_Xdnd_Position struct _Ecore_X_Event_Xdnd_Position
@ -803,14 +806,17 @@ EAPI int ecore_x_selection_primary_set(Ecore_X_Window w, unsigned c
EAPI int ecore_x_selection_primary_clear(void); EAPI int ecore_x_selection_primary_clear(void);
EAPI int ecore_x_selection_secondary_set(Ecore_X_Window w, unsigned char *data, int size); EAPI int ecore_x_selection_secondary_set(Ecore_X_Window w, unsigned char *data, int size);
EAPI int ecore_x_selection_secondary_clear(void); EAPI int ecore_x_selection_secondary_clear(void);
EAPI int ecore_x_selection_xdnd_set(Ecore_X_Window w, unsigned char *data, int size);
EAPI int ecore_x_selection_xdnd_clear(void);
EAPI int ecore_x_selection_clipboard_set(Ecore_X_Window w, unsigned char *data, int size); EAPI int ecore_x_selection_clipboard_set(Ecore_X_Window w, unsigned char *data, int size);
EAPI int ecore_x_selection_clipboard_clear(void); EAPI int ecore_x_selection_clipboard_clear(void);
EAPI void ecore_x_selection_primary_request(Ecore_X_Window w, char *target); EAPI void ecore_x_selection_primary_request(Ecore_X_Window w, char *target);
EAPI void ecore_x_selection_secondary_request(Ecore_X_Window w, char *target);
EAPI void ecore_x_selection_clipboard_request(Ecore_X_Window w, char *target);
EAPI void ecore_x_selection_primary_request_data_get(void **buf, int *len); EAPI void ecore_x_selection_primary_request_data_get(void **buf, int *len);
EAPI void ecore_x_selection_secondary_request(Ecore_X_Window w, char *target);
EAPI void ecore_x_selection_secondary_request_data_get(void **buf, int *len); EAPI void ecore_x_selection_secondary_request_data_get(void **buf, int *len);
EAPI void ecore_x_selection_xdnd_request(Ecore_X_Window w, char *target);
EAPI void ecore_x_selection_xdnd_request_data_get(void **buf, int *len); EAPI void ecore_x_selection_xdnd_request_data_get(void **buf, int *len);
EAPI void ecore_x_selection_clipboard_request(Ecore_X_Window w, char *target);
EAPI void ecore_x_selection_clipboard_request_data_get(void **buf, int *len); EAPI void ecore_x_selection_clipboard_request_data_get(void **buf, int *len);
EAPI void ecore_x_selection_converter_add(char *target, int (*func)(char *target, void *data, int size, void **data_ret, int *size_ret)); EAPI void ecore_x_selection_converter_add(char *target, int (*func)(char *target, void *data, int size, void **data_ret, int *size_ret));
EAPI void ecore_x_selection_converter_atom_add(Ecore_X_Atom target, int (*func)(char *target, void *data, int size, void **data_ret, int *size_ret)); EAPI void ecore_x_selection_converter_atom_add(Ecore_X_Atom target, int (*func)(char *target, void *data, int size, void **data_ret, int *size_ret));
@ -823,6 +829,7 @@ EAPI int ecore_x_dnd_type_isset(Ecore_X_Window win, const char *typ
EAPI void ecore_x_dnd_type_set(Ecore_X_Window win, const char *type, int on); EAPI void ecore_x_dnd_type_set(Ecore_X_Window win, const char *type, int on);
EAPI int ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size); EAPI int ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size);
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_status(int will_accept, int suppress, Ecore_X_Rectangle rectangle, Ecore_X_Atom action);
EAPI void ecore_x_dnd_send_finished(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_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); EAPI Ecore_X_Window ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h);

View File

@ -6,7 +6,6 @@
#include "Ecore_X.h" #include "Ecore_X.h"
#include "Ecore_X_Atoms.h" #include "Ecore_X_Atoms.h"
static Ecore_X_Selection_Data _xdnd_selection;
static Ecore_X_DND_Protocol *_xdnd = NULL; static Ecore_X_DND_Protocol *_xdnd = NULL;
static int _ecore_x_dnd_init_count = 0; static int _ecore_x_dnd_init_count = 0;
@ -163,29 +162,14 @@ _ecore_x_dnd_protocol_get(void)
int int
ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size) ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size)
{ {
unsigned char *buf;
unsigned char *atoms;
int num;
if (!ecore_x_dnd_version_get(source)) if (!ecore_x_dnd_version_get(source))
return 0; return 0;
/* Take ownership of XdndSelection */ /* Take ownership of XdndSelection */
XSetSelectionOwner(_ecore_x_disp, ECORE_X_ATOM_SELECTION_XDND, source, if (!ecore_x_selection_xdnd_set(source, data, size))
_ecore_x_event_last_time);
if (XGetSelectionOwner(_ecore_x_disp, ECORE_X_ATOM_SELECTION_XDND) != source)
return 0; return 0;
/* Initialize Selection Data Struct */
_xdnd_selection.win = source;
_xdnd_selection.selection = ECORE_X_ATOM_SELECTION_XDND;
_xdnd_selection.length = size;
_xdnd_selection.time = _ecore_x_event_last_time;
buf = malloc(size);
memcpy(buf, data, size);
_xdnd_selection.data = buf;
_xdnd->source = source; _xdnd->source = source;
_xdnd->state = ECORE_X_DND_DRAGGING; _xdnd->state = ECORE_X_DND_DRAGGING;
_xdnd->time = _ecore_x_event_last_time; _xdnd->time = _ecore_x_event_last_time;
@ -193,11 +177,6 @@ ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size)
/* Default Accepted Action: ask */ /* Default Accepted Action: ask */
_xdnd->action = ECORE_X_ATOM_XDND_ACTION_ASK; _xdnd->action = ECORE_X_ATOM_XDND_ACTION_ASK;
_xdnd->accepted_action = None; _xdnd->accepted_action = None;
ecore_x_window_prop_property_get(source, ECORE_X_ATOM_XDND_TYPE_LIST,
XA_ATOM, 32, &atoms, &num);
_xdnd->num_types = num;
_xdnd->types = (Ecore_X_Atom *)atoms;
return 1; return 1;
} }
@ -253,6 +232,27 @@ ecore_x_dnd_send_status(int will_accept, int suppress, Ecore_X_Rectangle rectang
XSendEvent(_ecore_x_disp, _xdnd->source, False, 0, &xev); XSendEvent(_ecore_x_disp, _xdnd->source, False, 0, &xev);
} }
void
ecore_x_dnd_send_finished(void)
{
XEvent xev;
xev.xany.type = ClientMessage;
xev.xany.display = _ecore_x_disp;
xev.xclient.window = _xdnd->source;
xev.xclient.message_type = ECORE_X_ATOM_XDND_FINISHED;
xev.xclient.format = 32;
xev.xclient.data.l[0] = _xdnd->dest;
memset(xev.xclient.data.l + 1, 0, sizeof(long) * 3);
if (_xdnd->will_accept)
{
xev.xclient.data.l[1] |= 0x1UL;
xev.xclient.data.l[2] = _xdnd->accepted_action;
}
XSendEvent(_ecore_x_disp, _xdnd->source, False, 0, &xev);
}
void void
_ecore_x_dnd_drag(int x, int y) _ecore_x_dnd_drag(int x, int y)
{ {
@ -286,20 +286,27 @@ _ecore_x_dnd_drag(int x, int y)
ecore_x_dnd_version_get(win)); ecore_x_dnd_version_get(win));
if (win != _xdnd->dest) if (win != _xdnd->dest)
{ {
int i; int i, num;
unsigned char *data;
Ecore_X_Atom *types;
ecore_x_window_prop_property_get(_xdnd->source, ECORE_X_ATOM_XDND_TYPE_LIST,
XA_ATOM, 32, &data, &num);
types = (Ecore_X_Atom *)data;
/* Entered new window, send XdndEnter */ /* Entered new window, send XdndEnter */
xev.xclient.window = win; xev.xclient.window = win;
xev.xclient.message_type = ECORE_X_ATOM_XDND_ENTER; xev.xclient.message_type = ECORE_X_ATOM_XDND_ENTER;
xev.xclient.data.l[0] = _xdnd->source; xev.xclient.data.l[0] = _xdnd->source;
if(_xdnd->num_types > 3) if (num > 3)
xev.xclient.data.l[1] |= 0x1UL; xev.xclient.data.l[1] |= 0x1UL;
else else
xev.xclient.data.l[1] &= 0xfffffffeUL; xev.xclient.data.l[1] &= 0xfffffffeUL;
xev.xclient.data.l[1] |= ((unsigned long) _xdnd->version) << 24; xev.xclient.data.l[1] |= ((unsigned long) _xdnd->version) << 24;
for (i = 0; i < MIN(_xdnd->num_types, 3); ++i) for (i = 0; i < MIN(num, 3); ++i)
xev.xclient.data.l[i + 2] = _xdnd->types[i]; xev.xclient.data.l[i + 2] = types[i];
XFree(data);
XSendEvent(_ecore_x_disp, win, False, 0, &xev); XSendEvent(_ecore_x_disp, win, False, 0, &xev);
_xdnd->await_status = 0; _xdnd->await_status = 0;
} }
@ -349,27 +356,3 @@ _ecore_x_dnd_drag(int x, int y)
_xdnd->dest = win; _xdnd->dest = win;
} }
#if 0 /* Unused? */
void
_ecore_x_dnd_send_finished(void)
{
XEvent xev;
xev.xany.type = ClientMessage;
xev.xany.display = _ecore_x_disp;
xev.xclient.window = _xdnd->source;
xev.xclient.message_type = ECORE_X_ATOM_XDND_FINISHED;
xev.xclient.format = 32;
xev.xclient.data.l[0] = _xdnd->dest;
memset(xev.xclient.data.l + 1, 0, sizeof(long) * 3);
XSendEvent(_ecore_x_disp, _xdnd->source, False, 0, &xev);
}
int
_ecore_x_dnd_own_selection(void)
{
return (!XSetSelectionOwner(_ecore_x_disp, ECORE_X_ATOM_SELECTION_XDND,
_xdnd->source, CurrentTime));
}
#endif

View File

@ -1,7 +1,6 @@
/* /*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/ */
#include "ecore_private.h" #include "ecore_private.h"
#include "Ecore.h" #include "Ecore.h"
#include "ecore_x_private.h" #include "ecore_x_private.h"
@ -146,6 +145,19 @@ _ecore_x_event_free_selection_notify(void *data __UNUSED__, void *ev)
free(e); free(e);
} }
static void
_ecore_x_event_free_xdnd_enter(void *data __UNUSED__, void *ev)
{
Ecore_X_Event_Xdnd_Enter *e;
int i;
e = ev;
for (i = 0; i < e->num_types; i++)
XFree(e->types[i]);
free(e->types);
free(e);
}
void void
_ecore_x_event_handle_key_press(XEvent *xevent) _ecore_x_event_handle_key_press(XEvent *xevent)
{ {
@ -498,8 +510,8 @@ _ecore_x_event_handle_motion_notify(XEvent *xevent)
x2 = _xdnd->rectangle.x + _xdnd->rectangle.width; x2 = _xdnd->rectangle.x + _xdnd->rectangle.width;
y1 = _xdnd->rectangle.y; y1 = _xdnd->rectangle.y;
y2 = _xdnd->rectangle.y + _xdnd->rectangle.height; y2 = _xdnd->rectangle.y + _xdnd->rectangle.height;
if (e->win != _xdnd->dest || e->root.x < x1 || e->root.x > x2 if ((e->win != _xdnd->dest) || (e->root.x < x1) || (e->root.x > x2)
|| e->root.y < y1 || e->root.y > y2) || (e->root.y < y1) || (e->root.y > y2))
{ {
_ecore_x_dnd_drag(e->root.x, e->root.y); _ecore_x_dnd_drag(e->root.x, e->root.y);
} }
@ -1143,6 +1155,9 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
Ecore_X_DND_Protocol *_xdnd; Ecore_X_DND_Protocol *_xdnd;
unsigned long three; unsigned long three;
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter));
if (!e) return;
_xdnd = _ecore_x_dnd_protocol_get(); _xdnd = _ecore_x_dnd_protocol_get();
_xdnd->source = xevent->xclient.data.l[0]; _xdnd->source = xevent->xclient.data.l[0];
_xdnd->dest = xevent->xclient.window; _xdnd->dest = xevent->xclient.window;
@ -1158,7 +1173,7 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
{ {
/* source supports more than 3 types, fetch property */ /* source supports more than 3 types, fetch property */
unsigned char *data; unsigned char *data;
Atom *types; Ecore_X_Atom *types;
int i, num_ret; int i, num_ret;
if (!(ecore_x_window_prop_property_get(_xdnd->source, if (!(ecore_x_window_prop_property_get(_xdnd->source,
ECORE_X_ATOM_XDND_TYPE_LIST, ECORE_X_ATOM_XDND_TYPE_LIST,
@ -1170,31 +1185,28 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
printf("DND: Could not fetch data type list from source window, aborting.\n"); printf("DND: Could not fetch data type list from source window, aborting.\n");
return; return;
} }
types = (Atom *) data; types = (Ecore_X_Atom *)data;
_xdnd->types = calloc(num_ret + 1, sizeof(Atom)); e->types = calloc(num_ret, sizeof(char *));
for (i = 0; i < num_ret; i++) for (i = 0; i < num_ret; i++)
_xdnd->types[i] = types[i]; e->types[i] = XGetAtomName(_ecore_x_disp, types[i]);
_xdnd->num_types = num_ret; e->num_types = num_ret;
free(types);
} }
else else
{ {
_xdnd->types = calloc(4, sizeof(Atom)); e->types = calloc(3, sizeof(char *));
_xdnd->types[0] = xevent->xclient.data.l[2]; e->types[0] = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[2]);
_xdnd->types[1] = xevent->xclient.data.l[3]; e->types[1] = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[3]);
_xdnd->types[2] = xevent->xclient.data.l[4]; e->types[2] = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[4]);
_xdnd->num_types = 3; e->num_types = 3;
} }
_xdnd->state = ECORE_X_DND_TARGET_ENTERED; _xdnd->state = ECORE_X_DND_TARGET_ENTERED;
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter));
if (!e) return;
e->win = _xdnd->dest; e->win = _xdnd->dest;
e->source = _xdnd->source; e->source = _xdnd->source;
e->time = CurrentTime; e->time = CurrentTime;
_ecore_x_event_last_time = e->time; _ecore_x_event_last_time = e->time;
ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e, NULL, NULL); ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e, _ecore_x_event_free_xdnd_enter, NULL);
} }
/* Message Type: XdndPosition */ /* Message Type: XdndPosition */
@ -1214,6 +1226,9 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
/* Would it be feasible to handle the processing of this message /* Would it be feasible to handle the processing of this message
* within ecore? I think not, but someone might have an idea here. */ * within ecore? I think not, but someone might have an idea here. */
_ecore_x_event_last_time = (_xdnd->version >= 1) ?
(Time)xevent->xclient.data.l[3] : CurrentTime;
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position)); e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position));
if (!e) return; if (!e) return;
e->win = _xdnd->dest; e->win = _xdnd->dest;
@ -1233,8 +1248,8 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
_xdnd = _ecore_x_dnd_protocol_get(); _xdnd = _ecore_x_dnd_protocol_get();
/* Make sure source/target match */ /* Make sure source/target match */
if (_xdnd->source != xevent->xclient.window if ((_xdnd->source != xevent->xclient.window )
|| _xdnd->dest != (Window)xevent->xclient.data.l[0]) || (_xdnd->dest != (Window)xevent->xclient.data.l[0]))
return; return;
_xdnd->will_accept = xevent->xclient.data.l[1] & 0x1UL; _xdnd->will_accept = xevent->xclient.data.l[1] & 0x1UL;
_xdnd->suppress = (xevent->xclient.data.l[1] & 0x2UL) ? 0 : 1; _xdnd->suppress = (xevent->xclient.data.l[1] & 0x2UL) ? 0 : 1;
@ -1269,12 +1284,9 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
_xdnd = _ecore_x_dnd_protocol_get(); _xdnd = _ecore_x_dnd_protocol_get();
/* Match source/target */ /* Match source/target */
if (_xdnd->source != (Window)xevent->xclient.data.l[0] if ((_xdnd->source != (Window)xevent->xclient.data.l[0])
|| _xdnd->dest != xevent->xclient.window) || (_xdnd->dest != xevent->xclient.window))
return; return;
if (_xdnd->types)
free(_xdnd->types);
_xdnd->num_types = 0;
/* XXX: May need to reset event handler callbacks as well */ /* XXX: May need to reset event handler callbacks as well */
_xdnd->state = ECORE_X_DND_IDLE; _xdnd->state = ECORE_X_DND_IDLE;
@ -1292,20 +1304,13 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
_xdnd = _ecore_x_dnd_protocol_get(); _xdnd = _ecore_x_dnd_protocol_get();
/* Match source/target */ /* Match source/target */
if (_xdnd->source != (Window)xevent->xclient.data.l[0] if ((_xdnd->source != (Window)xevent->xclient.data.l[0])
|| _xdnd->dest != xevent->xclient.window) || (_xdnd->dest != xevent->xclient.window))
return; return;
timestamp = (_xdnd->version >= (int)1) ? timestamp = (_xdnd->version >= 1) ?
(Time)xevent->xclient.data.l[2] : _ecore_x_event_last_time; (Time)xevent->xclient.data.l[2] : _ecore_x_event_last_time;
XConvertSelection(_ecore_x_disp, ECORE_X_ATOM_SELECTION_XDND,
_xdnd->dest, ECORE_X_ATOM_SELECTION_PROP_XDND, _xdnd->dest,
timestamp);
/* FIXME: Have to wait for SelectionNotify before we can send
* XdndFinished. Stupid, retarded protocols, gah! */
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop)); e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop));
if (!e) return; if (!e) return;
e->win = _xdnd->dest; e->win = _xdnd->dest;
@ -1326,11 +1331,11 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
_xdnd = _ecore_x_dnd_protocol_get(); _xdnd = _ecore_x_dnd_protocol_get();
/* Match source/target */ /* Match source/target */
if (_xdnd->source != xevent->xclient.window if ((_xdnd->source != xevent->xclient.window)
|| _xdnd->dest != (Window)xevent->xclient.data.l[0]) || (_xdnd->dest != (Window)xevent->xclient.data.l[0]))
return; return;
if (_xdnd->version >= 5 && (xevent->xclient.data.l[1] & 0x1UL)) if ((_xdnd->version >= 5) && (xevent->xclient.data.l[1] & 0x1UL))
{ {
/* Target successfully performed drop action */ /* Target successfully performed drop action */
_xdnd->state = ECORE_X_DND_IDLE; _xdnd->state = ECORE_X_DND_IDLE;
@ -1359,7 +1364,6 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
} }
ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL); ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL);
} }
else else
{ {

View File

@ -91,9 +91,7 @@ typedef struct _Ecore_X_DND_Protocol
Time time; Time time;
Ecore_X_Atom *types;
Ecore_X_Atom action, accepted_action; Ecore_X_Atom action, accepted_action;
int num_types;
int will_accept; int will_accept;
int suppress; int suppress;

View File

@ -6,7 +6,7 @@
#include "Ecore_X.h" #include "Ecore_X.h"
#include "Ecore_X_Atoms.h" #include "Ecore_X_Atoms.h"
static Ecore_X_Selection_Data selections[3]; static Ecore_X_Selection_Data selections[4];
static Ecore_X_Selection_Data request_data[4]; static Ecore_X_Selection_Data request_data[4];
static Ecore_X_Selection_Converter *converters = NULL; static Ecore_X_Selection_Converter *converters = NULL;
@ -41,7 +41,8 @@ _ecore_x_selection_shutdown(void)
return; return;
/* free the selection converters */ /* free the selection converters */
while (cnv) { while (cnv)
{
tmp = cnv->next; tmp = cnv->next;
free(cnv); free(cnv);
cnv = tmp; cnv = tmp;
@ -165,8 +166,10 @@ _ecore_x_selection_get(Atom selection)
return &selections[0]; return &selections[0];
else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY) else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
return &selections[1]; return &selections[1];
else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD) else if (selection == ECORE_X_ATOM_SELECTION_XDND)
return &selections[2]; return &selections[2];
else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
return &selections[3];
else else
return NULL; return NULL;
} }
@ -185,8 +188,10 @@ _ecore_x_selection_set(Window w, unsigned char *data, int size, Atom selection)
in = 0; in = 0;
else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY) else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
in = 1; in = 1;
else else if (selection == ECORE_X_ATOM_SELECTION_XDND)
in = 2; in = 2;
else
in = 3;
if (data) if (data)
{ {
@ -218,9 +223,6 @@ _ecore_x_selection_set(Window w, unsigned char *data, int size, Atom selection)
* @param size The size of the data buffer in bytes * @param size The size of the data buffer in bytes
* @return Returns 1 if the ownership of the selection was successfully * @return Returns 1 if the ownership of the selection was successfully
* claimed, or 0 if unsuccessful. * claimed, or 0 if unsuccessful.
*
* Get the converted data from a previous PRIMARY selection
* request. The buffer must be freed when done with.
*/ */
int int
ecore_x_selection_primary_set(Ecore_X_Window w, unsigned char *data, int size) ecore_x_selection_primary_set(Ecore_X_Window w, unsigned char *data, int size)
@ -247,9 +249,6 @@ ecore_x_selection_primary_clear(void)
* @param size The size of the data buffer in bytes * @param size The size of the data buffer in bytes
* @return Returns 1 if the ownership of the selection was successfully * @return Returns 1 if the ownership of the selection was successfully
* claimed, or 0 if unsuccessful. * claimed, or 0 if unsuccessful.
*
* Get the converted data from a previous SECONDARY selection
* request. The buffer must be freed when done with.
*/ */
int int
ecore_x_selection_secondary_set(Ecore_X_Window w, unsigned char *data, int size) ecore_x_selection_secondary_set(Ecore_X_Window w, unsigned char *data, int size)
@ -269,6 +268,32 @@ ecore_x_selection_secondary_clear(void)
return _ecore_x_selection_set(None, NULL, 0, ECORE_X_ATOM_SELECTION_SECONDARY); return _ecore_x_selection_set(None, NULL, 0, ECORE_X_ATOM_SELECTION_SECONDARY);
} }
/**
* Claim ownership of the XDND selection and set its data.
* @param w The window to which this selection belongs
* @param data The data associated with the selection
* @param size The size of the data buffer in bytes
* @return Returns 1 if the ownership of the selection was successfully
* claimed, or 0 if unsuccessful.
*/
int
ecore_x_selection_xdnd_set(Ecore_X_Window w, unsigned char *data, int size)
{
return _ecore_x_selection_set(w, data, size, ECORE_X_ATOM_SELECTION_XDND);
}
/**
* Release ownership of the XDND selection
* @return Returns 1 if the selection was successfully cleared,
* or 0 if unsuccessful.
*
*/
int
ecore_x_selection_xdnd_clear(void)
{
return _ecore_x_selection_set(None, NULL, 0, ECORE_X_ATOM_SELECTION_XDND);
}
/** /**
* Claim ownership of the CLIPBOARD selection and set its data. * Claim ownership of the CLIPBOARD selection and set its data.
* @param w The window to which this selection belongs * @param w The window to which this selection belongs
@ -351,8 +376,6 @@ _ecore_x_selection_request(Ecore_X_Window w, Ecore_X_Atom selection, char *targe
prop = ECORE_X_ATOM_SELECTION_PROP_PRIMARY; prop = ECORE_X_ATOM_SELECTION_PROP_PRIMARY;
else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY) else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
prop = ECORE_X_ATOM_SELECTION_PROP_SECONDARY; prop = ECORE_X_ATOM_SELECTION_PROP_SECONDARY;
else if (selection == ECORE_X_ATOM_SELECTION_XDND)
prop = ECORE_X_ATOM_SELECTION_PROP_XDND;
else else
prop = ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD; prop = ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD;
@ -372,6 +395,17 @@ ecore_x_selection_secondary_request(Ecore_X_Window w, char *target)
_ecore_x_selection_request(w, ECORE_X_ATOM_SELECTION_SECONDARY, target); _ecore_x_selection_request(w, ECORE_X_ATOM_SELECTION_SECONDARY, target);
} }
void
ecore_x_selection_xdnd_request(Ecore_X_Window w, char *target)
{
Ecore_X_Atom atom;
atom = ecore_x_atom_get(target);
XConvertSelection(_ecore_x_disp, ECORE_X_ATOM_SELECTION_XDND, atom,
ECORE_X_ATOM_SELECTION_PROP_XDND, w,
_ecore_x_event_last_time);
}
void void
ecore_x_selection_clipboard_request(Ecore_X_Window w, char *target) ecore_x_selection_clipboard_request(Ecore_X_Window w, char *target)
{ {
@ -402,7 +436,9 @@ ecore_x_selection_converter_atom_add(Ecore_X_Atom target,
cnv->next = calloc(1, sizeof(Ecore_X_Selection_Converter)); cnv->next = calloc(1, sizeof(Ecore_X_Selection_Converter));
cnv = cnv->next; cnv = cnv->next;
} else { }
else
{
converters = calloc(1, sizeof(Ecore_X_Selection_Converter)); converters = calloc(1, sizeof(Ecore_X_Selection_Converter));
cnv = converters; cnv = converters;
} }
@ -437,9 +473,9 @@ ecore_x_selection_converter_atom_del(Ecore_X_Atom target)
{ {
if (cnv->target == target) if (cnv->target == target)
{ {
if (target == ECORE_X_ATOM_TEXT || if ((target == ECORE_X_ATOM_TEXT) ||
target == ECORE_X_ATOM_COMPOUND_TEXT || (target == ECORE_X_ATOM_COMPOUND_TEXT) ||
target == ECORE_X_ATOM_STRING) (target == ECORE_X_ATOM_STRING))
{ {
cnv->convert = _ecore_x_selection_converter_text; cnv->convert = _ecore_x_selection_converter_text;
} }
@ -509,7 +545,8 @@ _ecore_x_selection_convert(Atom selection, Atom target, void **data_ret)
/* TODO: We need to work out a mechanism for automatic conversion to any requested /* TODO: We need to work out a mechanism for automatic conversion to any requested
* locale using Ecore_Txt functions */ * locale using Ecore_Txt functions */
/* Converter for standard non-utf8 text targets */ /* Converter for standard non-utf8 text targets */
static int _ecore_x_selection_converter_text(char *target, void *data, int size, void **data_ret, int *size_ret) static int
_ecore_x_selection_converter_text(char *target, void *data, int size, void **data_ret, int *size_ret)
{ {
XTextProperty text_prop; XTextProperty text_prop;
char *mystr; char *mystr;