mirror of
https://github.com/block/buzz.git
synced 2026-11-02 15:31:27 +00:00
fix(desktop): launch at sane default size, restore geometry, focus on show
The main window launched maximized on every start: tauri.conf.json set maximized: true and the window-state plugin was configured to skip restoring size/position/maximized, so user resizes never survived a relaunch and large displays always got an edge-to-edge window. - Default to a centered 1280x800 window instead of maximized. - Restore saved size/position/maximized across launches (only VISIBLE and FULLSCREEN stay excluded: visibility is app-managed via the hidden-until-React-mounts flow, and relaunching into fullscreen is jarring). - Chain setFocus() after show() on mount so the window no longer reveals itself underneath other windows on launch. Co-authored-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
parent
5d4edf1535
commit
2943d52abd
@@ -84,16 +84,14 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(
|
||||
tauri_plugin_window_state::Builder::default()
|
||||
// The main window should always launch edge-to-edge in the
|
||||
// available desktop area. Do not let stale saved geometry or
|
||||
// fullscreen state override the maximized launch config.
|
||||
// Restore the user's window size/position (and maximized
|
||||
// state) across launches. First launch falls back to the
|
||||
// centered default bounds in tauri.conf.json instead of
|
||||
// opening edge-to-edge. Visibility stays managed by the app
|
||||
// (window is revealed once React mounts) and fullscreen is
|
||||
// never restored — relaunching into fullscreen is jarring.
|
||||
.with_state_flags(
|
||||
StateFlags::all()
|
||||
& !(StateFlags::VISIBLE
|
||||
| StateFlags::POSITION
|
||||
| StateFlags::SIZE
|
||||
| StateFlags::MAXIMIZED
|
||||
| StateFlags::FULLSCREEN),
|
||||
StateFlags::all() & !(StateFlags::VISIBLE | StateFlags::FULLSCREEN),
|
||||
)
|
||||
.build(),
|
||||
)
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
"windows": [
|
||||
{
|
||||
"title": "",
|
||||
"width": 800,
|
||||
"height": 600,
|
||||
"maximized": true,
|
||||
"width": 1280,
|
||||
"height": 800,
|
||||
"center": true,
|
||||
"visible": false,
|
||||
"titleBarStyle": "Overlay",
|
||||
"hiddenTitle": true,
|
||||
|
||||
@@ -234,7 +234,11 @@ export function App() {
|
||||
useReloadShortcut();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
void getCurrentWindow().show();
|
||||
// The window starts hidden (visible: false in tauri.conf.json) so users
|
||||
// never see an unstyled flash. Reveal it once React mounts, and focus it
|
||||
// explicitly — show() alone can leave the window behind others on launch.
|
||||
const appWindow = getCurrentWindow();
|
||||
void appWindow.show().then(() => appWindow.setFocus());
|
||||
}, []);
|
||||
|
||||
const [sharedIdentity, setSharedIdentity] = useState<boolean | null>(null);
|
||||
|
||||
Reference in New Issue
Block a user