From 2af3f64ecfaf1b41ed000e277c796808d717ecb9 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Wed, 2 Jun 2021 14:37:09 -0400 Subject: [PATCH] wayland: Activate the window on first ShowWindow, if possible --- src/video/wayland/SDL_waylandwindow.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index cf4c81273..1c69d54f8 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -775,6 +775,22 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) if (window->flags & SDL_WINDOW_BORDERLESS) { Wayland_SetWindowBordered(_this, window, SDL_FALSE); } + + /* We're finally done putting the window together, raise if possible */ + if (c->activation_manager) { + /* Note that we don't check for empty strings, as that is still + * considered a valid activation token! + */ + const char *activation_token = SDL_getenv("XDG_ACTIVATION_TOKEN"); + if (activation_token) { + xdg_activation_v1_activate(c->activation_manager, + activation_token, + data->surface); + + /* Clear this variable, per the protocol's request */ + unsetenv("XDG_ACTIVATION_TOKEN"); + } + } } void Wayland_HideWindow(_THIS, SDL_Window *window)