From aa9af2a7354e3fc3da686c9d55eac412543f02d1 Mon Sep 17 00:00:00 2001 From: Aether Date: Mon, 23 Feb 2026 21:33:03 +0000 Subject: [PATCH] Remove windows crate dependency - simplify window click-through --- src-tauri/src/window.rs | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src-tauri/src/window.rs b/src-tauri/src/window.rs index 2e790e0..a7cc498 100644 --- a/src-tauri/src/window.rs +++ b/src-tauri/src/window.rs @@ -1,4 +1,4 @@ -use tauri::{AppHandle, Manager, Window, WindowBuilder, WindowUrl, Position, PhysicalPosition}; +use tauri::{AppHandle, Manager, Window, WindowBuilder, WindowUrl}; use tracing::info; pub fn create_main_window(app: &AppHandle) -> Window { @@ -30,7 +30,7 @@ pub fn create_overlay_window(app: &AppHandle) { let x = (monitor_size.width as f64 - window_width) / 2.0; let y = monitor_size.height as f64 - window_height - 20.0; // 20px from bottom - let window = WindowBuilder::new( + let _window = WindowBuilder::new( app, "overlay", WindowUrl::App("/#/overlay".into()) @@ -43,8 +43,6 @@ pub fn create_overlay_window(app: &AppHandle) { .always_on_top(true) .skip_taskbar(true) .visible(false) - // Enable click-through when not focused - .focus() .build() .expect("Failed to create overlay window"); @@ -57,42 +55,15 @@ pub fn toggle_overlay_window(app: &AppHandle) { if is_visible { window.hide().ok(); - // Re-enable click-through - enable_click_through(&window, true); } else { window.show().ok(); window.set_always_on_top(true).ok(); window.set_focus().ok(); - // Disable click-through when active - enable_click_through(&window, false); } } else { create_overlay_window(app); if let Some(window) = app.get_window("overlay") { window.show().ok(); - enable_click_through(&window, false); - } - } -} - -fn enable_click_through(window: &Window, enable: bool) { - #[cfg(target_os = "windows")] - unsafe { - use windows::Win32::Foundation::HWND; - use windows::Win32::UI::WindowsAndMessaging::{SetWindowLongW, GetWindowLongW, GWL_EXSTYLE}; - use windows::Win32::UI::WindowsAndMessaging::{WS_EX_LAYERED, WS_EX_TRANSPARENT, WS_EX_NOACTIVATE}; - - let hwnd = HWND(window.hwnd().unwrap().0 as *mut _); - let ex_style = GetWindowLongW(hwnd, GWL_EXSTYLE); - - if enable { - // Enable click-through - SetWindowLongW(hwnd, GWL_EXSTYLE, - ex_style | WS_EX_LAYERED.0 as i32 | WS_EX_TRANSPARENT.0 as i32); - } else { - // Disable click-through - SetWindowLongW(hwnd, GWL_EXSTYLE, - ex_style & !(WS_EX_TRANSPARENT.0 as i32)); } } } @@ -102,13 +73,11 @@ pub fn show_overlay_window(app: &AppHandle) { window.show().ok(); window.set_always_on_top(true).ok(); window.set_focus().ok(); - enable_click_through(&window, false); } } pub fn hide_overlay_window(app: &AppHandle) { if let Some(window) = app.get_window("overlay") { window.hide().ok(); - enable_click_through(&window, true); } }