Repository navigation
Return get_display_size() in window units with display scaling - #2948
Merged
Merged
Conversation
pvcraven
force-pushed
the
fix/display-size-scaling
branch
2 times, most recently
from
October 8, 2026 17:22
f121681 to
c87ec69
Compare
In stretch mode, pyglet multiplies a window's size by the screen's scale on Windows and Linux, but get_display_size() returned the screen's size in pixels, so a window that size was scaled up twice and didn't fit on the screen. It now divides by the scale there, rounding down. macOS and the web don't scale windows, so they're unchanged (#2791). center_window() needs the size in pixels, to match the framebuffer and set_location, so it reads the window's screen directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pvcraven
force-pushed
the
fix/display-size-scaling
branch
from
October 8, 2026 17:23
c87ec69 to
3cfd9b3
Compare
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.
Summary
Fixes #2791: a window sized with
arcade.get_display_size()doesn't fit on the screen with display scaling.Arcade uses pyglet's
"stretch"DPI mode. On Windows and Linux, it multiplies a window's requested size by the display scale.get_display_size()returned the screen's size in pixels, so a window that size was scaled up a second time.Measured on this machine (1920×1200 screen, Windows at 125%):
get_display_size()The fix
get_display_size()divides by the screen's scale. It rounds down, so the scaled window is never bigger than the screen. The docstring explains that the size is in window units."platform"DPI scaling it isn't divided anywhere.center_window(): this usedget_display_size(), but it needs pixels to match the framebuffer size andset_location. It now reads the window's own screen. Centered, an 800×600 window lands at (460, 225), the same position as before.Tests
New
tests/unit/window/test_display_size.pyuses a fake screen, since tests run with"platform"scaling:"platform"mode: unchanged.9 of the 15 fail on development. I also checked by hand on a real 125% display, with the results in the table above.
Full suite: 1771 passed. ruff, mypy and pyright all pass.
The changelog has an entry under Unreleased → Fixes.
🤖 Generated with Claude Code