Repository navigation
Wayland: Start a popup with the scale of the window it belongs to - #9
Closed
topemalheiro wants to merge 1 commit into
Closed
topemalheiro wants to merge 1 commit into
topemalheiro wants to merge 1 commit into
Conversation
A new surface learns its scale from the compositor only after a roundtrip, and the outputs it is on only after it has been mapped. Until then it reported the largest integer scale of all outputs. PopupMenu reads the scale of its window as soon as the window is created, to compare it with the scale of its target component. With fractional scaling, for example a 1.2 output that the compositor rounds up to 2 for wl_output, a menu opened from a window at 1.2 computed a scale of 1.2 / 2 = 0.6: it came up at 60% of its size and away from its target component. A popup almost always opens on the output of the window it belongs to, so until the compositor reports the popup's own scale, the popup now takes the preferred scales of its owner window, and uses the owner's integer scale while it hasn't entered an output. The owner's override scale is not taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged manually |
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.
On Wayland, a new surface learns its preferred scale from the compositor only after a roundtrip, and its outputs only after it is mapped. Until then
WaylandComponentPeerreported the largest integer scale of all outputs.PopupMenu'sMenuWindowreads the platform scale of its own peer right afteraddToDesktop, to compare it with its target component's peer (since ab9d4d3). With fractional scaling this gives the wrong ratio. Take KDE Plasma with an output at 1.2:wl_output.scaleis 2, while the window the menu is opened from reports 1.2 through wp_fractional_scale_v1. The menu getsscaleFactor1.2 / 2 = 0.6, so it opens at 60% of its size and away from its target. On a 1.0 output next to a 1.2 one, the ratio is 0.5.A popup almost always opens on the output of the window it belongs to. So until the compositor reports the popup's own scale, the popup now takes:
The owner's override scale is not taken. The compositor's own values replace the guess as soon as they arrive. A unit test covers
WaylandSurfaceScale::inheritPreferredScales.Tested with plugdata's standalone on KWin 6.7.2 (run nested) with outputs at 1.2 and 1.0. An Inspector combo box menu opened at 95x77 on the 1.2 output and 79x64 on the 1.0 output before; after the change, 158x128 on both, positioned over the combo box. The main menu and the canvas right-click menu still open correctly. That build also had #8 applied. In JUCE's UnitTestRunner built from this branch, all 41
WaylandSurfaceScalecases pass, the new one included, and so do theWaylandSurfaceOutputstests.Not tested: other compositors (GNOME, Sway), a compositor without wp_fractional_scale_v1 (where only the integer fallback applies), a popup that opens on a different output than its owner, a plugin host that sets a scale override (only the unit test covers that the override isn't copied), and a real desktop session outside the nested compositor. All three files are only compiled on Linux/BSD, so nothing changes on Windows, macOS or iOS.
🤖 Generated with Claude Code