x11: Look for text/uri-list in the list of MIME types more thoroughly
A uri-list of files is the preferred format, so don't bail if a preferred text format is encountered first.
This commit is contained in:
@@ -122,15 +122,19 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop)
|
|||||||
if available, else return None */
|
if available, else return None */
|
||||||
static Atom X11_PickTarget(Display *disp, Atom list[], int list_count)
|
static Atom X11_PickTarget(Display *disp, Atom list[], int list_count)
|
||||||
{
|
{
|
||||||
|
const Atom text_uri_request = X11_XInternAtom(disp, "text/uri-list", False);
|
||||||
Atom request = None;
|
Atom request = None;
|
||||||
char *name;
|
Atom preferred = None;
|
||||||
int i;
|
|
||||||
for (i = 0; i < list_count && request == None; i++) {
|
for (int i = 0; i < list_count && request != text_uri_request; i++) {
|
||||||
name = X11_XGetAtomName(disp, list[i]);
|
char *name = X11_XGetAtomName(disp, list[i]);
|
||||||
// Preferred MIME targets
|
// Preferred MIME targets
|
||||||
if ((SDL_strcmp("text/uri-list", name) == 0) ||
|
if ((SDL_strcmp("text/uri-list", name) == 0) ||
|
||||||
(SDL_strcmp("text/plain;charset=utf-8", name) == 0) ||
|
(SDL_strcmp("text/plain;charset=utf-8", name) == 0) ||
|
||||||
(SDL_strcmp("UTF8_STRING", name) == 0)) {
|
(SDL_strcmp("UTF8_STRING", name) == 0)) {
|
||||||
|
if (preferred == None) {
|
||||||
|
preferred = list[i];
|
||||||
|
}
|
||||||
request = list[i];
|
request = list[i];
|
||||||
}
|
}
|
||||||
// Fallback MIME targets
|
// Fallback MIME targets
|
||||||
@@ -142,6 +146,11 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count)
|
|||||||
}
|
}
|
||||||
X11_XFree(name);
|
X11_XFree(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The type 'text/uri-list' is preferred over all others.
|
||||||
|
if (preferred != None && request != text_uri_request) {
|
||||||
|
request = preferred;
|
||||||
|
}
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user