事象
Ubuntu 24.04(WSL) に Emacs 30.1 (with pgtk) をインストール を行い、Emacsを起動したところ、下記のメッセージが表示され、W Windowモードとなってしまいました。
You are trying to run Emacs configured with the “pure-GTK” interface under the X Window System. That configuration is unsupported and will lead to sporadic crashes during transfer of large selection data. It will also lead to various problems with keyboard input.
調査
Ubuntu 22.04 では動作しているので、ビルド方法の問題かと思い、ビルドの仕方をいろいろと変えて試してみたのですが、結局 WSL(WSLg) の Ubuntu24.04 の問題でした。
環境変数 $XDG_RUNTIME_DIR は例えば run/user/1000 なのですが、そちらに /mnt/wslg/runtime-dir/wayland-0 へのシンボリックリンクが必要であるにも関わらず、自動では生成されないようです。
対応方法
.bashrc に下記を追記しました。
if [ ! -S "$XDG_RUNTIME_DIR/wayland-0" ]; then ln -s /mnt/wslg/runtime-dir/wayland-0* "$XDG_RUNTIME_DIR" fi