@@ -45,7 +45,7 @@ const CLOSE_BTN_RECT_EXTRA: RECT = RECT {
4545 bottom : CLOSE_BTN_RECT . bottom + 8 ,
4646} ;
4747
48- static ACTIVE_NOTIFICATIONS : Lazy < Mutex < Vec < HWND > > > = Lazy :: new ( || Mutex :: new ( Vec :: new ( ) ) ) ;
48+ static ACTIVE_NOTIFICATIONS : Lazy < Mutex < Vec < isize > > > = Lazy :: new ( || Mutex :: new ( Vec :: new ( ) ) ) ;
4949static PRIMARY_MONITOR : Lazy < Mutex < MONITORINFOEXW > > =
5050 Lazy :: new ( || unsafe { Mutex :: new ( util:: get_monitor_info ( util:: primary_monitor ( ) ) ) } ) ;
5151
@@ -159,18 +159,18 @@ impl Notification {
159159 style : CS_HREDRAW | CS_VREDRAW | CS_OWNDC ,
160160 cbClsExtra : 0 ,
161161 cbWndExtra : 0 ,
162- hIcon : 0 ,
163- hCursor : 0 , // must be null in order for cursor state to work properly
162+ hIcon : std :: ptr :: null_mut ( ) ,
163+ hCursor : std :: ptr :: null_mut ( ) , // must be null in order for cursor state to work properly
164164 lpszMenuName : ptr:: null ( ) ,
165- hIconSm : 0 ,
165+ hIconSm : std :: ptr :: null_mut ( ) ,
166166 } ;
167167 RegisterClassExW ( & wnd_class) ;
168168
169169 if let Ok ( pm) = PRIMARY_MONITOR . lock ( ) {
170170 let RECT { right, bottom, .. } = pm. monitorInfo . rcWork ;
171171
172172 let data = WindowData {
173- window : 0 ,
173+ window : std :: ptr :: null_mut ( ) ,
174174 mouse_hovering_close_btn : false ,
175175 notification : self . clone ( ) ,
176176 } ;
@@ -184,19 +184,19 @@ impl Notification {
184184 bottom - NH - 15 ,
185185 NW ,
186186 NH ,
187- 0 ,
188- 0 ,
187+ std :: ptr :: null_mut ( ) ,
188+ std :: ptr :: null_mut ( ) ,
189189 hinstance,
190190 Box :: into_raw ( Box :: new ( data) ) as _ ,
191191 ) ;
192192
193- if hwnd == 0 {
193+ if hwnd. is_null ( ) {
194194 return Err ( GetLastError ( ) ) ;
195195 }
196196
197197 // reposition active notifications and make room for new one
198198 if let Ok ( mut active_notifications) = ACTIVE_NOTIFICATIONS . lock ( ) {
199- active_notifications. push ( hwnd) ;
199+ active_notifications. push ( hwnd as _ ) ;
200200 reposition_notifications ( & active_notifications, right, bottom)
201201 }
202202
@@ -208,6 +208,7 @@ impl Notification {
208208 }
209209
210210 let timeout = self . timeout ;
211+ let hwnd = hwnd as isize ;
211212 thread:: spawn ( move || {
212213 thread:: sleep ( Duration :: from_millis ( timeout. into ( ) ) ) ;
213214 if timeout != Timeout :: Never {
@@ -221,15 +222,15 @@ impl Notification {
221222 }
222223}
223224
224- unsafe fn close_notification ( hwnd : HWND ) {
225- ShowWindow ( hwnd, SW_HIDE ) ;
226- CloseWindow ( hwnd) ;
225+ unsafe fn close_notification ( hwnd : isize ) {
226+ ShowWindow ( hwnd as _ , SW_HIDE ) ;
227+ CloseWindow ( hwnd as _ ) ;
227228
228229 // We can NOT call `DestroyWindow` from this window
229230 // Sending WM_CLOSE will by default make the windows call it on itself.
230231 // Note WM_DESTROY should not be sent directly as it would create a leak
231232 // see https://devblogs.microsoft.com/oldnewthing/20110926-00/?p=9553
232- SendMessageA ( hwnd, WM_CLOSE , 0 , 0 ) ;
233+ SendMessageA ( hwnd as _ , WM_CLOSE , 0 , 0 ) ;
233234
234235 if let Ok ( mut active_notifications) = ACTIVE_NOTIFICATIONS . lock ( ) {
235236 if let Some ( index) = active_notifications. iter ( ) . position ( |e| * e == hwnd) {
@@ -249,8 +250,8 @@ unsafe fn reposition_notifications(notifications: &[isize], right: i32, bottom:
249250 let mut i = notifications. len ( ) as i32 ;
250251 for & hwnd in notifications. iter ( ) {
251252 SetWindowPos (
252- hwnd,
253- 0 ,
253+ hwnd as _ ,
254+ std :: ptr :: null_mut ( ) ,
254255 right - NW - 15 ,
255256 bottom - 15 - ( NH * i) - 10 * ( i - 1 ) ,
256257 0 ,
@@ -299,7 +300,7 @@ pub unsafe extern "system" fn window_proc(
299300 fErase : 0 ,
300301 fIncUpdate : 0 ,
301302 fRestore : 0 ,
302- hdc : 0 ,
303+ hdc : std :: ptr :: null_mut ( ) ,
303304 rcPaint : RECT {
304305 bottom : 0 ,
305306 left : 0 ,
@@ -318,7 +319,17 @@ pub unsafe extern "system" fn window_proc(
318319 notification. icon_width ,
319320 notification. icon_height ,
320321 ) ;
321- DrawIconEx ( hdc, NM , NM , hicon, NIS , NIS , 0 , 0 , DI_NORMAL ) ;
322+ DrawIconEx (
323+ hdc,
324+ NM ,
325+ NM ,
326+ hicon,
327+ NIS ,
328+ NIS ,
329+ 0 ,
330+ std:: ptr:: null_mut ( ) ,
331+ DI_NORMAL ,
332+ ) ;
322333 }
323334
324335 // draw notification close button
@@ -406,7 +417,10 @@ pub unsafe extern "system" fn window_proc(
406417 let ( x, y) = ( GET_X_LPARAM ( lparam) , GET_Y_LPARAM ( lparam) ) ;
407418 let hit = util:: rect_contains ( CLOSE_BTN_RECT_EXTRA , x as i32 , y as i32 ) ;
408419
409- SetCursor ( LoadCursorW ( 0 , if hit { IDC_HAND } else { IDC_ARROW } ) ) ;
420+ SetCursor ( LoadCursorW (
421+ std:: ptr:: null_mut ( ) ,
422+ if hit { IDC_HAND } else { IDC_ARROW } ,
423+ ) ) ;
410424 if hit != ( * userdata) . mouse_hovering_close_btn {
411425 // only trigger redraw if the previous state is different than the new state
412426 InvalidateRect ( hwnd, std:: ptr:: null ( ) , 0 ) ;
@@ -420,7 +434,7 @@ pub unsafe extern "system" fn window_proc(
420434 let ( x, y) = ( GET_X_LPARAM ( lparam) , GET_Y_LPARAM ( lparam) ) ;
421435
422436 if util:: rect_contains ( CLOSE_BTN_RECT_EXTRA , x as i32 , y as i32 ) {
423- close_notification ( hwnd)
437+ close_notification ( hwnd as _ )
424438 }
425439
426440 DefWindowProcW ( hwnd, msg, wparam, lparam)
0 commit comments