Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a rwh_05 feature flag #319

Merged
merged 3 commits into from
Dec 14, 2023
Merged

Add a rwh_05 feature flag #319

merged 3 commits into from
Dec 14, 2023

Conversation

nicopap
Copy link
Contributor

@nicopap nicopap commented Dec 14, 2023

This allows using accesskit with current and older versions of wgpu. Typically this is a requirement for game developers, or low level UI toolkit developers.

Changelog

Added the rwh_05 and rwh_06 feature flags to the accesskit_winit crate.

This allows consumers of the accesskit_winit crate to pick and chose which version of raw-window-handle accesskit_winit will depend on.

  • rwh_05 enables the winit rwh_05 feature flag, which uses the raw-window-handle version 0.5.
  • rwh_06 is similar to rwh_05, but for raw-window-handle version 0.6.

See rust-windowing/winit#3075 for a discussion of why this is wanted.

rwh_06 is enabled by default, following winit's convention. If both features are enabled at the same time, a compile_error! is emitted.

Tests

Tested on

  • linux/X11
  • macos
  • windows

Steps to test:

git clone https://github.com/AccessKit/accesskit.git
cd accesskit
cargo test
cargo test -p accesskit_{yourplateform}
cargo check -p accesskit_winit --no-default-features --features  'async-io rwh_05'
cargo check -p accesskit_winit

@Vrixyz
Copy link
Contributor

Vrixyz commented Dec 14, 2023

Failed test 1

$ cargo test -p accesskit_windows
   Compiling winit v0.29.3
   Compiling scopeguard v1.1.0
   Compiling accesskit_windows v0.15.1 (C:\Users\thier\Documents\perso\accesskit\platforms\windows)
    Finished test [unoptimized + debuginfo] target(s) in 4.72s
     Running unittests src\lib.rs (C:\Users\thier\Documents\cargo_target_dir\debug\deps\accesskit_windows-2eeb92a15880c7fe.exe)

running 6 tests
test node::platform_node_impl_send_sync ... ok
test text::platform_range_impl_send_sync ... ok
test tests::subclassed::has_native_uia ... ok
test tests::simple::has_native_uia ... ok
test tests::simple::navigation ... ok
test tests::simple::focus ... FAILED

failures:

---- tests::simple::focus stdout ----
thread 'tests::simple::focus' panicked at platforms\windows\src\tests\simple.rs:189:9:
assertion failed: equal
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tests::simple::focus

test result: FAILED. 5 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.13s

error: test failed, to rerun pass `-p accesskit_windows --lib`

failed test 2

$ cargo check -p accesskit_winit --no-default-features --features  'async-io rwh_05'
    Checking accesskit v0.12.1 (C:\Users\thier\Documents\perso\accesskit\common)
    Checking once_cell v1.17.1
    Checking cfg-if v1.0.0
    Checking unicode-segmentation v1.10.1
    Checking bitflags v2.4.1
   Compiling winit v0.29.3
    Checking smol_str v0.2.0
    Checking windows_x86_64_msvc v0.48.0
    Checking static_assertions v1.1.0
    Checking raw-window-handle v0.5.2
    Checking cursor-icon v1.1.0
    Checking windows-targets v0.48.1
    Checking log v0.4.17
    Checking windows v0.48.0
    Checking windows-sys v0.48.0
    Checking accesskit_consumer v0.16.1 (C:\Users\thier\Documents\perso\accesskit\consumer)
    Checking accesskit_windows v0.15.1 (C:\Users\thier\Documents\perso\accesskit\platforms\windows)
    Checking accesskit_winit v0.16.1 (C:\Users\thier\Documents\perso\accesskit\platforms\winit)
error[E0432]: unresolved import `winit::raw_window_handle`
 --> platforms\winit\src\platform_impl\windows.rs:9:5
  |
9 |     raw_window_handle::{HasWindowHandle, RawWindowHandle},
  |     ^^^^^^^^^^^^^^^^^ could not find `raw_window_handle` in `winit`

warning: unused import: `HWND`
 --> platforms\winit\src\platform_impl\windows.rs:6:45
  |
6 | use accesskit_windows::{SubclassingAdapter, HWND};
  |                                             ^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0599]: no method named `window_handle` found for reference `&winit::window::Window` in the current scope
  --> platforms\winit\src\platform_impl\windows.rs:25:33
   |
25 |         let hwnd = match window.window_handle().unwrap().as_raw() {
   |                                 ^^^^^^^^^^^^^ method not found in `&Window`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
warning: `accesskit_winit` (lib) generated 1 warning
error: could not compile `accesskit_winit` (lib) due to 2 previous errors; 1 warning emitted

This allows using accesskit with current versions of wgpu.

Winit has a similar system to widden its support. See

rust-windowing/winit#3126
@Vrixyz
Copy link
Contributor

Vrixyz commented Dec 14, 2023

Tests green on windows as of f729859

@DataTriny
Copy link
Member

Hello @nicopap, thank you for handling this! I am happy with your work but the PR is still a draft, do you want to add something else?

@DataTriny
Copy link
Member

Tested on macOS, tests are OK.

@DataTriny DataTriny marked this pull request as ready for review December 14, 2023 19:43
@DataTriny DataTriny merged commit f4d279c into AccessKit:main Dec 14, 2023
5 checks passed
@mwcampbell mwcampbell mentioned this pull request Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants