mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.61k stars 2.92k forks source link

Also check WAYLAND_SOCKET environment variable when detecting platform #15330

Open mstoeckl opened 3 hours ago

mstoeckl commented 3 hours ago

Expected behavior of the wanted feature

There are two ways for programs to connect to the Wayland compositor: typically, the environment variable WAYLAND_DISPLAY is set, in which case it specifies a socket file to connect to; but sometimes compositors may provide the environment variable WAYLAND_SOCKET to specify a file descriptor for an already-connected socket (which was inherited from the parent process). (Note: the main Wayland documentation only mentions WAYLAND_DISPLAY; WAYLAND_SOCKET is mentioned in wl_display_connect()'s description.)

mpv currently only detects the Wayland compositor by whether WAYLAND_DISPLAY is available; this feature request is to also try to connect to a Wayland compositor if WAYLAND_SOCKET is set.

WAYLAND_SOCKET is sometimes used by compositors when running specific programs like taskbars, and some of the programs I've made (like https://gitlab.freedesktop.org/mstoeckl/windowtolayer) set it when running just a single Wayland application. It does not see much use otherwise, so I'd consider this more of a feature request than a bug.

Alternative behavior of the wanted feature

No response

Log File

I've attached a script to run an application under WAYLAND_SOCKET instead of WAYLAND_DISPLAY. It also unsets DISPLAY to prevent an X11 connection. wldisplaytosocket.py.txt

Under a Wayland compositor, with Xwayland turned off, running mpv path/to/video_file works fine; but wldisplaytosocket.py mpv path/to/video.h264 fails to detect Wayland availability and uses the drm backend, which fails. I've attached the resulting log file in case it's useful: output.txt

Sample Files

No response

sfan5 commented 3 hours ago

relevant code https://github.com/mpv-player/mpv/blob/e8fd7b8798e88c37987e73029cc4fba9d384264a/video/out/wayland_common.c#L3025-L3029