Ecore_X(cb): More work toward the effort of getting drag-n-drop to

work for gtk apps (tho no success yet).



SVN revision: 62731
This commit is contained in:
Christopher Michael 2011-08-23 18:03:11 +00:00
parent f915dca8ae
commit e07f363689
1 changed files with 49 additions and 27 deletions

View File

@ -113,11 +113,13 @@ ecore_x_selection_converter_atom_add(Ecore_X_Atom target,
break; break;
} }
cnv->next = calloc(1, sizeof(Ecore_X_Selection_Converter)); cnv->next = calloc(1, sizeof(Ecore_X_Selection_Converter));
if (!cnv->next) return;
cnv = cnv->next; cnv = cnv->next;
} }
else else
{ {
_converters = calloc(1, sizeof(Ecore_X_Selection_Converter)); _converters = calloc(1, sizeof(Ecore_X_Selection_Converter));
if (!_converters) return;
cnv = _converters; cnv = _converters;
} }
cnv->target = target; cnv->target = target;
@ -435,7 +437,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, Ecore_X_Atom target, void **da
} }
EAPI Eina_Bool EAPI Eina_Bool
ecore_x_selection_notify_send(Ecore_X_Window requestor, Ecore_X_Atom selection, Ecore_X_Atom target, Ecore_X_Atom property, Ecore_X_Time time) ecore_x_selection_notify_send(Ecore_X_Window requestor, Ecore_X_Atom selection, Ecore_X_Atom target, Ecore_X_Atom property, Ecore_X_Time tim)
{ {
xcb_selection_notify_event_t ev; xcb_selection_notify_event_t ev;
@ -448,7 +450,7 @@ ecore_x_selection_notify_send(Ecore_X_Window requestor, Ecore_X_Atom selection,
ev.selection = selection; ev.selection = selection;
ev.target = target; ev.target = target;
ev.property = property; ev.property = property;
ev.time = time; ev.time = tim;
xcb_send_event(_ecore_xcb_conn, 0, requestor, xcb_send_event(_ecore_xcb_conn, 0, requestor,
XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
@ -457,11 +459,11 @@ ecore_x_selection_notify_send(Ecore_X_Window requestor, Ecore_X_Atom selection,
} }
EAPI void EAPI void
ecore_x_selection_owner_set(Ecore_X_Window win, Ecore_X_Atom atom, Ecore_X_Time time) ecore_x_selection_owner_set(Ecore_X_Window win, Ecore_X_Atom atom, Ecore_X_Time tim)
{ {
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_set_selection_owner(_ecore_xcb_conn, win, atom, time); xcb_set_selection_owner(_ecore_xcb_conn, win, atom, tim);
} }
EAPI Ecore_X_Window EAPI Ecore_X_Window
@ -531,8 +533,7 @@ _ecore_xcb_selection_set(Ecore_X_Window win, const void *data, int size, Ecore_X
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_set_selection_owner(_ecore_xcb_conn, win, xcb_set_selection_owner(_ecore_xcb_conn, win, selection, XCB_CURRENT_TIME);
selection, _ecore_xcb_events_last_time_get());
cookie = xcb_get_selection_owner(_ecore_xcb_conn, selection); cookie = xcb_get_selection_owner(_ecore_xcb_conn, selection);
reply = xcb_get_selection_owner_reply(_ecore_xcb_conn, cookie, NULL); reply = xcb_get_selection_owner_reply(_ecore_xcb_conn, cookie, NULL);
@ -664,7 +665,8 @@ static void *
_ecore_xcb_selection_parser_text(const char *target __UNUSED__, void *data, int size, int format __UNUSED__) _ecore_xcb_selection_parser_text(const char *target __UNUSED__, void *data, int size, int format __UNUSED__)
{ {
Ecore_X_Selection_Data_Text *sel; Ecore_X_Selection_Data_Text *sel;
char *_data; unsigned char *_data;
void *t;
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
@ -676,12 +678,19 @@ _ecore_xcb_selection_parser_text(const char *target __UNUSED__, void *data, int
if (_data[size - 1]) if (_data[size - 1])
{ {
size++; size++;
_data = realloc(_data, size); t = realloc(_data, size);
if (!t)
{
free(sel);
return NULL;
}
_data = t;
_data[size - 1] = 0; _data[size - 1] = 0;
} }
sel->text = (char *)_data; sel->text = (char *)_data;
ECORE_XCB_SELECTION_DATA(sel)->length = size; ECORE_XCB_SELECTION_DATA(sel)->length = size;
ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TEXT; ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TEXT;
ECORE_XCB_SELECTION_DATA(sel)->data = _data;
ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_text_free; ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_text_free;
return sel; return sel;
} }
@ -719,6 +728,12 @@ _ecore_xcb_selection_parser_files(const char *target, void *data, int size, int
} }
tmp = malloc(size); tmp = malloc(size);
if (!tmp)
{
free(sel);
return NULL;
}
while ((is < size) && (_data[is])) while ((is < size) && (_data[is]))
{ {
if ((i == 0) && (_data[is] == '#')) if ((i == 0) && (_data[is] == '#'))
@ -770,45 +785,52 @@ static void *
_ecore_xcb_selection_parser_targets(const char *target __UNUSED__, void *data, int size, int format __UNUSED__) _ecore_xcb_selection_parser_targets(const char *target __UNUSED__, void *data, int size, int format __UNUSED__)
{ {
Ecore_X_Selection_Data_Targets *sel; Ecore_X_Selection_Data_Targets *sel;
uint32_t *targets; unsigned long *targets;
xcb_get_atom_name_cookie_t *cookies;
int i = 0; int i = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!(targets = (uint32_t *)data)) return NULL; if (!(targets = (unsigned long *)data)) return NULL;
sel = calloc(1, sizeof(Ecore_X_Selection_Data_Targets)); sel = calloc(1, sizeof(Ecore_X_Selection_Data_Targets));
if (!sel) return NULL; if (!sel) return NULL;
sel->num_targets = (size - 2); sel->num_targets = (size - 2);
sel->targets = malloc((size - 2) * sizeof(char *)); sel->targets = malloc((size - 2) * sizeof(char *));
cookies = if (!sel->targets)
(xcb_get_atom_name_cookie_t *)malloc((size - 2) *
sizeof(xcb_get_atom_name_cookie_t));
for (i = 0; i < (size - 2); i++)
cookies[i] = xcb_get_atom_name_unchecked(_ecore_xcb_conn, targets[i + 2]);
for (i = 0; i < (size - 2); i++)
{ {
free(sel);
return NULL;
}
for (i = 2; i < size; i++)
{
xcb_get_atom_name_cookie_t cookie;
xcb_get_atom_name_reply_t *reply; xcb_get_atom_name_reply_t *reply;
char *name; char *name = NULL;
int len = 0; int len = 0;
reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookies[i], NULL); cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, targets[i]);
len = reply->name_len; reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
name = (char *)malloc(len + 1); if (reply)
memcpy(name, xcb_get_atom_name_name(reply), len); {
name[len] = '\0'; len = xcb_get_atom_name_name_length(reply);
sel->targets[i - 2] = name; name = (char *)malloc(sizeof(char) * (len + 1));
if (name)
{
memcpy(name, xcb_get_atom_name_name(reply), len);
name[len] = '\0';
sel->targets[i - 2] = name;
}
free(reply);
}
} }
free(cookies);
free(data);
ECORE_XCB_SELECTION_DATA(sel)->free = ECORE_XCB_SELECTION_DATA(sel)->free =
_ecore_xcb_selection_data_targets_free; _ecore_xcb_selection_data_targets_free;
ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TARGETS; ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TARGETS;
ECORE_XCB_SELECTION_DATA(sel)->length = size; ECORE_XCB_SELECTION_DATA(sel)->length = size;
ECORE_XCB_SELECTION_DATA(sel)->data = data;
return sel; return sel;
} }