[FFmpeg-devel] [PATCH 2/2] avdevice/x11grab: fix cursor drawing in multi-screen setup

2014-09-08 Thread Antonio Ospite
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 
---
 libavdevice/x11grab.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index 4379e1b..1481e7d 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);
 
-- 
2.1.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] avdevice/x11grab: rename the "w" Window to "root" in paint_mouse_pointer

2014-09-08 Thread Antonio Ospite
This specifies better the meaning of the variable, and is also in
preparation of a subsequent change which will introduce a temporary
Window variable for which "w" is an good name.

Signed-off-by: Antonio Ospite 
---
 libavdevice/x11grab.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index e0d1dfa..4379e1b 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -389,7 +389,7 @@ static void paint_mouse_pointer(XImage *image, 
AVFormatContext *s1)
  * Anyone who performs further investigation of the xlib API likely risks
  * permanent brain damage. */
 uint8_t *pix = image->data;
-Window w;
+Window root;
 XSetWindowAttributes attr;
 
 /* Code doesn't currently support 16-bit or PAL8 */
@@ -398,9 +398,9 @@ static void paint_mouse_pointer(XImage *image, 
AVFormatContext *s1)
 
 if (!s->c)
 s->c = XCreateFontCursor(dpy, XC_left_ptr);
-w = DefaultRootWindow(dpy);
+root = DefaultRootWindow(dpy);
 attr.cursor = s->c;
-XChangeWindowAttributes(dpy, w, CWCursor, &attr);
+XChangeWindowAttributes(dpy, root, CWCursor, &attr);
 
 xcim = XFixesGetCursorImage(dpy);
 if (!xcim) {
-- 
2.1.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 0/2] avdevice/x11grab: fix cursor drawing in multi-screen setup

2014-09-08 Thread Antonio Ospite
Hi,

with multi-screen setups x11grab does not behave in the correct way wrt.
drawing the mouse cursor, e.g. when doing:

  ffplay -f x11grab -i ":0.1"

the mouse cursor was drawn in the captured video even when the mouse
pointer was on :0.0.

The following patches fix the issue.

Patch 1 is just a preparatory change which has also the effect to
minimize the delta with the version of patch 2 I am sending to libav.

Patch 2 has the actual fix I came up with, look there for a detailed
description of the issue.

I can provide further info about how to replicate the issue with
a virtual screen using the xserver-xorg-video-dummy driver if anybody is
interested.

Thanks,
   Antonio

Antonio Ospite (2):
  avdevice/x11grab: rename the "w" Window to "root" in
paint_mouse_pointer
  avdevice/x11grab: fix cursor drawing in multi-screen setup

 libavdevice/x11grab.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 0/2] avdevice/x11grab: fix cursor drawing in multi-screen setup

2014-09-09 Thread Antonio Ospite
On Tue, 9 Sep 2014 05:32:36 +0200
Michael Niedermayer  wrote:

> On Mon, Sep 08, 2014 at 01:15:17PM +0200, Antonio Ospite wrote:
> > Hi,
> > 
> > with multi-screen setups x11grab does not behave in the correct way wrt.
> > drawing the mouse cursor, e.g. when doing:
> > 
> >   ffplay -f x11grab -i ":0.1"
> > 
> > the mouse cursor was drawn in the captured video even when the mouse
> > pointer was on :0.0.
> > 
> > The following patches fix the issue.
> > 
> > Patch 1 is just a preparatory change which has also the effect to
> > minimize the delta with the version of patch 2 I am sending to libav.
> > 
> > Patch 2 has the actual fix I came up with, look there for a detailed
> > description of the issue.
> > 
> > I can provide further info about how to replicate the issue with
> > a virtual screen using the xserver-xorg-video-dummy driver if anybody is
> > interested.
> > 
> > Thanks,
> >Antonio
> > 
> > Antonio Ospite (2):
> >   avdevice/x11grab: rename the "w" Window to "root" in
> > paint_mouse_pointer
> >   avdevice/x11grab: fix cursor drawing in multi-screen setup
> > 
> >  libavdevice/x11grab.c | 13 ++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> patchset applied
> 
> Thanks
> 

Thanks Michael.

>From a discussion on libav-devel[1] it came out that the follow_mouse
option is broken too in multi-screen setups.

I will submit a patch for that too.

Regards,
   Antonio

[1]
https://lists.libav.org/pipermail/libav-devel/2014-September/063068.html

-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel