window: focus on window show for wayland activation
authorJoan Bruguera <joanbrugueram@gmail.com>
Tue, 6 Dec 2022 20:55:53 +0000 (20:55 +0000)
committerDmitry Shachnev <mitya57@debian.org>
Wed, 15 Feb 2023 09:45:23 +0000 (09:45 +0000)
When using xdg_activation this is responsible for submitting
the activation token / startup id to the compositor.

This supersedes 5dca6dce91b4413064c858ae011ea7b1e33421e2, which misses the case
where the window is shown with gtk_widget_show instead of gtk_window_present.
Note 5dca6dce91 was also accidentally missing on the xdg-activation GTK3 port.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/5386
Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5301
Applied-upstream: no, rejected in https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5302#note_1622250

Gbp-Pq: Name window-focus-on-window-show-for-wayland-activation.patch

gtk/gtkwindow.c

index e1b09a3658e4cc218a217f1dc66fd6d9b49cb1cb..ded0a8e23bb9033837df61c0942eca006a24f70a 100644 (file)
@@ -6227,6 +6227,16 @@ gtk_window_show (GtkWidget *widget)
   
   if (priv->modal)
     gtk_grab_add (widget);
+
+#ifdef GDK_WINDOWING_WAYLAND
+  if (GDK_IS_WAYLAND_WINDOW (gtk_widget_get_window (widget)))
+    {
+      // Submits the activation token / startup id to the compositor
+      gdk_window_focus (gtk_widget_get_window (widget), priv->initial_timestamp);
+      // Use gtk_window_present's timestamp only once
+      priv->initial_timestamp = GDK_CURRENT_TIME;
+    }
+#endif
 }
 
 static void