Added GLFW_WIN32_GENERIC_BADGE window hint

This commit is contained in:
GamesTrap 2023-03-08 21:22:10 +01:00
parent 367a50e82d
commit de81fae268
No known key found for this signature in database
GPG Key ID: 31DFD452434ECDA3
5 changed files with 21 additions and 9 deletions

View File

@ -1117,6 +1117,7 @@ extern "C" {
*/ */
#define GLFW_X11_INSTANCE_NAME 0x00024002 #define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 #define GLFW_WIN32_KEYBOARD_MENU 0x00025001
#define GLFW_WIN32_GENERIC_BADGE 0x00025002
/*! @brief Wayland specific /*! @brief Wayland specific
* [window hint](@ref GLFW_WAYLAND_APP_ID_hint). * [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
* *

View File

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

View File

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

View File

@ -1384,6 +1384,7 @@ static int createNativeWindow(_GLFWwindow* window,
window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
window->win32.keymenu = wndconfig->win32.keymenu; window->win32.keymenu = wndconfig->win32.keymenu;
window->win32.genericBadge = wndconfig->win32.genericBadge;
if (!window->monitor) if (!window->monitor)
{ {
@ -2046,8 +2047,11 @@ void _glfwSetWindowBadgeWin32(_GLFWwindow* window, int count)
} }
count = min(count, 999); count = min(count, 999);
if (count > 0) if (count > 0)
{
if (window->win32.genericBadge)
icon = GenerateGenericBadgeIcon(window->win32.handle);
else
{ {
//Convert count to string (its guaranteed to be at max 3 digits) //Convert count to string (its guaranteed to be at max 3 digits)
memset(countStr, 0, 4 * sizeof(char)); memset(countStr, 0, 4 * sizeof(char));
@ -2060,6 +2064,8 @@ void _glfwSetWindowBadgeWin32(_GLFWwindow* window, int count)
} }
icon = GenerateTextBadgeIcon(window->win32.handle, countWStr); icon = GenerateTextBadgeIcon(window->win32.handle, countWStr);
}
if (!icon) if (!icon)
{ {
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar badge count"); _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar badge count");

View File

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