api: overhaul pointer API
- Rename `CursorMoved` to `PointerMoved`. - Rename `CursorEntered` to `PointerEntered`. - Rename `CursorLeft` to `PointerLeft`. - Rename `MouseInput` to `PointerButton`. - Add `position` to every `PointerEvent`. - Remove `Touch`, which is folded into the `Pointer*` events. - New `PointerType` added to `PointerEntered` and `PointerLeft`, signifying which pointer type is the source of this event. - New `PointerSource` added to `PointerMoved`, similar to `PointerType` but holding additional data. - New `ButtonSource` added to `PointerButton`, similar to `PointerType` but holding pointer type specific buttons. Use `ButtonSource::mouse_button()` to easily normalize any pointer button type to a generic mouse button. - In the same spirit rename `DeviceEvent::MouseMotion` to `PointerMotion`. - Remove `Force::Calibrated::altitude_angle`. Fixes #3833. Fixes #883. Fixes #336. Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
This commit is contained in:
parent
32cd1ad9a7
commit
eccd9e415d
25 changed files with 1236 additions and 869 deletions
|
|
@ -44,7 +44,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
|||
self.windows.clear();
|
||||
event_loop.exit();
|
||||
},
|
||||
WindowEvent::CursorEntered { device_id: _ } => {
|
||||
WindowEvent::PointerEntered { device_id: _, .. } => {
|
||||
// On x11, println when the cursor entered in a window even if the child window
|
||||
// is created by some key inputs.
|
||||
// the child windows are always placed at (0, 0) with size (200, 200) in the
|
||||
|
|
|
|||
|
|
@ -446,20 +446,23 @@ impl ApplicationHandler for Application {
|
|||
}
|
||||
}
|
||||
},
|
||||
WindowEvent::MouseInput { button, state, .. } => {
|
||||
WindowEvent::PointerButton { button, state, .. } => {
|
||||
info!("Pointer button {button:?} {state:?}");
|
||||
let mods = window.modifiers;
|
||||
if let Some(action) =
|
||||
state.is_pressed().then(|| Self::process_mouse_binding(button, &mods)).flatten()
|
||||
if let Some(action) = state
|
||||
.is_pressed()
|
||||
.then(|| Self::process_mouse_binding(button.mouse_button(), &mods))
|
||||
.flatten()
|
||||
{
|
||||
self.handle_action_with_window(event_loop, window_id, action);
|
||||
}
|
||||
},
|
||||
WindowEvent::CursorLeft { .. } => {
|
||||
info!("Cursor left Window={window_id:?}");
|
||||
WindowEvent::PointerLeft { .. } => {
|
||||
info!("Pointer left Window={window_id:?}");
|
||||
window.cursor_left();
|
||||
},
|
||||
WindowEvent::CursorMoved { position, .. } => {
|
||||
info!("Moved cursor to {position:?}");
|
||||
WindowEvent::PointerMoved { position, .. } => {
|
||||
info!("Moved pointer to {position:?}");
|
||||
window.cursor_moved(position);
|
||||
},
|
||||
WindowEvent::ActivationTokenDone { token: _token, .. } => {
|
||||
|
|
@ -510,11 +513,10 @@ impl ApplicationHandler for Application {
|
|||
WindowEvent::TouchpadPressure { .. }
|
||||
| WindowEvent::HoveredFileCancelled
|
||||
| WindowEvent::KeyboardInput { .. }
|
||||
| WindowEvent::CursorEntered { .. }
|
||||
| WindowEvent::PointerEntered { .. }
|
||||
| WindowEvent::DroppedFile(_)
|
||||
| WindowEvent::HoveredFile(_)
|
||||
| WindowEvent::Destroyed
|
||||
| WindowEvent::Touch(_)
|
||||
| WindowEvent::Moved(_) => (),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue