forked from enlightenment/efl
parent
308789fc4a
commit
90eccc9123
|
@ -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);
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -492,18 +504,18 @@ _ecore_x_event_handle_motion_notify(XEvent *xevent)
|
||||||
/* Xdnd handling */
|
/* Xdnd handling */
|
||||||
_xdnd = _ecore_x_dnd_protocol_get();
|
_xdnd = _ecore_x_dnd_protocol_get();
|
||||||
if (_xdnd->state == ECORE_X_DND_DRAGGING)
|
if (_xdnd->state == ECORE_X_DND_DRAGGING)
|
||||||
{
|
{
|
||||||
/* Determine if we're still in the rectangle from the last status */
|
/* Determine if we're still in the rectangle from the last status */
|
||||||
x1 = _xdnd->rectangle.x;
|
x1 = _xdnd->rectangle.x;
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ecore_event_add(ECORE_X_EVENT_MOUSE_MOVE, e, NULL, NULL);
|
ecore_event_add(ECORE_X_EVENT_MOUSE_MOVE, e, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1123,258 +1135,250 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
|
||||||
/* otherwise generate generic client message event. this would handle*/
|
/* otherwise generate generic client message event. this would handle*/
|
||||||
/* netwm, ICCCM, gnomewm, old kde and mwm hint client message protocols */
|
/* netwm, ICCCM, gnomewm, old kde and mwm hint client message protocols */
|
||||||
if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS) &&
|
if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS) &&
|
||||||
(xevent->xclient.format == 32) &&
|
(xevent->xclient.format == 32) &&
|
||||||
(xevent->xclient.data.l[0] == (long)ECORE_X_ATOM_WM_DELETE_WINDOW))
|
(xevent->xclient.data.l[0] == (long)ECORE_X_ATOM_WM_DELETE_WINDOW))
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Window_Delete_Request *e;
|
Ecore_X_Event_Window_Delete_Request *e;
|
||||||
|
|
||||||
e = calloc(1, sizeof(Ecore_X_Event_Window_Delete_Request));
|
e = calloc(1, sizeof(Ecore_X_Event_Window_Delete_Request));
|
||||||
if (!e) return;
|
if (!e) return;
|
||||||
e->win = xevent->xclient.window;
|
e->win = xevent->xclient.window;
|
||||||
e->time = _ecore_x_event_last_time;
|
e->time = _ecore_x_event_last_time;
|
||||||
ecore_event_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
|
ecore_event_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Xdnd Client Message Handling Begin */
|
/* Xdnd Client Message Handling Begin */
|
||||||
/* Message Type: XdndEnter */
|
/* Message Type: XdndEnter */
|
||||||
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_ENTER)
|
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_ENTER)
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Xdnd_Enter *e;
|
Ecore_X_Event_Xdnd_Enter *e;
|
||||||
Ecore_X_DND_Protocol *_xdnd;
|
Ecore_X_DND_Protocol *_xdnd;
|
||||||
unsigned long three;
|
unsigned long three;
|
||||||
|
|
||||||
_xdnd = _ecore_x_dnd_protocol_get();
|
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter));
|
||||||
_xdnd->source = xevent->xclient.data.l[0];
|
if (!e) return;
|
||||||
_xdnd->dest = xevent->xclient.window;
|
|
||||||
_xdnd->version = (int) (xevent->xclient.data.l[1] >> 24);
|
|
||||||
if (_xdnd->version > ECORE_X_DND_VERSION)
|
|
||||||
{
|
|
||||||
printf("DND: Requested version %d, we only support up to %d\n", _xdnd->version,
|
|
||||||
ECORE_X_DND_VERSION);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((three = xevent->xclient.data.l[1] & 0x1UL))
|
_xdnd = _ecore_x_dnd_protocol_get();
|
||||||
{
|
_xdnd->source = xevent->xclient.data.l[0];
|
||||||
/* source supports more than 3 types, fetch property */
|
_xdnd->dest = xevent->xclient.window;
|
||||||
unsigned char *data;
|
_xdnd->version = (int) (xevent->xclient.data.l[1] >> 24);
|
||||||
Atom *types;
|
if (_xdnd->version > ECORE_X_DND_VERSION)
|
||||||
int i, num_ret;
|
{
|
||||||
if (!(ecore_x_window_prop_property_get(_xdnd->source,
|
printf("DND: Requested version %d, we only support up to %d\n", _xdnd->version,
|
||||||
ECORE_X_ATOM_XDND_TYPE_LIST,
|
ECORE_X_DND_VERSION);
|
||||||
XA_ATOM,
|
return;
|
||||||
32,
|
}
|
||||||
&data,
|
|
||||||
&num_ret)))
|
|
||||||
{
|
|
||||||
printf("DND: Could not fetch data type list from source window, aborting.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
types = (Atom *) data;
|
|
||||||
_xdnd->types = calloc(num_ret + 1, sizeof(Atom));
|
|
||||||
for (i = 0; i < num_ret; i++)
|
|
||||||
_xdnd->types[i] = types[i];
|
|
||||||
_xdnd->num_types = num_ret;
|
|
||||||
free(types);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_xdnd->types = calloc(4, sizeof(Atom));
|
|
||||||
_xdnd->types[0] = xevent->xclient.data.l[2];
|
|
||||||
_xdnd->types[1] = xevent->xclient.data.l[3];
|
|
||||||
_xdnd->types[2] = xevent->xclient.data.l[4];
|
|
||||||
_xdnd->num_types = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
_xdnd->state = ECORE_X_DND_TARGET_ENTERED;
|
if ((three = xevent->xclient.data.l[1] & 0x1UL))
|
||||||
|
{
|
||||||
|
/* source supports more than 3 types, fetch property */
|
||||||
|
unsigned char *data;
|
||||||
|
Ecore_X_Atom *types;
|
||||||
|
int i, num_ret;
|
||||||
|
if (!(ecore_x_window_prop_property_get(_xdnd->source,
|
||||||
|
ECORE_X_ATOM_XDND_TYPE_LIST,
|
||||||
|
XA_ATOM,
|
||||||
|
32,
|
||||||
|
&data,
|
||||||
|
&num_ret)))
|
||||||
|
{
|
||||||
|
printf("DND: Could not fetch data type list from source window, aborting.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
types = (Ecore_X_Atom *)data;
|
||||||
|
e->types = calloc(num_ret, sizeof(char *));
|
||||||
|
for (i = 0; i < num_ret; i++)
|
||||||
|
e->types[i] = XGetAtomName(_ecore_x_disp, types[i]);
|
||||||
|
e->num_types = num_ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e->types = calloc(3, sizeof(char *));
|
||||||
|
e->types[0] = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[2]);
|
||||||
|
e->types[1] = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[3]);
|
||||||
|
e->types[2] = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[4]);
|
||||||
|
e->num_types = 3;
|
||||||
|
}
|
||||||
|
|
||||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter));
|
_xdnd->state = ECORE_X_DND_TARGET_ENTERED;
|
||||||
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 */
|
||||||
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_POSITION)
|
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_POSITION)
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Xdnd_Position *e;
|
Ecore_X_Event_Xdnd_Position *e;
|
||||||
Ecore_X_DND_Protocol *_xdnd;
|
Ecore_X_DND_Protocol *_xdnd;
|
||||||
|
|
||||||
_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;
|
||||||
_xdnd->pos.x = xevent->xclient.data.l[2] >> 16;
|
_xdnd->pos.x = xevent->xclient.data.l[2] >> 16;
|
||||||
_xdnd->pos.y = xevent->xclient.data.l[2] & 0xFFFFUL;
|
_xdnd->pos.y = xevent->xclient.data.l[2] & 0xFFFFUL;
|
||||||
_xdnd->action = xevent->xclient.data.l[4]; /* Version 2 */
|
_xdnd->action = xevent->xclient.data.l[4]; /* Version 2 */
|
||||||
/* TODO: Resolve a suitable method for enumerating Xdnd actions */
|
/* TODO: Resolve a suitable method for enumerating Xdnd actions */
|
||||||
|
|
||||||
/* 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. */
|
||||||
|
|
||||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position));
|
_ecore_x_event_last_time = (_xdnd->version >= 1) ?
|
||||||
if (!e) return;
|
(Time)xevent->xclient.data.l[3] : CurrentTime;
|
||||||
e->win = _xdnd->dest;
|
|
||||||
e->source = _xdnd->source;
|
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position));
|
||||||
e->position.x = _xdnd->pos.x;
|
if (!e) return;
|
||||||
e->position.y = _xdnd->pos.y;
|
e->win = _xdnd->dest;
|
||||||
e->time = xevent->xclient.data.l[3]; /* Version 1 */
|
e->source = _xdnd->source;
|
||||||
e->action = _xdnd->action;
|
e->position.x = _xdnd->pos.x;
|
||||||
ecore_event_add(ECORE_X_EVENT_XDND_POSITION, e, NULL, NULL);
|
e->position.y = _xdnd->pos.y;
|
||||||
}
|
e->time = xevent->xclient.data.l[3]; /* Version 1 */
|
||||||
|
e->action = _xdnd->action;
|
||||||
|
ecore_event_add(ECORE_X_EVENT_XDND_POSITION, e, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Message Type: XdndStatus */
|
/* Message Type: XdndStatus */
|
||||||
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_STATUS)
|
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_STATUS)
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Xdnd_Status *e;
|
Ecore_X_Event_Xdnd_Status *e;
|
||||||
Ecore_X_DND_Protocol *_xdnd;
|
Ecore_X_DND_Protocol *_xdnd;
|
||||||
|
|
||||||
_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;
|
||||||
|
|
||||||
_xdnd->rectangle.x = xevent->xclient.data.l[2] >> 16;
|
_xdnd->rectangle.x = xevent->xclient.data.l[2] >> 16;
|
||||||
_xdnd->rectangle.y = xevent->xclient.data.l[2] & 0xFFFFUL;
|
_xdnd->rectangle.y = xevent->xclient.data.l[2] & 0xFFFFUL;
|
||||||
_xdnd->rectangle.width = xevent->xclient.data.l[3] >> 16;
|
_xdnd->rectangle.width = xevent->xclient.data.l[3] >> 16;
|
||||||
_xdnd->rectangle.height = xevent->xclient.data.l[3] & 0xFFFFUL;
|
_xdnd->rectangle.height = xevent->xclient.data.l[3] & 0xFFFFUL;
|
||||||
|
|
||||||
_xdnd->accepted_action = xevent->xclient.data.l[4];
|
_xdnd->accepted_action = xevent->xclient.data.l[4];
|
||||||
|
|
||||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Status));
|
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Status));
|
||||||
if (!e) return;
|
if (!e) return;
|
||||||
e->win = _xdnd->source;
|
e->win = _xdnd->source;
|
||||||
e->target = _xdnd->dest;
|
e->target = _xdnd->dest;
|
||||||
e->will_accept = _xdnd->will_accept;
|
e->will_accept = _xdnd->will_accept;
|
||||||
e->rectangle.x = _xdnd->rectangle.x;
|
e->rectangle.x = _xdnd->rectangle.x;
|
||||||
e->rectangle.y = _xdnd->rectangle.y;
|
e->rectangle.y = _xdnd->rectangle.y;
|
||||||
e->rectangle.width = _xdnd->rectangle.width;
|
e->rectangle.width = _xdnd->rectangle.width;
|
||||||
e->rectangle.height = _xdnd->rectangle.height;
|
e->rectangle.height = _xdnd->rectangle.height;
|
||||||
e->action = _xdnd->accepted_action;
|
e->action = _xdnd->accepted_action;
|
||||||
|
|
||||||
ecore_event_add(ECORE_X_EVENT_XDND_STATUS, e, NULL, NULL);
|
ecore_event_add(ECORE_X_EVENT_XDND_STATUS, e, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Message Type: XdndLeave */
|
/* Message Type: XdndLeave */
|
||||||
/* Pretend the whole thing never happened, sort of */
|
/* Pretend the whole thing never happened, sort of */
|
||||||
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_LEAVE)
|
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_LEAVE)
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Xdnd_Leave *e;
|
Ecore_X_Event_Xdnd_Leave *e;
|
||||||
Ecore_X_DND_Protocol *_xdnd;
|
Ecore_X_DND_Protocol *_xdnd;
|
||||||
|
|
||||||
_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)
|
/* XXX: May need to reset event handler callbacks as well */
|
||||||
free(_xdnd->types);
|
_xdnd->state = ECORE_X_DND_IDLE;
|
||||||
_xdnd->num_types = 0;
|
|
||||||
/* XXX: May need to reset event handler callbacks as well */
|
|
||||||
_xdnd->state = ECORE_X_DND_IDLE;
|
|
||||||
|
|
||||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Leave));
|
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Leave));
|
||||||
if (!e) return;
|
if (!e) return;
|
||||||
e->win = _xdnd->dest;
|
e->win = _xdnd->dest;
|
||||||
e->source = _xdnd->source;
|
e->source = _xdnd->source;
|
||||||
ecore_event_add(ECORE_X_EVENT_XDND_LEAVE, e, NULL, NULL);
|
ecore_event_add(ECORE_X_EVENT_XDND_LEAVE, e, NULL, NULL);
|
||||||
}
|
}
|
||||||
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_DROP)
|
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_DROP)
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Xdnd_Drop *e;
|
Ecore_X_Event_Xdnd_Drop *e;
|
||||||
Ecore_X_DND_Protocol *_xdnd;
|
Ecore_X_DND_Protocol *_xdnd;
|
||||||
Ecore_X_Time timestamp;
|
Ecore_X_Time timestamp;
|
||||||
|
|
||||||
_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,
|
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop));
|
||||||
_xdnd->dest, ECORE_X_ATOM_SELECTION_PROP_XDND, _xdnd->dest,
|
if (!e) return;
|
||||||
timestamp);
|
e->win = _xdnd->dest;
|
||||||
|
e->source = _xdnd->source;
|
||||||
/* FIXME: Have to wait for SelectionNotify before we can send
|
e->time = timestamp;
|
||||||
* XdndFinished. Stupid, retarded protocols, gah! */
|
e->action = _xdnd->action;
|
||||||
|
e->position.x = _xdnd->pos.x;
|
||||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop));
|
e->position.y = _xdnd->pos.y;
|
||||||
if (!e) return;
|
ecore_event_add(ECORE_X_EVENT_XDND_DROP, e, NULL, NULL);
|
||||||
e->win = _xdnd->dest;
|
}
|
||||||
e->source = _xdnd->source;
|
|
||||||
e->time = timestamp;
|
|
||||||
e->action = _xdnd->action;
|
|
||||||
e->position.x = _xdnd->pos.x;
|
|
||||||
e->position.y = _xdnd->pos.y;
|
|
||||||
ecore_event_add(ECORE_X_EVENT_XDND_DROP, e, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Message Type: XdndFinished */
|
/* Message Type: XdndFinished */
|
||||||
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_FINISHED)
|
else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_FINISHED)
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Xdnd_Finished *e;
|
Ecore_X_Event_Xdnd_Finished *e;
|
||||||
Ecore_X_DND_Protocol *_xdnd;
|
Ecore_X_DND_Protocol *_xdnd;
|
||||||
int completed = 1;
|
int completed = 1;
|
||||||
|
|
||||||
_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;
|
||||||
} else {
|
} else {
|
||||||
completed = 0;
|
completed = 0;
|
||||||
_xdnd->state = ECORE_X_DND_TARGET_CONVERTING;
|
_xdnd->state = ECORE_X_DND_TARGET_CONVERTING;
|
||||||
|
|
||||||
/* FIXME: Probably need to add a timer to switch back to idle
|
/* FIXME: Probably need to add a timer to switch back to idle
|
||||||
* and discard the selection data */
|
* and discard the selection data */
|
||||||
}
|
}
|
||||||
|
|
||||||
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Finished));
|
e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Finished));
|
||||||
if (!e) return;
|
if (!e) return;
|
||||||
e->win = _xdnd->source;
|
e->win = _xdnd->source;
|
||||||
e->target = _xdnd->dest;
|
e->target = _xdnd->dest;
|
||||||
e->completed = completed;
|
e->completed = completed;
|
||||||
if (_xdnd->version >= 5)
|
if (_xdnd->version >= 5)
|
||||||
{
|
{
|
||||||
_xdnd->accepted_action = xevent->xclient.data.l[2];
|
_xdnd->accepted_action = xevent->xclient.data.l[2];
|
||||||
e->action = _xdnd->accepted_action;
|
e->action = _xdnd->accepted_action;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_xdnd->accepted_action = 0;
|
_xdnd->accepted_action = 0;
|
||||||
e->action = _xdnd->action;
|
e->action = _xdnd->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL);
|
ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL);
|
||||||
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Ecore_X_Event_Client_Message *e;
|
Ecore_X_Event_Client_Message *e;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
e = (Ecore_X_Event_Client_Message *) calloc(1, sizeof(Ecore_X_Event_Client_Message));
|
e = (Ecore_X_Event_Client_Message *) calloc(1, sizeof(Ecore_X_Event_Client_Message));
|
||||||
e->win = xevent->xclient.window;
|
e->win = xevent->xclient.window;
|
||||||
e->message_type = xevent->xclient.message_type;
|
e->message_type = xevent->xclient.message_type;
|
||||||
e->format = xevent->xclient.format;
|
e->format = xevent->xclient.format;
|
||||||
for(i = 0; i < 5; i++)
|
for(i = 0; i < 5; i++)
|
||||||
e->data.l[i] = xevent->xclient.data.l[i];
|
e->data.l[i] = xevent->xclient.data.l[i];
|
||||||
|
|
||||||
ecore_event_add(ECORE_X_EVENT_CLIENT_MESSAGE, e, NULL, NULL);
|
ecore_event_add(ECORE_X_EVENT_CLIENT_MESSAGE, e, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,11 +41,12 @@ _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;
|
||||||
}
|
}
|
||||||
|
|
||||||
converters = NULL;
|
converters = NULL;
|
||||||
}
|
}
|
||||||
|
@ -56,22 +57,22 @@ _ecore_x_selection_request_data_get(Ecore_X_Atom selection, void **buf, int *len
|
||||||
int i;
|
int i;
|
||||||
char *data;
|
char *data;
|
||||||
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
||||||
i = 0;
|
i = 0;
|
||||||
else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
|
else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
|
||||||
i = 1;
|
i = 1;
|
||||||
else if (selection == ECORE_X_ATOM_SELECTION_XDND)
|
else if (selection == ECORE_X_ATOM_SELECTION_XDND)
|
||||||
i = 2;
|
i = 2;
|
||||||
else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
|
else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
|
||||||
i = 3;
|
i = 3;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!request_data[i].data || !request_data[i].length)
|
if (!request_data[i].data || !request_data[i].length)
|
||||||
{
|
{
|
||||||
*len = 0;
|
*len = 0;
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = malloc(request_data[i].length);
|
data = malloc(request_data[i].length);
|
||||||
memcpy(data, request_data[i].data, request_data[i].length);
|
memcpy(data, request_data[i].data, request_data[i].length);
|
||||||
|
@ -145,15 +146,15 @@ _ecore_x_selection_request_data_set(Ecore_X_Selection_Data data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (data.selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
if (data.selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
||||||
i = 0;
|
i = 0;
|
||||||
else if (data.selection == ECORE_X_ATOM_SELECTION_SECONDARY)
|
else if (data.selection == ECORE_X_ATOM_SELECTION_SECONDARY)
|
||||||
i = 1;
|
i = 1;
|
||||||
else if (data.selection == ECORE_X_ATOM_SELECTION_XDND)
|
else if (data.selection == ECORE_X_ATOM_SELECTION_XDND)
|
||||||
i = 2;
|
i = 2;
|
||||||
else if (data.selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
|
else if (data.selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
|
||||||
i = 3;
|
i = 3;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
request_data[i] = data;
|
request_data[i] = data;
|
||||||
}
|
}
|
||||||
|
@ -162,13 +163,15 @@ Ecore_X_Selection_Data *
|
||||||
_ecore_x_selection_get(Atom selection)
|
_ecore_x_selection_get(Atom selection)
|
||||||
{
|
{
|
||||||
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
||||||
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_XDND)
|
||||||
|
return &selections[2];
|
||||||
else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
|
else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
|
||||||
return &selections[2];
|
return &selections[3];
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -179,34 +182,36 @@ _ecore_x_selection_set(Window w, unsigned char *data, int size, Atom selection)
|
||||||
|
|
||||||
XSetSelectionOwner(_ecore_x_disp, selection, w, _ecore_x_event_last_time);
|
XSetSelectionOwner(_ecore_x_disp, selection, w, _ecore_x_event_last_time);
|
||||||
if (XGetSelectionOwner(_ecore_x_disp, selection) != w)
|
if (XGetSelectionOwner(_ecore_x_disp, selection) != w)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
||||||
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 if (selection == ECORE_X_ATOM_SELECTION_XDND)
|
||||||
|
in = 2;
|
||||||
else
|
else
|
||||||
in = 2;
|
in = 3;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
selections[in].win = w;
|
selections[in].win = w;
|
||||||
selections[in].selection = selection;
|
selections[in].selection = selection;
|
||||||
selections[in].length = size;
|
selections[in].length = size;
|
||||||
selections[in].time = _ecore_x_event_last_time;
|
selections[in].time = _ecore_x_event_last_time;
|
||||||
|
|
||||||
buf = malloc(size);
|
buf = malloc(size);
|
||||||
memcpy(buf, data, size);
|
memcpy(buf, data, size);
|
||||||
selections[in].data = buf;
|
selections[in].data = buf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (selections[in].data)
|
if (selections[in].data)
|
||||||
{
|
{
|
||||||
free(selections[in].data);
|
free(selections[in].data);
|
||||||
memset(&selections[in], 0, sizeof(Ecore_X_Selection_Data));
|
memset(&selections[in], 0, sizeof(Ecore_X_Selection_Data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -304,23 +329,23 @@ _ecore_x_selection_target_atom_get(char *target)
|
||||||
Atom x_target;
|
Atom x_target;
|
||||||
|
|
||||||
if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
|
if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
|
||||||
x_target = ECORE_X_ATOM_TEXT;
|
x_target = ECORE_X_ATOM_TEXT;
|
||||||
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
|
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
|
||||||
x_target = ECORE_X_ATOM_COMPOUND_TEXT;
|
x_target = ECORE_X_ATOM_COMPOUND_TEXT;
|
||||||
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
|
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
|
||||||
x_target = ECORE_X_ATOM_STRING;
|
x_target = ECORE_X_ATOM_STRING;
|
||||||
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
|
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
|
||||||
x_target = ECORE_X_ATOM_UTF8_STRING;
|
x_target = ECORE_X_ATOM_UTF8_STRING;
|
||||||
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_FILENAME))
|
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_FILENAME))
|
||||||
x_target = ECORE_X_ATOM_FILE_NAME;
|
x_target = ECORE_X_ATOM_FILE_NAME;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *atom_name;
|
char *atom_name;
|
||||||
atom_name = malloc(strlen(target) + 4);
|
atom_name = malloc(strlen(target) + 4);
|
||||||
sprintf(atom_name, "_E_%s", target);
|
sprintf(atom_name, "_E_%s", target);
|
||||||
x_target = XInternAtom(_ecore_x_disp, atom_name, False);
|
x_target = XInternAtom(_ecore_x_disp, atom_name, False);
|
||||||
free(atom_name);
|
free(atom_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return x_target;
|
return x_target;
|
||||||
}
|
}
|
||||||
|
@ -329,15 +354,15 @@ char *
|
||||||
_ecore_x_selection_target_get(Atom target)
|
_ecore_x_selection_target_get(Atom target)
|
||||||
{
|
{
|
||||||
if (target == ECORE_X_ATOM_FILE_NAME)
|
if (target == ECORE_X_ATOM_FILE_NAME)
|
||||||
return strdup(ECORE_X_SELECTION_TARGET_FILENAME);
|
return strdup(ECORE_X_SELECTION_TARGET_FILENAME);
|
||||||
else if (target == ECORE_X_ATOM_STRING)
|
else if (target == ECORE_X_ATOM_STRING)
|
||||||
return strdup(ECORE_X_SELECTION_TARGET_STRING);
|
return strdup(ECORE_X_SELECTION_TARGET_STRING);
|
||||||
else if (target == ECORE_X_ATOM_UTF8_STRING)
|
else if (target == ECORE_X_ATOM_UTF8_STRING)
|
||||||
return strdup(ECORE_X_SELECTION_TARGET_UTF8_STRING);
|
return strdup(ECORE_X_SELECTION_TARGET_UTF8_STRING);
|
||||||
else if (target == ECORE_X_ATOM_TEXT)
|
else if (target == ECORE_X_ATOM_TEXT)
|
||||||
return strdup(ECORE_X_SELECTION_TARGET_TEXT);
|
return strdup(ECORE_X_SELECTION_TARGET_TEXT);
|
||||||
else
|
else
|
||||||
return strdup(ECORE_X_SELECTION_TARGET_TEXT);
|
return strdup(ECORE_X_SELECTION_TARGET_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -348,16 +373,14 @@ _ecore_x_selection_request(Ecore_X_Window w, Ecore_X_Atom selection, char *targe
|
||||||
target = _ecore_x_selection_target_atom_get(target_str);
|
target = _ecore_x_selection_target_atom_get(target_str);
|
||||||
|
|
||||||
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
|
||||||
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;
|
||||||
|
|
||||||
XConvertSelection(_ecore_x_disp, selection, target, prop,
|
XConvertSelection(_ecore_x_disp, selection, target, prop,
|
||||||
w, _ecore_x_event_last_time);
|
w, _ecore_x_event_last_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -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,9 +436,11 @@ 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 {
|
}
|
||||||
converters = calloc(1, sizeof(Ecore_X_Selection_Converter));
|
else
|
||||||
cnv = converters;
|
{
|
||||||
|
converters = calloc(1, sizeof(Ecore_X_Selection_Converter));
|
||||||
|
cnv = converters;
|
||||||
}
|
}
|
||||||
cnv->target = target;
|
cnv->target = target;
|
||||||
cnv->convert = func;
|
cnv->convert = func;
|
||||||
|
@ -418,7 +454,7 @@ ecore_x_selection_converter_add(char *target,
|
||||||
Ecore_X_Atom x_target;
|
Ecore_X_Atom x_target;
|
||||||
|
|
||||||
if (!func || !target)
|
if (!func || !target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x_target = _ecore_x_selection_target_atom_get(target);
|
x_target = _ecore_x_selection_target_atom_get(target);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -465,7 +501,7 @@ ecore_x_selection_converter_del(char *target)
|
||||||
Ecore_X_Atom x_target;
|
Ecore_X_Atom x_target;
|
||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x_target = _ecore_x_selection_target_atom_get(target);
|
x_target = _ecore_x_selection_target_atom_get(target);
|
||||||
ecore_x_selection_converter_atom_del(x_target);
|
ecore_x_selection_converter_atom_del(x_target);
|
||||||
|
@ -509,30 +545,31 @@ _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;
|
||||||
XICCEncodingStyle style;
|
XICCEncodingStyle style;
|
||||||
|
|
||||||
if (!data || !size)
|
if (!data || !size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
|
if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
|
||||||
style = XTextStyle;
|
style = XTextStyle;
|
||||||
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
|
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
|
||||||
style = XCompoundTextStyle;
|
style = XCompoundTextStyle;
|
||||||
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
|
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
|
||||||
style = XStringStyle;
|
style = XStringStyle;
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
|
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
|
||||||
style = XUTF8StringStyle;
|
style = XUTF8StringStyle;
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(mystr = strdup(data)))
|
if (!(mystr = strdup(data)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (XmbTextListToTextProperty(_ecore_x_disp, &mystr, 1, style, &text_prop) == Success)
|
if (XmbTextListToTextProperty(_ecore_x_disp, &mystr, 1, style, &text_prop) == Success)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue