From 4b28f10470477a9f0daa6ab799d324f2df2bb191 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 4 Feb 2024 16:10:28 -0800 Subject: [PATCH] chore: fmt and doc fixes Signed-off-by: John Nunley --- winit-core/src/dpi.rs | 2 +- winit-core/src/event.rs | 16 ++++++++++++++-- winit-core/src/event_loop.rs | 3 +++ winit-core/src/window.rs | 14 +++++++++++--- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/winit-core/src/dpi.rs b/winit-core/src/dpi.rs index 3c99251a7..022fe0c9a 100644 --- a/winit-core/src/dpi.rs +++ b/winit-core/src/dpi.rs @@ -97,7 +97,7 @@ //! [points]: https://en.wikipedia.org/wiki/Point_(typography) //! [picas]: https://en.wikipedia.org/wiki/Pica_(typography) //! [`ScaleFactorChanged`]: crate::event::WindowEvent::ScaleFactorChanged -//! [`window.scale_factor()`]: crate::window::Window::scale_factor +//! [`window.scale_factor()`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.scale_factor //! [windows_1]: https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows //! [apple_1]: https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html //! [apple_2]: https://developer.apple.com/design/human-interface-guidelines/macos/icons-and-images/image-size-and-resolution/ diff --git a/winit-core/src/event.rs b/winit-core/src/event.rs index 94f6d6ec8..d5681bb06 100644 --- a/winit-core/src/event.rs +++ b/winit-core/src/event.rs @@ -15,7 +15,7 @@ use std::time::Instant; use web_time::Instant; #[cfg(feature = "serde")] -pub use serde::{Serialize, Deserialize}; +pub use serde::{Deserialize, Serialize}; use smol_str::SmolStr; @@ -79,7 +79,7 @@ pub enum Event { event: DeviceEvent, }, - /// Emitted when an event is sent from [`EventLoopProxy::send_event`](crate::event_loop::EventLoopProxy::send_event) + /// Emitted when an event is sent from [`EventLoopProxy::send_event`](https://docs.rs/winit/latest/winit/event_loop/struct.EventLoopProxy.html#method.send_event) UserEvent(T), /// Emitted when the application has been suspended. @@ -304,6 +304,8 @@ pub enum StartCause { } /// Describes an event from a [`Window`]. +/// +/// [`Window`]: https://docs.rs/winit/latest/winit/window/struct.Window.html #[derive(Debug, Clone, PartialEq)] pub enum WindowEvent { /// The activation token was delivered back and now could be used. @@ -391,6 +393,8 @@ pub enum WindowEvent { /// ## Platform-specific /// /// - **iOS / Android / Web / Orbital:** Unsupported. + /// + /// [`Window::set_ime_allowed`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_ime_allowed Ime(Ime), /// The cursor has moved on the window. @@ -596,6 +600,8 @@ pub enum WindowEvent { /// /// Winit will aggregate duplicate redraw requests into a single event, to /// help avoid duplicating rendering work. + /// + /// [`Window::request_redraw`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.request_redraw RedrawRequested, } @@ -889,6 +895,8 @@ impl From for Modifiers { /// Ime::Preedit("", None) // Synthetic event generated by winit to clear preedit. /// Ime::Commit("啊不") /// ``` +/// +/// [`Window::set_ime_cursor_area`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_ime_cursor_area #[derive(Debug, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum Ime { @@ -897,6 +905,8 @@ pub enum Ime { /// After getting this event you could receive [`Preedit`](Self::Preedit) and /// [`Commit`](Self::Commit) events. You should also start performing IME related requests /// like [`Window::set_ime_cursor_area`]. + /// + /// [`Window::set_ime_cursor_area`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_ime_cursor_area Enabled, /// Notifies when a new composing text should be set at the cursor position. @@ -919,6 +929,8 @@ pub enum Ime { /// [`Commit`](Self::Commit) events until the next [`Enabled`](Self::Enabled) event. You should /// also stop issuing IME related requests like [`Window::set_ime_cursor_area`] and clear pending /// preedit text. + /// + /// [`Window::set_ime_cursor_area`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_ime_cursor_area Disabled, } diff --git a/winit-core/src/event_loop.rs b/winit-core/src/event_loop.rs index 7e1204de5..fafafc3fd 100644 --- a/winit-core/src/event_loop.rs +++ b/winit-core/src/event_loop.rs @@ -39,6 +39,9 @@ impl AsyncRequestSerial { /// Defaults to [`Wait`]. /// /// [`Wait`]: Self::Wait +/// +/// [`EventLoopWindowTarget::set_control_flow()`]: https://docs.rs/winit/latest/winit/event_loop/struct.EventLoopWindowTarget.html#method.set_control_flow +/// [`Event::AboutToWait`]: crate::event::Event::AboutToWait #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub enum ControlFlow { /// When the current loop iteration finishes, immediately begin a new iteration regardless of diff --git a/winit-core/src/window.rs b/winit-core/src/window.rs index f2daf0715..24655366c 100644 --- a/winit-core/src/window.rs +++ b/winit-core/src/window.rs @@ -4,11 +4,11 @@ pub use cursor_icon::{CursorIcon, ParseError as CursorIconParseError}; #[cfg(feature = "serde")] -pub use serde::{Serialize, Deserialize}; +pub use serde::{Deserialize, Serialize}; /// Identifier of a window. Unique for each window. /// -/// Can be obtained with [`window.id()`](`Window::id`). +/// Can be obtained with [`window.id()`](https://docs.rs/winit/latest/winit/window/struct.Window.html#method.id). /// /// Whenever you receive an event specific to a window, this event contains a `WindowId` which you /// can then compare to the ids of your windows. @@ -45,6 +45,8 @@ impl From for WindowId { /// The behavior of cursor grabbing. /// /// Use this enum with [`Window::set_cursor_grab`] to grab the cursor. +/// +/// [`Window::set_cursor_grab`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_cursor_grab #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum CursorGrabMode { @@ -60,6 +62,8 @@ pub enum CursorGrabMode { /// /// - **macOS:** Not implemented. Always returns [`ExternalError::NotSupported`] for now. /// - **iOS / Android / Web / Orbital:** Always returns an [`ExternalError::NotSupported`]. + /// + /// [`ExternalError::NotSupported`]: https://docs.rs/winit/latest/winit/error/enum.ExternalError.html#variant.NotSupported Confined, /// The cursor is locked inside the window area to the certain position. @@ -71,6 +75,8 @@ pub enum CursorGrabMode { /// /// - **X11 / Windows:** Not implemented. Always returns [`ExternalError::NotSupported`] for now. /// - **iOS / Android / Orbital:** Always returns an [`ExternalError::NotSupported`]. + /// + /// [`ExternalError::NotSupported`]: https://docs.rs/winit/latest/winit/error/enum.ExternalError.html#variant.NotSupported Locked, } @@ -176,6 +182,8 @@ pub enum WindowLevel { /// ## Platform-specific /// /// - **iOS / Android / Web / Windows / X11 / macOS / Orbital:** Unsupported. +/// +/// [`Window::set_ime_purpose`]: https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_ime_purpose #[derive(Debug, PartialEq, Eq, Clone, Copy)] #[non_exhaustive] pub enum ImePurpose { @@ -197,7 +205,7 @@ impl Default for ImePurpose { /// An stringly-typed token used to activate the [`Window`]. /// -/// [`Window`]: crate::window::Window +/// [`Window`]: https://docs.rs/winit/latest/winit/window/struct.Window.html #[derive(Debug, PartialEq, Eq, Clone)] pub struct ActivationToken { pub(crate) token: String,