I'm currently trying to make a custom titlebar for my Tauri app that automatically shows/hides itself depending on if the app is maximized/fullscreened or not. The closest I've gotten to a good solution is using an interval of 200ms and setting variables to keep track of whether the app is maximized or not, and hiding the titlebar if it is. I'm not sure if there are any better solutions for something in React considering most of tauri's JS apis are async, and client-side react components can't be async. Having to run those functions every 200ms seems like a pretty unnecessary performance hit. Is there anything else I could do?
#Showing and hiding window controls depending on if window is fullscreen/maximized
11 messages · Page 1 of 1 (latest)
maybe you can listen to webview window events?
^ try listening to the window resize event
wait is the resize event responsible for maximizing / minimizing?
No but when the window is maximized/restored it's fired and I don't think there's a dedicated event
Yeah from what I've seen there's no dedicated maximize event. I did try to use a listener like you guys said but the app would crash upon reloading (I'm assuming that because the unlisten function returned is async, useEffect doesn't know how to properly dispose of the listener?)
It also would only work for one maximize and one unmaximize, after which it would stop responding (I did make sure i was using listen() and not once())
Can you send your code
const [maximized, setMaximized] = useState(false)
const [fullscreen, setFullscreen] = useState(false)
useEffect(() => {
const unlisten = getCurrent().listen('tauri://resize', () => {
getCurrent().isMaximized().then(setMaximized)
getCurrent().isFullscreen().then(setFullscreen)
})
return () => {
unlisten.then(u => u())
}
}, [])
Fullscreening works, unfullscreening works, and then neither works after that. Reloading the page just crashes with tokio-runtime-worker thread errors.
From the problem report macOS gave me it seems to be a segfault