Skip to content

Commit 481deb4

Browse files
MacDuenico
authored andcommitted
DisplaySettings: Reapply old fix to avoid resetting background color
A reapplication of fix from bf9c08c, removed in e9e4bae. This meant changing an unrelated setting could change the background color to the current theme's default.
1 parent 4ff440a commit 481deb4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed)
163163
{
164164
}
165165

166+
static inline ByteString current_system_theme()
167+
{
168+
return GUI::ConnectionToWindowServer::the().get_system_theme();
169+
}
170+
166171
void ThemesSettingsWidget::apply_settings()
167172
{
168173
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()
172177
}
173178
auto color_scheme_path = color_scheme_path_or_error.release_value();
174179

180+
bool keep_background_color = m_background_settings_changed || (m_selected_theme && m_selected_theme->name == current_system_theme());
175181
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);
177183
if (!set_theme_result)
178184
GUI::MessageBox::show_error(window(), "Failed to apply theme settings"sv);
179185
} 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());
181187
if (!set_theme_result)
182188
GUI::MessageBox::show_error(window(), "Failed to apply theme settings"sv);
183189
} else {
@@ -187,7 +193,7 @@ void ThemesSettingsWidget::apply_settings()
187193
return;
188194
}
189195
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());
191197
if (!set_theme_result || preferred_color_scheme_path.is_error()) {
192198
GUI::MessageBox::show_error(window(), "Failed to apply theme settings"sv);
193199
return;

0 commit comments

Comments
 (0)