diff options
Diffstat (limited to 'input')
-rw-r--r-- | input/event.c | 12 | ||||
-rw-r--r-- | input/event.h | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/input/event.c b/input/event.c index f765342518..a15bc11919 100644 --- a/input/event.c +++ b/input/event.c @@ -56,8 +56,8 @@ 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, enum mp_dnd_action action) { - // X11 and Wayland file list format. - if (strcmp(mime_type, "text/uri-list") == 0) { + // (text lists are the only format supported right now) + if (mp_event_get_mime_type_score(ictx, mime_type) >= 0) { void *tmp = talloc_new(NULL); int num_files = 0; char **files = NULL; @@ -76,3 +76,11 @@ int mp_event_drop_mime_data(struct input_ctx *ictx, const char *mime_type, return -1; } } + +int mp_event_get_mime_type_score(struct input_ctx *ictx, const char *mime_type) +{ + // X11 and Wayland file list format. + if (strcmp(mime_type, "text/uri-list") == 0) + return 10; + return -1; +} diff --git a/input/event.h b/input/event.h index 3a06ce1d1d..cf8e35ac8d 100644 --- a/input/event.h +++ b/input/event.h @@ -32,3 +32,8 @@ void mp_event_drop_files(struct input_ctx *ictx, int num_files, char **files, // Returns <0 on error, ==0 if data was ok but empty, >0 on success. int mp_event_drop_mime_data(struct input_ctx *ictx, const char *mime_type, bstr data, enum mp_dnd_action append); + +// Many drag & drop APIs support multiple mime types, and this function returns +// whether a type is preferred (higher integer score), or supported (scores +// below 0 indicate unsupported types). +int mp_event_get_mime_type_score(struct input_ctx *ictx, const char *mime_type); |