diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b745bc148..9f2549cd45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre # Unreleased +- On Windows, fix icons specified on `WindowBuilder` not taking effect for windows created after the first one. - On Windows, fix focusing menubar when pressing `Alt`. - On MacOS, made `accepts_first_mouse` configurable. - Migrated `WindowBuilderExtUnix::with_resize_increments` to `WindowBuilder`. diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index cb57a3ca8d..127f155c77 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -786,7 +786,8 @@ impl<'a, T: 'static> InitData<'a, T> { let window_state = { let window_state = WindowState::new( &self.attributes, - self.pl_attribs.taskbar_icon.clone(), + // Will be set later in on_create + None, scale_factor, current_theme, self.attributes.preferred_theme, @@ -896,6 +897,8 @@ impl<'a, T: 'static> InitData<'a, T> { } win.set_skip_taskbar(self.pl_attribs.skip_taskbar); + win.set_window_icon(self.attributes.window_icon.clone()); + win.set_taskbar_icon(self.pl_attribs.taskbar_icon.clone()); let attributes = self.attributes.clone(); @@ -949,7 +952,7 @@ where { let title = util::encode_wide(&attributes.title); - let class_name = register_window_class::(&attributes.window_icon, &pl_attribs.taskbar_icon); + let class_name = register_window_class::(); let mut window_flags = WindowFlags::empty(); window_flags.set(WindowFlags::MARKER_DECORATIONS, attributes.decorations); @@ -1022,21 +1025,9 @@ where Ok(initdata.window.unwrap()) } -unsafe fn register_window_class( - window_icon: &Option, - taskbar_icon: &Option, -) -> Vec { +unsafe fn register_window_class() -> Vec { let class_name = util::encode_wide("Window Class"); - let h_icon = taskbar_icon - .as_ref() - .map(|icon| icon.inner.as_raw_handle()) - .unwrap_or(0); - let h_icon_small = window_icon - .as_ref() - .map(|icon| icon.inner.as_raw_handle()) - .unwrap_or(0); - use windows_sys::Win32::UI::WindowsAndMessaging::COLOR_WINDOWFRAME; let class = WNDCLASSEXW { cbSize: mem::size_of::() as u32, @@ -1045,12 +1036,12 @@ unsafe fn register_window_class( cbClsExtra: 0, cbWndExtra: 0, hInstance: util::get_instance_handle(), - hIcon: h_icon, + hIcon: 0, hCursor: 0, // must be null in order for cursor state to work properly hbrBackground: COLOR_WINDOWFRAME as _, lpszMenuName: ptr::null(), lpszClassName: class_name.as_ptr(), - hIconSm: h_icon_small, + hIconSm: 0, }; // We ignore errors because registering the same window class twice would trigger