[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.
This commit is contained in:
Geoffrey McRae
2026-08-15 20:43:56 +10:00
parent 52d9ab10a0
commit 3e9491dbea

View File

@@ -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") ||
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"))
!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)))