From: Foxe Chen Date: Fri, 16 Jan 2026 18:36:31 +0000 (+0000) Subject: patch 9.1.2089: Wayland: Clipboard not working with external programs X-Git-Tag: v9.1.2089^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b8f10d3d818bae31b17e456ed578d2188140196;p=thirdparty%2Fvim.git patch 9.1.2089: Wayland: Clipboard not working with external programs Problem: Wayland: Clipboard not working with external programs on Wayland (devsnek) Solution: Simplify the Wayland offer logic and drop offering the special mime type (Foxe Chen) fixes: #19050 closes: #19184 Signed-off-by: Foxe Chen Signed-off-by: Christian Brabandt --- diff --git a/src/clipboard.c b/src/clipboard.c index 2471158ea1..8cf62cf88b 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -2676,7 +2676,7 @@ vwl_data_device_listener_event_selection( // There are two cases when sel->offer is NULL // 1. No one owns the selection // 2. We own the selection (we'll just access the register directly) - if (offer == NULL || offer->from_vim) + if (offer == NULL || sel->source != NULL) { // Selection event is from us, so we are the source client. Therefore // ignore it. Or the selection is cleared, so set sel->offer to NULL @@ -3233,7 +3233,6 @@ clip_wl_own_selection(Clipboard_T *cbd) vwl_data_source_add_listener(sel->source, &vwl_data_source_listener, sel); // Advertise mime types - vwl_data_source_offer(sel->source, wayland_vim_special_mime); for (int i = 0; i < (int)ARRAY_LENGTH(supported_mimes); i++) vwl_data_source_offer(sel->source, supported_mimes[i]); diff --git a/src/globals.h b/src/globals.h index c534bfc659..5e96304cc3 100644 --- a/src/globals.h +++ b/src/globals.h @@ -2088,15 +2088,6 @@ EXTERN clipmethod_T clipmethod INIT(= CLIPMETHOD_NONE); // Wayland display name for global connection (ex. wayland-0). Can be NULL EXTERN char *wayland_display_name INIT(= NULL); -// Special mime type used to identify selection events that came from us setting -// the selection. Is in format of "application/x-vim-instance-" where -// is the PID of the Vim process. Set in main.c -// -// This is more reliable than just checking if our data source is non-NULL, as -// that may be subject to data races in the Wayland protocol. -EXTERN char wayland_vim_special_mime[ - sizeof("application/x-vim-instance-") + NUMBUFLEN - 1]; // Includes NUL - // Don't connect to Wayland compositor if TRUE EXTERN int wayland_no_connect INIT(= FALSE); diff --git a/src/main.c b/src/main.c index bf68879ed0..5ae94e43e0 100644 --- a/src/main.c +++ b/src/main.c @@ -689,9 +689,6 @@ vim_main2(void) if (!gui.in_use) # endif { - sprintf(wayland_vim_special_mime, "application/x-vim-instance-%ld", - mch_get_pid()); - if (wayland_init_connection(wayland_display_name) == OK) { TIME_MSG("connected to Wayland display"); diff --git a/src/version.c b/src/version.c index 00c2988f99..157cab82cf 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2089, /**/ 2088, /**/ diff --git a/src/wayland.c b/src/wayland.c index 59694b400d..4db13c4c07 100644 --- a/src/wayland.c +++ b/src/wayland.c @@ -1268,10 +1268,7 @@ static const struct zwp_primary_selection_source_v1_listener const char *mime_type) \ { \ vwl_data_offer_T *self = data; \ - if (STRCMP(mime_type, wayland_vim_special_mime) == 0) \ - self->from_vim = true; \ - else if (!self->from_vim && \ - self->listener->offer(self->data, self, mime_type)) \ + if (self->listener->offer(self->data, self, mime_type)) \ { \ char *mime = (char *)vim_strsave((char_u *)mime_type); \ if (ga_grow(&self->mime_types, 1) == FAIL) \ diff --git a/src/wayland.h b/src/wayland.h index f83502febd..80eb52cc33 100644 --- a/src/wayland.h +++ b/src/wayland.h @@ -124,8 +124,6 @@ struct vwl_data_offer_S { void *data; // Should be same as parent data // device. garray_T mime_types; - bool from_vim; // If offer came from us setting the - // selection. const vwl_data_offer_listener_T *listener; vwl_data_protocol_T protocol;