mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Merge origin/taskbar-progress into origin/application-badge
This commit is contained in:
commit
3ed4a360fd
@ -2,12 +2,6 @@ cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR)
|
||||
|
||||
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)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
@ -18,9 +12,7 @@ endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(GLFW_STANDALONE TRUE)
|
||||
endif()
|
||||
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} GLFW_STANDALONE)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
|
||||
|
@ -189,6 +189,7 @@ video tutorials.
|
||||
- pthom
|
||||
- Martin Pulec
|
||||
- Guillaume Racicot
|
||||
- Juan Ramos
|
||||
- Christian Rauch
|
||||
- Simon Richter
|
||||
- Philip Rideout
|
||||
|
@ -121,7 +121,7 @@ information on what to include when reporting a bug.
|
||||
|
||||
## 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_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
||||
|
@ -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.
|
||||
|
||||
|
||||
@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
|
||||
do this with @ref glfwSetWindowTaskbarProgress.
|
||||
If you wish to display the progress of some action on the Dock icon or task bar, you can
|
||||
do this with @ref glfwSetWindowProgressIndicator.
|
||||
|
||||
@code
|
||||
glfwSetWindowTaskbarProgress(window, GLFW_TASKBAR_PROGRESS_NORMAL, 50);
|
||||
glfwSetWindowProgressIndicator(window, GLFW_PROGRESS_INDICATOR_NORMAL, 0.5);
|
||||
@endcode
|
||||
|
||||
There are different taskbar progress states available for you to use:
|
||||
- @ref GLFW_TASKBAR_PROGRESS_DISABLED
|
||||
- @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE
|
||||
- @ref GLFW_TASKBAR_PROGRESS_NORMAL
|
||||
- @ref GLFW_TASKBAR_PROGRESS_ERROR
|
||||
- @ref GLFW_TASKBAR_PROGRESS_PAUSED
|
||||
There are different progress states available for you to use:
|
||||
- @ref GLFW_PROGRESS_INDICATOR_DISABLED
|
||||
- @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE
|
||||
- @ref GLFW_PROGRESS_INDICATOR_NORMAL
|
||||
- @ref GLFW_PROGRESS_INDICATOR_ERROR
|
||||
- @ref GLFW_PROGRESS_INDICATOR_PAUSED
|
||||
|
||||
The last argument is the progress percentage to display.
|
||||
It has a valid range of 0.0 to 1.0.
|
||||
|
@ -1279,51 +1279,51 @@ extern "C" {
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Display the progress bar in an indeterminate state.
|
||||
*
|
||||
* @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`.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Display the progress bar in an error state.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* Display the progress bar in a paused state.
|
||||
*
|
||||
* @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
|
||||
@ -3358,43 +3358,45 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
|
||||
*/
|
||||
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] progressState State of the progress to be displayed in the taskbar. Valid values are:
|
||||
* @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] window The window whose progress to set.
|
||||
* @param[in] progressState The state of the progress to be displayed in the dock
|
||||
* or taskbar. Valid values are: @ref GLFW_PROGRESS_INDICATOR_DISABLED,
|
||||
* @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_NORMAL,
|
||||
* @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.
|
||||
* 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
|
||||
* GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR,
|
||||
* @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
|
||||
* displays the combined values of all the windows.
|
||||
*
|
||||
* @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
|
||||
* @ref GLFW_TASKBAR_PROGRESS_INDETERMINATE, @ref GLFW_TASKBAR_PROGRESS_ERROR and @ref GLFW_TASKBAR_PROGRESS_PAUSED
|
||||
* have the same behaviour as @ref GLFW_TASKBAR_PROGRESS_NORMAL. The Unity Launcher API is only known
|
||||
* to be supported on the Unity and KDE desktop environments, on other desktop environments this
|
||||
* function may do nothing.
|
||||
* @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_ERROR
|
||||
* and @ref GLFW_PROGRESS_INDICATOR_PAUSED have the same behaviour as
|
||||
* @ref GLFW_PROGRESS_INDICATOR_NORMAL. The Unity Launcher API is only known
|
||||
* 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.
|
||||
*
|
||||
* @sa @ref window_taskbar_progress
|
||||
* @sa @ref window_progress_indicator
|
||||
*
|
||||
* @since Added in version 3.4.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* window, int progressState, double value);
|
||||
GLFWAPI void glfwSetWindowProgressIndicator(GLFWwindow* window, int progressState, double value);
|
||||
|
||||
//TODO Documentation
|
||||
//Use count = 0 to disable badge icon
|
||||
|
@ -528,7 +528,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowCocoa,
|
||||
_glfwSetWindowTitleCocoa,
|
||||
_glfwSetWindowIconCocoa,
|
||||
_glfwSetWindowTaskbarProgressCocoa,
|
||||
_glfwSetWindowProgressIndicatorCocoa,
|
||||
_glfwSetWindowBadgeCocoa,
|
||||
_glfwSetWindowBadgeStringCocoa,
|
||||
_glfwGetWindowPosCocoa,
|
||||
|
@ -230,7 +230,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, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorCocoa(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowBadgeCocoa(_GLFWwindow* window, int count);
|
||||
void _glfwSetWindowBadgeStringCocoa(_GLFWwindow* window, const char* string);
|
||||
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
|
@ -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.
|
||||
// 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];
|
||||
// else
|
||||
// [progressIndicator setDoubleValue:0.25];
|
||||
@ -268,8 +268,8 @@ static void setDockProgressIndicator(int progressState, double value)
|
||||
indicator = createProgressIndicator(dockTile);
|
||||
}
|
||||
|
||||
[indicator setIndeterminate:progressState == GLFW_TASKBAR_PROGRESS_INDETERMINATE];
|
||||
[indicator setHidden:progressState == GLFW_TASKBAR_PROGRESS_DISABLED];
|
||||
[indicator setIndeterminate:progressState == GLFW_PROGRESS_INDICATOR_INDETERMINATE];
|
||||
[indicator setHidden:progressState == GLFW_PROGRESS_INDICATOR_DISABLED];
|
||||
[indicator setDoubleValue:value];
|
||||
|
||||
[dockTile display];
|
||||
@ -1064,7 +1064,7 @@ void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
_glfwSetWindowTaskbarProgressCocoa(window, GLFW_TASKBAR_PROGRESS_DISABLED, 0.0);
|
||||
_glfwSetWindowProgressIndicatorCocoa(window, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
|
||||
|
||||
if (_glfw.ns.disabledCursorWindow == window)
|
||||
_glfw.ns.disabledCursorWindow = NULL;
|
||||
@ -1111,10 +1111,10 @@ void _glfwSetWindowIconCocoa(_GLFWwindow* window,
|
||||
"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)
|
||||
progressState = GLFW_TASKBAR_PROGRESS_NORMAL;
|
||||
if (progressState == GLFW_PROGRESS_INDICATOR_ERROR || progressState == GLFW_PROGRESS_INDICATOR_PAUSED)
|
||||
progressState = GLFW_PROGRESS_INDICATOR_NORMAL;
|
||||
|
||||
const int oldState = window->ns.dockProgressIndicator.state;
|
||||
const int state = progressState;
|
||||
@ -1123,8 +1123,8 @@ void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState,
|
||||
|
||||
if (oldState == state)
|
||||
{
|
||||
if (state == GLFW_TASKBAR_PROGRESS_DISABLED ||
|
||||
state == GLFW_TASKBAR_PROGRESS_INDETERMINATE ||
|
||||
if (state == GLFW_PROGRESS_INDICATOR_DISABLED ||
|
||||
state == GLFW_PROGRESS_INDICATOR_INDETERMINATE ||
|
||||
oldValue == value)
|
||||
return;
|
||||
}
|
||||
@ -1132,36 +1132,36 @@ void _glfwSetWindowTaskbarProgressCocoa(_GLFWwindow* window, int progressState,
|
||||
if (oldState != state)
|
||||
{
|
||||
// Reset
|
||||
if (oldState == GLFW_TASKBAR_PROGRESS_INDETERMINATE)
|
||||
if (oldState == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
|
||||
--_glfw.ns.dockProgressIndicator.indeterminateCount;
|
||||
if (oldState != GLFW_TASKBAR_PROGRESS_DISABLED)
|
||||
if (oldState != GLFW_PROGRESS_INDICATOR_DISABLED)
|
||||
{
|
||||
--_glfw.ns.dockProgressIndicator.windowCount;
|
||||
_glfw.ns.dockProgressIndicator.totalValue -= oldValue;
|
||||
}
|
||||
|
||||
// Set
|
||||
if (state == GLFW_TASKBAR_PROGRESS_INDETERMINATE)
|
||||
if (state == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
|
||||
++_glfw.ns.dockProgressIndicator.indeterminateCount;
|
||||
if (state != GLFW_TASKBAR_PROGRESS_DISABLED)
|
||||
if (state != GLFW_PROGRESS_INDICATOR_DISABLED)
|
||||
{
|
||||
++_glfw.ns.dockProgressIndicator.windowCount;
|
||||
_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);
|
||||
|
||||
|
||||
if (_glfw.ns.dockProgressIndicator.windowCount > _glfw.ns.dockProgressIndicator.indeterminateCount)
|
||||
{
|
||||
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)
|
||||
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_INDETERMINATE, 0.0f);
|
||||
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_INDETERMINATE, 0.0f);
|
||||
else
|
||||
setDockProgressIndicator(GLFW_TASKBAR_PROGRESS_DISABLED, 0.0f);
|
||||
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_DISABLED, 0.0f);
|
||||
|
||||
window->ns.dockProgressIndicator.state = state;
|
||||
window->ns.dockProgressIndicator.value = value;
|
||||
|
@ -707,7 +707,7 @@ struct _GLFWplatform
|
||||
void (*destroyWindow)(_GLFWwindow*);
|
||||
void (*setWindowTitle)(_GLFWwindow*,const char*);
|
||||
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
|
||||
void (*setWindowTaskbarProgress)(_GLFWwindow*,const int,double);
|
||||
void (*setWindowProgressIndicator)(_GLFWwindow*,const int,double);
|
||||
void (*setWindowBadge)(_GLFWwindow*,int);
|
||||
void (*setWindowBadgeString)(_GLFWwindow*,const char* string);
|
||||
void (*getWindowPos)(_GLFWwindow*,int*,int*);
|
||||
|
@ -73,7 +73,7 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowNull,
|
||||
_glfwSetWindowTitleNull,
|
||||
_glfwSetWindowIconNull,
|
||||
_glfwSetWindowTaskbarProgressNull,
|
||||
_glfwSetWindowProgressIndicatorNull,
|
||||
_glfwSetWindowBadgeNull,
|
||||
_glfwSetWindowBadgeStringNull,
|
||||
_glfwGetWindowPosNull,
|
||||
|
@ -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, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorNull(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowBadgeNull(_GLFWwindow* window, int count);
|
||||
void _glfwSetWindowBadgeStringNull(_GLFWwindow* window, const char* string);
|
||||
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//========================================================================
|
||||
// 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
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
@ -41,8 +41,9 @@ void _glfwInitDBusPOSIX(void)
|
||||
_glfw.dbus.connection = NULL;
|
||||
|
||||
_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)
|
||||
@ -72,6 +73,26 @@ void _glfwInitDBusPOSIX(void)
|
||||
_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);
|
||||
@ -104,14 +125,6 @@ void _glfwInitDBusPOSIX(void)
|
||||
_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)
|
||||
|
@ -1,8 +1,7 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 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
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -638,7 +638,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowWin32,
|
||||
_glfwSetWindowTitleWin32,
|
||||
_glfwSetWindowIconWin32,
|
||||
_glfwSetWindowTaskbarProgressWin32,
|
||||
_glfwSetWindowProgressIndicatorWin32,
|
||||
_glfwSetWindowBadgeWin32,
|
||||
_glfwSetWindowBadgeStringWin32,
|
||||
_glfwGetWindowPosWin32,
|
||||
|
@ -619,7 +619,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, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorWin32(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowBadgeWin32(_GLFWwindow* window, int count);
|
||||
void _glfwSetWindowBadgeStringWin32(_GLFWwindow* window, const char* string);
|
||||
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
|
@ -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;
|
||||
int winProgressState = 0;
|
||||
@ -1622,16 +1622,16 @@ void _glfwSetWindowTaskbarProgressWin32(_GLFWwindow* window, int progressState,
|
||||
|
||||
switch(progressState)
|
||||
{
|
||||
case 1:
|
||||
case GLFW_PROGRESS_INDICATOR_INDETERMINATE:
|
||||
winProgressState = TBPF_INDETERMINATE;
|
||||
break;
|
||||
case 2:
|
||||
case GLFW_PROGRESS_INDICATOR_NORMAL:
|
||||
winProgressState = TBPF_NORMAL;
|
||||
break;
|
||||
case 3:
|
||||
case GLFW_PROGRESS_INDICATOR_ERROR:
|
||||
winProgressState = TBPF_ERROR;
|
||||
break;
|
||||
case 4:
|
||||
case GLFW_PROGRESS_INDICATOR_PAUSED:
|
||||
winProgressState = TBPF_PAUSED;
|
||||
break;
|
||||
|
||||
|
12
src/window.c
12
src/window.c
@ -561,7 +561,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
|
||||
_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;
|
||||
|
||||
@ -571,19 +571,19 @@ GLFWAPI void glfwSetWindowTaskbarProgress(GLFWwindow* handle, int progressState,
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (progressState != GLFW_TASKBAR_PROGRESS_DISABLED && progressState != GLFW_TASKBAR_PROGRESS_INDETERMINATE &&
|
||||
progressState != GLFW_TASKBAR_PROGRESS_NORMAL && progressState != GLFW_TASKBAR_PROGRESS_ERROR &&
|
||||
progressState != GLFW_TASKBAR_PROGRESS_PAUSED)
|
||||
if (progressState != GLFW_PROGRESS_INDICATOR_DISABLED && progressState != GLFW_PROGRESS_INDICATOR_INDETERMINATE &&
|
||||
progressState != GLFW_PROGRESS_INDICATOR_NORMAL && progressState != GLFW_PROGRESS_INDICATOR_ERROR &&
|
||||
progressState != GLFW_PROGRESS_INDICATOR_PAUSED)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid progress state 0x%08X", progressState);
|
||||
return;
|
||||
}
|
||||
|
||||
_glfw.platform.setWindowTaskbarProgress(window, progressState, value);
|
||||
_glfw.platform.setWindowProgressIndicator(window, progressState, value);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowBadge(GLFWwindow* handle, int count)
|
||||
|
@ -419,7 +419,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowWayland,
|
||||
_glfwSetWindowTitleWayland,
|
||||
_glfwSetWindowIconWayland,
|
||||
_glfwSetWindowTaskbarProgressWayland,
|
||||
_glfwSetWindowProgressIndicatorWayland,
|
||||
_glfwSetWindowBadgeWayland,
|
||||
_glfwSetWindowBadgeStringWayland,
|
||||
_glfwGetWindowPosWayland,
|
||||
|
@ -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, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorWayland(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowBadgeWayland(_GLFWwindow* window, int count);
|
||||
void _glfwSetWindowBadgeStringWayland(_GLFWwindow* window, const char* string);
|
||||
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
|
@ -1843,6 +1843,14 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1902,11 +1910,11 @@ void _glfwSetWindowIconWayland(_GLFWwindow* window,
|
||||
"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;
|
||||
|
||||
const dbus_bool_t progressVisible = (progressState != GLFW_TASKBAR_PROGRESS_DISABLED);
|
||||
const dbus_bool_t progressVisible = (progressState != GLFW_PROGRESS_INDICATOR_DISABLED);
|
||||
|
||||
_glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value);
|
||||
}
|
||||
|
@ -1209,7 +1209,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
||||
_glfwDestroyWindowX11,
|
||||
_glfwSetWindowTitleX11,
|
||||
_glfwSetWindowIconX11,
|
||||
_glfwSetWindowTaskbarProgressX11,
|
||||
_glfwSetWindowProgressIndicatorX11,
|
||||
_glfwSetWindowBadgeX11,
|
||||
_glfwSetWindowBadgeStringX11,
|
||||
_glfwGetWindowPosX11,
|
||||
|
@ -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, int progressState, double value);
|
||||
void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value);
|
||||
void _glfwSetWindowBadgeX11(_GLFWwindow* window, int count);
|
||||
void _glfwSetWindowBadgeStringX11(_GLFWwindow* window, const char* string);
|
||||
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
|
@ -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);
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
@ -2152,11 +2160,11 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag
|
||||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
|
||||
void _glfwSetWindowTaskbarProgressX11(_GLFWwindow* window, int progressState, double value)
|
||||
void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value)
|
||||
{
|
||||
(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);
|
||||
}
|
||||
|
@ -414,30 +414,26 @@ int main(int argc, char** argv)
|
||||
|
||||
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);
|
||||
|
||||
static int state = GLFW_TASKBAR_PROGRESS_DISABLED;
|
||||
static int state = GLFW_PROGRESS_INDICATOR_DISABLED;
|
||||
static float progress = 0;
|
||||
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"))
|
||||
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_INDETERMINATE, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_INDETERMINATE, (double) progress);
|
||||
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"))
|
||||
glfwSetWindowTaskbarProgress(window, state = GLFW_TASKBAR_PROGRESS_ERROR, (double) progress);
|
||||
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_ERROR, (double) progress);
|
||||
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_layout_row_push(nk, 1.f / 3.f);
|
||||
nk_labelf(nk, NK_TEXT_LEFT, "Progress: %0.3f", 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_label(nk, "Progress: ", NK_TEXT_ALIGN_LEFT);
|
||||
if (nk_slider_float(nk, 0.0f, &progress, 1.0f, 0.05f))
|
||||
glfwSetWindowProgressIndicator(window, state, (double) progress);
|
||||
|
||||
nk_layout_row_dynamic(nk, 30, 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user