Merge origin/taskbar-progress into origin/application-badge

This commit is contained in:
GamesTrap 2023-03-21 13:36:38 +01:00
commit 3ed4a360fd
No known key found for this signature in database
GPG Key ID: 31DFD452434ECDA3
25 changed files with 198 additions and 179 deletions

View File

@ -2,12 +2,6 @@ cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR)
project(GLFW VERSION 3.4.0 LANGUAGES C) project(GLFW VERSION 3.4.0 LANGUAGES C)
set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if (POLICY CMP0069) if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW) cmake_policy(SET CMP0069 NEW)
endif() endif()
@ -18,9 +12,7 @@ endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} GLFW_STANDALONE)
set(GLFW_STANDALONE TRUE)
endif()
option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE}) option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})

View File

@ -189,6 +189,7 @@ video tutorials.
- pthom - pthom
- Martin Pulec - Martin Pulec
- Guillaume Racicot - Guillaume Racicot
- Juan Ramos
- Christian Rauch - Christian Rauch
- Simon Richter - Simon Richter
- Philip Rideout - Philip Rideout

View File

@ -121,7 +121,7 @@ information on what to include when reporting a bug.
## Changelog ## Changelog
- Added `glfwSetWindowTaskbarProgress` allowing to display progress on the taskbar (#2286,#1183) - Added `glfwSetWindowProgressIndicator` for displaying progress on the dock or taskbar (#2286,#1183)
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) - Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, - Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to

View File

@ -1159,21 +1159,21 @@ not supported, the application as a whole. Once the user has given it
attention, the system will automatically end the request. attention, the system will automatically end the request.
@subsection window_taskbar_progress Window taskbar progress @subsection window_progress_indicator Window progress indicator
If you wish to display the progress of some action on the taskbar, you can If you wish to display the progress of some action on the Dock icon or task bar, you can
do this with @ref glfwSetWindowTaskbarProgress. do this with @ref glfwSetWindowProgressIndicator.
@code @code
glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_NORMAL, 50); glfwSetWindowProgressIndicator(window, GLFW_PROGRESS_INDICATOR_NORMAL, 0.5);
@endcode @endcode
There are different taskbar progress states available for you to use: There are different progress states available for you to use:
- @ref GLFW_TASKBAR_PROGRESS_DISABLED - @ref GLFW_PROGRESS_INDICATOR_DISABLED
- @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE - @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE
- @ref GLFW_TASKBAR_PROGRESS_NORMAL - @ref GLFW_PROGRESS_INDICATOR_NORMAL
- @ref GLFW_TASKBAR_PROGRESS_ERROR - @ref GLFW_PROGRESS_INDICATOR_ERROR
- @ref GLFW_TASKBAR_PROGRESS_PAUSED - @ref GLFW_PROGRESS_INDICATOR_PAUSED
The last argument is the progress percentage to display. The last argument is the progress percentage to display.
It has a valid range of 0.0 to 1.0. It has a valid range of 0.0 to 1.0.

View File

