Fix responsive scaling feedback loop
Some checks failed
Build / release (macos-latest) (push) Has been cancelled
Build / release (ubuntu-latest) (push) Has been cancelled
Build / release (windows-latest) (push) Has been cancelled
Windows Smoke Test / windows-smoke (push) Has been cancelled

This commit is contained in:
2026-05-04 15:36:14 +09:00
parent 010dbc30a4
commit 363fd11f63

View File

@@ -39,6 +39,7 @@ const BASE_WINDOW_WIDTH = 1400
const BASE_WINDOW_HEIGHT = 860 const BASE_WINDOW_HEIGHT = 860
let responsiveLayoutFrame = null let responsiveLayoutFrame = null
let lastAppliedZoomFactor = null
function clamp(value, min, max){ function clamp(value, min, max){
return Math.min(Math.max(value, min), max) return Math.min(Math.max(value, min), max)
@@ -70,13 +71,18 @@ function syncLaunchDetailWidths(){
} }
function applyResponsiveLayout(){ function applyResponsiveLayout(){
const currentWindow = remote.getCurrentWindow()
const contentBounds = currentWindow.getContentBounds()
const scale = clamp( const scale = clamp(
Math.min(window.innerWidth / BASE_WINDOW_WIDTH, window.innerHeight / BASE_WINDOW_HEIGHT), Math.min(contentBounds.width / BASE_WINDOW_WIDTH, contentBounds.height / BASE_WINDOW_HEIGHT),
0.72, 0.72,
1.45 1.45
) )
if(lastAppliedZoomFactor == null || Math.abs(lastAppliedZoomFactor - scale) > 0.001){
lastAppliedZoomFactor = scale
webFrame.setZoomFactor(scale) webFrame.setZoomFactor(scale)
}
document.documentElement.style.setProperty('--launcher-scale', scale.toFixed(3)) document.documentElement.style.setProperty('--launcher-scale', scale.toFixed(3))
window.requestAnimationFrame(() => { window.requestAnimationFrame(() => {
@@ -94,9 +100,10 @@ function queueResponsiveLayout(){
}) })
} }
window.addEventListener('resize', () => { const responsiveWindow = remote.getCurrentWindow()
queueResponsiveLayout() responsiveWindow.on('resize', queueResponsiveLayout)
}) responsiveWindow.on('maximize', queueResponsiveLayout)
responsiveWindow.on('unmaximize', queueResponsiveLayout)
// Initialize auto updates in production environments. // Initialize auto updates in production environments.
let updateCheckListener let updateCheckListener