From a468cd8023fef02509642eb8d211269d30b0d811 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 23 Aug 2026 00:59:57 +0300
Subject: [PATCH 59/59] gtk4(x): Fix reopening Messages tab closed as window

If Messages were windowed and then closed, it was
impossible to reopen afterwards.

See RM #2160

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-gtk-4.0/gui_stuff.c  | 2 ++
 client/gui-gtk-4.0/messagewin.c | 2 +-
 client/gui-gtk-5.0/gui_stuff.c  | 2 ++
 client/gui-gtk-5.0/messagewin.c | 2 +-
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c
index 31ee468f5b..be24e1f97f 100644
--- a/client/gui-gtk-4.0/gui_stuff.c
+++ b/client/gui-gtk-4.0/gui_stuff.c
@@ -352,6 +352,8 @@ static gint gui_dialog_delete_handler(GtkWidget *widget, gpointer data)
 {
   struct gui_dialog *dlg = data;
 
+  dlg->v.window = NULL;
+
   /* emit response signal. */
   gui_dialog_response(dlg, GTK_RESPONSE_DELETE_EVENT);
 
diff --git a/client/gui-gtk-4.0/messagewin.c b/client/gui-gtk-4.0/messagewin.c
index 31bb202306..42f9fb8747 100644
--- a/client/gui-gtk-4.0/messagewin.c
+++ b/client/gui-gtk-4.0/messagewin.c
@@ -420,7 +420,7 @@ static void meswin_dialog_free(struct meswin_dialog *pdialog)
 ****************************************************************************/
 void meswin_dialog_popup(bool raise)
 {
-  if (NULL == meswin.shell) {
+  if (meswin.shell == NULL || meswin.shell->v.window == NULL) {
     meswin_dialog_init(&meswin);
   }
 
diff --git a/client/gui-gtk-5.0/gui_stuff.c b/client/gui-gtk-5.0/gui_stuff.c
index 90a1047177..8fbba7c44c 100644
--- a/client/gui-gtk-5.0/gui_stuff.c
+++ b/client/gui-gtk-5.0/gui_stuff.c
@@ -353,6 +353,8 @@ static gint gui_dialog_delete_handler(GtkWidget *widget, gpointer data)
 {
   struct gui_dialog *dlg = data;
 
+  dlg->v.window = NULL;
+
   /* emit response signal. */
   gui_dialog_response(dlg, GTK_RESPONSE_DELETE_EVENT);
 
diff --git a/client/gui-gtk-5.0/messagewin.c b/client/gui-gtk-5.0/messagewin.c
index 4acb358793..8195763e7f 100644
--- a/client/gui-gtk-5.0/messagewin.c
+++ b/client/gui-gtk-5.0/messagewin.c
@@ -420,7 +420,7 @@ static void meswin_dialog_free(struct meswin_dialog *pdialog)
 ****************************************************************************/
 void meswin_dialog_popup(bool raise)
 {
-  if (NULL == meswin.shell) {
+  if (meswin.shell == NULL || meswin.shell->v.window == NULL) {
     meswin_dialog_init(&meswin);
   }
 
-- 
2.53.0

