From 25bf61a6c0855df2fac9262103fd43b35b2e8262 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 4 Feb 2023 17:29:27 +0000 Subject: [PATCH] Reapply GNOME/gtk!5301 for now I had hoped that applying GNOME/gtk!5443 and GNOME/gtk!5398 would resolve GNOME/gtk#5386, but that does not seem to be the case. --- ...ave-custom-xdg-activation-startup_id.patch | 39 ++++++++++++++++++ debian/patches/series | 2 + ...n-window-show-for-wayland-activation.patch | 40 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 debian/patches/gdk-wayland-save-custom-xdg-activation-startup_id.patch create mode 100644 debian/patches/window-focus-on-window-show-for-wayland-activation.patch diff --git a/debian/patches/gdk-wayland-save-custom-xdg-activation-startup_id.patch b/debian/patches/gdk-wayland-save-custom-xdg-activation-startup_id.patch new file mode 100644 index 0000000000..0764693706 --- /dev/null +++ b/debian/patches/gdk-wayland-save-custom-xdg-activation-startup_id.patch @@ -0,0 +1,39 @@ +From: Joan Bruguera +Date: Tue, 6 Dec 2022 23:51:28 +0000 +Subject: gdk/wayland: save custom xdg-activation startup_id + +We must save the startup id. in gdk_wayland_display_notify_startup_complete +which was set by a previous gtk_window_set_startup_id call so we can use it +later when presenting the window. + +Needed for activation of gnome-terminal (also needs patches on the application +side, see https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/7952). + +Signed-off-by: Joan Bruguera + +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 +--- + gdk/wayland/gdkdisplay-wayland.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c +index 55c0388..da366d7 100644 +--- a/gdk/wayland/gdkdisplay-wayland.c ++++ b/gdk/wayland/gdkdisplay-wayland.c +@@ -952,7 +952,13 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display, + #ifdef HAVE_XDG_ACTIVATION + /* Will be signaled with focus activation */ + if (display_wayland->xdg_activation) +- return; ++ { ++ if (startup_id != NULL) ++ { ++ display_wayland->startup_notification_id = g_strdup (startup_id); ++ } ++ return; ++ } + #endif + + if (startup_id == NULL) diff --git a/debian/patches/series b/debian/patches/series index 20328e0460..7f204afbb3 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -21,3 +21,5 @@ Remove-warning.patch 060_ignore-random-icons.patch reftest_compare_surfaces-Report-how-much-the-images-diffe.patch reftests-Allow-minor-differences-to-be-tolerated.patch +window-focus-on-window-show-for-wayland-activation.patch +gdk-wayland-save-custom-xdg-activation-startup_id.patch diff --git a/debian/patches/window-focus-on-window-show-for-wayland-activation.patch b/debian/patches/window-focus-on-window-show-for-wayland-activation.patch new file mode 100644 index 0000000000..4ad8445a22 --- /dev/null +++ b/debian/patches/window-focus-on-window-show-for-wayland-activation.patch @@ -0,0 +1,40 @@ +From: Joan Bruguera +Date: Tue, 6 Dec 2022 20:55:53 +0000 +Subject: window: focus on window show for wayland activation + +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 +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 +--- + gtk/gtkwindow.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c +index e1b09a3..ded0a8e 100644 +--- a/gtk/gtkwindow.c ++++ b/gtk/gtkwindow.c +@@ -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