2013-05-29 Mike Blumenkrantz
* Added eina_str_convert_len() to work around broken eina_str_convert()
+ * Add ecore-x(cb) support for text/x-moz-url DND operations
2013-05-28 ChunEon Park (Hermet)
ecore_x_randr_crtc_info_free()
ecore_x_dnd_self_begin()
ecore_x_dnd_self_drop()
+ support for text/x-moz-url DND operations
* ecore_wayland:
- Store global wayland interfaces in a globals list so wayland programs
can bind to other non-standard wayland protocol extensions.
#define ECORE_X_SELECTION_TARGET_STRING "STRING"
#define ECORE_X_SELECTION_TARGET_UTF8_STRING "UTF8_STRING"
#define ECORE_X_SELECTION_TARGET_FILENAME "FILENAME"
+#define ECORE_X_SELECTION_TARGET_X_MOZ_URL "X_MOZ_URL"
#define ECORE_X_DND_VERSION 5
typedef struct _Ecore_X_Selection_Data Ecore_X_Selection_Data;
typedef struct _Ecore_X_Selection_Data_Files Ecore_X_Selection_Data_Files;
typedef struct _Ecore_X_Selection_Data_Text Ecore_X_Selection_Data_Text;
+typedef struct _Ecore_X_Selection_Data_X_Moz_Url Ecore_X_Selection_Data_X_Moz_Url;
typedef struct _Ecore_X_Selection_Data_Targets Ecore_X_Selection_Data_Targets;
typedef struct _Ecore_X_Event_Xdnd_Enter Ecore_X_Event_Xdnd_Enter;
typedef struct _Ecore_X_Event_Xdnd_Position Ecore_X_Event_Xdnd_Position;
ECORE_X_SELECTION_CONTENT_NONE,
ECORE_X_SELECTION_CONTENT_TEXT,
ECORE_X_SELECTION_CONTENT_FILES,
+ ECORE_X_SELECTION_CONTENT_X_MOZ_URL,
ECORE_X_SELECTION_CONTENT_TARGETS,
ECORE_X_SELECTION_CONTENT_CUSTOM
} content;
char *text;
};
+struct _Ecore_X_Selection_Data_X_Moz_Url
+{
+ Ecore_X_Selection_Data data;
+ Eina_Inarray *links;
+ Eina_Inarray *link_names;
+};
+
struct _Ecore_X_Selection_Data_Targets
{
Ecore_X_Selection_Data data;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_STRING;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_TEXT;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_UTF8_STRING;
+EAPI extern Ecore_X_Atom ECORE_X_ATOM_X_MOZ_URL;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_WINDOW;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_PIXMAP;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_VISUALID;
EAPI Ecore_X_Atom ECORE_X_ATOM_FILE_NAME = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_STRING = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_TEXT = 0;
+EAPI Ecore_X_Atom ECORE_X_ATOM_X_MOZ_URL = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_UTF8_STRING = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_WINDOW = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_PIXMAP = 0;
{ "FILE_NAME", &ECORE_X_ATOM_FILE_NAME },
{ "STRING", &ECORE_X_ATOM_STRING },
{ "TEXT", &ECORE_X_ATOM_TEXT },
+ { "X_MOZ_URL", &ECORE_X_ATOM_X_MOZ_URL },
{ "UTF8_STRING", &ECORE_X_ATOM_UTF8_STRING },
{ "WINDOW", &ECORE_X_ATOM_WINDOW },
{ "PIXMAP", &ECORE_X_ATOM_PIXMAP },
void *data,
int size,
int format EINA_UNUSED);
+static void *_ecore_xcb_selection_parser_xmozurl(const char *target EINA_UNUSED,
+ void *data,
+ int size,
+ int format EINA_UNUSED);
static void *_ecore_xcb_selection_parser_files(const char *target,
void *data,
int size,
_ecore_xcb_selection_parser_text);
ecore_x_selection_parser_add("text/uri-list",
_ecore_xcb_selection_parser_files);
+ ecore_x_selection_parser_add("text/x-moz-url",
+ _ecore_x_selection_parser_xmozurl);
ecore_x_selection_parser_add("_NETSCAPE_URL",
_ecore_xcb_selection_parser_files);
ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_TARGETS,
return sel;
}
+static int
+_ecore_xcb_selection_data_xmozurl_free(void *data)
+{
+ Ecore_X_Selection_Data_X_Moz_Url *sel = data;
+ char **buf;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ if (!sel) return 0;
+
+ buf = eina_inarray_nth(sel->links, 0);
+ free(*buf);
+ eina_inarray_free(sel->links);
+ eina_inarray_free(sel->link_names);
+ free(sel);
+ return 1;
+}
+
+static void *
+_ecore_xcb_selection_parser_xmozurl(const char *target EINA_UNUSED,
+ void *_data,
+ int size,
+ int format EINA_UNUSED)
+{
+ Ecore_X_Selection_Data_X_Moz_Url *sel;
+ char *prev, *n, *buf, *data = _data;
+ size_t sz;
+ int num = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ buf = eina_str_convert_len("UTF-16LE", "UTF-8", data, size, &sz);
+ if (!buf) return NULL;
+ sel = calloc(1, sizeof(Ecore_X_Selection_Data_X_Moz_Url));
+ if (!sel)
+ {
+ free(buf);
+ return NULL;
+ }
+ sel->links = eina_inarray_new(sizeof(char*), 0);
+ sel->link_names = eina_inarray_new(sizeof(char*), 0);
+ prev = buf;
+ for (n = memchr(buf, '\n', sz); n; n = memchr(prev, '\n', sz - (prev - buf)))
+ {
+ n[0] = 0;
+ if (num % 2 == 0)
+ eina_inarray_push(sel->links, &prev);
+ else
+ eina_inarray_push(sel->link_names, &prev);
+ num++;
+ prev = n + 1;
+ }
+ eina_inarray_push(sel->link_names, &prev[0]);
+
+ ECORE_XCB_SELECTION_DATA(sel)->length = size;
+ ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_X_MOZ_URL;
+ ECORE_XCB_SELECTION_DATA(sel)->data = (void*)data;
+ ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_xmozurl_free;
+ return sel;
+}
+
static void *
_ecore_xcb_selection_parser_files(const char *target,
void *data,
x_target = ECORE_X_ATOM_UTF8_STRING;
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_FILENAME))
x_target = ECORE_X_ATOM_FILE_NAME;
+ else if (!strcmp(target, ECORE_X_SELECTION_TARGET_X_MOZ_URL))
+ x_target = ECORE_X_ATOM_X_MOZ_URL;
else
x_target = ecore_x_atom_get(target);
return strdup(ECORE_X_SELECTION_TARGET_UTF8_STRING);
else if (target == ECORE_X_ATOM_TEXT)
return strdup(ECORE_X_SELECTION_TARGET_TEXT);
+ else if (target == ECORE_X_ATOM_X_MOZ_URL)
+ return strdup(ECORE_X_SELECTION_TARGET_X_MOZ_URL);
else
return ecore_x_atom_name_get(target);
}
void *data,
int size,
int format);
+static void *_ecore_x_selection_parser_xmozurl(const char *target,
+ void *data,
+ int size,
+ int format);
static int _ecore_x_selection_data_text_free(void *data);
static void *_ecore_x_selection_parser_targets(const char *target,
void *data,
_ecore_x_selection_parser_text);
ecore_x_selection_parser_add("text/uri-list",
_ecore_x_selection_parser_files);
+ ecore_x_selection_parser_add("text/x-moz-url",
+ _ecore_x_selection_parser_xmozurl);
ecore_x_selection_parser_add("_NETSCAPE_URL",
_ecore_x_selection_parser_files);
ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_TARGETS,
x_target = ECORE_X_ATOM_UTF8_STRING;
else if (!strcmp(target, ECORE_X_SELECTION_TARGET_FILENAME))
x_target = ECORE_X_ATOM_FILE_NAME;
+ else if (!strcmp(target, ECORE_X_SELECTION_TARGET_X_MOZ_URL))
+ x_target = ECORE_X_ATOM_X_MOZ_URL;
else
x_target = ecore_x_atom_get(target);
return strdup(ECORE_X_SELECTION_TARGET_UTF8_STRING);
else if (target == ECORE_X_ATOM_TEXT)
return strdup(ECORE_X_SELECTION_TARGET_TEXT);
+ else if (target == ECORE_X_ATOM_X_MOZ_URL)
+ return strdup(ECORE_X_SELECTION_TARGET_X_MOZ_URL);
else
return XGetAtomName(_ecore_x_disp, target);
}
return sel;
}
+static int
+_ecore_x_selection_data_xmozurl_free(void *data)
+{
+ Ecore_X_Selection_Data_X_Moz_Url *sel = data;
+ char **buf;
+
+ buf = eina_inarray_nth(sel->links, 0);
+ free(*buf);
+ eina_inarray_free(sel->links);
+ eina_inarray_free(sel->link_names);
+ free(sel);
+ return 1;
+}
+#ifdef HAVE_ICONV
+# include <errno.h>
+# include <iconv.h>
+#endif
+static void *
+_ecore_x_selection_parser_xmozurl(const char *target EINA_UNUSED,
+ void *_data,
+ int size,
+ int format EINA_UNUSED)
+{
+ Ecore_X_Selection_Data_X_Moz_Url *sel;
+ char *prev, *n, *buf, *data = _data;
+ size_t sz;
+ int num = 0;
+
+ buf = eina_str_convert_len("UTF-16LE", "UTF-8", data, size, &sz);
+ if (!buf) return NULL;
+ sel = calloc(1, sizeof(Ecore_X_Selection_Data_X_Moz_Url));
+ if (!sel)
+ {
+ free(buf);
+ return NULL;
+ }
+ sz = strlen(buf);
+ sel->links = eina_inarray_new(sizeof(char*), 0);
+ sel->link_names = eina_inarray_new(sizeof(char*), 0);
+ prev = buf;
+ for (n = memchr(buf, '\n', sz); n; n = memchr(prev, '\n', sz - (prev - buf)))
+ {
+ n[0] = 0;
+ if (num % 2 == 0)
+ eina_inarray_push(sel->links, &prev);
+ else
+ eina_inarray_push(sel->link_names, &prev);
+ num++;
+ prev = n + 1;
+ }
+ eina_inarray_push(sel->link_names, &prev);
+
+ ECORE_X_SELECTION_DATA(sel)->length = size;
+ ECORE_X_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_X_MOZ_URL;
+ ECORE_X_SELECTION_DATA(sel)->data = (void*)data;
+ ECORE_X_SELECTION_DATA(sel)->free = _ecore_x_selection_data_xmozurl_free;
+ return sel;
+}
+
static int
_ecore_x_selection_data_text_free(void *data)
{