1- import { createElementBounds } from "@solid-primitives/bounds" ;
21import { createTimer } from "@solid-primitives/timer" ;
32import { createMutation } from "@tanstack/solid-query" ;
43import { LogicalPosition } from "@tauri-apps/api/dpi" ;
@@ -111,8 +110,8 @@ function InProgressRecordingInner() {
111110 const [ startingDismissed , setStartingDismissed ] = createSignal ( false ) ;
112111 const [ interactiveAreaRef , setInteractiveAreaRef ] =
113112 createSignal < HTMLDivElement | null > ( null ) ;
114- const interactiveBounds = createElementBounds ( interactiveAreaRef ) ;
115113 let settingsButtonRef : HTMLButtonElement | undefined ;
114+ let lastInteractiveBoundsKey = "" ;
116115 const recordingMode = createMemo (
117116 ( ) => currentRecording . data ?. mode ?? optionsQuery . rawOptions . mode ,
118117 ) ;
@@ -292,30 +291,55 @@ function InProgressRecordingInner() {
292291 void refreshCameraWindowState ( ) ;
293292 } ) ;
294293
295- createEffect ( ( ) => {
294+ const syncInteractiveAreaBounds = ( ) => {
296295 const element = interactiveAreaRef ( ) ;
297296 if ( ! element ) {
298- void commands . removeFakeWindow ( FAKE_WINDOW_BOUNDS_NAME ) ;
297+ if ( lastInteractiveBoundsKey !== "" ) {
298+ lastInteractiveBoundsKey = "" ;
299+ void commands . removeFakeWindow ( FAKE_WINDOW_BOUNDS_NAME ) ;
300+ }
299301 return ;
300302 }
301303
302- const left = interactiveBounds . left ?? 0 ;
303- const top = interactiveBounds . top ?? 0 ;
304- const width = interactiveBounds . width ?? 0 ;
305- const height = interactiveBounds . height ?? 0 ;
304+ const rect = element . getBoundingClientRect ( ) ;
305+ if ( rect . width === 0 || rect . height === 0 ) return ;
306306
307- if ( width === 0 || height === 0 ) return ;
307+ const key = [ rect . left , rect . top , rect . width , rect . height ]
308+ . map ( ( value ) => value . toFixed ( 2 ) )
309+ . join ( ":" ) ;
310+ if ( key === lastInteractiveBoundsKey ) return ;
308311
312+ lastInteractiveBoundsKey = key ;
309313 void commands . setFakeWindowBounds ( FAKE_WINDOW_BOUNDS_NAME , {
310- position : { x : left , y : top } ,
311- size : { width, height } ,
314+ position : { x : rect . left , y : rect . top } ,
315+ size : { width : rect . width , height : rect . height } ,
312316 } ) ;
317+ } ;
318+
319+ createEffect ( ( ) => {
320+ interactiveAreaRef ( ) ;
321+ queueMicrotask ( syncInteractiveAreaBounds ) ;
322+ } ) ;
323+
324+ createEffect ( ( ) => {
325+ state ( ) ;
326+ issuePanelVisible ( ) ;
327+ queueMicrotask ( syncInteractiveAreaBounds ) ;
313328 } ) ;
314329
315330 onCleanup ( ( ) => {
331+ lastInteractiveBoundsKey = "" ;
316332 void commands . removeFakeWindow ( FAKE_WINDOW_BOUNDS_NAME ) ;
317333 } ) ;
318334
335+ onMount ( ( ) => {
336+ const onResize = ( ) => syncInteractiveAreaBounds ( ) ;
337+ window . addEventListener ( "resize" , onResize ) ;
338+ onCleanup ( ( ) => window . removeEventListener ( "resize" , onResize ) ) ;
339+ requestAnimationFrame ( ( ) => syncInteractiveAreaBounds ( ) ) ;
340+ setTimeout ( ( ) => syncInteractiveAreaBounds ( ) , 150 ) ;
341+ } ) ;
342+
319343 createTimer (
320344 ( ) => {
321345 void refreshCameraWindowState ( ) ;
@@ -324,6 +348,8 @@ function InProgressRecordingInner() {
324348 setInterval ,
325349 ) ;
326350
351+ createTimer ( syncInteractiveAreaBounds , 250 , setInterval ) ;
352+
327353 createEffect ( ( ) => {
328354 if (
329355 state ( ) . variant === "stopped" &&
0 commit comments