From 1845e57bf6b200e7e3447192b4f528eb55809a26 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Mon, 30 Nov 2020 19:17:00 +0100 Subject: [PATCH 1/7] Improved multi-touch --- src/platform_impl/android/mod.rs | 101 ++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 16 deletions(-) diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index ddd1eb961a..b4791edac3 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -180,39 +180,107 @@ impl EventLoop { let device_id = event::DeviceId(DeviceId); match &event { InputEvent::MotionEvent(motion_event) => { - let phase = match motion_event.action() { + match motion_event.action() { MotionAction::Down | MotionAction::PointerDown => { - Some(event::TouchPhase::Started) + let pointer = motion_event + .pointer_at_index(motion_event.pointer_index()); + let location = PhysicalPosition { + x: pointer.x() as _, + y: pointer.y() as _, + }; + let event = event::Event::WindowEvent { + window_id, + event: event::WindowEvent::Touch( + event::Touch { + device_id, + phase: event::TouchPhase::Started, + location, + id: pointer.pointer_id() as u64, + force: None, + }, + ), + }; + + call_event_handler!( + event_handler, + self.window_target(), + control_flow, + event + ); } MotionAction::Up | MotionAction::PointerUp => { - Some(event::TouchPhase::Ended) - } - MotionAction::Move => Some(event::TouchPhase::Moved), - MotionAction::Cancel => { - Some(event::TouchPhase::Cancelled) - } - _ => None, // TODO mouse events - }; - - if let Some(phase) = phase { - for pointer in motion_event.pointers() { + let pointer = motion_event + .pointer_at_index(motion_event.pointer_index()); let location = PhysicalPosition { x: pointer.x() as _, y: pointer.y() as _, }; - let event = event::Event::WindowEvent { window_id, event: event::WindowEvent::Touch( event::Touch { device_id, - phase, + phase: event::TouchPhase::Ended, location, id: pointer.pointer_id() as u64, force: None, }, ), }; + + call_event_handler!( + event_handler, + self.window_target(), + control_flow, + event + ); + } + MotionAction::Move => { + for pointer in motion_event.pointers() { + let location = PhysicalPosition { + x: pointer.x() as _, + y: pointer.y() as _, + }; + + let event = event::Event::WindowEvent { + window_id, + event: event::WindowEvent::Touch( + event::Touch { + device_id, + phase: event::TouchPhase::Moved, + location, + id: pointer.pointer_id() as u64, + force: None, + }, + ), + }; + call_event_handler!( + event_handler, + self.window_target(), + control_flow, + event + ); + } + } + MotionAction::Cancel => { + let location = PhysicalPosition { + x: 0 as _, + y: 0 as _, + }; + + let event = event::Event::WindowEvent { + window_id, + event: event::WindowEvent::Touch( + event::Touch { + device_id, + phase: event::TouchPhase::Cancelled, + location, + id: std::u64::MAX, + force: None, + }, + ), + }; + call_event_handler!( event_handler, self.window_target(), @@ -220,7 +288,8 @@ impl EventLoop { event ); } - } + _ => (), // TODO mouse events + }; } InputEvent::KeyEvent(_) => {} // TODO }; From 5b67a70bc5ee5fd05fd12cae2e410225dbc6b29a Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Mon, 30 Nov 2020 20:52:45 +0100 Subject: [PATCH 2/7] Update feature matrix --- FEATURES.md | 86 ++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index ca28c417f1..c2f8c4da14 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -166,61 +166,61 @@ Legend: - ❓: Unknown status ### Windowing -|Feature |Windows|MacOS |Linux x11 |Linux Wayland |Android|iOS |WASM | -|-------------------------------- | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | -|Window initialization |✔️ |✔️ |▢[#5] |✔️ |▢[#33]|▢[#33] |✔️ | -|Providing pointer to init OpenGL |✔️ |✔️ |✔️ |✔️ |✔️ |✔️ |**N/A**| -|Providing pointer to init Vulkan |✔️ |✔️ |✔️ |✔️ |✔️ |❓ |**N/A**| -|Window decorations |✔️ |✔️ |✔️ |▢[#306] |**N/A**|**N/A**|**N/A**| -|Window decorations toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| -|Window resizing |✔️ |▢[#219]|✔️ |▢[#306] |**N/A**|**N/A**|✔️ | -|Window resize increments |❌ |❌ |❌ |❌ |❌ |❌ |**N/A**| -|Window transparency |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|N/A | -|Window maximization |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| -|Window maximization toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| -|Window minimization |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| -|Fullscreen |✔️ |✔️ |✔️ |✔️ |**N/A**|✔️ |✔️ | -|Fullscreen toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|✔️ |✔️ | -|Exclusive fullscreen |✔️ |✔️ |✔️ |**N/A** |❌ |✔️ |**N/A**| -|HiDPI support |✔️ |✔️ |✔️ |✔️ |▢[#721]|✔️ |✔️ \*1| -|Popup windows |❌ |❌ |❌ |❌ |❌ |❌ |**N/A**| +| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | +| -------------------------------- | ------- | ------- | --------- | ------------- | ------- | ------- | ------- | +| Window initialization | ✔️ | ✔️ | ▢[#5] | ✔️ | ▢[#33] | ▢[#33] | ✔️ | +| Providing pointer to init OpenGL | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | +| Providing pointer to init Vulkan | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❓ | **N/A** | +| Window decorations | ✔️ | ✔️ | ✔️ | ▢[#306] | **N/A** | **N/A** | **N/A** | +| Window decorations toggle | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | +| Window resizing | ✔️ | ▢[#219] | ✔️ | ▢[#306] | **N/A** | **N/A** | ✔️ | +| Window resize increments | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | **N/A** | +| Window transparency | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | N/A | +| Window maximization | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | +| Window maximization toggle | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | +| Window minimization | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | +| Fullscreen | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | ✔️ | ✔️ | +| Fullscreen toggle | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | ✔️ | ✔️ | +| Exclusive fullscreen | ✔️ | ✔️ | ✔️ | **N/A** | ❌ | ✔️ | **N/A** | +| HiDPI support | ✔️ | ✔️ | ✔️ | ✔️ | ▢[#721] | ✔️ | ✔️ \*1 | +| Popup windows | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | **N/A** | \*1: `WindowEvent::ScaleFactorChanged` is not sent on `stdweb` backend. ### System information -|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | -|---------------- | ----- | ---- | ------- | ----------- | ----- | ------- | -------- | -|Monitor list |✔️ |✔️ |✔️ |✔️ |**N/A**|✔️ |**N/A**| -|Video mode query |✔️ |✔️ |✔️ |✔️ |❌ |✔️ |**N/A**| +| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | +| ---------------- | ------- | ----- | --------- | ------------- | ------- | --- | ------- | +| Monitor list | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | ✔️ | **N/A** | +| Video mode query | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ✔️ | **N/A** | ### Input handling -|Feature |Windows |MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | -|----------------------- | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | -|Mouse events |✔️ |▢[#63] |✔️ |✔️ |**N/A**|**N/A**|✔️ | -|Mouse set location |✔️ |✔️ |✔️ |❓ |**N/A**|**N/A**|**N/A**| -|Cursor grab |✔️ |▢[#165] |▢[#242] |✔️ |**N/A**|**N/A**|❓ | -|Cursor icon |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|✔️ | -|Touch events |✔️ |❌ |✔️ |✔️ |✔️ |✔️ |❌ | -|Touch pressure |✔️ |❌ |❌ |❌ |❌ |✔️ |❌ | -|Multitouch |✔️ |❌ |✔️ |✔️ |❓ |✔️ |❌ | -|Keyboard events |✔️ |✔️ |✔️ |✔️ |❓ |❌ |✔️ | -|Drag & Drop |▢[#720] |▢[#720] |▢[#720] |❌[#306] |**N/A**|**N/A**|❓ | -|Raw Device Events |▢[#750] |▢[#750] |▢[#750] |❌ |❌ |❌ |❓ | -|Gamepad/Joystick events |❌[#804] |❌ |❌ |❌ |❌ |❌ |❓ | -|Device movement events |❓ |❓ |❓ |❓ |❌ |❌ |❓ | +| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | +| ----------------------- | ------- | ------- | --------- | ------------- | ------- | ------- | ------- | +| Mouse events | ✔️ | ▢[#63] | ✔️ | ✔️ | **N/A** | **N/A** | ✔️ | +| Mouse set location | ✔️ | ✔️ | ✔️ | ❓ | **N/A** | **N/A** | **N/A** | +| Cursor grab | ✔️ | ▢[#165] | ▢[#242] | ✔️ | **N/A** | **N/A** | ❓ | +| Cursor icon | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | ✔️ | +| Touch events | ✔️ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | +| Touch pressure | ✔️ | ❌ | ❌ | ❌ | ❌ | ✔️ | ❌ | +| Multitouch | ✔️ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | +| Keyboard events | ✔️ | ✔️ | ✔️ | ✔️ | ❓ | ❌ | ✔️ | +| Drag & Drop | ▢[#720] | ▢[#720] | ▢[#720] | ❌[#306] | **N/A** | **N/A** | ❓ | +| Raw Device Events | ▢[#750] | ▢[#750] | ▢[#750] | ❌ | ❌ | ❌ | ❓ | +| Gamepad/Joystick events | ❌[#804] | ❌ | ❌ | ❌ | ❌ | ❌ | ❓ | +| Device movement events | ❓ | ❓ | ❓ | ❓ | ❌ | ❌ | ❓ | ### Pending API Reworks Changes in the API that have been agreed upon but aren't implemented across all platforms. -|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | -|------------------------------ | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | -|New API for HiDPI ([#315] [#319]) |✔️ |✔️ |✔️ |✔️ |▢[#721]|✔️ |❓ | -|Event Loop 2.0 ([#459]) |✔️ |✔️ |❌ |✔️ |❌ |✔️ |❓ | -|Keyboard Input ([#812]) |❌ |❌ |❌ |❌ |❌ |❌ |❓ | +| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | +| --------------------------------- | ------- | ----- | --------- | ------------- | ------- | --- | ---- | +| New API for HiDPI ([#315] [#319]) | ✔️ | ✔️ | ✔️ | ✔️ | ▢[#721] | ✔️ | ❓ | +| Event Loop 2.0 ([#459]) | ✔️ | ✔️ | ❌ | ✔️ | ❌ | ✔️ | ❓ | +| Keyboard Input ([#812]) | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❓ | ### Completed API Reworks -|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | -|------------------------------ | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | +| ------- | ------- | ----- | --------- | ------------- | ------- | --- | ---- | [#165]: https://github.com/rust-windowing/winit/issues/165 [#219]: https://github.com/rust-windowing/winit/issues/219 From a2cd2f1390a6ebb6c11b8f007f33a6bceda8813b Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Tue, 1 Dec 2020 12:53:37 +0100 Subject: [PATCH 3/7] Generate cancelled events for all pointers --- src/platform_impl/android/mod.rs | 47 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index b4791edac3..02ad1b1607 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -263,30 +263,31 @@ impl EventLoop { } } MotionAction::Cancel => { - let location = PhysicalPosition { - x: 0 as _, - y: 0 as _, - }; - - let event = event::Event::WindowEvent { - window_id, - event: event::WindowEvent::Touch( - event::Touch { - device_id, - phase: event::TouchPhase::Cancelled, - location, - id: std::u64::MAX, - force: None, - }, - ), - }; + for pointer in motion_event.pointers() { + let location = PhysicalPosition { + x: pointer.x() as _, + y: pointer.y() as _, + }; - call_event_handler!( - event_handler, - self.window_target(), - control_flow, - event - ); + let event = event::Event::WindowEvent { + window_id, + event: event::WindowEvent::Touch( + event::Touch { + device_id, + phase: event::TouchPhase::Moved, + location, + id: pointer.pointer_id() as u64, + force: None, + }, + ), + }; + call_event_handler!( + event_handler, + self.window_target(), + control_flow, + event + ); + } } _ => (), // TODO mouse events }; From 88c6958a5a54d84e9534394ea3ad73b8dcf94ca5 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Wed, 2 Dec 2020 16:06:02 +0100 Subject: [PATCH 4/7] Changed back features matrix layout --- FEATURES.md | 86 ++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index c2f8c4da14..1b859726cd 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -166,61 +166,61 @@ Legend: - ❓: Unknown status ### Windowing -| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | -| -------------------------------- | ------- | ------- | --------- | ------------- | ------- | ------- | ------- | -| Window initialization | ✔️ | ✔️ | ▢[#5] | ✔️ | ▢[#33] | ▢[#33] | ✔️ | -| Providing pointer to init OpenGL | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | -| Providing pointer to init Vulkan | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❓ | **N/A** | -| Window decorations | ✔️ | ✔️ | ✔️ | ▢[#306] | **N/A** | **N/A** | **N/A** | -| Window decorations toggle | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | -| Window resizing | ✔️ | ▢[#219] | ✔️ | ▢[#306] | **N/A** | **N/A** | ✔️ | -| Window resize increments | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | **N/A** | -| Window transparency | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | N/A | -| Window maximization | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | -| Window maximization toggle | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | -| Window minimization | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | **N/A** | -| Fullscreen | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | ✔️ | ✔️ | -| Fullscreen toggle | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | ✔️ | ✔️ | -| Exclusive fullscreen | ✔️ | ✔️ | ✔️ | **N/A** | ❌ | ✔️ | **N/A** | -| HiDPI support | ✔️ | ✔️ | ✔️ | ✔️ | ▢[#721] | ✔️ | ✔️ \*1 | -| Popup windows | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | **N/A** | +|Feature |Windows|MacOS |Linux x11 |Linux Wayland |Android|iOS |WASM | +|-------------------------------- | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +|Window initialization |✔️ |✔️ |▢[#5] |✔️ |▢[#33]|▢[#33] |✔️ | +|Providing pointer to init OpenGL |✔️ |✔️ |✔️ |✔️ |✔️ |✔️ |**N/A**| +|Providing pointer to init Vulkan |✔️ |✔️ |✔️ |✔️ |✔️ |❓ |**N/A**| +|Window decorations |✔️ |✔️ |✔️ |▢[#306] |**N/A**|**N/A**|**N/A**| +|Window decorations toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| +|Window resizing |✔️ |▢[#219]|✔️ |▢[#306] |**N/A**|**N/A**|✔️ | +|Window resize increments |❌ |❌ |❌ |❌ |❌ |❌ |**N/A**| +|Window transparency |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|N/A | +|Window maximization |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| +|Window maximization toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| +|Window minimization |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A**| +|Fullscreen |✔️ |✔️ |✔️ |✔️ |**N/A**|✔️ |✔️ | +|Fullscreen toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|✔️ |✔️ | +|Exclusive fullscreen |✔️ |✔️ |✔️ |**N/A** |❌ |✔️ |**N/A**| +|HiDPI support |✔️ |✔️ |✔️ |✔️ |▢[#721]|✔️ |✔️ \*1| +|Popup windows |❌ |❌ |❌ |❌ |❌ |❌ |**N/A**| \*1: `WindowEvent::ScaleFactorChanged` is not sent on `stdweb` backend. ### System information -| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | -| ---------------- | ------- | ----- | --------- | ------------- | ------- | --- | ------- | -| Monitor list | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | ✔️ | **N/A** | -| Video mode query | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ✔️ | **N/A** | +|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | +|---------------- | ----- | ---- | ------- | ----------- | ----- | ------- | -------- | +|Monitor list |✔️ |✔️ |✔️ |✔️ |**N/A**|✔️ |**N/A**| +|Video mode query |✔️ |✔️ |✔️ |✔️ |❌ |✔️ |**N/A**| ### Input handling -| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | -| ----------------------- | ------- | ------- | --------- | ------------- | ------- | ------- | ------- | -| Mouse events | ✔️ | ▢[#63] | ✔️ | ✔️ | **N/A** | **N/A** | ✔️ | -| Mouse set location | ✔️ | ✔️ | ✔️ | ❓ | **N/A** | **N/A** | **N/A** | -| Cursor grab | ✔️ | ▢[#165] | ▢[#242] | ✔️ | **N/A** | **N/A** | ❓ | -| Cursor icon | ✔️ | ✔️ | ✔️ | ✔️ | **N/A** | **N/A** | ✔️ | -| Touch events | ✔️ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | -| Touch pressure | ✔️ | ❌ | ❌ | ❌ | ❌ | ✔️ | ❌ | -| Multitouch | ✔️ | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | -| Keyboard events | ✔️ | ✔️ | ✔️ | ✔️ | ❓ | ❌ | ✔️ | -| Drag & Drop | ▢[#720] | ▢[#720] | ▢[#720] | ❌[#306] | **N/A** | **N/A** | ❓ | -| Raw Device Events | ▢[#750] | ▢[#750] | ▢[#750] | ❌ | ❌ | ❌ | ❓ | -| Gamepad/Joystick events | ❌[#804] | ❌ | ❌ | ❌ | ❌ | ❌ | ❓ | -| Device movement events | ❓ | ❓ | ❓ | ❓ | ❌ | ❌ | ❓ | +|Feature |Windows |MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | +|----------------------- | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +|Mouse events |✔️ |▢[#63] |✔️ |✔️ |**N/A**|**N/A**|✔️ | +|Mouse set location |✔️ |✔️ |✔️ |❓ |**N/A**|**N/A**|**N/A**| +|Cursor grab |✔️ |▢[#165] |▢[#242] |✔️ |**N/A**|**N/A**|❓ | +|Cursor icon |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|✔️ | +|Touch events |✔️ |❌ |✔️ |✔️ |✔️ |✔️ |❌ | +|Touch pressure |✔️ |❌ |❌ |❌ |❌ |✔️ |❌ | +|Multitouch |✔️ |❌ |✔️ |✔️ |✔️ |✔️ |❌ | +|Keyboard events |✔️ |✔️ |✔️ |✔️ |❓ |❌ |✔️ | +|Drag & Drop |▢[#720] |▢[#720] |▢[#720] |❌[#306] |**N/A**|**N/A**|❓ | +|Raw Device Events |▢[#750] |▢[#750] |▢[#750] |❌ |❌ |❌ |❓ | +|Gamepad/Joystick events |❌[#804] |❌ |❌ |❌ |❌ |❌ |❓ | +|Device movement events |❓ |❓ |❓ |❓ |❌ |❌ |❓ | ### Pending API Reworks Changes in the API that have been agreed upon but aren't implemented across all platforms. -| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | -| --------------------------------- | ------- | ----- | --------- | ------------- | ------- | --- | ---- | -| New API for HiDPI ([#315] [#319]) | ✔️ | ✔️ | ✔️ | ✔️ | ▢[#721] | ✔️ | ❓ | -| Event Loop 2.0 ([#459]) | ✔️ | ✔️ | ❌ | ✔️ | ❌ | ✔️ | ❓ | -| Keyboard Input ([#812]) | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❓ | +|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | +|------------------------------ | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +|New API for HiDPI ([#315] [#319]) |✔️ |✔️ |✔️ |✔️ |▢[#721]|✔️ |❓ | +|Event Loop 2.0 ([#459]) |✔️ |✔️ |❌ |✔️ |❌ |✔️ |❓ | +|Keyboard Input ([#812]) |❌ |❌ |❌ |❌ |❌ |❌ |❓ | ### Completed API Reworks -| Feature | Windows | MacOS | Linux x11 | Linux Wayland | Android | iOS | WASM | -| ------- | ------- | ----- | --------- | ------------- | ------- | --- | ---- | +|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |WASM | +|------------------------------ | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | [#165]: https://github.com/rust-windowing/winit/issues/165 [#219]: https://github.com/rust-windowing/winit/issues/219 From d63dce96c01e1e39879f2a4012e725387b34fd11 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Wed, 2 Dec 2020 16:07:20 +0100 Subject: [PATCH 5/7] Reduced code duplication --- src/platform_impl/android/mod.rs | 115 ++++++++----------------------- 1 file changed, 29 insertions(+), 86 deletions(-) diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index 02ad1b1607..b8df45151b 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -180,37 +180,36 @@ impl EventLoop { let device_id = event::DeviceId(DeviceId); match &event { InputEvent::MotionEvent(motion_event) => { - match motion_event.action() { + let phase = match motion_event.action() { MotionAction::Down | MotionAction::PointerDown => { - let pointer = motion_event - .pointer_at_index(motion_event.pointer_index()); - let location = PhysicalPosition { - x: pointer.x() as _, - y: pointer.y() as _, - }; - let event = event::Event::WindowEvent { - window_id, - event: event::WindowEvent::Touch( - event::Touch { - device_id, - phase: event::TouchPhase::Started, - location, - id: pointer.pointer_id() as u64, - force: None, - }, - ), - }; - - call_event_handler!( - event_handler, - self.window_target(), - control_flow, - event - ); + Some(event::TouchPhase::Started) } MotionAction::Up | MotionAction::PointerUp => { - let pointer = motion_event - .pointer_at_index(motion_event.pointer_index()); + Some(event::TouchPhase::Ended) + } + MotionAction::Move => Some(event::TouchPhase::Moved), + MotionAction::Cancel => { + Some(event::TouchPhase::Cancelled) + } + _ => None, // TODO mouse events + }; + if let Some(phase) = phase { + let pointers: Box< + dyn Iterator>, + > = match phase { + event::TouchPhase::Started + | event::TouchPhase::Ended => Box::new( + std::iter::once(motion_event.pointer_at_index( + motion_event.pointer_index(), + )), + ), + event::TouchPhase::Moved + | event::TouchPhase::Cancelled => { + Box::new(motion_event.pointers()) + } + }; + + for pointer in pointers { let location = PhysicalPosition { x: pointer.x() as _, y: pointer.y() as _, @@ -220,14 +219,13 @@ impl EventLoop { event: event::WindowEvent::Touch( event::Touch { device_id, - phase: event::TouchPhase::Ended, + phase, location, id: pointer.pointer_id() as u64, force: None, }, ), }; - call_event_handler!( event_handler, self.window_target(), @@ -235,62 +233,7 @@ impl EventLoop { event ); } - MotionAction::Move => { - for pointer in motion_event.pointers() { - let location = PhysicalPosition { - x: pointer.x() as _, - y: pointer.y() as _, - }; - - let event = event::Event::WindowEvent { - window_id, - event: event::WindowEvent::Touch( - event::Touch { - device_id, - phase: event::TouchPhase::Moved, - location, - id: pointer.pointer_id() as u64, - force: None, - }, - ), - }; - call_event_handler!( - event_handler, - self.window_target(), - control_flow, - event - ); - } - } - MotionAction::Cancel => { - for pointer in motion_event.pointers() { - let location = PhysicalPosition { - x: pointer.x() as _, - y: pointer.y() as _, - }; - - let event = event::Event::WindowEvent { - window_id, - event: event::WindowEvent::Touch( - event::Touch { - device_id, - phase: event::TouchPhase::Moved, - location, - id: pointer.pointer_id() as u64, - force: None, - }, - ), - }; - call_event_handler!( - event_handler, - self.window_target(), - control_flow, - event - ); - } - } - _ => (), // TODO mouse events - }; + } } InputEvent::KeyEvent(_) => {} // TODO }; From 1d91c13f10565852d811339c127299da4d4b6731 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Wed, 2 Dec 2020 20:36:38 +0100 Subject: [PATCH 6/7] Updated changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c588aceb93..5a2acb54ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ - **Breaking:** On X11, removed `WindowExt::set_urgent`, use `Window::request_user_attention`. - On Wayland, default font size in CSD increased from 11 to 17. - On Windows, fix bug causing message boxes to appear delayed. -- On Android, support multi-touch. +- On Android, support multi-touch with proper implemenation for every input state in `event::TouchPhase` # 0.23.0 (2020-10-02) From 56caaefe52da724934b0f4e3c0e40d4f9496b114 Mon Sep 17 00:00:00 2001 From: Marnix Kuijs Date: Wed, 2 Dec 2020 21:03:57 +0100 Subject: [PATCH 7/7] Revert changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a2acb54ad..c588aceb93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ - **Breaking:** On X11, removed `WindowExt::set_urgent`, use `Window::request_user_attention`. - On Wayland, default font size in CSD increased from 11 to 17. - On Windows, fix bug causing message boxes to appear delayed. -- On Android, support multi-touch with proper implemenation for every input state in `event::TouchPhase` +- On Android, support multi-touch. # 0.23.0 (2020-10-02)