Skip to content

Add Window::setParentWindow (macOS child windows)#1

Closed
bumfo wants to merge 1 commit into
claude-rebasefrom
child-windows
Closed

Add Window::setParentWindow (macOS child windows)#1
bumfo wants to merge 1 commit into
claude-rebasefrom
child-windows

Conversation

@bumfo

@bumfo bumfo commented Jul 12, 2026

Copy link
Copy Markdown
Owner

What

New cross-platform API Window.setParentWindow(@Nullable Window parent), implemented on macOS via -[NSWindow addChildWindow:ordered:] (NSWindowAbove). A child window stays ordered above its parent within the application — unlike setZOrder(FLOATING/MODAL_PANEL), it does not float over other applications' windows. Passing null detaches.

Why

Downstream (robocode-jwm), robot console windows used ZOrder.MODAL_PANEL to stay above the battle view, which also kept them above every other app. Child windows are the native macOS mechanism for "always above one specific window only".

Notes / caveats

  • macOS semantics: the child moves together with its parent; hiding (orderOut) a child window detaches it automatically, so callers should attach after setVisible(true) on every show. Documented in the javadoc.
  • Windows/X11 are TODO stubs following the existing setZOrder stub style (Win32 could later reuse the _nWinSetParent owner-window plumbing; X11 via XSetTransientForHint).
  • README feature matrix + CHANGELOG updated.
  • Built and exercised on macOS arm64 via robocode-jwm consuming target/classes (per the downstream-patch workflow in CLAUDE.md).

🤖 Generated with Claude Code

Attaches a window as a child of another so it stays above its parent
within the application, without floating over other apps' windows
(unlike ZOrder.FLOATING/MODAL_PANEL). Pass null to detach; hiding a
child window detaches it automatically on macOS, so callers re-attach
on show. Windows/X11: TODO stubs matching setZOrder.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bumfo

bumfo commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the upstream PR: HumbleUI#312 (same change, rebased onto upstream/main with only the setParentWindow commit).

@bumfo bumfo closed this Jul 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 61eb5577d2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread macos/cc/WindowMac.mm
[nsWindow.parentWindow removeChildWindow:nsWindow];
if (parentPtr) {
jwm::WindowMac* parent = reinterpret_cast<jwm::WindowMac*>(static_cast<uintptr_t>(parentPtr));
[parent->fNSWindow addChildWindow:nsWindow ordered:NSWindowAbove];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Set fullscreen auxiliary behavior for child windows

When parent is already in macOS fullscreen, this attaches the child while it still has the initialization-time NSWindowCollectionBehaviorFullScreenPrimary used for every WindowMac. Secondary windows need NSWindowCollectionBehaviorFullScreenAuxiliary to appear in the same fullscreen Space as their parent; otherwise the child is ordered on another Space/desktop and setParentWindow does not keep it above the fullscreen parent. Set the auxiliary behavior before attaching, and restore the top-level behavior on detach if needed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude fix in current branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant