mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 13:46:37 +00:00
Implement glfwWindowBell
Exposes the platform specific Bell/Beep API to make the default system beep sound.
This commit is contained in:
parent
2884915000
commit
0fbf489bbb
@ -3185,6 +3185,29 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* window);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
|
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*! @brief Sounds an audible bell associated with the window
|
||||||
|
*
|
||||||
|
* This function sounds an audible bell, on platforms where it is
|
||||||
|
* supported. Currently (macOS, Windows, X11 and Wayland).
|
||||||
|
*
|
||||||
|
* @param[in] window The window with which the bell is associated.
|
||||||
|
* @return GLFW_TRUE if the bell succeeded otherwise GLFW_FALSE
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
|
* GLFW_PLATFORM_ERROR.
|
||||||
|
*
|
||||||
|
* @remark @macos Bell is associated to the application as a whole, not the
|
||||||
|
* specific window.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI int glfwWindowBell(GLFWwindow* window);
|
||||||
|
|
||||||
|
|
||||||
/*! @brief Returns the monitor that the window uses for full screen mode.
|
/*! @brief Returns the monitor that the window uses for full screen mode.
|
||||||
*
|
*
|
||||||
* This function returns the handle of the monitor that the specified window is
|
* This function returns the handle of the monitor that the specified window is
|
||||||
@ -5519,4 +5542,3 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _glfw3_h_ */
|
#endif /* _glfw3_h_ */
|
||||||
|
|
||||||
|
@ -1367,6 +1367,12 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
|||||||
[NSApp requestUserAttention:NSInformationalRequest];
|
[NSApp requestUserAttention:NSInformationalRequest];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowBell(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
NSBeep();
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
// Make us the active application
|
// Make us the active application
|
||||||
@ -1906,4 +1912,3 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
||||||
return window->ns.object;
|
return window->ns.object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,6 +653,7 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
|
|||||||
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
|
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
|
||||||
|
int _glfwPlatformWindowBell(_GLFWwindow* window);
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window);
|
void _glfwPlatformFocusWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor,
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor,
|
||||||
int xpos, int ypos, int width, int height,
|
int xpos, int ypos, int width, int height,
|
||||||
@ -768,4 +769,3 @@ void _glfwTerminateVulkan(void);
|
|||||||
const char* _glfwGetVulkanResultString(VkResult result);
|
const char* _glfwGetVulkanResultString(VkResult result);
|
||||||
|
|
||||||
char* _glfw_strdup(const char* source);
|
char* _glfw_strdup(const char* source);
|
||||||
|
|
||||||
|
@ -205,6 +205,11 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowBell(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
|
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -318,4 +323,3 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
|||||||
// This seems like the most appropriate error to return here
|
// This seems like the most appropriate error to return here
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1474,6 +1474,11 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
|||||||
FlashWindow(window->win32.handle, TRUE);
|
FlashWindow(window->win32.handle, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowBell(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return MessageBeep(0xFFFFFFFF) ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
BringWindowToTop(window->win32.handle);
|
BringWindowToTop(window->win32.handle);
|
||||||
@ -2009,4 +2014,3 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
return window->win32.handle;
|
return window->win32.handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/window.c
11
src/window.c
@ -768,6 +768,16 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
|||||||
_glfwPlatformRequestWindowAttention(window);
|
_glfwPlatformRequestWindowAttention(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI int glfwWindowBell(GLFWwindow* handle)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||||
|
|
||||||
|
return _glfwPlatformWindowBell(window);
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
@ -1096,4 +1106,3 @@ GLFWAPI void glfwPostEmptyEvent(void)
|
|||||||
|
|
||||||
_glfwPlatformPostEmptyEvent();
|
_glfwPlatformPostEmptyEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,6 +1079,18 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
|||||||
"Wayland: Window attention request not implemented yet");
|
"Wayland: Window attention request not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowBell(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
// TODO: Use an actual Wayland API to implement this when one becomes available
|
||||||
|
int fd = open("/dev/tty", O_WRONLY | O_CLOEXEC);
|
||||||
|
if (fd > -1) {
|
||||||
|
int ret = write(fd, "\x07", 1) == 1 ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
close(fd);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
@ -1539,4 +1551,3 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
return window->wl.surface;
|
return window->wl.surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2340,6 +2340,11 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
|||||||
0, 1, 0);
|
0, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowBell(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return XkbBell(_glfw.x11.display, window->x11.handle, 100, (Atom)0) ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.NET_ACTIVE_WINDOW)
|
if (_glfw.x11.NET_ACTIVE_WINDOW)
|
||||||
@ -3039,4 +3044,3 @@ GLFWAPI const char* glfwGetX11SelectionString(void)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
return getSelectionString(_glfw.x11.PRIMARY);
|
return getSelectionString(_glfw.x11.PRIMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user