mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Cleanup sending/receiving mimetype atoms
This commit is contained in:
13
glfw/x11_window.c
vendored
13
glfw/x11_window.c
vendored
@@ -793,7 +793,7 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
|||||||
32,
|
32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
(unsigned char*) targets,
|
(unsigned char*) targets,
|
||||||
aa->sz + 2);
|
sizeof(targets[0]) * (aa->sz + 2));
|
||||||
free(targets);
|
free(targets);
|
||||||
return request->property;
|
return request->property;
|
||||||
}
|
}
|
||||||
@@ -2901,6 +2901,11 @@ void _glfwPlatformSetClipboard(GLFWClipboardType t) {
|
|||||||
for (size_t i = 0; i < cd->num_mime_types; i++) {
|
for (size_t i = 0; i < cd->num_mime_types; i++) {
|
||||||
MimeAtom *a = aa->array + aa->sz++;
|
MimeAtom *a = aa->array + aa->sz++;
|
||||||
*a = atom_for_mime(cd->mime_types[i]);
|
*a = atom_for_mime(cd->mime_types[i]);
|
||||||
|
if (strcmp(cd->mime_types[i], "text/plain") == 0) {
|
||||||
|
a = aa->array + aa->sz++;
|
||||||
|
a->atom = _glfw.x11.UTF8_STRING;
|
||||||
|
a->mime = "text/plain";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2932,10 +2937,12 @@ get_available_mime_types(Atom which_clipboard, GLFWclipboardwritedatafun write_d
|
|||||||
char **names = calloc(count, sizeof(char*));
|
char **names = calloc(count, sizeof(char*));
|
||||||
get_atom_names(atoms, count, names);
|
get_atom_names(atoms, count, names);
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
if (atoms[i] != _glfw.x11.UTF8_STRING && atoms[i] != XA_STRING) {
|
if (strchr(names[i], '/')) {
|
||||||
if (ok) ok = write_data(object, names[i], strlen(names[i]));
|
if (ok) ok = write_data(object, names[i], strlen(names[i]));
|
||||||
} else {
|
} else {
|
||||||
ok = write_data(object, "text/plain", strlen("text/plain"));
|
if (atoms[i] == _glfw.x11.UTF8_STRING || atoms[i] == XA_STRING) {
|
||||||
|
if (ok) ok = write_data(object, "text/plain", strlen("text/plain"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
XFree(names[i]);
|
XFree(names[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user