Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 65 additions & 42 deletions doc/wayland.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*wayland.txt* For Vim バージョン 9.2. Last change: 2026 Feb 14
*wayland.txt* For Vim バージョン 9.2. Last change: 2026 Apr 20


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

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

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

*wayland-primary-selection*
X11 スタイルのプライマリセレクションが便利だと感じる場合、Wayland も独自のプロ
トコルでこの動作を実装している:

- プライマリセレクションプロトコルは最も広くサポートされているが、使用するには
フォーカスが必要である。|wayland-focus-steal| を参照。

- システムで利用可能なデータ制御プロトコル (ext プロトコルや wlr プロトコルな
ど) を使用している場合は、プライマリセレクションもサポートされる。ただし、
wlr-data-control プロトコルのバージョン 1 (プロトコル名の 'v1' とは異なる)
を使用している場合は、プライマリセレクションプロトコルがフォールバックとして
使用される。

*wayland-focus-steal* *wayland-gnome*
Wayland で GNOME デスクトップ環境を使用している場合、この記事の執筆時点では、
Vim などの外部クライアントがフォーカスされていない状態でクリップボードにアクセ
スしたり、クリップボードを変更したりする手段はない。この場合のフォーカスされて
いるの意味は、クライアントが何らかの入力イベント (ウィンドウがフォーカスされて
いるなど) を受信したことを意味する。これは、wlr-data-control-unstable-v1 プロ
トコルと ext-data-control-v1 プロトコルによって解決される。Wayland コンポジタ
が上記のプロトコルをサポートしていない場合は、上記の説明が適用される。

この問題を解決するため、Vim は一時的に透明なトップレベルサーフェスを作成するこ
とで、クリップボードにアクセスするためにフォーカスを取得する方法を実装してい
る。これはデフォルトでは無効になっているが、'wlsteal' オプションで有効にでき
る。さらに、キーボード付きのシート、'wlseat' を参照、および xdg-shell プロトコ
ルが利用可能である必要がある。加えて Vim は |+wayland_focus_steal| 機能を使用
してコンパイルする必要がある。

Note この方法は、フォーカスを奪取することによるいくつかの副作用を引き起こす可
能性があることに注意。例えば、デスクトップ環境に現在開いているアプリを表示する
タスクバーがある場合、Vim がフォーカスを奪取しようとすると、ウィンドウを開いて
すぐに閉じたかのように「ちらつく」ことがある。
さらに、フルスクリーンモードの場合、作成されたサーフェスがフォーカスを取得しな
いため、このフォーカス奪取は機能しない。この場合、Vim は一時的にフリーズしたよ
うに見える。詳細については、'wltimeoutlen' を参照。
X11 スタイルのプライマリ選択が便利だと感じる場合、Wayland も Vim がサポートす
るプロトコルを使用してこの機能を実装している。ただし、wlr-data-control プロト
コルのバージョン 1 (プロトコル名の 'v1' とは異なる) を使用している場合は、プラ
イマリ選択はサポートされない。これを確認するには、以下を使用する >
wayland-info | grep -E '(ext_data_control|zwlr_data_control)'
"zwlr_data_control_manager_v1" の "version:" エントリが "2" 以上であれば、プラ
イマリ選択がサポートされる。また、"ext_data_control_manager_v1" も取得できた場
合は、Vim は代わりにそのプロトコルを使用する。このプロトコルにはプライマリ選択
のサポートが組み込まれている。

Wayland コンポジタが wlr-data-control-v1 または ext-data-control-v1 プロトコル
をサポートしていない場合、Vim は Wayland プロトコルを介してクリップボードに直
接アクセスできない。代わりに、ユーザー定義の |clipboard-providers| を介して
wl-clipboard などの外部ツールを使用できる。

例: `wl-copy` と `wl-paste` を実行するプロバイダを定義する: >vim9

vim9script

def Available(): bool
return executable('wl-copy') && executable('wl-paste')
enddef

def Copy(reg: string, type: string, str: list<string>)
var args = "wl-copy"

if reg == "*"
args ..= " -p"
endif

system(args, str)
enddef

def Paste(reg: string): tuple<string, list<string>>
var args = "wl-paste --type text/plain;charset=utf-8"

