From e57b08d073ee2cd9a84d8effa49e895923bc3292 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 28 May 2024 17:14:28 -0700 Subject: [PATCH] feat(wm): unset unknown bits when using bitflags This commit switches to using the bitflags from_bits_truncate fn to handle applications like Foxit Reader which use garbage bits that aren't part of the Window Styles or Extended Window Styles Win32 specs. Any unknown bits that are not in the Win32 specs will be unset when this function is run. --- komorebi/src/window.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 1379721a..f1d66e2a 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -7,7 +7,6 @@ use std::fmt::Write as _; use std::time::Duration; use color_eyre::eyre; -use color_eyre::eyre::anyhow; use color_eyre::Result; use komorebi_core::config_generation::IdWithIdentifier; use komorebi_core::config_generation::MatchingRule; @@ -270,12 +269,12 @@ impl Window { pub fn style(self) -> Result { let bits = u32::try_from(WindowsApi::gwl_style(self.hwnd())?)?; - WindowStyle::from_bits(bits).ok_or_else(|| anyhow!("there is no gwl style")) + Ok(WindowStyle::from_bits_truncate(bits)) } pub fn ex_style(self) -> Result { let bits = u32::try_from(WindowsApi::gwl_ex_style(self.hwnd())?)?; - ExtendedWindowStyle::from_bits(bits).ok_or_else(|| anyhow!("there is no gwl style")) + Ok(ExtendedWindowStyle::from_bits_truncate(bits)) } pub fn title(self) -> Result {