Skip to content

Fix embedded webview geometry on scaled displays (PR #63 + review follow-ups) - #66

Merged
shannah merged 2 commits into
masterfrom
claude/great-goodall-3h1z5v
Oct 3, 2026
Merged

shannah merged 2 commits into
masterfrom
claude/great-goodall-3h1z5v

Conversation

@shannah

@shannah shannah commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

This branch starts from @Aunali321's commit in #63 (6cbe02d, kept as-is) and adds one commit that addresses the points raised in the review of that PR.

Included from #63

  • Windows (heavyweight): webview_embed_set_bounds sizes the child HWND and the WebView2 controller from the canvas HWND's client rect instead of from AWT user-space w, h.
  • Linux (lightweight): the hidden popup's -32000 offset is divided by the window scale, so it no longer wraps on screen at 2x.

Follow-ups (this branch)

Windows (Canvas 6 §6 + new operation 17)

  • fit_child_to_parent is now the one resize routine. It zero-initialises the RECT and returns early if GetClientRect on the canvas HWND fails, so a late dispatched op can no longer push garbage bounds.
  • The child now follows the canvas HWND's device size even when Java fires no componentResized. Example: the frame is dragged to a monitor with a different scale, so the canvas's device size changes but its user-space size doesn't. A thread-specific WH_CALLWNDPROCRET hook on the AWT toolkit thread watches the canvas's WM_SIZE and WM_WINDOWPOSCHANGED (size changed) and posts WM_EMBED_FIT_PARENT to our WebViewEmbedChild. The hook is refcounted per thread, acquired in create_engine and adopt_retained_popup, and released in destroy_engine. AWT's window procedure is never replaced, and the hook only posts. It never calls SendMessage, so the AWT thread can't block on the worker.

Linux lightweight (Canvas 33 D2)

  • gtk_off_park_offscreen now does the scale-aware move. It runs once before the popup is shown, and again from a notify::scale-factor handler, so a runtime change to Gdk/WindowScaling re-parks the popup off screen.

SPDD

  • Canvas 6 §6 constraint, new operation 17 and a Safeguard; Canvas 33 D2, operation 1 and Safeguard 1. Done via /spdd-prompt-update → /spdd-generate.
  • The media analysis's "-32000 is off every monitor" rationale now accounts for scale. The story's mention is a historical repro at 1x and is left unchanged.

Verification

  • Linux lightweight: xvfb-run ./run-linux-media-smoketest.sh passes all checks (A, B, P). With GDK_SCALE=2, xwininfo shows the popup at +-32000+-32000 device px. The runtime scale-change path was not exercised: it needs a live X settings daemon.
  • Windows: not built or run here. The new hook, fit and refcount functions compile under MinGW with -Wall -Wextra against real windows.h. The full file needs MSVC/WRL, so CI has to confirm it. Needs on-device check: at a scale above 100%, drag the frame between monitors of different scale and confirm the page still fills the canvas without resizing the frame.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HKYwyMrdMwg5rJNj38hxvj


Generated by Claude Code

Aunali321 and others added 2 commits October 2, 2026 00:27
Windows (Canvas 6 operation 17):
- Factor the set_bounds resize into fit_child_to_parent, which
  zero-initialises its RECT and leaves the child and controller untouched
  when GetClientRect on the canvas HWND fails.
- Keep the child HWND sized to the canvas HWND even when Java fires no
  componentResized (e.g. the frame moves to a monitor with a different
  scale). A refcounted, thread-specific WH_CALLWNDPROCRET hook on the AWT
  toolkit thread watches the canvas's WM_SIZE / WM_WINDOWPOSCHANGED and
  posts WM_EMBED_FIT_PARENT to the child. AWT's window procedure is never
  replaced, and the hook only posts.

Linux lightweight (Canvas 33 D2):
- Move the offscreen park into gtk_off_park_offscreen and re-run it from a
  notify::scale-factor handler, so a runtime window-scale change cannot
  leave the hidden popup wrapped on screen.

Correct the media analysis's off-screen rationale to account for scale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HKYwyMrdMwg5rJNj38hxvj
@shannah
shannah marked this pull request as ready for review October 3, 2026 14:11
@shannah
shannah merged commit 1ac43de into master Oct 3, 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.

3 participants