mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 16:44:11 +00:00
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:
+30
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user