diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-10-05 05:35:22 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-05 05:42:55 +0400 |
commit | 345160a9cdf27c928c2430101513c5882e6f9fe1 (patch) | |
tree | 6cd256a054f852e8177729c2346fd955413bf34b /libavdevice | |
parent | 8e5be0fffe9fee1916bb62bc343f56eb4b6af020 (diff) | |
parent | 2a5ac99e6e06078713f684fee2466c91f677b303 (diff) |
Merge commit '2a5ac99e6e06078713f684fee2466c91f677b303'
* commit '2a5ac99e6e06078713f684fee2466c91f677b303':
x11grab: Check the XQueryPointer return value
Conflicts:
libavdevice/x11grab.c
See: 69c34a6ac986e31b5286a1d566617ec25b93e6a7
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/x11grab.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 9066ae21ad..3a833eb27f 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -410,14 +410,6 @@ 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) @@ -425,6 +417,7 @@ 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); @@ -527,8 +520,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; @@ -566,14 +559,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; @@ -600,7 +595,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. @@ -622,7 +617,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, s1); return s->frame_size; |