Opened 4 years ago

Closed 2 years ago

#12704 closed defect (fixed)

Some flickering in wxStyledTextCtrl with syntax highlighting in wxGTK.

Reported by: ruslanch Owned by:
Priority: normal Milestone: 2.9.5
Component: wxStyledText Version: stable-latest
Keywords: flickering Cc:
Blocked By: Blocking:
Patch: yes

Description

I have some flickering in wxStyledTextCtrl with syntax highlighting in wxGTK. To avoid this problem is enough to use wxBufferedPaintDC in wxPaintEvent handler:

void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
#ifdef __WXGTK__
    wxBufferedPaintDC dc(this);
#else
    wxPaintDC dc(this);
#endif
    m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
}

Attachments (1)

stc.patch download (1.3 KB) - added by ruslanch 4 years ago.

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by ruslanch

comment:1 Changed 4 years ago by ruslanch

  • Milestone set to 2.9.2

comment:2 follow-up: Changed 4 years ago by vadz

  • Milestone 2.9.2 deleted

Very strange, GTK+ 2.0 is supposed to perform its own double buffering (as most of the other modern systems, i.e. OS X and Windows since Vista). Does anybody know if STC do something to deactivate GTK+ double buffering by chance?

comment:3 in reply to: ↑ 2 Changed 4 years ago by robind

Replying to vadz:

Does anybody know if STC do something to deactivate GTK+ double buffering by chance?

It doesn't. wxSTC is all fairly generic wx code at the bottom level.

comment:4 Changed 4 years ago by ruslanch

I have not dug far, but if you comment out:

    style | = wxVSCROLL | wxHSCROLL;

in wxStyledTextCtrl::Create, the problem disappears. But will not work scrollbars.

comment:5 Changed 2 years ago by arondobos

  • Milestone set to 2.9.5

I am also encountering very significant flickering on wxGTK2 using the current SVN ( r72947 ). It happens as I am typing, even on a line without any syntax highlighting (lexer is turned on). I experience the same behavior on Fedora 16 and Slackware 14, using a similarly configured wxWidgets:

./configure --prefix=/usr/local/wx3-svn --enable-stl --enable-shared=no --enable-debug=no --with-libjpeg=builtin --with-libpng=builtin --with-zlib=builtin --with-expat=builtin --with-libtiff=builtin --disable-precomp-headers

I tried many things, including wxWindow::SetDoubleBuffered(true) (forcibly enables gtk2 double buffering), and wxStyledTextCtrl::SetBufferedDraw(true), but neither was sufficient. The only thing I tried that worked to eliminate flickering during typing was the patch suggested above by ruslanch.

I hope this patch can be integrated, or an alternate resolution resolved. I have spent quite some time tracking through the wxStyledTextCtrl and scintilla code, and cannot clearly define the cause of the flickering problem... I do not see this behavior on MSW or OSX-Cocoa.

Thank you!

comment:6 Changed 2 years ago by jens

We use the wxBufferedPaintDC in the wxScintilla we use for Code::Blocks since 3 years, because we also received bug-reports about the flickering.

As far as I can see, there are no drawbacks.

The patch was provided by Eran Ifrah the developer of CodeLite.

Jens

comment:7 Changed 2 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73001]) Use wxBufferedPaintDC for wxStyledTextCtrl drawing in wxGTK.

GTK+ doesn't seem to use double buffering for Scintilla window for some
reason, resulting in bad flicker when it's updated, e.g. when the user types
into it.

Force the use of double buffering at wxWidgets level by using
wxBufferedPaintDC for painting it. This may be inefficient if GTK+ does double
buffer it in some cases but at least it gets rid of the flicker.

Closes #12704, #14828.

Note: See TracTickets for help on using tickets.