mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
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:
parent
cb70a7f6a7
commit
3705f08bad
1 changed files with 6 additions and 10 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue