Florian Müllner f7f80c
From b39b84c683e29086b999b835c09ac4ee5a960852 Mon Sep 17 00:00:00 2001
Florian Müllner f7f80c
From: Ray Strode <rstrode@redhat.com>
Florian Müllner f7f80c
Date: Thu, 14 Sep 2017 14:46:13 -0400
Florian Müllner f7f80c
Subject: [PATCH] gtk-embed: ensure we only listen for window-created events
Florian Müllner f7f80c
 once
Florian Müllner f7f80c
Florian Müllner f7f80c
If a tray icon gets a mapped and unmapped and the mapped again
Florian Müllner f7f80c
in quick succession, we can end up with multiple handlers
Florian Müllner f7f80c
listening for window creation events.
Florian Müllner f7f80c
Florian Müllner f7f80c
This commit tries to guard against that by only listening for
Florian Müllner f7f80c
window-created events when we don't  know the actor associated
Florian Müllner f7f80c
with the icon.
Florian Müllner f7f80c
Florian Müllner f7f80c
https://bugzilla.gnome.org/show_bug.cgi?id=787361
Florian Müllner f7f80c
---
Florian Müllner f7f80c
 src/shell-gtk-embed.c | 15 ++++++++-------
Florian Müllner f7f80c
 1 file changed, 8 insertions(+), 7 deletions(-)
Florian Müllner f7f80c
Florian Müllner f7f80c
diff --git a/src/shell-gtk-embed.c b/src/shell-gtk-embed.c
Florian Müllner f7f80c
index 176b41320..54061046b 100644
Florian Müllner f7f80c
--- a/src/shell-gtk-embed.c
Florian Müllner f7f80c
+++ b/src/shell-gtk-embed.c
Florian Müllner f7f80c
@@ -124,13 +124,14 @@ shell_gtk_embed_on_window_mapped (GtkWidget     *object,
Florian Müllner f7f80c
   ShellGtkEmbedPrivate *priv = shell_gtk_embed_get_instance_private (embed);
Florian Müllner f7f80c
   MetaDisplay *display = shell_global_get_display (shell_global_get ());
Florian Müllner f7f80c
 
Florian Müllner f7f80c
-  /* Listen for new windows so we can detect when Mutter has
Florian Müllner f7f80c
-     created a MutterWindow for this window */
Florian Müllner f7f80c
-  priv->window_created_handler =
Florian Müllner f7f80c
-    g_signal_connect (display,
Florian Müllner f7f80c
-                      "window-created",
Florian Müllner f7f80c
-                      G_CALLBACK (shell_gtk_embed_window_created_cb),
Florian Müllner f7f80c
-                      embed);
Florian Müllner f7f80c
+  if (priv->window_created_handler == 0 && priv->window_actor == NULL)
Florian Müllner f7f80c
+    /* Listen for new windows so we can detect when Mutter has
Florian Müllner f7f80c
+       created a MutterWindow for this window */
Florian Müllner f7f80c
+    priv->window_created_handler =
Florian Müllner f7f80c
+      g_signal_connect (display,
Florian Müllner f7f80c
+                        "window-created",
Florian Müllner f7f80c
+                        G_CALLBACK (shell_gtk_embed_window_created_cb),
Florian Müllner f7f80c
+                        embed);
Florian Müllner f7f80c
 }
Florian Müllner f7f80c
 
Florian Müllner f7f80c
 static void
Florian Müllner f7f80c
-- 
Florian Müllner f7f80c
2.13.5
Florian Müllner f7f80c