Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions port/linux/src/sdl_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ and the debug keyboard that the game's console reads.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HALO_WINDOWS
/* port/windows/src/win32_window.c, compiled with the Windows SDK */
void win32_window_borderless_apply(SDL_Window *window);
#endif
#if !defined(_WIN32) && !defined(HALO_ANDROID)
#include <signal.h>
#endif
Expand Down Expand Up @@ -839,6 +843,9 @@ BOOL platform_video_initialize(unsigned long width, unsigned long height)
#endif
platform_fullscreen_requested = platform_fullscreen_setting();
platform_fullscreen_kind_apply();
#endif
#ifdef HALO_WINDOWS
win32_window_borderless_apply(platform_window);
#endif
platform_gl_context = SDL_GL_CreateContext(platform_window);
#ifdef HALO_GLES
Expand Down Expand Up @@ -950,6 +957,11 @@ void platform_video_swap(void)
static Uint64 next_frame;
Uint64 interval, now;

#endif
#ifdef HALO_WINDOWS
/* SDL can restore its fullscreen styles on a mode or focus change.
Keep borderless on the desktop before the driver presents a frame. */
win32_window_borderless_apply(platform_window);
#endif
SDL_GL_SwapWindow(platform_window);
#ifdef HALO_WEB
Expand Down
28 changes: 28 additions & 0 deletions port/windows/src/win32_window.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
WIN32_WINDOW.C

Keep borderless OpenGL windows on the desktop. NVIDIA's driver treats
SDL's WS_POPUP fullscreen window as exclusive even without a display mode,
which blanks the monitor when the player switches to another application.
*/

#include <windows.h>
#include <SDL3/SDL.h>

void win32_window_borderless_apply(SDL_Window *window)
{
HWND handle;
LONG_PTR style;

if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) || SDL_GetWindowFullscreenMode(window))
return;
handle = SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
if (!handle)
return;
style = GetWindowLongPtr(handle, GWL_STYLE);
if (!(style & WS_POPUP) && !(GetWindowLongPtr(handle, GWL_EXSTYLE) & WS_EX_TOPMOST))
return;
SetWindowLongPtr(handle, GWL_STYLE, style & ~WS_POPUP);
SetWindowPos(handle, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED);
}