X-Debbugs-CC: Antonio <antde...@gmail.com>

This happened to me, too.  I can't tell what the cause in your case
might have been, but in my case it was because I set DISPLAY to ":0"
via ~/.pam_environment which made kwin_wayland believe it is running
within an X server, so it chose the X11 backend without testing if it
could actually connect to the X server first.  Since with SDDM (which
I use, too) the sddm-greeter's X server runs as user sddm, the
logged-in user's .Xauthority file will not match (because it is not
updated when entering a Wayland session) and the connection will fail
with an authentication error.

A remedy would be to actually try to open an X display in
kwin/main_wayland.cpp:automaticBackendSelection() and choose a
different plugin if it fails.  The code could look as simple as this:

#include <X11/Xlib.h>
...
static QString automaticBackendSelection(SpawnMode spawnMode)
{
...
    if (qEnvironmentVariableIsSet("DISPLAY")) {
        if (qEnvironmentVariableIsSet("KWIN_WAYLAND_SKIP_X11CHECK"))
            return s_x11Plugin;

        Display *d = XOpenDisplay(NULL);
        if (d) {
            XCloseDisplay(d);
            return s_x11Plugin;
        }
    }
...
}

Since kwin_wayland already links against libX11.so.6 there would be no
new dependencies.

N.B.: There is another very insidious problem here with how
startplasma-wayland chooses default values.  If startplasma-wayland is
called without arguments it unconditionally runs:

    kwin_wayland --xwayland 
--exit-with-session=/path/to/startplasma-waylandsession

But if a user modifies the Exec= line in
/usr/share/wayland-sessions/plasmawayland.desktop to e.g.

     /usr/bin/startplasma-wayland --drm

then it runs only this:

    kwin_wayland --drm

The user has no way of knowing (beyond studying the source code) that
he must also specify those other options, too, as otherwise the Plasma
session will not be set up correctly due to a missing X server.  The
lack of a manpage does not help exactly either.

Regards.

Reply via email to