From 9dfc96f89bcb80443398a30c4213933da4a8dcf8 Mon Sep 17 00:00:00 2001 From: Xavier Defrang Date: Tue, 22 Jun 2021 22:28:21 +0200 Subject: DisplaySettings: Revert changes unless confirmed --- Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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()), -- cgit v1.2.3