Skip to content

[WIP] Wayland support - #340

Draft
Sunderland93 wants to merge 8 commits into
mate-desktop:masterfrom
Sunderland93:wayland
Draft

[WIP] Wayland support#340
Sunderland93 wants to merge 8 commits into
mate-desktop:masterfrom
Sunderland93:wayland

Conversation

@Sunderland93

@Sunderland93 Sunderland93 commented Aug 16, 2026

Copy link
Copy Markdown

This PR adds support for Wayland in mate-session-manager. It incorporates some features from mate-wayland-session, e.g. config template, and aims to provide complete session management for Wayland:

  • separate Wayland backend (X11 code is untouched), session is starts with startmatewayland wrapper
  • provides org.mate.session, session startup capplet, etc
  • idle monitor via ext-idle-notify-v1 protocol
  • ability to change default compositor in settings or at build time (default is wayfire)

Tested in clean environment with Wayfire and some MATE components, like mate-panel, but needs more deeply testing and probably some Wayfire config tweaks.

Closes: mate-desktop/mate-wayland-session#16

@lukefromdc

lukefromdc commented Aug 16, 2026 via email

Copy link
Copy Markdown
Member

@Sunderland93

Copy link
Copy Markdown
Author

I'm planning to revise the Wayland session startup sequence: currently, we launch Wayfire, which in turn launches mate-session, which then launches the rest of MATE components. The problem is that this creates several race conditions, and in certain situations, this causes Wayfire to crash. I want to try implementing Wayland session startup directly in mate-session itself, which will launch first and run the compositor and everything else. Similar to what's done for the X11 session. This will also allow you to change the desired compositor and store its value as a gsettings key. The only remaining issue is passing our predefined configuration to Wayfire (we copy it to the home directory the first time the script is run, but if mate-session is the startup process, we need to decide where to place our configuration and allow the user to upload their own).

@lukefromdc

lukefromdc commented Aug 16, 2026 via email

Copy link
Copy Markdown
Member

@Sunderland93

Copy link
Copy Markdown
Author

Found an issue with LightDM: it doesn't export $DISPLAY variable to child processes in Wayland sessions, so any apps that is child of Wayfire get wrong value for it (wayland-0 for both WAYLAND_DISPLAY and DISPLAY). So we probably need an workaround for LightDM that directly exports these vars to all compositor's child processes. GDM and SDDM is not affected by this issue.

@lukefromdc

lukefromdc commented Aug 19, 2026

Copy link
Copy Markdown
Member

On an initial test run, I got this result using SDDM. Not installing GDM as it pulls in half of gnome-shell meaning more fs space to manage at backups and more bandwidth at updates. I haven't used lightdm since developing the original desktop session since at that time it wasn't yet showing wayland sessions. That's how I ended up using SDDM instead

The entire desktop was rendered in the top left at full scale but using only the top left portion of the screen . Below and to the right of the external camera image shown the greeter was still shown but was nonresponsive to any input. The desktop was also nonresponsive.

A lot had to be redacted in this image for privacy reasons of course

Desktop_Nested

@lukefromdc

Copy link
Copy Markdown
Member

I just got the desktop to open normally by running mate-wayland-session from a tty, but after many 15-30 seconds it crashed. I've had issues with a crasher in the network-manager-applet (which is not a MATE package) that for some reason crashes wayfire back to the greeter, so that may be the culprit but not sure. I do not know how to cut and paste an error message out of a TTY rather than a terminal app

@Sunderland93

Copy link
Copy Markdown
Author

I'm almost done refactoring the Wayland session, getting rid of shell scripts. In my case, the session starts fine, but there's an issue with some environment variables, particularly DISPLAY. I plan to finish the refactoring by the weekend and publish it.

@Sunderland93

Copy link
Copy Markdown
Author

Tested with latest commit. Session starts fine with LightDM, SDDM or from TTY.

@lukefromdc

Copy link
Copy Markdown
Member

This now mostly works, a few times a bare wayfire session came up with all defaults, nothing in wayfire.ini applied and none of the MATE session but most of the time the session opened. I had to copy over my wayfire.ini from the shell script session with the part of it concerning the old session starter script removed to retain my usual settings, then applying a few was a bit cranky but that's probably a wayfire issue not an issue with this session. Notably, applying anything in wcm seems to reset the scaling to 1.0 which I had seen before in the old session but not in quite a while. Keeping mate-display-properties open stops that most of the time but not all of the time.

@Sunderland93

Sunderland93 commented Aug 20, 2026

