mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.61k stars 377 forks source link

Allowing users to choose the output backend of weston #501

Open taoky opened 1 year ago

taoky commented 1 year ago

Currently, x11docker will start weston with x11 backend when DISPLAY is set ($Hostdisplay is not null): https://github.com/mviereck/x11docker/blob/93a2793e62a9fd5e5bb0ed9ffd67467463ed8003/x11docker#L4030-L4034

However, this will also start weston in x11 when in a wayland session with xwayland support. And unfortunately, I got this bug (I submitted just now) of weston x11 backend, which makes the experience uncomfortable.

Although weston.ini(5) supports settings backends:

CORE SECTION
       The core section is used to select the startup compositor modules and general options.

       shell=desktop-shell.so
              specifies  a  shell  to load (string). This can be used to load your own implemented shell or one with
              Weston as default. Available shells in the /usr/lib/weston directory are:

                 desktop-shell.so

       xwayland=true
              ask Weston to load the XWayland module (boolean).

       modules=cms-colord.so,screen-share.so
              specifies the modules to load (string). Available modules in the /usr/lib/weston directory are:

                 cms-colord.so
                 screen-share.so

       backend=headless-backend.so
              overrides defaults backend. Available backend modules in the /usr/lib/libweston-11 directory are:

                 drm-backend.so
                 headless-backend.so
                 rdp-backend.so
                 wayland-backend.so
                 x11-backend.so

It seems that the backend set in command line takes higher priority than weston.ini:

https://github.com/mviereck/x11docker/blob/93a2793e62a9fd5e5bb0ed9ffd67467463ed8003/x11docker#L4137-L4141

Currently my workaround is to modify [ -n "$Hostdisplay" ] && Westonoutput="X" to [ -n "$Hostdisplay" ] && Westonoutput="WL", and set size manually in weston.ini (otherwise the window is too large when default option is wayland backend). I think that it can be fixed by:

  1. If users don't provide their own weston.ini, keep current behavior.
  2. Otherwise, check if backend is set inside weston.ini. If so, don't add --backend to $Compositorcommand.
taoky commented 1 year ago

And, unsetting DISPLAY when running x11docker also workarounds this, but breaks the clipboard sharing functionality.