1 Commits
Author SHA1 Message Date
moxuunandXuc Pan e7724c6d86 fix(hook): map a full-monitor capture request onto the whole frame (#30)
* fix(hook): map a full-monitor capture request onto the whole frame

The Wine hook scaled the client's source rectangle by the virtual desktop
size, on the assumption that a captured frame covers every monitor. The
Wayland portal capture path selects a single monitor, so on a multi-monitor
desktop the frame is narrower than the virtual desktop and the horizontal
scale factor was wrong.

With a 4480x1600 virtual desktop and a 2560x1600 frame, a request for the
whole 2560x1600 monitor produced:

    sw = 2560 * 2560 / 4480 = 1462

That sampled only the left 57% of the frame and stretched it across the
destination, dropping the right 43%. The vertical factor stayed correct
(1600 * 1600 / 1600), which is why the symptom was a missing right edge
rather than a visible aspect distortion. On a single monitor the virtual
desktop equals the frame and the two factors agree, so the bug stayed
hidden.

Detect the case where the requested rectangle covers exactly one Wine
monitor whose size equals the frame, and use the whole frame. Every other
request keeps the previous virtual-desktop mapping, so partial regions are
unchanged.

This does not add portal coordinates to the frame protocol. Portal
coordinates are compositor coordinates and Wine enumerates monitors in a
different order, so capturing a monitor that is not the Wine primary
monitor still needs a separate output-to-monitor mapping.

* fix(hook): keep full-monitor geometry across fractional scaling

GNOME 125 percent scaling can expose a 2048x1152 Wine monitor while the selected Portal frame remains 1280x720. Match the aspect ratio of an exact monitor rectangle instead of requiring equal pixel dimensions; leave partial and virtual-desktop requests on the existing path.

Verified with real isolated GNOME dual monitors, native DMA-BUF capture, and a real Windows FFmpeg GDI consumer. The old fractional-scale output drops the desktop panel; the revised output preserves the whole image. No test scripts added.

---------

Co-authored-by: Xuc Pan <[email protected]>
2026-10-18 00:18:41 +08:00