From 5dca6dce91b4413064c858ae011ea7b1e33421e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 25 Aug 2021 12:17:47 +0200 Subject: [PATCH 1/5] window: Make sure we call gdk_wayland_surface_focus When using xdg_activation this is responsible for submitting the activation token / startup id to the compositor. --- gtk/gtkwindow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 9c58c36f1b..ec6bb6fd20 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -5271,14 +5271,15 @@ gtk_window_present_with_time (GtkWindow *window, #endif timestamp = gtk_get_current_event_time (); } - - gdk_toplevel_focus (GDK_TOPLEVEL (surface), timestamp); } else { priv->initial_timestamp = timestamp; gtk_widget_show (widget); } + + g_assert (priv->surface != NULL); + gdk_toplevel_focus (GDK_TOPLEVEL (priv->surface), timestamp); } /** From 999509be619bfa0f50a549489b5ab5c890b574fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 25 Aug 2021 12:21:48 +0200 Subject: [PATCH 2/5] wayland: Keep startup_notification_id around long enough When using xdg_activation we need to keep the id around until we send the first activate to signal succesful startup. --- gdk/wayland/gdkdisplay-wayland.c | 4 ++++ gdk/wayland/gdksurface-wayland.c | 1 + 2 files changed, 5 insertions(+) diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index ea64041aa7..c8100ff4fa 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -854,6 +854,10 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display, GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); char *free_this = NULL; + /* Will be signaled with focus activation */ + if (display_wayland->xdg_activation) + return; + if (startup_id == NULL) { startup_id = free_this = display_wayland->startup_notification_id; diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index da2f110b14..25be2f0b7c 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -3474,6 +3474,7 @@ gdk_wayland_surface_focus (GdkSurface *surface, xdg_activation_v1_activate (display_wayland->xdg_activation, display_wayland->startup_notification_id, impl->display_server.wl_surface); + gdk_wayland_display_set_startup_notification_id (GDK_DISPLAY (display_wayland), NULL); } else if (display_wayland->gtk_shell_version >= 3) { From 5ba02e3459d56ad1bec6ded002e93f1d753eb4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 11 Jan 2022 20:27:25 +0100 Subject: [PATCH 3/5] widget-factory: Use gtk_window_present() This lets xdg-activation work as otherwise gdk_wayland_surface_focus is never invoked. --- demos/widget-factory/widget-factory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 319ad760ac..5e0353b80b 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -2360,7 +2360,7 @@ activate (GApplication *app) model = (GMenuModel *)gtk_builder_get_object (builder, "new_style_context_menu_model"); set_up_context_popover (widget, model); - gtk_widget_show (GTK_WIDGET (window)); + gtk_window_present (window); g_object_unref (builder); } From db8339ca66ef75b7b71bf2603c1b5910c1708b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 11 Jan 2022 20:27:25 +0100 Subject: [PATCH 4/5] demo: Use gtk_window_present() This lets xdg-activation work as otherwise gdk_wayland_surface_focus is never invoked. --- demos/gtk-demo/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index da6b5db73a..a31ce36790 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -1040,7 +1040,7 @@ out: g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app); } else - gtk_widget_show (GTK_WIDGET (window)); + gtk_window_present (GTK_WINDOW (window)); if (autoquit) g_timeout_add_seconds (1, auto_quit, app); From 25f4e597eed7a216953b01f7693c429bec05b0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 11 Jan 2022 20:27:25 +0100 Subject: [PATCH 5/5] print-editor: Use gtk_window_present() This lets xdg-activation work as otherwise gdk_wayland_surface_focus is never invoked. --- demos/print-editor/print-editor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/print-editor/print-editor.c b/demos/print-editor/print-editor.c index bfadd5e494..ca5d143d06 100644 --- a/demos/print-editor/print-editor.c +++ b/demos/print-editor/print-editor.c @@ -871,7 +871,7 @@ activate (GApplication *app) update_ui (); - gtk_widget_show (main_window); + gtk_window_present (GTK_WINDOW (main_window)); } static void