Skip to content

Commit

Permalink
chore: Don't show tip if owner window is not active or focused
Browse files Browse the repository at this point in the history
  • Loading branch information
bric3 committed Jun 2, 2024
1 parent 8681ffd commit aea300a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
Expand All @@ -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
}
}
Expand Down

0 comments on commit aea300a

Please sign in to comment.