summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-09-02 08:21:03 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-09-02 08:21:03 +0200
commit694654e38368c2f33be2c8e3be2f3b8ab3dcfa77 (patch)
treea08179f2d537518b607b1f043a34050eb71e38d0
parent04caddb7c84a9a8fd4a454766405830233d6c413 (diff)
downloadmpv-694654e38368c2f33be2c8e3be2f3b8ab3dcfa77.tar.bz2
mpv-694654e38368c2f33be2c8e3be2f3b8ab3dcfa77.tar.xz
cocoa_common: avoid the opengl view to leak it's state
Just because everything is in a single file it doesn't excuse us to have high coupling between C and ObjC code.
-rw-r--r--video/out/cocoa_common.m20
1 files changed, 13 insertions, 7 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 289c158b01..edf683b049 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -50,12 +50,13 @@
@property(nonatomic, assign) struct vo *videoOutput;
@end
-@interface GLMPlayerOpenGLView : NSView
+@interface GLMPlayerOpenGLView : NSView {
+ BOOL hasMouseDown;
+}
@property(nonatomic, retain) NSTrackingArea *tracker;
@property(nonatomic, assign) struct vo *videoOutput;
-- (BOOL)containsMouseLocation;
+- (BOOL)canHideCursor;
- (void)recalcDraggableState;
-@property(nonatomic, assign, getter=hasMouseDown) BOOL mouseDown;
@end
@interface NSScreen (mpvadditions)
@@ -169,8 +170,7 @@ static void vo_cocoa_set_cursor_visibility(struct vo *vo, bool visible)
if (visible) {
CGDisplayShowCursor(kCGDirectMainDisplay);
- } else if (vo->opts->fullscreen && ![s->view hasMouseDown] &&
- [s->view containsMouseLocation]) {
+ } else if ([s->view canHideCursor]) {
CGDisplayHideCursor(kCGDirectMainDisplay);
}
}
@@ -782,7 +782,6 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
@implementation GLMPlayerOpenGLView
@synthesize tracker = _tracker;
@synthesize videoOutput = _video_output;
-@synthesize mouseDown = _mouse_down;
// mpv uses flipped coordinates, because X11 uses those. So let's just use them
// as well without having to do any coordinate conversion of mouse positions.
- (BOOL)isFlipped { return YES; }
@@ -827,6 +826,13 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
- (BOOL)becomeFirstResponder { return YES; }
- (BOOL)resignFirstResponder { return YES; }
+- (BOOL)canHideCursor
+{
+ struct vo *vo = self.videoOutput;
+ return vo->opts->fullscreen && !self->hasMouseDown &&
+ [self containsMouseLocation];
+}
+
- (void)recalcDraggableState
{
struct vo *vo = self.videoOutput;
@@ -908,7 +914,7 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
- (void)putMouseEvent:(NSEvent *)event withState:(int)state
{
- self.mouseDown = (state == MP_KEY_STATE_DOWN);
+ self->hasMouseDown = (state == MP_KEY_STATE_DOWN);
int mp_key = (MP_MOUSE_BTN0 + [event mpvButtonNumber]);
cocoa_put_key_with_modifiers(mp_key | state, [event modifierFlags]);
}