NSOpenGLContext* actualContext;
NSTrackingArea *trackingArea;
GstNavigation *navigation;
+ NSRect drawingBounds;
}
- (void) drawQuad;
- (void) drawRect: (NSRect) rect;
- (void) setKeepAspectRatio: (BOOL) flag;
- (void) reshape;
- (void) setVideoSize: (int) w: (int) h;
+- (NSRect) getDrawingBounds;
- (BOOL) haveSuperview;
- (void) haveSuperviewReal: (NSMutableArray *)closure;
- (void) addToSuperview: (NSView *)superview;
data = nil;
width = frame.size.width;
height = frame.size.height;
+ drawingBounds = NSMakeRect(0, 0, width, height);
GST_LOG ("Width: %d Height: %d", width, height);
return self;
}
+- (NSRect) getDrawingBounds {
+ return drawingBounds;
+}
+
- (void) reshape {
NSRect bounds;
gdouble frame_par, view_par;
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);
}
- (void)sendMouseEvent:(NSEvent *)event: (const char *)event_name
{
NSPoint location;
- NSRect bounds;
gint button;
- gint view_width, view_height;
gdouble x, y;
if (!navigation)
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
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));
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