Skip to content

Commit

Permalink
Add a rwh_05 feature flag
Browse files Browse the repository at this point in the history
This allows using accesskit with current versions of wgpu.

Winit has a similar system to widden its support. See

rust-windowing/winit#3126
  • Loading branch information
nicopap committed Dec 14, 2023
1 parent c80cdf7 commit 6443c22
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
12 changes: 10 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions platforms/winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ edition = "2021"
features = ["winit/rwh_06", "winit/x11", "winit/wayland"]

[features]
default = ["accesskit_unix", "async-io"]
default = ["accesskit_unix", "async-io", "rwh_06"]
rwh_06 = ["winit/rwh_06"]
rwh_05 = ["winit/rwh_05"]
async-io = ["accesskit_unix/async-io"]
tokio = ["accesskit_unix/tokio"]

[dependencies]
accesskit = { version = "0.12.1", path = "../../common" }
winit = { version = "0.29", default-features = false, features = ["rwh_06"] }
winit = { version = "0.29", default-features = false }

[target.'cfg(target_os = "windows")'.dependencies]
accesskit_windows = { version = "0.15.1", path = "../windows" }
Expand All @@ -34,4 +36,4 @@ accesskit_unix = { version = "0.6.1", path = "../unix", optional = true, default
[dev-dependencies.winit]
version = "0.29"
default-features = false
features = ["rwh_06", "x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]
features = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]
3 changes: 3 additions & 0 deletions platforms/winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use winit::{

mod platform_impl;

#[cfg(all(feature = "rwh_05", feature = "rwh_06"))]
compile_error!("Cannot enable both 'rwh_05' and 'rwh_06' features at the same time");

#[derive(Debug)]
pub struct ActionRequestEvent {
pub window_id: WindowId,
Expand Down
3 changes: 3 additions & 0 deletions platforms/winit/src/platform_impl/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ impl Adapter {
action_handler: ActionHandlerBox,
) -> Self {
let view = match window.window_handle().unwrap().as_raw() {
#[cfg(feature = "rwh_06")]
RawWindowHandle::AppKit(handle) => handle.ns_view.as_ptr(),
#[cfg(feature = "rwh_05")]
RawWindowHandle::AppKit(handle) => handle.ns_view,
RawWindowHandle::UiKit(_) => unimplemented!(),
_ => unreachable!(),
};
Expand Down
3 changes: 3 additions & 0 deletions platforms/winit/src/platform_impl/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ impl Adapter {
action_handler: ActionHandlerBox,
) -> Self {
let hwnd = match window.window_handle().unwrap().as_raw() {
#[cfg(feature = "rwh_06")]
RawWindowHandle::Win32(handle) => HWND(handle.hwnd.get()),
#[cfg(feature = "rwh_05")]
RawWindowHandle::Win32(handle) => handle.hwnd as isize,
RawWindowHandle::WinRt(_) => unimplemented!(),
_ => unreachable!(),
};
Expand Down

0 comments on commit 6443c22

Please sign in to comment.