aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorAntonio Ospite <ao2@ao2.it>2014-09-26 00:44:17 +0200
committerLuca Barbato <lu_zero@gentoo.org>2014-10-04 23:46:46 +0200
commit2a5ac99e6e06078713f684fee2466c91f677b303 (patch)
treef5c5d5d877962cecee78612ab0ab260ac2d645e0 /libavdevice
parent5b9c817dc7577b6d44acc94d73b9c77c52cda489 (diff)
downloadffmpeg-2a5ac99e6e06078713f684fee2466c91f677b303.tar.gz
x11grab: Check the XQueryPointer return value
The paint_mouse_pointer() code uses XFixes to retrieve the cursor coordinates, but XFixes gives no information about which 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. CC: libav-stable@libav.org Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/x11grab.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index 1f91be9f29..3aa4294059 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -487,8 +487,8 @@ static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
int x_off = s->x_off;
int y_off = s->y_off;
int follow_mouse = s->follow_mouse;
- int screen;
- Window root;
+ int screen, pointer_x, pointer_y, _, same_screen = 1;
+ Window w, root;
int64_t curtime, delay;
struct timespec ts;
@@ -516,14 +516,16 @@ static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
- if (follow_mouse) {
+
+ if (follow_mouse || s->draw_mouse)
+ same_screen = XQueryPointer(dpy, root, &w, &w,
+ &pointer_x, &pointer_y, &_, &_, &_);
+
+ if (follow_mouse && same_screen) {
int screen_w, screen_h;
- int pointer_x, pointer_y, _;
- Window w;
screen_w = DisplayWidth(dpy, screen);
screen_h = DisplayHeight(dpy, screen);
- XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
if (follow_mouse == -1) {
// follow the mouse, put it at center of grabbing region
x_off += pointer_x - s->width / 2 - x_off;
@@ -550,7 +552,7 @@ static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
s->y_off - REGION_WIN_BORDER);
}
- if (s->show_region) {
+ if (s->show_region && same_screen) {
if (s->region_win) {
XEvent evt = { .type = NoEventMask };
// Clean up the events, and do the initial draw or redraw.
@@ -572,7 +574,7 @@ static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
}
- if (s->draw_mouse)
+ if (s->draw_mouse && same_screen)
paint_mouse_pointer(image, s);
return s->frame_size;