Resize GameArea after MainFrame initialization

The GameArea was setting incorrect minimum size during initialization
due to the MainFrame not being entirely loaded, this caused the
MainFrame to not be resized properly on initialization. Resetting the
MainFrame minimum size after everything has been loaded fixes the issue.

This also changes MainFrame to ignore events sent before initialization
is complete, which should speed up startup a bit.

Fixes #1186
This commit is contained in:
Fabrice de Gans 2023-10-24 12:49:34 -07:00
parent 71ca0fb270
commit bf2452aab9
3 changed files with 16 additions and 0 deletions

View File

@ -2813,5 +2813,12 @@ bool MainFrame::BindControls()
panel->SetFrameTitle(); panel->SetFrameTitle();
// All OK; activate idle loop // All OK; activate idle loop
panel->SetExtraStyle(panel->GetExtraStyle() | wxWS_EX_PROCESS_IDLE); panel->SetExtraStyle(panel->GetExtraStyle() | wxWS_EX_PROCESS_IDLE);
// Re-adjust size now to nudge some sense into Widgets.
panel->AdjustSize(false);
// Frame initialization is complete.
init_complete_ = true;
return true; return true;
} }

View File

@ -930,6 +930,9 @@ void MainFrame::OnMenu(wxContextMenuEvent& event)
} }
void MainFrame::OnMove(wxMoveEvent&) { void MainFrame::OnMove(wxMoveEvent&) {
if (!init_complete_) {
return;
}
if (!IsFullScreen() && !IsMaximized()) { if (!IsFullScreen() && !IsMaximized()) {
const wxPoint window_pos = GetScreenPosition(); const wxPoint window_pos = GetScreenPosition();
OPTION(kGeomWindowX) = window_pos.x; OPTION(kGeomWindowX) = window_pos.x;
@ -954,6 +957,9 @@ void MainFrame::OnMoveEnd(wxMoveEvent&) {
void MainFrame::OnSize(wxSizeEvent& event) void MainFrame::OnSize(wxSizeEvent& event)
{ {
wxFrame::OnSize(event); wxFrame::OnSize(event);
if (!init_complete_) {
return;
}
const wxRect window_rect = GetRect(); const wxRect window_rect = GetRect();
const wxPoint window_pos = GetScreenPosition(); const wxPoint window_pos = GetScreenPosition();

View File

@ -356,6 +356,9 @@ private:
JoystickPoller* jpoll = nullptr; JoystickPoller* jpoll = nullptr;
// quicker & more accurate than FindFocus() != NULL // quicker & more accurate than FindFocus() != NULL
bool focused; bool focused;
// One-time toggle to indicate that this object is fully initialized. This
// used to filter events that are sent during initialization.
bool init_complete_ = false;
#ifndef NO_LINK #ifndef NO_LINK
const config::OptionsObserver gba_link_observer_; const config::OptionsObserver gba_link_observer_;
#endif #endif