summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2015-06-19 23:52:16 +0300
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2015-06-20 22:23:06 +0300
commit475bc14beddf4229b030acf0ae127e436ef63d2b (patch)
treea84f6cd5647841341293e7652266a886cc275f6e
parent70626580a63696c2a947f19265dfe23ec509a32d (diff)
downloadelementary-475bc14beddf4229b030acf0ae127e436ef63d2b.tar.gz
NO PUSH: selection targets determination
This patch tries to improve the selection code by removing a function that is totally wrong. This one checks data that is not some uri but targets atoms ids sent by the source. The problem is that now, during a cnp of text inside an entry, the requested type is uri. The uri handler doesn't know how to deal with the sent data. If we change it to retrive text when no file is found, the data appears but is no more converted to plain text (markups characters). A solution would be that when the uri handler fails, we request the next type that was proposed by the source and supported by the target.
-rw-r--r--src/lib/elm_cnp.c57
1 files changed, 17 insertions, 40 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 17b5a74d4..0aceecd70 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -216,7 +216,6 @@ static Eina_Bool _x11_text_converter (char *target, void *data, i
static Eina_Bool _x11_general_converter (char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize);
static Eina_Bool _x11_image_converter (char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize);
static Eina_Bool _x11_vcard_send (char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize);
-static Eina_Bool _x11_is_uri_type_data (X11_Cnp_Selection *sel EINA_UNUSED, Ecore_X_Event_Selection_Notify *notify);
static Eina_Bool _x11_notify_handler_targets (X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify);
static Eina_Bool _x11_data_preparer_text (Ecore_X_Event_Selection_Notify *notify, Elm_Selection_Data *ddata, Tmp_Info **tmp_info);
static Eina_Bool _x11_data_preparer_image (Ecore_X_Event_Selection_Notify *notify, Elm_Selection_Data *ddata, Tmp_Info **tmp_info);
@@ -890,25 +889,6 @@ _x11_vcard_send(char *target EINA_UNUSED, void *data EINA_UNUSED, int size EINA_
return EINA_TRUE;
}
-static Eina_Bool
-_x11_is_uri_type_data(X11_Cnp_Selection *sel EINA_UNUSED, Ecore_X_Event_Selection_Notify *notify)
-{
- Ecore_X_Selection_Data *data;
- char *p;
-
- data = notify->data;
- cnp_debug("data->format is %d %p %p\n", data->format, notify, data);
- if (data->content == ECORE_X_SELECTION_CONTENT_FILES) return EINA_TRUE;
- p = (char *)data->data;
- if (!p) return EINA_TRUE;
- cnp_debug("Got %s\n", p);
- if (strncmp(p, "file:/", 6))
- {
- if (*p != '/') return EINA_FALSE;
- }
- return EINA_TRUE;
-}
-
/*
* Callback to handle a targets response on a selection request:
* So pick the format we'd like; and then request it.
@@ -918,36 +898,33 @@ _x11_notify_handler_targets(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Noti
{
Ecore_X_Selection_Data_Targets *targets;
Ecore_X_Atom *atomlist;
- int i, j;
+ int i, min_index = CNP_N_ATOMS;
+ cnp_debug("Selection format %X\n", sel->format);
targets = notify->data;
atomlist = (Ecore_X_Atom *)(targets->data.data);
for (i = 0; i < targets->data.length; i++) cnp_debug("Source Atom %s\n", ecore_x_atom_name_get(atomlist[i]));
- for (j = (CNP_ATOM_LISTING_ATOMS + 1); j < CNP_N_ATOMS; j++)
+ /* We have to find the first atom that corresponds to one
+ * of the supported data types. */
+ for (i = 0; i < targets->data.length; i++)
{
- cnp_debug("\t%s %d\n", _atoms[j].name, _atoms[j].x_atom);
- if (!(_atoms[j].formats & sel->requestformat)) continue;
- for (i = 0; i < targets->data.length; i++)
+ Cnp_Atom *atom = eina_hash_find(_types_hash, ecore_x_atom_name_get(atomlist[i]));
+ if (atom && atom->formats != ELM_SEL_FORMAT_TARGETS && (atom->formats & sel->format))
{
- if ((_atoms[j].x_atom == atomlist[i]) && (_atoms[j].x_data_preparer))
- {
- if ((j == CNP_ATOM_text_uri) ||
- (j == CNP_ATOM_text_urilist))
- {
- if (!_x11_is_uri_type_data(sel, notify)) continue;
- }
- cnp_debug("Atom %s matches\n", _atoms[j].name);
- goto done;
- }
+ int atom_idx = (atom - _atoms);
+ if (min_index > atom_idx) min_index = atom_idx;
+ cnp_debug("Candidate atom %s %d %d\n", ecore_x_atom_name_get(atomlist[i]), atom_idx, min_index);
}
}
+ if (min_index != CNP_N_ATOMS)
+ {
+ cnp_debug("Sending request for %s, xwin=%#llx\n",
+ _atoms[min_index].name, (unsigned long long)sel->xwin);
+ sel->request(sel->xwin, _atoms[min_index].name);
+ return ECORE_CALLBACK_PASS_ON;
+ }
cnp_debug("Couldn't find anything that matches\n");
return ECORE_CALLBACK_PASS_ON;
-done:
- cnp_debug("Sending request for %s, xwin=%#llx\n",
- _atoms[j].name, (unsigned long long)sel->xwin);
- sel->request(sel->xwin, _atoms[j].name);
- return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool