forked from enlightenment/efl
parent
635ac723f6
commit
b1a203f57b
|
@ -1393,53 +1393,68 @@ _ecore_x_event_handle_selection_clear(xcb_generic_event_t *event)
|
|||
void
|
||||
_ecore_x_event_handle_selection_request(xcb_generic_event_t *event)
|
||||
{
|
||||
xcb_selection_request_event_t *ev;
|
||||
Ecore_X_Selection_Intern *sd;
|
||||
xcb_selection_notify_event_t sn_event;
|
||||
void *data;
|
||||
xcb_selection_request_event_t *ev;
|
||||
Ecore_X_Event_Selection_Request *e;
|
||||
Ecore_X_Selection_Intern *sd;
|
||||
void *data;
|
||||
int len;
|
||||
int typesize;
|
||||
|
||||
ev = (xcb_selection_request_event_t *)event;
|
||||
/* FIXME: is it the correct value ? */
|
||||
sn_event.response_type = XCB_SELECTION_NOTIFY;
|
||||
sn_event.pad0 = 0;
|
||||
/* FIXME: is it the correct value ? */
|
||||
sn_event.sequence = 0;
|
||||
sn_event.time = XCB_CURRENT_TIME;
|
||||
sn_event.requestor = ev->requestor;
|
||||
sn_event.selection = ev->selection;
|
||||
sn_event.target = ev->target;
|
||||
_ecore_xcb_last_event_mouse_move = 0;
|
||||
|
||||
/*
|
||||
* Generate a selection request event.
|
||||
*/
|
||||
e = malloc(sizeof(Ecore_X_Event_Selection_Request));
|
||||
e->owner = ev->owner;
|
||||
e->requestor = ev->requestor;
|
||||
e->time = ev->time;
|
||||
e->selection = ev->selection;
|
||||
e->target = ev->target;
|
||||
e->property = ev->property;
|
||||
ecore_event_add(ECORE_X_EVENT_SELECTION_REQUEST, e, NULL, NULL);
|
||||
|
||||
if ((sd = _ecore_x_selection_get(ev->selection)) &&
|
||||
(sd->win == ev->owner))
|
||||
{
|
||||
if (!ecore_x_selection_convert(ev->selection, ev->target,
|
||||
&data))
|
||||
{
|
||||
/* Refuse selection, conversion to requested target failed */
|
||||
sn_event.property = XCB_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: This does not properly handle large data transfers */
|
||||
ecore_x_window_prop_property_set(ev->requestor,
|
||||
ev->property,
|
||||
ev->target,
|
||||
8, data, sd->length);
|
||||
sn_event.property = ev->property;
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sn_event.property = XCB_NONE;
|
||||
return;
|
||||
}
|
||||
Ecore_X_Selection_Intern *si;
|
||||
|
||||
/* FIXME: I use _ecore_xcb_conn, as ev has no information on the connection */
|
||||
xcb_send_event(_ecore_xcb_conn, 0,
|
||||
ev->requestor, 0, (const char *)&sn_event);
|
||||
si = _ecore_x_selection_get(ev->selection);
|
||||
if (si->data)
|
||||
{
|
||||
Ecore_X_Atom property;
|
||||
Ecore_X_Atom type;
|
||||
|
||||
free(event);
|
||||
/* Set up defaults for strings first */
|
||||
type = ev->target;
|
||||
typesize = 8;
|
||||
len = sd->length;
|
||||
|
||||
if (!ecore_x_selection_convert(ev->selection, ev->target,
|
||||
&data, &len, &type, &typesize))
|
||||
{
|
||||
/* Refuse selection, conversion to requested target failed */
|
||||
property = XCB_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: This does not properly handle large data transfers */
|
||||
ecore_x_window_prop_property_set(ev->requestor,
|
||||
ev->property,
|
||||
ev->target,
|
||||
8, data, sd->length);
|
||||
property = ev->property;
|
||||
free(data);
|
||||
}
|
||||
|
||||
ecore_x_selection_notify_send(ev->requestor,
|
||||
ev->selection,
|
||||
ev->target,
|
||||
property,
|
||||
ev->time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: round trip */
|
||||
|
|
|
@ -107,7 +107,8 @@ struct _Ecore_X_Selection_Converter
|
|||
{
|
||||
Ecore_X_Atom target;
|
||||
int (*convert)(char *target, void *data, int size,
|
||||
void **data_ret, int *size_ret);
|
||||
void **data_ret, int *size_ret,
|
||||
Ecore_X_Atom *type, int *typeseize);
|
||||
Ecore_X_Selection_Converter *next;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ static Ecore_X_Selection_Intern selections[4];
|
|||
static Ecore_X_Selection_Converter *converters = NULL;
|
||||
static Ecore_X_Selection_Parser *parsers = NULL;
|
||||
|
||||
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, Ecore_X_Atom *tprop, int *);
|
||||
static int _ecore_x_selection_data_default_free(void *data);
|
||||
static void *_ecore_x_selection_parser_files(const char *target, void *data, int size, int format);
|
||||
static int _ecore_x_selection_data_files_free(void *data);
|
||||
|
@ -23,7 +23,7 @@ static int _ecore_x_selection_data_targets_free(void *data);
|
|||
#define ECORE_X_SELECTION_DATA(x) ((Ecore_X_Selection_Data *)(x))
|
||||
|
||||
void
|
||||
_ecore_x_selection_init(void)
|
||||
_ecore_x_selection_data_init(void)
|
||||
{
|
||||
/* Initialize global data */
|
||||
memset(selections, 0, sizeof(selections));
|
||||
|
@ -567,7 +567,9 @@ ecore_x_selection_converter_atom_add(Ecore_X_Atom target,
|
|||
void *data,
|
||||
int size,
|
||||
void **data_ret,
|
||||
int *size_ret))
|
||||
int *size_ret,
|
||||
Ecore_X_Atom *ttype,
|
||||
int *tsize))
|
||||
{
|
||||
Ecore_X_Selection_Converter *cnv;
|
||||
|
||||
|
@ -605,7 +607,9 @@ ecore_x_selection_converter_add(char *target,
|
|||
void *data,
|
||||
int size,
|
||||
void **data_ret,
|
||||
int *size_ret))
|
||||
int *size_ret,
|
||||
Ecore_X_Atom *,
|
||||
int *))
|
||||
{
|
||||
Ecore_X_Atom x_target;
|
||||
|
||||
|
@ -678,15 +682,17 @@ ecore_x_selection_notify_send(Ecore_X_Window requestor,
|
|||
|
||||
/* Locate and run conversion callback for specified selection target */
|
||||
EAPI int
|
||||
ecore_x_selection_convert(Ecore_X_Atom selection,
|
||||
Ecore_X_Atom target,
|
||||
void **data_ret)
|
||||
ecore_x_selection_convert(Ecore_X_Atom selection,
|
||||
Ecore_X_Atom target,
|
||||
void **data_ret,
|
||||
int *size,
|
||||
Ecore_X_Atom *targtype,
|
||||
int *typesize)
|
||||
{
|
||||
Ecore_X_Selection_Intern *sel;
|
||||
Ecore_X_Selection_Converter *cnv;
|
||||
void *data;
|
||||
char *tgt_str;
|
||||
int size;
|
||||
|
||||
sel = _ecore_x_selection_get(selection);
|
||||
tgt_str = _ecore_x_selection_target_get(target);
|
||||
|
@ -696,7 +702,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection,
|
|||
if (cnv->target == target)
|
||||
{
|
||||
int r;
|
||||
r = cnv->convert(tgt_str, sel->data, sel->length, &data, &size);
|
||||
r = cnv->convert(tgt_str, sel->data, sel->length, &data, size, targtype, typesize);
|
||||
free(tgt_str);
|
||||
if (r)
|
||||
{
|
||||
|
@ -719,7 +725,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection,
|
|||
* locale using Ecore_Txt functions */
|
||||
/* 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)
|
||||
_ecore_x_selection_converter_text(char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *targprop, int *s)
|
||||
{
|
||||
|
||||
/* FIXME: to do... */
|
||||
|
|
Loading…
Reference in New Issue