From 2cfc0dd88a8c9c0e43b0521f48b00ab37bcf26f2 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 6 Sep 2026 03:47:26 +0300
Subject: [PATCH 69/69] gtk4(x): Unparent popups from the citydlg info labels

See RM #2194

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-gtk-4.0/citydlg.c | 11 +++++++++++
 client/gui-gtk-5.0/citydlg.c | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c
index 85f53984c3..61fcae210a 100644
--- a/client/gui-gtk-4.0/citydlg.c
+++ b/client/gui-gtk-4.0/citydlg.c
@@ -661,6 +661,14 @@ static gboolean citydlg_keyboard_handler(GtkEventControllerKey *controller,
   return FALSE;
 }
 
+/**********************************************************************//**
+  Information popup destruction requested
+**************************************************************************/
+static void info_popdown_callback(GtkWidget *w, gpointer data)
+{
+  gtk_widget_unparent(w);
+}
+
 /***********************************************************************//**
   Popup info dialog
 ***************************************************************************/
@@ -727,6 +735,9 @@ static gboolean show_info_popup(GtkGestureClick *gesture, int n_press,
 
   gtk_popover_set_child(GTK_POPOVER(p), label);
 
+  g_signal_connect(p, "closed",
+                   G_CALLBACK(info_popdown_callback), NULL);
+
   gtk_popover_popup(GTK_POPOVER(p));
 
   return TRUE;
diff --git a/client/gui-gtk-5.0/citydlg.c b/client/gui-gtk-5.0/citydlg.c
index 81b9c3c1f3..e12faddb13 100644
--- a/client/gui-gtk-5.0/citydlg.c
+++ b/client/gui-gtk-5.0/citydlg.c
@@ -808,6 +808,14 @@ static gboolean citydlg_keyboard_handler(GtkEventControllerKey *controller,
   return FALSE;
 }
 
+/**********************************************************************//**
+  Information popup destruction requested
+**************************************************************************/
+static void info_popdown_callback(GtkWidget *w, gpointer data)
+{
+  gtk_widget_unparent(w);
+}
+
 /***********************************************************************//**
   Popup info dialog
 ***************************************************************************/
@@ -874,6 +882,9 @@ static gboolean show_info_popup(GtkGestureClick *gesture, int n_press,
 
   gtk_popover_set_child(GTK_POPOVER(p), label);
 
+  g_signal_connect(p, "closed",
+                   G_CALLBACK(info_popdown_callback), NULL);
+
   gtk_popover_popup(GTK_POPOVER(p));
 
   return TRUE;
-- 
2.53.0

