#Showing and hiding window controls depending on if window is fullscreen/maximized

11 messages · Page 1 of 1 (latest)

empty jewel
#

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?

hasty tangle
#

maybe you can listen to webview window events?

remote kestrel
#

^ try listening to the window resize event

hasty tangle
remote kestrel
empty jewel
#

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())

empty jewel
#
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