Re: gdk_image_get() error handling



Havoc Pennington <hp redhat com> writes:
> Gary Wong <gtw research att com> writes: 
> >   I'll file a report on bugzilla.gnome.org if that's appropriate, but
> > I wanted to check if I'm overlooking something first.  (Or to pick
> > somebody's brain if they have a better idea about how I can perform a
> > robust gdk_image_get()...)
> 
> I think it may be fixed in 1.2.9, if it is but isn'y fixed in CVS HEAD
> a bug would be good.

  Thanks very much -- you're quite right, 1.2.9 does fix it.  It
didn't occur to me that bug fixes might be applied to 1.2.x without
also being made on 1.3.x.  I've posted it as bug 52687.

  If anybody is interested, I think the way to work around my previous
rant about the broken semantics of the X GetImage protocol request is
to catch BadMatch errors (gdk_error_trap_push() will do the trick), and
if one crops up, then create a pixmap, copy the region you want from the
window to the pixmap with gdk_draw_pixmap(), and then gdk_image_get() from
the pixmap instead of the window.  This works because gdk_draw_pixmap()
uses the CopyArea request rather than GetImage (and so does not cause
BadMatch errors when the source is obscured), and because pixmaps are
never obscured as the source for gdk_image_get().  It is also possible
to determine what region of the window was obscured (if you care) by
using gdk_event_get_graphics_expose() after the gdk_draw_pixmap().

Cheers,
Gary.
-- 
  Gary Wong    Consultant, Dependable Distributed Computing, AT&T Shannon Labs
        gtw research att com            http://www.cs.arizona.edu/~gary/




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