Skip to content

Commit 0fbad89

Browse files
authored
Merge pull request #2593 from h-east/update-wayland
Update wayland.{txt,jax}
2 parents 01d261a + ae07f6f commit 0fbad89

2 files changed

Lines changed: 127 additions & 81 deletions

File tree

doc/wayland.jax

Lines changed: 65 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*wayland.txt* For Vim バージョン 9.2. Last change: 2026 Feb 14
1+
*wayland.txt* For Vim バージョン 9.2. Last change: 2026 Apr 20
22

33

44
VIM リファレンスマニュアル by Bram Moolenaar
@@ -50,15 +50,13 @@ Vim は Wayland コンポジタとの通信に失敗した。これは Wayland
5050

5151
Vim は、現在の Wayland セレクションにアクセスするための
5252
wlr-data-control-unstable-v1 プロトコルと ext-data-control-v1 プロトコルをサ
53-
ポートしている。これらは最適なシナリオのプロトコルである。
54-
|wayland-focus-steal| を参照。この場合のセレクションは基本的に "clipboard" を
55-
指す。Wayland コンポジタがこれらのプロトコルをサポートしているかどうかを確認す
56-
るには、wayland-info コマンドを実行する。このコマンドは、あなたのシステムでは
53+
ポートしている。この場合のセレクションは基本的に "clipboard" を指す。Wayland
54+
コンポジタがこれらのプロトコルをサポートしているかどうかを確認するには、
55+
wayland-info コマンドを実行する。このコマンドは、あなたのシステムでは
5756
libwayland にバンドルされているはずである: >
5857
wayland-info | grep -E '(ext_data_control|zwlr_data_control)'
5958
<grep で一致するものが見つかった場合、システムにはどちらか、または両方のプロト
60-
コルが存在する。一致するものが見つからない場合、詳細については
61-
|wayland-focus-steal| を参照。
59+
コルが存在する。
6260

6361
どちらかまたは両方のプロトコルをサポートすることが知られているコンポジタの一部:
6462
1. KWin (KDE)
@@ -85,40 +83,65 @@ X11 のカットバッファを使用する場合、Wayland にはそのよう
8583
するときにどちらを使用するかを決定する。
8684

