Ticket #12704 (closed defect: fixed)

Opened 3 years ago

Last modified 7 months ago

Some flickering in wxStyledTextCtrl with syntax highlighting in wxGTK.

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

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

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

Change History

Changed 3 years ago by ruslanch

  Changed 3 years ago by ruslanch

  • milestone set to 2.9.2

follow-up: ↓ 3   Changed 3 years ago by vadz

  • milestone 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?

in reply to: ↑ 2   Changed 3 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.

  Changed 3 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.

  Changed 7 months 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!

  Changed 7 months 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

  Changed 7 months ago by VZ

  • status changed from new to closed
  • resolution set to fixed

(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.