diff options
Diffstat (limited to 'gdk/wayland/gdkapplaunchcontext-wayland.c')
-rw-r--r-- | gdk/wayland/gdkapplaunchcontext-wayland.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/gdk/wayland/gdkapplaunchcontext-wayland.c b/gdk/wayland/gdkapplaunchcontext-wayland.c index f18c13e6b4..004a390bd2 100644 --- a/gdk/wayland/gdkapplaunchcontext-wayland.c +++ b/gdk/wayland/gdkapplaunchcontext-wayland.c @@ -30,6 +30,24 @@ #include "gdkinternals.h" #include "gdkintl.h" +typedef struct { + gchar *token; +} AppLaunchData; + +static void +token_done (gpointer data, + struct xdg_activation_token_v1 *provider, + const char *token) +{ + AppLaunchData *app_launch_data = data; + + app_launch_data->token = g_strdup (token); +} + +static const struct xdg_activation_token_v1_listener token_listener = { + token_done, +}; + static char * gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context, GAppInfo *info, @@ -40,7 +58,34 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context g_object_get (context, "display", &display, NULL); - if (display->gtk_shell_version >= 3) + if (display->xdg_activation) + { + struct xdg_activation_token_v1 *token; + GdkSeat *seat; + GdkWindow *focus_window; + AppLaunchData app_launch_data = { 0 }; + + seat = gdk_display_get_default_seat (GDK_DISPLAY (display)); + focus_window = gdk_wayland_device_get_focus (gdk_seat_get_keyboard (seat)); + token = xdg_activation_v1_get_activation_token (display->xdg_activation); + + xdg_activation_token_v1_add_listener (token, + &token_listener, + &app_launch_data); + xdg_activation_token_v1_set_serial (token, + _gdk_wayland_seat_get_last_implicit_grab_serial (seat, NULL), + gdk_wayland_seat_get_wl_seat (seat)); + xdg_activation_token_v1_set_surface (token, + gdk_wayland_window_get_wl_surface (focus_window)); + xdg_activation_token_v1_commit (token); + + while (app_launch_data.token == NULL) + wl_display_roundtrip (display->wl_display); + + xdg_activation_token_v1_destroy (token); + id = app_launch_data.token; + } + else if (display->gtk_shell_version >= 3) { id = g_uuid_string_random (); gtk_shell1_notify_launch (display->gtk_shell, id); |