mirror of
https://github.com/storytold/craft-launcher.git
synced 2026-11-16 23:24:31 +00:00
Handle Command+M in the macOS launcher window (#350)
Co-authored-by: skylar taylor-barrick <hi@skylar.cc>
This commit is contained in:
1 parent
82bbae4536
commit
c99e375a67
2 files changed
+22
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user