From d860b49ce602b9f9339547df03a6d25b7b7b9deb Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 2 Aug 2026 07:10:30 +0300
Subject: [PATCH 22/22] gtk4: Don't pause music when "Turn Done" button pressed

Grab the focus to another widget before "Turn Done"
button goes insensitive. That avoids freeciv window from
losing focus completely. This in turn fixes behavior
of the "Silent when not in focus" client option.

See RM #2107

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-gtk-4.0/gui_main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c
index 0219346533..2672cfe060 100644
--- a/client/gui-gtk-4.0/gui_main.c
+++ b/client/gui-gtk-4.0/gui_main.c
@@ -2263,6 +2263,10 @@ static gboolean show_info_popup(GtkGestureClick *gesture, int n_press,
 **************************************************************************/
 static void end_turn_callback(GtkWidget *w, gpointer data)
 {
+  /* Button going insensitive is going to lose focus. Keep focus at least
+   * within the window */
+  gtk_widget_grab_focus(map_canvas);
+
   gtk_widget_set_sensitive(turn_done_button, FALSE);
   user_ended_turn();
 }
-- 
2.53.0

