Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


[gtk] Add call to BeginPaintRect()/EndPaintRect() before and after Event... #268

wants to merge 1 commit into from

4 participants

Atsushi Eno Lluis Sanchez Hywel Thomas Vsevolod Kukol
Atsushi Eno


This enables double buffering for user code.

Atsushi Eno atsushieno [gtk] Add call to BeginPaintRect()/EndPaintRect() before and after Ev…

This enables double buffering for user code.
Lluis Sanchez

Aren't GTK widgets already double-buffered by default?

Atsushi Eno

It is documented so, but as long as I tried with my project[*1] it didn't.


Hywel Thomas

Looking at gtk+-2.12.0, in gdkwindow.c, the comment to gdk_window_begin_paint says:-

  • When using GTK+, the widget system automatically places calls to gdk_window_begin_paint_region() and
  • gdk_window_end_paint() around emissions of the expose_event signal. That is, if you're writing an
  • expose event handler, you can assume that the exposed area in #GdkEventExpose has already been cleared
  • to the window background, is already set as the clip region, and already has a backing store.
  • Therefore in most cases, application code need not call gdk_window_begin_paint_region(). (You can disable the
  • automatic calls around expose events on a widget-by-widget basis by calling gtk_widget_set_double_buffered().)

This does seem to be the default behaviour, as far as I've experienced. How do you experience it not being the case?

Atsushi Eno

This BeginPaintRect() and EndPaintRect() fixed significant performance issue in my app mentioned above. It uses DrawingArea.

Vsevolod Kukol

I think this can be closed. If someone experiences the same problem, please open a new issue with some example Xwt based code, so it can be reproduced by others.

Vsevolod Kukol sevoku closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 1, 2013
  1. Atsushi Eno

    [gtk] Add call to BeginPaintRect()/EndPaintRect() before and after Ev…

    atsushieno authored
    This enables double buffering for user code.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 0 deletions.
  1. +2 −0  Xwt.Gtk/Xwt.GtkBackend/CanvasBackend.cs
2  Xwt.Gtk/Xwt.GtkBackend/CanvasBackend.cs
@@ -169,7 +169,9 @@ protected override bool OnExposeEvent (Gdk.EventExpose evnt)
Backend.ApplicationContext.InvokeUserCode (delegate {
using (var context = CreateContext ()) {
var a = evnt.Area;
+ evnt.Window.BeginPaintRect (new Gdk.Rectangle (a.X, a.Y, a.Width, a.Height));
EventSink.OnDraw (context, new Rectangle (a.X, a.Y, a.Width, a.Height));
+ evnt.Window.EndPaint ();
return base.OnExposeEvent (evnt);
Something went wrong with that request. Please try again.