The code uses XFixes to retrieve the cursor coordinates, but XFixes gives no information of what screen the pointer is on; this results in always drawing the cursor on the captured screen even if the mouse pointer was on another screen.
For example, when capturing from screen 1 (i.e. -f x11grab -i ":0.1") the cursor was being drawn in the captured image even when the mouse pointer was actually on screen 0, which is wrong and visually confusing. Use XQueryPointer to check that the pointer is actually on the screen which is being captured. Signed-off-by: Antonio Ospite <[email protected]> --- Hi, I also sent a smiliar fix to ffmpeg-devel: https://ffmpeg.org/pipermail/ffmpeg-devel/2014-September/162685.html Ciao, Antonio libavdevice/x11grab.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 03fd567..3e3e4d2 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -367,6 +367,15 @@ static void paint_mouse_pointer(XImage *image, X11GrabContext *s) * Anyone who performs further investigation of the xlib API likely risks * permanent brain damage. */ uint8_t *pix = image->data; + Window root; + 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) -- 2.1.0 _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
