Skip to content

Commit

Permalink
chore: clear docs a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov committed Oct 4, 2024
1 parent 09a8273 commit 4e9719c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
5 changes: 3 additions & 2 deletions examples/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ impl ApplicationHandler for Application {
}
},
WindowEvent::PointerButton { button, state, .. } => {
info!("Pointer button {button:?} {state:?}");
let mods = window.modifiers;
if let Some(action) = state
.is_pressed()
Expand All @@ -457,11 +458,11 @@ impl ApplicationHandler for Application {
}
},
WindowEvent::PointerLeft { .. } => {
info!("Cursor left Window={window_id:?}");
info!("Pointer left Window={window_id:?}");
window.cursor_left();
},
WindowEvent::PointerMoved { position, .. } => {
info!("Moved cursor to {position:?}");
info!("Moved pointer to {position:?}");
window.cursor_moved(position);
},
WindowEvent::ActivationTokenDone { token: _token, .. } => {
Expand Down
4 changes: 2 additions & 2 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ changelog entry.
device can't be uniquely identified.
- Pointer `WindowEvent`s were overhauled. The new events can handle any type of pointer, serving as
a single pointer input source. Now your application can handle any pointer type without having to
explicitly handle e.g. `Touch`!

explicitly handle e.g. `Touch`:
- Rename `CursorMoved` to `PointerMoved`.
- Rename `CursorEntered` to `PointerEntered`.
- Rename `CursorLeft` to `PointerLeft`.
- Rename `MouseInput` to `PointerButton`.
- Add `position` to every `PointerEvent`.
- `PointerMoved` is **not sent** after `PointerEntered` anymore.
- Remove `Touch`, which is folded into the `Pointer*` events.
- New `PointerKind` added to `PointerEntered` and `PointerLeft`, signifying which pointer type is
the source of this event.
Expand Down
31 changes: 13 additions & 18 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ pub enum WindowEvent {
/// - **iOS / Android / Web / Orbital:** Unsupported.
Ime(Ime),

/// The cursor has moved on the window.
/// The pointer has moved on the window.
PointerMoved {
device_id: Option<DeviceId>,

/// (x,y) coords in pixels relative to the top-left corner of the window. Because the range
/// of this data is limited by the display area and it may have been transformed by
/// the OS to implement effects such as cursor acceleration, it should not be used
/// to implement non-cursor-like interactions such as 3D camera control. For that,
/// consider [`DeviceEvent::PointerMotion`].
/// (x,y) coordinates in pixels relative to the top-left corner of the window. Because the
/// range of this data is limited by the display area and it may have been
/// transformed by the OS to implement effects such as pointer acceleration, it
/// should not be used to implement non-pointer-like interactions such as 3D camera
/// control. For that, consider [`DeviceEvent::PointerMotion`].
///
/// ## Platform-specific
///
Expand All @@ -248,11 +248,11 @@ pub enum WindowEvent {
source: PointerSource,
},

/// The cursor has entered the window.
/// The pointer has entered the window.
PointerEntered {
device_id: Option<DeviceId>,

/// The position of the cursor when it entered the window.
/// The position of the pointer when it entered the window.
///
/// ## Platform-specific
///
Expand All @@ -267,11 +267,11 @@ pub enum WindowEvent {
kind: PointerKind,
},

/// The cursor has left the window.
/// The pointer has left the window.
PointerLeft {
device_id: Option<DeviceId>,

/// The position of the cursor when it left the window. The position reported can be
/// The position of the pointer when it left the window. The position reported can be
/// outside the bounds of the window.
///
/// ## Platform-specific
Expand Down Expand Up @@ -455,12 +455,7 @@ pub enum WindowEvent {
RedrawRequested,
}

/// Represents the pointer type of a pointer event.
///
/// ## Platform-specific
///
/// **Wayland/X11:** Can only identify [`Touch`](Self::Touch), any other pointer is identified as
/// [`Mouse`](Self::Mouse).
/// Represents the kind type of a pointer event.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum PointerKind {
Mouse,
Expand All @@ -482,7 +477,7 @@ pub enum PointerKind {
#[derive(Clone, Debug, PartialEq)]
pub enum PointerSource {
Mouse,
/// Represents a touch event
/// Represents a touch event.
///
/// Every time the user touches the screen, a [`WindowEvent::PointerEntered`] and a
/// [`WindowEvent::PointerButton`] with [`ElementState::Pressed`] event with an unique
Expand Down Expand Up @@ -610,7 +605,7 @@ impl FingerId {
/// Useful for interactions that diverge significantly from a conventional 2D GUI, such as 3D camera
/// or first-person game controls. Many physical actions, such as mouse movement, can produce both
/// device and window events. Because window events typically arise from virtual devices
/// (corresponding to GUI cursors and keyboard focus) the device IDs may not match.
/// (corresponding to GUI pointers and keyboard focus) the device IDs may not match.
///
/// Note that these events are delivered regardless of input focus.
#[derive(Clone, Copy, Debug, PartialEq)]
Expand Down

0 comments on commit 4e9719c

Please sign in to comment.