From 3e9491dbea1bd3d97760b20ca725f6a9932e3fca Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 15 Aug 2026 20:43:56 +1000 Subject: [PATCH] [client] wayland: fix MATE clipboard MIME handling Treat either GNOME or MATE copied-files data as preferred over the URI list fallback. The previous pair of strcmp conditions could never both be false, so a MATE offer could not replace an earlier URI list. GNOME and MATE use the same copied-files representation. Generate that payload once and serve it under both advertised MIME names instead of overwriting and leaking the first allocation. --- client/displayservers/Wayland/clipboard.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/displayservers/Wayland/clipboard.c b/client/displayservers/Wayland/clipboard.c index c22b97b8..46079c36 100644 --- a/client/displayservers/Wayland/clipboard.c +++ b/client/displayservers/Wayland/clipboard.c @@ -435,11 +435,14 @@ static void dataOfferHandleOffer(void * opaque, struct wl_data_offer * offer, if (data->mimetypes[type]) { - if (type != LG_CLIPBOARD_DATA_FILES || - strcmp(mimetype, "x-special/gnome-copied-files") || - strcmp(mimetype, "x-special/mate-copied-files") || - !strcmp(data->mimetypes[type], "x-special/gnome-copied-files") || - !strcmp(data->mimetypes[type], "x-special/mate-copied-files")) + const bool preferredFileMime = + !strcmp(mimetype, "x-special/gnome-copied-files") || + !strcmp(mimetype, "x-special/mate-copied-files" ); + const bool currentPreferredFileMime = + !strcmp(data->mimetypes[type], "x-special/gnome-copied-files") || + !strcmp(data->mimetypes[type], "x-special/mate-copied-files" ); + if (type != LG_CLIPBOARD_DATA_FILES || !preferredFileMime || + currentPreferredFileMime) return; free(data->mimetypes[type]); } @@ -1546,9 +1549,6 @@ static bool waylandCBPublish(LG_ClipboardData type) !clipboardFiles_getRemotePresentation(transfer->filePresentation, "x-special/gnome-copied-files", &transfer->fileGnome, &transfer->fileGnomeSize) || - !clipboardFiles_getRemotePresentation(transfer->filePresentation, - "x-special/mate-copied-files", - &transfer->fileGnome, &transfer->fileGnomeSize) || !clipboardFiles_getRemotePresentation(transfer->filePresentation, "application/x-kde-cutselection", &transfer->fileKde, &transfer->fileKdeSize)))