Skip to content

refactor/gtk4: fix scaling issues#43

Open
fufexan wants to merge 4 commits intoStremio:refactor/gtk4from
fufexan:scaling-fix
Open

refactor/gtk4: fix scaling issues#43
fufexan wants to merge 4 commits intoStremio:refactor/gtk4from
fufexan:scaling-fix

Conversation

@fufexan
Copy link
Copy Markdown

@fufexan fufexan commented Feb 27, 2026

I've been experiencing scaling issues such as:

  • blurriness on scaled displays
  • scale not changing between scaled and unscaled displays
  • cursor offsets

I have no idea how to debug and fix all these issues on my own so I used Claude Opus 4.6. Here's its summary:

Root cause: CEF's OSR mode ignores device_scale_factor for paint buffer size — it always renders at 1× view_rect dimensions. The old GLArea code upscaled this via GL, and fractional scaling made it worse.

Solution (across all commits):

  1. Widget + GdkMemoryTexture replaces GLArea — CPU frame buffer with dirty rect blitting, rendered via GTK's snapshot pipeline at exact fractional scale
  2. view_rect = device pixels with device_scale_factor=1 — CEF renders at native resolution
  3. Zoom level = ln(scale)/ln(1.2) — compensates DPI so content layouts at correct CSS size
  4. Mouse coordinates × scale — transforms GTK CSS coords to device pixel coords for CEF
  5. Surface scale property listener — detects fractional scale changes when moving between monitors
  6. queue_allocate() on scale change — forces recomputation of device pixel dimensions

I don't know whether this code is robust or pragmatic, and some of the changes feel intrusive. Feel free to change in any way necessary.

fufexan and others added 4 commits February 27, 2026 18:04
Replace GLArea with Widget + GdkMemoryTexture for sharp rendering at
fractional scales. CEF OSR doesn't apply device_scale_factor to paint
buffers, so we bypass it entirely: give CEF device pixel dimensions as
view_rect with device_scale_factor=1, and use zoom level for DPI
compensation. Mouse coordinates are scaled to device pixels before
forwarding to CEF.

Listen for GdkSurface 'scale' property changes (fractional) instead of
widget 'scale-factor' (integer) to properly handle cross-monitor moves.
Queue widget allocate on scale change to recompute device pixel dimensions.

Remove debug logging added during investigation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@fxzzi
Copy link
Copy Markdown

fxzzi commented Mar 11, 2026

image

works4me

@tymmesyde tymmesyde force-pushed the refactor/gtk4 branch 3 times, most recently from 3413145 to 0b83716 Compare April 29, 2026 10:59
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