Skip to content

Commit

Permalink
fix(#64): can not restore settings window
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Sep 2, 2024
1 parent 5cc054e commit 744b2e4
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/background/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion src/background/seelen_bar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/background/seelen_weg/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(());
}
Expand Down
7 changes: 5 additions & 2 deletions src/background/seelen_weg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/background/seelen_wm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 10 additions & 7 deletions src/background/windows_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 13 additions & 3 deletions src/background/windows_api/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 744b2e4

Please sign in to comment.