summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJulien Moutte <julien@moutte.net>2005-11-22 10:09:54 +0000
committerJulien Moutte <julien@moutte.net>2005-11-22 10:09:54 +0000
commit24cc7d9c1a55279e9d395fa39fa277bcbb7534dc (patch)
tree35e8eaa05ada5b63c02305f58ad2bf6003f80a67 /sys
parent629092a79a3c07a5e75087599d63e70c7fd27e47 (diff)
sys/xvimage/xvimagesink.c: Handle navigation events correcly with borders if applicable.
Original commit message from CVS: 2005-11-22 Julien MOUTTE <julien@moutte.net> * sys/xvimage/xvimagesink.c: (gst_xvimagesink_navigation_send_event): Handle navigation events correcly with borders if applicable.
Diffstat (limited to 'sys')
-rw-r--r--sys/xvimage/xvimagesink.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c
index 2a004414..8313bd76 100644
--- a/sys/xvimage/xvimagesink.c
+++ b/sys/xvimage/xvimagesink.c
@@ -1751,22 +1751,47 @@ gst_xvimagesink_navigation_send_event (GstNavigation * navigation,
if ((peer = gst_pad_get_peer (GST_VIDEO_SINK_PAD (xvimagesink)))) {
GstEvent *event;
+ GstVideoRectangle src, dst, result;
gdouble x, y, xscale = 1.0, yscale = 1.0;
- event = gst_event_new_custom (GST_EVENT_NAVIGATION, structure);
+ event = gst_event_new_navigation (structure);
- if (xvimagesink->xwindow) {
- xscale = GST_VIDEO_SINK_WIDTH (xvimagesink) / xvimagesink->xwindow->width;
- yscale =
- GST_VIDEO_SINK_HEIGHT (xvimagesink) / xvimagesink->xwindow->height;
+ /* We take the flow_lock while we look at the window */
+ g_mutex_lock (xvimagesink->flow_lock);
+
+ if (!xvimagesink->xwindow) {
+ g_mutex_unlock (xvimagesink->flow_lock);
+ return;
+ }
+
+ src.w = GST_VIDEO_SINK_WIDTH (xvimagesink);
+ src.h = GST_VIDEO_SINK_HEIGHT (xvimagesink);
+ dst.w = xvimagesink->xwindow->width;
+ dst.h = xvimagesink->xwindow->height;
+
+ g_mutex_unlock (xvimagesink->flow_lock);
+
+ if (xvimagesink->keep_aspect) {
+ gst_video_sink_center_rect (src, dst, &result, TRUE);
+ } else {
+ result.x = result.y = 0;
+ result.w = dst.w;
+ result.h = dst.h;
}
+ xscale = (gdouble) GST_VIDEO_SINK_WIDTH (xvimagesink) / result.w;
+ yscale = (gdouble) GST_VIDEO_SINK_HEIGHT (xvimagesink) / result.h;
+
/* Converting pointer coordinates to the non scaled geometry */
if (gst_structure_get_double (structure, "pointer_x", &x)) {
+ x = MIN (x, result.x + result.w);
+ x = MAX (x - result.x, 0);
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
(gdouble) x * xscale, NULL);
}
if (gst_structure_get_double (structure, "pointer_y", &y)) {
+ y = MIN (y, result.y + result.h);
+ y = MAX (y - result.y, 0);
gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
(gdouble) y * yscale, NULL);
}