Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borderless Fullscreen mode for Win32 and SDL linux/macOS #759

Closed

Conversation

SRSaunders
Copy link

@SRSaunders SRSaunders commented Mar 16, 2023

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, and r_windowWidth/Height and r_fullscreen = -1 in the console, followed by vid_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, ...

@RobertBeckebans
Copy link
Owner

Borderless fullscreen mode works fine on Windows. I'm going to make a new test build with these changes this weekend.
I was a bit skeptical about r_fullscreen -2 for Alt + Enter but it's probably a good idea when people want to jump between the engine in fullscreen mode and editors like TrenchBroomBFG or Blender.

./RBDoom3BFG +set r_fullscreen -2 also works fine on Linux.

@RobertBeckebans
Copy link
Owner

I merged a rebased version of this into master.

@SRSaunders SRSaunders deleted the borderless-changes branch January 26, 2024 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Just compiled on Linux, unable to launch RBDoom3BFG
2 participants