win-capture: Improve fullscreen window detection

It's not that uncommon for apps on Windows to use a hacky method of
extending their windows 1-2px past the supported monitor resolution
to preserve "true" windowed fullscreen and circumvent some exclusive
fullscreen-related issues presented by their graphics library,
Windows itself, or both.

Therefore, the fullscreen detection technique has been relaxed
to properly identify windows slightly larger than the monitor's
viewport as fullscreen.

Windows also does something similar, evident by the fact that
the taskbar disappears, as it always does for fullscreen windows,
even when a window stretches slightly beyond the defined viewport.
This commit is contained in:
Kira-NT
2026-08-22 16:02:45 -04:00
committed by Ryan Foster
parent f86e9c1d59
commit 7e22ed2d48
+11 -2
View File
@@ -1104,6 +1104,12 @@ static void setup_window(struct game_capture *gc, HWND window)
}
}
static int rects_nearly_equal(RECT first, RECT second, long delta)
{
return abs(first.left - second.left) <= delta && abs(first.right - second.right) <= delta &&
abs(first.top - second.top) <= delta && abs(first.bottom - second.bottom) <= delta;
}
static void get_fullscreen_window(struct game_capture *gc)
{
HWND window = GetForegroundWindow();
@@ -1137,8 +1143,11 @@ static void get_fullscreen_window(struct game_capture *gc)
return;
}
if (rect.left == mi.rcMonitor.left && rect.right == mi.rcMonitor.right && rect.bottom == mi.rcMonitor.bottom &&
rect.top == mi.rcMonitor.top) {
/* Some apps extend their windows 1-2 pixels beyond the monitor's supported resolution to circumvent certain
* exclusive fullscreen-related issues caused either by their graphics library, Windows itself, or both. Thus,
* we compare the window's corner coordinates with those of the monitor using an acceptable relative margin of
* 2, allowing it to extend slightly past the edge of the monitor. */
if (rects_nearly_equal(rect, mi.rcMonitor, 2)) {
setup_window(gc, window);
} else {
gc->wait_for_target_startup = true;