@ -1279,51 +1279,51 @@ extern "C" {
* *
* Disable the progress bar. * Disable the progress bar.
* *
* Used by @ref window_taskbar_progress. * Used by @ref window_progress_indicator.
*/ */
#define GLFW_TASKBAR_PROGRESS_DISABLED 0 #define GLFW_PROGRESS_INDICATOR_DISABLED 0
/*! @brief Display the progress bar in an indeterminate state. /*! @brief Display the progress bar in an indeterminate state.
* *
* Display the progress bar in an indeterminate state. * Display the progress bar in an indeterminate state.
* *
* @remark @win32 This displays the progress bar animation cycling repeatedly. * @remark @win32 This displays the progress bar animation cycling repeatedly.
* *
* @remark @x11 @wayland This behaves like @ref GLFW_TASKBAR_PROGRESS_NORMAL. * @remark @x11 @wayland This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
* *
* @remark @macos This displays a standard indeterminate `NSProgressIndicator`. * @remark @macos This displays a standard indeterminate `NSProgressIndicator`.
* *
* Used by @ref window_taskbar_progress. * Used by @ref window_progress_indicator.
*/ */
#define GLFW_TASKBAR_PROGRESS_INDETERMINATE 1 #define GLFW_PROGRESS_INDICATOR_INDETERMINATE 1
/*! @brief Display the normal progress bar. /*! @brief Display the normal progress bar.
* *
* Display the normal progress bar. * Display the normal progress bar.
* *
* Used by @ref window_taskbar_progress. * Used by @ref window_progress_indicator.
*/ */
#define GLFW_TASKBAR_PROGRESS_NORMAL 2 #define GLFW_PROGRESS_INDICATOR_NORMAL 2
/*! @brief Display the progress bar in an error state. /*! @brief Display the progress bar in an error state.
* *
* Display the progress bar in an error state. * Display the progress bar in an error state.
* *
* @remark @win32 This displays a red progress bar. * @remark @win32 This displays a red progress bar.
* *
* @remark @x11 @wayland @macos This behaves like @ref GLFW_TASKBAR_PROGRESS_NORMAL. * @remark @x11 @wayland @macos This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
* *
* Used by @ref window_taskbar_progress. * Used by @ref window_progress_indicator.
*/ */
#define GLFW_TASKBAR_PROGRESS_ERROR 3 #define GLFW_PROGRESS_INDICATOR_ERROR 3
/*! @brief Display the progress bar in a paused state. /*! @brief Display the progress bar in a paused state.
* *
* Display the progress bar in a paused state. * Display the progress bar in a paused state.
* *
* @remark @win32 This displays a yellow progress bar. * @remark @win32 This displays a yellow progress bar.
* *
* @remark @x11 @wayland @macos This behaves like @ref GLFW_TASKBAR_PROGRESS_NORMAL. * @remark @x11 @wayland @macos This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
* *
* Used by @ref window_taskbar_progress. * Used by @ref window_progress_indicator.
*/ */
#define GLFW_TASKBAR_PROGRESS_PAUSED 4 #define GLFW_PROGRESS_INDICATOR_PAUSED 4
/*! @} */ /*! @} */
#define GLFW_CONNECTED 0x00040001 #define GLFW_CONNECTED 0x00040001
@ -3358,43 +3358,45 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
*/ */
GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images); GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
/*! @brief Sets the taskbar progress for the specified window. /*! @brief Sets the dock or taskbar progress indicator for the specified window.
* *
* This function sets the taskbar progress of the specified window. * This function sets the dock or taskbar progress indicator of the specified window.
* *
* @param[in] window The window whose taskbar progress to set. * @param[in] window The window whose progress to set.
* @param[in] progressState State of the progress to be displayed in the taskbar. Valid values are: * @param[in] progressState The state of the progress to be displayed in the dock
* @ref GLFW_TASKBAR_PROGRESS_DISABLED, @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE, * or taskbar. Valid values are: @ref GLFW_PROGRESS_INDICATOR_DISABLED,
* @ref GLFW_TASKBAR_PROGRESS_NORMAL, @ref GLFW_TASKBAR_PROGRESS_ERROR * @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_NORMAL,
* and @ref GLFW_TASKBAR_PROGRESS_PAUSED. * @ref GLFW_PROGRESS_INDICATOR_ERROR and @ref GLFW_PROGRESS_INDICATOR_PAUSED.
* @param[in] value The amount of completed progress to set. Valid range is 0.0 to 1.0. * @param[in] value The amount of completed progress to set. Valid range is 0.0 to 1.0.
* This is ignored if progressState is set to @ref GLFW_TASKBAR_PROGRESS_DISABLED. * This is ignored if progressState is set to @ref GLFW_PROGRESS_INDICATOR_DISABLED.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR, * GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR,
* @ref GLFW_FEATURE_UNIMPLEMENTED and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * @ref GLFW_FEATURE_UNIMPLEMENTED and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
* *
* @remark @win32 On Windows Vista and earlier, this function will emit @ref GLFW_FEATURE_UNAVAILABLE. * @remark @win32 On Windows Vista and earlier, this function will emit
* @ref GLFW_FEATURE_UNAVAILABLE.
* *
* @remark @macos There exists only one Dock icon progress bar, and this * @remark @macos There exists only one Dock icon progress bar, and this
* displays the combined values of all the windows. * displays the combined values of all the windows.
* *
* @remark @x11 @wayland Requires a valid application desktop file with the same name * @remark @x11 @wayland Requires a valid application desktop file with the same name
* as the compiled executable. Due to limitations in the Unity Launcher API * as the compiled executable. Due to limitations in the Unity Launcher API
* @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE, @ref GLFW_TASKBAR_PROGRESS_ERROR and @ref GLFW_TASKBAR_PROGRESS_PAUSED * @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_ERROR
* have the same behaviour as @ref GLFW_TASKBAR_PROGRESS_NORMAL. The Unity Launcher API is only known * and @ref GLFW_PROGRESS_INDICATOR_PAUSED have the same behaviour as
* to be supported on the Unity and KDE desktop environments, on other desktop environments this * @ref GLFW_PROGRESS_INDICATOR_NORMAL. The Unity Launcher API is only known
* function may do nothing. * to be supported on the Unity and KDE desktop environments; on other desktop
* environments this function may do nothing.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_taskbar_progress * @sa @ref window_progress_indicator
* *
* @since Added in version 3.4. * @since Added in version 3.4.
* *
* @ingroup window * @ingroup window
*/ */
GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* window, int progressState, double value); GLFWAPI void glfwSetWindowProgressIndicator(GLFWwindow* window, int progressState, double value);
//TODO Documentation //TODO Documentation
//Use count = 0 to disable badge icon //Use count = 0 to disable badge icon

