Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove assertions from Windows dark mode code #1459

Merged
merged 9 commits into from
Mar 7, 2020
Prev Previous commit
Next Next commit
Pass dark mode by mutable reference
chrisduerr committed Mar 7, 2020

Verified

This commit was signed with the committer’s verified signature.
chrisduerr Christian Duerr
commit 946cb712e423f7f0e8b674b640e241816309341a
6 changes: 3 additions & 3 deletions src/platform_impl/windows/dark_mode.rs
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ pub fn try_dark_mode(hwnd: HWND) -> bool {
}
}

fn set_dark_mode_for_window(hwnd: HWND, is_dark_mode: bool) {
fn set_dark_mode_for_window(hwnd: HWND, is_dark_mode: &mut bool) {
// Uses Windows undocumented API SetWindowCompositionAttribute,
// as seen in win32-darkmode example linked at top of file.

@@ -123,11 +123,11 @@ fn set_dark_mode_for_window(hwnd: HWND, is_dark_mode: bool) {
if let Some(set_window_composition_attribute) = *SET_WINDOW_COMPOSITION_ATTRIBUTE {
unsafe {
// SetWindowCompositionAttribute needs a bigbool (i32), not bool.
let mut is_dark_mode_bigbool = is_dark_mode as BOOL;
let mut is_dark_mode_bigbool = is_dark_mode as &mut BOOL;

let mut data = WINDOWCOMPOSITIONATTRIBDATA {
Attrib: WCA_USEDARKMODECOLORS,
pvData: &mut is_dark_mode_bigbool as *mut _ as _,
pvData: is_dark_mode_bigbool as *mut _ as _,
cbData: std::mem::size_of_val(&is_dark_mode_bigbool) as _,
};