mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
fixes for mpv focus switching
- avoid changing focus if an Anki window is already focused - only try to restore focus when playing videos
This commit is contained in:
parent
0fc0616ad1
commit
fbeade1f23
2 changed files with 11 additions and 5 deletions
|
@ -102,7 +102,7 @@ class MpvManager(MPV):
|
|||
super().__init__(window_id=None, debug=False)
|
||||
|
||||
def queueFile(self, file):
|
||||
runHook("mpvWillPlay")
|
||||
runHook("mpvWillPlay", file)
|
||||
|
||||
path = os.path.join(os.getcwd(), file)
|
||||
self.command("loadfile", path, "append-play")
|
||||
|
|
14
aqt/main.py
14
aqt/main.py
|
@ -970,13 +970,19 @@ Difference to correct time: %s.""") % diffText
|
|||
Invalid property found on card. Please use Tools>Check Database, \
|
||||
and if the problem comes up again, please ask on the support site."""))
|
||||
|
||||
def onMpvWillPlay(self):
|
||||
if not self._activeWindowOnPlay:
|
||||
self._activeWindowOnPlay = self.app.activeWindow()
|
||||
def _isVideo(self, file):
|
||||
head, ext = os.path.splitext(file.lower())
|
||||
return ext in (".mp4", ".mov", ".mpg", ".mpeg", ".mkv", ".avi")
|
||||
|
||||
def onMpvWillPlay(self, file):
|
||||
if not self._isVideo(file):
|
||||
return
|
||||
|
||||
self._activeWindowOnPlay = self.app.activeWindow() or self._activeWindowOnPlay
|
||||
|
||||
def onMpvIdle(self):
|
||||
w = self._activeWindowOnPlay
|
||||
if w and not sip.isdeleted(w) and w.isVisible():
|
||||
if not self.app.activeWindow() and w and not sip.isdeleted(w) and w.isVisible():
|
||||
w.activateWindow()
|
||||
w.raise_()
|
||||
self._activeWindowOnPlay = None
|
||||
|
|
Loading…
Reference in a new issue