mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
fix(client): skip window-state save while minimized
A minimized window reports placeholder coordinates (-32000 on Windows); the move event fired by minimize was persisting them, so quitting while minimized silently discarded the remembered position (the new off-screen validation then falls back to centered). Skip the save while minimized so the last real geometry survives. Follow-up to #124. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwtnpHAoSFr1ZibQgQkNQK
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
"core:window:allow-set-size",
|
||||
"core:window:allow-maximize",
|
||||
"core:window:allow-is-maximized",
|
||||
"core:window:allow-is-minimized",
|
||||
"core:window:allow-outer-position",
|
||||
"core:window:allow-outer-size",
|
||||
"core:window:allow-available-monitors",
|
||||
|
||||
@@ -188,6 +188,17 @@ export async function initWindowState(): Promise<() => void> {
|
||||
saveTimer = setTimeout(() => {
|
||||
void (async () => {
|
||||
try {
|
||||
// A minimized window reports placeholder coordinates (-32000 on
|
||||
// Windows) — skip so the last real geometry survives a minimized
|
||||
// exit. Checked separately so platforms without isMinimized still
|
||||
// save normally.
|
||||
let minimized = false;
|
||||
try {
|
||||
minimized = await win.isMinimized();
|
||||
} catch {
|
||||
// Treat as not minimized
|
||||
}
|
||||
if (minimized) return;
|
||||
const pos = await win.outerPosition();
|
||||
const size = await win.outerSize();
|
||||
const maximized = await win.isMaximized();
|
||||
|
||||
@@ -39,6 +39,7 @@ vi.mock("@tauri-apps/api/window", () => ({
|
||||
outerPosition: vi.fn(),
|
||||
outerSize: vi.fn(),
|
||||
isMaximized: vi.fn().mockResolvedValue(false),
|
||||
isMinimized: vi.fn().mockResolvedValue(false),
|
||||
}),
|
||||
availableMonitors: () =>
|
||||
h.monitorsError !== null ? Promise.reject(h.monitorsError) : Promise.resolve(h.monitors),
|
||||
|
||||
Reference in New Issue
Block a user