Repository navigation
Description
Context
On macOS an app can open more windows with desktop.OpenWindow, and NSGo's own doc example for it is a settings window (desktop/app.go:43). But every window it opens is an independent top-level window: nothing ties it to the window it was opened from.
WindowOptionshas a title, size, frame, key, hidden flag, material and constraints, and no parent (core/window.go:34-54).driver.SurfaceConfig, which the core sends to the platform, has no parent either (internal/driver/services.go:175-198).- The macOS backend makes an ordinary
NSWindow, centers it on the screen (not over the window that opened it) and orders it front, without any relation to another window (internal/platform/macos/app.go:95-137).docs/architecture/application.md:56describes exactly that: "A window is anNsgoWindowcentered at its content size." - The only link between windows is ownership: a window "belongs to the current owner and closes when that owner goes" (
core/window.go:94-97). That covers lifetime when the window is opened from a scope inside another window. It does not cover the window server: z-order, minimizing, hiding the app's window, or full screen.
Why it matters for real apps
Kando (github.com/yldm-tech/kando), a desktop video player, opens its Settings as a separate 880x640 window that is a child of the main player window (apps/kando/state_settings.go:208-223, Parent: a.win). The user changes the subtitle look or the playback speed while watching, and clicks back and forth between the two windows:
- Clicking the large player window must not bury Settings behind it. With independent windows it disappears behind the video, and the user has to find it again from the Window menu or Mission Control.
- Minimizing the player, or hiding it, should take Settings with it. Restoring the player should bring Settings back above it.
- When the player goes full screen, its child should go with it to the full-screen Space instead of staying behind on the desktop.
- Settings should open centered over the player, not over the middle of the screen, which on a large or second display can be far from where the user is looking.
Inspectors, find panels, "now playing" mini windows and preference windows in editors all want the same behavior, so this is not specific to a video player.
Minimal repro on upstream main: open a main window and a settings window, click into the main window, and Settings goes behind it. There is no option to express the relationship.
package main
import (
"github.com/nsgo-dev/nsgo"
"github.com/nsgo-dev/nsgo/core"
"github.com/nsgo-dev/nsgo/desktop"
)
func main() { nsgo.Run(App) }
func App(app *core.Scope) {
player := desktop.OpenWindow(app, desktop.WindowOptions{Title: "Player", Width: 1280, Height: 800},
func(cx *core.Scope) core.Node { return core.Text{Content: "player"} })
desktop.SetMainWindow(app, player)
desktop.OpenWindow(app, desktop.WindowOptions{Title: "Settings", Width: 880, Height: 640, Key: "settings"},
func(cx *core.Scope) core.Node { return core.Text{Content: "settings"} })
// Click the Player window: Settings goes behind it. Minimize Player: Settings stays on screen.
}Proposal
A Parent on WindowOptions, in the same style as Key:
type WindowOptions struct {
// ...
// Parent, when set and open, makes the window a child of it: it opens
// centered over its parent, stays above it whenever the parent comes in
// front, hides while the parent is minimized or hidden and shows again
// with it, follows it into full screen, and closes with it. Nil, or a
// closed window, opens an ordinary window.
Parent *Window
}settings := desktop.OpenWindow(cx, desktop.WindowOptions{Title: "Settings", Key: "settings", Parent: desktop.MainWindow(cx)}, Settings)- Core: carry the parent's surface ID in
driver.SurfaceConfig(for exampleParent uint32), and dispose the child's scope in the parent'sgone(core/window.go:174), so a child closes with its parent whichever scope opened it. A child counts towardShutdownOnLastWindowCloselike any other window. - macOS:
addChildWindow:ordered:withNSWindowAbovegives ordering, hiding with a minimized parent and following it into full screen. Two AppKit behaviors are worth designing around: an attached child window is kept on its parent's Space, so when the user drags it to another display (with "Displays have separate Spaces" on) it is not drawn there while its frame still takes clicks, and AppKit keeps sibling children in the order they were attached rather than the order the user clicked them. A robust implementation orders the child above its parent when the parent comes in front, becomes key or is deminiaturized, and only attaches it while the parent is in full screen. Either approach satisfies the acceptance below; the API does not depend on which one is used. - A child opened without
Framecenters over its parent's frame, kept on the parent's screen, instead of on the main screen. - Windows and Linux: the same field maps to an owned window (
GWLP_HWNDPARENT) andgtk_window_set_transient_for; they can land with the surfaces work tracked in [Feature] Desktop shell parity on Windows and Linux: windows, panels, tray icons, global shortcuts, one instance #31. Until thenOpenWindowreturns nil there, so the field has no effect.
Acceptance
- On macOS, a window opened with
Parentstays above its parent when the user clicks the parent, and above it again after the parent is ordered front from the Window menu or the Dock. - Minimizing or hiding the parent hides the child; restoring it shows the child again above it.
- A child that is showing goes with its parent into full screen and comes back with it.
- A child dragged to another display is drawn and clickable there.
- Closing the parent closes the child, and its
OnClosinghandlers are not asked (as with an owner going). - A child opened without
Frameopens centered over its parent. -
Parent: nilor a closed parent behaves exactly as today. -
core/window_test.gocovers the parent ID inSurfaceConfigand the child closing with its parent;docs/architecture/application.mddescribes child windows.
Activity
houko commentedon Nov 20, 2026
Reviewed against current origin/main.
WindowOptionsanddriver.SurfaceConfigstill have no parent relationship, and the macOS surface opener creates independent top-level windows. A complete implementation needs core ownership/close semantics, parent IDs in the surface protocol, macOS child ordering/minimize/full-screen behavior and multi-display coordinate handling, plus future Windows/Linux transient-window mapping. This is coupled to the broader surfaces work, so I am leaving the issue open rather than opening a macOS-only API that would not satisfy the cross-target acceptance.houko commentedon Nov 21, 2026
Rechecked against main after #1199 merged.
WindowOptions.Parentnow sends the parent surface ID and closes the child with its parent. The AppKit backend centers unpositioned children, follows parent visibility and ordering, and attaches the child during full screen. Normal Spaces use independent windows so a child can move between displays.The focused core and macOS tests reported in #1199 passed, including parent lookup within the app, centering, visibility and ordering, and the AppKit attachment notifications. Live full-screen Space transitions and dragging across physical displays were not exercised on the test machines. Windows and Linux native ordering and visibility are tracked separately in the roadmap.