Copy link
Copy Markdown
Author

WCM saves config in ~/.config/wayfire.ini, but we put our default config in ~/.config/mate/wayfire/wayfire.ini and explicit pass it to Wayfire at session start. If we want to WCM can change default settings we need to put our default config in ~/.config/

@lukefromdc

lukefromdc commented Aug 21, 2026 via email

Copy link
Copy Markdown
Member

@lukefromdc

Copy link
Copy Markdown
Member

I just confirmed that wcm (which normally saves to the same file that was read when wayfire was opened) is reading and writing from ~/.config/wayfire.ini with this session on my system. For now I have made the two files identical.

@lukefromdc

Copy link
Copy Markdown
Member

Looking at gsm-compositor.c it looks like we build the path to the intended wayfire.ini OK, but config_path is loaded into argv[2] but I don't know enough about g_spawn_async () to tell if passing argv as a whole to it is correctly passing the config path to it.

Looking at the wayfire man page, the only arguments wayfire itself takes are -c or --config for the configuration path, -B or --config-backend for the configuration backend to use (is gsettings support coming?), -d or -- debug, -D or
--damage-debug, -h or --help, -r or --damage-renderer to rerender damaged regions, and -v or --version to print the version number. Thus I don't know what the rest of argv is doing probably just for lack of experience spawning binaries from inside other binaries. I've only done a little of that myself and by rather simple means

@lukefromdc

Copy link
Copy Markdown
Member

The DISPLAY variable issue is not surprisingly causing a lot of issues with wayfire's plugins. Worst of all, Xwayland doesn't work, disabling quite a few programs. Also the cube cannot be rotated, probably nothing that requires fetching the display works right, and this may also explain the scaling resets I've had on closing WCM and all the problems I've had there.

No great surprise on a WIP under development, this is a normal part of building something new. You should have seen the first time I had a caja desktop showing under wayfire: it was under Xwayland, was decorated, could be moved, and did not stay on the bottom. So it always is in early development.

@Sunderland93

Copy link
Copy Markdown
Author

It seems like DISPLAY issue is not in mate-session, but in mate-terminal itself: in other terminal emulator, like Konsole, or mate-terminal built from git, DISPLAY is :0 as expected. I'll investigate other issue with Xwayland and Wayfire plugins

@lukefromdc

lukefromdc commented Aug 21, 2026 via email

Copy link
Copy Markdown
Member

@Sunderland93

Copy link
Copy Markdown
Author

How old a version of mate-terminal are you using? The first stable release with fixes getting DISPLAY right in wayland was probably 1.28.0

1.26, but yes, I realize that mate-terminal 1.28 doesn't have this issue

@Sunderland93

Copy link
Copy Markdown
Author

Latest commit fixes Xwayland issue for me, e.g. Steam is properly launched from menu or terminal

@lukefromdc

lukefromdc commented Aug 21, 2026 via email

Copy link
Copy Markdown
Member

@lukefromdc

lukefromdc commented Aug 21, 2026

Copy link
Copy Markdown
Member

That got xwayland working, though the cube plugin is still broken and wayfire acts like it's not reloading the configuration after making changes in wcm. System is now mostly usable from this session though. Seems to be a bit less CPU use than the shell script based session, though on this 6 core that might be an illusion.

@lukefromdc

lukefromdc commented Aug 21, 2026

Copy link
Copy Markdown
Member

What seems to be broken in plugins is all of the plugins that can show the workspaces together: cube, expo, etc

@Sunderland93

Copy link
Copy Markdown
Author

What seems to be broken in plugins is all of the plugins that can show the workspaces together: cube, expo, etc

Does this plugins work if you disable ext-workspace plugin?

@lukefromdc

lukefromdc commented Aug 22, 2026 via email

Copy link
Copy Markdown
Member

@lukefromdc

Copy link
Copy Markdown
Member

The newly added protocols are all already in my default wayfire.ini file for this, though no idea what is actually being applied

@Sunderland93

Copy link
Copy Markdown
Author

mate-session reads ~/.config/mate/wayfire/wayfire.ini if it's present (it copied on a first login in Wayland session), otherwise it uses /usr/share/mate-session-manager/wayfire.ini template.

@lukefromdc

lukefromdc commented Aug 22, 2026 via email

Copy link
Copy Markdown
Member

@lukefromdc

Copy link
Copy Markdown
Member

I am trying symlinking ~/.config/wayfire.ini to ~/config/mate/wayfire/wayfire.ini to get wcm working.

