mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 14:49:07 -04:00
wayland: Move hash algorithm to foldhash
At the moment, the wayland code uses ahash to perform hashing in its various hash mas. This was done because ahash was seen as the best default in the Rust community at the time. However, most Rust crates (including `hashbrown`) have since moved to using foldhash instead. This move is done for two primary reasons: - This reduces the number of dependencies in the tree for most GUI projects. As other projects use foldhash now, this removes ahash (as well as its five dependencies) from the tree. - In most cases, foldhash is faster than ahash. Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
@@ -67,9 +67,9 @@ unicode-segmentation = "1.7.1"
|
||||
windows-sys = "0.61"
|
||||
|
||||
# Linux dependencies.
|
||||
ahash = { version = "0.8.7", features = ["no-rng"] }
|
||||
bytemuck = { version = "1.13.1", default-features = false }
|
||||
calloop = "0.14.3"
|
||||
foldhash = { version = "0.2.0", default-features = false, features = ["std"] }
|
||||
libc = "0.2.64"
|
||||
memmap2 = "0.9.0"
|
||||
percent-encoding = "2.0"
|
||||
|
||||
@@ -32,6 +32,7 @@ allow = [
|
||||
"ISC", # https://tldrlegal.com/license/isc-license
|
||||
"MIT", # https://tldrlegal.com/license/mit-license
|
||||
"Unicode-3.0", # https://spdx.org/licenses/Unicode-3.0.html
|
||||
"Zlib", # https://spdx.org/licenses/Zlib.html
|
||||
]
|
||||
confidence-threshold = 1.0
|
||||
private = { ignore = true }
|
||||
|
||||
@@ -29,8 +29,8 @@ tracing.workspace = true
|
||||
winit-core.workspace = true
|
||||
|
||||
# Platform-specific
|
||||
ahash.workspace = true
|
||||
calloop.workspace = true
|
||||
foldhash.workspace = true
|
||||
libc.workspace = true
|
||||
memmap2.workspace = true
|
||||
rustix = { workspace = true, features = ["std", "system", "thread", "process", "event", "pipe"] }
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
//! * `wayland-csd-adwaita-crossfont`.
|
||||
//! * `wayland-csd-adwaita-notitle`.
|
||||
//! * `wayland-csd-adwaita-notitlebar`.
|
||||
|
||||
#![allow(clippy::mutable_key_type)]
|
||||
|
||||
use std::ffi::c_void;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ahash::AHashMap;
|
||||
use foldhash::HashMap;
|
||||
use sctk::reexports::client::backend::ObjectId;
|
||||
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||
use sctk::reexports::client::protocol::wl_touch::WlTouch;
|
||||
@@ -43,7 +43,7 @@ pub struct WinitSeatState {
|
||||
touch: Option<WlTouch>,
|
||||
|
||||
/// The mapping from touched points to the surfaces they're present.
|
||||
touch_map: AHashMap<i32, TouchPoint>,
|
||||
touch_map: HashMap<i32, TouchPoint>,
|
||||
|
||||
/// Id of the first touch event.
|
||||
first_touch_id: Option<i32>,
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::cell::RefCell;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use ahash::AHashMap;
|
||||
use foldhash::HashMap;
|
||||
use sctk::compositor::{CompositorHandler, CompositorState};
|
||||
use sctk::output::{OutputHandler, OutputState};
|
||||
use sctk::reexports::calloop::LoopHandle;
|
||||
@@ -62,10 +62,10 @@ pub struct WinitState {
|
||||
pub xdg_shell: XdgShell,
|
||||
|
||||
/// The currently present windows.
|
||||
pub windows: RefCell<AHashMap<WindowId, Arc<Mutex<WindowState>>>>,
|
||||
pub windows: RefCell<HashMap<WindowId, Arc<Mutex<WindowState>>>>,
|
||||
|
||||
/// The requests from the `Window` to EventLoop, such as close operations and redraw requests.
|
||||
pub window_requests: RefCell<AHashMap<WindowId, Arc<WindowRequests>>>,
|
||||
pub window_requests: RefCell<HashMap<WindowId, Arc<WindowRequests>>>,
|
||||
|
||||
/// The events that were generated directly from the window.
|
||||
pub window_events_sink: Arc<Mutex<EventSink>>,
|
||||
@@ -74,10 +74,10 @@ pub struct WinitState {
|
||||
pub window_compositor_updates: Vec<WindowCompositorUpdate>,
|
||||
|
||||
/// Currently handled seats.
|
||||
pub seats: AHashMap<ObjectId, WinitSeatState>,
|
||||
pub seats: HashMap<ObjectId, WinitSeatState>,
|
||||
|
||||
/// Currently present cursor surfaces.
|
||||
pub pointer_surfaces: AHashMap<ObjectId, Arc<ThemedPointer<WinitPointerData>>>,
|
||||
pub pointer_surfaces: HashMap<ObjectId, Arc<ThemedPointer<WinitPointerData>>>,
|
||||
|
||||
/// The state of the text input on the client.
|
||||
pub text_input_state: Option<TextInputState>,
|
||||
@@ -156,7 +156,7 @@ impl WinitState {
|
||||
|
||||
let seat_state = SeatState::new(globals, queue_handle);
|
||||
|
||||
let mut seats = AHashMap::default();
|
||||
let mut seats = HashMap::default();
|
||||
for seat in seat_state.seats() {
|
||||
seats.insert(seat.id(), WinitSeatState::new());
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::num::NonZeroU32;
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
use std::time::Duration;
|
||||
|
||||
use ahash::HashSet;
|
||||
use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Size};
|
||||
use foldhash::HashSet;
|
||||
use sctk::compositor::{CompositorState, Region, SurfaceData, SurfaceDataExt};
|
||||
use sctk::globals::GlobalData;
|
||||
use sctk::reexports::client::backend::ObjectId;
|
||||
|
||||
@@ -53,3 +53,4 @@ changelog entry.
|
||||
|
||||
- On X11, fix `set_hittest` not working on some window managers.
|
||||
- On Redox, handle `EINTR` when reading from `event_socket` instead of panicking.
|
||||
- On Wayland, switch from using the `ahash` hashing algorithm to `foldhash`.
|
||||
|
||||
Reference in New Issue
Block a user