diff options
author | Xavier Defrang <xavier.defrang@gmail.com> | 2021-06-22 22:28:21 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-23 01:27:21 +0200 |
commit | 9dfc96f89bcb80443398a30c4213933da4a8dcf8 (patch) | |
tree | 3b607c561a817e4638c551b31c52f57ea86fbe9e | |
parent | 40f7977508bbe6f1e5abeb3e7192ca6776507dc6 (diff) | |
download | serenity-9dfc96f89bcb80443398a30c4213933da4a8dcf8.zip |
DisplaySettings: Revert changes unless confirmed
-rw-r--r-- | Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index abff8e00e1..e733b51167 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -121,12 +121,18 @@ void MonitorSettingsWidget::apply_settings() }); // 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) { + if (box->exec() == GUI::MessageBox::ExecYes) { auto save_result = GUI::WindowServerConnection::the().save_screen_layout(); if (!save_result.success()) { GUI::MessageBox::show(window(), String::formatted("Error saving settings: {}", save_result.error_msg()), "Unable to save setting", GUI::MessageBox::Type::Error); } + } else { + auto restore_result = GUI::WindowServerConnection::the().set_screen_layout(current_layout, false); + if (!restore_result.success()) { + GUI::MessageBox::show(window(), String::formatted("Error restoring settings: {}", restore_result.error_msg()), + "Unable to restore setting", GUI::MessageBox::Type::Error); + } } } else { GUI::MessageBox::show(window(), String::formatted("Error setting screen layout: {}", result.error_msg()), |