This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit f54961f0cd5ab4f9b43db0eb12a30431a3d9234c
Author: Kim Woelders <[email protected]>
AuthorDate: Fri Feb 17 16:14:36 2023 +0100

    x11_grab: Let __imlib_Grab..() return error instead of ok
---
 src/lib/api_x11.c  | 34 ++++++++++++++++++++--------------
 src/lib/x11_grab.c | 23 ++++++++---------------
 src/lib/x11_rend.c |  2 +-
 3 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/src/lib/api_x11.c b/src/lib/api_x11.c
index 61561c4..4e4c957 100644
--- a/src/lib/api_x11.c
+++ b/src/lib/api_x11.c
@@ -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
diff --git a/src/lib/x11_grab.c b/src/lib/x11_grab.c
index eab7eea..f535fe4 100644
--- a/src/lib/x11_grab.c
+++ b/src/lib/x11_grab.c
@@ -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;
 }
 
diff --git a/src/lib/x11_rend.c b/src/lib/x11_rend.c
index e1fd58e..d19feb9 100644
--- a/src/lib/x11_rend.c
+++ b/src/lib/x11_rend.c
@@ -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);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to