diff options
author | wm4 <wm4@nowhere> | 2014-01-04 19:32:09 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-01-04 19:33:40 +0100 |
commit | 7c6bb321eb0542c474e5147558fb71ecf2d44bd4 (patch) | |
tree | 82a8d90b9bbc0f33b390d95ca78d5d0a24c64405 /input/event.c | |
parent | 6534839154b9644a0019baf155f9bda542aa6e75 (diff) | |
download | mpv-7c6bb321eb0542c474e5147558fb71ecf2d44bd4.tar.bz2 mpv-7c6bb321eb0542c474e5147558fb71ecf2d44bd4.tar.xz |
video/out: remove some code duplication between X11 and wayland
Both X11 and Wayland support the same format for drag & drop operations
(text/uri-list), and the code for that was copied from x11_common.c to
wayland_common.c. Factor it out.
Diffstat (limited to 'input/event.c')
-rw-r--r-- | input/event.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/input/event.c b/input/event.c index 20ef80d36a..e2d488b5ca 100644 --- a/input/event.c +++ b/input/event.c @@ -48,3 +48,27 @@ void mp_event_drop_files(struct input_ctx *ictx, int num_files, char **files) } } } + +int mp_event_drop_mime_data(struct input_ctx *ictx, const char *mime_type, + bstr data) +{ + // X11 and Wayland file list format. + if (strcmp(mime_type, "text/uri-list") == 0) { + void *tmp = talloc_new(NULL); + int num_files = 0; + char **files = NULL; + while (data.len) { + bstr line = bstr_getline(data, &data); + line = bstr_strip_linebreaks(line); + if (bstr_startswith0(line, "#")) + continue; + char *s = bstrto0(tmp, line); + MP_TARRAY_APPEND(tmp, files, num_files, s); + } + mp_event_drop_files(ictx, num_files, files); + talloc_free(tmp); + return num_files > 0; + } else { + return -1; + } +} |