-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore AWT mouse events during window resize #949
Conversation
@@ -279,9 +279,43 @@ internal abstract class ComposeBridge( | |||
}) | |||
} | |||
|
|||
// Decides which AWT events should be delivered, and which should be filtered out | |||
private val awtEventFilter = object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need an extra object here? It seems like it can be just private functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it, but I think it's cleaner to bundle it into a "filter" object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also looks cleaner to me
return !isDisposed | ||
} | ||
} | ||
|
||
private fun onMouseEvent(event: MouseEvent): Unit = catchExceptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called from several places including mouseEntered
/mouseExited
events, so it looks like we need to filter it only there and drop additional bool storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to know the current pressed state of the primary mouse button in order to filter correctly.
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposeBridge.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposeBridge.desktop.kt
Outdated
Show resolved
Hide resolved
@@ -279,9 +279,43 @@ internal abstract class ComposeBridge( | |||
}) | |||
} | |||
|
|||
// Decides which AWT events should be delivered, and which should be filtered out | |||
private val awtEventFilter = object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also looks cleaner to me
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposeBridge.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposeBridge.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposeBridge.desktop.kt
Outdated
Show resolved
Hide resolved
b361f3d
to
d4749a5
Compare
…the primary mouse button, but aren't mouse press/release events.
…e press/release events.
d4749a5
to
55ee365
Compare
While resizing the window by dragging it by its edge, AWT (at least on macOS) sends mouse enter/exit events that report the primary button as pressed. This causes
PointerInputScope.detectTapAndPress
to falsely detect a tap.Proposed Changes
Ignore mouse events that signal a change in the pressed state of the primary mouse button, but aren't mouse press/release events.
Testing
Test: tested manually that resizing the window no longer triggers
PointerInputScope.detectTapAndPress
.Issues Fixed
Fixes: JetBrains/compose-multiplatform#2850