gdk/x11: Emit "remove" s-n message from gdk_toplevel_set_startup_id
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 18 Jan 2023 19:37:01 +0000 (20:37 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 25 Jan 2023 10:22:40 +0000 (11:22 +0100)
In the way towards deprecating gdk_display_notify_startup_complete(),
make gdk_toplevel_set_startup_id() on X11 perform this piece of messaging
itself. It should be harmless that the message is emitted twice, if
callers do still use that API.

(cherry-picked from commit 7fab1b85adbddff7628e3e916f00677080fb9150)

gdk/x11/gdkwindow-x11.c

index 194bc82e298897b77f5129f8fc86b9c07afd89e8..89f066601487524a6d7c56a6ada2396f2a8e32ed 100644 (file)
@@ -2901,6 +2901,7 @@ gdk_x11_window_set_startup_id (GdkWindow   *window,
                               const gchar *startup_id)
 {
   GdkDisplay *display;
+  gchar *free_this = NULL;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
 
@@ -2918,6 +2919,23 @@ gdk_x11_window_set_startup_id (GdkWindow   *window,
   else
     XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
                      gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"));
+
+  if (startup_id == NULL)
+    {
+      GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
+
+      startup_id = free_this = display_x11->startup_notification_id;
+      display_x11->startup_notification_id = NULL;
+
+      if (startup_id == NULL)
+        return;
+    }
+
+  gdk_x11_display_broadcast_startup_message (display, "remove",
+                                             "ID", startup_id,
+                                             NULL);
+
+  g_free (free_this);
 }
 
 static void