|
| 1 | +*wayland.txt* For Vim version 9.1. Last change: 2025 Jun 28 |
| 2 | + |
| 3 | + |
| 4 | + VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | + |
| 6 | + |
| 7 | +Wayland Protocol Support *wayland* |
| 8 | + |
| 9 | +1. Useful Wayland information |wayland-useful| |
| 10 | +2. Wayland selections |wayland-selections| |
| 11 | + |
| 12 | +============================================================================== |
| 13 | +1. Useful Wayland information *wayland-useful* |
| 14 | + |
| 15 | + *wayland-seat* |
| 16 | +Functionality such as the clipboard for Wayland requires a seat to use. A |
| 17 | +Wayland seat can consist of a keyboard, pointer, and touch device(s). The |
| 18 | +seat to use can be set with the 'wlseat' option. Only useful if you use |
| 19 | +multiple Wayland seats in the same Wayland session. |
| 20 | + |
| 21 | + *wayland-gui* |
| 22 | +See |gui-wayland|. Please note that when using the GUI, Vim uses the toolkit |
| 23 | +such as GTK for accessing the clipboard, and does not access the clipboard |
| 24 | +though Wayland. You can check this though the |v:clipmethod| variable, which |
| 25 | +should equal to "none" when running the GUI. |
| 26 | + |
| 27 | +Wayland commands: |
| 28 | + *:wlrestore* *:wl* |
| 29 | +:wl[restore] [display] Reinitializes the connection to the Wayland compositor. |
| 30 | + Useful when running Vim in a screen/tmux session that |
| 31 | + continues running after the Wayland compositor |
| 32 | + restarts. |
| 33 | + |
| 34 | + [display] should be in the format of the |
| 35 | + $WAYLAND_DISPLAY environment variable (e.g. |
| 36 | + "wayland-0"). If [display] is omitted, then it |
| 37 | + reinitializes the connection using the same value as |
| 38 | + was used for the previous execution of this command. |
| 39 | + If the value was never specified, then it uses the |
| 40 | + value of $WAYLAND_DISPLAY environment variable. This |
| 41 | + will also update |v:clipmethod|. |
| 42 | + {only available when compiled with the |+wayland| |
| 43 | + feature} |
| 44 | + |
| 45 | +Wayland errors: |
| 46 | + *E1548* |
| 47 | +Vim failed communicating with the Wayland compositor. This is likely due to |
| 48 | +the Wayland compositor process being killed. Try the `:wlrestore` command to |
| 49 | +try connecting again. |
| 50 | + |
| 51 | +============================================================================== |
| 52 | +2. Wayland Selections *wayland-selections* |
| 53 | + |
| 54 | +Vim supports the wlr-data-control-unstable-v1 and ext-data-control-v1 |
| 55 | +protocols, for accessing the current Wayland selection. These are the best |
| 56 | +case scenario protocols, see |wayland-focus-steal|. Selection in this case |
| 57 | +essentially means the "clipboard." You can check if your Wayland compositor |
| 58 | +supports either of these protocols by running the wayland-info command, which |
| 59 | +should be bunded with libwayland on your system: > |
| 60 | + wayland-info | grep -E '(ext_data_control|zwlr_data_control)' |
| 61 | +<If grep finds a match, then you have either or both protocols on your system. |
| 62 | +If you don't get any match, then please see |wayland-focus-steal| for more |
| 63 | +information. |
| 64 | + |
| 65 | +If you come from X11, then the regular Wayland selection is equivalent to the |
| 66 | +CLIPBOARD selection in X11, and the primary Wayland selection equates to the |
| 67 | +X11 primary selection. Accessing these selections is the same as X11 in Vim, |
| 68 | +in which the + register is the regular selection, and the * register is the |
| 69 | +primary selection, note that your compositor may not support primary |
| 70 | +selections, see |wayland-primary-selection| for more details. |
| 71 | + |
| 72 | + *wayland-persist* |
| 73 | +If you use X11 cut buffers, no such things exist on Wayland. Instead to |
| 74 | +emulate such functionality, a separate clipboard manager must be used in order |
| 75 | +to persist selection data when a Wayland client exists. |
| 76 | + |
| 77 | + *wayland-and-x11* |
| 78 | +If your version of Vim comes compiled with both X11 and Wayland support, then |
| 79 | +Vim determines which one to use when accessing the clipboard using the |
| 80 | +'clipmethod' option. |
| 81 | + |
| 82 | + *wayland-primary-selection* |
| 83 | +If you find X11 style primary selections useful, Wayland also implements this |
| 84 | +behaviour in its own protocols: |
| 85 | + |
| 86 | +- The primary selection protocol is the most widely supported, but requires |
| 87 | + focus in order to be used, see |wayland-focus-steal|. |
| 88 | + |
| 89 | +- Data control protocol available on your system, such as the ext or wlr |
| 90 | + protocols, then primary selection is also supported. This is unless you are |
| 91 | + using version 1 (not the same as the 'v1' in the protocol name), of the |
| 92 | + wlr-data-control protocol. Then the primary selection protocol will be used |
| 93 | + as a fallback. |
| 94 | + |
| 95 | + *wayland-focus-steal* *wayland-gnome* |
| 96 | +If you are using the GNOME desktop environment on Wayland, as of this writing, |
| 97 | +there is no method of accessing/modifying the clipboard for external clients |
| 98 | +such as Vim without being focused. Focused in this case means the client has |
| 99 | +received some sort of input event, such as a window being focused. This is |
| 100 | +what the wlr-data-control-unstable-v1 and ext-data-control-v1 protocols solve. |
| 101 | +If your Wayland compositor does not support the above protocols, then the |
| 102 | +above explanation applies. |
| 103 | + |
| 104 | +To solve this problem, Vim implements a way of gaining focus in order to |
| 105 | +access the clipboard, by creating a temporary transparent top-level surface. |
| 106 | +This is by default disabled and can be enabled via the 'wlsteal' option. |
| 107 | +Moreover, a seat that has a keyboard is also required, see 'wlseat', and the |
| 108 | +xdg-shell protocol must be available. |
| 109 | + |
| 110 | +Note that this method can have several side effects from the result of focus |
| 111 | +stealing. For example, if you have a taskbar that shows currently opened apps |
| 112 | +in your desktop environment, then when Vim attempts to steal focus, it may |
| 113 | +"flicker," as if a window was opened then immediately closed after. |
| 114 | +Additionally, if you are in fullscreen mode, this focus stealing won't work, |
| 115 | +because the created surface won't ever gain focus. If this happens, Vim will |
| 116 | +seem to freeze temporarily, see 'wltimeoutlen' for more information. |
| 117 | + |
| 118 | + vim:tw=78:ts=8:noet:ft=help:norl |
0 commit comments