Web: Migrate touch input to unified Pointer Events API#2799
Merged
Conversation
ApoloApps
reviewed
Feb 26, 2026
| } | ||
|
|
||
| keyboardModeState = KeyboardModeState.Hardware | ||
| private val activeTouchPointers = mutableMapOf<Int, TouchEventWithContainerOffset>() |
ApoloApps
reviewed
Feb 26, 2026
| val composePointers: List<ComposeScenePointer> by lazy { | ||
| val coalesced = getCoalescedEvents(event).toList() | ||
| val list = coalesced.takeIf { it.isNotEmpty() } ?: listOf(event) | ||
| list.map { e -> |
ApoloApps
reviewed
Feb 26, 2026
| "pointerup", | ||
| "pointerleave", | ||
| "pointercancel" | ||
| ).forEach { name -> |
Member
Author
There was a problem hiding this comment.
this is not a hot path and is called once
ApoloApps
reviewed
Feb 26, 2026
| "pointerleave", | ||
| "pointercancel" | ||
| ).forEach { name -> | ||
| addTypedEvent<PointerEvent>(name, passive = false) { onPointerEvent(it) } |
There was a problem hiding this comment.
Suggested change
| addTypedEvent<PointerEvent>(name, passive = false) { onPointerEvent(it) } | |
| addTypedEvent<PointerEvent>(name, passive = false, handler = ::onPointerEvent) |
There was a problem hiding this comment.
::onPointerEvent would create a new Function instance on every iteration anyway.
If the goal is to reduce allocations, then something like this would do:
val handler = ::onPointerEvent // just one instantiation.
... fastForEach {
addTypedEvent<PointerEvent>(name, passive = false, handler)
}
This particular initialization is one time call though, unlike other palces such as a handler itself.
- Replace `TouchEvent` handling with a more unified Pointer Event approach. - Remove obsolete `TouchEvent`-specific code and tests. - Adjust event propagation while maintaining browser compatibility. Fixes https://youtrack.jetbrains.com/issue/CMP-9745 ## Release Notes ### Fixes - Web - Unified touch and pointer event handling for better consistency and performance on Web.
5bbb131 to
07f0931
Compare
- Integrate optimized utility methods for PointerEvent processing. - Replace `map` with `fastMap` and streamline pointer type determination. - Use `mutableIntObjectMapOf` for active touch pointers to improve performance.
- Introduce reusable touch pointer list to reduce allocations. - Replace inline pointer collection logic with `getCoalescedTouchPointers` for clarity and performance.
f66771f to
d7af528
Compare
Oleksandr Karpovich (eymar)
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor and streamline touch handling on Web
TouchEventhandling with a more unified Pointer Event approach.TouchEvent-specific code and tests.Fixes https://youtrack.jetbrains.com/issue/CMP-9745
Release Notes
Fixes - Web