8785
*wayland-primary-selection*
88-
X11 スタイルのプライマリセレクションが便利だと感じる場合、Wayland も独自のプロ
89-
トコルでこの動作を実装している:
90-
91-
- プライマリセレクションプロトコルは最も広くサポートされているが、使用するには
92-
フォーカスが必要である。|wayland-focus-steal| を参照。
93-
94-
- システムで利用可能なデータ制御プロトコル (ext プロトコルや wlr プロトコルな
95-
ど) を使用している場合は、プライマリセレクションもサポートされる。ただし、
96-
wlr-data-control プロトコルのバージョン 1 (プロトコル名の 'v1' とは異なる)
97-
を使用している場合は、プライマリセレクションプロトコルがフォールバックとして
98-
使用される。
99-
100-
*wayland-focus-steal* *wayland-gnome*
101-
Wayland で GNOME デスクトップ環境を使用している場合、この記事の執筆時点では、
102-
Vim などの外部クライアントがフォーカスされていない状態でクリップボードにアクセ
103-
スしたり、クリップボードを変更したりする手段はない。この場合のフォーカスされて
104-
いるの意味は、クライアントが何らかの入力イベント (ウィンドウがフォーカスされて
105-
いるなど) を受信したことを意味する。これは、wlr-data-control-unstable-v1 プロ
106-
トコルと ext-data-control-v1 プロトコルによって解決される。Wayland コンポジタ
107-
が上記のプロトコルをサポートしていない場合は、上記の説明が適用される。
108-
109-
この問題を解決するため、Vim は一時的に透明なトップレベルサーフェスを作成するこ
110-
とで、クリップボードにアクセスするためにフォーカスを取得する方法を実装してい
111-
る。これはデフォルトでは無効になっているが、'wlsteal' オプションで有効にでき
112-
る。さらに、キーボード付きのシート、'wlseat' を参照、および xdg-shell プロトコ
113-
ルが利用可能である必要がある。加えて Vim は |+wayland_focus_steal| 機能を使用
114-
してコンパイルする必要がある。
115-
116-
Note この方法は、フォーカスを奪取することによるいくつかの副作用を引き起こす可
117-
能性があることに注意。例えば、デスクトップ環境に現在開いているアプリを表示する
118-
タスクバーがある場合、Vim がフォーカスを奪取しようとすると、ウィンドウを開いて
119-
すぐに閉じたかのように「ちらつく」ことがある。
120-
さらに、フルスクリーンモードの場合、作成されたサーフェスがフォーカスを取得しな
121-
いため、このフォーカス奪取は機能しない。この場合、Vim は一時的にフリーズしたよ
122-
うに見える。詳細については、'wltimeoutlen' を参照。
86+
X11 スタイルのプライマリ選択が便利だと感じる場合、Wayland も Vim がサポートす
87+
るプロトコルを使用してこの機能を実装している。ただし、wlr-data-control プロト
88+
コルのバージョン 1 (プロトコル名の 'v1' とは異なる) を使用している場合は、プラ
89+
イマリ選択はサポートされない。これを確認するには、以下を使用する >
90+
wayland-info | grep -E '(ext_data_control|zwlr_data_control)'
91+
"zwlr_data_control_manager_v1" の "version:" エントリが "2" 以上であれば、プラ
92+
イマリ選択がサポートされる。また、"ext_data_control_manager_v1" も取得できた場
93+
合は、Vim は代わりにそのプロトコルを使用する。このプロトコルにはプライマリ選択
94+
のサポートが組み込まれている。
95+
96+
Wayland コンポジタが wlr-data-control-v1 または ext-data-control-v1 プロトコル
97+
をサポートしていない場合、Vim は Wayland プロトコルを介してクリップボードに直
98+
接アクセスできない。代わりに、ユーザー定義の |clipboard-providers| を介して
99+
wl-clipboard などの外部ツールを使用できる。
100+
101+
例: `wl-copy``wl-paste` を実行するプロバイダを定義する: >vim9
102+
103+
vim9script
104+
105+
def Available(): bool
106+
return executable('wl-copy') && executable('wl-paste')
107+
enddef
108+
109+
def Copy(reg: string, type: string, str: list<string>)
110+
var args = "wl-copy"
111+
112+
if reg == "*"
113+
args ..= " -p"
114+
endif
115+
116+
system(args, str)
117+
enddef
118+
119+
def Paste(reg: string): tuple<string, list<string>>
120+
var args = "wl-paste --type text/plain;charset=utf-8"
121+
122+
if reg == "*"
123+
args ..= " -p"
124+
endif
125+
126+
return ("", systemlist(args))
127+
enddef
128+
129+
v:clipproviders["wl_clipboard"] = {
130+
available: Available,
131+
copy: {
132+
"+": Copy,
133+
"*": Copy
134+
},
135+
paste: {
136+
"+": Paste,
137+
"*": Paste
138+
}
139+
}
140+
141+
set clipmethod=wl_clipboard
142+
143+
144+
これは、wl-clipboard パッケージがインストールされていることを前提としている
145+
(https://github.com/bugaevc/wl-clipboard).
123146

124147
vim:tw=78:ts=8:noet:ft=help:norl:

en/wayland.txt

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*wayland.txt* For Vim version 9.2. Last change: 2026 Feb 14
1+
*wayland.txt* For Vim version 9.2. Last change: 2026 Apr 20
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -54,15 +54,12 @@ try connecting again.
5454
2. Wayland Selections *wayland-selections*
5555

5656
Vim supports the wlr-data-control-unstable-v1 and ext-data-control-v1
57-
protocols, for accessing the current Wayland selection. These are the best
58-
case scenario protocols, see |wayland-focus-steal|. Selection in this case
57+
protocols, for accessing the current Wayland selection. Selection in this case
5958
essentially means the "clipboard." You can check if your Wayland compositor
6059
supports either of these protocols by running the wayland-info command, which
6160
should be bundled with libwayland on your system: >
6261
wayland-info | grep -E '(ext_data_control|zwlr_data_control)'
6362
<If grep finds a match, then you have either or both protocols on your system.
64-
If you don't get any match, then please see |wayland-focus-steal| for more
65-
information.
6663

6764
Some compositors that are known to support either or both protocols:
6865
1. KWin (KDE)
@@ -90,39 +87,65 @@ Vim determines which one to use when accessing the clipboard using the
9087

9188
*wayland-primary-selection*
9289
If you find X11 style primary selections useful, Wayland also implements this
93-
behaviour in its own protocols:
94-
95-
- The primary selection protocol is the most widely supported, but requires
96-
focus in order to be used, see |wayland-focus-steal|.
97-
98-
- Data control protocol available on your system, such as the ext or wlr
99-
protocols, then primary selection is also supported. This is unless you are
100-
using version 1 (not the same as the 'v1' in the protocol name), of the
101-
wlr-data-control protocol. Then the primary selection protocol will be used
102-
as a fallback.
103-
104-
*wayland-focus-steal* *wayland-gnome*
105-
If you are using the GNOME desktop environment on Wayland, as of this writing,
106-
there is no method of accessing/modifying the clipboard for external clients
107-
such as Vim without being focused. Focused in this case means the client has
108-
received some sort of input event, such as a window being focused. This is
109-
what the wlr-data-control-unstable-v1 and ext-data-control-v1 protocols solve.
110-
If your Wayland compositor does not support the above protocols, then the
111-
above explanation applies.
112-
113-
To solve this problem, Vim implements a way of gaining focus in order to
114-
access the clipboard, by creating a temporary transparent top-level surface.
115-
This is by default disabled and can be enabled via the 'wlsteal' option.
116-
Moreover, a seat that has a keyboard is also required, see 'wlseat', and the
117-
xdg-shell protocol must be available. Additionally, Vim must be compiled with
118-
the |+wayland_focus_steal| feature.
119-
120-
Note that this method can have several side effects from the result of focus
121-
stealing. For example, if you have a taskbar that shows currently opened apps
122-
in your desktop environment, then when Vim attempts to steal focus, it may
123-
"flicker," as if a window was opened then immediately closed after.
124-
Additionally, if you are in fullscreen mode, this focus stealing won't work,
125-
because the created surface won't ever gain focus. If this happens, Vim will
126-
seem to freeze temporarily, see 'wltimeoutlen' for more information.
90+
feature using the protocols that Vim supports. This is unless you are using
91+
version 1 (not the same as the 'v1' in the protocol name), of the
92+
wlr-data-control protocol, then primary selection will not be supported. You
93+
can check this using >
94+
wayland-info | grep -E '(ext_data_control|zwlr_data_control)'
95+
If the "version:" entry for "zwlr_data_control_manager_v1" is "2" or greater,
96+
then primary selection is supported. If you also get
97+
"ext_data_control_manager_v1", then Vim will use that protocol instead, which
98+
has primary selection support builtin into it.
99+
100+
If your Wayland compositor does not support the wlr-data-control-v1 or the
101+
ext-data-control-v1 protocol, Vim cannot access the clipboard directly through
102+
the Wayland protocol. External tools such as wl-clipboard can be used instead
103+
via a user-defined |clipboard-providers|.
104+
105+
Example: define a provider that shells out to `wl-copy` and `wl-paste`: >vim9
106+
107+
vim9script
108+
109+
def Available(): bool
110+
return executable('wl-copy') && executable('wl-paste')
111+
enddef
112+
113+
def Copy(reg: string, type: string, str: list<string>)
114+
var args = "wl-copy"
115+
116+
if reg == "*"
117+
args ..= " -p"
118+
endif
119+
120+
system(args, str)
121+
enddef
122+
123+
def Paste(reg: string): tuple<string, list<string>>
124+
var args = "wl-paste --type text/plain;charset=utf-8"
125+
126+
if reg == "*"
127+
args ..= " -p"
128+
endif
129+
130+
return ("", systemlist(args))
131+
enddef
132+
133+
v:clipproviders["wl_clipboard"] = {
134+
available: Available,
135+
copy: {
136+
"+": Copy,
137+
"*": Copy
138+
},
139+
paste: {
140+
"+": Paste,
141+
"*": Paste
142+
}
143+
}
144+
145+
set clipmethod=wl_clipboard
146+
147+
148+
This relies on the wl-clipboard package being installed
149+
(https://github.com/bugaevc/wl-clipboard).
127150

128151
vim:tw=78:ts=8:noet:ft=help:norl

0 commit comments

Comments
 (0)