Skip to content

Commit

Permalink
enh(weg, tb): handle option normally, instead of HWND::default
Browse files Browse the repository at this point in the history
  • Loading branch information
luriusTM committed Nov 12, 2024
1 parent c5efe63 commit 0c15c66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
23 changes: 12 additions & 11 deletions src/background/seelen_bar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct FancyToolbar {
pub theoretical_rect: RECT,
last_focus: Option<HWND>,
overlaped: bool,
last_overlapped_window: Window,
last_overlapped_window: Option<Window>,
}

impl Drop for FancyToolbar {
Expand All @@ -50,7 +50,7 @@ impl FancyToolbar {
last_focus: None,
theoretical_rect: RECT::default(),
overlaped: false,
last_overlapped_window: Window::from(HWND::default()),
last_overlapped_window: None,
})
}

Expand All @@ -75,7 +75,7 @@ impl FancyToolbar {

pub fn handle_overlaped_status(&mut self, hwnd: HWND) -> Result<()> {
let window = Window::from(hwnd);
let monitor_index = window.monitor().index()?;
let monitor = window.monitor();
let is_overlaped = self.is_overlapping(hwnd)?
&& !window.is_desktop()
&& !window.is_seelen_overlay()
Expand All @@ -88,16 +88,17 @@ impl FancyToolbar {

if settings.use_multi_monitor_overlap_logic {
if is_overlaped {
self.last_overlapped_window = window;
} else if self.last_overlapped_window.hwnd() != HWND::default()
&& self.last_overlapped_window != window
&& self.last_overlapped_window.monitor().index()? != monitor_index
&& Window::from(self.window.hwnd()?).monitor().index()? != monitor_index
{
return Ok(());
self.last_overlapped_window = Some(window);
} else if let Some(past_window) = self.last_overlapped_window {
if past_window != window
&& past_window.monitor() != monitor
&& Window::from(self.window.hwnd()?).monitor() != monitor
{
return Ok(());
}
}
} else {
self.last_overlapped_window = Window::from(HWND::default());
self.last_overlapped_window = None;
}

self.set_overlaped_status(is_overlaped)
Expand Down
23 changes: 12 additions & 11 deletions src/background/seelen_weg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct SeelenWegApp {
pub struct SeelenWeg {
window: WebviewWindow<Wry>,
overlaped: bool,
last_overlapped_window: Window,
last_overlapped_window: Option<Window>,
/// Is the rect that the dock should have when it isn't hidden
pub theoretical_rect: RECT,
}
Expand Down Expand Up @@ -235,7 +235,7 @@ impl SeelenWeg {
let weg = Self {
window: Self::create_window(postfix)?,
overlaped: false,
last_overlapped_window: Window::from(HWND::default()),
last_overlapped_window: None,
theoretical_rect: RECT::default(),
};

Expand Down Expand Up @@ -263,7 +263,7 @@ impl SeelenWeg {

pub fn handle_overlaped_status(&mut self, hwnd: HWND) -> Result<()> {
let window = Window::from(hwnd);
let monitor_index = window.monitor().index()?;
let monitor = window.monitor();
let is_overlaped = self.is_overlapping(hwnd)?
&& !window.is_desktop()
&& !window.is_seelen_overlay()
Expand All @@ -276,16 +276,17 @@ impl SeelenWeg {

if settings.use_multi_monitor_overlap_logic {
if is_overlaped {
self.last_overlapped_window = window;
} else if self.last_overlapped_window.hwnd() != HWND::default()
&& self.last_overlapped_window != window
&& self.last_overlapped_window.monitor().index()? != monitor_index
&& Window::from(self.window.hwnd()?).monitor().index()? != monitor_index
{
return Ok(());
self.last_overlapped_window = Some(window);
} else if let Some(past_window) = self.last_overlapped_window {
if past_window != window
&& past_window.monitor() != monitor
&& Window::from(self.window.hwnd()?).monitor() != monitor
{
return Ok(());
}
}
} else {
self.last_overlapped_window = Window::from(HWND::default());
self.last_overlapped_window = None;
}

self.set_overlaped_status(is_overlaped)
Expand Down

0 comments on commit 0c15c66

Please sign in to comment.