]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2089: Wayland: Clipboard not working with external programs v9.1.2089
authorFoxe Chen <chen.foxe@gmail.com>
Fri, 16 Jan 2026 18:36:31 +0000 (18:36 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 16 Jan 2026 18:36:31 +0000 (18:36 +0000)
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.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/clipboard.c
src/globals.h
src/main.c
src/version.c
src/wayland.c
src/wayland.h

index 2471158ea119de1585ff222403aabdc1b95f596a..8cf62cf88b5217caa262aae4bc39fb27a1c70454 100644 (file)
@@ -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]);
 
index c534bfc659016fb387e3006270c943cf7f9b6e47..5e96304cc3f54693001b6d7abe206c6f34cfe90e 100644 (file)
@@ -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);
 
index bf68879ed0a7f1bc3c037d9e57ff490244875863..5ae94e43e0d35b851761edc273fb491107b60ca7 100644 (file)
@@ -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");
index 00c2988f990b8a04212abf71f66b05eacca0d2c5..157cab82cf74463163ebcf44919b33b8ac501c5b 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2089,
 /**/
     2088,
 /**/
index 59694b400d8c6f827fa48ca444b65b245edc625a..4db13c4c0781cd6f530f733b21757c5c4860b72a 100644 (file)
@@ -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) \
index f83502febd87d8bdce834b6ea6c0ec71f6052a3a..80eb52cc33589afb148698a690dfea0c0ddceaa5 100644 (file)
@@ -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;