[Windows] Remove visible WINDOW_MODE_FULLSCREEN border by setting window region.
An attempt to solve https://github.com/godotengine/godot/issues/63500 and preserve multi-window functionality.
In non-exclusive full-screen mode (or borderless maximized, which is the same thing), the window client area is set to be 2 pixels wider than a screen, renderer context size is set to screen size, and extra pixels are cut by setting window region.
- [x] Test on NVIDIA GPU.
- [x] Test on AMD GPU.
- [x] Test on Intel GPU.
- [x] Test for potential performance changes in
WINDOW_MODE_FULLSCREEN.
Expected test project behavior:
- Red border IS NOT visible in all modes (clean color).
- Green border IS fully visible on all window sides and in all modes (draw in the usable window area from the code).
- Option box is functional in all modes except
WINDOW_MODE_EXCLUSIVE_FULLSCREEN.
It breaks the application when fullscreen is set in project settings. It first shows black screen, then application window disappears and trying to open it from alt+tab or taskbar doesn't work anymore. It shows an empty preview.
Setting fullscreen at runtime works well!
GPU is AMD Radeon R7
Hmm, I haven't tested it yet but honestly I am a bit wary of SetWindowRgn. I am not sure how it interacts with DWM and it just feels like a dated technology. Perhaps actual testing will prove me wrong?
Hey all! Just bumping this PR and wondering what testing still remains before it can be merged. Is there anything I can help with? Seems like this would be a great benefit to folks trying to create a non-exclusive fullscreen setup that doesn't impact scaling.
It seems to be missing some testing. See the checkboxes in the OP.
Gotcha! Wasn't sure if the checklist had actually been updated, since it looks like @Calinou gathered some perf metrics. Is there a more exhaustive set of metrics to validate?
In the meantime, I did some testing on an Intel GPU (Intel Iris Xe Graphics) on Windows 11. Note: I did merge with latest main before testing; given the recent embedded game window changes also touched this file, there may be additional adjustments to make. Going down the expected test project behavior:
- Red border was indeed never visible, though the red clear color in the background was visible when resizing (I believe that's expected)
- Green border was visible most of the time, but I've attached a video where switching into borderless seems to cause the window to resize incorrectly and cut off the green border (see video)
- I can switch values in the option box on exclusive fullscreen -- and in fact the window flashes whenever I do
Hopefully the video below is helpful. I'll continue to test, peruse the changes, and update folks if I find anything else!
https://github.com/user-attachments/assets/cefa9fa6-63ae-4fc8-ac60-e62f5ca1ed9e
Needs a rebase before this can be merged
Thanks!