Skip to content

Commit cda35e7

Browse files
BenjaminBrienenDataTriny
authored andcommitted
fix!: Update windows to 0.58 on accesskit_windows (#453)
1 parent 8a84abf commit cda35e7

File tree

13 files changed

+146
-87
lines changed

13 files changed

+146
-87
lines changed

Cargo.lock

Lines changed: 63 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platforms/windows/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ accesskit = { version = "0.16.0", path = "../../common" }
1616
accesskit_consumer = { version = "0.24.0", path = "../../consumer" }
1717
paste = "1.0"
1818
static_assertions = "1.1.0"
19+
windows-core = "0.58.0"
1920

2021
[dependencies.windows]
21-
version = "0.54"
22+
version = "0.58.0"
2223
features = [
2324
"implement",
2425
"Win32_Foundation",
@@ -36,4 +37,3 @@ features = [
3637
once_cell = "1.13.0"
3738
scopeguard = "1.1.0"
3839
winit = "0.30"
39-

platforms/windows/examples/hello_world.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ struct SimpleActionHandler {
189189
window: HWND,
190190
}
191191

192+
unsafe impl Send for SimpleActionHandler {}
193+
unsafe impl Sync for SimpleActionHandler {}
194+
192195
impl ActionHandler for SimpleActionHandler {
193196
fn do_action(&mut self, request: ActionRequest) {
194197
match request.action {
@@ -334,9 +337,9 @@ fn create_window(title: &str, initial_focus: NodeId) -> Result<HWND> {
334337
None,
335338
GetModuleHandleW(None).unwrap(),
336339
Some(Box::into_raw(create_params) as _),
337-
)
340+
)?
338341
};
339-
if window.0 == 0 {
342+
if window.is_invalid() {
340343
return Err(Error::from_win32());
341344
}
342345

@@ -350,11 +353,11 @@ fn main() -> Result<()> {
350353
println!("Enable Narrator with [Win]+[Ctrl]+[Enter] (or [Win]+[Enter] on older versions of Windows).");
351354

352355
let window = create_window(WINDOW_TITLE, INITIAL_FOCUS)?;
353-
unsafe { ShowWindow(window, SW_SHOW) };
356+
let _ = unsafe { ShowWindow(window, SW_SHOW) };
354357

355358
let mut message = MSG::default();
356-
while unsafe { GetMessageW(&mut message, HWND(0), 0, 0) }.into() {
357-
unsafe { TranslateMessage(&message) };
359+
while unsafe { GetMessageW(&mut message, HWND::default(), 0, 0) }.into() {
360+
let _ = unsafe { TranslateMessage(&message) };
358361
unsafe { DispatchMessageW(&message) };
359362
}
360363

platforms/windows/src/adapter.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::{
2121
filters::filter,
2222
node::{NodeWrapper, PlatformNode},
2323
util::QueuedEvent,
24+
window_handle::WindowHandle,
2425
};
2526

2627
fn focus_event(context: &Arc<Context>, node_id: NodeId) -> QueuedEvent {
@@ -140,7 +141,7 @@ const PLACEHOLDER_ROOT_ID: NodeId = NodeId(0);
140141

141142
enum State {
142143
Inactive {
143-
hwnd: HWND,
144+
hwnd: WindowHandle,
144145
is_window_focused: bool,
145146
action_handler: Arc<dyn ActionHandlerNoMut + Send + Sync>,
146147
},
@@ -186,7 +187,7 @@ impl Adapter {
186187
init_uia();
187188

188189
let state = State::Inactive {
189-
hwnd,
190+
hwnd: hwnd.into(),
190191
is_window_focused,
191192
action_handler,
192193
};
@@ -356,15 +357,15 @@ fn normalize_objid(lparam: LPARAM) -> i32 {
356357
}
357358

358359
struct WmGetObjectResult {
359-
hwnd: HWND,
360+
hwnd: WindowHandle,
360361
wparam: WPARAM,
361362
lparam: LPARAM,
362363
el: IRawElementProviderSimple,
363364
}
364365

365366
impl From<WmGetObjectResult> for LRESULT {
366367
fn from(this: WmGetObjectResult) -> Self {
367-
unsafe { UiaReturnRawElementProvider(this.hwnd, this.wparam, this.lparam, &this.el) }
368+
unsafe { UiaReturnRawElementProvider(this.hwnd.0, this.wparam, this.lparam, &this.el) }
368369
}
369370
}
370371

platforms/windows/src/context.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
use accesskit::{ActionHandler, ActionRequest, Point};
77
use accesskit_consumer::Tree;
88
use std::sync::{atomic::AtomicBool, Arc, Mutex, RwLock, RwLockReadGuard};
9-
use windows::Win32::Foundation::*;
109

11-
use crate::util::*;
10+
use crate::{util::*, window_handle::WindowHandle};
1211

1312
pub(crate) trait ActionHandlerNoMut {
1413
fn do_action(&self, request: ActionRequest);
@@ -29,15 +28,15 @@ impl<H: ActionHandler + Send> ActionHandlerNoMut for ActionHandlerWrapper<H> {
2928
}
3029

3130
pub(crate) struct Context {
32-
pub(crate) hwnd: HWND,
31+
pub(crate) hwnd: WindowHandle,
3332
pub(crate) tree: RwLock<Tree>,
3433
pub(crate) action_handler: Arc<dyn ActionHandlerNoMut + Send + Sync>,
3534
pub(crate) is_placeholder: AtomicBool,
3635
}
3736

3837
impl Context {
3938
pub(crate) fn new(
40-
hwnd: HWND,
39+
hwnd: WindowHandle,
4140
tree: Tree,
4241
action_handler: Arc<dyn ActionHandlerNoMut + Send + Sync>,
4342
is_placeholder: bool,

platforms/windows/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod filters;
88
mod node;
99
mod text;
1010
mod util;
11+
mod window_handle;
1112

1213
mod adapter;
1314
pub use adapter::{Adapter, QueuedEvents};

0 commit comments

Comments
 (0)