From aea300aa46708dd35fd1c9d61b20e7d0a4ee25dd Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Sun, 2 Jun 2024 21:22:50 +0200 Subject: [PATCH] chore: Don't show tip if owner window is not active or focused --- .../bric3/fireplace/ui/toolkit/FollowingTipService.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/FollowingTipService.kt b/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/FollowingTipService.kt index 50dfa38..0b37973 100644 --- a/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/FollowingTipService.kt +++ b/fireplace-app/src/main/kotlin/io/github/bric3/fireplace/ui/toolkit/FollowingTipService.kt @@ -69,6 +69,11 @@ private class FollowingTip { val component: Component when (e.id) { MOUSE_ENTERED, MOUSE_MOVED, MOUSE_DRAGGED, MOUSE_WHEEL -> { + // Don't bother to show tip if the owner window is not focused or active + if (!ownerWindow.isActive || !ownerWindow.isFocused) { + tipWindow.isVisible = false + return@AWTEventListener + } event = e as MouseEvent component = e.component if (ownerWindow.isAncestorOf(component) && component is JComponent) { @@ -85,7 +90,7 @@ private class FollowingTip { } val content = contentProvider?.invoke(component, event) - if (content == null) { + if (content == null || !ownerWindow.isActive || !ownerWindow.isFocused) { tipWindow.isVisible = false return@AWTEventListener } @@ -101,7 +106,7 @@ private class FollowingTip { event = e as MouseEvent component = e.component val p = SwingUtilities.convertPoint(component, event.point, ownerWindow) - if (!ownerWindow.contains(p)) { + if (!ownerWindow.contains(p) || !ownerWindow.isActive || !ownerWindow.isFocused) { tipWindow.isVisible = false } }