Win32: Add GLFW_WIN32_SHOWDEFAULT

Fixes #2359
This commit is contained in:
Camilla Löwy
2024-02-01 02:10:34 +01:00
parent 2afd57bf9b
commit 8946f5314d
8 changed files with 45 additions and 1 deletions

View File

@@ -412,6 +412,7 @@ struct _GLFWwndconfig
} x11;
struct {
GLFWbool keymenu;
GLFWbool showDefault;
} win32;
struct {
char appId[256];

View File

@@ -424,6 +424,7 @@ typedef struct _GLFWwindowWin32
GLFWbool transparent;
GLFWbool scaleToMonitor;
GLFWbool keymenu;
GLFWbool showDefault;
// Cached size used to filter out duplicate events
int width, height;

View File

@@ -1390,6 +1390,7 @@ static int createNativeWindow(_GLFWwindow* window,
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
window->win32.keymenu = wndconfig->win32.keymenu;
window->win32.showDefault = wndconfig->win32.showDefault;
if (!window->monitor)
{
@@ -1772,7 +1773,23 @@ void _glfwMaximizeWindowWin32(_GLFWwindow* window)
void _glfwShowWindowWin32(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_SHOWNA);
int showCommand = SW_SHOWNA;
if (window->win32.showDefault)
{
// NOTE: GLFW windows currently do not seem to match the Windows 10 definition of
// a main window, so even SW_SHOWDEFAULT does nothing
// This definition is undocumented and can change (source: Raymond Chen)
// HACK: Apply the STARTUPINFO show command manually if available
STARTUPINFOW si = { sizeof(si) };
GetStartupInfoW(&si);
if (si.dwFlags & STARTF_USESHOWWINDOW)
showCommand = si.wShowWindow;
window->win32.showDefault = GLFW_FALSE;
}
ShowWindow(window->win32.handle, showCommand);
}
void _glfwHideWindowWin32(_GLFWwindow* window)

View File

@@ -380,6 +380,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_WIN32_KEYBOARD_MENU:
_glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_WIN32_SHOWDEFAULT:
_glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_COCOA_GRAPHICS_SWITCHING:
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
return;