View File

@ -528,7 +528,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
_glfwDestroyWindowCocoa, _glfwDestroyWindowCocoa,
_glfwSetWindowTitleCocoa, _glfwSetWindowTitleCocoa,
_glfwSetWindowIconCocoa, _glfwSetWindowIconCocoa,
_glfwSetWindowTaskbarProgressCocoa, _glfwSetWindowProgressIndicatorCocoa,
_glfwSetWindowBadgeCocoa, _glfwSetWindowBadgeCocoa,
_glfwSetWindowBadgeStringCocoa, _glfwSetWindowBadgeStringCocoa,
_glfwGetWindowPosCocoa, _glfwGetWindowPosCocoa,

View File

@ -230,7 +230,7 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndco
void _glfwDestroyWindowCocoa(_GLFWwindow* window); void _glfwDestroyWindowCocoa(_GLFWwindow* window);
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState, double value); void _glfwSetWindowProgressIndicatorCocoa(_GLFWwindow* window, int progressState, double value);
void _glfwSetWindowBadgeCocoa(_GLFWwindow* window, int count); void _glfwSetWindowBadgeCocoa(_GLFWwindow* window, int count);
void _glfwSetWindowBadgeStringCocoa(_GLFWwindow* window, const char* string); void _glfwSetWindowBadgeStringCocoa(_GLFWwindow* window, const char* string);
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);

View File

