Merge branch 'main' into options-menu

This commit is contained in:
Hyper 2024-12-03 19:31:30 +00:00
commit 578dc8c186
2 changed files with 28 additions and 1 deletions

View file

@ -179,6 +179,10 @@ void Window::Init()
SDL_GetWindowWMInfo(s_pWindow, &info);
s_handle = info.info.win.window;
SetDarkTitleBar(true);
SDL_ShowWindow(s_pWindow);
}
void Window::Update()

View file

@ -5,6 +5,12 @@
#include <ui/window_events.h>
#include <user/config.h>
#if _WIN32
#include <dwmapi.h>
#include <kernel/platform.h>
#pragma comment(lib, "dwmapi.lib")
#endif
#define DEFAULT_WIDTH 1280
#define DEFAULT_HEIGHT 720
@ -66,6 +72,23 @@ public:
SDL_SetWindowTitle(s_pWindow, title ? title : GetTitle());
}
static void SetDarkTitleBar(bool isEnabled)
{
#if _WIN32
auto version = GetPlatformVersion();
if (version.Major < 10 || version.Build <= 17763)
return;
auto flag = version.Build >= 18985
? DWMWA_USE_IMMERSIVE_DARK_MODE
: 19; // DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1
const DWORD useImmersiveDarkMode = isEnabled;
DwmSetWindowAttribute(s_handle, flag, &useImmersiveDarkMode, sizeof(useImmersiveDarkMode));
#endif
}
static bool IsFullscreen()
{
return SDL_GetWindowFlags(s_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP;
@ -135,7 +158,7 @@ public:
static uint32_t GetWindowFlags()
{
uint32_t flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
uint32_t flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
if (Config::WindowState == EWindowState::Maximised)
flags |= SDL_WINDOW_MAXIMIZED;