Skip to content

Commit 86f1ab1

Browse files
author
arch
committed
add draft workaround for embedded mpv on windows
1 parent b954c09 commit 86f1ab1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

funscript_editor/ui/funscript_editor_window.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import logging
1111
import shutil
1212
import webbrowser
13+
import platform
1314

1415
import numpy as np
1516

@@ -40,10 +41,22 @@ def __init__(self):
4041
self.__setup_shortcut_bindings()
4142
self.__setup_variables()
4243
self.__setup_autosave_timer()
44+
self.setMouseTracking(True)
4345

4446
__generateFunscript = QtCore.pyqtSignal()
4547
__logger = logging.getLogger(__name__)
4648

49+
50+
def mouseMoveEvent(self, event):
51+
""" Track the mouse in Qt Window """
52+
# On Windows the embedded mpv player do not get the mouse events
53+
if False:
54+
if platform.system() == 'Windows':
55+
self.video_player.send_mouse_pos(
56+
event.x() - self.ui.videoPane.x(),
57+
event.y() - self.ui.videoPane.y() - self.ui.menubar.height())
58+
59+
4760
def closeEvent(self, event):
4861
""" Implement for the Qt closeEvent handler """
4962
self.__save_funscript()

funscript_editor/ui/video_player.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,20 @@ def __update_stroke_indicator(self) -> None:
506506
)
507507

508508

509+
def send_mouse_pos(self, x :int, y :int) -> None:
510+
""" Control mouse on mpv via commands
511+
512+
Args:
513+
x (int): x position
514+
y (int): y position
515+
"""
516+
self.player.command("mouse", str(x), str(y))
517+
self.player.command("keydown", "MOUSE_BTN0")
518+
time .sleep(0.01)
519+
self.player.command("keyup", "MOUSE_BTN0")
520+
# print("[DEBUG] click ui at", x, y)
521+
522+
509523
def run(self) -> None:
510524
""" Video Player Thread Function """
511525
self.player.wait_until_playing()

0 commit comments

Comments
 (0)