@lukefromdc

lukefromdc commented Aug 22, 2026

Copy link
Copy Markdown
Member

That works, I now have the cube and other plugins working again. We need to get wcm to find the file wayfire is running from so plugins can be activated. With wayfire.ini found and wcm working via the symlink I now have my session working with this setup

@lukefromdc

Copy link
Copy Markdown
Member

We have an issue if the compositor is terminated or crashes: something keeps running and prevents the greeter from coming back up at least on SDDM. Logout works fine, but if the compositor is killed with ctrl-alt-backspace (same as killing an Xorg session on wayfire) SDDM hangs. This implies a compositor crash would also hang SDDM. Only way I've found out of it (on a systemd system) is to log in on another tty and run systemctl stop sddm followed by systemctl start sddm which will bring the greeter back up

@Sunderland93

Copy link
Copy Markdown
Author

Please check the latest commit

@lukefromdc

lukefromdc commented Aug 26, 2026 via email

Copy link
Copy Markdown
Member

@lukefromdc

Copy link
Copy Markdown
Member

Just tested on x11, there the desktop comes up unresponsive but becomes responsive after about a minute or so. Killing x11 tends to incompletely exit the session just like in wayland, but with a twist: some process is surviving in such a durable way that it takes a minute or so just for systemctl stop sddm to return and allow restarting SDDM

@Sunderland93

Copy link
Copy Markdown
Author

A test build with today's changes still hung SDDM on killing the compositor.

I have tested a bunch of solutions, but result is the same: no login screen, black screen with blinking cursor. That's because Wayfire starts as mate-session's child, not SDDM's. So when it crashes/exits, mate-session' process remain launched and prevents SDDM login screen to appear. In order to change it, we need to return to wrapper-based solution, just like xfce4-session and lxqt-session does: compositor should start first, as display manager's child process. And then launches session itself.

@lukefromdc

lukefromdc commented Aug 28, 2026 via email

Copy link
Copy Markdown
Member

@Sunderland93

Copy link
Copy Markdown
Author

Would it be possible to determine if the compositor is still running and terminate the session if it is not?

Yes, and the proven way (lxqt-session and xfce4-session) is to detect it architecturally rather then polling inside the session manager. SDDM only restarts the greeter when the process it launched via the session file's Exec= exists. Both Xfce and LXQt make the compositor display manager-tracked session leader; startlxqtwayland does exec wayfire -c and Wayfire's autistart config then runs lxqt-session && killall wayfire. When compositor is killed or crashed, display manager's tracked leader exits directly and the greeter comes back.

Also note that if wayfire gains support for relaunching and reconnecting after a crash in the future (as KDE
was reportedly working on a while back) we'd want to be able to take advantage of that

This is the other side of the coin - KDE-style reconnect needs the session manager to survive while a restartable compositor relaunches - i.e. session first. Wayland clients now die when compositor's socket closes, and Wayfire (and wlroots itself, as far as I know) doesn't support client reconnect, so we have to make compositor-first now. To keep that door open, we're centralizing policy at one explicit point (e.g. compositor-death-policy key + hook), so that when Wayfire gains xdg-session-management/reconnect support, mate-session can flip from "terminate session" to "relaunch compositor" and keep the session with a small, contained change rather than a redesign

@lukefromdc

lukefromdc commented Aug 29, 2026 via email

Copy link
Copy Markdown
Member

@Sunderland93

Copy link
Copy Markdown
Author

I return to the wrapper-based solution: Wayfire now starts first, then launches mate-session in it's auotostart section. The startmatewayland wrapper allows to add more compositors in future (it can read compositor value from gsettings to). Now session is correctly returns to the greeter when Wayfire is killed by Ctrl+Alt+Backspace or crashed. No regressions is found during my tests.

One caveat: terminate session is using logind, so the whole Wayland session is depends on systemd, so it cannot be used in other init systems or OS, like FreeBSD.

@lukefromdc

lukefromdc commented Aug 29, 2026 via email

Copy link
Copy Markdown
Member

@lukefromdc

lukefromdc commented Aug 29, 2026

Copy link
Copy Markdown
Member

Just tested this, got a bare wayfire session without the rest of the session started, every time. This happened before on occasion, not it happens consistantly. Brought up the desktop by running the wayland-components.sh script from the old wayland session from a terminal.

(EDIT)I see that we only kill the compositor after the session exits with this code. It looks like the rest of the session is trying to start up outside the compositor without connecting to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why mate-session is not used?

2 participants