From 0d30b22a3e3aa571b79aa5b1f7de0ec30cc10d66 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 31 Jan 2024 09:49:45 +0100 Subject: [PATCH] [client,wayland] add alternate bitmap mime types add alternate bitmap mime types to clipboard --- client/Wayland/wlf_cliprdr.c | 37 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/client/Wayland/wlf_cliprdr.c b/client/Wayland/wlf_cliprdr.c index dbd1413cf..3f0ced89c 100644 --- a/client/Wayland/wlf_cliprdr.c +++ b/client/Wayland/wlf_cliprdr.c @@ -46,16 +46,16 @@ static const char* mime_text[] = { mime_text_plain, mime_text_utf8, "UTF8_STRING", "COMPOUND_TEXT", "TEXT", "STRING" }; -static const char* mime_image[] = { - "image/png", "image/bmp", "image/x-bmp", "image/x-MS-bmp", - "image/x-icon", "image/x-ico", "image/x-win-bitmap", "image/vmd.microsoft.icon", - "application/ico", "image/ico", "image/icon", "image/jpeg", - "image/gif", "image/tiff" -}; - +static const char mime_png[] = "image/png"; +static const char mime_webp[] = "image/webp"; +static const char mime_jpg[] = "image/jpeg"; +static const char mime_tiff[] = "image/tiff"; static const char mime_uri_list[] = "text/uri-list"; static const char mime_html[] = "text/html"; -static const char mime_bmp[] = "image/bmp"; + +#define BMP_MIME_LIST "image/bmp", "image/x-bmp", "image/x-MS-bmp", "image/x-win-bitmap" +static const char* mime_bitmap[] = { BMP_MIME_LIST }; +static const char* mime_image[] = { mime_png, mime_webp, mime_jpg, mime_tiff, BMP_MIME_LIST }; static const char mime_gnome_copied_files[] = "x-special/gnome-copied-files"; static const char mime_mate_copied_files[] = "x-special/mate-copied-files"; @@ -287,9 +287,15 @@ static BOOL wlf_cliprdr_add_client_format(wfClipboard* clipboard, const char* mi } else if (wlf_mime_is_image(mime)) { - UINT32 formatId = ClipboardGetFormatId(clipboard->system, mime_bmp); - wfl_cliprdr_add_client_format_id(clipboard, formatId); + for (size_t x = 0; x < ARRAYSIZE(mime_image); x++) + { + const char* mime_bmp = mime_image[x]; + UINT32 formatId = ClipboardGetFormatId(clipboard->system, mime_bmp); + if (formatId != 0) + wfl_cliprdr_add_client_format_id(clipboard, formatId); + } wfl_cliprdr_add_client_format_id(clipboard, CF_DIB); + wfl_cliprdr_add_client_format_id(clipboard, CF_TIFF); } else if (wlf_mime_is_file(mime)) { @@ -539,7 +545,10 @@ static void wlf_cliprdr_transfer_data(UwacSeat* seat, void* context, const char* else if (wlf_mime_is_image(mime)) { request.responseMime = mime; - request.responseFormat = CF_DIB; + if (strcmp(mime, mime_tiff) == 0) + request.responseFormat = CF_TIFF; + else + request.responseFormat = CF_DIB; } if (request.responseMime != NULL) @@ -749,7 +758,11 @@ wlf_cliprdr_server_format_data_request(CliprdrClientContext* context, case CF_DIB: case CF_DIBV5: - mime = mime_bmp; + mime = mime_bitmap[0]; + break; + + case CF_TIFF: + mime = mime_tiff; break; default: