From ea8a8af3ec096b61219588d6b8ddcb9b61ee20f1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 17 May 2013 00:36:06 +0200 Subject: [PATCH] cocoa_common: implement mouse movement notifications Notify the core of mouse movement events. The coordinates are converted to a coordinate system with the origin in upper left corner, since Cocoa has it in the lower left corner. --- video/out/cocoa_common.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 6f618c296c..9af5922cf1 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -829,6 +829,16 @@ int vo_cocoa_cgl_color_size(struct vo *vo) { if (self.videoOutput->opts->fs) vo_cocoa_display_cursor(self.videoOutput, 1); + + NSView *view = self.contentView; + NSPoint loc = [view convertPoint:[theEvent locationInWindow] fromView:nil]; + NSRect bounds = [view bounds]; + + int x = loc.x; + int y = - loc.y + bounds.size.height; // convert to x11-like coord system + if (CGRectContainsPoint(bounds, NSMakePoint(x, y))) { + vo_mouse_movement(self.videoOutput, x, y); + } } - (void)mouseDragged:(NSEvent *)theEvent