Skip to content

Commit e0589e4

Browse files
committed
scrotGrabMousePointer: error in case of failure
if the user asks us to grab the pointer, we should either do that otherwise fail rather than continuing on. also remove a redundant comment, it should be clear that a function named XFixesGetCursorImage is indeed returning back a cursor image. ref: #272
1 parent c3bc2ba commit e0589e4

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/scrot.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,9 @@ Window scrotGetWindow(Display *display, Window window, int x, int y)
480480
void scrotGrabMousePointer(Imlib_Image image, const int xOffset,
481481
const int yOffset)
482482
{
483-
XFixesCursorImage *xcim = NULL;
484-
/* Get the X cursor and the information we want. */
485-
if ((xcim = XFixesGetCursorImage(disp)) == NULL) {
486-
warnx("Can't get the cursor from X");
487-
goto end;
488-
}
483+
XFixesCursorImage *xcim = XFixesGetCursorImage(disp);
484+
if (!xcim)
485+
errx(EXIT_FAILURE, "Can't get the cursor from X");
489486
const unsigned short width = xcim->width;
490487
const unsigned short height = xcim->height;
491488
const size_t pixcnt = (size_t)width*height;
@@ -499,10 +496,8 @@ void scrotGrabMousePointer(Imlib_Image image, const int xOffset,
499496
}
500497

501498
Imlib_Image imcursor = imlib_create_image_using_data(width, height, pixels);
502-
if (!imcursor) {
503-
warnx("Can't create cursor image");
504-
goto end;
505-
}
499+
if (!imcursor)
500+
errx(EXIT_FAILURE, "Can't create cursor image");
506501

507502
/* Overlay the cursor into `image`. */
508503
const int x = (xcim->x - xcim->xhot) - xOffset;
@@ -514,8 +509,6 @@ void scrotGrabMousePointer(Imlib_Image image, const int xOffset,
514509
height);
515510
imlib_context_set_image(imcursor);
516511
imlib_free_image();
517-
518-
end:
519512
XFree(xcim);
520513
}
521514

0 commit comments

Comments
 (0)