Skip to content

Return get_display_size() in window units with display scaling - #2948

Merged
pvcraven merged 1 commit into
developmentfrom
fix/display-size-scaling
Oct 8, 2026
Merged

pvcraven merged 1 commit into
developmentfrom
fix/display-size-scaling

Conversation

@pvcraven

@pvcraven pvcraven commented Oct 8, 2026

Copy link
Copy Markdown
Member

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() Window framebuffer
development 1920×1200 2400×1500 (too big)
this PR 1536×960 1920×1200 (fills the screen exactly)

The fix

  • On Windows and Linux in stretch mode, 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.
  • Unchanged elsewhere: in pyglet's stretch mode, macOS doesn't scale window sizes because its screen sizes are already in points, and the web doesn't scale them either. With "platform" DPI scaling it isn't divided anywhere.
  • center_window(): this used get_display_size(), but it needs pixels to match the framebuffer size and set_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.py uses a fake screen, since tests run with "platform" scaling:

  • Stretch on Windows and Linux: divided by scales 1.0, 1.25, 1.5 and 1.75, including rounding down.
  • macOS and the web: unchanged.
  • "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

@pvcraven
pvcraven force-pushed the fix/display-size-scaling branch 2 times, most recently from f121681 to c87ec69 Compare October 8, 2026 17:22
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
pvcraven force-pushed the fix/display-size-scaling branch from c87ec69 to 3cfd9b3 Compare October 8, 2026 17:23
@pvcraven
pvcraven merged commit bc52add into development Oct 8, 2026
7 checks passed
@pvcraven
pvcraven deleted the fix/display-size-scaling branch October 8, 2026 17:23
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.

Using screen dimensions for window is too big

1 participant