summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-11 00:22:23 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-12 15:27:54 +0200
commit74c15ec696036a00fbd55398e758cc128f5aefea (patch)
treeb9e162070a517f70ab599edcdef99b5a1e3ba9fa
parent6a14dd593fe9cd14bbb9fa86a1f77944d12a8275 (diff)
downloadmpv-74c15ec696036a00fbd55398e758cc128f5aefea.tar.bz2
mpv-74c15ec696036a00fbd55398e758cc128f5aefea.tar.xz
cocoa_common: add native OSX fullscreen support
This adds Mission Control fullscreen functionality to mpv. Since this doesn't play well with many of mpv's features disable it by default. Users can activate this feature by using `--native-fs` when starting mpv. Fixes #34
-rw-r--r--DOCS/man/en/options.rst7
-rw-r--r--core/cfg-mplayer.h4
-rw-r--r--core/options.h2
-rw-r--r--video/out/cocoa_common.m59
4 files changed, 52 insertions, 20 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 3a98ca9c93..035f3ed28e 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -712,6 +712,13 @@
``--fstype=fullscreen``
Fixes fullscreen switching on OpenBox 1.x.
+--native-fs
+ (OS X only)
+ Use OSX's Mission Control's fullscreen feature instead of the custom one
+ provided by mpv. This can potentially break a lot of stuff like
+ ``--geometry`` and is disabled by default. On the other hand it provides
+ a more 'OS X-like' user exeprience.
+
--gamma=<-100-100>
Adjust the gamma of the video signal (default: 0). Not supported by all
video output drivers.
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index f2e90d07d2..5b30e387c3 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -611,6 +611,10 @@ const m_option_t mplayer_opts[]={
OPT_CHOICE_OR_INT("fs-screen", vo.fsscreen_id, 0, 0, 32,
({"all", -2}, {"current", -1})),
+#ifdef CONFIG_COCOA
+ OPT_FLAG("native-fs", vo.native_fs, 0),
+#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/core/options.h b/core/options.h
index 276745492d..9905397f0e 100644
--- a/core/options.h
+++ b/core/options.h
@@ -41,6 +41,8 @@ typedef struct mp_vo_opts {
float force_monitor_aspect;
float monitor_pixel_aspect;
int force_window_position;
+
+ int native_fs;
} mp_vo_opts;
typedef struct MPOpts {
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index cc8f69bc1d..481096fd96 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -543,6 +543,11 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t d_width,
s->window_title =
[[NSString alloc] initWithUTF8String:vo_get_window_title(vo)];
[s->window setTitle: s->window_title];
+
+ if (opts->native_fs) {
+ [s->window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ [NSApp setPresentationOptions:NSFullScreenWindowMask];
+ }
});
[vo->cocoa->glContext makeCurrentContext];
@@ -686,32 +691,46 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
struct vo_cocoa_state *s = self.videoOutput->cocoa;
struct mp_vo_opts *opts = self.videoOutput->opts;
+ if (opts->native_fs) {
+ if (!opts->fs) {
+ [self setContentResizeIncrements:NSMakeSize(1, 1)];
+ } else {
+ [self setContentAspectRatio:s->current_video_size];
+ }
+
+ [self toggleFullScreen:nil];
+ } else {
+ if (!opts->fs) {
+ update_screen_info(self.videoOutput);
+ if (current_screen_has_dock_or_menubar(self.videoOutput))
+ [NSApp setPresentationOptions:NSApplicationPresentationHideDock|
+ NSApplicationPresentationHideMenuBar];
+ s->windowed_frame = [self frame];
+ [self setHasShadow:NO];
+ [self setStyleMask:s->fullscreen_mask];
+ [self setFrame:s->fsscreen_frame display:YES animate:NO];
+ [self setMovableByWindowBackground: NO];
+ } else {
+ [NSApp setPresentationOptions:NSApplicationPresentationDefault];
+ [self setHasShadow:YES];
+ [self setStyleMask:s->windowed_mask];
+ [self setTitle:s->window_title];
+ [self setFrame:s->windowed_frame display:YES animate:NO];
+ if (s->out_fs_resize) {
+ [self setContentSize:s->current_video_size keepCentered:YES];
+ s->out_fs_resize = NO;
+ }
+ [self setContentAspectRatio:s->current_video_size];
+ [self setMovableByWindowBackground: YES];
+ }
+ }
+
if (!opts->fs) {
- update_screen_info(self.videoOutput);
- if (current_screen_has_dock_or_menubar(self.videoOutput))
- [NSApp setPresentationOptions:NSApplicationPresentationHideDock|
- NSApplicationPresentationHideMenuBar];
- s->windowed_frame = [self frame];
- [self setHasShadow:NO];
- [self setStyleMask:s->fullscreen_mask];
- [self setFrame:s->fsscreen_frame display:YES animate:NO];
opts->fs = VO_TRUE;
vo_cocoa_display_cursor(self.videoOutput, 0);
- [self setMovableByWindowBackground: NO];
} else {
- [NSApp setPresentationOptions:NSApplicationPresentationDefault];
- [self setHasShadow:YES];
- [self setStyleMask:s->windowed_mask];
- [self setTitle:s->window_title];
- [self setFrame:s->windowed_frame display:YES animate:NO];
- if (s->out_fs_resize) {
- [self setContentSize:s->current_video_size keepCentered:YES];
- s->out_fs_resize = NO;
- }
- [self setContentAspectRatio:s->current_video_size];
opts->fs = false;
vo_cocoa_display_cursor(self.videoOutput, 1);
- [self setMovableByWindowBackground: YES];
}
resize_window(self.videoOutput);