fix: hide WAYLAND_DISPLAY during mpv init so it uses X11 wid embedding

This commit is contained in:
2026-04-06 20:41:16 +02:00
parent 02c63bdfde
commit c130010e36
+8
View File
@@ -468,11 +468,19 @@ class MpvWidget(QFrame):
def _init_player(self):
if self._player is not None:
return
# Temporarily hide WAYLAND_DISPLAY so mpv picks X11 output and
# respects the wid parameter (X11 window ID). Without this, mpv
# detects Wayland via the environment and opens its own window.
_wd = os.environ.pop("WAYLAND_DISPLAY", None)
try:
self._player = mpv.MPV(
wid=str(int(self.winId())),
keep_open=True,
pause=True,
)
finally:
if _wd is not None:
os.environ["WAYLAND_DISPLAY"] = _wd
# mpv fires events on its own thread; bounce to Qt thread via QTimer.
@self._player.event_callback("file-loaded")
def _on_file_loaded(event):