From 0f142e3a1a7689677c98c047d5c2f906c309e9eb Mon Sep 17 00:00:00 2001 From: GamesTrap Date: Thu, 2 Mar 2023 13:50:16 +0100 Subject: [PATCH] glfwSetWindowTaskbarProgress Changed value type from int to double --- docs/window.dox | 2 +- include/GLFW/glfw3.h | 4 ++-- src/cocoa_platform.h | 2 +- src/cocoa_window.m | 2 +- src/internal.h | 2 +- src/null_platform.h | 2 +- src/null_window.c | 2 +- src/win32_platform.h | 2 +- src/win32_window.c | 7 ++++--- src/window.c | 4 ++-- src/wl_platform.h | 2 +- src/wl_window.c | 5 ++--- src/x11_platform.h | 2 +- src/x11_window.c | 5 ++--- tests/window.c | 14 +++++++------- 15 files changed, 28 insertions(+), 29 deletions(-) diff --git a/docs/window.dox b/docs/window.dox index e3915a3f..6a51ac58 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -1176,7 +1176,7 @@ There are different taskbar progress states available for you to use: - @ref GLFW_TASKBAR_PROGRESS_PAUSED The last argument is the progress percentage to display. -It has a valid range of 0 to 100. +It has a valid range of 0.0 to 1.0. @subsection window_refresh Window damage and refresh diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 3b622d35..b7826263 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3365,7 +3365,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * @ref GLFW_TASKBAR_PROGRESS_DISABLED, @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE, * @ref GLFW_TASKBAR_PROGRESS_NORMAL, @ref GLFW_TASKBAR_PROGRESS_ERROR * and @ref GLFW_TASKBAR_PROGRESS_PAUSED. - * @param[in] value The amount of completed progress to set. Valid range is 0 to 100. + * @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. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref @@ -3391,7 +3391,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * * @ingroup window */ -GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* window, const int progressState, int value); +GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* window, const int progressState, double value); /*! @brief Retrieves the position of the content area of the specified window. * diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9ebfbda9..4323a874 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -218,7 +218,7 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndco void _glfwDestroyWindowCocoa(_GLFWwindow* window); void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title); void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images); -void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, const int taskbarState, int value); +void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, const int taskbarState, double value); void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos); void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height); diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 3b2c6dae..a7ba3030 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1032,7 +1032,7 @@ void _glfwSetWindowIconCocoa(_GLFWwindow* window, "Cocoa: Regular windows do not have icons on macOS"); } -void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, const int progressState, int value) +void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, const int progressState, double value) { _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Cocoa: Window taskbar progress is not implemented"); diff --git a/src/internal.h b/src/internal.h index 7f74e293..3766294b 100644 --- a/src/internal.h +++ b/src/internal.h @@ -706,7 +706,7 @@ struct _GLFWplatform void (*destroyWindow)(_GLFWwindow*); void (*setWindowTitle)(_GLFWwindow*,const char*); void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); - void (*setWindowTaskbarProgress)(_GLFWwindow*,const int,int); + void (*setWindowTaskbarProgress)(_GLFWwindow*,const int,double); void (*getWindowPos)(_GLFWwindow*,int*,int*); void (*setWindowPos)(_GLFWwindow*,int,int); void (*getWindowSize)(_GLFWwindow*,int*,int*); diff --git a/src/null_platform.h b/src/null_platform.h index 80e2946f..a4e5e4ad 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -89,7 +89,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndcon void _glfwDestroyWindowNull(_GLFWwindow* window); void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title); void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images); -void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, const int taskbarState, int value); +void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, const int taskbarState, double value); void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos); diff --git a/src/null_window.c b/src/null_window.c index bbb30e68..2638827e 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -187,7 +187,7 @@ void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* ima { } -void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, const int progressState, int value) +void _glfwSetWindowTaskbarProgressNull(_GLFWwindow* window, const int progressState, double value) { } diff --git a/src/win32_platform.h b/src/win32_platform.h index 9ec1174b..34847e81 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -618,7 +618,7 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndco void _glfwDestroyWindowWin32(_GLFWwindow* window); void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title); void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images); -void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, const int taskbarState, int value); +void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, const int taskbarState, double value); void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos); void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height); diff --git a/src/win32_window.c b/src/win32_window.c index 2123934d..44a2ae00 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1596,10 +1596,11 @@ void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* im } } -void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, const int progressState, int value) +void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, const int progressState, double value) { HRESULT res = S_OK; - int32_t winProgressState = 0; + int winProgressState = 0; + int progressValue = (int)(value * 100.0); if(!IsWindows7OrGreater()) { @@ -1610,7 +1611,7 @@ void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, const int progressS if(!window->win32.TaskbarList) return; - res = window->win32.TaskbarList->lpVtbl->SetProgressValue(window->win32.TaskbarList, window->win32.handle, value, 100); + res = window->win32.TaskbarList->lpVtbl->SetProgressValue(window->win32.TaskbarList, window->win32.handle, progressValue, 100); if(res != S_OK) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar progress value"); diff --git a/src/window.c b/src/window.c index 46dff20c..c68b7fd6 100644 --- a/src/window.c +++ b/src/window.c @@ -558,7 +558,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, _glfw.platform.setWindowIcon(window, count, images); } -GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, const int progressState, int value) +GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, const int progressState, double value) { _GLFWwindow* window = (_GLFWwindow*) handle; @@ -566,7 +566,7 @@ GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, const int progress _GLFW_REQUIRE_INIT(); - if (value < 0 || value > 100) + if (value < 0.0 || value > 1.0) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid progress amount for window taskbar progress"); return; diff --git a/src/wl_platform.h b/src/wl_platform.h index eaa29d87..fabc90a2 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -446,7 +446,7 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wnd void _glfwDestroyWindowWayland(_GLFWwindow* window); void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title); void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images); -void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, const int taskbarState, int value); +void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, const int taskbarState, double value); void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos); void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height); diff --git a/src/wl_window.c b/src/wl_window.c index df7339bf..f35072d5 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1902,14 +1902,13 @@ void _glfwSetWindowIconWayland(_GLFWwindow* window, "Wayland: The platform does not support setting the window icon"); } -void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, const int taskbarState, int value) +void _glfwSetWindowTaskbarProgressWayland(_GLFWwindow* window, const int taskbarState, double value) { (void)window; const dbus_bool_t progressVisible = (taskbarState != GLFW_TASKBAR_PROGRESS_DISABLED); - const double progressValue = (double)value / 100.0; - _glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, progressValue); + _glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value); } void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos) diff --git a/src/x11_platform.h b/src/x11_platform.h index 20766834..6eeeab4e 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -905,7 +905,7 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconf void _glfwDestroyWindowX11(_GLFWwindow* window); void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title); void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images); -void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, const int taskbarState, int value); +void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, const int taskbarState, double value); void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos); void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos); void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height); diff --git a/src/x11_window.c b/src/x11_window.c index d2583608..236ecc45 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2152,14 +2152,13 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag XFlush(_glfw.x11.display); } -void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, const int taskbarState, int value) +void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, const int taskbarState, double value) { (void)window; const dbus_bool_t progressVisible = (taskbarState != GLFW_TASKBAR_PROGRESS_DISABLED); - const double progressValue = (double)value / 100.0; - _glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, progressValue); + _glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value); } void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos) diff --git a/tests/window.c b/tests/window.c index c7631246..69975aee 100644 --- a/tests/window.c +++ b/tests/window.c @@ -418,20 +418,20 @@ int main(int argc, char** argv) nk_layout_row_dynamic(nk, 30, 5); - static int progress = 0; + static float progress = 0; if(nk_button_label(nk, "No progress")) - glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_DISABLED, progress); + glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_DISABLED, (double)progress); if (nk_button_label(nk, "Indeterminate")) - glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_INDETERMINATE, progress); + glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_INDETERMINATE, (double)progress); if (nk_button_label(nk, "Normal")) - glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_NORMAL, progress); + glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_NORMAL, (double)progress); if (nk_button_label(nk, "Error")) - glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_ERROR, progress); + glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_ERROR, (double)progress); if (nk_button_label(nk, "Paused")) - glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_PAUSED, progress); + glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_PAUSED, (double)progress); nk_label(nk, "Progress: ", NK_TEXT_ALIGN_LEFT); - nk_slider_int(nk, 0, &progress, 100, 1); + nk_slider_float(nk, 0.0f, &progress, 1.0f, 0.05f); } nk_end(nk);