Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

4 participants

Atsushi Eno Lluis Sanchez Hywel Thomas Vsevolod Kukol
Atsushi Eno
Collaborator

...Sink.OnDraw().

This enables double buffering for user code.

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

This enables double buffering for user code.
9ba8726
Lluis Sanchez
Owner

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

Atsushi Eno
Collaborator

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

[*1] https://github.com/atsushieno/xmdsp

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
Collaborator

This BeginPaintRect() and EndPaintRect() https://github.com/atsushieno/xmdsp/blob/gtk-sharp/Xmdsp/View.Xwt/KeyboardList.cs#L90 fixed significant performance issue in my app mentioned above. It uses DrawingArea.

Vsevolod Kukol
Collaborator

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
    …entSink.OnDraw().
    
    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
View
@@ -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.