chore: Housekeeping

- Update CHANGELOG
- Add documentation to items I forgot to document
- Trait implementations

Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
John Nunley
2024-02-04 15:53:34 -08:00
parent c6e57430bb
commit daf1304879
8 changed files with 39 additions and 12 deletions

View File

@@ -49,6 +49,14 @@ Unreleased` header.
- On Wayland, fix `Window::set_{min,max}_inner_size` not always applied.
- On Windows, fix inconsistent resizing behavior with multi-monitor setups when repositioning outside the event loop.
- On Wayland, fix `WAYLAND_SOCKET` not used when detecting platform.
- **Breaking:** Move some types to the `winit-core` crate. Most types are
re-exported verbatim; however:
- `Event`, `WindowEvent` and `KeyEvent` now take a generic that `winit`
implements.
- `ActivationToken` and `InnerSizeWriter` expose new methods to make them
useful.
- `InnerSizeWriter::request_inner_size` returns an `InnerSizeIgnored` error
instead of an `ExternalError`.
# 0.29.10

View File

@@ -8,7 +8,9 @@ resolver = "2"
[workspace.dependencies]
bitflags = "2"
cfg_aliases = "0.2.0"
cursor-icon = "1.1.0"
serde = { version = "1", features = ["serde_derive"] }
smol_str = "0.2.0"
web-time = "1"
winit-core = { path = "./winit-core", default-features = false, features = ["std"] }

View File

@@ -21,9 +21,12 @@ serde = ["dep:serde", "cursor-icon/serde", "smol_str/serde"]
[dependencies]
bitflags.workspace = true
cursor-icon.workspace = true
mint = { version = "0.5.6", optional = true }
serde = { workspace = true, optional = true }
smol_str.workspace = true
web-time = "1"
[target.'cfg(target_family = "wasm")'.dependencies]
web-time.workspace = true
[build-dependencies]
cfg_aliases = "0.2.0"
cfg_aliases.workspace = true

View File

@@ -14,6 +14,9 @@ use std::time::Instant;
#[cfg(web_platform)]
use web_time::Instant;
#[cfg(feature = "serde")]
pub use serde::{Serialize, Deserialize};
use smol_str::SmolStr;
/// Identifier of an input device.
@@ -778,6 +781,7 @@ pub struct Modifiers {
}
impl Modifiers {
/// Only `winit` should instantiate this!
#[doc(hidden)]
pub fn new(state: ModifiersState, pressed_mods: ModifiersKeys) -> Self {
Self {
@@ -1120,6 +1124,7 @@ impl InnerSizeWriter {
}
}
/// Get the underlying size.
pub fn get(&self) -> PhysicalSize<u32> {
*self.new_inner_size.upgrade().unwrap().lock().unwrap()
}

View File

@@ -3,6 +3,9 @@
#[doc(inline)]
pub use cursor_icon::{CursorIcon, ParseError as CursorIconParseError};
#[cfg(feature = "serde")]
pub use serde::{Serialize, Deserialize};
/// Identifier of a window. Unique for each window.
///
/// Can be obtained with [`window.id()`](`Window::id`).
@@ -192,7 +195,7 @@ impl Default for ImePurpose {
}
}
/// An opaque token used to activate the [`Window`].
/// An stringly-typed token used to activate the [`Window`].
///
/// [`Window`]: crate::window::Window
#[derive(Debug, PartialEq, Eq, Clone)]
@@ -201,14 +204,17 @@ pub struct ActivationToken {
}
impl ActivationToken {
pub fn new(_token: String) -> Self {
Self { token: _token }
/// Create a new [`ActivationToken`].
pub fn new(token: String) -> Self {
Self { token }
}
/// Get the underlying token.
pub fn token(&self) -> &str {
&self.token
}
/// Convert into the underlying token.
pub fn into_token(self) -> String {
self.token
}

View File

@@ -52,19 +52,19 @@ wayland-csd-adwaita-crossfont = ["sctk-adwaita", "sctk-adwaita/crossfont"]
wayland-csd-adwaita-notitle = ["sctk-adwaita"]
android-native-activity = ["android-activity/native-activity"]
android-game-activity = ["android-activity/game-activity"]
serde = ["dep:serde", "cursor-icon/serde", "smol_str/serde"]
mint = ["winit-core/mint"]
serde = ["dep:serde", "winit-core/serde", "cursor-icon/serde", "smol_str/serde"]
rwh_04 = ["dep:rwh_04", "ndk/rwh_04"]
rwh_05 = ["dep:rwh_05", "ndk/rwh_05"]
rwh_06 = ["dep:rwh_06", "ndk/rwh_06"]
[build-dependencies]
cfg_aliases = "0.2.0"
cfg_aliases.workspace = true
[dependencies]
bitflags.workspace = true
cursor-icon.workspace = true
log = "0.4"
mint = { version = "0.5.6", optional = true }
once_cell = "1.12"
rwh_04 = { package = "raw-window-handle", version = "0.4", optional = true }
rwh_05 = { package = "raw-window-handle", version = "0.5.2", features = ["std"], optional = true }
@@ -246,7 +246,7 @@ js-sys = "0.3.64"
pin-project = "1"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-time = "1"
web-time.workspace = true
[target.'cfg(all(target_family = "wasm", target_feature = "atomics"))'.dependencies]
atomic-waker = "1"

View File

@@ -16,6 +16,12 @@ pub enum ExternalError {
Os(OsError),
}
impl From<winit_core::event::InnerSizeIgnored> for ExternalError {
fn from(_: winit_core::event::InnerSizeIgnored) -> Self {
Self::Ignored
}
}
/// The error type for when the OS cannot perform the requested operation.
#[derive(Debug)]
pub struct OsError {

View File

@@ -14,9 +14,6 @@ pub use crate::icon::{BadIcon, Icon};
#[doc(inline)]
pub use winit_core::window::*;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Represents a window.
///
/// The window is closed when dropped.