diff options
author | Andoni Morales Alastruey <ylatuya@gmail.com> | 2012-05-16 21:12:22 +0200 |
---|---|---|
committer | Alessandro Decina <alessandro.decina@collabora.co.uk> | 2012-05-23 11:43:32 +0200 |
commit | b0e664ca7bac61f62378fcb434561fc60bf57f2b (patch) | |
tree | ddb0899140727b1a553ee6a22cf921e9d463ac49 /sys | |
parent | 31d6828cd1e82de1b4aa1e21ae5f8dccc35575d6 (diff) | |
download | gstreamer-plugins-good-b0e664ca7bac61f62378fcb434561fc60bf57f2b.tar.gz |
osxvideosink: fix navigation when force-aspect-ratio is activated
Diffstat (limited to 'sys')
-rw-r--r-- | sys/osxvideo/cocoawindow.h | 2 | ||||
-rw-r--r-- | sys/osxvideo/cocoawindow.m | 24 | ||||
-rw-r--r-- | sys/osxvideo/osxvideosink.m | 23 |
3 files changed, 25 insertions, 24 deletions
diff --git a/sys/osxvideo/cocoawindow.h b/sys/osxvideo/cocoawindow.h index 049bb5f9e..d811cb6fd 100644 --- a/sys/osxvideo/cocoawindow.h +++ b/sys/osxvideo/cocoawindow.h @@ -48,6 +48,7 @@ struct _GstOSXImage; NSOpenGLContext* actualContext; NSTrackingArea *trackingArea; GstNavigation *navigation; + NSRect drawingBounds; } - (void) drawQuad; - (void) drawRect: (NSRect) rect; @@ -61,6 +62,7 @@ struct _GstOSXImage; - (void) setKeepAspectRatio: (BOOL) flag; - (void) reshape; - (void) setVideoSize: (int) w: (int) h; +- (NSRect) getDrawingBounds; - (BOOL) haveSuperview; - (void) haveSuperviewReal: (NSMutableArray *)closure; - (void) addToSuperview: (NSView *)superview; diff --git a/sys/osxvideo/cocoawindow.m b/sys/osxvideo/cocoawindow.m index b41b20d0d..2e9398356 100644 --- a/sys/osxvideo/cocoawindow.m +++ b/sys/osxvideo/cocoawindow.m @@ -126,6 +126,7 @@ data = nil; width = frame.size.width; height = frame.size.height; + drawingBounds = NSMakeRect(0, 0, width, height); GST_LOG ("Width: %d Height: %d", width, height); @@ -140,6 +141,10 @@ return self; } +- (NSRect) getDrawingBounds { + return drawingBounds; +} + - (void) reshape { NSRect bounds; gdouble frame_par, view_par; @@ -180,6 +185,7 @@ c_y = (view_height - c_height) / 2; } + drawingBounds = NSMakeRect(c_x, c_y, c_width, c_height); glViewport (c_x, c_y, (GLint) c_width, (GLint) c_height); } @@ -475,9 +481,7 @@ - (void)sendMouseEvent:(NSEvent *)event: (const char *)event_name { NSPoint location; - NSRect bounds; gint button; - gint view_width, view_height; gdouble x, y; if (!navigation) @@ -502,19 +506,13 @@ location = [self convertPoint:[event locationInWindow] fromView:nil]; - /* scale X and Y locations to the frame size */ - bounds = [self bounds]; - view_width = bounds.size.width; - view_height = bounds.size.height; - - x = ((gdouble) location.x / view_width) * width; - y = ((gdouble) location.y / view_height) * height; - + x = location.x; + y = location.y; /* invert Y */ - y = (1 - y / height) * height; - gst_navigation_send_mouse_event (navigation, event_name, button, - x, y); + y = (1 - ((gdouble) y) / [self bounds].size.height) * [self bounds].size.height; + + gst_navigation_send_mouse_event (navigation, event_name, button, x, y); } - (void)sendKeyEvent:(NSEvent *)event: (const char *)event_name diff --git a/sys/osxvideo/osxvideosink.m b/sys/osxvideo/osxvideosink.m index aa1b30016..f68a522b5 100644 --- a/sys/osxvideo/osxvideosink.m +++ b/sys/osxvideo/osxvideosink.m @@ -590,6 +590,7 @@ gst_osx_video_sink_navigation_send_event (GstNavigation * navigation, GstPad *peer; GstEvent *event; GstVideoRectangle src, dst, result; + NSRect bounds; gdouble x, y, xscale = 1.0, yscale = 1.0; peer = gst_pad_get_peer (GST_VIDEO_SINK_PAD (osxvideosink)); @@ -599,24 +600,24 @@ gst_osx_video_sink_navigation_send_event (GstNavigation * navigation, event = gst_event_new_navigation (structure); - /* FIXME: Use this when this sink is capable of keeping the display - * aspect ratio */ - if (0) { //(osxvideosink->keep_aspect) { + bounds = [osxvideosink->osxwindow->gstview getDrawingBounds]; + + if (osxvideosink->keep_par) { /* We get the frame position using the calculated geometry from _setcaps that respect pixel aspect ratios */ src.w = GST_VIDEO_SINK_WIDTH (osxvideosink); src.h = GST_VIDEO_SINK_HEIGHT (osxvideosink); - //dst.w = osxvideosink->osxwindow->gstview->width; - //dst.w = osxvideosink->osxwindow->gstview->height; + dst.w = bounds.size.width; + dst.h = bounds.size.height; gst_video_sink_center_rect (src, dst, &result, TRUE); - //result.x += osxvideosink->gstview->x; - //result.y += osxvideosink->gstview->y; + result.x += bounds.origin.x; + result.y += bounds.origin.y; } else { - result.x = 0; - result.y = 0; - result.w = osxvideosink->osxwindow->width; - result.h = osxvideosink->osxwindow->height; + result.x = bounds.origin.x; + result.y = bounds.origin.y; + result.w = bounds.size.width; + result.h = bounds.size.height; } /* We calculate scaling using the original video frames geometry to include |