fix clipped game area in GL fullscreen #89

Trigger OnSize in the drawing panel after setting the geometry and
calling Layout(). I'm not sure what exactly broke but this seems to fix
the issue for the time being.

Also do a bit of very minor refactoring, change some calls to GetSize()
to GetClientSize() and simplify GLDrawingPanel::OnSize(ev&), tested to
work fine in wx 2.8.
This commit is contained in:
Rafael Kitover 2017-02-28 17:16:46 -08:00
parent fa1e13e606
commit d1918c12f4
1 changed files with 22 additions and 22 deletions

View File

@ -747,7 +747,7 @@ void GameArea::AdjustSize(bool force)
(std::ceil(basic_height * gopts.video_scale) / hidpi_scale_factor)); (std::ceil(basic_height * gopts.video_scale) / hidpi_scale_factor));
if (!force) { if (!force) {
wxSize sz = GetSize(); wxSize sz = GetClientSize();
if (sz.GetWidth() >= newsz.GetWidth() && sz.GetHeight() >= newsz.GetHeight()) if (sz.GetWidth() >= newsz.GetWidth() && sz.GetHeight() >= newsz.GetHeight())
return; return;
@ -768,10 +768,6 @@ void GameArea::ShowFullScreen(bool full)
return; return;
} }
// Some kbd accels can send a menu open event without a close event,
// this happens on Mac in HiDPI mode for the fullscreen toggle accel.
main_frame->SetMenusOpened(false);
// on Mac maximize is native fullscreen, so ignore fullscreen requests // on Mac maximize is native fullscreen, so ignore fullscreen requests
#ifdef __WXMAC__ #ifdef __WXMAC__
if (full && main_frame->IsMaximized()) return; if (full && main_frame->IsMaximized()) return;
@ -816,6 +812,10 @@ void GameArea::ShowFullScreen(bool full)
while (!tlw->popups.empty()) while (!tlw->popups.empty())
tlw->popups.front()->Close(); tlw->popups.front()->Close();
// Some kbd accels can send a menu open event without a close event,
// this happens on Mac in HiDPI mode for the fullscreen toggle accel.
main_frame->SetMenusOpened(false);
// mouse stays blank whenever full-screen // mouse stays blank whenever full-screen
HidePointer(); HidePointer();
cursz_valid = true; cursz_valid = true;
@ -1013,16 +1013,19 @@ void GameArea::OnIdle(wxIdleEvent& event)
w->SetMaxSize(wxSize(basic_width * maxScale, w->SetMaxSize(wxSize(basic_width * maxScale,
basic_height * maxScale)); basic_height * maxScale));
GetSizer()->Add(w, 1, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER) : wxEXPAND);
Layout();
if (pointer_blanked)
w->SetCursor(wxCursor(wxCURSOR_BLANK));
// if user changed Display/Scale config, this needs to run // if user changed Display/Scale config, this needs to run
AdjustMinSize(); AdjustMinSize();
AdjustSize(false); AdjustSize(false);
GetSizer()->Add(w, 1, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER) : wxEXPAND);
Layout();
// this is necessary for GL + fullscreen, why I have no clue
wxSizeEvent size_ev = wxSizeEvent(w->GetClientSize());
panel->OnSize(size_ev);
if (pointer_blanked)
w->SetCursor(wxCursor(wxCURSOR_BLANK));
// set focus to panel // set focus to panel
w->SetFocus(); w->SetFocus();
@ -1388,7 +1391,7 @@ DrawingPanelBase::DrawingPanelBase(int _width, int _height)
DrawingPanel::DrawingPanel(wxWindow* parent, int _width, int _height) DrawingPanel::DrawingPanel(wxWindow* parent, int _width, int _height)
: DrawingPanelBase(_width, _height) : DrawingPanelBase(_width, _height)
, wxPanel(parent, wxID_ANY, wxPoint(0, 0), parent->GetSize(), , wxPanel(parent, wxID_ANY, wxPoint(0, 0), parent->GetClientSize(),
wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS) wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS)
{ {
} }
@ -2008,7 +2011,7 @@ static int glopts[] = {
GLDrawingPanel::GLDrawingPanel(wxWindow* parent, int _width, int _height) GLDrawingPanel::GLDrawingPanel(wxWindow* parent, int _width, int _height)
: DrawingPanelBase(_width, _height) : DrawingPanelBase(_width, _height)
, wxglc(parent, wxID_ANY, glopts, wxPoint(0, 0), parent->GetSize(), , wxglc(parent, wxID_ANY, glopts, wxPoint(0, 0), parent->GetClientSize(),
wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS) wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS)
{ {
RequestHighResolutionOpenGLSurface(); RequestHighResolutionOpenGLSurface();
@ -2132,22 +2135,19 @@ void GLDrawingPanel::DrawingPanelInit()
void GLDrawingPanel::OnSize(wxSizeEvent& ev) void GLDrawingPanel::OnSize(wxSizeEvent& ev)
{ {
#ifndef wxGL_IMPLICIT_CONTEXT
SetCurrent(*ctx);
#else
SetCurrent();
#endif
SetSize(ev.GetSize());
AdjustViewport(); AdjustViewport();
Center();
ev.Skip(true); ev.Skip(true);
} }
void GLDrawingPanel::AdjustViewport() void GLDrawingPanel::AdjustViewport()
{ {
#ifndef wxGL_IMPLICIT_CONTEXT
SetCurrent(*ctx);
#else
SetCurrent();
#endif
int x, y; int x, y;
GetRealPixelClientSize(&x, &y); GetRealPixelClientSize(&x, &y);
glViewport(0, 0, x, y); glViewport(0, 0, x, y);