@ -248,7 +248,7 @@ static void setDockProgressIndicator(int progressState, double value)
// The bug is caused by NSProgressIndicator not immediately updating its value when it's increasing. // The bug is caused by NSProgressIndicator not immediately updating its value when it's increasing.
// This code illustrates the exact same problem, but this time from NORMAL, PAUSED and ERROR to INDETERMINATE: // This code illustrates the exact same problem, but this time from NORMAL, PAUSED and ERROR to INDETERMINATE:
// //
// if (progressState == GLFW_TASKBAR_PROGRESS_INDETERMINATE) // if (progressState == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
// [progressIndicator setDoubleValue:0.75]; // [progressIndicator setDoubleValue:0.75];
// else // else
// [progressIndicator setDoubleValue:0.25]; // [progressIndicator setDoubleValue:0.25];
@ -268,8 +268,8 @@ static void setDockProgressIndicator(int progressState, double value)
indicator = createProgressIndicator(dockTile); indicator = createProgressIndicator(dockTile);
} }
[indicator setIndeterminate:progressState == GLFW_TASKBAR_PROGRESS_INDETERMINATE]; [indicator setIndeterminate:progressState == GLFW_PROGRESS_INDICATOR_INDETERMINATE];
[indicator setHidden:progressState == GLFW_TASKBAR_PROGRESS_DISABLED]; [indicator setHidden:progressState == GLFW_PROGRESS_INDICATOR_DISABLED];
[indicator setDoubleValue:value]; [indicator setDoubleValue:value];
[dockTile display]; [dockTile display];
@ -1064,7 +1064,7 @@ void _glfwDestroyWindowCocoa(_GLFWwindow* window)
{ {
@autoreleasepool { @autoreleasepool {
_glfwSetWindowTaskbarProgressCocoa(window, GLFW_TASKBAR_PROGRESS_DISABLED, 0.0); _glfwSetWindowProgressIndicatorCocoa(window, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
_glfw.ns.disabledCursorWindow = NULL; _glfw.ns.disabledCursorWindow = NULL;
@ -1111,10 +1111,10 @@ void _glfwSetWindowIconCocoa(_GLFWwindow* window,
"Cocoa: Regular windows do not have icons on macOS"); "Cocoa: Regular windows do not have icons on macOS");
} }
void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState, double value) void _glfwSetWindowProgressIndicatorCocoa(_GLFWwindow* window, int progressState, double value)
{ {
if (progressState == GLFW_TASKBAR_PROGRESS_ERROR || progressState == GLFW_TASKBAR_PROGRESS_PAUSED) if (progressState == GLFW_PROGRESS_INDICATOR_ERROR || progressState == GLFW_PROGRESS_INDICATOR_PAUSED)
progressState = GLFW_TASKBAR_PROGRESS_NORMAL; progressState = GLFW_PROGRESS_INDICATOR_NORMAL;
const int oldState = window->ns.dockProgressIndicator.state; const int oldState = window->ns.dockProgressIndicator.state;
const int state = progressState; const int state = progressState;
@ -1123,8 +1123,8 @@ void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState,
if (oldState == state) if (oldState == state)
{ {
if (state == GLFW_TASKBAR_PROGRESS_DISABLED || if (state == GLFW_PROGRESS_INDICATOR_DISABLED ||
state == GLFW_TASKBAR_PROGRESS_INDETERMINATE || state == GLFW_PROGRESS_INDICATOR_INDETERMINATE ||
oldValue == value) oldValue == value)
return; return;
} }
@ -1132,36 +1132,36 @@ void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState,
if (oldState != state) if (oldState != state)
{ {
// Reset // Reset
if (oldState == GLFW_TASKBAR_PROGRESS_INDETERMINATE) if (oldState == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
--_glfw.ns.dockProgressIndicator.indeterminateCount; --_glfw.ns.dockProgressIndicator.indeterminateCount;
if (oldState != GLFW_TASKBAR_PROGRESS_DISABLED) if (oldState != GLFW_PROGRESS_INDICATOR_DISABLED)
{ {
--_glfw.ns.dockProgressIndicator.windowCount; --_glfw.ns.dockProgressIndicator.windowCount;
_glfw.ns.dockProgressIndicator.totalValue -= oldValue; _glfw.ns.dockProgressIndicator.totalValue -= oldValue;
} }
// Set // Set
if (state == GLFW_TASKBAR_PROGRESS_INDETERMINATE) if (state == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
++_glfw.ns.dockProgressIndicator.indeterminateCount; ++_glfw.ns.dockProgressIndicator.indeterminateCount;
if (state != GLFW_TASKBAR_PROGRESS_DISABLED) if (state != GLFW_PROGRESS_INDICATOR_DISABLED)
{ {
++_glfw.ns.dockProgressIndicator.windowCount; ++_glfw.ns.dockProgressIndicator.windowCount;
_glfw.ns.dockProgressIndicator.totalValue += value; _glfw.ns.dockProgressIndicator.totalValue += value;
} }
} }
else if (state != GLFW_TASKBAR_PROGRESS_DISABLED) else if (state != GLFW_PROGRESS_INDICATOR_DISABLED)
_glfw.ns.dockProgressIndicator.totalValue += (value - oldValue); _glfw.ns.dockProgressIndicator.totalValue += (value - oldValue);
if (_glfw.ns.dockProgressIndicator.windowCount > _glfw.ns.dockProgressIndicator.indeterminateCount) if (_glfw.ns.dockProgressIndicator.windowCount > _glfw.ns.dockProgressIndicator.indeterminateCount)
{ {
const double finalValue = _glfw.ns.dockProgressIndicator.totalValue / _glfw.ns.dockProgressIndicator.windowCount; const double finalValue = _glfw.ns.dockProgressIndicator.totalValue / _glfw.ns.dockProgressIndicator.windowCount;
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_NORMAL, finalValue); setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_NORMAL, finalValue);
} }
else if (_glfw.ns.dockProgressIndicator.indeterminateCount > 0) else if (_glfw.ns.dockProgressIndicator.indeterminateCount > 0)
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_INDETERMINATE, 0.0f); setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_INDETERMINATE, 0.0f);
else else
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_DISABLED, 0.0f); setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_DISABLED, 0.0f);
window->ns.dockProgressIndicator.state = state; window->ns.dockProgressIndicator.state = state;
window->ns.dockProgressIndicator.value = value; window->ns.dockProgressIndicator.value = value;

View File

@ -707,7 +707,7 @@ struct _GLFWplatform
void (*destroyWindow)(_GLFWwindow*); void (*destroyWindow)(_GLFWwindow*);
void (*setWindowTitle)(_GLFWwindow*,const char*); void (*setWindowTitle)(_GLFWwindow*,const char*);
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
void (*setWindowTaskbarProgress)(_GLFWwindow*,const int,double); void (*setWindowProgressIndicator)(_GLFWwindow*,const int,double);
void (*setWindowBadge)(_GLFWwindow*,int); void (*setWindowBadge)(_GLFWwindow*,int);
void (*setWindowBadgeString)(_GLFWwindow*,const char* string); void (*setWindowBadgeString)(_GLFWwindow*,const char* string);
void (*getWindowPos)(_GLFWwindow*,int*,int*); void (*getWindowPos)(_GLFWwindow*,int*,int*);

View File

@ -73,7 +73,7 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
_glfwDestroyWindowNull, _glfwDestroyWindowNull,
_glfwSetWindowTitleNull, _glfwSetWindowTitleNull,
_glfwSetWindowIconNull, _glfwSetWindowIconNull,
_glfwSetWindowTaskbarProgressNull, _glfwSetWindowProgressIndicatorNull,
_glfwSetWindowBadgeNull, _glfwSetWindowBadgeNull,
_glfwSetWindowBadgeStringNull, _glfwSetWindowBadgeStringNull,
_glfwGetWindowPosNull, _glfwGetWindowPosNull,

