fix high CPU usage under wxgtk2 #260

When using GTK2, call DrawArea(dc) instead of GetWindow()->Refresh(),
this prevents glib from using huge amounts of CPU (as discovered by
@retro-wertz .)

Switching video drivers sometimes crashes the app, the DrawArea() call
is as safe as possible, the problem is elsewhere.
This commit is contained in:
Rafael Kitover 2018-06-18 10:11:14 -07:00
parent d160321811
commit 89228b0697
1 changed files with 13 additions and 1 deletions

View File

@ -1816,8 +1816,20 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
}
}
// next, draw the frame (queue a PaintEv)
// next, draw the frame (queue a PaintEv) Refresh must be used under
// Wayland or nothing is drawn, however it causes high CPU usage with GTK2,
// so use the old method in that case
#ifdef __WXGTK3__
GetWindow()->Refresh();
#else
{
DrawingPanelBase* panel = wxGetApp().frame->GetPanel()->panel;
if (panel) {
wxClientDC dc(panel->GetWindow());
panel->DrawArea(dc);
}
}
#endif
// finally, draw on-screen text using wx method, if possible
// this method flickers too much right now