why. the region field of gdkeventexpose allows you to redraw less than the traditional gdkeventregion.area. in gtk+ 1.x, the gdkeventexpose structure only had an area field to let you determine the region that you needed to redraw. in gtk+ 2.x, this field exists for compatibility and as a simple interface. however, there is also a region field which contains a fine-grained region. the area field is simply the bounding rectangle of the region. widgets that are very expensive to re-render, such as an image editor, may prefer to use the gdkeventexpose.region field to paint as little as possible. widgets that just use a few drawing primitives, such as labels and buttons, may prefer to use the traditional gdkeventexpose.area field for simplicity. regions have an internal representation that is accessible as a list of rectangles. to turn the gdkeventexpose.region field into such a list, use gdk_region_get_rectangles(): static gboolean my_widget_expose_event_handler (gtkwidget *widget, gdkeventexpose *event) { gdkrectangle *rects; int n_rects; int i; gdk_region_get_rectangles (event->region, &rects, &n_rects); for (i = 0; i < n_rects; i++) { /* repaint rectangle: (rects[i].x, rects[i].y), * (rects[i].width, rects[i].height) */ } g_free (rects); return false; } |