Skip to content

Commit

Permalink
always redraw titlebar
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Sep 19, 2024
1 parent e595125 commit 0b1daad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
16 changes: 5 additions & 11 deletions src/platform_impl/windows/dark_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@ fn refresh_immersive_color_policy_state() {

/// Attempt to set a theme on a window, if necessary.
/// Returns the theme that was picked
pub fn try_window_theme(
hwnd: HWND,
preferred_theme: Option<Theme>,
redraw_title_bar: bool,
) -> Theme {
pub fn try_window_theme(hwnd: HWND, preferred_theme: Option<Theme>) -> Theme {
if *DARK_MODE_SUPPORTED {
let is_dark_mode = match preferred_theme {
Some(theme) => theme == Theme::Dark,
Expand All @@ -135,7 +131,7 @@ pub fn try_window_theme(
false => Theme::Light,
};

refresh_titlebar_theme_color(hwnd, is_dark_mode, redraw_title_bar);
refresh_titlebar_theme_color(hwnd, is_dark_mode);

theme
} else {
Expand Down Expand Up @@ -165,7 +161,7 @@ pub fn allow_dark_mode_for_window(hwnd: HWND, is_dark_mode: bool) {
}
}

fn refresh_titlebar_theme_color(hwnd: HWND, is_dark_mode: bool, redraw_title_bar: bool) {
fn refresh_titlebar_theme_color(hwnd: HWND, is_dark_mode: bool) {
if let Some(ver) = *WIN10_BUILD_VERSION {
if ver < 17763 {
let mut is_dark_mode_bigbool: i32 = is_dark_mode.into();
Expand All @@ -192,10 +188,8 @@ fn refresh_titlebar_theme_color(hwnd: HWND, is_dark_mode: bool, redraw_title_bar
std::mem::size_of::<BOOL>() as u32,
);
}
if redraw_title_bar {
unsafe { DefWindowProcW(hwnd, WM_NCACTIVATE, None, None) };
unsafe { DefWindowProcW(hwnd, WM_NCACTIVATE, WPARAM(true.into()), None) };
}
unsafe { DefWindowProcW(hwnd, WM_NCACTIVATE, None, None) };
unsafe { DefWindowProcW(hwnd, WM_NCACTIVATE, WPARAM(true.into()), None) };
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,6 @@ unsafe fn public_window_callback_inner<T: 'static>(
let new_theme = try_window_theme(
window,
preferred_theme.or(*subclass_input.event_loop_preferred_theme.lock()),
false,
);
let mut window_state = subclass_input.window_state.lock();

Expand Down
1 change: 0 additions & 1 deletion src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,6 @@ unsafe fn init<T: 'static>(
attributes
.preferred_theme
.or(*event_loop.preferred_theme.lock()),
false,
);

let window_state = {
Expand Down

0 comments on commit 0b1daad

Please sign in to comment.