From c92f6807e05955fbe35098ff12f687dc6ec12aca Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 14 Mar 2022 13:24:05 -0400
Subject: [PATCH] Convert "borderless fullscreen windowed mode" into
FULLSCREEN_DESKTOP.
Corrects window creation for Awesomenauts (which still doesn't render with
sdl12-compat; this is a separate problem from that).
Reference issue #168.
---
README.md | 9 +++++++++
src/SDL12_compat.c | 11 +++++++++++
test/testsprite.c | 3 +++
3 files changed, 23 insertions(+)
diff --git a/README.md b/README.md
index a697059..1702b34 100644
--- a/README.md
+++ b/README.md
@@ -111,6 +111,15 @@ The available options are:
option is enabled by default, but not all applications are compatible
with it: try changing this if you can only see a black screen.
+- SDL12COMPAT_FIX_BORDERLESS_FS_WIN:
+ Enables turning borderless windows at the desktop resolution into actual
+ fullscreen windows (so they'll go into a separate space on macOS and
+ properly hide dock windows on other desktop environments, etc).
+ If disabled, applications may not get the full display to theirselves as
+ they expect. This option is enabled by default, but this option is here
+ so it can be manually disabled, in case this causes some negative result
+ we haven't anticipated.
+
- SDL12COMPAT_SCALE_METHOD:
Choose the scaling method used when applications render at a non-native
resolution. The options are `nearest`, for nearest-neighbour sampling
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 3677856..f79c902 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -4948,6 +4948,7 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
SDL_bool use_gl_scaling = SDL_FALSE;
const char *env;
SDL_bool use_highdpi = SDL_TRUE;
+ SDL_bool fix_bordless_fs_win = SDL_TRUE;
FIXME("Should we offer scaling for windowed modes, too?");
if (flags12 & SDL12_OPENGL) {
@@ -4978,6 +4979,11 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
use_highdpi = SDL20_atoi(env) ? SDL_TRUE : SDL_FALSE;
}
+ env = SDL20_getenv("SDL12COMPAT_FIX_BORDERLESS_FS_WIN");
+ if (env) {
+ fix_bordless_fs_win = SDL20_atoi(env) ? SDL_TRUE : SDL_FALSE;
+ }
+
FIXME("currently ignores SDL_WINDOWID, which we could use with SDL_CreateWindowFrom ...?");
flags12 &= ~SDL12_HWACCEL; /* just in case - https://github.com/libsdl-org/SDL-1.2/issues/817 */
@@ -5104,6 +5110,11 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
} else {
fullscreen_flags20 |= SDL_WINDOW_FULLSCREEN;
}
+ } else if (fix_bordless_fs_win && (flags12 & SDL12_NOFRAME) && (width == dmode.w) && (height == dmode.h)) {
+ /* app appears to be trying to do a "borderless fullscreen windowed" mode, so just bump
+ it to FULLSCREEN_DESKTOP so it cooperates with various display managers
+ (into a fullscreen space on macOS, hide the Dock on Gnome, etc). */
+ fullscreen_flags20 |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
if (!VideoWindow20) { /* create it */
diff --git a/test/testsprite.c b/test/testsprite.c
index f83de9a..0e2fd17 100644
--- a/test/testsprite.c
+++ b/test/testsprite.c
@@ -202,6 +202,9 @@ int main(int argc, char *argv[])
if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
videoflags ^= SDL_FULLSCREEN;
} else
+ if ( strcmp(argv[argc], "-noframe") == 0 ) {
+ videoflags ^= SDL_NOFRAME;
+ } else
if ( isdigit(argv[argc][0]) ) {
numsprites = atoi(argv[argc]);
} else {