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

chore(platforms/windows)!: Migrate to windows-rs 0.37 #109

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 24 additions & 53 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions platforms/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ libc = "0.2.112"
paste = "1.0"

[dependencies.windows]
version = "0.27.0"
version = "0.37.0"
features = [
"alloc",
"build",
"std",
"implement",
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_System_Com",
Expand Down
16 changes: 4 additions & 12 deletions platforms/windows/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,12 @@ use windows::{
lazy_static! {
static ref WIN32_INSTANCE: HINSTANCE = {
let instance = unsafe { GetModuleHandleW(None) };
if instance.0 == 0 {
let result: Result<()> = Err(Error::from_win32());
result.unwrap();
}
instance
instance.unwrap()
};

static ref DEFAULT_CURSOR: HCURSOR = {
let cursor = unsafe { LoadCursorW(None, IDC_ARROW) };
if cursor.0 == 0 {
let result: Result<()> = Err(Error::from_win32());
result.unwrap();
}
cursor
cursor.unwrap()
};

static ref WINDOW_CLASS_ATOM: u16 = {
Expand All @@ -48,7 +40,7 @@ lazy_static! {
let wc = WNDCLASSW {
hCursor: *DEFAULT_CURSOR,
hInstance: *WIN32_INSTANCE,
lpszClassName: PWSTR(class_name_wsz.as_ptr() as _),
lpszClassName: PCWSTR(class_name_wsz.as_ptr() as _),
style: CS_HREDRAW | CS_VREDRAW,
lpfnWndProc: Some(wndproc),
..Default::default()
Expand Down Expand Up @@ -334,7 +326,7 @@ fn create_window(title: &str, initial_state: TreeUpdate, initial_focus: NodeId)
let window = unsafe {
CreateWindowExW(
Default::default(),
PWSTR(*WINDOW_CLASS_ATOM as usize as _),
PCWSTR(*WINDOW_CLASS_ATOM as usize as _),
title,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
Expand Down
10 changes: 5 additions & 5 deletions platforms/windows/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use windows::Win32::{

use crate::{
node::{PlatformNode, ResolvedPlatformNode},
util::Event,
util::QueuedEvent,
};

pub struct Adapter<Source = Box<dyn FnOnce() -> TreeUpdate>>
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<Source: Into<TreeUpdate>> Adapter<Source> {
} => {
let platform_node = PlatformNode::new(&new_node, self.hwnd);
let element: IRawElementProviderSimple = platform_node.into();
queue.push(Event::Simple {
queue.push(QueuedEvent::Simple {
element,
event_id: UIA_AutomationFocusChangedEventId,
});
Expand Down Expand Up @@ -176,7 +176,7 @@ fn force_init_uia() {

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

impl QueuedEvents {
/// Raise all queued events synchronously.
Expand All @@ -192,10 +192,10 @@ impl QueuedEvents {
pub fn raise(self) {
for event in self.0 {
match event {
Event::Simple { element, event_id } => {
QueuedEvent::Simple { element, event_id } => {
unsafe { UiaRaiseAutomationEvent(element, event_id) }.unwrap();
}
Event::PropertyChanged {
QueuedEvent::PropertyChanged {
element,
property_id,
old_value,
Expand Down
Loading