Wayland: Apparently Java doesnt even set text/plain as a mimetype when copying text. Instead it uses UTF8_STRING and STRING.
So check for those as well. Am guessing whoever wrote this code in Java just copied their old X11 shit without checking the specs. See #4183
This commit is contained in:
parent
68ad513dd5
commit
6da5a8073c
2
glfw/wl_platform.h
vendored
2
glfw/wl_platform.h
vendored
@ -230,7 +230,7 @@ typedef struct _GLFWWaylandDataOffer
|
|||||||
size_t idx;
|
size_t idx;
|
||||||
bool is_self_offer;
|
bool is_self_offer;
|
||||||
bool is_primary;
|
bool is_primary;
|
||||||
const char *plain_text_mime, *mime_for_drop;
|
const char *mime_for_drop;
|
||||||
uint32_t source_actions;
|
uint32_t source_actions;
|
||||||
uint32_t dnd_action;
|
uint32_t dnd_action;
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
|
|||||||
50
glfw/wl_window.c
vendored
50
glfw/wl_window.c
vendored
@ -1561,11 +1561,6 @@ static void mark_primary_selection_offer(void *data UNUSED, struct zwp_primary_s
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
set_offer_mimetype(_GLFWWaylandDataOffer* offer, const char* mime) {
|
set_offer_mimetype(_GLFWWaylandDataOffer* offer, const char* mime) {
|
||||||
if (strcmp(mime, "text/plain;charset=utf-8") == 0) {
|
|
||||||
offer->plain_text_mime = "text/plain;charset=utf-8";
|
|
||||||
} else if (!offer->plain_text_mime && strcmp(mime, "text/plain") == 0) {
|
|
||||||
offer->plain_text_mime = "text/plain";
|
|
||||||
}
|
|
||||||
if (strcmp(mime, clipboard_mime()) == 0) {
|
if (strcmp(mime, clipboard_mime()) == 0) {
|
||||||
offer->is_self_offer = true;
|
offer->is_self_offer = true;
|
||||||
}
|
}
|
||||||
@ -1814,16 +1809,38 @@ void _glfwPlatformSetClipboardString(const char* string)
|
|||||||
wl_callback_add_listener(callback, &clipboard_copy_callback_listener, _glfw.wl.dataSourceForClipboard);
|
wl_callback_add_listener(callback, &clipboard_copy_callback_listener, _glfw.wl.dataSourceForClipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
offer_has_mime(const _GLFWWaylandDataOffer *d, const char *mime) {
|
||||||
|
for (unsigned i = 0; i < d->mimes_count; i++) {
|
||||||
|
if (strcmp(d->mimes[i], mime) == 0) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char*
|
||||||
|
plain_text_mime_for_offer(const _GLFWWaylandDataOffer *d) {
|
||||||
|
#define A(x) if (offer_has_mime(d, x)) return x;
|
||||||
|
A("text/plain;charset=utf-8");
|
||||||
|
A("text/plain");
|
||||||
|
A("UTF8_STRING");
|
||||||
|
A("STRING");
|
||||||
|
#undef A
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetClipboardString(void)
|
const char* _glfwPlatformGetClipboardString(void)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
|
for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
|
||||||
_GLFWWaylandDataOffer *d = _glfw.wl.dataOffers + i;
|
_GLFWWaylandDataOffer *d = _glfw.wl.dataOffers + i;
|
||||||
if (d->id && d->offer_type == CLIPBOARD && d->plain_text_mime) {
|
if (d->id && d->offer_type == CLIPBOARD) {
|
||||||
if (d->is_self_offer) return _glfw.wl.clipboardString;
|
if (d->is_self_offer) return _glfw.wl.clipboardString;
|
||||||
free(_glfw.wl.pasteString);
|
const char *mime = plain_text_mime_for_offer(d);
|
||||||
size_t sz = 0;
|
if (mime) {
|
||||||
_glfw.wl.pasteString = read_data_offer(d->id, d->plain_text_mime, &sz);
|
free(_glfw.wl.pasteString);
|
||||||
return _glfw.wl.pasteString;
|
size_t sz = 0;
|
||||||
|
_glfw.wl.pasteString = read_data_offer(d->id, mime, &sz);
|
||||||
|
return _glfw.wl.pasteString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1871,13 +1888,14 @@ const char* _glfwPlatformGetPrimarySelectionString(void)
|
|||||||
|
|
||||||
for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
|
for (size_t i = 0; i < arraysz(_glfw.wl.dataOffers); i++) {
|
||||||
_GLFWWaylandDataOffer *d = _glfw.wl.dataOffers + i;
|
_GLFWWaylandDataOffer *d = _glfw.wl.dataOffers + i;
|
||||||
if (d->id && d->is_primary && d->offer_type == PRIMARY_SELECTION && d->plain_text_mime) {
|
if (d->id && d->is_primary && d->offer_type == PRIMARY_SELECTION) {
|
||||||
if (d->is_self_offer) {
|
if (d->is_self_offer) return _glfw.wl.primarySelectionString;
|
||||||
return _glfw.wl.primarySelectionString;
|
const char *mime = plain_text_mime_for_offer(d);
|
||||||
|
if (mime) {
|
||||||
|
free(_glfw.wl.pasteString);
|
||||||
|
_glfw.wl.pasteString = read_primary_selection_offer(d->id, mime);
|
||||||
|
return _glfw.wl.pasteString;
|
||||||
}
|
}
|
||||||
free(_glfw.wl.pasteString);
|
|
||||||
_glfw.wl.pasteString = read_primary_selection_offer(d->id, d->plain_text_mime);
|
|
||||||
return _glfw.wl.pasteString;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user