Improve handling of errors when calling CompositeNameWindowPixmap

To guard against CompositeNameWindowPixmap failing, just use an
error trap. Previous code used:

 GrabServer/GetWindowAttributes/CompositeNameWindowPixmap/UngrabServer

To prevent BadMatch errors from !viewable, but didn't check the
return value of GetWindowAttributes and didn't check if an error
occured during the error trap. This way is more correct and more
efficient.

http://bugzilla.gnome.org/show_bug.cgi?id=580023
This commit is contained in:
Owen W. Taylor 2008-11-22 10:27:00 -05:00 committed by Owen W. Taylor
parent 626912a9a4
commit 63b1d6642c

View File

@ -1474,23 +1474,22 @@ repair_win (MutterWindow *cw)
if (priv->back_pixmap == None)
{
gint pxm_width, pxm_height;
XWindowAttributes attr;
meta_error_trap_push (display);
XGrabServer (xdisplay);
priv->back_pixmap = XCompositeNameWindowPixmap (xdisplay, xwindow);
XGetWindowAttributes (xdisplay, xwindow, &attr);
if (attr.map_state == IsViewable)
priv->back_pixmap = XCompositeNameWindowPixmap (xdisplay, xwindow);
else
{
priv->back_pixmap = None;
}
XUngrabServer (xdisplay);
meta_error_trap_pop (display, FALSE);
if (meta_error_trap_pop_with_return (display, FALSE) != Success)
{
/* Probably a BadMatch if the window isn't viewable; we could
* GrabServer/GetWindowAttributes/NameWindowPixmap/UngrabServer/Sync
* to avoid this, but there's no reason to take two round trips
* when one will do. (We need that Sync if we want to handle failures
* for any reason other than !viewable. That's unlikely, but maybe
* we'll BadAlloc or something.)
*/
priv->back_pixmap = None;
}
if (priv->back_pixmap == None)
{