enforce aspect ratio via Win32 SetWindowPos from Rust instead of Tauri JS setSize which wasn't working

This commit is contained in:
2026-05-27 21:46:52 +03:00
parent 1c89bb6b0f
commit 07521b4a8b
2 changed files with 40 additions and 15 deletions
+5 -15
View File
@@ -35,23 +35,13 @@
win.onResized(async () => {
if (enforcing) return
await updateSize()
// Re-sync ratio in case it changed
await syncRatio()
if (lockedRatio === null) return
// Let Rust handle ratio enforcement via Win32 API
enforcing = true
if (resizeDebounce !== null) clearTimeout(resizeDebounce)
resizeDebounce = window.setTimeout(async () => {
const ratio = lockedRatio!
const targetH = Math.round(width / ratio)
const minH = 90
const clampedH = Math.max(minH, targetH)
if (Math.abs(clampedH - height) > 2) {
enforcing = true
try {
await win.setSize({ type: "Logical", width, height: clampedH })
await updateSize()
} catch {}
enforcing = false
}
try { await invoke("enforce_overlay_aspect") } catch {}
await updateSize()
enforcing = false
}, 80)
}).then(fn => cleanup.push(fn))