Fix doubled editor scale for embedded plugin UIs under JUCE 9 - #183
Merged
baconpaul merged 1 commit intoAug 5, 2026
Merged
Conversation
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>
Contributor
Author
|
Tested fix on Linux. Verified there as well. |
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? |
Collaborator
|
Sorry that was mangled I meant do we need a juce 8 branch for is dpi aware thread branch |
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. |
Collaborator
|
Oh and sudara alreaded added juce 9 to ci. So cool I will merge this once we are green. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 receivesset_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'sset_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 viaComponentPeer::setCustomPlatformScaleFactor()/detail::PluginScaleFactorManager.)Fix
After
addToDesktop()inguiWin32Attach()/guiX11Attach(), pin the peer's platform scale to 1.0 with the JUCE 9setCustomPlatformScaleFactor()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 windowaddToDesktop()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