From c99e375a67cba194d386b3e87316d173fbc76343 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 17 Oct 2026 23:05:46 +0200 Subject: [PATCH] Handle Command+M in the macOS launcher window (#350) Co-authored-by: skylar taylor-barrick --- crates/ui-egui/src/app.rs | 3 +++ crates/ui-egui/tests/ui.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index b124da32..2a5e389e 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -552,6 +552,9 @@ impl LauncherUi { /// Draws the launcher. pub fn ui(&mut self, ui: &mut egui::Ui, host: &mut dyn Host) { let ctx = ui.ctx().clone(); + if host.title_bar() == TitleBar::MacOs && ctx.input_mut(|i| i.consume_key(egui::Modifiers::MAC_CMD, egui::Key::M)) { + ctx.send_viewport_cmd(egui::ViewportCommand::Minimized(true)); + } // Set the current language for this frame based on settings. let lang = effective_lang(&self.settings.language); set_current(lang); diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index a93fc8b2..05e2e857 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -1745,6 +1745,25 @@ fn changelog_shortcuts_zoom_only_the_notes_text() { assert!(h.ctx.zoom_factor() > global, "main-UI keyboard zoom should still work after closing notes"); } +#[test] +fn command_m_minimizes_the_mac_window_only() { + use artcraft_launcher_ui_egui::TitleBar; + for bar in [TitleBar::MacOs, TitleBar::Native, TitleBar::Custom] { + let (mut h, _) = harness_with_title_bar(events(), ViewMode::Grid, egui::Theme::Dark, true, 1.0, bar); + h.run_steps(4); + h.input_mut().events.push(egui::Event::Key { + key: egui::Key::M, + physical_key: None, + pressed: true, + repeat: false, + modifiers: egui::Modifiers::MAC_CMD, + }); + h.step(); + let minimized = h.output().viewport_output.values().any(|v| v.commands.iter().any(|c| matches!(c, egui::ViewportCommand::Minimized(true)))); + assert_eq!(minimized, bar == TitleBar::MacOs, "{bar:?}"); + } +} + #[test] fn an_occupied_folder_asks_before_replacing_it() { let path = "/Volumes/Craft Apps/PhotoCraft.app";