@@ -163,6 +163,11 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed)
163
163
{
164
164
}
165
165
166
+ static inline ByteString current_system_theme ()
167
+ {
168
+ return GUI::ConnectionToWindowServer::the ().get_system_theme ();
169
+ }
170
+
166
171
void ThemesSettingsWidget::apply_settings ()
167
172
{
168
173
auto color_scheme_path_or_error = String::formatted (" /res/color-schemes/{}.ini" , m_selected_color_scheme_name);
@@ -172,12 +177,13 @@ void ThemesSettingsWidget::apply_settings()
172
177
}
173
178
auto color_scheme_path = color_scheme_path_or_error.release_value ();
174
179
180
+ bool keep_background_color = m_background_settings_changed || (m_selected_theme && m_selected_theme->name == current_system_theme ());
175
181
if (!m_color_scheme_is_file_based && find_descendant_of_type_named<GUI::CheckBox>(" custom_color_scheme_checkbox" )->is_checked ()) {
176
- auto set_theme_result = GUI::ConnectionToWindowServer::the ().set_system_theme (m_selected_theme->path , m_selected_theme->name , m_background_settings_changed , " Custom" sv);
182
+ auto set_theme_result = GUI::ConnectionToWindowServer::the ().set_system_theme (m_selected_theme->path , m_selected_theme->name , keep_background_color , " Custom" sv);
177
183
if (!set_theme_result)
178
184
GUI::MessageBox::show_error (window (), " Failed to apply theme settings" sv);
179
185
} else if (find_descendant_of_type_named<GUI::CheckBox>(" custom_color_scheme_checkbox" )->is_checked ()) {
180
- auto set_theme_result = GUI::ConnectionToWindowServer::the ().set_system_theme (m_selected_theme->path , m_selected_theme->name , m_background_settings_changed , color_scheme_path.to_byte_string ());
186
+ auto set_theme_result = GUI::ConnectionToWindowServer::the ().set_system_theme (m_selected_theme->path , m_selected_theme->name , keep_background_color , color_scheme_path.to_byte_string ());
181
187
if (!set_theme_result)
182
188
GUI::MessageBox::show_error (window (), " Failed to apply theme settings" sv);
183
189
} else {
@@ -187,7 +193,7 @@ void ThemesSettingsWidget::apply_settings()
187
193
return ;
188
194
}
189
195
auto preferred_color_scheme_path = get_color_scheme_name_from_pathname (theme_config.release_value ()->read_entry (" Paths" , " ColorScheme" ));
190
- auto set_theme_result = GUI::ConnectionToWindowServer::the ().set_system_theme (m_selected_theme->path , m_selected_theme->name , m_background_settings_changed , OptionalNone ());
196
+ auto set_theme_result = GUI::ConnectionToWindowServer::the ().set_system_theme (m_selected_theme->path , m_selected_theme->name , keep_background_color , OptionalNone ());
191
197
if (!set_theme_result || preferred_color_scheme_path.is_error ()) {
192
198
GUI::MessageBox::show_error (window (), " Failed to apply theme settings" sv);
193
199
return ;
0 commit comments