View File

@ -89,7 +89,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndcon
void _glfwDestroyWindowNull(_GLFWwindow* window); void _glfwDestroyWindowNull(_GLFWwindow* window);
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, int progressState, double value); void _glfwSetWindowProgressIndicatorNull(_GLFWwindow* window, int progressState, double value);
void _glfwSetWindowBadgeNull(_GLFWwindow* window, int count); void _glfwSetWindowBadgeNull(_GLFWwindow* window, int count);
void _glfwSetWindowBadgeStringNull(_GLFWwindow* window, const char* string); void _glfwSetWindowBadgeStringNull(_GLFWwindow* window, const char* string);
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);

View File

@ -187,7 +187,7 @@ void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* ima
{ {
} }
void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, int progressState, double value) void _glfwSetWindowProgressIndicatorNull(_GLFWwindow* window, int progressState, double value)
{ {
} }

View File

@ -1,7 +1,7 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2023 Camilla Löwy <elmindreda@glfw.org>
// //
// This software is provided 'as-is', without any express or implied // This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages // warranty. In no event will the authors be held liable for any damages
@ -41,77 +41,90 @@ void _glfwInitDBusPOSIX(void)
_glfw.dbus.connection = NULL; _glfw.dbus.connection = NULL;
_glfw.dbus.handle = _glfwPlatformLoadModule("libdbus-1.so.3"); _glfw.dbus.handle = _glfwPlatformLoadModule("libdbus-1.so.3");
if (_glfw.dbus.handle) if (!_glfw.dbus.handle)
{ return;
_glfw.dbus.error_init = (PFN_dbus_error_init)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_init");
_glfw.dbus.error_is_set = (PFN_dbus_error_is_set)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_is_set");
_glfw.dbus.error_free = (PFN_dbus_error_free)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_free");
_glfw.dbus.connection_unref = (PFN_dbus_connection_unref)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_unref");
_glfw.dbus.connection_send = (PFN_dbus_connection_send)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_send");
_glfw.dbus.connection_flush = (PFN_dbus_connection_flush)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_flush");
_glfw.dbus.bus_request_name = (PFN_dbus_bus_request_name)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_bus_request_name");
_glfw.dbus.bus_get = (PFN_dbus_bus_get)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_bus_get");
_glfw.dbus.message_unref = (PFN_dbus_message_unref)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_unref");
_glfw.dbus.message_new_signal = (PFN_dbus_message_new_signal)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_new_signal");
_glfw.dbus.message_iter_init_append = (PFN_dbus_message_iter_init_append)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_init_append");
_glfw.dbus.message_iter_append_basic = (PFN_dbus_message_iter_append_basic)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_append_basic");
_glfw.dbus.message_iter_open_container = (PFN_dbus_message_iter_open_container)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_open_container");
_glfw.dbus.message_iter_close_container = (PFN_dbus_message_iter_close_container)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_close_container");
//Initialize DBus connection _glfw.dbus.error_init = (PFN_dbus_error_init)
dbus_error_init(&_glfw.dbus.error); _glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_init");
_glfw.dbus.connection = dbus_bus_get(DBUS_BUS_SESSION, &_glfw.dbus.error); _glfw.dbus.error_is_set = (PFN_dbus_error_is_set)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_is_set");
_glfw.dbus.error_free = (PFN_dbus_error_free)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_free");
_glfw.dbus.connection_unref = (PFN_dbus_connection_unref)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_unref");
_glfw.dbus.connection_send = (PFN_dbus_connection_send)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_send");
_glfw.dbus.connection_flush = (PFN_dbus_connection_flush)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_flush");
_glfw.dbus.bus_request_name = (PFN_dbus_bus_request_name)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_bus_request_name");
_glfw.dbus.bus_get = (PFN_dbus_bus_get)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_bus_get");
_glfw.dbus.message_unref = (PFN_dbus_message_unref)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_unref");
_glfw.dbus.message_new_signal = (PFN_dbus_message_new_signal)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_new_signal");
_glfw.dbus.message_iter_init_append = (PFN_dbus_message_iter_init_append)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_init_append");
_glfw.dbus.message_iter_append_basic = (PFN_dbus_message_iter_append_basic)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_append_basic");
_glfw.dbus.message_iter_open_container = (PFN_dbus_message_iter_open_container)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_open_container");
_glfw.dbus.message_iter_close_container = (PFN_dbus_message_iter_close_container)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_close_container");
if (!_glfw.dbus.error_init ||
!_glfw.dbus.error_is_set ||
!_glfw.dbus.error_free ||
!_glfw.dbus.connection_unref ||
!_glfw.dbus.connection_send ||
!_glfw.dbus.connection_flush ||
!_glfw.dbus.bus_request_name ||
!_glfw.dbus.bus_get ||
!_glfw.dbus.message_unref ||
!_glfw.dbus.message_new_signal ||
!_glfw.dbus.message_iter_init_append ||
!_glfw.dbus.message_iter_append_basic ||
!_glfw.dbus.message_iter_open_container ||
!_glfw.dbus.message_iter_close_container)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"POSIX: Failed to load DBus entry points");
return;
}
//Initialize DBus connection
dbus_error_init(&_glfw.dbus.error);
_glfw.dbus.connection = dbus_bus_get(DBUS_BUS_SESSION, &_glfw.dbus.error);
//Check for errors
if(dbus_error_is_set(&_glfw.dbus.error) || !_glfw.dbus.connection)
{
if(dbus_error_is_set(&_glfw.dbus.error))
dbus_error_free(&_glfw.dbus.error);
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to connect to DBus");
dbus_connection_unref(_glfw.dbus.connection);
_glfw.dbus.connection = NULL;
}
else
{
//Request name
const int res = dbus_bus_request_name(_glfw.dbus.connection, "org.glfw", DBUS_NAME_FLAG_REPLACE_EXISTING, &_glfw.dbus.error);
//Check for errors //Check for errors
if(dbus_error_is_set(&_glfw.dbus.error) || !_glfw.dbus.connection) if(dbus_error_is_set(&_glfw.dbus.error) || res != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
{ {
if(dbus_error_is_set(&_glfw.dbus.error)) if(dbus_error_is_set(&_glfw.dbus.error))
dbus_error_free(&_glfw.dbus.error); dbus_error_free(&_glfw.dbus.error);
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to connect to DBus"); _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to request DBus name");
dbus_connection_unref(_glfw.dbus.connection);
_glfw.dbus.connection = NULL;
}
else
{
//Request name
const int res = dbus_bus_request_name(_glfw.dbus.connection, "org.glfw", DBUS_NAME_FLAG_REPLACE_EXISTING, &_glfw.dbus.error);
//Check for errors
if(dbus_error_is_set(&_glfw.dbus.error) || res != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
{
if(dbus_error_is_set(&_glfw.dbus.error))
dbus_error_free(&_glfw.dbus.error);
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to request DBus name");
dbus_connection_unref(_glfw.dbus.connection); dbus_connection_unref(_glfw.dbus.connection);
_glfw.dbus.connection = NULL; _glfw.dbus.connection = NULL;
}
} }
} }
if(_glfw.dbus.connection)
{
//Window NULL is safe here because it won't get
//used inside the SetWindowTaskbarProgress function
_glfw.platform.setWindowTaskbarProgress(NULL, GLFW_TASKBAR_PROGRESS_DISABLED, 0);
}
} }
void _glfwTerminateDBusPOSIX(void) void _glfwTerminateDBusPOSIX(void)

