aboutsummaryrefslogtreecommitdiffhomepage
path: root/input/event.c
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2016-03-15 22:42:06 +0100
committerGravatar wm4 <wm4@nowhere>2016-03-15 22:42:06 +0100
commit7e75e2a5dc1719326ec46265d67205336b975eec (patch)
treea53568d7e9c648a6f5b4c238c348bee22cf77e53 /input/event.c
parent718cc27f34bd0bbaa155cb61e11179dba31cbd33 (diff)
x11, input: move mime type drag&drop negotiation to common code
Drag&drop mechanisms typically support multiple types for the drop data. Move most of the logic which types are accepted and preferred to event.c, where the data is also interpreted. (Maybe sorting the types by assigning scores is over-engineered, since they're already sorted by preference, but it's actually not much more code.) Not very interesting/meaningful yet, but preparation for the next commit.
Diffstat (limited to 'input/event.c')
-rw-r--r--input/event.c12
1 files changed, 10 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;
+}