5

I am running Wayland on Ubuntu 18.04.

According to the Wayland FAX, one of it's advantages, compared to X11, is that

Wayland allows better isolation between processes: one window cannot access resources from, or inject keystrokes into, another window.

That same Wayland document also says that

because Emacs is not a real GTK apps, it still talks with X11 and therefore will use XWayland

where XWayland is described as:

Note that any X program will still run, as there is a XWayland server that provides backwards compatibility with X program. Those programs will not, however, benefit from the security and performance improvements Wayland provides.

There is a 2016 devlevel discussion thread which considers removing X11 dependency from Emacs - notably a condition already achieved in Win23 and NS versions of Emacs.

It's now 2019 and so my question is, as the title states:
Is there an X11-free build of Emacs that can run on Wayland (not going through XWayland)?

If the answer is no, I do have another question which is probably off topic for this list:
Why can't Wayland just intercept all X11 calls in XWayland and convert them into proper Wayland calls?


Edit Background Info: Apparently Electron (which the editor Atom uses to interface with Linux) has some X-call dependencies which require a setting DISABLE_WAYLAND=1 causing it to run via XWayland when running on Wayland. Also see Arch docs on Wayland which suggests setting GDK_BACKEND=x11 for Electron. So it's by no means an Emacs only issue.


Edit: Clarification (c.f. @phils very helpful and through provoking comments)

Wayland does intercept X11-calls, and of course Wayland-calls. However, the Wayland documention suggests only the Wayland calls enjoy the security benefits that Wayland has to offer.

As @phils and @wasamasa point out, emacs-nox makes no X-calls, so it should theoretically be able to run on a terminal-emulator (e.g. terminology, termite) which itself is using only Wayland protocol, and not X-protocol.

Testing that on Ubuntu has turned out not to simple, as even with a Wayland desktop on 18.04 it seems to use XWayland as the default. So the dual Wayland/X compatible terminology terminal emulator runs in X mode by default. From terminology:

~$ echo $XDG_SESSION_TYPE
x11

FINISHED

Emacs-nox runs well in Fedora 29 (personally ran it), and Fedora 29 doesn't support X at all. By default it seems to not share the system clipboard - the same as seen in emacs-nox on Ubuntu. But emacs-nox can be modified easily enough to work with @wasamasa' s answer below and custom emacs calls to external clipboardhere and here.

  • "Is there an X11-free build of Emacs that can run on Wayland" -- Yes, you can compile it without X, or use a pre-compiled build without X. You can run Emacs in a terminal in any system, including under Wayland. I don't think this is what you were asking, but it's a valid answer to your question as phrased, so please clarify the question if necessary. – phils Mar 24 at 21:49
  • 1
    "Why can't Wayland just intercept all X11 calls in XWayland and convert them into proper Wayland calls?" -- I'm pretty sure that is what XWayland is doing -- Wikipedia says it's an X.Org server implemented on top of Wayland. – phils Mar 24 at 21:52
  • @phils - The Wayland documention quoted in my question: "XWayland server provides backwards compatibility with X program ... will not, however, benefit from the security ... improvements Wayland provides." - that's the point I'm getting at. I am running: /usr/bin/emacs25-nox in a gnome terminal running as part of the gnome-terminal-server process. I'm not clear on whether not that will result in no calls to XWayland, either directly or indirectly. At least in name -nox implies no X-calls will be directly by emacs - although I suppose come terminal-calls could be translated in X. – Craig Hicks Mar 24 at 23:01
  • I imagine there is at least one Wayland-native terminal emulator available? – phils Mar 25 at 0:40
  • And yes, a -nox build of Emacs will almost certainly have been compiled without X support, so would not be making any X calls of its own. – phils Mar 25 at 0:41
2

There is no graphical Emacs build for Linux without X, no. As suggested in the commentary, you can use textual Emacs instead and customize the parts interacting with the clipboard to use wl-clipboard instead.

  • Good tip, I will try it. So far it's harder than I expected to get an terminal to run with Wayland on Ubuntu. The purpose of Wayland on Ubuntu seems to be to prove that XWayland can provide back compatibility. So I'm going to try to set up a Wayland only env on a container and test from there, eventually. – Craig Hicks Mar 25 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.