mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-02 14:50:04 -04:00
Fix Windows' try_theme returning Theme::Dark when new theme is light (#1861)
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
- On Android, unimplemented events are marked as unhandled on the native event loop.
|
- On Android, unimplemented events are marked as unhandled on the native event loop.
|
||||||
- On Windows, added `WindowBuilderExtWindows::with_menu` to set a custom menu at window creation time.
|
- On Windows, added `WindowBuilderExtWindows::with_menu` to set a custom menu at window creation time.
|
||||||
- On Android, bump `ndk` and `ndk-glue` to 0.3: use predefined constants for event `ident`.
|
- On Android, bump `ndk` and `ndk-glue` to 0.3: use predefined constants for event `ident`.
|
||||||
|
- On Windows, fixed `WindowEvent::ThemeChanged` not properly firing and fixed `Window::theme` returning the wrong theme.
|
||||||
- On Web, added support for `DeviceEvent::MouseMotion` to listen for relative mouse movements.
|
- On Web, added support for `DeviceEvent::MouseMotion` to listen for relative mouse movements.
|
||||||
|
|
||||||
# 0.24.0 (2020-12-09)
|
# 0.24.0 (2020-12-09)
|
||||||
|
|||||||
@@ -81,16 +81,20 @@ pub fn try_theme(hwnd: HWND, preferred_theme: Option<Theme>) -> Theme {
|
|||||||
None => should_use_dark_mode(),
|
None => should_use_dark_mode(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let theme_name = if is_dark_mode {
|
let theme = if is_dark_mode {
|
||||||
DARK_THEME_NAME.as_ptr()
|
Theme::Dark
|
||||||
} else {
|
} else {
|
||||||
LIGHT_THEME_NAME.as_ptr()
|
Theme::Light
|
||||||
|
};
|
||||||
|
let theme_name = match theme {
|
||||||
|
Theme::Dark => DARK_THEME_NAME.as_ptr(),
|
||||||
|
Theme::Light => LIGHT_THEME_NAME.as_ptr(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let status = unsafe { uxtheme::SetWindowTheme(hwnd, theme_name as _, std::ptr::null()) };
|
let status = unsafe { uxtheme::SetWindowTheme(hwnd, theme_name as _, std::ptr::null()) };
|
||||||
|
|
||||||
if status == S_OK && set_dark_mode_for_window(hwnd, is_dark_mode) {
|
if status == S_OK && set_dark_mode_for_window(hwnd, is_dark_mode) {
|
||||||
return Theme::Dark;
|
return theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user