@@ -265,59 +265,58 @@ export default class WindowsController extends BaseController {
265265 }
266266
267267 async initPlaybackWindowSize ( window : Electron . BrowserWindow ) {
268- const {
269- state : {
270- editor : { overrideWindowSize } ,
271- } ,
272- } = await this . session . state . get ( )
273- if ( ! overrideWindowSize . active ) {
274- window . webContents . setZoomFactor ( 1 )
275- return
276- }
277- const { width, height } =
278- await this . session . resizablePanels . getPanelScreenPosition (
279- 'playback-panel'
280- )
281- const targetWidth = overrideWindowSize . width
282- const targetHeight = overrideWindowSize . height
283- if ( targetWidth > width || targetHeight > height ) {
284- const xZoom = width / targetWidth
285- const yZoom = height / targetHeight
286- window . setSize ( width , height )
287- window . webContents . setZoomFactor ( Math . max ( 0.1 , Math . min ( xZoom , yZoom ) ) )
288- } else {
289- window . setSize ( targetWidth , targetHeight )
290- window . webContents . setZoomFactor ( 1 )
291- }
268+ const panel = await this . session . resizablePanels . getPanelScreenPosition (
269+ 'playback-panel'
270+ )
271+ const { height, width, zoomFactor } = await this . calculateScaleAndZoom (
272+ panel . width ,
273+ panel . height
274+ )
275+ window . setSize ( width , height )
276+ window . webContents . setZoomFactor ( zoomFactor )
292277 }
293278
294- async resizePlaybackWindows ( _targetWidth : number , _targetHeight : number ) {
279+ async calculateScaleAndZoom ( _targetWidth : number , _targetHeight : number ) {
295280 const {
296281 state : {
297282 editor : { overrideWindowSize } ,
298283 } ,
299284 } = await this . session . state . get ( )
300285 const targetWidth = overrideWindowSize . active
301- ? overrideWindowSize . width
286+ ? Math . max ( overrideWindowSize . width , 150 )
302287 : _targetWidth
303288 const targetHeight = overrideWindowSize . active
304- ? overrideWindowSize . height
289+ ? Math . max ( overrideWindowSize . height , 150 )
305290 : _targetHeight
306291
307292 const { width, height } =
308293 await this . session . resizablePanels . getPanelScreenPosition (
309294 'playback-panel'
310295 )
296+ const xAspect = width / targetWidth
297+ const yAspect = height / targetHeight
298+ let resultWidth = targetWidth
299+ let resultHeight = targetHeight
300+ const zoomFactor = Math . min ( xAspect , yAspect , 1 )
301+ if ( xAspect < 1 || yAspect < 1 ) {
302+ resultWidth = Math . round ( targetWidth * zoomFactor )
303+ resultHeight = Math . round ( targetHeight * zoomFactor )
304+ }
305+ return {
306+ width : resultWidth ,
307+ height : resultHeight ,
308+ zoomFactor,
309+ }
310+ }
311+
312+ async resizePlaybackWindows ( _targetWidth : number , _targetHeight : number ) {
313+ const { width, height, zoomFactor } = await this . calculateScaleAndZoom (
314+ _targetWidth ,
315+ _targetHeight
316+ )
311317 this . playbackWindows . forEach ( ( window ) => {
312- if ( targetWidth > width || targetHeight > height ) {
313- const xZoom = width / targetWidth
314- const yZoom = height / targetHeight
315- window . setSize ( width , height )
316- window . webContents . setZoomFactor ( Math . max ( 0.1 , Math . min ( xZoom , yZoom ) ) )
317- } else {
318- window . setSize ( targetWidth , targetHeight )
319- window . webContents . setZoomFactor ( 1 )
320- }
318+ window . setSize ( width , height )
319+ window . webContents . setZoomFactor ( zoomFactor )
321320 } )
322321 }
323322
@@ -380,7 +379,9 @@ export default class WindowsController extends BaseController {
380379 this . session . api . windows . onPlaybackWindowChanged . dispatchEvent (
381380 window . id ,
382381 {
383- title : window . webContents . getURL ( ) ,
382+ title : window . webContents
383+ . getURL ( )
384+ . replace ( this . session . projects . project . url , '' ) ,
384385 }
385386 )
386387 } )
0 commit comments