Re: GDK_EXPOSE




slogan@crash.cts.com (Syd Logan) writes:

> I think there might be a bug in how GDK_EXPOSE events are generated.
> 
> In X11, an expose event is sent if some portion of a window was exposed as
> in need of redraw by a client.
> 
> An X11 GraphicsExpose event is very different. This will occur when the
> CopyArea or CopyPlane X protocol has been performed and the destination of
> the CopyArea or CopyPlane could not be drawn completely because some 
> portion of the source was obscured or unmapped, making the bits
> unavailable.
>
> Here's the code in Gdk that takes the raw X event and synthesizes the 
> GDK_EXPOSE events. Notice that the only diffs are the GDK_NOTE and that
> the event structure fields come from different places.

It is a little complicated to explain why GTK+ does this, but it
isn't a bug.

Almost always when you care about GraphicsExpose events, it is
because you are moving bits around on the screen with an XCopyArea.

If the original bits aren't there (because the window is obscured)
than one wants to redraw the target area, just as if it got
exposed normally.

So, to make things simpler on the developer, GTK+ simply converts
the GraphicsExpose events into Expose events.

Now, there are some pitfalls with this:

 - When scrolling with XCopyAreas, you have to be careful so
   you don't copy out of bounds, and thus get spurious exposes.

 - If you accidentally copy out of bounds from (say) a pixmap
   with a GC with GraphicExposes set than you can get yourself
   into big trouble with loops of expose/redraw.

   To prevent this, GDK's gcs default to not generating
   graphics exposes.

Coordinates and timing can also be a tricky issue - this is
the reason for gdk_event_get_graphics_expose() - you don't want
to scroll again until you handle the GraphicsExpose events
from the first time... so this event is used to search events
until you get the last GraphicsExpose or the NoExpose.

testgtk has an example of it's use.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]