+#pragma mark -
+#pragma mark Mouse handling
+
+- (void)mouseDown:(NSEvent *)o_event
+{
+ @synchronized (self) {
+ if (vd) {
+ if ([o_event type] == NSLeftMouseDown && !([o_event modifierFlags] & NSControlKeyMask)) {
+ if ([o_event clickCount] <= 1)
+ vout_display_SendEventMousePressed (vd, MOUSE_BUTTON_LEFT);
+ }
+ }
+ }
+
+ [super mouseDown:o_event];
+}
+
+- (void)otherMouseDown:(NSEvent *)o_event
+{
+ @synchronized (self) {
+ if (vd)
+ vout_display_SendEventMousePressed (vd, MOUSE_BUTTON_CENTER);
+ }
+
+ [super otherMouseDown: o_event];
+}
+
+- (void)mouseUp:(NSEvent *)o_event
+{
+ @synchronized (self) {
+ if (vd) {
+ if ([o_event type] == NSLeftMouseUp)
+ vout_display_SendEventMouseReleased (vd, MOUSE_BUTTON_LEFT);
+ }
+ }
+
+ [super mouseUp: o_event];
+}
+
+- (void)otherMouseUp:(NSEvent *)o_event
+{
+ @synchronized (self) {
+ if (vd)
+ vout_display_SendEventMouseReleased (vd, MOUSE_BUTTON_CENTER);
+ }
+
+ [super otherMouseUp: o_event];
+}
+
+- (void)mouseMoved:(NSEvent *)o_event
+{
+ /* on HiDPI displays, the point bounds don't equal the actual pixel based bounds */
+ NSPoint ml = [self convertPoint: [o_event locationInWindow] fromView: nil];
+ NSRect videoRect = [self bounds];
+ BOOL b_inside = [self mouse: ml inRect: videoRect];
+
+ if (OSX_LION) {
+ ml = [self convertPointToBacking: ml];
+ videoRect = [self convertRectToBacking: videoRect];
+ }
+
+ if (b_inside) {
+ @synchronized (self) {
+ if (vd) {
+ vout_display_SendMouseMovedDisplayCoordinates(vd, ORIENT_NORMAL,
+ (int)ml.x, videoRect.size.height - (int)ml.y,
+ &vd->sys->place);
+ }
+ }
+ }
+
+ [super mouseMoved: o_event];
+}
+
+- (void)mouseDragged:(NSEvent *)o_event
+{
+ [self mouseMoved: o_event];
+ [super mouseDragged: o_event];
+}
+
+- (void)otherMouseDragged:(NSEvent *)o_event
+{
+ [self mouseMoved: o_event];
+ [super otherMouseDragged: o_event];
+}
+
+- (void)rightMouseDragged:(NSEvent *)o_event
+{
+ [self mouseMoved: o_event];
+ [super rightMouseDragged: o_event];
+}
+
+- (BOOL)acceptsFirstResponder