Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 1 | *wayland.txt* For Vim version 9.1. Last change: 2025 Jun 28 |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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 |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 18 | seat to use can be set with the 'wlseat' option. Only useful if you use |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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* |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 29 | :wl[restore] [display] Reinitializes the connection to the Wayland compositor. |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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. |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 36 | "wayland-0"). If [display] is omitted, then it |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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|. |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 42 | {only available when compiled with the |+wayland| |
| 43 | feature} |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 44 | |
| 45 | Wayland errors: |
| 46 | *E1548* |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 47 | Vim failed communicating with the Wayland compositor. This is likely due to |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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 | |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 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 |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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* |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 73 | If you use X11 cut buffers, no such things exist on Wayland. Instead to |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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 | |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 82 | *wayland-primary-selection* |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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 |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 92 | wlr-data-control protocol. Then the primary selection protocol will be used |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 93 | as a fallback. |
| 94 | |
Hirohito Higashi | 73b9650 | 2025-06-28 18:18:21 +0200 | [diff] [blame] | 95 | *wayland-focus-steal* *wayland-gnome* |
Foxe Chen | b90c239 | 2025-06-27 21:10:35 +0200 | [diff] [blame] | 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 | |
Hirohito Higashi | b657310 | 2025-06-28 18:34:48 +0200 | [diff] [blame] | 118 | vim:tw=78:ts=8:noet:ft=help:norl |