From c3239453a4de528fafd82a22365fd7d1e8226243 Mon Sep 17 00:00:00 2001 From: junlu592 Date: Fri, 14 Nov 2025 12:23:57 +0100 Subject: [PATCH] Updated the code to only monitor focus if the window was active when the tooltip was created --- ftl/qt-repo | 2 +- qt/aqt/utils.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ftl/qt-repo b/ftl/qt-repo index 0b7c53023..dad4e2736 160000 --- a/ftl/qt-repo +++ b/ftl/qt-repo @@ -1 +1 @@ -Subproject commit 0b7c530233390d73b706f012bbe7489539925c7d +Subproject commit dad4e2736a2b53dcdb52d79b5703dd464c05d666 diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index 68054e128..2abfbf72c 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -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 )