From 247e584fe07b9cc3a2070612179f79816e6214c5 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Tue, 4 Apr 2017 13:30:56 -0700 Subject: [PATCH] better fix for clipped video in GL fullscreen #89 In d1918c12 I manually sent a SIZE event to the DrawingPanel after calling Layout() in the setup code in OnIdle(). But the obvious problem is that the ->Connect() calls to set up the event handlers, including SIZE, are after all the setup code including the Layout(). Move the ->Connect() calls to the top of the setup code and remove the manual SIZE event sending. This is a much better solution that for some reason I didn't notice at the time. Tested to also fix the problem. --- src/wx/panel.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index b7565d98..a7cfdbb3 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1014,6 +1014,16 @@ void GameArea::OnIdle(wxIdleEvent& event) } wxWindow* w = panel->GetWindow(); + + // set up event handlers + // use both CHAR_HOOK and KEY_DOWN in case CHAR_HOOK does not work for whatever reason + w->Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(GameArea::OnKeyDown), NULL, this); + w->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(GameArea::OnKeyDown), NULL, this); + w->Connect(wxEVT_KEY_UP, wxKeyEventHandler(GameArea::OnKeyUp), NULL, this); + w->Connect(wxEVT_PAINT, wxPaintEventHandler(GameArea::PaintEv), NULL, this); + w->Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(GameArea::EraseBackground), NULL, this); + w->Connect(wxEVT_SIZE, wxSizeEventHandler(GameArea::OnSize), NULL, this); + w->SetBackgroundStyle(wxBG_STYLE_CUSTOM); w->SetSize(wxSize(basic_width, basic_height)); @@ -1027,24 +1037,12 @@ void GameArea::OnIdle(wxIdleEvent& event) 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 w->SetFocus(); - - // set up event handlers - // use both CHAR_HOOK and KEY_DOWN in case CHAR_HOOK does not work for whatever reason - w->Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(GameArea::OnKeyDown), NULL, this); - w->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(GameArea::OnKeyDown), NULL, this); - w->Connect(wxEVT_KEY_UP, wxKeyEventHandler(GameArea::OnKeyUp), NULL, this); - w->Connect(wxEVT_PAINT, wxPaintEventHandler(GameArea::PaintEv), NULL, this); - w->Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(GameArea::EraseBackground), NULL, this); - w->Connect(wxEVT_SIZE, wxSizeEventHandler(GameArea::OnSize), NULL, this); } if (!paused) {