Skip to content

Commit 1b723ba

Browse files
authored
Merge pull request #2129 from h-east/add-wayland
Add wayland.{txt,jax}
2 parents a42eb5f + 4480ef2 commit 1b723ba

File tree

2 files changed

+234
-0
lines changed

2 files changed

+234
-0
lines changed

doc/wayland.jax

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
*wayland.txt* For Vim バージョン 9.1. Last change: 2025 Jun 28
2+
3+
4+
VIMリファレンスマニュアル by Bram Moolenaar
5+
6+
7+
Wayland プロトコルのサポート *wayland*
8+
9+
1. Wayland の役立つ情報 |wayland-useful|
10+
2. Wayland セレクション |wayland-selections|
11+
12+
==============================================================================
13+
1. Wayland の役立つ情報 *wayland-useful*
14+
15+
*wayland-seat*
16+
Wayland のクリップボードなどの機能を使用するには、シートが必要である。Wayland
17+
シートは、キーボード、ポインター、タッチデバイスで構成される。使用するシートは
18+
'wlseat' オプションで設定できる。これは、同じ Wayland セッションで複数の
19+
Wayland シートを使用する場合にのみ役立つ。
20+
21+
*wayland-gui*
22+
|gui-wayland| を参照。GUI 使用時、Vim はクリップボードへのアクセスに GTK など
23+
のツールキットを使用し、Wayland 経由ではアクセスしない。これは |v:clipmethod|
24+
変数で確認できる。GUI 実行時にはこの変数は "none" になる。
25+
26+
Wayland のコマンド:
27+
*:wlrestore* *:wl*
28+
:wl[restore] [display] Wayland コンポジタへの接続を再初期化する。Wayland コン
29+
ポジタの再起動後も Vim を screen/tmux セッションで実行
30+
し続ける場合に便利である。
31+
32+
[display] は、環境変数 $WAYLAND_DISPLAY の形式(例:
33+
"wayland-0")で指定する必要がある。[display] を省略し
34+
た場合は、このコマンドの前回実行時に使用された値と同じ
35+
値を使用して接続を再初期化する。
36+
値が指定されていない場合は、環境変数 $WAYLAND_DISPLAY
37+
の値が使用される。また、|v:clipmethod| も更新される。
38+
{Vimが |+wayland| 機能付きでコンパイルされたときのみ有
39+
効}
40+
41+
Wayland のエラー:
42+
*E1548*
43+
Vim は Wayland コンポジタとの通信に失敗した。これは Wayland コンポジタのプロセ
44+
スが強制終了したことが原因である可能性がある。再接続するには `:wlrestore` コマ
45+
ンドを試すこと。
46+
47+
==============================================================================
48+
2. Wayland セレクション *wayland-selections*
49+
50+
Vim は、現在の Wayland セレクションにアクセスするための
51+
wlr-data-control-unstable-v1 プロトコルと ext-data-control-v1 プロトコルをサ
52+
ポートしている。これらは最適なシナリオのプロトコルである。
53+
|wayland-focus-steal| を参照。この場合のセレクションは基本的に "clipboard" を
54+
指す。Wayland コンポジタがこれらのプロトコルをサポートしているかどうかを確認す
55+
るには、wayland-info コマンドを実行する。このコマンドは、あなたのシステムでは
56+
libwayland にバンドルされているはずである: >
57+
wayland-info | grep -E '(ext_data_control|zwlr_data_control)'
58+
<grep で一致するものが見つかった場合、システムにはどちらか、または両方のプロト
59+
コルが存在する。一致するものが見つからない場合、詳細については
60+
|wayland-focus-steal| を参照。
61+
62+
X11 から移行する場合、通常の Waylandセレクション は X11 のクリップボードセレク
63+
ションに相当し、プライマリ Wayland セレクションは X11 のプライマリセレクション
64+
に相当する。これらのセレクションへのアクセスは Vim の X11 と同様で、+ レジスタ
65+
が通常のセレクション、* レジスタがプライマリセレクションである。Note コンポジ
66+
タがプライマリセレクションをサポートしていない可能性があることに注意。詳細は
67+
|wayland-primary-selection| を参照。
68+
69+
*wayland-persist*
70+
X11 のカットバッファを使用する場合、Wayland にはそのような機能は存在しない。そ
71+
のような機能をエミュレートするには、Wayland クライアントが存在する場合にセレク
72+
ションデータを保持するために、別のクリップボードマネージャーを使用する必要があ
73+
る。
74+
75+
*wayland-and-x11*
76+
使用している Vim のバージョンが X11 と Wayland の両方のサポートでコンパイルさ
77+
れている場合、Vim は 'clipmethod' オプションを使用してクリップボードにアクセス
78+
するときにどちらを使用するかを決定する。
79+
80+
*wayland-primary-selection*
81+
X11 スタイルのプライマリセレクションが便利だと感じる場合、Wayland も独自のプロ
82+
トコルでこの動作を実装している:
83+
84+
- プライマリセレクションプロトコルは最も広くサポートされているが、使用するには
85+
フォーカスが必要である。|wayland-focus-steal| を参照。
86+
87+
- システムで利用可能なデータ制御プロトコル (ext プロトコルや wlr プロトコルな
88+
ど) を使用している場合は、プライマリセレクションもサポートされる。ただし、
89+
wlr-data-control プロトコルのバージョン 1 (プロトコル名の 'v1' とは異なる)
90+
を使用している場合は、プライマリセレクションプロトコルがフォールバックとして
91+
使用される。
92+
93+
*wayland-focus-steal* *wayland-gnome*
94+
Wayland で GNOME デスクトップ環境を使用している場合、この記事の執筆時点では、
95+
Vim などの外部クライアントがフォーカスされていない状態でクリップボードにアクセ
96+
スしたり、クリップボードを変更したりする手段はない。この場合のフォーカスされて
97+
いるの意味は、クライアントが何らかの入力イベント (ウィンドウがフォーカスされて
98+
いるなど) を受信したことを意味する。これは、wlr-data-control-unstable-v1 プロ
99+
トコルと ext-data-control-v1 プロトコルによって解決される。Wayland コンポジタ
100+
が上記のプロトコルをサポートしていない場合は、上記の説明が適用される。
101+
102+
この問題を解決するため、Vim は一時的に透明なトップレベルサーフェスを作成するこ
103+
とで、クリップボードにアクセスするためにフォーカスを取得する方法を実装してい
104+
る。これはデフォルトでは無効になっているが、'wlsteal' オプションで有効にでき
105+
る。さらに、キーボード付きのシート、'wlseat' を参照、と xdg-shell プロトコルが
106+
利用可能である必要がある。
107+
108+
Note この方法は、フォーカスを奪取することによるいくつかの副作用を引き起こす可
109+
能性があることに注意。例えば、デスクトップ環境に現在開いているアプリを表示する
110+
タスクバーがある場合、Vim がフォーカスを奪取しようとすると、ウィンドウを開いて
111+
すぐに閉じたかのように「ちらつく」ことがある。
112+
さらに、フルスクリーンモードの場合、作成されたサーフェスがフォーカスを取得しな
113+
いため、このフォーカス奪取は機能しない。この場合、Vim は一時的にフリーズしたよ
114+
うに見える。詳細については、'wltimeoutlen' を参照。
115+
116+
vim:tw=78:ts=8:noet:ft=help:norl:

en/wayland.txt

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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

Comments
 (0)