hopefully fix resize artifacts on game panel #138

Paint the whole GameArea (containing the emulator graphics panel) black
on size events for both the GameArea and the panel.

This will hopefully fix reports of garbage around the panel when going
full screen with the OpenGL driver on Linux.
This commit is contained in:
Rafael Kitover 2017-08-16 04:02:12 -07:00
parent 346d97a760
commit 4d7e102e26
1 changed files with 14 additions and 6 deletions

View File

@ -1024,6 +1024,7 @@ void GameArea::OnIdle(wxIdleEvent& event)
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);
this->Connect(wxEVT_SIZE, wxSizeEventHandler(GameArea::OnSize), NULL, this);
w->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
w->SetSize(wxSize(basic_width, basic_height));
@ -1234,6 +1235,15 @@ static bool process_key_press(bool down, int key, int mod, int joy = 0)
}
}
static void draw_black_background(wxWindow* win) {
wxClientDC dc(win);
wxCoord w, h;
dc.GetSize(&w, &h);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
dc.DrawRectangle(0, 0, w, h);
}
void GameArea::OnKeyDown(wxKeyEvent& ev)
{
if (process_key_press(true, ev.GetKeyCode(), ev.GetModifiers())) {
@ -1271,7 +1281,9 @@ void GameArea::EraseBackground(wxEraseEvent& ev)
void GameArea::OnSize(wxSizeEvent& ev)
{
panel->OnSize(ev);
draw_black_background(this);
if (panel)
panel->OnSize(ev);
}
void GameArea::OnSDLJoy(wxSDLJoyEvent& ev)
@ -1415,11 +1427,7 @@ void DrawingPanelBase::PaintEv(wxPaintEvent& ev)
if (!todraw) {
// since this is set for custom background, not drawing anything
// will cause garbage to be displayed, so draw a black area
wxCoord w, h;
dc.GetSize(&w, &h);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxBLACK_BRUSH);
dc.DrawRectangle(0, 0, w, h);
draw_black_background(GetWindow());
return;
}