From 744b2e4a64a43d9aba5608e7cdeb3cbbd8410c25 Mon Sep 17 00:00:00 2001 From: eythaann Date: Sun, 1 Sep 2024 23:54:06 -0500 Subject: [PATCH] fix(#64): can not restore settings window --- changelog.md | 3 +++ src/background/hook.rs | 2 +- src/background/seelen_bar/mod.rs | 3 ++- src/background/seelen_weg/handler.rs | 3 +-- src/background/seelen_weg/mod.rs | 7 +++++-- src/background/seelen_wm/mod.rs | 3 ++- src/background/windows_api/mod.rs | 17 ++++++++++------- src/background/windows_api/window.rs | 16 +++++++++++++--- 8 files changed, 37 insertions(+), 17 deletions(-) diff --git a/changelog.md b/changelog.md index 80c3e395..ce7ef5d9 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,9 @@ ### enhancements - clean weg items on load to remove duped items and apps/files that don't exist. +### fix +- can not restore settings window. + ## [1.10.3] ### features - add beta channel diff --git a/src/background/hook.rs b/src/background/hook.rs index 10f73cee..6b06fc78 100644 --- a/src/background/hook.rs +++ b/src/background/hook.rs @@ -117,7 +117,7 @@ impl HookManager { } let window = Window::from(origin); - if event == WinEvent::SystemForeground && !window.is_seelen_window() { + if event == WinEvent::SystemForeground && !window.is_seelen_overlay() { LAST_ACTIVE_NOT_SEELEN.store(origin.0, Ordering::Relaxed); } diff --git a/src/background/seelen_bar/mod.rs b/src/background/seelen_bar/mod.rs index 726dc204..a187a734 100644 --- a/src/background/seelen_bar/mod.rs +++ b/src/background/seelen_bar/mod.rs @@ -117,6 +117,7 @@ impl FancyToolbar { // statics impl FancyToolbar { + pub const TITLE: &'static str = "Seelen Fancy Toolbar"; const TARGET: &'static str = "fancy-toolbar"; /// Work area no works fine on multiple monitors @@ -180,7 +181,7 @@ impl FancyToolbar { label, tauri::WebviewUrl::App("toolbar/index.html".into()), ) - .title("Seelen Fancy Toolbar") + .title(Self::TITLE) .maximizable(false) .minimizable(false) .resizable(false) diff --git a/src/background/seelen_weg/handler.rs b/src/background/seelen_weg/handler.rs index c8e60300..f8ae5da4 100644 --- a/src/background/seelen_weg/handler.rs +++ b/src/background/seelen_weg/handler.rs @@ -10,7 +10,7 @@ use crate::{ }; use windows::Win32::{ Foundation::{HWND, LPARAM, WPARAM}, - UI::WindowsAndMessaging::{PostMessageW, SW_MINIMIZE, SW_RESTORE, SW_SHOWNORMAL, WM_CLOSE}, + UI::WindowsAndMessaging::{PostMessageW, SW_MINIMIZE, SW_RESTORE, WM_CLOSE}, }; use super::SeelenWeg; @@ -73,7 +73,6 @@ pub fn weg_toggle_window_state(hwnd: isize, exe_path: String) -> Result<()> { } if WindowsApi::is_iconic(hwnd) { - WindowsApi::show_window(hwnd, SW_SHOWNORMAL)?; WindowsApi::show_window(hwnd, SW_RESTORE)?; return Ok(()); } diff --git a/src/background/seelen_weg/mod.rs b/src/background/seelen_weg/mod.rs index d020ed0a..a7a89899 100644 --- a/src/background/seelen_weg/mod.rs +++ b/src/background/seelen_weg/mod.rs @@ -326,6 +326,9 @@ impl SeelenWeg { } impl SeelenWeg { + pub const TITLE: &'static str = "SeelenWeg"; + pub const TITLE_HITBOX: &'static str = "SeelenWeg Hitbox"; + const TARGET: &'static str = "seelenweg"; const TARGET_HITBOX: &'static str = "seelenweg-hitbox"; @@ -337,7 +340,7 @@ impl SeelenWeg { format!("{}/{}", Self::TARGET_HITBOX, postfix), tauri::WebviewUrl::App("seelenweg-hitbox/index.html".into()), ) - .title("SeelenWeg Hitbox") + .title(Self::TITLE_HITBOX) .maximizable(false) .minimizable(false) .resizable(false) @@ -355,7 +358,7 @@ impl SeelenWeg { format!("{}/{}", Self::TARGET, postfix), tauri::WebviewUrl::App("seelenweg/index.html".into()), ) - .title("SeelenWeg") + .title(Self::TITLE) .maximizable(false) .minimizable(false) .resizable(false) diff --git a/src/background/seelen_wm/mod.rs b/src/background/seelen_wm/mod.rs index 49dd4f0a..76a85544 100644 --- a/src/background/seelen_wm/mod.rs +++ b/src/background/seelen_wm/mod.rs @@ -54,6 +54,7 @@ impl Drop for WindowManager { } impl WindowManager { + pub const TITLE: &'static str = "Seelen Window Manager"; pub const TARGET: &'static str = "window-manager"; pub const VIRTUAL_PREVIEWS: [&'static str; 2] = [ "Virtual desktop switching preview", @@ -296,7 +297,7 @@ impl WindowManager { format!("{}/{}", Self::TARGET, monitor_id), tauri::WebviewUrl::App("seelen_wm/index.html".into()), ) - .title("Seelen Window Manager") + .title(Self::TITLE) .maximizable(false) .minimizable(false) .resizable(false) diff --git a/src/background/windows_api/mod.rs b/src/background/windows_api/mod.rs index fddddb09..5f878fe1 100644 --- a/src/background/windows_api/mod.rs +++ b/src/background/windows_api/mod.rs @@ -72,10 +72,10 @@ use windows::{ GetWindow, GetWindowLongW, GetWindowRect, GetWindowTextW, GetWindowThreadProcessId, IsIconic, IsWindow, IsWindowVisible, IsZoomed, SetForegroundWindow, SetWindowPos, ShowWindow, ShowWindowAsync, SystemParametersInfoW, ANIMATIONINFO, GWL_EXSTYLE, - GWL_STYLE, GW_OWNER, SET_WINDOW_POS_FLAGS, SHOW_WINDOW_CMD, SPIF_SENDCHANGE, - SPIF_UPDATEINIFILE, SPI_GETANIMATION, SPI_GETDESKWALLPAPER, SPI_SETANIMATION, - SPI_SETDESKWALLPAPER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, - SWP_NOZORDER, SW_MINIMIZE, SW_NORMAL, SW_RESTORE, + GWL_STYLE, GW_OWNER, HWND_TOP, SET_WINDOW_POS_FLAGS, SHOW_WINDOW_CMD, + SPIF_SENDCHANGE, SPIF_UPDATEINIFILE, SPI_GETANIMATION, SPI_GETDESKWALLPAPER, + SPI_SETANIMATION, SPI_SETDESKWALLPAPER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, + SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SW_MINIMIZE, SW_NORMAL, SW_RESTORE, SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS, WINDOW_EX_STYLE, WINDOW_STYLE, WNDENUMPROC, }, }, @@ -320,12 +320,15 @@ impl WindowsApi { hook_manager.skip(WinEvent::SystemMinimizeStart, hwnd.0); hook_manager.skip(WinEvent::SystemMinimizeEnd, hwnd.0); } + Self::set_minimize_animation(false)?; - Self::show_window_async(hwnd, SW_MINIMIZE)?; - Self::show_window_async(hwnd, SW_RESTORE)?; + Self::show_window(hwnd, SW_MINIMIZE)?; + Self::show_window(hwnd, SW_RESTORE)?; Self::set_minimize_animation(true)?; - Self::set_foreground(hwnd) + Self::bring_to(hwnd, HWND_TOP)?; + Self::set_foreground(hwnd)?; + Ok(()) } pub fn async_force_set_foreground(hwnd: HWND) { diff --git a/src/background/windows_api/window.rs b/src/background/windows_api/window.rs index 04267ef8..4b554766 100644 --- a/src/background/windows_api/window.rs +++ b/src/background/windows_api/window.rs @@ -5,7 +5,10 @@ use std::{ use windows::Win32::Foundation::HWND; -use crate::error_handler::Result; +use crate::{ + error_handler::Result, seelen_bar::FancyToolbar, seelen_weg::SeelenWeg, + seelen_wm::WindowManager, +}; use super::{WindowEnumerator, WindowsApi}; @@ -106,9 +109,16 @@ impl Window { WindowsApi::get_desktop_window() == self.0 || self.class() == "Progman" } - pub fn is_seelen_window(&self) -> bool { + pub fn is_seelen_overlay(&self) -> bool { if let Ok(exe) = self.exe() { - return exe.ends_with("seelen-ui.exe"); + return exe.ends_with("seelen-ui.exe") + && [ + FancyToolbar::TITLE, + WindowManager::TITLE, + SeelenWeg::TITLE, + SeelenWeg::TITLE_HITBOX, + ] + .contains(&self.title().as_str()); } false }