Compare commits

...

2 Commits

Author SHA1 Message Date
Fabrice de Gans
8fa2e48134 Disable open menu tracking outside of Windows
Tracking whether or not the menus are opened is necessary on Windows since menus stop
the main loop. This is not necessary on other platforms. In particular, on Mac, we do
not get a `wxEVT_MENU_CLOSE` event when opening a dialog from a shortcut, resulting in
the menu status tracking being incorrect.

Fixes #1348
2024-09-28 12:00:26 -07:00
Fabrice de Gans
ad6592e193 [dialogs] Display all controls in AccelConfig on Mac
Calling `ExpandAll()` on the `wxTreeCtrl` would cause it to display outside of its
intended view, hiding other controls. Instead, this sets a minimum size for the tree
control, so the default window size is reasonable.
2024-09-28 10:13:03 -07:00
5 changed files with 28 additions and 18 deletions

View File

@@ -46,7 +46,7 @@ if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-ggdb3 -Og -fno-omit-frame-pointer -Wall -Wextra)
add_compile_options(-ggdb3 -fno-omit-frame-pointer -Wall -Wextra)
else()
add_compile_options(-Ofast -fomit-frame-pointer)
endif()

View File

@@ -145,9 +145,11 @@ AccelConfig::AccelConfig(wxWindow* parent,
PopulateTreeWithMenu(&command_to_item_id_, tree_, id, menu->GetMenu(i), recents,
menu->GetMenuLabelText(i) + '\n');
}
tree_->ExpandAll();
tree_->SelectItem(menu_id);
// Set a minimum size for the tree so the default dialog size is reasonable.
tree_->SetMinSize(wxSize(300, 300));
int w, h;
current_keys_->GetTextExtent("CTRL-ALT-SHIFT-ENTER", &w, &h);
wxSize size(w, h);

View File

@@ -894,11 +894,15 @@ EVT_MOVE_START(MainFrame::OnMoveStart)
EVT_MOVE_END(MainFrame::OnMoveEnd)
EVT_SIZE(MainFrame::OnSize)
#if defined(__WXMSW__)
// For tracking menubar state.
EVT_MENU_OPEN(MainFrame::MenuPopped)
EVT_MENU_CLOSE(MainFrame::MenuPopped)
EVT_MENU_HIGHLIGHT_ALL(MainFrame::MenuPopped)
#endif // defined(__WXMSW__)
END_EVENT_TABLE()
void MainFrame::OnActivate(wxActivateEvent& event)
@@ -1152,8 +1156,9 @@ void MainFrame::ResetMenuAccelerators() {
ResetRecentAccelerators();
}
void MainFrame::MenuPopped(wxMenuEvent& evt)
{
#if defined(__WXMSW__)
void MainFrame::MenuPopped(wxMenuEvent& evt) {
// We consider the menu closed when the main menubar or system menu is closed, not any submenus.
// On Windows nullptr is the system menu.
if (evt.GetEventType() == wxEVT_MENU_CLOSE && (evt.GetMenu() == nullptr || evt.GetMenu()->GetMenuBar() == GetMenuBar()))
@@ -1166,18 +1171,16 @@ void MainFrame::MenuPopped(wxMenuEvent& evt)
// On Windows, opening the menubar will stop the app, but DirectSound will
// loop, so we pause audio here.
void MainFrame::SetMenusOpened(bool state)
{
void MainFrame::SetMenusOpened(bool state) {
menus_opened = state;
#ifdef __WXMSW__
if (menus_opened)
soundPause();
else if (!paused)
soundResume();
#endif
}
#endif // defined(__WXMSW__)
// ShowModal that also disables emulator loop
// uses dialog_opened as a nesting counter
int MainFrame::ShowModal(wxDialog* dlg)
@@ -1338,12 +1341,12 @@ int wxvbamApp::FilterEvent(wxEvent& event)
return wxEventFilter::Event_Skip;
}
if (!frame->CanProcessShortcuts()) {
if (event.GetEventType() != VBAM_EVT_USER_INPUT) {
// We only treat "VBAM_EVT_USER_INPUT" events here.
return wxEventFilter::Event_Skip;
}
if (event.GetEventType() != VBAM_EVT_USER_INPUT) {
// We only treat "VBAM_EVT_USER_INPUT" events here.
if (!frame->CanProcessShortcuts()) {
return wxEventFilter::Event_Skip;
}

View File

@@ -97,7 +97,7 @@ public:
bool pending_fullscreen;
#if __WXMAC__
// I suppose making this work will require tweaking the bundle
void MacOpenFile(const wxString& f)
void MacOpenFile(const wxString& f) override
{
pending_load = f;
};
@@ -219,10 +219,15 @@ public:
// possible
void StartModal();
void StopModal();
// however, adding a handler for open/close menu to do the same is unsafe.
// there is no guarantee every show will be matched by a hide.
#if defined(__WXMSW__)
// On Windows, we need to disable the audio loop when the menu is open. We also disable
// shortcuts to prevent issues. This is not necessary on other systems.
void MenuPopped(wxMenuEvent& evt);
#endif // defined(__WXMSW__)
// flags for enabling commands
int cmd_enable;

View File

@@ -2,7 +2,7 @@
<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
<object class="wxDialog" name="AccelConfig">
<title>Key Shortcuts</title>
<style>wxRESIZE_BORDER</style>
<style>wxRESIZE_BORDER|wxCLOSE_BOX</style>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<flag>wxEXPAND</flag>
@@ -56,6 +56,7 @@
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<object class="wxBoxSizer">
<object class="sizeritem">
<object class="wxButton" name="Assign">
@@ -80,7 +81,6 @@
</object>
<orient>wxVERTICAL</orient>
</object>
<flag>wxEXPAND</flag>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
@@ -98,6 +98,7 @@
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<object class="wxBoxSizer">
<object class="sizeritem">
<flag>wxALL</flag>
@@ -113,7 +114,6 @@
</object>
<orient>wxVERTICAL</orient>
</object>
<flag>wxEXPAND</flag>
</object>
</object>
</object>