12

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.

8
  • "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, 2019 at 21:49
  • 2
    "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, 2019 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. Mar 24, 2019 at 23:01
  • I imagine there is at least one Wayland-native terminal emulator available?
    – phils
    Mar 25, 2019 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, 2019 at 0:41

2 Answers 2

3

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.

1
  • 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. Mar 25, 2019 at 17:42
11

As of early 2021, the previously accepted answer is no longer the case. Emacs can now be ran in Wayland without XWayland. Core Emacs code has been (quite labouriously!) updated to use pure GTK, and this should be available to the general public as of Emacs 28. For now, Arch Linux users can use the updated Emacs by switching to this AUR package. Other distributions may have similar luck by searching for "emacs pgtk" builds.

For more information, see this news article.

3
  • Are there any instructions for how to build the master branch to work with wayland? - or has this not yet been merged? I checked the AUR package, it doesn't seem to contain build steps.
    – ideasman42
    Feb 28, 2021 at 7:42
  • 1
    It hasn't been merged to master yet, it's on the 'feature/pgtk' branch. './configure --with-pgtk' should get you started.
    – rpluim
    Feb 28, 2021 at 16:21
  • Consider also this alternate package: aur.archlinux.org/packages/emacs-pgtk-native-comp-git Feb 28, 2021 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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