static Cnp_Atom atoms[CNP_N_ATOMS] = {
[CNP_ATOM_TARGETS] = {
"TARGETS",
- (Elm_Sel_Format) -1, // everything
+ ELM_SEL_TARGETS,
targets_converter,
response_handler_targets,
notify_handler_targets,
0
},
[CNP_ATOM_ATOM] = {
- "ATOM",
- (Elm_Sel_Format) -1, // everything
+ "ATOM", // for opera browser
+ ELM_SEL_TARGETS,
targets_converter,
response_handler_targets,
notify_handler_targets,
sel = selections + selection;
- sel->active = 1;
+ sel->active = EINA_TRUE;
sel->widget = widget;
sel->set(xwin, &selection, sizeof(Elm_Sel_Type));
/* No longer this selection: Consider it gone! */
if ((!sel->active) || (sel->widget != widget)) return EINA_TRUE;
- sel->active = 0;
+ sel->active = EINA_FALSE;
sel->widget = NULL;
sel->clear();
return ECORE_CALLBACK_PASS_ON;
}
-
+static Elm_Sel_Format
+_get_selection_type(void *data, int size)
+{
+ if (size == sizeof(Elm_Sel_Type))
+ {
+ Cnp_Selection *sel;
+ sel = selections + *((int *)data);
+ if (sel->active)
+ return sel->format;
+ }
+ return ELM_SEL_FORMAT_NONE;
+}
static Eina_Bool
targets_converter(char *target __UNUSED__, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize)
if (!data_ret) return EINA_FALSE;
- if (size != sizeof(int))
+ if (_get_selection_type(data, size) == ELM_SEL_FORMAT_NONE)
{
if (data_ret)
{
Cnp_Selection *sel;
cnp_debug("text converter\n");
- if (size != sizeof(int))
+ if (_get_selection_type(data, size) == ELM_SEL_FORMAT_NONE)
{
if (data_ret)
{
static Eina_Bool
general_converter(char *target __UNUSED__, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *ttype __UNUSED__, int *typesize __UNUSED__)
{
- if (size == sizeof(int))
- {
- Cnp_Selection *sel;
-
- sel = selections + *((int *)data);
- if (data_ret) *data_ret = strdup(sel->selbuf);
- if (size_ret) *size_ret = strlen(sel->selbuf);
- }
- else if (size)
+ if (_get_selection_type(data, size) == ELM_SEL_FORMAT_NONE)
{
if (data_ret)
{
}
if (size_ret) *size_ret = size;
}
+ else
+ {
+ Cnp_Selection *sel;
+
+ sel = selections + *((int *)data);
+ if (data_ret) *data_ret = strdup(sel->selbuf);
+ if (size_ret) *size_ret = strlen(sel->selbuf);
+ }
return EINA_TRUE;
}
typedef enum _Elm_Sel_Format
{
+ /** Targets: for matching every atom requesting */
+ ELM_SEL_TARGETS = -1,
+ /** they come from outside of elm */
+ ELM_SEL_FORMAT_NONE = 0x0,
/** Plain unformated text: Used for things that don't want rich markup */
ELM_SEL_FORMAT_TEXT = 0x01,
/** Edje textblock markup, including inline images */
ELM_SEL_FORMAT_MARKUP = 0x02,
/** Images */
- ELM_SEL_FORMAT_IMAGE = 0x04,
+ ELM_SEL_FORMAT_IMAGE = 0x04,
/** Vcards */
- ELM_SEL_FORMAT_VCARD = 0x08,
+ ELM_SEL_FORMAT_VCARD = 0x08,
/** Raw HTMLish things for widgets that want that stuff (hello webkit!) */
- ELM_SEL_FORMAT_HTML = 0x10,
+ ELM_SEL_FORMAT_HTML = 0x10,
} Elm_Sel_Format;
struct _Elm_Selection_Data