mirror of
https://github.com/hedge-dev/UnleashedRecomp
synced 2026-08-04 01:22:59 -04:00
Implemented immersive dark title bar
This commit is contained in:
@@ -162,6 +162,10 @@ void Window::Init()
|
|||||||
SDL_GetWindowWMInfo(s_pWindow, &info);
|
SDL_GetWindowWMInfo(s_pWindow, &info);
|
||||||
|
|
||||||
s_handle = info.info.win.window;
|
s_handle = info.info.win.window;
|
||||||
|
|
||||||
|
SetDarkTitleBar(true);
|
||||||
|
|
||||||
|
SDL_ShowWindow(s_pWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::Update()
|
void Window::Update()
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
#include <ui/window_events.h>
|
#include <ui/window_events.h>
|
||||||
#include <cfg/config.h>
|
#include <cfg/config.h>
|
||||||
|
|
||||||
|
#if _WIN32
|
||||||
|
#include <dwmapi.h>
|
||||||
|
#include <kernel/platform.h>
|
||||||
|
#pragma comment(lib, "dwmapi.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_WIDTH 1280
|
#define DEFAULT_WIDTH 1280
|
||||||
#define DEFAULT_HEIGHT 720
|
#define DEFAULT_HEIGHT 720
|
||||||
|
|
||||||
@@ -70,6 +76,23 @@ public:
|
|||||||
SDL_SetWindowTitle(s_pWindow, title);
|
SDL_SetWindowTitle(s_pWindow, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
static bool IsFullscreen()
|
||||||
{
|
{
|
||||||
return SDL_GetWindowFlags(s_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP;
|
return SDL_GetWindowFlags(s_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
@@ -139,7 +162,7 @@ public:
|
|||||||
|
|
||||||
static uint32_t GetWindowFlags()
|
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)
|
if (Config::WindowState == EWindowState::Maximised)
|
||||||
flags |= SDL_WINDOW_MAXIMIZED;
|
flags |= SDL_WINDOW_MAXIMIZED;
|
||||||
|
|||||||
Reference in New Issue
Block a user