ximagesrc: Fix drawing the cursor when it is outside the capturing region

When the cursor is partially or totally out of the capturing region on
the top side or on the left side, it gets drawn fully inside of the
region with its coordinates rounded up to the left or to the top border.

This is immediately noticeable when using the xid property to capture
a specific window.

To fix the issue, allow negative cx and cx coordinates when checking the
boundaries before drawing the cursor.

NOTE that the boundaries checking calculations still allows the cursor
to be drawn when it is only partially outside of the capturing region,
but this makes sense and gives a more pleasing visual behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=690646
This commit is contained in:
Antonio Ospite 2014-09-05 11:33:31 +02:00 committed by Sebastian Dröge
parent cb70a7f6a7
commit 3705f08bad

View file

@ -714,31 +714,27 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
cx = ximagesrc->cursor_image->x - ximagesrc->cursor_image->xhot -
ximagesrc->x;
if (cx < 0)
cx = 0;
cy = ximagesrc->cursor_image->y - ximagesrc->cursor_image->yhot -
ximagesrc->y;
if (cy < 0)
cy = 0;
count = ximagesrc->cursor_image->width * ximagesrc->cursor_image->height;
/* only get where cursor last was, if it is in our range */
if (ximagesrc->endx > ximagesrc->startx &&
ximagesrc->endy > ximagesrc->starty) {
/* check bounds */
if (cx + ximagesrc->cursor_image->width < ximagesrc->startx ||
cx > ximagesrc->endx) {
if (cx + ximagesrc->cursor_image->width < (int) ximagesrc->startx ||
cx > (int) ximagesrc->endx) {
/* trivial reject */
cursor_in_image = FALSE;
} else if (cy + ximagesrc->cursor_image->height < ximagesrc->starty ||
cy > ximagesrc->endy) {
} else if (cy + ximagesrc->cursor_image->height <
(int) ximagesrc->starty || cy > (int) ximagesrc->endy) {
/* trivial reject */
cursor_in_image = FALSE;
} else {
/* find intersect region */
startx = (cx < ximagesrc->startx) ? ximagesrc->startx : cx;
starty = (cy < ximagesrc->starty) ? ximagesrc->starty : cy;
startx = (cx < (int) ximagesrc->startx) ? ximagesrc->startx : cx;
starty = (cy < (int) ximagesrc->starty) ? ximagesrc->starty : cy;
iwidth = (cx + ximagesrc->cursor_image->width < ximagesrc->endx) ?
cx + ximagesrc->cursor_image->width - startx :
ximagesrc->endx - startx;