View File

@ -1,8 +1,7 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2023 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
// //
// This software is provided 'as-is', without any express or implied // This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages // warranty. In no event will the authors be held liable for any damages

View File

@ -638,7 +638,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
_glfwDestroyWindowWin32, _glfwDestroyWindowWin32,
_glfwSetWindowTitleWin32, _glfwSetWindowTitleWin32,
_glfwSetWindowIconWin32, _glfwSetWindowIconWin32,
_glfwSetWindowTaskbarProgressWin32, _glfwSetWindowProgressIndicatorWin32,
_glfwSetWindowBadgeWin32, _glfwSetWindowBadgeWin32,
_glfwSetWindowBadgeStringWin32, _glfwSetWindowBadgeStringWin32,
_glfwGetWindowPosWin32, _glfwGetWindowPosWin32,

View File

@ -619,7 +619,7 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndco
void _glfwDestroyWindowWin32(_GLFWwindow* window); void _glfwDestroyWindowWin32(_GLFWwindow* window);
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, int progressState, double value); void _glfwSetWindowProgressIndicatorWin32(_GLFWwindow* window, int progressState, double value);
void _glfwSetWindowBadgeWin32(_GLFWwindow* window, int count); void _glfwSetWindowBadgeWin32(_GLFWwindow* window, int count);
void _glfwSetWindowBadgeStringWin32(_GLFWwindow* window, const char* string); void _glfwSetWindowBadgeStringWin32(_GLFWwindow* window, const char* string);
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);

View File

