0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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.
This commit is contained in:
Stefano Pigozzi 2013-05-17 00:36:06 +02:00 committed by wm4
parent 8fe357380e
commit ea8a8af3ec

View File

@ -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