enforce aspect ratio via Win32 SetWindowPos from Rust instead of Tauri JS setSize which wasn't working
This commit is contained in:
+5
-15
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user