x11_grab: Let __imlib_Grab..() return error instead of ok
This commit is contained in:
parent
9657d6a291
commit
f54961f0cd
|
@ -295,6 +295,7 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
|
|||
int height, char need_to_grab_x)
|
||||
{
|
||||
ImlibImage *im;
|
||||
int err;
|
||||
char domask = 0;
|
||||
|
||||
if (mask)
|
||||
|
@ -308,10 +309,12 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
|
|||
if (!im)
|
||||
return NULL;
|
||||
|
||||
if (!__imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctx->display,
|
||||
ctx->drawable, mask, ctx->visual,
|
||||
ctx->colormap, ctx->depth, x, y, width,
|
||||
height, &domask, need_to_grab_x))
|
||||
err = __imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height,
|
||||
ctx->display, ctx->drawable, mask,
|
||||
ctx->visual, ctx->colormap, ctx->depth,
|
||||
x, y, width, height,
|
||||
&domask, need_to_grab_x);
|
||||
if (err)
|
||||
{
|
||||
__imlib_FreeImage(im);
|
||||
return NULL;
|
||||
|
@ -346,6 +349,7 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int src_x, int src_y,
|
|||
char get_mask_from_shape)
|
||||
{
|
||||
ImlibImage *im;
|
||||
int err;
|
||||
char domask;
|
||||
|
||||
if (!IMAGE_DIMENSIONS_OK(src_width, src_height))
|
||||
|
@ -357,11 +361,13 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int src_x, int src_y,
|
|||
|
||||
domask = mask != 0 || get_mask_from_shape;
|
||||
|
||||
if (!__imlib_GrabDrawableScaledToRGBA(im->data, 0, 0, dst_width, dst_height,
|
||||
ctx->display, ctx->drawable, mask,
|
||||
ctx->visual, ctx->colormap, ctx->depth,
|
||||
src_x, src_y, src_width, src_height,
|
||||
&domask, need_to_grab_x))
|
||||
err = __imlib_GrabDrawableScaledToRGBA(im->data, 0, 0, dst_width, dst_height,
|
||||
ctx->display, ctx->drawable, mask,
|
||||
ctx->visual, ctx->colormap,
|
||||
ctx->depth,
|
||||
src_x, src_y, src_width, src_height,
|
||||
&domask, need_to_grab_x);
|
||||
if (err)
|
||||
{
|
||||
__imlib_FreeImage(im);
|
||||
return NULL;
|
||||
|
@ -433,11 +439,11 @@ imlib_copy_drawable_to_image(Pixmap mask, int src_x, int src_y, int src_width,
|
|||
if ((src_width <= 0) || (src_height <= 0))
|
||||
return 0;
|
||||
__imlib_DirtyImage(im);
|
||||
return __imlib_GrabDrawableToRGBA(im->data, dst_x, dst_y, im->w, im->h,
|
||||
ctx->display, ctx->drawable, mask,
|
||||
ctx->visual, ctx->colormap, ctx->depth,
|
||||
src_x, src_y, src_width, src_height,
|
||||
&domask, need_to_grab_x);
|
||||
return !__imlib_GrabDrawableToRGBA(im->data, dst_x, dst_y, im->w, im->h,
|
||||
ctx->display, ctx->drawable, mask,
|
||||
ctx->visual, ctx->colormap, ctx->depth,
|
||||
src_x, src_y, src_width, src_height,
|
||||
&domask, need_to_grab_x);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
|
@ -635,11 +635,7 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
|
|||
src_w = xatt.width;
|
||||
src_h = xatt.height;
|
||||
if ((xatt.map_state != IsViewable) && (xatt.backing_store == NotUseful))
|
||||
{
|
||||
if (grab)
|
||||
XUngrabServer(d);
|
||||
return 0;
|
||||
}
|
||||
goto bail;
|
||||
}
|
||||
|
||||
/* clip to the drawable tree and screen */
|
||||
|
@ -691,11 +687,7 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
|
|||
}
|
||||
|
||||
if ((width <= 0) || (height <= 0))
|
||||
{
|
||||
if (grab)
|
||||
XUngrabServer(d);
|
||||
return 0;
|
||||
}
|
||||
goto bail;
|
||||
|
||||
w_src = width;
|
||||
h_src = height;
|
||||
|
@ -712,11 +704,7 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
|
|||
if (!xim)
|
||||
xim = XGetImage(d, p, x_src, y_src, w_src, h_src, 0xffffffff, ZPixmap);
|
||||
if (!xim)
|
||||
{
|
||||
if (grab)
|
||||
XUngrabServer(d);
|
||||
return 0;
|
||||
}
|
||||
goto bail;
|
||||
|
||||
mxim = NULL;
|
||||
if ((m) && (domask))
|
||||
|
@ -806,6 +794,11 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
|
|||
*pdomask = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
bail:
|
||||
if (grab)
|
||||
XUngrabServer(d);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
if (blend && im->has_alpha)
|
||||
{
|
||||
back = malloc(dw * dh * sizeof(uint32_t));
|
||||
if (!__imlib_GrabDrawableToRGBA
|
||||
if (__imlib_GrabDrawableToRGBA
|
||||
(back, 0, 0, dw, dh, d, w, 0, v, cm, depth, dx, dy, dw, dh, 0, 1))
|
||||
{
|
||||
free(back);
|
||||
|
|
Loading…
Reference in New Issue