Skip to content

Fix windowDidResize using window frame instead of content rect#217

Merged
YoavCodes merged 2 commits intoblackboardsh:mainfrom
jensb1:fix/window-resize-content-rect
Mar 7, 2026
Merged

Fix windowDidResize using window frame instead of content rect#217
YoavCodes merged 2 commits intoblackboardsh:mainfrom
jensb1:fix/window-resize-content-rect

Conversation

@jensb1
Copy link
Contributor

@jensb1 jensb1 commented Feb 25, 2026

Summary

  • Fix windowDidResize: using [window frame] (outer dimensions including title bar) instead of the content rect for webview resize and resize handler callback
  • This caused window.innerHeight to jump by 28px (macOS title bar height) on any resize event

Root Cause

The window is created with initWithContentRect: which correctly interprets the size as the content area. However, windowDidResize: used [window frame] for both:

  1. Resizing the webview ([abstractView resize:fullFrame ...]) — making the webview 28px taller than the content area
  2. Reporting dimensions to JavaScript via self.resizeHandler — reporting the outer frame size instead of content size

Fix

  • Use [containerView bounds] for webview resize (matches the actual content area)
  • Use [window contentRectForFrameRect:] for the resize handler dimensions

Testing

Built and tested the patched libNativeWrapper.dylib locally on macOS arm64 (Sequoia). Verified:

  • Horizontal-only resize no longer changes window.innerHeight
  • Growing and shrinking the window both work correctly
  • window.innerHeight stays consistent between initial load and after resize

Fixes #215

jensb1 and others added 2 commits February 25, 2026 22:26
windowDidResize was using [window frame] which includes the title bar
height (28px on macOS). This caused the webview to be resized to the
outer frame dimensions and window.innerHeight to jump by 28px on any
resize event.

The window is created with initWithContentRect: which correctly uses
the content area, but windowDidResize used [window frame] for both
the webview resize and the resize handler callback, creating an
inconsistency.

Fix: use [containerView bounds] for webview resize and
contentRectForFrameRect: for the resize handler dimensions.

Fixes blackboardsh#215
Copy link
Member

@YoavCodes YoavCodes left a comment

Choose a reason for hiding this comment

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

I merged in main and resolved the conflict (part of this already got fixed by another PR).

Nice work! thanks! ✨

@YoavCodes YoavCodes merged commit 4137a64 into blackboardsh:main Mar 7, 2026
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.

Window height changes unexpectedly during horizontal-only resize

2 participants