@ -1598,7 +1598,7 @@ void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* im
} }
} }
void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, int progressState, double value) void _glfwSetWindowProgressIndicatorWin32(_GLFWwindow* window, int progressState, double value)
{ {
HRESULT res = S_OK; HRESULT res = S_OK;
int winProgressState = 0; int winProgressState = 0;
@ -1622,22 +1622,22 @@ void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, int progressState,
switch(progressState) switch(progressState)
{ {
case 1: case GLFW_PROGRESS_INDICATOR_INDETERMINATE:
winProgressState = TBPF_INDETERMINATE; winProgressState = TBPF_INDETERMINATE;
break; break;
case 2: case GLFW_PROGRESS_INDICATOR_NORMAL:
winProgressState = TBPF_NORMAL; winProgressState = TBPF_NORMAL;
break; break;
case 3: case GLFW_PROGRESS_INDICATOR_ERROR:
winProgressState = TBPF_ERROR; winProgressState = TBPF_ERROR;
break; break;
case 4: case GLFW_PROGRESS_INDICATOR_PAUSED:
winProgressState = TBPF_PAUSED; winProgressState = TBPF_PAUSED;
break; break;
default: default:
winProgressState = TBPF_NOPROGRESS; winProgressState = TBPF_NOPROGRESS;
break; break;
} }
res = window->win32.taskbarList->lpVtbl->SetProgressState(window->win32.taskbarList, window->win32.handle, winProgressState); res = window->win32.taskbarList->lpVtbl->SetProgressState(window->win32.taskbarList, window->win32.handle, winProgressState);

View File

@ -561,7 +561,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
_glfw.platform.setWindowIcon(window, count, images); _glfw.platform.setWindowIcon(window, count, images);
} }
GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, int progressState, double value) GLFWAPI void glfwSetWindowProgressIndicator(GLFWwindow* handle, int progressState, double value)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
@ -571,19 +571,19 @@ GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, int progressState,
if (value < 0.0 || value > 1.0) if (value < 0.0 || value > 1.0)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid progress amount for window taskbar progress"); _glfwInputError(GLFW_INVALID_VALUE, "Invalid progress amount for window progress indicator");
return; return;
} }
if (progressState != GLFW_TASKBAR_PROGRESS_DISABLED && progressState != GLFW_TASKBAR_PROGRESS_INDETERMINATE && if (progressState != GLFW_PROGRESS_INDICATOR_DISABLED && progressState != GLFW_PROGRESS_INDICATOR_INDETERMINATE &&
progressState != GLFW_TASKBAR_PROGRESS_NORMAL && progressState != GLFW_TASKBAR_PROGRESS_ERROR && progressState != GLFW_PROGRESS_INDICATOR_NORMAL && progressState != GLFW_PROGRESS_INDICATOR_ERROR &&
progressState != GLFW_TASKBAR_PROGRESS_PAUSED) progressState != GLFW_PROGRESS_INDICATOR_PAUSED)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Invalid progress state 0x%08X", progressState); _glfwInputError(GLFW_INVALID_ENUM, "Invalid progress state 0x%08X", progressState);
return; return;
} }
_glfw.platform.setWindowTaskbarProgress(window, progressState, value); _glfw.platform.setWindowProgressIndicator(window, progressState, value);
} }
GLFWAPI void glfwSetWindowBadge(GLFWwindow* handle, int count) GLFWAPI void glfwSetWindowBadge(GLFWwindow* handle, int count)

View File

@ -419,7 +419,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
_glfwDestroyWindowWayland, _glfwDestroyWindowWayland,
_glfwSetWindowTitleWayland, _glfwSetWindowTitleWayland,
_glfwSetWindowIconWayland, _glfwSetWindowIconWayland,
_glfwSetWindowTaskbarProgressWayland, _glfwSetWindowProgressIndicatorWayland,
_glfwSetWindowBadgeWayland, _glfwSetWindowBadgeWayland,
_glfwSetWindowBadgeStringWayland, _glfwSetWindowBadgeStringWayland,
_glfwGetWindowPosWayland, _glfwGetWindowPosWayland,

View File

@ -446,7 +446,7 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wnd
void _glfwDestroyWindowWayland(_GLFWwindow* window); void _glfwDestroyWindowWayland(_GLFWwindow* window);
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, int progressState, double value); void _glfwSetWindowProgressIndicatorWayland(_GLFWwindow* window, int progressState, double value);
void _glfwSetWindowBadgeWayland(_GLFWwindow* window, int count); void _glfwSetWindowBadgeWayland(_GLFWwindow* window, int count);
void _glfwSetWindowBadgeStringWayland(_GLFWwindow* window, const char* string); void _glfwSetWindowBadgeStringWayland(_GLFWwindow* window, const char* string);
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);

View File

@ -1843,6 +1843,14 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,
return GLFW_FALSE; return GLFW_FALSE;
} }
//Reset progress state as it gets saved between application runs
if(_glfw.dbus.connection)
{
//Window NULL is safe here because it won't get
//used inside the SetWindowTaskbarProgress function
_glfwSetWindowProgressIndicatorWayland(NULL, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
}
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -1902,11 +1910,11 @@ void _glfwSetWindowIconWayland(_GLFWwindow* window,
"Wayland: The platform does not support setting the window icon"); "Wayland: The platform does not support setting the window icon");
} }
void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, const int progressState, double value) void _glfwSetWindowProgressIndicatorWayland(_GLFWwindow* window, const int progressState, double value)
{ {
(void)window; (void)window;
const dbus_bool_t progressVisible = (progressState != GLFW_TASKBAR_PROGRESS_DISABLED); const dbus_bool_t progressVisible = (progressState != GLFW_PROGRESS_INDICATOR_DISABLED);
_glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value); _glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value);
} }

