aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out
diff options
context:
space:
mode:
authorGravatar Stefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-30 13:41:56 +0200
committerGravatar Stefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-30 23:03:20 +0200
commit68c3e2aabbff7cb057dc31834d40f9a90fed4b31 (patch)
tree2e3c7bbb307ec943a5f32df296246b78f2c40ead /video/out
parent0aac8bc5ad0fd49f288ecf18346bd10af35247c1 (diff)
cocoa_common: refactor fullscreen code for readability
Break up the code into several methods and reduce code duplication. Also add comments to make the intention of all this clearer.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa_common.m84
1 files changed, 53 insertions, 31 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 8cb34c0825..ace63679b2 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -645,51 +645,73 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
s->did_resize = YES;
}
}
+- (void)toggleMissionControlFullScreen:(BOOL)willBeFullscreen
+{
+ struct vo_cocoa_state *s = self.videoOutput->cocoa;
+
+ if (willBeFullscreen) {
+ [self setContentResizeIncrements:NSMakeSize(1, 1)];
+ } else {
+ [self setContentAspectRatio:s->current_video_size];
+ }
+
+ [self toggleFullScreen:nil];
+}
+- (void)toggleViewFullscreen:(BOOL)willBeFullscreen
+{
+ struct vo_cocoa_state *s = self.videoOutput->cocoa;
+
+ if (willBeFullscreen) {
+ NSDictionary *fsopts = @{
+ NSFullScreenModeWindowLevel :
+ @(NSFloatingWindowLevel),
+ NSFullScreenModeAllScreens :
+ @NO,
+ NSFullScreenModeApplicationPresentationOptions :
+ @(NSApplicationPresentationHideDock |
+ NSApplicationPresentationAutoHideMenuBar)
+ };
+
+ [s->view enterFullScreenMode:s->fs_screen withOptions:fsopts];
+ } else {
+ [s->view exitFullScreenModeWithOptions:nil];
+ [self makeFirstResponder:s->view];
+ }
+}
- (void)fullscreen
{
struct vo_cocoa_state *s = self.videoOutput->cocoa;
- struct mp_vo_opts *opts = self.videoOutput->opts;
+ struct mp_vo_opts *opts = self.videoOutput->opts;
+ vo_cocoa_update_screen_info(self.videoOutput);
+
+ // Go use the fullscreen API selected by the user. View-based or Mission
+ // Control.
if (opts->native_fs) {
- if (!opts->fs) {
- vo_cocoa_set_cursor_visibility(false);
- [self setContentResizeIncrements:NSMakeSize(1, 1)];
- opts->fs = VO_TRUE;
- } else {
- vo_cocoa_set_cursor_visibility(true);
- [self setContentAspectRatio:s->current_video_size];
- opts->fs = VO_FALSE;
- }
+ [self toggleMissionControlFullScreen:!opts->fs];
+ } else {
+ [self toggleViewFullscreen:!opts->fs];
+ }
- [self toggleFullScreen:nil];
+ // Do common work such as setting mouse visibility and actually setting
+ // the new fullscreen state
+ if (!opts->fs) {
+ vo_cocoa_set_cursor_visibility(false);
+ opts->fs = VO_TRUE;
} else {
- if (!opts->fs) {
- NSDictionary *fsopts = @{
- NSFullScreenModeWindowLevel :
- @(NSFloatingWindowLevel),
- NSFullScreenModeAllScreens :
- @NO,
- NSFullScreenModeApplicationPresentationOptions :
- @(NSApplicationPresentationAutoHideDock |
- NSApplicationPresentationAutoHideMenuBar)
- };
-
- [s->view enterFullScreenMode:s->fs_screen withOptions:fsopts];
- vo_cocoa_set_cursor_visibility(false);
- opts->fs = VO_TRUE;
- } else {
- [s->view exitFullScreenModeWithOptions:nil];
- vo_cocoa_set_cursor_visibility(true);
- [self makeFirstResponder:s->view];
- opts->fs = VO_FALSE;
- }
+ vo_cocoa_set_cursor_visibility(true);
+ opts->fs = VO_FALSE;
}
+ // Change window size if the core attempted to change it while we were in
+ // fullscreen. For example config() might have been called as a result of
+ // a new file changing the window size.
if (!opts->fs && s->out_fs_resize) {
resize_window_from_stored_size(self.videoOutput);
s->out_fs_resize = NO;
}
+ // Make the core aware of the view size change.
resize_window(self.videoOutput);
}