Blob Blame History Raw
diff -urNp xchat-2.8.8.orig/src/fe-gtk/plugin-tray.c xchat-2.8.8/src/fe-gtk/plugin-tray.c
--- xchat-2.8.8.orig/src/fe-gtk/plugin-tray.c	2019-08-16 15:08:14.591032240 +0200
+++ xchat-2.8.8/src/fe-gtk/plugin-tray.c	2019-08-16 15:09:06.772393960 +0200
@@ -65,9 +65,13 @@ static int tray_priv_count = 0;
 static int tray_pub_count = 0;
 static int tray_hilight_count = 0;
 static int tray_file_count = 0;
+static int tray_restore_timer = 0;
 
 
 void tray_apply_setup (void);
+static gboolean tray_menu_try_restore (void);
+static void tray_cleanup (void);
+static void tray_init (void);
 
 
 static WinStatus
@@ -406,6 +410,34 @@ tray_menu_restore_cb (GtkWidget *item, g
 }
 
 static void
+tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data)
+{
+	if (sticon)
+	{
+		if (!gtk_status_icon_is_embedded (sticon))
+		{
+			tray_restore_timer = g_timeout_add (500, (GSourceFunc)tray_menu_try_restore, NULL);
+		}
+		else
+		{
+			if (tray_restore_timer)
+			{
+				g_source_remove (tray_restore_timer);
+				tray_restore_timer = 0;
+			}
+		}
+	}
+}
+
+static gboolean
+tray_menu_try_restore (void)
+{
+	tray_cleanup ();
+	tray_init ();
+	return TRUE;
+}
+
+static void
 tray_menu_quit_cb (GtkWidget *item, gpointer userdata)
 {
 	mg_open_quit_dialog (FALSE);
@@ -555,6 +587,8 @@ tray_init (void)
 							G_CALLBACK (tray_menu_cb), sticon);
 	g_signal_connect (G_OBJECT (sticon), "activate",
 							G_CALLBACK (tray_menu_restore_cb), NULL);
+	g_signal_connect (G_OBJECT (sticon), "notify::embedded",
+							G_CALLBACK (tray_menu_notify_cb), NULL);
 }
 
 static int