fix: force QT_QPA_PLATFORM=xcb so mpv embeds correctly on Wayland sessions

This commit is contained in:
2026-04-06 20:39:12 +02:00
parent f30955b63c
commit 02c63bdfde
+5 -6
View File
@@ -805,9 +805,11 @@ class SettingsDialog(QDialog):
def main(): def main():
# Force X11/XCB mode so mpv can embed via wid — Wayland uses a different # Force X11/XCB (XWayland) so mpv can embed via wid.
# surface handle that mpv's wid parameter cannot accept. # mpv's wid parameter requires an X11 window ID; it does not work with
os.environ.setdefault("QT_QPA_PLATFORM", "xcb") # Wayland surface handles. Override rather than setdefault so this takes
# effect even when QT_QPA_PLATFORM=wayland is already set by the session.
os.environ["QT_QPA_PLATFORM"] = "xcb"
app = QApplication(sys.argv) app = QApplication(sys.argv)
locale.setlocale(locale.LC_NUMERIC, "C") # QApplication resets locale; re-apply for libmpv locale.setlocale(locale.LC_NUMERIC, "C") # QApplication resets locale; re-apply for libmpv
app.setStyle("Fusion") app.setStyle("Fusion")
@@ -1257,7 +1259,6 @@ class MainWindow(QMainWindow):
# --- Mask generation --- # --- Mask generation ---
def dragEnterEvent(self, event: QDragEnterEvent) -> None: def dragEnterEvent(self, event: QDragEnterEvent) -> None:
print("dragEnter formats:", event.mimeData().formats(), flush=True)
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.acceptProposedAction() event.acceptProposedAction()
else: else:
@@ -1270,12 +1271,10 @@ class MainWindow(QMainWindow):
event.ignore() event.ignore()
def dropEvent(self, event: QDropEvent) -> None: def dropEvent(self, event: QDropEvent) -> None:
print("drop urls:", event.mimeData().urls(), flush=True)
paths = [ paths = [
u.toLocalFile() for u in event.mimeData().urls() u.toLocalFile() for u in event.mimeData().urls()
if os.path.isfile(u.toLocalFile()) if os.path.isfile(u.toLocalFile())
] ]
print("drop paths:", paths, flush=True)
if paths: if paths:
self._playlist.add_files(paths) self._playlist.add_files(paths)