Skip to content
Permalink
Browse files

fix starting game pos and geometry #406

Fix display when loading ROMs with custom geometry.

This issue was a combination of `wxSHAPED` and its effect on the custom
geometry. It is necessary to force a dummy resize so the display adjusts
itself.

Align game frame on center, both horizontal and vertical.
  • Loading branch information
denisfa authored and rkitover committed Apr 9, 2019
1 parent 2beb561 commit 2ae72f38cd073a6c52154a11ee866cdddc289f3c
Showing with 9 additions and 6 deletions.
  1. +4 −2 src/wx/panel.cpp
  2. +5 −4 src/wx/wxvbam.cpp
@@ -1046,16 +1046,18 @@ void GameArea::OnIdle(wxIdleEvent& event)
// On windows with the vcpkg version of wxWidgets which is 3.1.2, the
// wxEXPAND flag throws an XRC error, but it is necessary on earlier versions of wxWidgets
#if defined(__WXMSW__) && wxCHECK_VERSION(3, 1, 2)
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL) : wxEXPAND);
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER) : wxEXPAND);
#else
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL | wxEXPAND) : wxEXPAND);
GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER | wxEXPAND) : wxEXPAND);
#endif

#if wxCHECK_VERSION(2, 9, 0)
GetSizer()->Add(0, 0, 1, wxEXPAND);
#endif

Layout();
SendSizeEvent();


if (pointer_blanked)
w->SetCursor(wxCursor(wxCURSOR_BLANK));
@@ -763,22 +763,23 @@ void MainFrame::OnMenu(wxContextMenuEvent& event)
void MainFrame::OnMove(wxMoveEvent& event)
{
(void)event; // unused params
wxRect pos = GetRect();
int x = pos.GetX(), y = pos.GetY();
wxPoint pos = GetScreenPosition();
int x = pos.x, y = pos.y;
if (x >= 0 && y >= 0 && !IsFullScreen())
{
windowPositionX = x;
windowPositionY = y;
update_opts();
}
update_opts();
}

void MainFrame::OnSize(wxSizeEvent& event)
{
wxFrame::OnSize(event);
wxRect pos = GetRect();
wxPoint windowPos = GetScreenPosition();
int height = pos.GetHeight(), width = pos.GetWidth();
int x = pos.GetX(), y = pos.GetY();
int x = windowPos.x, y = windowPos.y;
bool isFullscreen = IsFullScreen();
if (height > 0 && width > 0 && !isFullscreen)
{

0 comments on commit 2ae72f3

Please sign in to comment.
You can’t perform that action at this time.