Skip to content

Commit

Permalink
fix(windows): remove SetWindowTheme call with DarkMode_Explorer t…
Browse files Browse the repository at this point in the history
…heme (#849)

Fixes a glitch downstream in `muda` crate when manually drawing the menu bar
  • Loading branch information
amrbashir authored Nov 22, 2023
1 parent 397b70f commit 29b01bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changes/windows-dark-menubar-glitches.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On Windows, remove `SetWindowTheme` call with `DarkMode_Explorer` theme which fixes a glitch downstream in `muda` crate when manually drawing the menu bar.
10 changes: 2 additions & 8 deletions src/platform_impl/windows/dark_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use once_cell::sync::Lazy;
/// This is a simple implementation of support for Windows Dark Mode,
/// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode
use windows::{
core::{s, w, PCSTR, PCWSTR, PSTR},
core::{s, w, PCSTR, PSTR},
Win32::{
Foundation::{BOOL, HANDLE, HMODULE, HWND},
System::LibraryLoader::*,
UI::{Accessibility::*, Controls::SetWindowTheme, WindowsAndMessaging::*},
UI::{Accessibility::*, WindowsAndMessaging::*},
},
};

Expand Down Expand Up @@ -141,12 +141,6 @@ pub fn try_window_theme(hwnd: HWND, preferred_theme: Option<Theme>) -> Theme {
false => Theme::Light,
};

let theme_name = match theme {
Theme::Dark => w!("DarkMode_Explorer"),
Theme::Light => w!(""),
};
let _ = unsafe { SetWindowTheme(hwnd, theme_name, PCWSTR::null()) };

allow_dark_mode_for_window(hwnd, is_dark_mode);
refresh_titlebar_theme_color(hwnd, is_dark_mode);

Expand Down

0 comments on commit 29b01bf

Please sign in to comment.