为什么 Wayland 与 X11 不同

X11 已步入晚年

X11 在几年前就进入了维护模式, 最近除去 XWayland 也毫无真正的改进. 这意味着没有漏洞修复, 没有安全补丁, 没有新增功能.

X11 在设计上是一整个开发平台 – 应用可以用 X11 绘制界面, 用内置服务打印文档, 录制屏幕而不需要用户许可, 监听键盘事件.

但这些设计并没有用. 内置 UI 绘制看起来十分复古先进, 即使是当年也一样. 打印服务也并没有人用 – 窗口管理器不是用来管理打印的, CUPS 才是.

X11 的 功能 对某些开发者可能是必须, 但它本就不该存在. 举个例子, X11 允许应用移动自己的窗口, 设置自定义图标, 录制整个屏幕而无需许可. 如果应用是恶意的, 那么这些 功能 简直是为它敞开大门.

Wayland 相比 X11 更优秀

Wayland is a replacement for the X11 window system protocol and architecture with the aim to be easier to develop, extend, and maintain.

Wayland is the language (protocol) that applications can use to talk to a display server in order to make themselves visible and get input from the user (a person). A Wayland server is called a “compositor”. Applications are Wayland clients.
Wayland also refers to a system architecture. It is not just a server-client relationship between a compositor and applications. There is no single common Wayland server like Xorg is for X11, but every graphical environment brings with it one of many compositor implementations. Window management and the end user experience are often tied to the compositor rather than swappable components.

A core part of Wayland architecture is libwayland: an inter-process communication library that translates a protocol definition in XML to a C language API. This library does not implement Wayland, it merely encodes and decodes Wayland messages. The actual implementations are in the various compositor and application toolkit projects.
Wayland does not restrict where and how it is used. A Wayland compositor could be a standalone display server running on Linux kernel modesetting and evdev input devices or on many other operating systems, or a nested compositor that itself is an X11 or Wayland application (client). Wayland can even be used in application-internal communication as is done in some web browsers.
Part of the Wayland project is also the Weston reference implementation of a Wayland compositor. Weston can run as an X client or under Linux KMS and ships with a few demo clients. The Weston compositor is a minimal and fast compositor and is suitable for many embedded and mobile use cases.

– Freedesktop, Wayland

对 Wayland 的诬蔑

PCSX2

PCSX2 开发者 stenzek 在一个 Pull Request 中禁用了 Flatpak 版的 Wayland socket, 并使 AppImage Build 默认使用 X11. 若要在 PCSX2 中默认启用 Wayland, 需要设置 I_WANT_A_BROKEN_WAYLAND_UI.

作者在 YouTuber 发布一期提及此 Pr 的视频后添加了上述说明, 并锁定了评论区与 Reactions. 未修改的原文如下:

Description of Changes

Disables Wayland, it’s super broken/buggy in basically every scenario. KDE isn’t too buggy, GNOME is a complete disaster.

Until they sort their s**t out, which is unlikely, just keep it disabled. For the Flatpaks, users can re-enable it with flatseal if they really want the crappy experience.

修改后变化部分如下:

PCSX2 still supports Wayland. It just prefers the XCB/XWayland platform by default. You can set the I_WANT_A_BROKEN_WAYLAND_UI environment variable and experience the brokenness for yourself on the AppImage builds, or add the wayland socket to the flatpak.probonopd

显然, 这位开发者认为 Wayland 充满漏洞, 无法使用. 这是对 Wayland 的无端诬蔑, 且不是 PCSX2 和这位开发者的第一次类似行为.

PCSX2/pcsx2/#10065 中, VladimirVSC 报告了全屏与窗口模式切换时位置向上移动. stenzek 指出 这是 Wayland 的问题, 随后立即关闭了 Issue. 然而, Linux Mint 的 Cinnamon 桌面环境在当时甚至还未开始开发 Wayland 支持. 以上例子展现了 PCSX2 开发者 stenzek 无视事实将开发的问题推卸至 Wayland 上.

AppImage 核心开发者

probonopd 在他的 Gist 中 发布了一篇名为 Think twice before abandoning Xorg. Wayland breaks everything!文章. 这里并不会大篇幅截取他的文章, 因为不值得浪费篇幅.

首先, 他提出 Wayland 没有解决任何问题, 而是破坏了许多他需要的东西. 完全是一派胡言. 且不说 X11 已经停止功能开发, Wayland 还解决了多显示器不同 DPI 的问题; X11 的所谓 功能: 应用可以随意移动位置, 设置窗口图标, 不经允许录制屏幕和键盘操作等等. 如同 [上文](## X11 已步入晚年) 所说, 这些所谓的功能很容易被恶意程序利用.

接下来, 他认为 Wayland 有设计缺陷. 这是对的, 任何程序都有设计缺陷, 但他给出的理由十分牵强.

  • 混成器崩溃会杀死所有正在运行的程序

    • Plasma 6 已经解决了这个问题
  • 程序不能做许多 X11 下能做的事情

    • 见上文
  • 不存在 Wayland 显示服务器的统一 binary / Wayland 工作转移到了混成器上

    • Wayland 协议作为一个最小的库存在于系统中, 由混成器实现它. 因此, 某个混成器的实现错误并不会影响到其他 Wayland 混成器, X11 与之相反
  • Wayland 破坏了屏幕录制程序 / Wayland 破坏了屏幕共享程序

    • Wayland 下使用 Pipewire 进行屏幕录制, 需要请求用户许可. X11 使用 XSHM, 并且没有用户同意也可以捕捉屏幕, 给恶意软件敞开了大门. KDE 开发者发布了 XWaylandVideoBridge 解决这个问题.
    • There is a workaround for OBS Studio that requires a obs-xdg-portal plugin (which is known to be Red Hat/Flatpak-centric, GNOME-centric, “perhaps” works with other desktops)

      • 则是他散布的又一不实信息. 所有支持 XDG Desktop Portal 的桌面, KDE GNOME Hyprland etc 都可以通过 Pipewire 录制屏幕.
  • Wayland 破坏了自动化软件

    • 使用 ydotool. 自动化软件不应仅需用户权限就能操控系统, 因为它引入了被恶意软件利用的可能性.
  • Wayland 破坏了 Qt 全局菜单和 Platform Plugin

    • 不实信息. 截至目前, Qt5 & KDE 5.27 不存在问题.
  • Wayland 破坏了不提供 Wayland Qt 插件的 AppImage

    • 请修复垃圾打包
  • Wayland 破坏了红移

    • 主要的两个桌面环境, GNOME 与 KDE 的红移都能正常工作
    • wlr_gamma_control_unstable_v1 已经推出
  • Wayland 破坏了全局快捷键

    • 应用程序不应当能在后台捕捉键盘输入
    • KDE 已经推出了全局快捷键服务
  • Wayland 在 NVIDIA 闭源驱动上不工作

    • 请打开 DRM Kernel Mode Settings 后再编造不实消息
  • Wayland 在 Intel GPU 上造成了屏幕撕裂

    • 引用的这篇文章并没有提供任何证据
  • Wayland 使统一窗口装饰变得更难

  • Wayland 阻止应用自行拉起窗口

    • 应用自行拉起窗口毫无用处, 请使用 StartUpNotification 提醒用户激活窗口
    • 用户讨厌自行抢夺焦点
  • Wayland 破坏了窗口管理器 / xclip / SUDO_ASKPASS / xkill

    • Wayland 不是 X11
  • Wayland 破坏了游戏

    • XWayland

总结

抵制强制使用 XWayland 的垃圾, 包括开发者与应用程序.