summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_common.m
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2015-03-08 15:19:17 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2015-03-08 15:19:17 +0100
commit8ec9bce2d367541f9d3939f773b669beebd0be6d (patch)
treef54d271ed9d794a26f2229c3247b2575fc4c30d0 /video/out/cocoa_common.m
parentce239f1577ccd7eabccaac5b3b34fbe3959d860e (diff)
downloadmpv-8ec9bce2d367541f9d3939f773b669beebd0be6d.tar.bz2
mpv-8ec9bce2d367541f9d3939f773b669beebd0be6d.tar.xz
cocoa: fix autohide in fullscreen
Diffstat (limited to 'video/out/cocoa_common.m')
-rw-r--r--video/out/cocoa_common.m22
1 files changed, 21 insertions, 1 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index e4b0e9eca5..608e380414 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -60,6 +60,7 @@ struct vo_cocoa_state {
NSWindow *window;
NSView *view;
MpvVideoView *video;
+ MpvCocoaAdapter *adapter;
NSOpenGLContext *gl_ctx;
NSScreen *current_screen;
@@ -258,7 +259,7 @@ static int vo_cocoa_set_cursor_visibility(struct vo *vo, bool *visible)
if (*visible) {
CGDisplayShowCursor(kCGDirectMainDisplay);
- } else if ([v canHideCursor] && [s->window isKeyWindow]) {
+ } else if ([v canHideCursor]) {
CGDisplayHideCursor(kCGDirectMainDisplay);
} else {
*visible = true;
@@ -457,6 +458,7 @@ static void create_ui(struct vo *vo, struct mp_rect *win, int geo_flags)
[parent addSubview:s->view];
// update the cursor position now that the view has been added.
[view signalMousePosition];
+ s->adapter = adapter;
#if HAVE_COCOA_APPLICATION
cocoa_register_menu_item_action(MPM_H_SIZE, @selector(halfSize));
@@ -685,6 +687,13 @@ static void vo_cocoa_fullscreen(struct vo *vo)
draw_changes_after_next_frame(vo);
[(MpvEventsView *)s->view setFullScreen:opts->fullscreen];
+ if ([s->view window] != s->window) {
+ // cocoa implements fullscreen views by moving the view to a fullscreen
+ // window. Set that window delegate to the cocoa adapter to trigger
+ // calls to -windowDidResignKey: and -windowDidBecomeKey:
+ [[s->view window] setDelegate:s->adapter];
+ }
+
s->pending_events |= VO_EVENT_ICC_PROFILE_CHANGED;
s->pending_events |= VO_EVENT_RESIZE;
}
@@ -853,4 +862,15 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
struct vo_cocoa_state *s = self.vout->cocoa;
[(MpvEventsView *)s->view signalMousePosition];
}
+
+- (void)windowDidResignKey:(NSNotification *)notification
+{
+ [self didChangeMousePosition];
+}
+
+- (void)windowDidBecomeKey:(NSNotification *)notification
+{
+ [self didChangeMousePosition];
+}
+
@end