blob: 9ffcbbaec20af76d5de5cd3460704538f6174d5f [file] [log] [blame]
Hirohito Higashi73b96502025-06-28 18:18:21 +02001*wayland.txt* For Vim version 9.1. Last change: 2025 Jun 28
Foxe Chenb90c2392025-06-27 21:10:35 +02002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Wayland Protocol Support *wayland*
8
91. Useful Wayland information |wayland-useful|
102. Wayland selections |wayland-selections|
11
12==============================================================================
131. Useful Wayland information *wayland-useful*
14
15 *wayland-seat*
16Functionality such as the clipboard for Wayland requires a seat to use. A
17Wayland seat can consist of a keyboard, pointer, and touch device(s). The
Hirohito Higashi73b96502025-06-28 18:18:21 +020018seat to use can be set with the 'wlseat' option. Only useful if you use
Foxe Chenb90c2392025-06-27 21:10:35 +020019multiple Wayland seats in the same Wayland session.
20
21 *wayland-gui*
22See |gui-wayland|. Please note that when using the GUI, Vim uses the toolkit
23such as GTK for accessing the clipboard, and does not access the clipboard
24though Wayland. You can check this though the |v:clipmethod| variable, which
25should equal to "none" when running the GUI.
26
27Wayland commands:
28 *:wlrestore* *:wl*
Hirohito Higashi73b96502025-06-28 18:18:21 +020029:wl[restore] [display] Reinitializes the connection to the Wayland compositor.
Foxe Chenb90c2392025-06-27 21:10:35 +020030 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 Higashi73b96502025-06-28 18:18:21 +020036 "wayland-0"). If [display] is omitted, then it
Foxe Chenb90c2392025-06-27 21:10:35 +020037 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 Higashi73b96502025-06-28 18:18:21 +020042 {only available when compiled with the |+wayland|
43 feature}
Foxe Chenb90c2392025-06-27 21:10:35 +020044
45Wayland errors:
46 *E1548*
Hirohito Higashi73b96502025-06-28 18:18:21 +020047Vim failed communicating with the Wayland compositor. This is likely due to
Foxe Chenb90c2392025-06-27 21:10:35 +020048the Wayland compositor process being killed. Try the `:wlrestore` command to
49try connecting again.
50
51==============================================================================
522. Wayland Selections *wayland-selections*
53
54Vim supports the wlr-data-control-unstable-v1 and ext-data-control-v1
55protocols, for accessing the current Wayland selection. These are the best
56case scenario protocols, see |wayland-focus-steal|. Selection in this case
57essentially means the "clipboard." You can check if your Wayland compositor
58supports either of these protocols by running the wayland-info command, which
59should 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.
62If you don't get any match, then please see |wayland-focus-steal| for more
63information.
64
Hirohito Higashi73b96502025-06-28 18:18:21 +020065If you come from X11, then the regular Wayland selection is equivalent to the
66CLIPBOARD selection in X11, and the primary Wayland selection equates to the
Foxe Chenb90c2392025-06-27 21:10:35 +020067X11 primary selection. Accessing these selections is the same as X11 in Vim,
68in which the + register is the regular selection, and the * register is the
69primary selection, note that your compositor may not support primary
70selections, see |wayland-primary-selection| for more details.
71
72 *wayland-persist*
Hirohito Higashi73b96502025-06-28 18:18:21 +020073If you use X11 cut buffers, no such things exist on Wayland. Instead to
Foxe Chenb90c2392025-06-27 21:10:35 +020074emulate such functionality, a separate clipboard manager must be used in order
75to persist selection data when a Wayland client exists.
76
77 *wayland-and-x11*
78If your version of Vim comes compiled with both X11 and Wayland support, then
79Vim determines which one to use when accessing the clipboard using the
80'clipmethod' option.
81
Hirohito Higashi73b96502025-06-28 18:18:21 +020082 *wayland-primary-selection*
Foxe Chenb90c2392025-06-27 21:10:35 +020083If you find X11 style primary selections useful, Wayland also implements this
84behaviour 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 Higashi73b96502025-06-28 18:18:21 +020092 wlr-data-control protocol. Then the primary selection protocol will be used
Foxe Chenb90c2392025-06-27 21:10:35 +020093 as a fallback.
94
Hirohito Higashi73b96502025-06-28 18:18:21 +020095 *wayland-focus-steal* *wayland-gnome*
Foxe Chenb90c2392025-06-27 21:10:35 +020096If you are using the GNOME desktop environment on Wayland, as of this writing,
97there is no method of accessing/modifying the clipboard for external clients
98such as Vim without being focused. Focused in this case means the client has
99received some sort of input event, such as a window being focused. This is
100what the wlr-data-control-unstable-v1 and ext-data-control-v1 protocols solve.
101If your Wayland compositor does not support the above protocols, then the
102above explanation applies.
103
104To solve this problem, Vim implements a way of gaining focus in order to
105access the clipboard, by creating a temporary transparent top-level surface.
106This is by default disabled and can be enabled via the 'wlsteal' option.
107Moreover, a seat that has a keyboard is also required, see 'wlseat', and the
108xdg-shell protocol must be available.
109
110Note that this method can have several side effects from the result of focus
111stealing. For example, if you have a taskbar that shows currently opened apps
112in your desktop environment, then when Vim attempts to steal focus, it may
113"flicker," as if a window was opened then immediately closed after.
114Additionally, if you are in fullscreen mode, this focus stealing won't work,
115because the created surface won't ever gain focus. If this happens, Vim will
116seem to freeze temporarily, see 'wltimeoutlen' for more information.
117
Hirohito Higashib6573102025-06-28 18:34:48 +0200118 vim:tw=78:ts=8:noet:ft=help:norl