From 45d6c0091a37df874aaf92a16b096af3b532e259 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 23 Jan 2019 17:00:33 +0100 Subject: [PATCH 1/3] wayland/protocol: Update gtk-shell protocol to v3 This version has 2 new requests: - gtk_shell1.notify_launch notifies the compositor that the requesting client shall launch another application. The given ID is expected to be unique. - gtk_surface1.request_focus notifies the compositor that a surface requests focus due to it being activated. The given ID is passed to this process through undetermined means, if it corresponds with a current startup ID and there was no user interaction in between the surface will be focused, otherwise it will demand attention. --- gdk/wayland/protocol/gtk-shell.xml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gdk/wayland/protocol/gtk-shell.xml b/gdk/wayland/protocol/gtk-shell.xml index 8191fa9cfba..fb91940b309 100644 --- a/gdk/wayland/protocol/gtk-shell.xml +++ b/gdk/wayland/protocol/gtk-shell.xml @@ -1,6 +1,6 @@ - + gtk_shell is a protocol extension providing additional features for clients implementing it. @@ -28,9 +28,14 @@ + + + + + - + @@ -72,6 +77,11 @@ + + + + + -- GitLab From ed9db5a17327e0e12036d9daa25f37252554419d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 23 Jan 2019 17:03:25 +0100 Subject: [PATCH 2/3] gdk/wayland: Implement gdk_window_present() This uses the gtk_surface1.request_focus request added in gtk-shell v3, the given startup ID may be used by the compositor in order to determine when was the request started, and whether user input happened in between. Closes: https://gitlab.gnome.org/GNOME/gtk/issues/624 --- gdk/wayland/gdkdisplay-wayland.c | 2 +- gdk/wayland/gdkwindow-wayland.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 1e00f292d8e..be74c93e0af 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -83,7 +83,7 @@ #define MIN_SYSTEM_BELL_DELAY_MS 20 -#define GTK_SHELL1_VERSION 2 +#define GTK_SHELL1_VERSION 3 static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland); diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 91e01e1d90e..70f1044d9bd 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -3532,14 +3532,20 @@ gdk_wayland_window_focus (GdkWindow *window, if (!impl->display_server.gtk_surface) return; - /* We didn't have an event to fetch a time from, meaning we have nothing valid - * to send. This should rather be translated to a 'needs-attention' request or - * something. - */ if (timestamp == GDK_CURRENT_TIME) - return; + { + GdkWaylandDisplay *display_wayland = + GDK_WAYLAND_DISPLAY (gdk_window_get_display (window)); - gtk_surface1_present (impl->display_server.gtk_surface, timestamp); + if (display_wayland->gtk_shell_version >= 3) + { + gtk_surface1_request_focus (impl->display_server.gtk_surface, + display_wayland->startup_notification_id); + g_clear_pointer (&display_wayland->startup_notification_id, g_free); + } + } + else + gtk_surface1_present (impl->display_server.gtk_surface, timestamp); } static void -- GitLab From bff46d8696568b51c2c31e9379ee3a7249388f59 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 23 Jan 2019 17:02:01 +0100 Subject: [PATCH 3/3] gdk/wayland: Set a startup notification And notify the shell about it. This is done through the gtk_shell1.notify_launch request added in gtk-shell v3. All the plumbing on the way to the activated application is already in place to transfer the startup ID, so the other side just has to reply with gtk_surface1.request_focus. Closes: https://gitlab.gnome.org/GNOME/gtk/issues/624 --- gdk/wayland/gdkapplaunchcontext-wayland.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gdk/wayland/gdkapplaunchcontext-wayland.c b/gdk/wayland/gdkapplaunchcontext-wayland.c index b69cc31fce5..f18c13e6b4d 100644 --- a/gdk/wayland/gdkapplaunchcontext-wayland.c +++ b/gdk/wayland/gdkapplaunchcontext-wayland.c @@ -35,7 +35,20 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context GAppInfo *info, GList *files) { - return NULL; + GdkWaylandDisplay *display; + gchar *id = NULL; + + g_object_get (context, "display", &display, NULL); + + if (display->gtk_shell_version >= 3) + { + id = g_uuid_string_random (); + gtk_shell1_notify_launch (display->gtk_shell, id); + } + + g_object_unref (display); + + return id; } static void -- GitLab