patch 9.1.1543: Wayland: clipboard appears to not be working
Commit:
https://github.com/vim/vim/commit/d0bf380efa4ab0aabc5479274043f0de1115a232
Author: Foxe Chen <[email protected]>
Date: Mon Jul 14 21:54:23 2025 +0200
patch 9.1.1543: Wayland: clipboard appears to not be working
Problem: Wayland: clipboard appears to not be working
(Fuad Veliev)
Solution: Explicitly set selection each time (Foxe Chen)
fixes: #17732
closes: #17740
Signed-off-by: Foxe Chen <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/version.c b/src/version.c
index e14de81a4..634bf58b4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1543,
/**/
1542,
/**/
diff --git a/src/wayland.c b/src/wayland.c
index 3fef423eb..f9af42d71 100644
--- a/src/wayland.c
+++ b/src/wayland.c
@@ -2098,7 +2098,7 @@ vwl_data_device_listener_finished(vwl_data_device_T
*device)
{
vwl_clipboard_selection_T *clip_sel = device->data;
- vwl_data_device_destroy(device, FALSE);
+ vwl_data_device_destroy(&clip_sel->device, FALSE);
vwl_data_offer_destroy(clip_sel->offer, TRUE);
vwl_data_source_destroy(&clip_sel->source, FALSE);
vwl_clipboard_free_mime_types(clip_sel);
@@ -2246,8 +2246,39 @@ wayland_cb_own_selection(
return FAIL;
if (clip_sel->source.proxy != NULL)
- // We already own the selection
- return OK;
+ {
+ if (selection == WAYLAND_SELECTION_PRIMARY)
+ // We already own the selection, ignore (only do this for primary
+ // selection). We don't re set the selection because then we would
+ // be setting the selection every time the user moves the visual
+ // selection cursor, which is messy and inefficient.
+ //
+ // Vim doesn't have a mechanism to only set the selection
+ // when the user stops selecting (such as the user releasing the
+ // mouse button in graphical Wayland applications). So this
+ // behaviour in Vim differs from other Wayland applications.
+ return OK;
+ else if (selection == WAYLAND_SELECTION_REGULAR)
+ {
+ // Technically we don't need to do this as we already own the
+ // selection, however if a user yanks text a second time, the
+ // text yanked won't appear in their clipboard manager if they are
+ // using one.
+ //
+ // This can be unexpected behaviour for the user so its probably
+ // better to do it this way. Additionally other Wayland applications
+ // seem to set the selection every time.
+ //
+ // There should be no noticable performance change since its not
+ // like this is running in the background constantly in Vim, only
+ // runs once when the user yanks text to the system clipboard.
+ vwl_data_source_destroy(&clip_sel->source, FALSE);
+ vwl_display_flush(&vwl_display);
+ }
+ else
+ // Shouldn't happen
+ return FAIL;
+ }
if (!wayland_client_is_connected(FALSE) ||
!vwl_clipboard_selection_is_ready(clip_sel))
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1ubPLJ-005jjp-SL%40256bit.org.