View File

@ -1209,7 +1209,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
_glfwDestroyWindowX11, _glfwDestroyWindowX11,
_glfwSetWindowTitleX11, _glfwSetWindowTitleX11,
_glfwSetWindowIconX11, _glfwSetWindowIconX11,
_glfwSetWindowTaskbarProgressX11, _glfwSetWindowProgressIndicatorX11,
_glfwSetWindowBadgeX11, _glfwSetWindowBadgeX11,
_glfwSetWindowBadgeStringX11, _glfwSetWindowBadgeStringX11,
_glfwGetWindowPosX11, _glfwGetWindowPosX11,

View File

@ -905,7 +905,7 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconf
void _glfwDestroyWindowX11(_GLFWwindow* window); void _glfwDestroyWindowX11(_GLFWwindow* window);
void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, int progressState, double value); void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value);
void _glfwSetWindowBadgeX11(_GLFWwindow* window, int count); void _glfwSetWindowBadgeX11(_GLFWwindow* window, int count);
void _glfwSetWindowBadgeStringX11(_GLFWwindow* window, const char* string); void _glfwSetWindowBadgeStringX11(_GLFWwindow* window, const char* string);
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);

View File

@ -2040,6 +2040,14 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window,
} }
} }
//Reset progress state as it gets saved between application runs
if(_glfw.dbus.connection)
{
//Window NULL is safe here because it won't get
//used inside the SetWindowTaskbarProgress function
_glfwSetWindowProgressIndicatorX11(NULL, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
}
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -2152,11 +2160,11 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);
} }
void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, int progressState, double value) void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value)
{ {
(void)window; (void)window;
const dbus_bool_t progressVisible = (progressState != GLFW_TASKBAR_PROGRESS_DISABLED); const dbus_bool_t progressVisible = (progressState != GLFW_PROGRESS_INDICATOR_DISABLED);
_glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value); _glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value);
} }

View File

@ -414,30 +414,26 @@ int main(int argc, char** argv)
nk_layout_row_dynamic(nk, 30, 1); nk_layout_row_dynamic(nk, 30, 1);
nk_label(nk, "Taskbar Progress", NK_TEXT_CENTERED); nk_label(nk, "Window Progress indicator", NK_TEXT_CENTERED);
nk_layout_row_dynamic(nk, 30, 5); nk_layout_row_dynamic(nk, 30, 5);
static int state = GLFW_TASKBAR_PROGRESS_DISABLED; static int state = GLFW_PROGRESS_INDICATOR_DISABLED;
static float progress = 0; static float progress = 0;
if(nk_button_label(nk, "No progress")) if(nk_button_label(nk, "No progress"))
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_DISABLED, (double) progress); glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_DISABLED, (double) progress);
if (nk_button_label(nk, "Indeterminate")) if (nk_button_label(nk, "Indeterminate"))
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_INDETERMINATE, (double) progress); glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_INDETERMINATE, (double) progress);
if (nk_button_label(nk, "Normal")) if (nk_button_label(nk, "Normal"))
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_NORMAL, (double) progress); glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_NORMAL, (double) progress);
if (nk_button_label(nk, "Error")) if (nk_button_label(nk, "Error"))
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_ERROR, (double) progress); glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_ERROR, (double) progress);
if (nk_button_label(nk, "Paused")) if (nk_button_label(nk, "Paused"))
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_PAUSED, (double) progress); glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_PAUSED, (double) progress);
nk_layout_row_begin(nk, NK_DYNAMIC, 30, 2); nk_label(nk, "Progress: ", NK_TEXT_ALIGN_LEFT);
nk_layout_row_push(nk, 1.f / 3.f); if (nk_slider_float(nk, 0.0f, &progress, 1.0f, 0.05f))
nk_labelf(nk, NK_TEXT_LEFT, "Progress: %0.3f", progress); glfwSetWindowProgressIndicator(window, state, (double) progress);
nk_layout_row_push(nk, 2.f / 3.f);
if (nk_slider_float(nk, 0.f, &progress, 1.0f, 0.001f))
glfwSetWindowTaskbarProgress(window, state, (double)progress);
nk_layout_row_end(nk);
nk_layout_row_dynamic(nk, 30, 1); nk_layout_row_dynamic(nk, 30, 1);