diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 4379e1b1cd..1481e7d871 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -391,6 +391,14 @@ static void paint_mouse_pointer(XImage *image, AVFormatContext *s1) uint8_t *pix = image->data; Window root; XSetWindowAttributes attr; + Bool pointer_on_screen; + Window w; + int _; + + root = DefaultRootWindow(dpy); + pointer_on_screen = XQueryPointer(dpy, root, &w, &w, &_, &_, &_, &_, &_); + if (!pointer_on_screen) + return; /* Code doesn't currently support 16-bit or PAL8 */ if (image->bits_per_pixel != 24 && image->bits_per_pixel != 32) @@ -398,7 +406,6 @@ static void paint_mouse_pointer(XImage *image, AVFormatContext *s1) if (!s->c) s->c = XCreateFontCursor(dpy, XC_left_ptr); - root = DefaultRootWindow(dpy); attr.cursor = s->c; XChangeWindowAttributes(dpy, root, CWCursor, &attr);