win-capture: Improve fullscreen window detection by Kir-Antipov · Pull Request #10880 · obsproject/obs-studio (original) (raw)

Description

This small change allows windows that extend slightly beyond the defined viewport to be properly detected as fullscreen ones.

While, in general, one should not assume that bottom > top and right > left, win-capture is tailored to Windows, where this assumption always holds true. Therefore, simply swapping == with >= when comparing rect.right with mi.rcMonitor.right and rect.bottom with mi.rcMonitor.bottom should suffice.

Motivation and Context

While it may sound crazy, some apps on Windows use a dirty hack of extending their windows slightly beyond the monitor's declared resolution, usually by 1px, to preserve "true" windowed fullscreen and circumvent some issues related to the exclusive fullscreen mode presented by the graphics library being used, Windows itself, or both. As an example, see: glfw/glfw#527 (comment).

At the moment, these windows are not recognized by OBS Game Capture because they fail the strict comparison rules defined here:

if (rect.left == mi.rcMonitor.left &&
rect.right == mi.rcMonitor.right &&
rect.bottom == mi.rcMonitor.bottom &&
rect.top == mi.rcMonitor.top) {
setup_window(gc, window);
} else {
gc->wait_for_target_startup = true;
}

And this is quite annoying because, from the user's perspective, these windows are clearly in the fullscreen mode.

Additionally, Windows itself doesn't resort to such strict comparison rules, as evidenced by the fact that the taskbar disappears, as it always does for fullscreen windows, even when a window stretches slightly beyond the defined viewport. So, if anything, this should be considered a parity feature.

How Has This Been Tested?

There isn't much to test, so I just ran the freshly built OBS on Windows in a VM to check if it works. Thankfully, a two-symbol change didn't break the project :D

The change is very localized, shouldn't affect other areas of the code, and doesn't introduce any breaking changes. It simply fixes a minor issue/tweaks the pre-existing functionality to better match the, ahem, nuances of Windows development.

Types of changes

Checklist: