Skip to content

Heavyweight: re-position the native WebView when an ancestor moves or resizes - #74

Merged
shannah merged 1 commit into
masterfrom
claude/desktop-ui-apps-filesystem-ns366w
Oct 21, 2026
Merged

shannah merged 1 commit into
masterfrom
claude/desktop-ui-apps-filesystem-ns366w

Conversation

@shannah

@shannah shannah commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

On macOS the heavyweight WKWebView is a subview of NSWindow.contentView, positioned in window coordinates by sizeNative(). sizeNative() ran only on the canvas's own componentMoved and componentResized (plus on show and on attach).

When an ancestor moves, the canvas's position within its parent doesn't change, so AWT fires neither event and the native view stays where it was. This happens when you drag a JInternalFrame that holds the web view across a JDesktopPane, or move a container with a split-pane divider without resizing it. It was reported from the Agentic App Framework's desktop view: "When I move a window, the webview isn't moved". Resizing the window or switching tabs fixed it.

Fix (Canvas 6, Fix 3)

EmbeddedCanvas now also installs a HierarchyBoundsListener. Its ancestorMoved and ancestorResized call sizeNative() while the canvas is showing.

There is no native change. sizeNative() already sends window-content coordinates on every platform, so calling it from here is correct on all of them. It is idempotent with the existing triggers.

Testing

  • The sources compile (javac over src/).
  • Not run on macOS. Per this repo's rules, heavyweight isn't exercised on Linux. To check on a Mac: drag a JInternalFrame holding a WebViewComponent and the page should follow the frame.

The app works around this today by firing COMPONENT_MOVED at the canvases when a desktop window moves. Once this is released, the framework can drop that workaround.


Generated by Claude Code

… resizes (Canvas 6 Fix 3)

sizeNative() positions the native view in window-content coordinates but ran
only on the canvas's own componentMoved/componentResized. Dragging an ancestor
(a JInternalFrame across a JDesktopPane) moves the canvas in the window without
moving it within its parent, so no event fired and on macOS the WKWebView
stayed behind. EmbeddedCanvas now also listens for ancestorMoved and
ancestorResized and re-sizes the native view while showing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012AhsKesqVAYvmUoDMkPLRt
@shannah
shannah marked this pull request as ready for review October 21, 2026 13:28
@shannah
shannah merged commit d1f5677 into master Oct 21, 2026
7 checks passed
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.

2 participants