diff --git a/src/apps/seelenweg-hitbox/index.tsx b/src/apps/seelenweg-hitbox/index.tsx index 573ba3f6..899a5640 100644 --- a/src/apps/seelenweg-hitbox/index.tsx +++ b/src/apps/seelenweg-hitbox/index.tsx @@ -1,5 +1,4 @@ import { wrapConsole } from '../shared/ConsoleWrapper'; -import { invoke } from '@tauri-apps/api/core'; import { PhysicalPosition, PhysicalSize } from '@tauri-apps/api/dpi'; import { emitTo } from '@tauri-apps/api/event'; import { getCurrent } from '@tauri-apps/api/webviewWindow'; @@ -16,12 +15,9 @@ async function Main() { document.body.addEventListener('mousemove', () => { emitTo(main, 'mouseenter'); - invoke('ensure_hitboxes_zorder'); }); async function onClick(e: MouseEvent | TouchEvent) { - invoke('ensure_hitboxes_zorder'); - let x = 0; let y = 0; if (e instanceof MouseEvent) { diff --git a/src/apps/toolbar-hitbox/index.tsx b/src/apps/toolbar-hitbox/index.tsx index 29674c99..edfc6d92 100644 --- a/src/apps/toolbar-hitbox/index.tsx +++ b/src/apps/toolbar-hitbox/index.tsx @@ -1,5 +1,4 @@ import { wrapConsole } from '../shared/ConsoleWrapper'; -import { invoke } from '@tauri-apps/api/core'; import { emitTo } from '@tauri-apps/api/event'; import { getCurrent } from '@tauri-apps/api/webviewWindow'; @@ -14,8 +13,6 @@ async function Main() { await getCurrent().show(); async function onClick(e: MouseEvent | TouchEvent) { - invoke('ensure_hitboxes_zorder'); - let x = 0; let y = 0; if (e instanceof MouseEvent) { @@ -34,7 +31,6 @@ async function Main() { document.body.addEventListener('mousemove', () => { emitTo(main, 'mouseenter'); - invoke('ensure_hitboxes_zorder'); }); document.body.addEventListener('click', onClick); document.body.addEventListener('touchend', onClick); diff --git a/src/background/exposed.rs b/src/background/exposed.rs index bce70afd..f9bc46e8 100644 --- a/src/background/exposed.rs +++ b/src/background/exposed.rs @@ -131,22 +131,6 @@ fn is_dev_mode() -> bool { tauri::is_dev() } -#[command] -fn ensure_hitboxes_zorder() { - std::thread::spawn(|| -> Result<()> { - let seelen = trace_lock!(SEELEN); - for monitor in seelen.monitors() { - if let Some(toolbar) = monitor.toolbar() { - toolbar.ensure_hitbox_zorder()?; - } - if let Some(weg) = monitor.weg() { - weg.ensure_hitbox_zorder()?; - } - } - Ok(()) - }); -} - #[command] fn get_accent_color() -> String { let mut colorization: u32 = 0; @@ -222,7 +206,6 @@ pub fn register_invoke_handler(app_builder: Builder) -> Builder { get_user_envs, show_app_settings, reload_apps_configurations, - ensure_hitboxes_zorder, switch_workspace, // Auto Start set_auto_start, diff --git a/src/background/seelen_bar/mod.rs b/src/background/seelen_bar/mod.rs index 1860e753..08436f2e 100644 --- a/src/background/seelen_bar/mod.rs +++ b/src/background/seelen_bar/mod.rs @@ -14,9 +14,7 @@ use tauri::{AppHandle, Manager, WebviewWindow, Wry}; use windows::Win32::{ Foundation::HWND, Graphics::Gdi::HMONITOR, - UI::WindowsAndMessaging::{ - HWND_TOPMOST, SWP_ASYNCWINDOWPOS, SWP_NOSIZE, SW_HIDE, SW_SHOWNOACTIVATE, - }, + UI::WindowsAndMessaging::{SWP_ASYNCWINDOWPOS, SWP_NOSIZE, SW_HIDE, SW_SHOWNOACTIVATE}, }; pub struct FancyToolbar { @@ -79,10 +77,6 @@ impl FancyToolbar { )?; Ok(()) } - - pub fn ensure_hitbox_zorder(&self) -> Result<()> { - WindowsApi::bring_to(HWND(self.window.hwnd()?.0), HWND_TOPMOST) - } } // statics @@ -166,6 +160,7 @@ impl FancyToolbar { .shadow(false) .skip_taskbar(true) .always_on_top(true) + .owner(&hitbox)? .build()?, }; diff --git a/src/background/seelen_weg/mod.rs b/src/background/seelen_weg/mod.rs index 6419883e..f2a5d4c3 100644 --- a/src/background/seelen_weg/mod.rs +++ b/src/background/seelen_weg/mod.rs @@ -14,8 +14,8 @@ use windows::Win32::{ Foundation::{BOOL, HWND, LPARAM, RECT}, Graphics::Gdi::HMONITOR, UI::WindowsAndMessaging::{ - EnumWindows, GetParent, HWND_TOPMOST, SHOW_WINDOW_CMD, SWP_NOACTIVATE, SW_HIDE, - SW_SHOWNOACTIVATE, SW_SHOWNORMAL, WS_EX_APPWINDOW, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, + EnumWindows, GetParent, SHOW_WINDOW_CMD, SWP_NOACTIVATE, SW_HIDE, SW_SHOWNOACTIVATE, + SW_SHOWNORMAL, WS_EX_APPWINDOW, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, }, }; @@ -230,10 +230,6 @@ impl SeelenWeg { Ok(()) } - pub fn ensure_hitbox_zorder(&self) -> Result<()> { - WindowsApi::bring_to(HWND(self.window.hwnd()?.0), HWND_TOPMOST) - } - pub fn is_real_window(hwnd: HWND, ignore_frame: bool) -> bool { if !WindowsApi::is_window_visible(hwnd) { return false; @@ -295,7 +291,7 @@ impl SeelenWeg { let monitor_info = WindowsApi::monitor_info(HMONITOR(monitor_id))?; let rc_work = monitor_info.monitorInfo.rcWork; - let hitbox = tauri::WebviewWindowBuilder::>::new( + let hitbox = tauri::WebviewWindowBuilder::new( manager, format!("{}/{}", Self::TARGET_HITBOX, monitor_id), tauri::WebviewUrl::App("seelenweg-hitbox/index.html".into()), @@ -312,7 +308,7 @@ impl SeelenWeg { .always_on_top(true) .build()?; - let window = tauri::WebviewWindowBuilder::>::new( + let window = tauri::WebviewWindowBuilder::new( manager, format!("{}/{}", Self::TARGET, monitor_id), tauri::WebviewUrl::App("seelenweg/index.html".into()), @@ -327,6 +323,7 @@ impl SeelenWeg { .shadow(false) .skip_taskbar(true) .always_on_top(true) + .owner(&hitbox)? .build()?; window.set_ignore_cursor_events(true)?;