Hello,
I wanted to add my 10 cents:
I also noticed performance problems on GTK few years ago on Linux while scrolling with the mouse.
After a long debugging sessions, I changed the following in my code:
- Never call SetStatusMessage directly from the editor, instead fire a custom event using 'AddPendingEvent' in the OnScintillaUpdateUI (EVT_SCI_UPDATEUI) event handler
so my code looks like this:
void Editor::OnScintillaUpdateUI(wxScintillaEvent &e)
{
...
//update line number
wxString message;
message << wxT("Ln ")
<< curLine+1
<< wxT(", Col ")
<< GetColumn(pos)
<< wxT(", Pos ")
<< pos;
// Always update the status bar with event, calling it directly causes performance degredation
DoSetStatusMessage(message, 1);
...
}
void Editor::DoSetStatusMessage(const wxString &msg, int col)
{
// fire custom event
wxCommandEvent e(wxEVT_UPDATE_STATUS_BAR);
e.SetEventObject(this);
e.SetString(msg);
e.SetInt(col);
wxTheApp->GetTopWindow()->GetEventHandler()->AddPendingEvent(e);
}
- Line number margin: use a hard coded line margin width, calling TextWidth is a real pain under Linux:
// Line number margin
#ifdef __WXMSW__
int pixelWidth = 4 + 5*TextWidth(wxSCI_STYLE_LINENUMBER, wxT("9"));
#else
int pixelWidth = 4 + 5*8;
#endif
// Show number margin according to settings.
SetMarginWidth(NUMBER_MARGIN_ID, options->GetDisplayLineNumbers() ? pixelWidth : 0);
- Two phase drawing, buffered drawing settings are different from one OS to another here are the settings I am using:
#if defined(__WXMAC__)
// turning off these two greatly improves performance
// on Mac
SetTwoPhaseDraw(false);
SetBufferedDraw(false);
#elif defined(__WXGTK__)
SetTwoPhaseDraw(true);
SetBufferedDraw(false);
#else // MSW
SetTwoPhaseDraw(true);
SetBufferedDraw(true);
#endif
Adding these 3 changes improved performance noticeably on GTK and Mac for me
Eran