diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index ec393a05dc4..d5fa2d916d3 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -112,7 +112,7 @@ ErrorOr MonitorSettingsWidget::create_frame() m_screen_combo->set_model(*GUI::ItemListModel::create(m_screens)); m_screen_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { m_selected_screen_index = index.row(); - auto result = selected_screen_index_or_resolution_changed(); + auto result = selected_screen_index_or_resolution_changed(DidScreenIndexChange::Yes); if (result.is_error()) GUI::MessageBox::show_error(window(), "Screen info could not be updated"sv); }; @@ -125,7 +125,7 @@ ErrorOr MonitorSettingsWidget::create_frame() selected_screen.resolution = m_resolutions.at(index.row()); // Try to auto re-arrange things if there are overlaps or disconnected screens m_screen_layout.normalize(); - auto result = selected_screen_index_or_resolution_changed(); + auto result = selected_screen_index_or_resolution_changed(DidScreenIndexChange::No); if (result.is_error()) { GUI::MessageBox::show_error(window(), "Screen info could not be updated"sv); return; @@ -161,7 +161,7 @@ ErrorOr MonitorSettingsWidget::create_frame() m_dpi_label = *find_descendant_of_type_named("display_dpi"); m_screen_combo->set_selected_index(m_selected_screen_index); - TRY(selected_screen_index_or_resolution_changed()); + TRY(selected_screen_index_or_resolution_changed(DidScreenIndexChange::Yes)); return {}; } @@ -217,14 +217,16 @@ ErrorOr MonitorSettingsWidget::load_current_settings() if (!m_screen_combo.is_null()) { m_screen_combo->set_selected_index(m_selected_screen_index); - TRY(selected_screen_index_or_resolution_changed()); + TRY(selected_screen_index_or_resolution_changed(DidScreenIndexChange::Yes)); } return {}; } -ErrorOr MonitorSettingsWidget::selected_screen_index_or_resolution_changed() +ErrorOr MonitorSettingsWidget::selected_screen_index_or_resolution_changed(DidScreenIndexChange screen_index_changed) { - TRY(create_resolution_list()); + // Generate new resolution list only when changing monitors + if (screen_index_changed == DidScreenIndexChange::Yes) + TRY(create_resolution_list()); auto& screen = m_screen_layout.screens[m_selected_screen_index]; diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h index c6114e7f30a..4caa094dc67 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.h @@ -18,6 +18,11 @@ namespace DisplaySettings { +enum class DidScreenIndexChange { + No, + Yes +}; + class MonitorSettingsWidget final : public GUI::SettingsWindow::Tab { C_OBJECT(MonitorSettingsWidget); @@ -43,7 +48,7 @@ private: ErrorOr create_resolution_list(); ErrorOr load_current_settings(); ErrorOr generate_resolution_strings(); - ErrorOr selected_screen_index_or_resolution_changed(); + ErrorOr selected_screen_index_or_resolution_changed(DidScreenIndexChange screen_index_changed); size_t m_selected_screen_index { 0 };