mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 05:21:31 +11:00
On Windows, fix icons specified on WindowBuilder
not taking effect for windows created after the first one (#2530)
This commit is contained in:
parent
8669c2e8df
commit
50bbc85dc3
|
@ -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 and macOS, add `Window::title` to query the current window title.
|
||||
- On Windows, fix focusing menubar when pressing `Alt`.
|
||||
- On MacOS, made `accepts_first_mouse` configurable.
|
||||
|
|
|
@ -794,7 +794,6 @@ impl<'a, T: 'static> InitData<'a, T> {
|
|||
let window_state = {
|
||||
let window_state = WindowState::new(
|
||||
&self.attributes,
|
||||
self.pl_attribs.taskbar_icon.clone(),
|
||||
scale_factor,
|
||||
current_theme,
|
||||
self.attributes.preferred_theme,
|
||||
|
@ -904,6 +903,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();
|
||||
|
||||
|
@ -957,7 +958,7 @@ where
|
|||
{
|
||||
let title = util::encode_wide(&attributes.title);
|
||||
|
||||
let class_name = register_window_class::<T>(&attributes.window_icon, &pl_attribs.taskbar_icon);
|
||||
let class_name = register_window_class::<T>();
|
||||
|
||||
let mut window_flags = WindowFlags::empty();
|
||||
window_flags.set(WindowFlags::MARKER_DECORATIONS, attributes.decorations);
|
||||
|
@ -1030,21 +1031,9 @@ where
|
|||
Ok(initdata.window.unwrap())
|
||||
}
|
||||
|
||||
unsafe fn register_window_class<T: 'static>(
|
||||
window_icon: &Option<Icon>,
|
||||
taskbar_icon: &Option<Icon>,
|
||||
) -> Vec<u16> {
|
||||
unsafe fn register_window_class<T: 'static>() -> Vec<u16> {
|
||||
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::Graphics::Gdi::COLOR_WINDOWFRAME;
|
||||
let class = WNDCLASSEXW {
|
||||
cbSize: mem::size_of::<WNDCLASSEXW>() as u32,
|
||||
|
@ -1053,12 +1042,12 @@ unsafe fn register_window_class<T: 'static>(
|
|||
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
|
||||
|
|
|
@ -123,7 +123,6 @@ pub enum ImeState {
|
|||
impl WindowState {
|
||||
pub(crate) fn new(
|
||||
attributes: &WindowAttributes,
|
||||
taskbar_icon: Option<Icon>,
|
||||
scale_factor: f64,
|
||||
current_theme: Theme,
|
||||
preferred_theme: Option<Theme>,
|
||||
|
@ -140,7 +139,7 @@ impl WindowState {
|
|||
max_size: attributes.max_inner_size,
|
||||
|
||||
window_icon: attributes.window_icon.clone(),
|
||||
taskbar_icon,
|
||||
taskbar_icon: None,
|
||||
|
||||
saved_window: None,
|
||||
scale_factor,
|
||||
|
|
Loading…
Reference in a new issue