Skip to content

feat(desktop): open windows maximized and set the state explicitly - #2822

Merged
houko merged 1 commit into
mainfrom
feat/desktop-start-maximized-2816
Dec 1, 2026
Merged

houko merged 1 commit into
mainfrom
feat/desktop-start-maximized-2816

Conversation

@houko

@houko houko commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2816.

  • desktop.WindowOptions.Maximized (and nsgo.WindowMaximized() for the main window) opens a window maximized, zoomed on macOS, before it first shows, so it never appears at its size first. NoMaximize / NoResize constraints leave it at its size.
  • desktop.SetMaximized(cx, on) asks for a state instead of toggling it (driver.WindowSetMaximized). Called before the window first shows, such as from content as it mounts, it opens the window in that state rather than showing it and then resizing.
  • openSurface seeds the new surface's environment from the state it asked for, so desktop.Maximized reads true from the first frame of a window opened maximized instead of false until the platform's first report. desktop.Maximized now documents when it is valid.

Per platform:

  • macOS: sends zoom: (what ToggleMaximize sends) after centering and before the window attaches, so AppKit keeps the centered frame to zoom back to and the first layout and environment have the zoomed frame. SetMaximized zooms only when isZoomed differs.
  • Windows: a window to open maximized shows the first time with SW_SHOWMAXIMIZED instead of SW_SHOW / SW_SHOWNA (first batch, Show, OrderFront, owned-window sync), and reports Maximized meanwhile. SetMaximized on a window that has not shown yet changes how it will show instead of showing it, which avoids the deferred-show cancel the issue describes.
  • Linux: gtk_window_maximize before GTK maps the window, which GTK applies as it maps it. A test host's window, normally fixed in size for tiling compositors, stays resizable when opened maximized so the window manager maximizes it.
  • nsgotest records WindowSetMaximized and SurfaceConfig.Maximized.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None

Verification

  • head: 41de904f77eec6a55d369ade1b75fb69f64be1e9
  • base: fd02adf8ed86177303d3db4d5a3ee119690c8175
  • commands:
    • go tool nsgo check -target macos,windows,linux,ios → 0
    • go tool nsgo test ./core ./nsgotest ./desktop ./internal/driver ./internal/backend ./internal/testhost/testdata/windowstate → 0
  • result: pass
  • not covered: native window behaviour. The new TestWindowOpensMaximized in internal/testhost/testdata/windowstate skipped headless (it needs a GUI session); this PR adds it to the macOS and Windows window-state CI steps, and the Linux step already runs that whole package under openbox. The new Windows logic test TestFirstShowMaximizesOnce only runs in the Windows CI job.

Test output (host run, macOS arm64 over SSH):

  ✓ TestMaximizedWindowReadsItFromTheStart (0s)
  ✓ TestSetMaximizedAsksForAState (0s)
  ✓ TestWindowRecordsSetMaximized (10ms)
  - TestWindowOpensMaximized (0s)
  1562 passed, 0 failed, 5 skipped

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

Add WindowOptions.Maximized and nsgo.WindowMaximized, which macOS, Windows and Linux apply before the window first shows, and desktop.SetMaximized, which asks for a state instead of toggling it. The core seeds a new surface's environment from the state it asked for, so desktop.Maximized is valid from the first frame.

Fixes #2816
@github-actions github-actions Bot added enhancement New feature or request size/M local-ci-pass The head commit declares that its local checks passed documentation Improvements or additions to documentation macOS Windows Linux core ci and removed local-ci-pass The head commit declares that its local checks passed labels Dec 1, 2026
@houko
houko merged commit 8e5c1cc into main Dec 1, 2026
25 of 44 checks passed
@houko
houko deleted the feat/desktop-start-maximized-2816 branch December 1, 2026 01:39
houko added a commit to nsgo-dev/game that referenced this pull request Dec 1, 2026
Moves the game layer, the tools module and the sample games from NSGo v0.4.0 to NSGo main at 8e5c1cc (v0.4.1-0.20261201013927-8e5c1cc14ee7), so a project that requires NSGo main, such as for nsgo.WindowMaximized (nsgo-dev/nsgo#2822), can build the game layer.

NSGo's only breaking change since v0.4.0 (nsgo-dev/nsgo#2739) makes core.Style.FlexShrink a core.FlexShrink and shrinks growing boxes, scroll views along their scroll axis and the auto-sized boxes around them by default. Every numeric factor keeps its value: FlexShrink: 1 becomes core.Shrink(1) and FlexShrink: 0 becomes core.NoShrink (906 sites in pkg/editor, pkg/scene, pkg/online/admin/console, internal, the templates and their embedded copies, and the examples), and the docs and the nsgo-game skill show the new form. The operator console's embedded web build is regenerated for the new sources and NSGo version.

go mod tidy also adds the indirect requirements the examples were missing for nsgo's cmd/nsgo tool (quic-go and friends) and lists modelcontextprotocol/go-sdk as a direct requirement of the tools module, which imports it.

BREAKING CHANGE: the game layer requires an NSGo newer than v0.4.0, whose core.Style.FlexShrink is a core.FlexShrink.
houko added a commit to nsgo-dev/orbit-academy-game that referenced this pull request Dec 1, 2026
…ayer main

Move to nsgo main (8e5c1cc), which opens the main window maximized from its first frame (nsgo-dev/nsgo#2822) and brings the environment refresh (nsgo-dev/nsgo#2821) and sprite-frame crop cache (nsgo-dev/nsgo#2817) fixes, and to the game layer main (be78552), which builds against it (nsgo-dev/game#2723). Replace maximizeOnce, which waited for the first window frame to toggle maximize, with nsgo.WindowMaximized in main.go, and migrate the one numeric FlexShrink to core.Shrink.
houko added a commit to nsgo-dev/orbit-academy-game that referenced this pull request Dec 1, 2026
…ayer main (#5)

Move to nsgo main (8e5c1cc), which opens the main window maximized from its first frame (nsgo-dev/nsgo#2822) and brings the environment refresh (nsgo-dev/nsgo#2821) and sprite-frame crop cache (nsgo-dev/nsgo#2817) fixes, and to the game layer main (be78552), which builds against it (nsgo-dev/game#2723). Replace maximizeOnce, which waited for the first window frame to toggle maximize, with nsgo.WindowMaximized in main.go, and migrate the one numeric FlexShrink to core.Shrink.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci core documentation Improvements or additions to documentation enhancement New feature or request Linux macOS size/M Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: no way to open a window maximized, and Maximized reads false until the platform's first report

1 participant