Desktop: fix Mac restart dialog to show all changes to preferences requiring restart (#3903)

* Desktop: Fix restart dialog on Mac

* Fix

* Fix

* Fix

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Timon 2026-03-19 03:51:26 +01:00 committed by GitHub
parent 7f6571ee52
commit 2e842cb425
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 18 deletions

View File

@ -114,7 +114,7 @@ pub fn start() {
match exit_reason {
app::ExitReason::Restart | app::ExitReason::UiAccelerationFailure => {
tracing::error!("Restarting application");
tracing::info!("Restarting application");
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
#[cfg(target_family = "unix")]
let _ = std::os::unix::process::CommandExt::exec(&mut command);

View File

@ -37,5 +37,7 @@ pub enum DialogMessage {
},
RequestNewDocumentDialog,
RequestPreferencesDialog,
RequestConfirmRestartDialog,
RequestConfirmRestartDialog {
preferences_requiring_restart: Vec<String>,
},
}

View File

@ -136,11 +136,9 @@ impl MessageHandler<DialogMessage, DialogMessageContext<'_>> for DialogMessageHa
self.on_dismiss = Some(PreferencesDialogMessage::Confirm.into());
self.preferences_dialog.send_dialog_to_frontend(responses, preferences);
}
DialogMessage::RequestConfirmRestartDialog => {
DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart } => {
self.on_dismiss = Some(DialogMessage::Close.into());
let dialog = ConfirmRestartDialog {
changed_settings: vec!["Disable UI Acceleration".into()],
};
let dialog = ConfirmRestartDialog { preferences_requiring_restart };
dialog.send_dialog_to_frontend(responses);
}
}

View File

@ -28,9 +28,10 @@ impl MessageHandler<PreferencesDialogMessage, PreferencesDialogMessageContext<'_
}
PreferencesDialogMessage::Confirm => {
if let Some(unmodified_preferences) = &self.unmodified_preferences
&& unmodified_preferences.needs_restart(preferences)
&& let preferences_requiring_restart = unmodified_preferences.preferences_requiring_restart(preferences)
&& !preferences_requiring_restart.is_empty()
{
responses.add(DialogMessage::RequestConfirmRestartDialog);
responses.add(DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart });
} else {
responses.add(DialogMessage::Close);
}

View File

@ -3,7 +3,7 @@ use crate::messages::prelude::*;
/// A dialog for confirming the restart of the application when changing a preference that requires a restart to take effect.
pub struct ConfirmRestartDialog {
pub changed_settings: Vec<String>,
pub preferences_requiring_restart: Vec<String>,
}
impl DialogLayoutHolder for ConfirmRestartDialog {
@ -30,7 +30,7 @@ impl DialogLayoutHolder for ConfirmRestartDialog {
impl LayoutHolder for ConfirmRestartDialog {
fn layout(&self) -> Layout {
let changed_settings = "".to_string() + &self.changed_settings.join("\n");
let changed_settings = "".to_string() + &self.preferences_requiring_restart.join("\n");
Layout(vec![
LayoutGroup::row(vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()]),

View File

@ -28,14 +28,16 @@ pub struct PreferencesMessageHandler {
}
impl PreferencesMessageHandler {
#[cfg(not(target_os = "macos"))]
pub fn needs_restart(&self, other: &Self) -> bool {
self.disable_ui_acceleration != other.disable_ui_acceleration
pub fn preferences_requiring_restart(&self, other: &Self) -> Vec<String> {
let mut requiring_restart = Vec::new();
if self.disable_ui_acceleration != other.disable_ui_acceleration {
requiring_restart.push("Disable UI Acceleration");
}
#[cfg(target_os = "macos")]
pub fn needs_restart(&self, other: &Self) -> bool {
self.disable_ui_acceleration != other.disable_ui_acceleration || self.vsync != other.vsync
if self.vsync != other.vsync {
requiring_restart.push("Enable V-Sync");
}
requiring_restart.into_iter().map(String::from).collect()
}
pub fn get_selection_mode(&self) -> SelectionMode {