mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 19:06:11 +00:00
fix: follow the mouse to the active screen during recording
The recording indicator (overlay) was shown in a fixed corner of the screen it first appeared on. Moving the mouse to another monitor while a dictation was in progress caused the indicator to disappear from view, even though the recording was still running. Poll the cursor position every ~333 ms inside the animation tick and call _reposition() when the cursor has moved to a different screen. The window then jumps to the same corner on whichever monitor the user is looking at, making it clear that recording is still active. The check is throttled to every ten ticks rather than every frame (30 Hz) because screenAt() is a trivial coordinate lookup but there is no value in calling it more often than the human hand can move between monitors.
This commit is contained in:
@@ -264,6 +264,17 @@ class Overlay(QWidget):
|
|||||||
# the corner when it does rather than leaving a gap where it was.
|
# the corner when it does rather than leaving a gap where it was.
|
||||||
if self.below is not None and self.below.showing != self._stacked:
|
if self.below is not None and self.below.showing != self._stacked:
|
||||||
self._reposition()
|
self._reposition()
|
||||||
|
elif self.state in LIVE:
|
||||||
|
# Follow the screen the mouse is currently on. Checked every ten
|
||||||
|
# ticks (~333 ms) rather than every frame: screenAt() is cheap but
|
||||||
|
# the user's hand moves slowly, so there is no value in sampling it
|
||||||
|
# at 30 Hz.
|
||||||
|
self._screen_check_ticks = getattr(self, "_screen_check_ticks", 0) + 1
|
||||||
|
if self._screen_check_ticks >= 10:
|
||||||
|
self._screen_check_ticks = 0
|
||||||
|
current_screen = QApplication.screenAt(QCursor.pos())
|
||||||
|
if current_screen is not None and current_screen != self.screen():
|
||||||
|
self._reposition()
|
||||||
if self.state in LIVE and not self.paused:
|
if self.state in LIVE and not self.paused:
|
||||||
# keep the ribbon moving even through a pause in speech
|
# keep the ribbon moving even through a pause in speech
|
||||||
self.levels = self.levels[1:] + [self.levels[-1] * 0.72]
|
self.levels = self.levels[1:] + [self.levels[-1] * 0.72]
|
||||||
|
|||||||
Reference in New Issue
Block a user