summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2016-01-04 12:46:45 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2016-04-23 19:55:22 +0200
commit31a80aa1d4c7c5a2f6dc6965aed404326b362d02 (patch)
tree2ce5e03692e100d73eb220ac5b8a5e32a743d218
parentb1a8e8dba66fb9c85e3a1d4e812d4f842db68fe6 (diff)
downloadmpv-native-fs.tar.bz2
mpv-native-fs.tar.xz
cocoa: reimplement --fs-mission-control and make it defaultnative-fs
-rw-r--r--options/options.c3
-rw-r--r--options/options.h1
-rw-r--r--video/out/cocoa/window.h6
-rw-r--r--video/out/cocoa/window.m50
-rw-r--r--video/out/cocoa_common.m28
5 files changed, 76 insertions, 12 deletions
diff --git a/options/options.c b/options/options.c
index 1ae48a6fc2..a8048d3f35 100644
--- a/options/options.c
+++ b/options/options.c
@@ -474,6 +474,9 @@ const m_option_t mp_opts[] = {
({"all", -2}, {"current", -1})),
OPT_FLAG("fs-black-out-screens", vo.fs_black_out_screens, 0),
+#if HAVE_COCOA
+ OPT_FLAG("fs-mission-control", vo.fs_mission_control, 0, OPTDEF_INT(1)),
+#endif
OPT_INTRANGE("brightness", gamma_brightness, 0, -100, 100),
OPT_INTRANGE("saturation", gamma_saturation, 0, -100, 100),
OPT_INTRANGE("contrast", gamma_contrast, 0, -100, 100),
diff --git a/options/options.h b/options/options.h
index 95268cd522..800c28f7ec 100644
--- a/options/options.h
+++ b/options/options.h
@@ -17,6 +17,7 @@ typedef struct mp_vo_opts {
int screen_id;
int fsscreen_id;
int fs_black_out_screens;
+ int fs_mission_control;
char *winname;
int x11_netwm;
int x11_bypass_compositor;
diff --git a/video/out/cocoa/window.h b/video/out/cocoa/window.h
index 485831a932..56fd657a55 100644
--- a/video/out/cocoa/window.h
+++ b/video/out/cocoa/window.h
@@ -22,7 +22,11 @@
- (void)queueNewVideoSize:(NSSize)newSize;
@end
-@interface MpvVideoWindow : NSWindow <NSWindowDelegate, MpvSizing>
+@protocol MpvFullScreen
+- (void)setFullScreen:(BOOL)willBeFullscreen;
+@end
+
+@interface MpvVideoWindow : NSWindow <NSWindowDelegate, MpvSizing, MpvFullScreen>
@property(nonatomic, retain) MpvCocoaAdapter *adapter;
- (BOOL)canBecomeKeyWindow;
- (BOOL)canBecomeMainWindow;
diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m
index 646281df79..b9373c9b6e 100644
--- a/video/out/cocoa/window.m
+++ b/video/out/cocoa/window.m
@@ -32,6 +32,8 @@
@implementation MpvVideoWindow {
NSSize _queued_video_size;
+ NSRect _unfs_frame;
+ BOOL _isFs;
}
@synthesize adapter = _adapter;
@@ -50,6 +52,54 @@
return self;
}
+- (void)setFullScreen:(BOOL)willBeFullscreen {
+ [self setCollectionBehavior:(NSWindowCollectionBehaviorFullScreenPrimary)];
+
+ if (willBeFullscreen != _isFs) {
+ [self toggleFullScreen:nil];
+ }
+}
+
+- (void)toggleFullScreen:(id)sender {
+ _isFs = !_isFs;
+ [super toggleFullScreen:sender];
+}
+
+- (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)size {
+ return window.screen.frame.size;
+}
+
+- (NSApplicationPresentationOptions)window:(NSWindow *)window
+ willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)opts {
+ return NSApplicationPresentationFullScreen |
+ NSApplicationPresentationAutoHideDock |
+ NSApplicationPresentationAutoHideMenuBar |
+ NSApplicationPresentationAutoHideToolbar;
+}
+
+- (NSArray *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window {
+ return @[self];
+}
+
+- (NSArray*)customWindowsToExitFullScreenForWindow:(NSWindow*)window {
+ return @[self];
+}
+
+- (void)window:window startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration
+{
+ [window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
+ _unfs_frame = [window frame];
+ NSScreen *screen = [window screen];
+ NSRect screenFrame = [screen frame];
+ [window setFrame:screenFrame display:YES];
+}
+
+- (void)window:window startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration
+{
+ [window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
+ [window setFrame:_unfs_frame display:YES];
+}
+
- (void)windowDidChangeBackingProperties:(NSNotification *)notification
{
// XXX: we maybe only need expose for this
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 30b832da75..42512275e6 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -739,18 +739,24 @@ static int vo_cocoa_fullscreen(struct vo *vo)
vo_cocoa_update_screen_info(vo, NULL);
- 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];
- }
+ if (opts->fs_mission_control) {
+ [(MpvVideoWindow *)s->window setFullScreen:opts->fullscreen];
+ // for whatever reason sometimes cocoa doesn't create an up event on
+ // the fullscreen input key
+ cocoa_put_key(MP_INPUT_RELEASE_ALL);
+ } else {
+ draw_changes_after_next_frame(vo);
- flag_events(vo, VO_EVENT_ICC_PROFILE_CHANGED);
- resize_event(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];
+ }
+ }
return VO_TRUE;
}