From 69c34a6ac986e31b5286a1d566617ec25b93e6a7 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 8 Sep 2014 13:15:19 +0200 Subject: avdevice/x11grab: fix cursor drawing in multi-screen setup 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 Signed-off-by: Michael Niedermayer --- libavdevice/x11grab.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libavdevice') 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); -- cgit v1.2.3