cocoa: fix autohide in fullscreen

(cherry picked from commit 8ec9bce2d3)
This commit is contained in:
Stefano Pigozzi
2015-03-11 12:49:39 +09:00
committed by Diogo Franco (Kovensky)
parent 0e160123fd
commit 46cc45223c
4 changed files with 26 additions and 5 deletions
+2 -1
View File
@@ -166,7 +166,8 @@
- (BOOL)canHideCursor
{
return !self.hasMouseDown && [self containsMouseLocation];
return !self.hasMouseDown && [self containsMouseLocation]
&& [[self window] isKeyWindow];
}
- (void)mouseEntered:(NSEvent *)event
+1 -1
View File
@@ -18,7 +18,7 @@
#import <Cocoa/Cocoa.h>
#include "video/out/vo.h"
@interface MpvCocoaAdapter : NSObject
@interface MpvCocoaAdapter : NSObject<NSWindowDelegate>
- (void)setNeedsResize;
- (void)signalMouseMovement:(NSPoint)point;
- (void)putKeyEvent:(NSEvent*)event;
+2 -2
View File
@@ -63,12 +63,12 @@
- (void)windowDidResignKey:(NSNotification *)notification
{
[self.adapter didChangeMousePosition];
[self.adapter windowDidResignKey:notification];
}
- (void)windowDidBecomeKey:(NSNotification *)notification
{
[self.adapter didChangeMousePosition];
[self.adapter windowDidBecomeKey:notification];
}
- (BOOL)canBecomeMainWindow { return YES; }
+21 -1
View File
@@ -58,6 +58,7 @@ struct vo_cocoa_state {
NSWindow *window;
NSView *view;
MpvVideoView *video;
MpvCocoaAdapter *adapter;
NSOpenGLContext *gl_ctx;
NSScreen *current_screen;
@@ -169,7 +170,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;
@@ -367,6 +368,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));
@@ -595,6 +597,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;
}
@@ -758,4 +767,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