Wayland: Implement glfwRequestWindowAttention

This implements window attention requests via the xdg-activation-v1
protocol.

This was updated by @ elmindreda to work with recent Wayland related
 changes to the main branch:
 - Switched to current way of handling Wayland protocol files
 - Added the xdg-activation-v1.xml protocol file to deps/wayland
 - Added missing macros to rename protocol interface globals

The protocol file was copied from wayland-protocols 1.33.

Closes #2287
This commit is contained in:
Jan Schürkamp
2024-01-24 21:34:47 +01:00
committed by Camilla Löwy
parent 2590d4cdd4
commit 9317970243
8 changed files with 261 additions and 3 deletions
+34 -3
View File
@@ -48,6 +48,7 @@
#include "viewporter-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h"
#define GLFW_BORDER_SIZE 4
@@ -2054,6 +2055,9 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
if (window == _glfw.wl.keyboardFocus)
_glfw.wl.keyboardFocus = NULL;
if (window->wl.activationToken)
xdg_activation_token_v1_destroy(window->wl.activationToken);
if (window->wl.idleInhibitor)
zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
@@ -2335,11 +2339,38 @@ void _glfwHideWindowWayland(_GLFWwindow* window)
}
}
static void xdgActivationHandleDone(void* userData,
struct xdg_activation_token_v1* activationToken,
const char* token)
{
_GLFWwindow* window = userData;
if(activationToken != window->wl.activationToken)
return;
xdg_activation_v1_activate(_glfw.wl.activationManager, token, window->wl.surface);
xdg_activation_token_v1_destroy(window->wl.activationToken);
window->wl.activationToken = NULL;
}
static const struct xdg_activation_token_v1_listener xdgActivationListener =
{
xdgActivationHandleDone
};
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window)
{
// TODO
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
"Wayland: Window attention request not implemented yet");
if(!_glfw.wl.activationManager)
return;
//We're about to overwrite this with a new request
if(window->wl.activationToken)
xdg_activation_token_v1_destroy(window->wl.activationToken);
window->wl.activationToken = xdg_activation_v1_get_activation_token(_glfw.wl.activationManager);
xdg_activation_token_v1_add_listener(window->wl.activationToken, &xdgActivationListener, window);
xdg_activation_token_v1_commit(window->wl.activationToken);
}
void _glfwFocusWindowWayland(_GLFWwindow* window)