Skip to content

Commit

Permalink
fix(weg/tb): stealing focus when fullscreened apps
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Oct 3, 2024
1 parent 9b09dd6 commit 49cacf2
Show file tree
Hide file tree
Showing 4 changed files with 437 additions and 435 deletions.
4 changes: 2 additions & 2 deletions src/background/seelen_bar/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ impl FancyToolbar {
WinEvent::SyntheticFullscreenStart(event_data) => {
let monitor = WindowsApi::monitor_from_window(self.window.hwnd()?);
if monitor == event_data.monitor {
self.hide()?;
self.send_to_bottom()?;
}
}
WinEvent::SyntheticFullscreenEnd(event_data) => {
let monitor = WindowsApi::monitor_from_window(self.window.hwnd()?);
if monitor == event_data.monitor {
self.show()?;
self.bring_to_top_most()?;
}
}
_ => {}
Expand Down
11 changes: 6 additions & 5 deletions src/background/seelen_bar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use tauri::{Emitter, Listener, Manager, WebviewWindow};
use windows::Win32::{
Foundation::{HWND, RECT},
Graphics::Gdi::HMONITOR,
UI::WindowsAndMessaging::{SWP_NOACTIVATE, SW_HIDE, SW_SHOWNOACTIVATE},
UI::WindowsAndMessaging::{HWND_BOTTOM, SWP_NOACTIVATE},
};

pub struct FancyToolbar {
Expand Down Expand Up @@ -82,13 +82,14 @@ impl FancyToolbar {
self.set_overlaped_status(is_overlaped)
}

pub fn hide(&mut self) -> Result<()> {
WindowsApi::show_window_async(self.window.hwnd()?, SW_HIDE)?;
pub fn send_to_bottom(&mut self) -> Result<()> {
self.window.set_always_on_top(false)?;
WindowsApi::bring_to(self.window.hwnd()?, HWND_BOTTOM)?;
Ok(())
}

pub fn show(&mut self) -> Result<()> {
WindowsApi::show_window_async(self.window.hwnd()?, SW_SHOWNOACTIVATE)?;
pub fn bring_to_top_most(&mut self) -> Result<()> {
self.window.set_always_on_top(true)?;
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions src/background/seelen_weg/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ impl SeelenWeg {
WinEvent::SyntheticFullscreenStart(event_data) => {
let monitor = WindowsApi::monitor_from_window(self.window.hwnd()?);
if monitor == event_data.monitor {
self.hide()?;
self.send_to_bottom()?;
}
}
WinEvent::SyntheticFullscreenEnd(event_data) => {
let monitor = WindowsApi::monitor_from_window(self.window.hwnd()?);
if monitor == event_data.monitor {
self.show()?;
self.bring_to_top_most()?;
}
}
_ => {}
Expand Down
Loading

0 comments on commit 49cacf2

Please sign in to comment.