Commit: patch 9.1.2089: Wayland: Clipboard not working with external programs

0 views
Skip to first unread message

Christian Brabandt

unread,
2:01 PM (10 hours ago) 2:01 PM
to vim...@googlegroups.com
patch 9.1.2089: Wayland: Clipboard not working with external programs

Commit: https://github.com/vim/vim/commit/8b8f10d3d818bae31b17e456ed578d2188140196
Author: Foxe Chen <chen...@gmail.com>
Date: Fri Jan 16 18:36:31 2026 +0000

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 <chen...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/clipboard.c b/src/clipboard.c
index 2471158ea..8cf62cf88 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 c534bfc65..5e96304cc 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-<pid>" where <pid>
-// 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 bf68879ed..5ae94e43e 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 00c2988f9..157cab82c 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 59694b400..4db13c4c0 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 f83502feb..80eb52cc3 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;
Reply all
Reply to author
Forward
0 new messages