Skip to content

Fix doubled editor scale for embedded plugin UIs under JUCE 9 - #183

Merged
baconpaul merged 1 commit into
free-audio:mainfrom
Crandall1:fix/juce9-embedded-editor-scale
Aug 5, 2026
Merged

Fix doubled editor scale for embedded plugin UIs under JUCE 9#183
baconpaul merged 1 commit into
free-audio:mainfrom
Crandall1:fix/juce9-embedded-editor-scale

Conversation

@Crandall1

Copy link
Copy Markdown
Contributor

Problem

Built against JUCE 9, CLAP editors open mis-scaled on Windows and X11 at >100% display scaling in hosts that call set_scale() — the UI renders at twice the size of its frame, so only the upper-left quarter is visible. Manually resizing the window heals it. JUCE 8 builds are unaffected, as are macOS (cocoa never receives set_scale()) and 100% displays.

Cause

JUCE 9 changed peer scaling: every peer now derives its scale factor from the window DPI unconditionally (JUCE 8 gated this on isPerMonitorDPIAwareThread()), and an embedded peer reports its parent window's scale. This wrapper still uses the JUCE 8 model — it applies the host's set_scale() as an editor transform and reports transform-inflated bounds — so the scale is applied twice. (JUCE 9's own plugin wrappers moved scaling into the peer via ComponentPeer::setCustomPlatformScaleFactor() / detail::PluginScaleFactorManager.)

Fix

After addToDesktop() in guiWin32Attach() / guiX11Attach(), pin the peer's platform scale to 1.0 with the JUCE 9 setCustomPlatformScaleFactor() API — restoring the contract this wrapper's sizing model assumes — and push the component bounds to the native window. The push matters: the override alone does not resize the window addToDesktop() created at the native scale, and that stale size otherwise flows back into the component on the first window event, leaving the UI mis-scaled until the user resizes it.

Gated on JUCE_VERSION >= 0x090000; JUCE 8 and earlier paths are untouched.

Testing

Verified on Windows (JUCE 9.0.0, display at >100% scaling): the editor now opens at the correct size and interactive resizing stays correct. The X11 path shares the identical mechanism. macOS is untouched (cocoa attach path), and JUCE 8 builds compile the pre-existing code unchanged.

🤖 Generated with Claude Code

JUCE 9 derives every peer's scale from the window DPI unconditionally
(JUCE 8 gated this on isPerMonitorDPIAwareThread()), so a peer embedded
in a host window now follows the host window's DPI. This wrapper applies
the host's set_scale as an editor transform and reports transform-
inflated sizes, so under JUCE 9 the scale was applied twice: at >100%
display scaling the CLAP UI opened at double its frame on Windows and
X11, with only the upper-left quarter visible.

Pin embedded peers to a 1:1 platform scale after addToDesktop using the
JUCE 9 setCustomPlatformScaleFactor API, and push the component bounds
to the native window afterwards: the override alone does not resize the
window addToDesktop created at the native scale, and that stale size
otherwise flows back into the component on the first window event,
leaving the UI mis-scaled until the user resizes it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Crandall1

Copy link
Copy Markdown
Contributor Author

Tested fix on Linux. Verified there as well.

@baconpaul

Copy link
Copy Markdown
Collaborator

Thanks chris; I’ll merge this and the. Add a ice 9 ci stage/

‘do we need it on juce 8 if Sid-iawsrethingynalso?

@baconpaul

Copy link
Copy Markdown
Collaborator

Sorry that was mangled

I meant do we need a juce 8 branch for is dpi aware thread branch

@Crandall1

Copy link
Copy Markdown
Contributor Author

Best I can tell it will (a) work fine with JUCE 8, and (b) is not necessary for JUCE 8. Anyone on 7 or 6 deserves all the trouble they get.

@baconpaul

Copy link
Copy Markdown
Collaborator

Oh and sudara alreaded added juce 9 to ci. So cool I will merge this once we are green. Thanks!

@baconpaul
baconpaul merged commit c1a5ad0 into free-audio:main Aug 5, 2026
18 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