@@ -12,7 +12,6 @@ use std::time::{Duration, Instant};
12
12
use std:: { mem, panic, ptr} ;
13
13
14
14
use runner:: EventLoopRunner ;
15
- use windows_sys:: Win32 :: Devices :: HumanInterfaceDevice :: MOUSE_MOVE_RELATIVE ;
16
15
use windows_sys:: Win32 :: Foundation :: {
17
16
GetLastError , FALSE , HANDLE , HWND , LPARAM , LRESULT , POINT , RECT , WAIT_FAILED , WPARAM ,
18
17
} ;
@@ -37,7 +36,9 @@ use windows_sys::Win32::UI::Input::Touch::{
37
36
CloseTouchInputHandle , GetTouchInputInfo , TOUCHEVENTF_DOWN , TOUCHEVENTF_MOVE ,
38
37
TOUCHEVENTF_PRIMARY , TOUCHEVENTF_UP , TOUCHINPUT ,
39
38
} ;
40
- use windows_sys:: Win32 :: UI :: Input :: { RAWINPUT , RIM_TYPEKEYBOARD , RIM_TYPEMOUSE } ;
39
+ use windows_sys:: Win32 :: UI :: Input :: {
40
+ MOUSE_MOVE_RELATIVE , RAWINPUT , RIM_TYPEKEYBOARD , RIM_TYPEMOUSE ,
41
+ } ;
41
42
use windows_sys:: Win32 :: UI :: WindowsAndMessaging :: {
42
43
CreateWindowExW , DefWindowProcW , DestroyWindow , DispatchMessageW , GetClientRect , GetCursorPos ,
43
44
GetMenu , LoadCursorW , MsgWaitForMultipleObjectsEx , PeekMessageW , PostMessageW ,
@@ -402,7 +403,7 @@ impl EventLoop {
402
403
403
404
loop {
404
405
unsafe {
405
- if PeekMessageW ( & mut msg, 0 , 0 , 0 , PM_REMOVE ) == false . into ( ) {
406
+ if PeekMessageW ( & mut msg, ptr :: null_mut ( ) , 0 , 0 , PM_REMOVE ) == false . into ( ) {
406
407
break ;
407
408
}
408
409
@@ -634,10 +635,10 @@ fn create_high_resolution_timer() -> Option<OwnedHandle> {
634
635
// CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is supported only after
635
636
// Win10 1803 but it is already default option for rustc
636
637
// (std uses it to implement `std::thread::sleep`).
637
- if handle == 0 {
638
+ if handle. is_null ( ) {
638
639
None
639
640
} else {
640
- Some ( OwnedHandle :: from_raw_handle ( handle as * mut c_void ) )
641
+ Some ( OwnedHandle :: from_raw_handle ( handle) )
641
642
}
642
643
}
643
644
}
@@ -807,6 +808,7 @@ pub struct EventLoopProxy {
807
808
}
808
809
809
810
unsafe impl Send for EventLoopProxy { }
811
+ unsafe impl Sync for EventLoopProxy { }
810
812
811
813
impl EventLoopProxyProvider for EventLoopProxy {
812
814
fn wake_up ( & self ) {
@@ -894,12 +896,12 @@ fn create_event_target_window() -> HWND {
894
896
cbClsExtra : 0 ,
895
897
cbWndExtra : 0 ,
896
898
hInstance : util:: get_instance_handle ( ) ,
897
- hIcon : 0 ,
898
- hCursor : 0 , // must be null in order for cursor state to work properly
899
- hbrBackground : 0 ,
899
+ hIcon : ptr :: null_mut ( ) ,
900
+ hCursor : ptr :: null_mut ( ) , // must be null in order for cursor state to work properly
901
+ hbrBackground : ptr :: null_mut ( ) ,
900
902
lpszMenuName : ptr:: null ( ) ,
901
903
lpszClassName : THREAD_EVENT_TARGET_WINDOW_CLASS . as_ptr ( ) ,
902
- hIconSm : 0 ,
904
+ hIconSm : ptr :: null_mut ( ) ,
903
905
} ;
904
906
905
907
RegisterClassExW ( & class) ;
@@ -922,8 +924,8 @@ fn create_event_target_window() -> HWND {
922
924
0 ,
923
925
0 ,
924
926
0 ,
925
- 0 ,
926
- 0 ,
927
+ ptr :: null_mut ( ) ,
928
+ ptr :: null_mut ( ) ,
927
929
util:: get_instance_handle ( ) ,
928
930
ptr:: null ( ) ,
929
931
) ;
@@ -1245,7 +1247,7 @@ unsafe fn public_window_callback_inner(
1245
1247
// after marking `WM_PAINT` as handled.
1246
1248
result = ProcResult :: Value ( unsafe { DefWindowProcW ( window, msg, wparam, lparam) } ) ;
1247
1249
if std:: mem:: take ( & mut userdata. window_state_lock ( ) . redraw_requested ) {
1248
- unsafe { RedrawWindow ( window, ptr:: null ( ) , 0 , RDW_INTERNALPAINT ) } ;
1250
+ unsafe { RedrawWindow ( window, ptr:: null ( ) , ptr :: null_mut ( ) , RDW_INTERNALPAINT ) } ;
1249
1251
}
1250
1252
} ,
1251
1253
WM_WINDOWPOSCHANGING => {
@@ -1294,7 +1296,7 @@ unsafe fn public_window_callback_inner(
1294
1296
let new_monitor = unsafe { MonitorFromRect ( & new_rect, MONITOR_DEFAULTTONULL ) } ;
1295
1297
match fullscreen {
1296
1298
Fullscreen :: Borderless ( ref mut fullscreen_monitor) => {
1297
- if new_monitor != 0
1299
+ if !new_monitor . is_null ( )
1298
1300
&& fullscreen_monitor
1299
1301
. as_ref ( )
1300
1302
. map ( |monitor| new_monitor != monitor. hmonitor ( ) )
@@ -1741,7 +1743,7 @@ unsafe fn public_window_callback_inner(
1741
1743
} ,
1742
1744
1743
1745
WM_KEYUP | WM_SYSKEYUP => {
1744
- if msg == WM_SYSKEYUP && unsafe { GetMenu ( window) != 0 } {
1746
+ if msg == WM_SYSKEYUP && unsafe { ! GetMenu ( window) . is_null ( ) } {
1745
1747
// let Windows handle event if the window has a native menu, a modal event loop
1746
1748
// is started here on Alt key up.
1747
1749
result = ProcResult :: DefWindowProc ( wparam) ;
@@ -1973,7 +1975,7 @@ unsafe fn public_window_callback_inner(
1973
1975
// If it is the same as our window, then we're essentially retaining the capture. This
1974
1976
// can happen if `SetCapture` is called on our window when it already has the mouse
1975
1977
// capture.
1976
- if lparam != window {
1978
+ if lparam != window as isize {
1977
1979
userdata. window_state_lock ( ) . mouse . capture_count = 0 ;
1978
1980
}
1979
1981
result = ProcResult :: Value ( 0 ) ;
@@ -1986,7 +1988,7 @@ unsafe fn public_window_callback_inner(
1986
1988
1987
1989
let pcount = super :: loword ( wparam as u32 ) as usize ;
1988
1990
let mut inputs = Vec :: with_capacity ( pcount) ;
1989
- let htouch = lparam;
1991
+ let htouch = lparam as * mut _ ;
1990
1992
if unsafe {
1991
1993
GetTouchInputInfo (
1992
1994
htouch,
@@ -2309,7 +2311,7 @@ unsafe fn public_window_callback_inner(
2309
2311
Some ( selected_cursor) => {
2310
2312
let hcursor = match selected_cursor {
2311
2313
SelectedCursor :: Named ( cursor_icon) => unsafe {
2312
- LoadCursorW ( 0 , util:: to_windows_cursor ( cursor_icon) )
2314
+ LoadCursorW ( ptr :: null_mut ( ) , util:: to_windows_cursor ( cursor_icon) )
2313
2315
} ,
2314
2316
SelectedCursor :: Custom ( cursor) => cursor. as_raw_handle ( ) ,
2315
2317
} ;
@@ -2541,7 +2543,7 @@ unsafe fn public_window_callback_inner(
2541
2543
unsafe {
2542
2544
SetWindowPos (
2543
2545
window,
2544
- 0 ,
2546
+ ptr :: null_mut ( ) ,
2545
2547
new_outer_rect. left ,
2546
2548
new_outer_rect. top ,
2547
2549
new_outer_rect. right - new_outer_rect. left ,
@@ -2621,7 +2623,7 @@ unsafe extern "system" fn thread_event_target_callback(
2621
2623
let userdata = unsafe { Box :: from_raw ( userdata_ptr) } ;
2622
2624
2623
2625
if msg != WM_PAINT {
2624
- unsafe { RedrawWindow ( window, ptr:: null ( ) , 0 , RDW_INTERNALPAINT ) } ;
2626
+ unsafe { RedrawWindow ( window, ptr:: null ( ) , ptr :: null_mut ( ) , RDW_INTERNALPAINT ) } ;
2625
2627
}
2626
2628
2627
2629
let mut userdata_removed = false ;
@@ -2685,7 +2687,7 @@ unsafe fn handle_raw_input(userdata: &ThreadMsgTargetData, data: RAWINPUT) {
2685
2687
if data. header . dwType == RIM_TYPEMOUSE {
2686
2688
let mouse = unsafe { data. data . mouse } ;
2687
2689
2688
- if util:: has_flag ( mouse. usFlags as u32 , MOUSE_MOVE_RELATIVE ) {
2690
+ if util:: has_flag ( mouse. usFlags , MOUSE_MOVE_RELATIVE ) {
2689
2691
let x = mouse. lLastX as f64 ;
2690
2692
let y = mouse. lLastY as f64 ;
2691
2693
0 commit comments