Skip to content

GNOME Wayland mixed-DPI capture applies HiDPI scaling twice #4871

Description

@lorenzo-di-gregorio

Flameshot Version

Flameshot v14.0.0 (da6121b), compiled with Qt 6.2.4. The affected scaling path is also present on current master (369f9ed9).

Installation Type

Linux package manager (14.0.0-1) and a build from source for diagnosis/testing.

Operating System type and version

Ubuntu 22.04.5 LTS, GNOME 42.9, Wayland.

Description

On a GNOME Wayland mixed-DPI desktop, selecting the HiDPI monitor from the portal-based capture flow produces a blurred preview whose selection coordinates cover only the top-left quarter of the display.

The relevant geometry is:

  • HDMI-2: 2560x1440, DPR 1, position +2298+0
  • eDP-1: 3840x2400, DPR 2, position +0+1440
  • GNOME portal screenshot: 4858x3840, DPR 1

Here, Qt 6.2 reports the HiDPI screen geometry in native coordinates (3840x2400), and the portal composite uses the same native-coordinate canvas. ScreenGrabber::cropToMonitor() therefore correctly crops 3840x2400 pixels, but then treats the portal scale of 1 as a mismatch with the screen DPR of 2 and upscales that crop to 7680x4800. Assigning DPR 2 after that makes the capture surface use the raw 3840x2400 geometry instead of its 1920x1200 device-independent size. This applies HiDPI scaling twice: the preview is blurred and pointer/selection coordinates cover only one quarter of it.

This is the same visible symptom described in #265 and is related to the mixed-DPI reports #227, #2849, and #3444. These reports are closed, several following #4498, but the GNOME Wayland native-coordinate case remains reproducible.

Steps to reproduce

  1. Use GNOME Wayland with one DPR 1 monitor and one DPR 2 monitor.
  2. Run QT_QPA_PLATFORM=wayland flameshot gui.
  3. In GNOME's portal dialog, share the desktop screenshot.
  4. In Flameshot's "click to select a screen" preview, select the DPR 2 monitor.
  5. Try to make a region selection across that monitor.

Actual result: the preview is lower resolution/blurred, and selection works only in the top-left quarter.

Expected result: the HiDPI monitor is shown at its native sharpness and the full monitor is selectable.

Proposed fix

When GNOME Wayland returns a portal screenshot whose X and Y scale are both 1, keep the cropped pixels at their native resolution instead of scaling them to geometry * DPR. Then, when a Wayland screen's raw geometry size equals the screenshot's pixel size and DPR is greater than 1, size the capture surface and selection area using geometry / DPR.

I have tested this behavior on the hardware/configuration above; it restores a sharp preview and full-screen selection. A linked pull request contains the guarded implementation.

Screenshots or screen recordings

The geometry and scaling calculations above were captured with Flameshot's debug capture logging. I can provide additional logs if needed.

System Information

  • Ubuntu 22.04.5 LTS
  • GNOME Shell 42.9
  • Wayland session
  • Qt 6.2.4
  • Mixed-DPI layout: external 2560x1440 at DPR 1 plus internal 3840x2400 at DPR 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions