File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ impl Adapter {
195
195
// than the client area of the window. DefWindowProc can handle those.
196
196
// First, cast the lparam to i32, to handle inconsistent conversion
197
197
// behavior in senders.
198
- let objid: i32 = ( lparam. 0 & 0xFFFFFFFF ) as _ ;
198
+ let objid = normalize_objid ( lparam) ;
199
199
if objid < 0 && objid != UiaRootObjectId && objid != OBJID_CLIENT . 0 {
200
200
return None ;
201
201
}
@@ -210,6 +210,15 @@ impl Adapter {
210
210
}
211
211
}
212
212
213
+ #[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
214
+ fn normalize_objid ( lparam : LPARAM ) -> i32 {
215
+ ( lparam. 0 & 0xFFFFFFFF ) as _
216
+ }
217
+ #[ cfg( not( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ) ]
218
+ fn normalize_objid ( lparam : LPARAM ) -> i32 {
219
+ lparam. 0 as _
220
+ }
221
+
213
222
struct WmGetObjectResult {
214
223
hwnd : HWND ,
215
224
wparam : WPARAM ,
Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ use windows::{
13
13
14
14
use crate :: { Adapter , QueuedEvents , UiaInitMarker } ;
15
15
16
+ // Work around a difference between the SetWindowLongPtrW API definition
17
+ // in windows-rs on 32-bit and 64-bit Windows.
18
+ #[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
19
+ type LongPtr = isize ;
20
+ #[ cfg( not( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ) ]
21
+ type LongPtr = i32 ;
22
+
16
23
const PROP_NAME : PCWSTR = w ! ( "AccessKitAdapter" ) ;
17
24
18
25
type LazyAdapter = Lazy < Adapter , Box < dyn FnOnce ( ) -> Adapter > > ;
@@ -70,7 +77,7 @@ impl SubclassImpl {
70
77
let result: Result < ( ) > = Err ( Error :: from_win32 ( ) ) ;
71
78
result. unwrap ( ) ;
72
79
}
73
- self . prev_wnd_proc = unsafe { transmute :: < isize , WNDPROC > ( result) } ;
80
+ self . prev_wnd_proc = unsafe { transmute :: < LongPtr , WNDPROC > ( result) } ;
74
81
}
75
82
76
83
fn uninstall ( & self ) {
@@ -81,7 +88,7 @@ impl SubclassImpl {
81
88
SetWindowLongPtrW (
82
89
self . hwnd ,
83
90
GWLP_WNDPROC ,
84
- transmute :: < WNDPROC , isize > ( self . prev_wnd_proc ) ,
91
+ transmute :: < WNDPROC , LongPtr > ( self . prev_wnd_proc ) ,
85
92
)
86
93
} ;
87
94
if result == 0 {
You can’t perform that action at this time.
0 commit comments