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]>
This commit is contained in:
1 parent
a5e2aa44cd
commit
e7724c6d86
2 files changed
+49
-4
No files matched your search
@@ -50,6 +50,13 @@ the managed prefix configuration. It is never a global shared-memory name.
|
||||
|
||||
## Geometry and session changes
|
||||
|
||||
An exact Wine monitor rectangle maps onto the entire selected frame when their
|
||||
aspect ratios match. Pixel dimensions may differ under fractional scaling, where
|
||||
Xwayland's render size can exceed the portal's native frame size. Partial regions
|
||||
and whole-virtual-desktop requests retain the existing virtual-desktop mapping.
|
||||
This does not establish monitor identity between Wine and the portal; selecting
|
||||
a non-primary monitor still requires consistent client/input coordinates.
|
||||
|
||||
Each transport inode has immutable geometry. A negotiated size change creates
|
||||
a new mode-0600 file, initializes its header and slots, then atomically replaces
|
||||
the transport path. The previous mapping remains valid for existing readers;
|
||||
|
||||
+42
-4
@@ -492,10 +492,48 @@ static BOOL feed_capture_frame_locked(HDC hdc_dest, int x, int y, int width,
|
||||
screen_width = (int)fw;
|
||||
if (screen_height < 1)
|
||||
screen_height = (int)fh;
|
||||
int sx = (int)((int64_t)source_x * fw / screen_width);
|
||||
int sy = (int)((int64_t)source_y * fh / screen_height);
|
||||
int sw = (int)((int64_t)source_width * fw / screen_width);
|
||||
int sh = (int)((int64_t)source_height * fh / screen_height);
|
||||
/* The frame holds exactly one monitor, but the client may ask
|
||||
* for that monitor's whole rectangle. Wine reports the
|
||||
* compositor's monitors in its own order, so the virtual desktop
|
||||
* is only the right basis for a partial request; a complete
|
||||
* monitor request must map onto the whole frame. Fractional
|
||||
* scaling can give Xwayland and the portal different pixel
|
||||
* sizes, so compare aspect ratios rather than resolutions. */
|
||||
int sx = 0;
|
||||
int sy = 0;
|
||||
int sw = 0;
|
||||
int sh = 0;
|
||||
RECT requested;
|
||||
requested.left = (LONG)source_x;
|
||||
requested.top = (LONG)source_y;
|
||||
requested.right = (LONG)source_x + (LONG)source_width;
|
||||
requested.bottom = (LONG)source_y + (LONG)source_height;
|
||||
HMONITOR monitor = (source_width > 0 && source_height > 0)
|
||||
? MonitorFromRect(&requested, MONITOR_DEFAULTTONULL)
|
||||
: NULL;
|
||||
MONITORINFO info;
|
||||
info.cbSize = sizeof(info);
|
||||
BOOL whole_monitor = FALSE;
|
||||
if (monitor != NULL && GetMonitorInfoA(monitor, &info)) {
|
||||
whole_monitor =
|
||||
info.rcMonitor.left == requested.left &&
|
||||
info.rcMonitor.top == requested.top &&
|
||||
info.rcMonitor.right == requested.right &&
|
||||
info.rcMonitor.bottom == requested.bottom &&
|
||||
(int64_t)(info.rcMonitor.right - info.rcMonitor.left) * fh ==
|
||||
(int64_t)(info.rcMonitor.bottom - info.rcMonitor.top) * fw;
|
||||
}
|
||||
if (whole_monitor) {
|
||||
sx = 0;
|
||||
sy = 0;
|
||||
sw = (int)fw;
|
||||
sh = (int)fh;
|
||||
} else {
|
||||
sx = (int)((int64_t)source_x * fw / screen_width);
|
||||
sy = (int)((int64_t)source_y * fh / screen_height);
|
||||
sw = (int)((int64_t)source_width * fw / screen_width);
|
||||
sh = (int)((int64_t)source_height * fh / screen_height);
|
||||
}
|
||||
if (sw < 1)
|
||||
sw = (int)fw;
|
||||
if (sh < 1)
|
||||
|
||||
Reference in new issue
Block a user