Skip to content

Commit c8a1b0e

Browse files
author
Matt Campbell
authored
Revert "chore!(platforms/windows): Migrate to windows-rs 0.37 (#102)" (#106)
This reverts commit a3eaec6. I got the merge wrong. I screwed up the conventional commit message, and I should probably include the bit about renaming `Event to `QueuedEvent`. I will re-merge next.
1 parent a3eaec6 commit c8a1b0e

File tree

7 files changed

+186
-147
lines changed

7 files changed

+186
-147
lines changed

Cargo.lock

Lines changed: 53 additions & 24 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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ libc = "0.2.112"
1919
paste = "1.0"
2020

2121
[dependencies.windows]
22-
version = "0.37.0"
22+
version = "0.27.0"
2323
features = [
2424
"alloc",
25-
"implement",
25+
"build",
26+
"std",
2627
"Win32_Foundation",
2728
"Win32_Graphics_Gdi",
2829
"Win32_System_Com",

platforms/windows/examples/hello_world.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ use windows::{
2121
lazy_static! {
2222
static ref WIN32_INSTANCE: HINSTANCE = {
2323
let instance = unsafe { GetModuleHandleW(None) };
24-
instance.unwrap()
24+
if instance.0 == 0 {
25+
let result: Result<()> = Err(Error::from_win32());
26+
result.unwrap();
27+
}
28+
instance
2529
};
2630

2731
static ref DEFAULT_CURSOR: HCURSOR = {
2832
let cursor = unsafe { LoadCursorW(None, IDC_ARROW) };
29-
cursor.unwrap()
33+
if cursor.0 == 0 {
34+
let result: Result<()> = Err(Error::from_win32());
35+
result.unwrap();
36+
}
37+
cursor
3038
};
3139

3240
static ref WINDOW_CLASS_ATOM: u16 = {
@@ -40,7 +48,7 @@ lazy_static! {
4048
let wc = WNDCLASSW {
4149
hCursor: *DEFAULT_CURSOR,
4250
hInstance: *WIN32_INSTANCE,
43-
lpszClassName: PCWSTR(class_name_wsz.as_ptr() as _),
51+
lpszClassName: PWSTR(class_name_wsz.as_ptr() as _),
4452
style: CS_HREDRAW | CS_VREDRAW,
4553
lpfnWndProc: Some(wndproc),
4654
..Default::default()
@@ -326,7 +334,7 @@ fn create_window(title: &str, initial_state: TreeUpdate, initial_focus: NodeId)
326334
let window = unsafe {
327335
CreateWindowExW(
328336
Default::default(),
329-
PCWSTR(*WINDOW_CLASS_ATOM as usize as _),
337+
PWSTR(*WINDOW_CLASS_ATOM as usize as _),
330338
title,
331339
WS_OVERLAPPEDWINDOW,
332340
CW_USEDEFAULT,

platforms/windows/src/adapter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use windows::Win32::{
1515

1616
use crate::{
1717
node::{PlatformNode, ResolvedPlatformNode},
18-
util::QueuedEvent,
18+
util::Event,
1919
};
2020

2121
pub struct Adapter<Source = Box<dyn FnOnce() -> TreeUpdate>>
@@ -88,7 +88,7 @@ impl<Source: Into<TreeUpdate>> Adapter<Source> {
8888
} => {
8989
let platform_node = PlatformNode::new(&new_node, self.hwnd);
9090
let element: IRawElementProviderSimple = platform_node.into();
91-
queue.push(QueuedEvent::Simple {
91+
queue.push(Event::Simple {
9292
element,
9393
event_id: UIA_AutomationFocusChangedEventId,
9494
});
@@ -176,7 +176,7 @@ fn force_init_uia() {
176176

177177
/// Events generated by a tree update.
178178
#[must_use = "events must be explicitly raised"]
179-
pub struct QueuedEvents(Vec<QueuedEvent>);
179+
pub struct QueuedEvents(Vec<Event>);
180180

181181
impl QueuedEvents {
182182
/// Raise all queued events synchronously.
@@ -192,10 +192,10 @@ impl QueuedEvents {
192192
pub fn raise(self) {
193193
for event in self.0 {
194194
match event {
195-
QueuedEvent::Simple { element, event_id } => {
195+
Event::Simple { element, event_id } => {
196196
unsafe { UiaRaiseAutomationEvent(element, event_id) }.unwrap();
197197
}
198-
QueuedEvent::PropertyChanged {
198+
Event::PropertyChanged {
199199
element,
200200
property_id,
201201
old_value,

0 commit comments

Comments
 (0)