You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
input: Split out InputEventJava into Motion and Key with Deref (#503)
When I implemented the `from_java()` constructors for `MotionEvent`
and `KeyEvent` in #456, I used a single `InputEventJava` wrapper since
that could wrap the existing `enum InputEvent` and only need a single
destructor calling `AInputEvent_release()` (which must only be called
when the input event was created from Java).
This however requires existing callers to `MotionEvent::from_java()` and
`KeyEvent::from_java()` to _unwrap_/unpack that nested `enum InputEvent`
again in order to get access to the underlying native methods, despite
already calling a specific constructor method (since Android makes a
distinction between both types).
Not that that is even reachable, since the nested `InputEvent` member
was private and there was no `Deref` into `&InputEvent` anywhere making
it impossible to use this API in any meaningful way.
Solve both issues by splitting the `struct` into a `Motion` and `Key`
variant, and implement `Deref` on both to their respective type. No
wrapper `InputEventJava` remains since there does not appear to be any
reason to pass both of these types into a single API.
0 commit comments