From a18080501c5ddfdc19cd92d59bb97303972f76ed Mon Sep 17 00:00:00 2001 From: Alex Tang Date: Mon, 13 May 2024 15:06:58 -0700 Subject: [PATCH] Prevent Cmd-Shift-M from minimizing on EXCEPT on "Home" sub-screen The problem is that hitting "Cmd-Shift-M" on mac always minimizes the app, even though it should only minimize on "Cmd-M", and not on "Cmd-Shift-M". The code that minimizes (using the WXWidgets "Iconize()" call) happens in MainFrame.cpp keyboard event loop. The code that's checking, looks for "Cmd-M" but does not check for any other keyboard modifiers, so I added a check to ignore the event if Shift is pressed along with "Cmd-M". There's a secondary issue that isn't really relevant to this bug in that the app will still minimize when pressing "Cmd-Shift-M", but ONLY on the "Home" sub-screen. (all other sub-screens work as they should). I'm not sure why, but when the "Home" sub-screen is selected, the keyboard event loop (MainFrame.cpp, line 609), is called TWICE when "Cmd-Shift-" is pressed: * Once where the event's wxKeyModifier (retrieved via `evt.GetModifiers()` is set to `wxMOD_CONTROL` AND `wxMOD_SHIFT`. (this is correct) * Once where the event's wxKeyModifier is **ONLY** set to `wxMOD_CONTROL` (this is wrong). Again, this double-event (with the wrong modifiers) only happens when the user is on the "Home" sub-screen. For the context of this bug the 3DConnexion preferences dialog isn't needed on the "Home" sub-screen so this secondary bug doesn't matter. But it does make the UX odd where Cmd-Shift-M will minimize the app when the user is viewing the "Home" sub-screen, but not minimize the app when the user is viewing any other sub-screen. --- src/slic3r/GUI/KBShortcutsDialog.cpp | 7 ++++++- src/slic3r/GUI/MainFrame.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 9ae00a78f..d3b2b04ef 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -195,8 +195,13 @@ void KBShortcutsDialog::fill_shortcuts() #else { ctrl + "P", L("Preferences") }, #endif - //3D control + //3D control, for Apple, use Cmd-Shift-M instead of Ctrl/Cmd-M due + #ifndef __APPLE__ + { ctrl + "Shift+M", L("Show/Hide 3Dconnexion devices settings dialog") }, + #else { ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") }, + #endif + // Switch table page #ifndef __APPLE__ { ctrl + "Tab", L("Switch tab page")}, diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index c5a3a147f..752bf6134 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -611,7 +611,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_ if (evt.CmdDown() && (evt.GetKeyCode() == 'H')) { //call parent_menu hide behavior return;} - if (evt.CmdDown() && (evt.GetKeyCode() == 'M')) { + if (evt.CmdDown() && !evt.ShiftDown() && (evt.GetKeyCode() == 'M')) { this->Iconize(); return; }