Skip to content

Change order of DrawCanvas and EditorGestureReceiver.kt on composition#207

Merged
Ethran merged 6 commits intomainfrom
dev
Feb 9, 2026
Merged

Change order of DrawCanvas and EditorGestureReceiver.kt on composition#207
Ethran merged 6 commits intomainfrom
dev

Conversation

@Ethran
Copy link
Owner

@Ethran Ethran commented Feb 9, 2026

Now the event will first handled by DrawCanvas.kt, which passes down the touch gestures. Removed old workaround.

PR will fix issue #171

…n. Now the event will first handled by DrawCanvas.kt, which passes down the touch gestures. Removed old workaround.

--AI--
-   **`DrawCanvas` now handles stylus events directly:** `onTouchEvent` is overridden in `DrawCanvas` to specifically capture and process `TOOL_TYPE_STYLUS` and `TOOL_TYPE_ERASER` motion events. All other touch events (like finger gestures) are passed down to the standard view handling.
-   **Gesture Receiver handles non-stylus input:** The `EditorGestureReceiver` is now responsible only for touch gestures, with the temporary stylus handling logic removed.
-   **Composables layering order corrected:** The `EditorGestureReceiver` is now placed before the `EditorSurface` in the composable tree. This ensures that it can intercept touch gestures without blocking stylus events from reaching the `DrawCanvas` underneath.
-   **Removed obsolete code:** The temporary `eraserTouchPoint` flow and related logic for handling stylus events within the `EditorGestureReceiver` have been removed.
@Ethran Ethran requested a review from Copilot February 9, 2026 12:36
@Ethran Ethran linked an issue Feb 9, 2026 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reorders Compose layers so DrawCanvas receives pointer events before EditorGestureReceiver, and removes the old stylus workaround path.

Changes:

  • Reordered EditorGestureReceiver and EditorSurface in EditorView composition.
  • Moved stylus/eraser handling into DrawCanvas.onTouchEvent() and removed the SharedFlow-based workaround.
  • Cleaned up a misleading comment in OpenGLRenderer.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/src/main/java/com/ethran/notable/editor/ui/EditorSurface.kt Removes the sizing Box wrapper around AndroidView (now only AndroidView remains).
app/src/main/java/com/ethran/notable/editor/ui/EditorGestureReceiver.kt Removes stylus workaround and adds a runtime assertion about stylus events.
app/src/main/java/com/ethran/notable/editor/drawing/OpenGLRenderer.kt Removes outdated comment about event delivery.
app/src/main/java/com/ethran/notable/editor/EditorView.kt Reorders composables so DrawCanvas is layered above the gesture receiver.
app/src/main/java/com/ethran/notable/editor/DrawCanvas.kt Adds onTouchEvent to capture stylus/eraser and deletes the old eraser SharedFlow collector.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +70
// We should not get any stylus events
require(down.type != PointerType.Stylus ||
down.type == PointerType.Eraser)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require(...) will crash the app if a stylus event reaches this receiver (which can still happen under edge cases like event routing changes or OEM behaviors). Also, the condition is confusing and effectively reduces to down.type != PointerType.Stylus, since PointerType.Eraser already satisfies down.type != PointerType.Stylus. Prefer handling this gracefully (e.g., early-return/ignore stylus+eraser here, or log and skip), and use an explicit condition that matches the intended policy (ignore stylus and eraser vs. ignore only stylus).

Copilot uses AI. Check for mistakes.
@Ethran Ethran merged commit 0b4e109 into main Feb 9, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Quastion] Changing how the gesture recognition works

1 participant