Skip to content

Commit

Permalink
gui: try to fix pip mode on wayland env (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Feb 18, 2024
1 parent f7a5559 commit e172227
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
13 changes: 8 additions & 5 deletions feeluown/gui/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ def enter_fullwindow_mode(self, go_back=None):
if video_widget.parent() != self._fullwindow_container:
with video_widget.change_parent():
self._fullwindow_container.set_body(video_widget)
self._fullwindow_container.show()
self._fullwindow_container.raise_()
else:
self._fullwindow_container.show()
self._fullwindow_container.raise_()

self._fullwindow_container.show()
self._fullwindow_container.raise_()
video_widget.show()
video_widget.overlay_auto_visible = True
video_widget.ctl_bar.clear_adhoc_btns()
pip_btn = video_widget.ctl_bar.add_adhoc_btn('画中画')
Expand Down Expand Up @@ -138,14 +140,15 @@ def enter_pip_mode(self):
if video_widget.parent() != self._pip_container:
with video_widget.change_parent():
self._pip_container.attach_widget(video_widget)
self._pip_container.show()
else:
self._pip_container.show()

video_widget.ctl_bar.clear_adhoc_btns()
fullscreen_btn = video_widget.ctl_bar.add_adhoc_btn('全屏')
hide_btn = video_widget.ctl_bar.add_adhoc_btn('退出画中画')
fullscreen_btn.clicked.connect(self.toggle_pip_fullscreen)
hide_btn.clicked.connect(self.unkeep_pip_and_enter_fullwindow_mode)
self._pip_container.show()
self._app.ui.mpv_widget.show()
try:
width = int(self._app.player._mpv.width) # type: ignore
height = int(self._app.player._mpv.height) # type: ignore
Expand Down
15 changes: 13 additions & 2 deletions feeluown/gui/widgets/mpv_.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from contextlib import contextmanager

from PyQt5.QtCore import QMetaObject, pyqtSlot, QSize
Expand Down Expand Up @@ -119,7 +120,9 @@ def _before_change_mpv_widget_parent(self):
See mpv mpv_opengl_cb_uninit_gl implementation for more details.
"""
_mpv_set_property_string(self._app.player._mpv.handle, b'vid', b'no')
_mpv_set_property_string(self.mpv.handle, b'vid', b'no')
self.hide()
self.shutdown()

def _after_change_mpv_widget_parent(self):
"""
Expand All @@ -136,8 +139,16 @@ def _after_change_mpv_widget_parent(self):
Inpect mpv init_best_video_out caller for more details. You should see
mp_switch_track_n is one of the entrypoint.
Note the GL must be re-initialized properly before this function is called.
Generally, show parent once can trigger the initialization. Otherwise,
mpv.vid will not be set to 1, and video can not be shown.
"""
_mpv_set_property_string(self._app.player._mpv.handle, b'vid', b'1')
self.show()
self.repaint() # force repaint to trigger re-initialization
_mpv_set_property_string(self.mpv.handle, b'vid', b'1')
if not bool(self.mpv.vid):
print('WARNING: video widget is not reconfigured properly', file=sys.stderr)


# TODO: 实现 MpvEmbeddedWidget
Expand Down

0 comments on commit e172227

Please sign in to comment.