if reg == "*"
args ..= " -p"
endif

return ("", systemlist(args))
enddef

v:clipproviders["wl_clipboard"] = {
available: Available,
copy: {
"+": Copy,
"*": Copy
},
paste: {
"+": Paste,
"*": Paste
}
}

set clipmethod=wl_clipboard


これは、wl-clipboard パッケージがインストールされていることを前提としている
(https://github.com/bugaevc/wl-clipboard).

vim:tw=78:ts=8:noet:ft=help:norl:
101 changes: 62 additions & 39 deletions en/wayland.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*wayland.txt* For Vim version 9.2. Last change: 2026 Feb 14
*wayland.txt* For Vim version 9.2. Last change: 2026 Apr 20


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -54,15 +54,12 @@ try connecting again.
2. Wayland Selections *wayland-selections*

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

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

*wayland-primary-selection*
If you find X11 style primary selections useful, Wayland also implements this
behaviour in its own protocols:

- The primary selection protocol is the most widely supported, but requires
focus in order to be used, see |wayland-focus-steal|.

- Data control protocol available on your system, such as the ext or wlr
protocols, then primary selection is also supported. This is unless you are
using version 1 (not the same as the 'v1' in the protocol name), of the
wlr-data-control protocol. Then the primary selection protocol will be used
as a fallback.

*wayland-focus-steal* *wayland-gnome*
If you are using the GNOME desktop environment on Wayland, as of this writing,
there is no method of accessing/modifying the clipboard for external clients
such as Vim without being focused. Focused in this case means the client has
received some sort of input event, such as a window being focused. This is
what the wlr-data-control-unstable-v1 and ext-data-control-v1 protocols solve.
If your Wayland compositor does not support the above protocols, then the
above explanation applies.

To solve this problem, Vim implements a way of gaining focus in order to
access the clipboard, by creating a temporary transparent top-level surface.
This is by default disabled and can be enabled via the 'wlsteal' option.
Moreover, a seat that has a keyboard is also required, see 'wlseat', and the
xdg-shell protocol must be available. Additionally, Vim must be compiled with
the |+wayland_focus_steal| feature.

Note that this method can have several side effects from the result of focus
stealing. For example, if you have a taskbar that shows currently opened apps
in your desktop environment, then when Vim attempts to steal focus, it may
"flicker," as if a window was opened then immediately closed after.
Additionally, if you are in fullscreen mode, this focus stealing won't work,
because the created surface won't ever gain focus. If this happens, Vim will
seem to freeze temporarily, see 'wltimeoutlen' for more information.
feature using the protocols that Vim supports. This is unless you are using
version 1 (not the same as the 'v1' in the protocol name), of the
wlr-data-control protocol, then primary selection will not be supported. You
can check this using >
wayland-info | grep -E '(ext_data_control|zwlr_data_control)'
If the "version:" entry for "zwlr_data_control_manager_v1" is "2" or greater,
then primary selection is supported. If you also get
"ext_data_control_manager_v1", then Vim will use that protocol instead, which
has primary selection support builtin into it.

If your Wayland compositor does not support the wlr-data-control-v1 or the
ext-data-control-v1 protocol, Vim cannot access the clipboard directly through
the Wayland protocol. External tools such as wl-clipboard can be used instead
via a user-defined |clipboard-providers|.

Example: define a provider that shells out to `wl-copy` and `wl-paste`: >vim9

vim9script

def Available(): bool
return executable('wl-copy') && executable('wl-paste')
enddef

def Copy(reg: string, type: string, str: list<string>)
var args = "wl-copy"

if reg == "*"
args ..= " -p"
endif

system(args, str)
enddef

def Paste(reg: string): tuple<string, list<string>>
var args = "wl-paste --type text/plain;charset=utf-8"

if reg == "*"
args ..= " -p"
endif

return ("", systemlist(args))
enddef

v:clipproviders["wl_clipboard"] = {
available: Available,
copy: {
"+": Copy,
"*": Copy
},
paste: {
"+": Paste,
"*": Paste
}
}

set clipmethod=wl_clipboard


This relies on the wl-clipboard package being installed
(https://github.com/bugaevc/wl-clipboard).

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