From 1ec264194103f7814bc127eaed94b4d19e737af5 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 1 Jul 2025 16:49:55 +0000 Subject: [PATCH] gui, widgets: Use system colors on Windows title bar... ...when System colors theme is set. Previously, we just checked if the theme was set to Light or not and used that to decide the title bar colors. With the System colors theme, this was no longer valid logic. This patch renames themes_win32_is_darkmode_active () to gimp_is_win32_system_theme_dark (), and moves it to gimpwidgets-utils.c so that it can be accessed by functions that need to determine Windows mode settings. We then use it to determine dark mode if the System colors theme is set, and use the original logic otherwise. --- app/gui/themes.c | 24 +----------------------- app/widgets/gimpwidgets-utils.c | 23 ++++++++++++++++++++++- app/widgets/gimpwidgets-utils.h | 1 + 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/gui/themes.c b/app/gui/themes.c index a50c589571..1ae5401c6f 100644 --- a/app/gui/themes.c +++ b/app/gui/themes.c @@ -65,10 +65,6 @@ static void themes_theme_settings_portal_changed (GDBusProxy *proxy Gimp *gimp); #endif -#ifdef G_OS_WIN32 -static gboolean themes_win32_is_darkmode_active (void); -#endif - /* private variables */ @@ -406,7 +402,7 @@ themes_apply_theme (Gimp *gimp, #elif defined(G_OS_WIN32) if (config->theme_scheme == GIMP_THEME_SYSTEM) { - prefer_dark_theme = themes_win32_is_darkmode_active (); + prefer_dark_theme = gimp_is_win32_system_theme_dark (); color_scheme = prefer_dark_theme ? GIMP_THEME_DARK : GIMP_THEME_LIGHT; } else @@ -874,22 +870,4 @@ themes_set_title_bar (Gimp *gimp) if (windows) g_list_free (windows); } - -static gboolean -themes_win32_is_darkmode_active (void) -{ - DWORD val = 0; - DWORD val_size = sizeof (val); - LSTATUS status; - - status = RegGetValueA(HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", - "AppsUseLightTheme", - RRF_RT_REG_DWORD, - NULL, - &val, - &val_size); - - return status == ERROR_SUCCESS && val == 0; -} #endif diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c index 8fbfa1ad96..1aa3c718e7 100644 --- a/app/widgets/gimpwidgets-utils.c +++ b/app/widgets/gimpwidgets-utils.c @@ -2677,7 +2677,10 @@ gimp_window_set_title_bar_theme (Gimp *gimp, GimpGuiConfig *config; config = GIMP_GUI_CONFIG (gimp->config); - use_dark_mode = (config->theme_scheme != GIMP_THEME_LIGHT); + if (config->theme_scheme == GIMP_THEME_SYSTEM) + use_dark_mode = gimp_is_win32_system_theme_dark (); + else + use_dark_mode = (config->theme_scheme != GIMP_THEME_LIGHT); } else { @@ -2706,4 +2709,22 @@ gimp_window_set_title_bar_theme (Gimp *gimp, &use_dark_mode, sizeof (use_dark_mode)); } } + +gboolean +gimp_is_win32_system_theme_dark (void) +{ + DWORD val = 0; + DWORD val_size = sizeof (val); + LSTATUS status; + + status = RegGetValueA(HKEY_CURRENT_USER, + "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", + "AppsUseLightTheme", + RRF_RT_REG_DWORD, + NULL, + &val, + &val_size); + + return status == ERROR_SUCCESS && val == 0; +} #endif diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h index 0615718640..23edfd4b44 100644 --- a/app/widgets/gimpwidgets-utils.h +++ b/app/widgets/gimpwidgets-utils.h @@ -167,6 +167,7 @@ gboolean gimp_utils_are_menu_path_identical (const gchar *path1 #ifdef G_OS_WIN32 void gimp_window_set_title_bar_theme (Gimp *gimp, GtkWidget *dialog); +gboolean gimp_is_win32_system_theme_dark (void); #endif #endif /* __APP_GIMP_WIDGETS_UTILS_H__ */