diff options
author | belginul <belginstirbu@hotmail.com> | 2021-02-18 18:59:58 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-19 12:19:03 +0100 |
commit | 4f80bb6ce35ec3e3f86b11f3934d95409578bcc4 (patch) | |
tree | 4617689f70f4121bdc19784a30471d710567f59e | |
parent | a4d4571522501f138c62ae10e8485b78eee80c8b (diff) | |
download | serenity-4f80bb6ce35ec3e3f86b11f3934d95409578bcc4.zip |
DisplaySettings: Show revert dialog only for resolution/dpi changes.
-rw-r--r-- | Userland/Applications/DisplaySettings/DisplaySettings.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/Userland/Applications/DisplaySettings/DisplaySettings.cpp b/Userland/Applications/DisplaySettings/DisplaySettings.cpp index 3bc9799122..8db7086f32 100644 --- a/Userland/Applications/DisplaySettings/DisplaySettings.cpp +++ b/Userland/Applications/DisplaySettings/DisplaySettings.cpp @@ -283,28 +283,30 @@ void DisplaySettingsWidget::send_settings_to_window_server() current_scale_factor = 1; } - auto result = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetResolution>(m_monitor_widget->desktop_resolution(), m_monitor_widget->desktop_scale_factor()); - if (!result->success()) { - GUI::MessageBox::show(nullptr, String::formatted("Reverting to resolution {}x{} @ {}x", result->resolution().width(), result->resolution().height(), result->scale_factor()), - "Unable to set resolution", GUI::MessageBox::Type::Error); - } else { - auto box = GUI::MessageBox::construct(window(), String::formatted("Do you want to keep the new settings? They will be reverted after 10 seconds."), - String::formatted("New screen resolution: {}x{} @ {}x", m_monitor_widget->desktop_resolution().width(), m_monitor_widget->desktop_resolution().height(), - m_monitor_widget->desktop_scale_factor()), - GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - box->set_icon(window()->icon()); - - // If after 10 seconds the user doesn't close the message box, just close it. - auto timer = Core::Timer::construct(10000, [&] { - box->close(); - }); - - // If the user selects "No", closes the window or the window gets closed by the 10 seconds timer, revert the changes. - if (box->exec() != GUI::MessageBox::ExecYes) { - result = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetResolution>(current_resolution, current_scale_factor); - if (!result->success()) { - GUI::MessageBox::show(nullptr, String::formatted("Reverting to resolution {}x{} @ {}x", result->resolution().width(), result->resolution().height(), result->scale_factor()), - "Unable to set resolution", GUI::MessageBox::Type::Error); + if (current_resolution != m_monitor_widget->desktop_resolution() || current_scale_factor != m_monitor_widget->desktop_scale_factor()) { + auto result = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetResolution>(m_monitor_widget->desktop_resolution(), m_monitor_widget->desktop_scale_factor()); + if (!result->success()) { + GUI::MessageBox::show(nullptr, String::formatted("Reverting to resolution {}x{} @ {}x", result->resolution().width(), result->resolution().height(), result->scale_factor()), + "Unable to set resolution", GUI::MessageBox::Type::Error); + } else { + auto box = GUI::MessageBox::construct(window(), String::formatted("Do you want to keep the new settings? They will be reverted after 10 seconds."), + String::formatted("New screen resolution: {}x{} @ {}x", m_monitor_widget->desktop_resolution().width(), m_monitor_widget->desktop_resolution().height(), + m_monitor_widget->desktop_scale_factor()), + GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + box->set_icon(window()->icon()); + + // If after 10 seconds the user doesn't close the message box, just close it. + auto timer = Core::Timer::construct(10000, [&] { + box->close(); + }); + + // If the user selects "No", closes the window or the window gets closed by the 10 seconds timer, revert the changes. + if (box->exec() != GUI::MessageBox::ExecYes) { + result = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetResolution>(current_resolution, current_scale_factor); + if (!result->success()) { + GUI::MessageBox::show(nullptr, String::formatted("Reverting to resolution {}x{} @ {}x", result->resolution().width(), result->resolution().height(), result->scale_factor()), + "Unable to set resolution", GUI::MessageBox::Type::Error); + } } } } |