缘由
在 Debian 13 GNOME 开启 Wayland 的环境下,使用官方 DEB 包安装的 Visual Studio Code 默认不启动 Wayland 支持,在 XWayland 中运行。
经检验,此时 Code 的菜单出现显示问题。
检测
一般可以用 Xeyes 程序检查 XWayland 窗口。安装好 Xeyes 后可以在终端中运行,光标放在待检测的窗口中,如果 Xeyes 的眼睛随着光标动态移动,就说明是 XWayland 窗口。
解决方法
将 /usr/local/applications 中的对应 .desktop 文件复制到 ~/.local/share/applications 中,在其中的 Exec 配置中加入 –ozone-platform-hint=auto:
[Desktop Entry]
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/share/code/code --ozone-platform-hint=auto %F
Icon=vscode
Type=Application
StartupNotify=false
StartupWMClass=Code
Categories=TextEditor;Development;IDE;
MimeType=application/x-code-workspace;
Actions=new-empty-window;
Keywords=vscode;
[Desktop Action new-empty-window]
Name=New Empty Window
Name[cs]=Nové prázdné okno
Name[de]=Neues leeres Fenster
Name[es]=Nueva ventana vacía
Name[fr]=Nouvelle fenêtre vide
Name[it]=Nuova finestra vuota
Name[ja]=新しい空のウィンドウ
Name[ko]=새 빈 창
Name[ru]=Новое пустое окно
Name[zh_CN]=新建空窗口
Name[zh_TW]=開新空視窗
Exec=/usr/share/code/code --ozone-platform-hint=auto --new-window %F
Icon=vscode
可能需要注销重新登录生效。