Add Window::setParentWindow (macOS child windows)#1
Conversation
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>
|
Superseded by the upstream PR: HumbleUI#312 (same change, rebased onto upstream/main with only the setParentWindow commit). |
There was a problem hiding this comment.
💡 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".
| [nsWindow.parentWindow removeChildWindow:nsWindow]; | ||
| if (parentPtr) { | ||
| jwm::WindowMac* parent = reinterpret_cast<jwm::WindowMac*>(static_cast<uintptr_t>(parentPtr)); | ||
| [parent->fNSWindow addChildWindow:nsWindow ordered:NSWindowAbove]; |
There was a problem hiding this comment.
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 👍 / 👎.
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 — unlikesetZOrder(FLOATING/MODAL_PANEL), it does not float over other applications' windows. Passingnulldetaches.Why
Downstream (robocode-jwm), robot console windows used
ZOrder.MODAL_PANELto 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
setVisible(true)on every show. Documented in the javadoc.setZOrderstub style (Win32 could later reuse the_nWinSetParentowner-window plumbing; X11 viaXSetTransientForHint).target/classes(per the downstream-patch workflow in CLAUDE.md).🤖 Generated with Claude Code