Skip to content

Commit c28dfce

Browse files
juliusmarmingecodex
andcommitted
Defer maximized restore until window reveal
Co-authored-by: codex <[email protected]>
1 parent f8f445d commit c28dfce

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎apps/desktop/src/window/DesktopWindow.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ function makeFakeBrowserWindow() {
9191
on: vi.fn((eventName: string, listener: (...args: readonly unknown[]) => void) => {
9292
windowListeners.set(eventName, listener);
9393
}),
94-
once: vi.fn(),
94+
once: vi.fn((eventName: string, listener: (...args: readonly unknown[]) => void) => {
95+
windowListeners.set(eventName, listener);
96+
}),
9597
restore: vi.fn(),
9698
setBackgroundColor: vi.fn(),
9799
setAutoHideCursor: vi.fn(),
@@ -483,6 +485,12 @@ describe("DesktopWindow", () => {
483485
const desktopWindow = yield* DesktopWindow.DesktopWindow;
484486
yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
485487

488+
assert.equal(fakeWindow.maximize.mock.calls.length, 0);
489+
const readyToShow = fakeWindow.windowListeners.get("ready-to-show");
490+
if (!readyToShow) {
491+
return yield* Effect.die("window ready-to-show listener was not registered");
492+
}
493+
readyToShow();
486494
assert.equal(fakeWindow.maximize.mock.calls.length, 1);
487495
}).pipe(Effect.provide(layer));
488496
}),

‎apps/desktop/src/window/DesktopWindow.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,6 @@ export const make = Effect.gen(function* () {
341341
if (environment.platform === "darwin") {
342342
window.setAutoHideCursor(false);
343343
}
344-
if (persistedSettings.mainWindowMaximized) {
345-
window.maximize();
346-
}
347-
348344
let boundsPersistFiber: Fiber.Fiber<void, never> | undefined;
349345
let pendingBoundsPersistFiber: Fiber.Fiber<void, never> | undefined;
350346
let boundsPersistenceEnabled = persistedBounds === null || restoredPersistedBounds;
@@ -364,7 +360,7 @@ export const make = Effect.gen(function* () {
364360
});
365361
};
366362
const fallbackWindowBounds = boundsPersistenceEnabled ? null : readPersistableBounds();
367-
const fallbackWindowMaximized = window.isMaximized();
363+
const fallbackWindowMaximized = persistedSettings.mainWindowMaximized;
368364
const persistCurrentBounds = (): Fiber.Fiber<void, never> | undefined => {
369365
if (!boundsPersistenceEnabled) {
370366
return pendingBoundsPersistFiber;
@@ -636,6 +632,9 @@ export const make = Effect.gen(function* () {
636632
bindFirstRevealTrigger(revealSubscribers, () => {
637633
// Reveal the real window, then close the connecting splash (if any) so the
638634
// two don't overlap and there's no blank gap between them.
635+
if (persistedSettings.mainWindowMaximized) {
636+
window.maximize();
637+
}
639638
void runPromise(Effect.andThen(electronWindow.reveal(window), dismissConnectingSplash));
640639
});
641640

0 commit comments

Comments
 (0)