-
Notifications
You must be signed in to change notification settings - Fork 103
Redispatch unconsumed mouse wheel events (#2425) #2438
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
Redispatch unconsumed mouse wheel events (#2425) #2438
Conversation
|
Please:
|
compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/awt/ComposePanelTest.kt
Outdated
Show resolved
Hide resolved
Hmm, this must've been done automatically. When I created the PR, I copied the text manually and changed the release notes. Anyway, changed them again now.
Not sure how or why it's not working as-is. |
dd678b5 to
cbc3c43
Compare
it is broken, we are fixing it, it is a workaround
Clone https://jetbrains.team/p/ui/repositories/compose-teamcity-config, create a branch |
Did that. What now? |
Also, reset it to release/1.9 state, force push, then rerun all checks on GitHub |
This is a cherry-pick (with some adaptations) of #2425
Redispatch mouse wheel events which the Compose scene did not consume.
Difference with Swing behavior
This fix introduces a slight difference with how Swing handles nested mouse-wheel scrolling. In Swing, there is essentially no nested scrolling. In a scenario with a
JScrollPaneinside anotherJScrollPane, only the inner one can be scrolled when the mouse is over it. With this PR, aComposePanelwith a scrollable element within aJScrollPanewill scroll until it reaches the start/end and then the outerJScrollPanewill scroll.This behavior seems to be an improvement, so we thought it was ok to have this difference.
Danger, Will Robinson
Note that this includes a potentially dangerous hack of whose consequences I'm not yet sure. If it proves too problematic, we will need to take a different approach (documented in the source).
The hack is that in order to allow AWT to find the correct target for the redispatched event, we temporarily unregister
ComposeSceneMediator's mouse listeners.Feature flag
I've put the behavior behind
ComposeFeatureFlags.redispatchUnconsumedMouseWheelEvents. The flag will be:falseby default in 1.9.1trueby default in 1.10In this PR, it's
true, as it merges intojb-main. In the cherry-pick to 1.9.1, we should change it tofalse. When it's approved I will add a ticket to remove it for 1.11Other mouse events
Note that this PR only deals with mouse wheel events, but at least in the case of a lightweight skia layer (i.e.
SkiaSwingLayer), we should probably do the same for other mouse events.Fixes https://youtrack.jetbrains.com/issue/CMP-4601
Testing
Added unit tests, and also tested manually with
This should be tested by QA
Release Notes
Fixes - Desktop
ComposePanelcan now re-dispatch unconsumed mouse wheel events, allowing scrollable components beneath to be scrolled. To enable this behavior, set the system property"compose.swing.redispatchMouseWheelEvents"to"true".