win-capture: Improve fullscreen window detection #10880
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andright > left
,win-capture
is tailored to Windows, where this assumption always holds true. Therefore, simply swapping==
with>=
when comparingrect.right
withmi.rcMonitor.right
andrect.bottom
withmi.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:
obs-studio/plugins/win-capture/game-capture.c
Lines 1221 to 1228 in 48b1298
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: