Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i store and restore size and window position for multiple windows in Tauri?

Tags:

rust

tauri

I need to store a window size and position for multiple windows in tauri. And restore it after open. For example there was opened 3 windows and they have located in different parts of desktop. And when i'll open an application again app will restore all three windows(windows are the same) and restore their positions and size. Is it possible?

like image 715
Snoz3f Avatar asked Oct 22 '25 07:10

Snoz3f


1 Answers

Tauri has a plugin for exactly this: https://github.com/tauri-apps/tauri-plugin-window-state (recommended solution). You don't necessarily have to use this but its code should serve as good inspiration.

A JS-only solution is a bit tricky because there is no exit-requested event for the event loop on the JS side, only close-requested for the windows.

This wouldn't be an issue if you have a specific point in time where you want to save the windows. In that case you could just save a json file to disk containing the size/position and the window labels which you then read on app start to re-size/re-position the window.

like image 125
FabianLars Avatar answered Oct 25 '25 01:10

FabianLars



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!