Maelstrom: Clicking on the control button again closes the popup

From bc2681d5d896dcf48196369d4f36a622d598cd65 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 5 Apr 2026 23:16:23 -0700
Subject: [PATCH] Clicking on the control button again closes the popup

---
 game/lobby.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/game/lobby.cpp b/game/lobby.cpp
index 1e4c8aaa..376b5eef 100644
--- a/game/lobby.cpp
+++ b/game/lobby.cpp
@@ -104,6 +104,16 @@ class ControlClickCallback : public UIClickCallback
 			return;
 		}
 
+		// If we're clicking twice on the same button, close the dialog
+		if (m_dialog->IsShown()) {
+			UIAnchorInfo anchor;
+			m_dialog->GetAnchor(anchor);
+			if (anchor.element == m_button) {
+				m_dialog->Hide();
+				return;
+			}
+		}
+
 		// Show the control dialog
 		unsigned int num_gamepads = GetNumGamepads();
 		SetControl(CONTROL_NONE, (m_index > 0) && m_game.IsHosting());