summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Ospite <ao2@ao2.it>2014-09-05 00:15:30 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-09-16 10:32:22 +0300
commitcb70a7f6a7dfded16981edd9a67ad25969d0ba34 (patch)
treee5c5550d6c1cebf54ea87c2841a52951981034bf
parentd3eea8f606b240f9cc0cea2a7c2e32d488666754 (diff)
ximagesrc: Fix the destination coordinates of the cursor
XFixes provides the cursor coordinates relative to the root window, this is not taken into account when using the xid property to capture a specific window, the result is that the cursor gets drawn at the wrong position. In order to fix this consider the window location when calculating the cursor position in the destination image. https://bugzilla.gnome.org/show_bug.cgi?id=690646
-rw-r--r--sys/ximage/gstximagesrc.c30
-rw-r--r--sys/ximage/gstximagesrc.h2
2 files changed, 26 insertions, 6 deletions
diff --git a/sys/ximage/gstximagesrc.c b/sys/ximage/gstximagesrc.c
index 8058a953b..e8b276b14 100644
--- a/sys/ximage/gstximagesrc.c
+++ b/sys/ximage/gstximagesrc.c
@@ -169,6 +169,9 @@ gst_ximage_src_open_display (GstXImageSrc * s, const gchar * name)
int status;
XWindowAttributes attrs;
Window window;
+ int x, y;
+ Window child;
+ Bool coord_translated;
if (s->xid != 0) {
status = XGetWindowAttributes (s->xcontext->disp, s->xid, &attrs);
@@ -205,8 +208,19 @@ gst_ximage_src_open_display (GstXImageSrc * s, const gchar * name)
g_assert (s->xwindow != 0);
s->width = attrs.width;
s->height = attrs.height;
- GST_INFO_OBJECT (s, "Using default window size of %dx%d",
- s->width, s->height);
+
+ coord_translated = XTranslateCoordinates (s->xcontext->disp, s->xwindow,
+ s->xcontext->root, 0, 0, &x, &y, &child);
+ if (coord_translated) {
+ s->x = x;
+ s->y = y;
+ } else {
+ s->x = 0;
+ s->y = 0;
+ }
+
+ GST_INFO_OBJECT (s, "Using default window size of %dx%d at location %d,%d",
+ s->width, s->height, s->x, s->y);
}
use_root_window:
@@ -601,8 +615,10 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
if (ximagesrc->cursor_image) {
gint x, y, width, height;
- x = ximagesrc->cursor_image->x - ximagesrc->cursor_image->xhot;
- y = ximagesrc->cursor_image->y - ximagesrc->cursor_image->yhot;
+ x = ximagesrc->cursor_image->x - ximagesrc->cursor_image->xhot -
+ ximagesrc->x;
+ y = ximagesrc->cursor_image->y - ximagesrc->cursor_image->yhot -
+ ximagesrc->y;
width = ximagesrc->cursor_image->width;
height = ximagesrc->cursor_image->height;
@@ -696,10 +712,12 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
int startx, starty, iwidth, iheight;
gboolean cursor_in_image = TRUE;
- cx = ximagesrc->cursor_image->x - ximagesrc->cursor_image->xhot;
+ 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;
+ 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;
diff --git a/sys/ximage/gstximagesrc.h b/sys/ximage/gstximagesrc.h
index 76506bffc..efaff750a 100644
--- a/sys/ximage/gstximagesrc.h
+++ b/sys/ximage/gstximagesrc.h
@@ -49,6 +49,8 @@ struct _GstXImageSrc
/* Information on display */
GstXContext *xcontext;
+ gint x;
+ gint y;
gint width;
gint height;