From 8b10645751224424ec9341ead0c66e06c9de1899 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 7 Jun 2023 07:24:28 +0300 Subject: [PATCH 12/12] gtk: Apply changes to 'fullscreen' option changes immediately When 'fullscreen' option was changed via options dialog, it was taken to use only after a client restart. Add an option changed callback to gtk-clients that apply the change immediately. Reported by onluntuva See osdn #47531 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/gui_main.c | 14 ++++++++++++++ client/gui-gtk-2.0/gui_main.h | 5 ++++- client/gui-gtk-2.0/menu.c | 6 +----- client/gui-gtk-3.0/gui_main.c | 14 ++++++++++++++ client/gui-gtk-3.0/gui_main.h | 3 +++ client/gui-gtk-3.0/menu.c | 6 +----- client/gui-gtk-3.22/gui_main.c | 14 ++++++++++++++ client/gui-gtk-3.22/gui_main.h | 3 +++ client/gui-gtk-3.22/menu.c | 6 +----- 9 files changed, 55 insertions(+), 16 deletions(-) diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c index 5ea4557e4e..a5b5c1b18e 100644 --- a/client/gui-gtk-2.0/gui_main.c +++ b/client/gui-gtk-2.0/gui_main.c @@ -2116,6 +2116,18 @@ static void allied_chat_only_callback(struct option *poption) option_bool_get(poption)); } +/**************************************************************************** + Option callback for the 'fullscreen' gtk-gui option. +****************************************************************************/ +void fullscreen_opt_refresh(struct option *poption) +{ + if (gui_options.gui_gtk2_fullscreen) { + gtk_window_fullscreen(GTK_WINDOW(toplevel)); + } else { + gtk_window_unfullscreen(GTK_WINDOW(toplevel)); + } +} + /**************************************************************************** Change the city names font. ****************************************************************************/ @@ -2167,6 +2179,8 @@ void options_extra_init(void) option_var_set_callback(gui_gtk2_allied_chat_only, allied_chat_only_callback); + option_var_set_callback(gui_gtk2_fullscreen, + fullscreen_opt_refresh); option_var_set_callback(gui_gtk2_font_city_names, apply_city_names_font); diff --git a/client/gui-gtk-2.0/gui_main.h b/client/gui-gtk-2.0/gui_main.h index 980355088c..64b5b73306 100644 --- a/client/gui-gtk-2.0/gui_main.h +++ b/client/gui-gtk-2.0/gui_main.h @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ /* client */ #include "gui_main_g.h" +#include "options.h" /* gui-gtk-2.0 */ #include "gtkpixcomm.h" @@ -92,6 +93,8 @@ void popup_quit_dialog(void); void quit_gtk_main(void); void refresh_chat_buttons(void); +void fullscreen_opt_refresh(struct option *poption); + bool is_gui_up(void); void update_turn_done_tooltip(void); diff --git a/client/gui-gtk-2.0/menu.c b/client/gui-gtk-2.0/menu.c index 76084c4ffa..b61d5d0071 100644 --- a/client/gui-gtk-2.0/menu.c +++ b/client/gui-gtk-2.0/menu.c @@ -829,11 +829,7 @@ static void full_screen_callback(GtkToggleAction *action, gpointer data) if (gui_options.gui_gtk2_fullscreen ^ gtk_toggle_action_get_active(action)) { gui_options.gui_gtk2_fullscreen ^= 1; - if (gui_options.gui_gtk2_fullscreen) { - gtk_window_fullscreen(GTK_WINDOW(toplevel)); - } else { - gtk_window_unfullscreen(GTK_WINDOW(toplevel)); - } + fullscreen_opt_refresh(NULL); } } diff --git a/client/gui-gtk-3.0/gui_main.c b/client/gui-gtk-3.0/gui_main.c index c5a2fe1dbd..6802003151 100644 --- a/client/gui-gtk-3.0/gui_main.c +++ b/client/gui-gtk-3.0/gui_main.c @@ -2209,6 +2209,18 @@ static void allied_chat_only_callback(struct option *poption) option_bool_get(poption)); } +/**************************************************************************** + Option callback for the 'fullscreen' gtk-gui option. +****************************************************************************/ +void fullscreen_opt_refresh(struct option *poption) +{ + if (GUI_GTK_OPTION(fullscreen)) { + gtk_window_fullscreen(GTK_WINDOW(toplevel)); + } else { + gtk_window_unfullscreen(GTK_WINDOW(toplevel)); + } +} + /**************************************************************************** Change the city names font. ****************************************************************************/ @@ -2260,6 +2272,8 @@ void options_extra_init(void) option_var_set_callback(allied_chat_only, allied_chat_only_callback); + option_var_set_callback(fullscreen, + fullscreen_opt_refresh); option_var_set_callback(font_city_names, apply_city_names_font); diff --git a/client/gui-gtk-3.0/gui_main.h b/client/gui-gtk-3.0/gui_main.h index 68612b7c62..7288fafb04 100644 --- a/client/gui-gtk-3.0/gui_main.h +++ b/client/gui-gtk-3.0/gui_main.h @@ -17,6 +17,7 @@ /* client */ #include "gui_main_g.h" +#include "options.h" #define GUI_GTK_OPTION(optname) gui_options.gui_gtk3_##optname #define GUI_GTK_OPTION_STR(optname) "gui_gtk3_" #optname @@ -83,6 +84,8 @@ int screen_width(void); int screen_height(void); struct video_mode *resolution_request_get(void); +void fullscreen_opt_refresh(struct option *poption); + bool is_gui_up(void); void update_turn_done_tooltip(void); diff --git a/client/gui-gtk-3.0/menu.c b/client/gui-gtk-3.0/menu.c index ae7719f045..72ced4091c 100644 --- a/client/gui-gtk-3.0/menu.c +++ b/client/gui-gtk-3.0/menu.c @@ -1319,11 +1319,7 @@ static void full_screen_callback(GtkCheckMenuItem *item, gpointer data) if (GUI_GTK_OPTION(fullscreen) ^ gtk_check_menu_item_get_active(item)) { GUI_GTK_OPTION(fullscreen) ^= 1; - if (GUI_GTK_OPTION(fullscreen)) { - gtk_window_fullscreen(GTK_WINDOW(toplevel)); - } else { - gtk_window_unfullscreen(GTK_WINDOW(toplevel)); - } + fullscreen_opt_refresh(NULL); } } diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c index bde3ac62cd..996be76c5c 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -2294,6 +2294,18 @@ static void allied_chat_only_callback(struct option *poption) option_bool_get(poption)); } +/**************************************************************************** + Option callback for the 'fullscreen' gtk-gui option. +****************************************************************************/ +void fullscreen_opt_refresh(struct option *poption) +{ + if (GUI_GTK_OPTION(fullscreen)) { + gtk_window_fullscreen(GTK_WINDOW(toplevel)); + } else { + gtk_window_unfullscreen(GTK_WINDOW(toplevel)); + } +} + /**************************************************************************** Change the city names font. ****************************************************************************/ @@ -2345,6 +2357,8 @@ void options_extra_init(void) option_var_set_callback(allied_chat_only, allied_chat_only_callback); + option_var_set_callback(fullscreen, + fullscreen_opt_refresh); option_var_set_callback(font_city_names, apply_city_names_font); diff --git a/client/gui-gtk-3.22/gui_main.h b/client/gui-gtk-3.22/gui_main.h index 94fe58367c..c28adeea87 100644 --- a/client/gui-gtk-3.22/gui_main.h +++ b/client/gui-gtk-3.22/gui_main.h @@ -17,6 +17,7 @@ /* client */ #include "gui_main_g.h" +#include "options.h" #define GUI_GTK_OPTION(optname) gui_options.gui_gtk3_22_##optname #define GUI_GTK_OPTION_STR(optname) "gui_gtk3_22_" #optname @@ -83,6 +84,8 @@ int screen_width(void); int screen_height(void); struct video_mode *resolution_request_get(void); +void fullscreen_opt_refresh(struct option *poption); + bool is_gui_up(void); void update_turn_done_tooltip(void); diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index 9b9687b27a..8ab1a25e7d 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -1318,11 +1318,7 @@ static void full_screen_callback(GtkCheckMenuItem *item, gpointer data) if (GUI_GTK_OPTION(fullscreen) ^ gtk_check_menu_item_get_active(item)) { GUI_GTK_OPTION(fullscreen) ^= 1; - if (GUI_GTK_OPTION(fullscreen)) { - gtk_window_fullscreen(GTK_WINDOW(toplevel)); - } else { - gtk_window_unfullscreen(GTK_WINDOW(toplevel)); - } + fullscreen_opt_refresh(NULL); } } -- 2.39.2