Wayland: Implement glfwFocusWindow

This implements window focus requests via the xdg-activation-v1
protocol.  These requests will likely only work when another window of
the same application already has input focus, but that isn't unlike the
behavior of other platforms.

The GLFW_FEATURE_UNAVAILABLE error has been removed from this function
for now.

Related to #2284
Related to #2306
Related to #2439
This commit is contained in:
Camilla Löwy
2024-02-09 03:55:14 +01:00
parent eeb403135d
commit a360198f8f
4 changed files with 37 additions and 9 deletions
+30 -2
View File
@@ -2378,8 +2378,36 @@ void _glfwRequestWindowAttentionWayland(_GLFWwindow* window)
void _glfwFocusWindowWayland(_GLFWwindow* window)
{
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
"Wayland: The platform does not support setting the input focus");
if (!_glfw.wl.activationManager)
return;
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_set_serial(window->wl.activationToken,
_glfw.wl.serial,
_glfw.wl.seat);
_GLFWwindow* requester = _glfw.wl.keyboardFocus;
if (requester)
{
xdg_activation_token_v1_set_surface(window->wl.activationToken,
requester->wl.surface);
if (requester->wl.appId)
{
xdg_activation_token_v1_set_app_id(window->wl.activationToken,
requester->wl.appId);
}
}
xdg_activation_token_v1_commit(window->wl.activationToken);
}
void _glfwSetWindowMonitorWayland(_GLFWwindow* window,