diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 9b2b95ad..1cd5aa53 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1117,6 +1117,7 @@ extern "C" { */ #define GLFW_X11_INSTANCE_NAME 0x00024002 #define GLFW_WIN32_KEYBOARD_MENU 0x00025001 +#define GLFW_WIN32_GENERIC_BADGE 0x00025002 /*! @brief Wayland specific * [window hint](@ref GLFW_WAYLAND_APP_ID_hint). * diff --git a/src/internal.h b/src/internal.h index a7101a4b..36719295 100644 --- a/src/internal.h +++ b/src/internal.h @@ -415,6 +415,7 @@ struct _GLFWwndconfig } x11; struct { GLFWbool keymenu; + GLFWbool genericBadge; } win32; struct { char appId[256]; diff --git a/src/win32_platform.h b/src/win32_platform.h index d08a4634..bc2785be 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -497,6 +497,7 @@ typedef struct _GLFWwindowWin32 GLFWbool transparent; GLFWbool scaleToMonitor; GLFWbool keymenu; + GLFWbool genericBadge; // Cached size used to filter out duplicate events int width, height; diff --git a/src/win32_window.c b/src/win32_window.c index fa8ff78b..98995bf0 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1384,6 +1384,7 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.keymenu = wndconfig->win32.keymenu; + window->win32.genericBadge = wndconfig->win32.genericBadge; if (!window->monitor) { @@ -2046,20 +2047,25 @@ void _glfwSetWindowBadgeWin32(_GLFWwindow* window, int count) } count = min(count, 999); - if (count > 0) { - //Convert count to string (its guaranteed to be at max 3 digits) - memset(countStr, 0, 4 * sizeof(char)); - sprintf(countStr, "%d", count); - countWStr = _glfwCreateWideStringFromUTF8Win32(countStr); - if (!countWStr) + if (window->win32.genericBadge) + icon = GenerateGenericBadgeIcon(window->win32.handle); + else { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar badge count"); - return; + //Convert count to string (its guaranteed to be at max 3 digits) + memset(countStr, 0, 4 * sizeof(char)); + sprintf(countStr, "%d", count); + countWStr = _glfwCreateWideStringFromUTF8Win32(countStr); + if (!countWStr) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar badge count"); + return; + } + + icon = GenerateTextBadgeIcon(window->win32.handle, countWStr); } - icon = GenerateTextBadgeIcon(window->win32.handle, countWStr); if (!icon) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar badge count"); diff --git a/src/window.c b/src/window.c index 522025eb..1ccf9f2d 100644 --- a/src/window.c +++ b/src/window.c @@ -382,6 +382,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_GENERIC_BADGE: + _glfw.hints.window.win32.genericBadge = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; return;