Borderless Fullscreen mode for Win32 and SDL linux/macOS #759
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.
This is a rewrite of a now-defunct (retracted) pull request but on top of the new NVRHI base.
It implements Borderless Fullscreen mode (-2) as well as Borderless Windowed mode (-1) for Win32 and linux/macOS.
Borderless Fullscreen is available as a menu option within the Fullscreen Resolution menu, and the semantics are "go into borderless fullscreen mode on the current monitor hosting the window". Alt-Enter toggles this from the keyboard. In this mode the mouse can be freed (by opening the console) and Alt-tab works. In addition, on linux you can use the Maximize window bar widget to put the window into borderless fullscreen mode. On macOS this works too, but only if you hold down the option key for "Zoom" functionality of the maximize button, and don't try to use or activate macOS Spaces. I have disabled macOS Spaces via an SDL_HINT but it is not working fully, I suspect there is an SDL bug (see libsdl-org/SDL#7470)
For completeness, I also implemented the Borderless Window mode (-1) which is a custom mode settable via the console only for multi-monitor spanning. Once selected, the menu will display a read-only "Borderless Window", but it cannot be chosen via the GUI menu. This mode must be set by adjusting
r_windowX/Y
, andr_windowWidth/Height
andr_fullscreen = -1
in the console, followed byvid_restart
.In addition, this work cleans up a bunch of error conditions if the window is out of bounds on the desktop by accident, e.g. the multi-monitor config changed, or a monitor is off. The logic is smart enough to detect this and bring the window back to the primary or default display. I have tried to make this resilient for both Win32 and SDL.
In addition, I cleaned up a bunch of dead code in
VKimp_Init()
and removed some defunct cvars.Lastly, I think these changes should fix #740 but I cannot reproduce this error on my setup. I suspect what is happening here is due to an SDL oddity when creating the initial window in Fullscreen mode. Some linux window managers respond poorly to this and have trouble with window dimensions afterwards. Instead, I now create the window in non-fullscreen mode (bordered or borderless), and then go into fullscreen only after the window, device and swap chain are up and running. I am hoping this addresses the issue, and if Robert could test on his setup that would be great.
There is one more bug fix for the initialization of
glConfig.isFullscreen
on SDL platforms - at startup it previously would be set to either 0 or 1, which could mess things up on multi-monitor setups. Now it is properly initialized to the appropriate r_fullscreen mode: -2, -1, 0, 1, 2, ...