Skip to content

Make the BodyCaptcha editor window scale and resize - #143

Merged
charliehuge merged 1 commit into
mainfrom
claude/editor-hidpi-window-k7Rm2
Sep 6, 2026
Merged

charliehuge merged 1 commit into
mainfrom
claude/editor-hidpi-window-k7Rm2

Conversation

@ii-impy

@ii-impy ii-impy commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

What

bodycaptcha_editor.py opened a fixed, non-resizable window that renders very small on a HiDPI display.

-        self._surf    = pygame.display.set_mode((W, H))
+        self._surf    = pygame.display.set_mode((W, H), pygame.SCALED | pygame.RESIZABLE)

Why

Two separate causes, both at set_mode:

  • Small: W, H = 1060, 700 assumes a ~1080p display. On a 3072x1920 panel under Wayland/XWayland with xwayland-native-scaling enabled, SDL reports the desktop at full native resolution and nothing upscales the window — so it is 1060x700 physical pixels, about a third of the screen width.
  • Not resizable: no RESIZABLE flag, so the window manager has no resize handle.

SCALED is the right lever rather than RESIZABLE alone: the layout is computed from the W/H/GRID_W constants throughout (_cell_size, _grid_origin, _thumb_rects), so a bare resizable window would leave a 1060x700 image in the corner of a larger frame. SCALED keeps that math intact and lets SDL scale the result.

The two sibling tools (app.py, body_grid_tester.py) avoid this by running FULLSCREEN | NOFRAME; the editor was the only one showing a fixed windowed size.

Testing

  • Verified on a 3072x1920 display: SDL now opens a 2120x1400 window over the 1060x700 render surface, and the window resizes.
  • Grid clicks confirmed working in the running editor. Mouse coordinates arrive via both ev.pos and pygame.mouse.get_pos(); SCALED translates both back into surface space, so hit-testing is unaffected.
  • test_bodycaptcha_levels.py passes (7 tests). Note it covers level data, not the display layer — there is no automated coverage of this line.

No open issue tracks this; found while running the editor locally.

🤖 Generated with Claude Code

The editor called set_mode((W, H)) with no flags, so it opened a fixed
1060x700 window with no resize grip. Those constants assume a ~1080p
display; on a HiDPI panel under Wayland/XWayland with no compositor
upscaling, that is 1060x700 physical pixels — roughly a third of a
3072x1920 screen — and the window manager has nothing to drag.

Adding SCALED lets SDL open the window at a device-appropriate size
while the code keeps drawing into the 1060x700 surface all the layout
math depends on (_cell_size, _grid_origin, _thumb_rects). RESIZABLE
makes it draggable. Mouse positions from both ev.pos and
pygame.mouse.get_pos() are translated back to surface coordinates, so
grid and thumbnail hit-testing is unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@charliehuge
charliehuge merged commit 43b86ee into main Sep 6, 2026
1 check passed
@charliehuge
charliehuge deleted the claude/editor-hidpi-window-k7Rm2 branch September 6, 2026 07:22
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