diff --git a/src/platform_impl/windows/dark_mode.rs b/src/platform_impl/windows/dark_mode.rs index 889bd0d5d6..ebbd516bdf 100644 --- a/src/platform_impl/windows/dark_mode.rs +++ b/src/platform_impl/windows/dark_mode.rs @@ -80,7 +80,7 @@ pub fn try_theme(hwnd: HWND, preferred_theme: Option) -> Theme { Theme::Light => LIGHT_THEME_NAME.as_ptr(), }; - let status = unsafe { SetWindowTheme(hwnd, theme_name, ptr::null_mut()) }; + let status = unsafe { SetWindowTheme(hwnd, theme_name, ptr::null()) }; if status == S_OK && set_dark_mode_for_window(hwnd, is_dark_mode) { return theme; @@ -168,7 +168,7 @@ fn is_high_contrast() -> bool { let mut hc = HIGHCONTRASTA { cbSize: 0, dwFlags: 0, - lpszDefaultScheme: ptr::null_mut(), + lpszDefaultScheme: ptr::null(), }; let ok = unsafe { diff --git a/src/platform_impl/windows/drop_handler.rs b/src/platform_impl/windows/drop_handler.rs index fc048c8622..cd36309955 100644 --- a/src/platform_impl/windows/drop_handler.rs +++ b/src/platform_impl/windows/drop_handler.rs @@ -180,18 +180,18 @@ impl FileDropHandler { let hdrop = medium.Anonymous.hGlobal; // The second parameter (0xFFFFFFFF) instructs the function to return the item count - let item_count = DragQueryFileW(hdrop, 0xFFFFFFFF, ptr::null_mut(), 0); + let item_count = DragQueryFileW(hdrop, 0xFFFFFFFF, ptr::null(), 0); for i in 0..item_count { // Get the length of the path string NOT including the terminating null character. // Previously, this was using a fixed size array of MAX_PATH length, but the // Windows API allows longer paths under certain circumstances. - let character_count = DragQueryFileW(hdrop, i, ptr::null_mut(), 0) as usize; + let character_count = DragQueryFileW(hdrop, i, ptr::null(), 0) as usize; let str_len = character_count + 1; // Fill path_buf with the null-terminated file name let mut path_buf = Vec::with_capacity(str_len); - DragQueryFileW(hdrop, i, path_buf.as_mut_ptr(), str_len as u32); + DragQueryFileW(hdrop, i, path_buf.as_ptr(), str_len as u32); path_buf.set_len(str_len); callback(OsString::from_wide(&path_buf[0..character_count]).into()); diff --git a/src/platform_impl/windows/event.rs b/src/platform_impl/windows/event.rs index fba3d5ae4c..2f5e2be4e2 100644 --- a/src/platform_impl/windows/event.rs +++ b/src/platform_impl/windows/event.rs @@ -119,12 +119,12 @@ pub fn get_pressed_keys() -> impl Iterator { } unsafe fn get_char(keyboard_state: &[u8; 256], v_key: u32, hkl: HKL) -> Option { - let mut unicode_bytes = [0u16; 5]; + let unicode_bytes = [0u16; 5]; let len = ToUnicodeEx( v_key, 0, keyboard_state.as_ptr(), - unicode_bytes.as_mut_ptr(), + unicode_bytes.as_ptr(), unicode_bytes.len() as _, 0, hkl, diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index d6791d1ebf..90f363c0e9 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -635,11 +635,11 @@ fn create_event_target_window() -> HWND { lpfnWndProc: Some(thread_event_target_callback::), cbClsExtra: 0, cbWndExtra: 0, - hInstance: GetModuleHandleW(ptr::null_mut()), + hInstance: GetModuleHandleW(ptr::null()), hIcon: 0, hCursor: 0, // must be null in order for cursor state to work properly hbrBackground: 0, - lpszMenuName: ptr::null_mut(), + lpszMenuName: ptr::null(), lpszClassName: THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr(), hIconSm: 0, }; @@ -661,7 +661,7 @@ fn create_event_target_window() -> HWND { // It is unclear why the bug is triggered by waiting for several hours. | WS_EX_TOOLWINDOW, THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr(), - ptr::null_mut(), + ptr::null(), WS_OVERLAPPED, 0, 0, @@ -669,8 +669,8 @@ fn create_event_target_window() -> HWND { 0, 0, 0, - GetModuleHandleW(ptr::null_mut()), - ptr::null_mut(), + GetModuleHandleW(ptr::null()), + ptr::null(), ); super::set_window_long( diff --git a/src/platform_impl/windows/icon.rs b/src/platform_impl/windows/icon.rs index eba349969b..2c65e835b8 100644 --- a/src/platform_impl/windows/icon.rs +++ b/src/platform_impl/windows/icon.rs @@ -22,11 +22,11 @@ impl Pixel { impl RgbaIcon { fn into_windows_icon(self) -> Result { - let mut rgba = self.rgba; + let rgba = self.rgba; let pixel_count = rgba.len() / PIXEL_SIZE; let mut and_mask = Vec::with_capacity(pixel_count); let pixels = - unsafe { std::slice::from_raw_parts_mut(rgba.as_mut_ptr() as *mut Pixel, pixel_count) }; + unsafe { std::slice::from_raw_parts_mut(rgba.as_ptr() as *mut Pixel, pixel_count) }; for pixel in pixels { and_mask.push(pixel.a.wrapping_sub(std::u8::MAX)); // invert alpha channel pixel.to_bgra(); @@ -81,12 +81,12 @@ impl WinIcon { // width / height of 0 along with LR_DEFAULTSIZE tells windows to load the default icon size let (width, height) = size.map(Into::into).unwrap_or((0, 0)); - let mut wide_path = util::encode_wide(path.as_ref()); + let wide_path = util::encode_wide(path.as_ref()); let handle = unsafe { LoadImageW( 0, - wide_path.as_mut_ptr(), + wide_path.as_ptr(), IMAGE_ICON, width as i32, height as i32, @@ -108,7 +108,7 @@ impl WinIcon { let (width, height) = size.map(Into::into).unwrap_or((0, 0)); let handle = unsafe { LoadImageW( - GetModuleHandleW(ptr::null_mut()), + GetModuleHandleW(ptr::null()), resource_id as PWSTR, IMAGE_ICON, width as i32, diff --git a/src/platform_impl/windows/monitor.rs b/src/platform_impl/windows/monitor.rs index 1b76128e29..1aacd58305 100644 --- a/src/platform_impl/windows/monitor.rs +++ b/src/platform_impl/windows/monitor.rs @@ -217,8 +217,8 @@ impl MonitorHandle { loop { unsafe { - let mut monitor_info = get_monitor_info(self.0).unwrap(); - let device_name = monitor_info.szDevice.as_mut_ptr(); + let monitor_info = get_monitor_info(self.0).unwrap(); + let device_name = monitor_info.szDevice.as_ptr(); let mut mode: DEVMODEW = mem::zeroed(); mode.dmSize = mem::size_of_val(&mode) as u16; if EnumDisplaySettingsExW(device_name, i, &mut mode, 0) == false.into() { diff --git a/src/platform_impl/windows/raw_input.rs b/src/platform_impl/windows/raw_input.rs index 5f2ffb9fc4..46a6683044 100644 --- a/src/platform_impl/windows/raw_input.rs +++ b/src/platform_impl/windows/raw_input.rs @@ -116,7 +116,7 @@ pub fn get_raw_input_device_name(handle: HANDLE) -> Option { GetRawInputDeviceInfoW( handle, RIDI_DEVICENAME, - name.as_mut_ptr() as _, + name.as_ptr() as _, &mut minimum_size, ) }; diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index f0aa226ca5..002471b0a1 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -101,9 +101,9 @@ impl Window { } pub fn set_title(&self, text: &str) { - let mut wide_text = util::encode_wide(text); + let wide_text = util::encode_wide(text); unsafe { - SetWindowTextW(self.hwnd(), wide_text.as_mut_ptr()); + SetWindowTextW(self.hwnd(), wide_text.as_ptr()); } } @@ -428,7 +428,7 @@ impl Window { &native_video_mode, 0, CDS_FULLSCREEN, - ptr::null_mut(), + ptr::null(), ) }; @@ -442,11 +442,11 @@ impl Window { | (&Some(Fullscreen::Exclusive(_)), &Some(Fullscreen::Borderless(_))) => { let res = unsafe { ChangeDisplaySettingsExW( - ptr::null_mut(), - ptr::null_mut(), + ptr::null(), + ptr::null(), 0, CDS_FULLSCREEN, - ptr::null_mut(), + ptr::null(), ) }; @@ -862,10 +862,9 @@ unsafe fn init( where T: 'static, { - let mut title = util::encode_wide(&attributes.title); + let title = util::encode_wide(&attributes.title); - let mut class_name = - register_window_class::(&attributes.window_icon, &pl_attribs.taskbar_icon); + let class_name = register_window_class::(&attributes.window_icon, &pl_attribs.taskbar_icon); let mut window_flags = WindowFlags::empty(); window_flags.set(WindowFlags::DECORATIONS, attributes.decorations); @@ -907,8 +906,8 @@ where let (style, ex_style) = window_flags.to_window_styles(); let handle = CreateWindowExW( ex_style, - class_name.as_mut_ptr(), - title.as_mut_ptr(), + class_name.as_ptr(), + title.as_ptr(), style, CW_USEDEFAULT, CW_USEDEFAULT, @@ -916,7 +915,7 @@ where CW_USEDEFAULT, parent.unwrap_or(0), pl_attribs.menu.unwrap_or(0), - GetModuleHandleW(ptr::null_mut()), + GetModuleHandleW(ptr::null()), &mut initdata as *mut _ as *mut _, ); @@ -938,7 +937,7 @@ unsafe fn register_window_class( window_icon: &Option, taskbar_icon: &Option, ) -> Vec { - let mut class_name = util::encode_wide("Window Class"); + let class_name = util::encode_wide("Window Class"); let h_icon = taskbar_icon .as_ref() @@ -955,12 +954,12 @@ unsafe fn register_window_class( lpfnWndProc: Some(super::event_loop::public_window_callback::), cbClsExtra: 0, cbWndExtra: 0, - hInstance: GetModuleHandleW(ptr::null_mut()), + hInstance: GetModuleHandleW(ptr::null()), hIcon: h_icon, hCursor: 0, // must be null in order for cursor state to work properly hbrBackground: 0, - lpszMenuName: ptr::null_mut(), - lpszClassName: class_name.as_mut_ptr(), + lpszMenuName: ptr::null(), + lpszClassName: class_name.as_ptr(), hIconSm: h_icon_small, }; @@ -983,7 +982,7 @@ impl Drop for ComInitialized { thread_local! { static COM_INITIALIZED: ComInitialized = { unsafe { - CoInitializeEx(ptr::null_mut(), COINIT_APARTMENTTHREADED); + CoInitializeEx(ptr::null(), COINIT_APARTMENTTHREADED); ComInitialized(ptr::null_mut()) } };