]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/Windows.m
macosx: implement native fullscreen behaviour for yosemite titlebar
[vlc] / modules / gui / macosx / Windows.m
index 9267c5b6d5cc63111ea7d777c869f789fe4b5f2d..48b1d82f6ebe73a4c76b231cd8ee8ceb07a75b11 100644 (file)
 
     BOOL b_inFullscreen = [self fullscreen] || ([self respondsToSelector:@selector(inFullscreenTransition)] && [(VLCVideoWindowCommon *)self inFullscreenTransition]);
 
-    if(OSX_MAVERICKS && b_inFullscreen && constrainedRect.size.width == screenRect.size.width
+    if((OSX_MAVERICKS || OSX_YOSEMITE) && b_inFullscreen && constrainedRect.size.width == screenRect.size.width
           && constrainedRect.size.height != screenRect.size.height
           && abs(screenRect.size.height - constrainedRect.size.height) <= 25.) {
 
 @synthesize videoView=o_video_view;
 @synthesize controlsBar=o_controls_bar;
 @synthesize inFullscreenTransition=b_in_fullscreen_transition;
+@synthesize windowShouldExitFullscreenWhenFinished=b_windowShouldExitFullscreenWhenFinished;
 
 #pragma mark -
 #pragma mark Init
 
     if (b_nativeFullscreenMode) {
         [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
-    } else {
-        [o_titlebar_view setFullscreenButtonHidden: YES];
     }
 
+
     [super awakeFromNib];
 }
 
     [super mouseMoved: theEvent];
 }
 
+#pragma mark -
+#pragma mark Key events
+
+- (void)flagsChanged:(NSEvent *)theEvent
+{
+    BOOL b_alt_pressed = ([theEvent modifierFlags] & NSAlternateKeyMask) != 0;
+    [o_titlebar_view informModifierPressed: b_alt_pressed];
+
+    [super flagsChanged:theEvent];
+}
+
 #pragma mark -
 #pragma mark Lion native fullscreen handling
 
 
 - (void)windowWillEnterFullScreen:(NSNotification *)notification
 {
-    // workaround, see #6668
-    [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
-
     i_originalLevel = [self level];
+    b_windowShouldExitFullscreenWhenFinished = [[VLCMain sharedInstance] activeVideoPlayback];
+
     // b_fullscreen and b_in_fullscreen_transition must not be true yet
     [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
     [self setLevel:NSNormalWindowLevel];
         if ([[subviews objectAtIndex:x] respondsToSelector:@selector(reshape)])
             [[subviews objectAtIndex:x] reshape];
     }
-
 }
 
 - (void)windowWillExitFullScreen:(NSNotification *)notification
     b_in_fullscreen_transition = YES;
     [self setFullscreen: NO];
 
-    var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
-
     if ([self hasActiveVideo]) {
+        var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
+
         vout_thread_t *p_vout = getVoutForActiveWindow();
         if (p_vout) {
             var_SetBool(p_vout, "fullscreen", false);
         o_fullscreen_anim2 = nil;
     }
 
+    b_in_fullscreen_transition = YES;
+    [self setFullscreen:NO];
+
     if (!b_animation) {
         /* We don't animate if we are not visible, instead we
          * simply fade the display */
         return;
     }
 
-    b_in_fullscreen_transition = YES;
-
     [self setAlphaValue: 0.0];
     [self orderFront: self];
     [[o_video_view window] orderFront: self];
 
 - (void)hasEndedFullscreen
 {
-    [self setFullscreen:NO];
     b_in_fullscreen_transition = NO;
 
     /* This function is private and should be only triggered at the end of the fullscreen change animation */