Updated the code to only monitor focus if the window was active when the tooltip was created

This commit is contained in:
junlu592 2025-11-14 12:23:57 +01:00
parent eb42e901d7
commit c3239453a4
2 changed files with 11 additions and 10 deletions

@ -1 +1 @@
Subproject commit 0b7c530233390d73b706f012bbe7489539925c7d
Subproject commit dad4e2736a2b53dcdb52d79b5703dd464c05d666

View file

@ -1103,16 +1103,16 @@ def tooltip(
lab.move(aw.mapToGlobal(QPoint(0 + x_offset, aw.height() - y_offset)))
lab.show()
window = aw.window() if hasattr(aw, "window") else aw
if window is None:
window = aw
was_active = window.isActiveWindow() if window else False
def close_if_parent_inactive() -> None:
if not _tooltipLabel or window is None:
return
if (
not window.isActiveWindow()
or not window.isVisible()
not window.isVisible()
or (window.windowState() & Qt.WindowState.WindowMinimized)
or (was_active and not window.isActiveWindow())
):
closeTooltip()
@ -1124,11 +1124,12 @@ def tooltip(
pass
_tooltipFocusTimer = None
focus_timer = QTimer(lab)
focus_timer.setInterval(100)
qconnect(focus_timer.timeout, close_if_parent_inactive)
focus_timer.start()
_tooltipFocusTimer = focus_timer
if was_active:
focus_timer = QTimer(lab)
focus_timer.setInterval(100)
qconnect(focus_timer.timeout, close_if_parent_inactive)
focus_timer.start()
_tooltipFocusTimer = focus_timer
_tooltipTimer = aqt.mw.progress.timer(
period, closeTooltip, False, requiresCollection=False, parent=aw
)