macosx: split windows file to have one class per file
authorFelix Paul Kühne <felix@feepk.net>
Sun, 10 Jun 2018 09:36:51 +0000 (11:36 +0200)
committerFelix Paul Kühne <felix@feepk.net>
Sun, 10 Jun 2018 11:44:52 +0000 (13:44 +0200)
extras/package/macosx/VLC.xcodeproj/project.pbxproj
modules/gui/macosx/Makefile.am
modules/gui/macosx/VLCFSPanelController.h
modules/gui/macosx/VLCMainWindow.h
modules/gui/macosx/VLCVideoWindowCommon.h [new file with mode: 0644]
modules/gui/macosx/VLCVideoWindowCommon.m [new file with mode: 0644]
modules/gui/macosx/VLCWindow.h [new file with mode: 0644]
modules/gui/macosx/VLCWindow.m [new file with mode: 0644]
modules/gui/macosx/Windows.h [deleted file]
modules/gui/macosx/Windows.m [deleted file]
po/POTFILES.in

index fe0ee17..595a93f 100644 (file)
@@ -62,7 +62,6 @@
                1C31140B1E508C8800D4DD76 /* SPInvocationGrabbing.m in Sources */ = {isa = PBXBuildFile; fileRef = CCF0777A13659A8000AF19FD /* SPInvocationGrabbing.m */; };
                1C31140D1E508C8800D4DD76 /* SPMediaKeyTap.m in Sources */ = {isa = PBXBuildFile; fileRef = CCF0777C13659A8000AF19FD /* SPMediaKeyTap.m */; };
                1C5716AC1F5B142200678627 /* coreaudio_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 1C5716AB1F5B142200678627 /* coreaudio_common.c */; };
-               1C69FDF61EAB30C7007724ED /* Windows.m in Sources */ = {isa = PBXBuildFile; fileRef = E06CF7F516020F6200C698B7 /* Windows.m */; };
                1CAC3EE820CD1B3B00613DB2 /* VLCVideoOutputProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CAC3EE620CD1B3B00613DB2 /* VLCVideoOutputProvider.m */; };
                1CCC88EC2078A3D500E5626F /* MainMenu.xib in Sources */ = {isa = PBXBuildFile; fileRef = 6B8224091E4D2A9000833BE1 /* MainMenu.xib */; };
                1CCC88ED2078A3D500E5626F /* MainWindow.xib in Sources */ = {isa = PBXBuildFile; fileRef = 6B82240A1E4D2A9000833BE1 /* MainWindow.xib */; };
                6BF093F91EE0182B0049D8B0 /* VLCTimeField.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF093F81EE0182B0049D8B0 /* VLCTimeField.m */; };
                6BF5C5041EFE66EF008A9C12 /* VLCHUDTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF5C5031EFE66EF008A9C12 /* VLCHUDTableView.m */; };
                6BF5C5071EFE7E58008A9C12 /* VLCTintedImageButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF5C5061EFE7E58008A9C12 /* VLCTintedImageButtonCell.m */; };
+               7D2E0EDB20CD204D0033A221 /* VLCWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2E0ED920CD204D0033A221 /* VLCWindow.m */; };
+               7D2E0EDE20CD206F0033A221 /* VLCVideoWindowCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2E0EDD20CD206F0033A221 /* VLCVideoWindowCommon.m */; };
                7DB40D2A20CBCEB500F63173 /* VLCMainMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB40D2920CBCEB500F63173 /* VLCMainMenu.m */; };
                7DB40D2D20CBCEC200F63173 /* VLCStatusBarIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB40D2B20CBCEC200F63173 /* VLCStatusBarIcon.m */; };
                7DB7F1EC20CC036D00C2CAED /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DB7F1EB20CC036D00C2CAED /* AudioUnit.framework */; };
                6BF5C5051EFE7E58008A9C12 /* VLCTintedImageButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCTintedImageButtonCell.h; sourceTree = "<group>"; };
                6BF5C5061EFE7E58008A9C12 /* VLCTintedImageButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCTintedImageButtonCell.m; sourceTree = "<group>"; };
                7D0A387820CBCC4D00D4BF3B /* videotoolbox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = videotoolbox.m; path = ../../../modules/codec/videotoolbox.m; sourceTree = "<group>"; };
+               7D2E0ED920CD204D0033A221 /* VLCWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCWindow.m; sourceTree = "<group>"; };
+               7D2E0EDA20CD204D0033A221 /* VLCWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCWindow.h; sourceTree = "<group>"; };
+               7D2E0EDC20CD206F0033A221 /* VLCVideoWindowCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCVideoWindowCommon.h; sourceTree = "<group>"; };
+               7D2E0EDD20CD206F0033A221 /* VLCVideoWindowCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCVideoWindowCommon.m; sourceTree = "<group>"; };
                7D5678EB1D5BA1DC002698F3 /* VLCApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCApplication.h; sourceTree = "<group>"; };
                7D5678EC1D5BA1DC002698F3 /* VLCApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCApplication.m; sourceTree = "<group>"; };
                7D5678EE1D5BA397002698F3 /* VLCMainWindowControlsBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCMainWindowControlsBar.h; sourceTree = "<group>"; };
                DCE7BD0708A5724D007B10AE /* VLCBookmarksWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCBookmarksWindowController.h; sourceTree = "<group>"; };
                E0382C00160BA09E0031D7FF /* VLCControlsBarCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCControlsBarCommon.h; sourceTree = "<group>"; };
                E0382C01160BA09E0031D7FF /* VLCControlsBarCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCControlsBarCommon.m; sourceTree = "<group>"; };
-               E06CF7F416020F6200C698B7 /* Windows.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Windows.h; sourceTree = "<group>"; };
-               E06CF7F516020F6200C698B7 /* Windows.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Windows.m; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                        name = "Streaming and Remote Playback";
                        sourceTree = "<group>";
                };
+               7D2E0ED820CD201F0033A221 /* Windows */ = {
+                       isa = PBXGroup;
+                       children = (
+                               7D2E0EDA20CD204D0033A221 /* VLCWindow.h */,
+                               7D2E0ED920CD204D0033A221 /* VLCWindow.m */,
+                               7D2E0EDC20CD206F0033A221 /* VLCVideoWindowCommon.h */,
+                               7D2E0EDD20CD206F0033A221 /* VLCVideoWindowCommon.m */,
+                       );
+                       name = Windows;
+                       sourceTree = "<group>";
+               };
                7D349C8920CBC5D8003359A1 /* Custom View Classes */ = {
                        isa = PBXGroup;
                        children = (
+                               7D2E0ED820CD201F0033A221 /* Windows */,
                                6B846FE81CF5D89500112E54 /* HUD UI Classes */,
                                7D349C9E20CBC99D003359A1 /* Text Fields */,
                                7D349C9F20CBC9AC003359A1 /* Further views */,
                7D349C9B20CBC8A6003359A1 /* Class Extensions */ = {
                        isa = PBXGroup;
                        children = (
-                               E06CF7F416020F6200C698B7 /* Windows.h */,
-                               E06CF7F516020F6200C698B7 /* Windows.m */,
                                6B4D50A51E7AB52C004479B5 /* NSScreen+VLCAdditions.h */,
                                6B4D50A61E7AB52C004479B5 /* NSScreen+VLCAdditions.m */,
                                6B4D50941E7A7D16004479B5 /* NSSound+VLCAdditions.h */,
                                        };
                                };
                        };
-                       buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */;
+                       buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */;
                        compatibilityVersion = "Xcode 6.3";
                        developmentRegion = English;
                        hasScannedForEncodings = 1;
                                6B0AB0F11F1AC8B3003A1B4E /* VLCSliderCell.m in Sources */,
                                6B8166291EBFC34300C26F1B /* VLCDefaultValueSlider.m in Sources */,
                                6B81662A1EBFC34300C26F1B /* VLCDefaultValueSliderCell.m in Sources */,
-                               1C69FDF61EAB30C7007724ED /* Windows.m in Sources */,
                                6B3BE42C1E6217CB008D098A /* VLCImageButton.m in Sources */,
                                6B4D50901E79781F004479B5 /* VLCHotkeyChangeWindow.m in Sources */,
                                1C3114031E508C8800D4DD76 /* AppleRemote.m in Sources */,
                                1C3113901E508C6900D4DD76 /* VLCHelpWindowController.m in Sources */,
                                1C3113921E508C6900D4DD76 /* VLCAddonListItem.m in Sources */,
                                1C3113941E508C6900D4DD76 /* VLCAddonsWindowController.m in Sources */,
+                               7D2E0EDE20CD206F0033A221 /* VLCVideoWindowCommon.m in Sources */,
                                1C3113961E508C6900D4DD76 /* applescript.m in Sources */,
                                1C3113981E508C6900D4DD76 /* VLCAudioEffectsWindowController.m in Sources */,
                                6BBBF9851F7B257100B404CD /* VLCLogMessage.m in Sources */,
                                1C3113D71E508C6900D4DD76 /* VLCPopupPanelController.m in Sources */,
                                1C3113D91E508C6900D4DD76 /* VLCSimplePrefsController.m in Sources */,
                                6B2EFC601F2819F700F3C0EA /* VLCVolumeSlider.m in Sources */,
+                               7D2E0EDB20CD204D0033A221 /* VLCWindow.m in Sources */,
                                1C3113DB1E508C6900D4DD76 /* VLCStringUtility.m in Sources */,
                                6B4D50A71E7AB52C004479B5 /* NSScreen+VLCAdditions.m in Sources */,
                                1C3113DD1E508C6900D4DD76 /* VLCTrackSynchronizationWindowController.m in Sources */,
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Default;
                };
-               C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */ = {
+               C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                                C2F2A6EB09588F1B00018C74 /* Development */,
index ace16e1..e10209f 100644 (file)
@@ -66,7 +66,8 @@ libmacosx_plugin_la_SOURCES = \
        gui/macosx/VLCScrollingClipView.h gui/macosx/VLCScrollingClipView.m \
        gui/macosx/VLCStatusBarIcon.h gui/macosx/VLCStatusBarIcon.m \
        gui/macosx/VLCVideoOutputProvider.h gui/macosx/VLCVideoOutputProvider.m \
-       gui/macosx/Windows.h gui/macosx/Windows.m \
+       gui/macosx/VLCWindow.h gui/macosx/VLCWindow.m \
+       gui/macosx/VLCVideoWindowCommon.h gui/macosx/VLCVideoWindowCommon.m \
        gui/macosx/VLCAudioEffectsWindowController.h gui/macosx/VLCAudioEffectsWindowController.m \
        gui/macosx/VLCBookmarksWindowController.h gui/macosx/VLCBookmarksWindowController.m \
        gui/macosx/VLCBottomBarView.h gui/macosx/VLCBottomBarView.m \
index 5b86759..78366fd 100644 (file)
@@ -26,7 +26,7 @@
 
 #import <Cocoa/Cocoa.h>
 
-#import "Windows.h"
+#import "VLCWindow.h"
 #import "VLCDefaultValueSlider.h"
 #import "VLCTimeField.h"
 
index ae7fce9..b9bd614 100644 (file)
@@ -30,7 +30,7 @@
 #import <vlc_input.h>
 #import <vlc_vout_window.h>
 
-#import "Windows.h"
+#import "VLCVideoWindowCommon.h"
 #import "misc.h"
 #import "VLCFSPanelController.h"
 
diff --git a/modules/gui/macosx/VLCVideoWindowCommon.h b/modules/gui/macosx/VLCVideoWindowCommon.h
new file mode 100644 (file)
index 0000000..8d18a3b
--- /dev/null
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Windows.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2012-2014 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
+ *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+#import "VLCWindow.h"
+
+@class VLCVoutView;
+
+@class VLCControlsBarCommon;
+
+static const float f_min_video_height = 70.0;
+
+/*****************************************************************************
+ * VLCVideoWindowCommon
+ *
+ *  Common code for main window, detached window and extra video window
+ *****************************************************************************/
+
+@interface VLCVideoWindowCommon : VLCWindow <NSWindowDelegate, NSAnimationDelegate>
+
+@property (weak) IBOutlet NSLayoutConstraint *videoViewBottomConstraint;
+
+@property (nonatomic, weak) IBOutlet VLCVoutView* videoView;
+@property (nonatomic, weak) IBOutlet VLCControlsBarCommon* controlsBar;
+@property (readonly) BOOL inFullscreenTransition;
+@property (readonly) BOOL windowShouldExitFullscreenWhenFinished;
+@property (readwrite, assign) NSRect previousSavedFrame;
+@property (nonatomic, readwrite, assign) NSSize nativeVideoSize;
+
+- (void)setWindowLevel:(NSInteger)i_state;
+- (void)resizeWindow;
+
+- (NSRect)getWindowRectForProposedVideoViewSize:(NSSize)size;
+
+- (void)setTitle:(NSString *)title;
+
+/* fullscreen handling */
+- (void)enterFullscreenWithAnimation:(BOOL)b_animation;
+- (void)leaveFullscreenWithAnimation:(BOOL)b_animation;
+
+/* lion fullscreen handling */
+- (void)hideControlsBar;
+- (void)showControlsBar;
+
+- (void)windowWillEnterFullScreen:(NSNotification *)notification;
+- (void)windowDidEnterFullScreen:(NSNotification *)notification;
+- (void)windowWillExitFullScreen:(NSNotification *)notification;
+
+@end
diff --git a/modules/gui/macosx/VLCVideoWindowCommon.m b/modules/gui/macosx/VLCVideoWindowCommon.m
new file mode 100644 (file)
index 0000000..6a7e47a
--- /dev/null
@@ -0,0 +1,844 @@
+/*****************************************************************************
+ * Windows.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2012-2018 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
+ *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCMain.h"
+#import "VLCVideoWindowCommon.h"
+#import "CompatibilityFixes.h"
+#import "VLCCoreInteraction.h"
+#import "VLCControlsBarCommon.h"
+#import "VLCMainWindow.h"
+#import "NSScreen+VLCAdditions.h"
+
+/*****************************************************************************
+ * VLCVideoWindowCommon
+ *
+ *  Common code for main window, detached window and extra video window
+ *****************************************************************************/
+
+@interface VLCVideoWindowCommon()
+{
+    // variables for fullscreen handling
+    VLCVideoWindowCommon *o_current_video_window;
+    VLCWindow       * o_fullscreen_window;
+    NSViewAnimation * o_fullscreen_anim1;
+    NSViewAnimation * o_fullscreen_anim2;
+    NSView          * o_temp_view;
+
+    NSInteger i_originalLevel;
+
+    BOOL b_video_view_was_hidden;
+
+    NSRect frameBeforeLionFullscreen;
+}
+
+- (void)customZoom:(id)sender;
+- (void)hasBecomeFullscreen;
+- (void)hasEndedFullscreen;
+@end
+
+@implementation VLCVideoWindowCommon
+
+#pragma mark -
+#pragma mark Init
+
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)styleMask
+                  backing:(NSBackingStoreType)backingType defer:(BOOL)flag
+{
+    self = [super initWithContentRect:contentRect styleMask:styleMask
+                              backing:backingType defer:flag];
+
+    /* we want to be moveable regardless of our style */
+    [self setMovableByWindowBackground: YES];
+    [self setCanBecomeKeyWindow:YES];
+
+    o_temp_view = [[NSView alloc] init];
+    [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
+
+    return self;
+}
+
+- (void)awakeFromNib
+{
+    BOOL b_nativeFullscreenMode = var_InheritBool(getIntf(), "macosx-nativefullscreenmode");
+
+    if (b_nativeFullscreenMode) {
+        [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
+    } else if (OSX_EL_CAPITAN_AND_HIGHER) {
+        // Native fullscreen seems to be default on El Capitan, this disables it explicitely
+        [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
+    }
+
+    [super awakeFromNib];
+}
+
+- (void)setTitle:(NSString *)title
+{
+    if (!title || [title length] < 1)
+        return;
+
+    [super setTitle: title];
+}
+
+#pragma mark -
+#pragma mark zoom / minimize / close
+
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+    SEL s_menuAction = [menuItem action];
+
+    if ((s_menuAction == @selector(performClose:)) || (s_menuAction == @selector(performMiniaturize:)) || (s_menuAction == @selector(performZoom:)))
+        return YES;
+
+    return [super validateMenuItem:menuItem];
+}
+
+- (BOOL)windowShouldClose:(id)sender
+{
+    return YES;
+}
+
+- (void)performClose:(id)sender
+{
+    if (!([self styleMask] & NSTitledWindowMask)) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowWillCloseNotification object:self];
+
+        [self close];
+    } else
+        [super performClose: sender];
+}
+
+- (void)performMiniaturize:(id)sender
+{
+    if (!([self styleMask] & NSTitledWindowMask))
+        [self miniaturize: sender];
+    else
+        [super performMiniaturize: sender];
+}
+
+- (void)performZoom:(id)sender
+{
+    if (!([self styleMask] & NSTitledWindowMask))
+        [self customZoom: sender];
+    else
+        [super performZoom: sender];
+}
+
+- (void)zoom:(id)sender
+{
+    if (!([self styleMask] & NSTitledWindowMask))
+        [self customZoom: sender];
+    else
+        [super zoom: sender];
+}
+
+/**
+ * Given a proposed frame rectangle, return a modified version
+ * which will fit inside the screen.
+ *
+ * This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
+ *    Authors:  Scott Christley <scottc@net-community.com>, Venkat Ajjanagadde <venkat@ocbi.com>,
+ *              Felipe A. Rodriguez <far@ix.netcom.com>, Richard Frith-Macdonald <richard@brainstorm.co.uk>
+ *    Copyright (C) 1996 Free Software Foundation, Inc.
+ */
+- (NSRect) customConstrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
+{
+    NSRect screenRect = [screen visibleFrame];
+    CGFloat difference;
+
+    /* Move top edge of the window inside the screen */
+    difference = NSMaxY (frameRect) - NSMaxY (screenRect);
+    if (difference > 0) {
+        frameRect.origin.y -= difference;
+    }
+
+    /* If the window is resizable, resize it (if needed) so that the
+     bottom edge is on the screen or can be on the screen when the user moves
+     the window */
+    difference = NSMaxY (screenRect) - NSMaxY (frameRect);
+    if (self.styleMask & NSResizableWindowMask) {
+        CGFloat difference2;
+
+        difference2 = screenRect.origin.y - frameRect.origin.y;
+        difference2 -= difference;
+        // Take in account the space between the top of window and the top of the
+        // screen which can be used to move the bottom of the window on the screen
+        if (difference2 > 0) {
+            frameRect.size.height -= difference2;
+            frameRect.origin.y += difference2;
+        }
+
+        /* Ensure that resizing doesn't makewindow smaller than minimum */
+        difference2 = [self minSize].height - frameRect.size.height;
+        if (difference2 > 0) {
+            frameRect.size.height += difference2;
+            frameRect.origin.y -= difference2;
+        }
+    }
+
+    return frameRect;
+}
+
+#define DIST 3
+
+/**
+ Zooms the receiver.   This method calls the delegate method
+ windowShouldZoom:toFrame: to determine if the window should
+ be allowed to zoom to full screen.
+ *
+ * This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
+ *    Authors:  Scott Christley <scottc@net-community.com>, Venkat Ajjanagadde <venkat@ocbi.com>,
+ *              Felipe A. Rodriguez <far@ix.netcom.com>, Richard Frith-Macdonald <richard@brainstorm.co.uk>
+ *    Copyright (C) 1996 Free Software Foundation, Inc.
+ */
+- (void) customZoom: (id)sender
+{
+    NSRect maxRect = [[self screen] visibleFrame];
+    NSRect currentFrame = [self frame];
+
+    if ([[self delegate] respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)]) {
+        maxRect = [[self delegate] windowWillUseStandardFrame: self defaultFrame: maxRect];
+    }
+
+    maxRect = [self customConstrainFrameRect: maxRect toScreen: [self screen]];
+
+    // Compare the new frame with the current one
+    if ((fabs(NSMaxX(maxRect) - NSMaxX(currentFrame)) < DIST)
+        && (fabs(NSMaxY(maxRect) - NSMaxY(currentFrame)) < DIST)
+        && (fabs(NSMinX(maxRect) - NSMinX(currentFrame)) < DIST)
+        && (fabs(NSMinY(maxRect) - NSMinY(currentFrame)) < DIST)) {
+        // Already in zoomed mode, reset user frame, if stored
+        if ([self frameAutosaveName] != nil) {
+            [self setFrame: self.previousSavedFrame display: YES animate: YES];
+            [self saveFrameUsingName: [self frameAutosaveName]];
+        }
+        return;
+    }
+
+    if ([self frameAutosaveName] != nil) {
+        [self saveFrameUsingName: [self frameAutosaveName]];
+        self.previousSavedFrame = [self frame];
+    }
+
+    [self setFrame: maxRect display: YES animate: YES];
+}
+
+#pragma mark -
+#pragma mark Video window resizing logic
+
+- (void)setWindowLevel:(NSInteger)i_state
+{
+    if (var_InheritBool(getIntf(), "video-wallpaper") || [self level] < NSNormalWindowLevel)
+        return;
+
+    if (!self.fullscreen && !_inFullscreenTransition)
+        [self setLevel: i_state];
+
+    // save it for restore if window is currently minimized or in fullscreen
+    i_originalLevel = i_state;
+}
+
+- (NSRect)getWindowRectForProposedVideoViewSize:(NSSize)size
+{
+    NSSize windowMinSize = [self minSize];
+    NSRect screenFrame = [[self screen] visibleFrame];
+
+    NSRect topleftbase = NSMakeRect(0, [self frame].size.height, 0, 0);
+    NSPoint topleftscreen = [self convertRectToScreen: topleftbase].origin;
+
+    CGFloat f_width = size.width;
+    CGFloat f_height = size.height;
+    if (f_width < windowMinSize.width)
+        f_width = windowMinSize.width;
+    if (f_height < f_min_video_height)
+        f_height = f_min_video_height;
+
+    /* Calculate the window's new size */
+    NSRect new_frame;
+    new_frame.size.width = [self frame].size.width - [_videoView frame].size.width + f_width;
+    new_frame.size.height = [self frame].size.height - [_videoView frame].size.height + f_height;
+    new_frame.origin.x = topleftscreen.x;
+    new_frame.origin.y = topleftscreen.y - new_frame.size.height;
+
+    /* make sure the window doesn't exceed the screen size the window is on */
+    if (new_frame.size.width > screenFrame.size.width) {
+        new_frame.size.width = screenFrame.size.width;
+        new_frame.origin.x = screenFrame.origin.x;
+    }
+    if (new_frame.size.height > screenFrame.size.height) {
+        new_frame.size.height = screenFrame.size.height;
+        new_frame.origin.y = screenFrame.origin.y;
+    }
+    if (new_frame.origin.y < screenFrame.origin.y)
+        new_frame.origin.y = screenFrame.origin.y;
+
+    CGFloat right_screen_point = screenFrame.origin.x + screenFrame.size.width;
+    CGFloat right_window_point = new_frame.origin.x + new_frame.size.width;
+    if (right_window_point > right_screen_point)
+        new_frame.origin.x -= (right_window_point - right_screen_point);
+
+    return new_frame;
+}
+
+- (void)resizeWindow
+{
+    // VOUT_WINDOW_SET_SIZE is triggered when exiting fullscreen. This event is ignored here
+    // to avoid interference with the animation.
+    if ([self fullscreen] || _inFullscreenTransition)
+        return;
+
+    NSRect window_rect = [self getWindowRectForProposedVideoViewSize:self.nativeVideoSize];
+    [[self animator] setFrame:window_rect display:YES];
+}
+
+- (void)setNativeVideoSize:(NSSize)size
+{
+    _nativeVideoSize = size;
+
+    if (var_InheritBool(getIntf(), "macosx-video-autoresize") && !var_InheritBool(getIntf(), "video-wallpaper"))
+        [self resizeWindow];
+}
+
+- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
+{
+    if (![[VLCMain sharedInstance] activeVideoPlayback] || self.nativeVideoSize.width == 0. || self.nativeVideoSize.height == 0. || window != self)
+        return proposedFrameSize;
+
+    // needed when entering lion fullscreen mode
+    if (_inFullscreenTransition || [self fullscreen])
+        return proposedFrameSize;
+
+    if ([_videoView isHidden])
+        return proposedFrameSize;
+
+    if ([[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]) {
+        NSRect videoWindowFrame = [self frame];
+        NSRect viewRect = [_videoView convertRect:[_videoView bounds] toView: nil];
+        NSRect contentRect = [self contentRectForFrameRect:videoWindowFrame];
+        CGFloat marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
+        CGFloat marginx = contentRect.size.width - viewRect.size.width;
+
+        proposedFrameSize.height = (proposedFrameSize.width - marginx) * self.nativeVideoSize.height / self.nativeVideoSize.width + marginy;
+    }
+
+    return proposedFrameSize;
+}
+
+- (void)windowWillMiniaturize:(NSNotification *)notification
+{
+    // Set level to normal as a workaround for Mavericks bug causing window
+    // to vanish from screen, see radar://15473716
+    i_originalLevel = [self level];
+    [self setLevel: NSNormalWindowLevel];
+}
+
+- (void)windowDidDeminiaturize:(NSNotification *)notification
+{
+    [self setLevel: i_originalLevel];
+}
+
+#pragma mark -
+#pragma mark Lion native fullscreen handling
+
+- (void)hideControlsBar
+{
+    [[self.controlsBar bottomBarView] setHidden: YES];
+    self.videoViewBottomConstraint.priority = 1;
+}
+
+- (void)showControlsBar
+{
+    [[self.controlsBar bottomBarView] setHidden: NO];
+    self.videoViewBottomConstraint.priority = 999;
+}
+
+- (void)becomeKeyWindow
+{
+    [super becomeKeyWindow];
+
+    // change fspanel state for the case when multiple windows are in fullscreen
+    if ([self hasActiveVideo] && [self fullscreen])
+        [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive];
+    else
+        [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
+}
+
+- (void)resignKeyWindow
+{
+    [super resignKeyWindow];
+
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
+}
+
+-(NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow *)window
+{
+    if (window == self) {
+        return [NSArray arrayWithObject:window];
+    }
+
+    return nil;
+}
+
+- (NSArray*)customWindowsToExitFullScreenForWindow:(NSWindow*)window
+{
+    if (window == self) {
+        return [NSArray arrayWithObject:window];
+    }
+
+    return nil;
+}
+
+- (void)window:window startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration
+{
+    [window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
+
+    NSScreen *screen = [window screen];
+    NSRect screenFrame = [screen frame];
+
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
+        [context setDuration:0.5 * duration];
+        [[window animator] setFrame:screenFrame display:YES];
+    } completionHandler:nil];
+}
+
+- (void)window:window startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration
+{
+    [window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
+    [[window animator] setFrame:frameBeforeLionFullscreen display:YES animate:YES];
+
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
+        [context setDuration:0.5 * duration];
+        [[window animator] setFrame:frameBeforeLionFullscreen display:YES animate:YES];
+    } completionHandler:nil];
+}
+
+- (void)windowWillEnterFullScreen:(NSNotification *)notification
+{
+    _windowShouldExitFullscreenWhenFinished = [[VLCMain sharedInstance] activeVideoPlayback];
+
+    NSInteger i_currLevel = [self level];
+    // self.fullscreen and _inFullscreenTransition must not be true yet
+    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
+    [self setLevel:NSNormalWindowLevel];
+    i_originalLevel = i_currLevel;
+
+    _inFullscreenTransition = YES;
+
+    var_SetBool(pl_Get(getIntf()), "fullscreen", true);
+
+    frameBeforeLionFullscreen = [self frame];
+
+    if ([self hasActiveVideo]) {
+        vout_thread_t *p_vout = getVoutForActiveWindow();
+        if (p_vout) {
+            var_SetBool(p_vout, "fullscreen", true);
+            vlc_object_release(p_vout);
+        }
+    }
+
+    if (![_videoView isHidden]) {
+        [self hideControlsBar];
+    }
+
+    [self setMovableByWindowBackground: NO];
+}
+
+- (void)windowDidEnterFullScreen:(NSNotification *)notification
+{
+    // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
+    // But this creates some problems when leaving fs over remote intfs, so activate app here.
+    [NSApp activateIgnoringOtherApps:YES];
+
+    [self setFullscreen: YES];
+    _inFullscreenTransition = NO;
+
+    if ([self hasActiveVideo]) {
+        [[[[VLCMain sharedInstance] mainWindow] fspanel] setVoutWasUpdated:self];
+        if (![_videoView isHidden])
+            [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive];
+    }
+
+    NSArray *subviews = [[self videoView] subviews];
+    NSUInteger count = [subviews count];
+
+    for (NSUInteger x = 0; x < count; x++) {
+        if ([[subviews objectAtIndex:x] respondsToSelector:@selector(reshape)])
+            [[subviews objectAtIndex:x] reshape];
+    }
+}
+
+- (void)windowWillExitFullScreen:(NSNotification *)notification
+{
+    _inFullscreenTransition = YES;
+    [self setFullscreen: NO];
+
+    if ([self hasActiveVideo]) {
+        var_SetBool(pl_Get(getIntf()), "fullscreen", false);
+
+        vout_thread_t *p_vout = getVoutForActiveWindow();
+        if (p_vout) {
+            var_SetBool(p_vout, "fullscreen", false);
+            vlc_object_release(p_vout);
+        }
+    }
+
+    [NSCursor setHiddenUntilMouseMoves: NO];
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
+
+    if (![_videoView isHidden]) {
+        [self showControlsBar];
+    }
+
+    [self setMovableByWindowBackground: YES];
+}
+
+- (void)windowDidExitFullScreen:(NSNotification *)notification
+{
+    _inFullscreenTransition = NO;
+
+    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: i_originalLevel];
+    [self setLevel:i_originalLevel];
+}
+
+#pragma mark -
+#pragma mark Fullscreen Logic
+
+- (void)enterFullscreenWithAnimation:(BOOL)b_animation
+{
+    NSMutableDictionary *dict1, *dict2;
+    NSScreen *screen;
+    NSRect screen_rect;
+    NSRect rect;
+    BOOL blackout_other_displays = var_InheritBool(getIntf(), "macosx-black");
+
+    screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(getIntf(), "macosx-vdev")];
+
+    if (!screen) {
+        msg_Dbg(getIntf(), "chosen screen isn't present, using current screen for fullscreen mode");
+        screen = [self screen];
+    }
+    if (!screen) {
+        msg_Dbg(getIntf(), "Using deepest screen");
+        screen = [NSScreen deepestScreen];
+    }
+
+    screen_rect = [screen frame];
+
+    if (self.controlsBar)
+        [self.controlsBar setFullscreenState:YES];
+    [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:YES];
+
+    if (blackout_other_displays)
+        [screen blackoutOtherScreens];
+
+    /* Make sure we don't see the window flashes in float-on-top mode */
+    NSInteger i_currLevel = [self level];
+    // self.fullscreen must not be true yet
+    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
+    [self setLevel:NSNormalWindowLevel];
+    i_originalLevel = i_currLevel; // would be overwritten by previous call
+
+    /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
+    if (!o_fullscreen_window) {
+        /* We can't change the styleMask of an already created NSWindow, so we create another window, and do eye catching stuff */
+
+        rect = [[_videoView superview] convertRect: [_videoView frame] toView: nil]; /* Convert to Window base coord */
+        rect.origin.x += [self frame].origin.x;
+        rect.origin.y += [self frame].origin.y;
+        o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+        [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
+        [o_fullscreen_window setCanBecomeKeyWindow: YES];
+        [o_fullscreen_window setCanBecomeMainWindow: YES];
+        [o_fullscreen_window setHasActiveVideo: YES];
+        [o_fullscreen_window setFullscreen: YES];
+
+        /* Make sure video view gets visible in case the playlist was visible before */
+        b_video_view_was_hidden = [_videoView isHidden];
+        [_videoView setHidden: NO];
+        _videoView.translatesAutoresizingMaskIntoConstraints = YES;
+
+        if (!b_animation) {
+            /* We don't animate if we are not visible, instead we
+             * simply fade the display */
+            CGDisplayFadeReservationToken token;
+
+            if (blackout_other_displays) {
+                CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
+                CGDisplayFade(token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
+            }
+
+            NSDisableScreenUpdates();
+            [[_videoView superview] replaceSubview:_videoView with:o_temp_view];
+            [o_temp_view setFrame:[_videoView frame]];
+            [[o_fullscreen_window contentView] addSubview:_videoView];
+            [_videoView setFrame: [[o_fullscreen_window contentView] frame]];
+            [_videoView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+            NSEnableScreenUpdates();
+
+            [screen setFullscreenPresentationOptions];
+
+            [o_fullscreen_window setFrame:screen_rect display:YES animate:NO];
+
+            [o_fullscreen_window orderFront:self animate:YES];
+
+            [o_fullscreen_window setLevel:NSNormalWindowLevel];
+
+            if (blackout_other_displays) {
+                CGDisplayFade(token, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
+                CGReleaseDisplayFadeReservation(token);
+            }
+
+            /* Will release the lock */
+            [self hasBecomeFullscreen];
+
+            return;
+        }
+
+        /* Make sure we don't see the _videoView disappearing of the screen during this operation */
+        NSDisableScreenUpdates();
+        [[_videoView superview] replaceSubview:_videoView with:o_temp_view];
+        [o_temp_view setFrame:[_videoView frame]];
+        [[o_fullscreen_window contentView] addSubview:_videoView];
+        [_videoView setFrame: [[o_fullscreen_window contentView] frame]];
+        [_videoView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+        [o_fullscreen_window makeKeyAndOrderFront:self];
+        NSEnableScreenUpdates();
+    }
+
+    /* We are in fullscreen (and no animation is running) */
+    if ([self fullscreen]) {
+        /* Make sure we are hidden */
+        [self orderOut: self];
+
+        return;
+    }
+
+    if (o_fullscreen_anim1) {
+        [o_fullscreen_anim1 stopAnimation];
+    }
+    if (o_fullscreen_anim2) {
+        [o_fullscreen_anim2 stopAnimation];
+    }
+
+    [screen setFullscreenPresentationOptions];
+
+    dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
+    dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
+
+    [dict1 setObject:self forKey:NSViewAnimationTargetKey];
+    [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
+
+    [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
+    [dict2 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
+    [dict2 setObject:[NSValue valueWithRect:screen_rect] forKey:NSViewAnimationEndFrameKey];
+
+    /* Strategy with NSAnimation allocation:
+     - Keep at most 2 animation at a time
+     - leaveFullscreen/enterFullscreen are the only responsible for releasing and alloc-ing
+     */
+    o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict1]];
+    o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict2]];
+
+    [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
+    [o_fullscreen_anim1 setDuration: 0.3];
+    [o_fullscreen_anim1 setFrameRate: 30];
+    [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
+    [o_fullscreen_anim2 setDuration: 0.2];
+    [o_fullscreen_anim2 setFrameRate: 30];
+
+    [o_fullscreen_anim2 setDelegate: self];
+    [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
+
+    [o_fullscreen_anim1 startAnimation];
+    /* fullscreenAnimation will be unlocked when animation ends */
+
+    _inFullscreenTransition = YES;
+}
+
+- (void)hasBecomeFullscreen
+{
+    if ([[_videoView subviews] count] > 0)
+        [o_fullscreen_window makeFirstResponder: [[_videoView subviews] firstObject]];
+
+    [o_fullscreen_window makeKeyWindow];
+    [o_fullscreen_window setAcceptsMouseMovedEvents: YES];
+
+    /* tell the fspanel to move itself to front next time it's triggered */
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setVoutWasUpdated:o_fullscreen_window];
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive];
+
+    if ([self isVisible])
+        [self orderOut: self];
+
+    _inFullscreenTransition = NO;
+    [self setFullscreen:YES];
+}
+
+- (void)leaveFullscreenWithAnimation:(BOOL)b_animation
+{
+    NSMutableDictionary *dict1, *dict2;
+    NSRect frame;
+    BOOL blackout_other_displays = var_InheritBool(getIntf(), "macosx-black");
+
+    if (self.controlsBar)
+        [self.controlsBar setFullscreenState:NO];
+    [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:NO];
+
+    /* We always try to do so */
+    [NSScreen unblackoutScreens];
+
+    [[_videoView window] makeKeyAndOrderFront: nil];
+
+    /* Don't do anything if o_fullscreen_window is already closed */
+    if (!o_fullscreen_window) {
+        return;
+    }
+
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
+    [[o_fullscreen_window screen] setNonFullscreenPresentationOptions];
+
+    if (o_fullscreen_anim1) {
+        [o_fullscreen_anim1 stopAnimation];
+        o_fullscreen_anim1 = nil;
+    }
+    if (o_fullscreen_anim2) {
+        [o_fullscreen_anim2 stopAnimation];
+        o_fullscreen_anim2 = nil;
+    }
+
+    _inFullscreenTransition = YES;
+    [self setFullscreen:NO];
+
+    if (!b_animation) {
+        /* We don't animate if we are not visible, instead we
+         * simply fade the display */
+        CGDisplayFadeReservationToken token;
+
+        if (blackout_other_displays) {
+            CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
+            CGDisplayFade(token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
+        }
+
+        [self setAlphaValue:1.0];
+        [self orderFront: self];
+
+        /* Will release the lock */
+        [self hasEndedFullscreen];
+
+        if (blackout_other_displays) {
+            CGDisplayFade(token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
+            CGReleaseDisplayFadeReservation(token);
+        }
+
+        return;
+    }
+
+    [self setAlphaValue: 0.0];
+    [self orderFront: self];
+    [[_videoView window] orderFront: self];
+
+    frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
+    frame.origin.x += [self frame].origin.x;
+    frame.origin.y += [self frame].origin.y;
+
+    dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
+    [dict2 setObject:self forKey:NSViewAnimationTargetKey];
+    [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
+
+    o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict2]];
+
+    [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
+    [o_fullscreen_anim2 setDuration: 0.3];
+    [o_fullscreen_anim2 setFrameRate: 30];
+
+    [o_fullscreen_anim2 setDelegate: self];
+
+    dict1 = [[NSMutableDictionary alloc] initWithCapacity:3];
+
+    [dict1 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
+    [dict1 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
+    [dict1 setObject:[NSValue valueWithRect:frame] forKey:NSViewAnimationEndFrameKey];
+
+    o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict1]];
+
+    [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
+    [o_fullscreen_anim1 setDuration: 0.2];
+    [o_fullscreen_anim1 setFrameRate: 30];
+    [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
+
+    /* Make sure o_fullscreen_window is the frontmost window */
+    [o_fullscreen_window orderFront: self];
+
+    [o_fullscreen_anim1 startAnimation];
+    /* fullscreenAnimation will be unlocked when animation ends */
+}
+
+- (void)hasEndedFullscreen
+{
+    _inFullscreenTransition = NO;
+
+    /* This function is private and should be only triggered at the end of the fullscreen change animation */
+    /* Make sure we don't see the _videoView disappearing of the screen during this operation */
+    NSDisableScreenUpdates();
+    [_videoView removeFromSuperviewWithoutNeedingDisplay];
+    [[o_temp_view superview] replaceSubview:o_temp_view with:_videoView];
+    // TODO Replace tmpView by an existing view (e.g. middle view)
+    // TODO Use constraints for fullscreen window, reinstate constraints once the video view is added to the main window again
+    [_videoView setFrame:[o_temp_view frame]];
+    if ([[_videoView subviews] count] > 0)
+        [self makeFirstResponder: [[_videoView subviews] firstObject]];
+
+    [_videoView setHidden: b_video_view_was_hidden];
+
+    [self makeKeyAndOrderFront:self];
+
+    [o_fullscreen_window orderOut: self];
+    NSEnableScreenUpdates();
+
+    o_fullscreen_window = nil;
+
+    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: i_originalLevel];
+    [self setLevel:i_originalLevel];
+
+    [self setAlphaValue: config_GetFloat("macosx-opaqueness")];
+}
+
+- (void)animationDidEnd:(NSAnimation*)animation
+{
+    NSArray *viewAnimations;
+    if ([animation currentValue] < 1.0)
+        return;
+
+    /* Fullscreen ended or started (we are a delegate only for leaveFullscreen's/enterFullscren's anim2) */
+    viewAnimations = [o_fullscreen_anim2 viewAnimations];
+    if ([viewAnimations count] >=1 &&
+        [[[viewAnimations firstObject] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect]) {
+        /* Fullscreen ended */
+        [self hasEndedFullscreen];
+    } else
+    /* Fullscreen started */
+        [self hasBecomeFullscreen];
+}
+
+@end
diff --git a/modules/gui/macosx/VLCWindow.h b/modules/gui/macosx/VLCWindow.h
new file mode 100644 (file)
index 0000000..551e161
--- /dev/null
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Windows.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2012-2018 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
+ *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+/*****************************************************************************
+ * VLCWindow
+ *
+ *  Missing extension to NSWindow
+ *****************************************************************************/
+
+@class VLCVoutView;
+
+@interface VLCWindow : NSWindow <NSAnimationDelegate>
+
+@property (readwrite) BOOL canBecomeKeyWindow;
+@property (readwrite) BOOL canBecomeMainWindow;
+
+@property (nonatomic, readwrite) BOOL hasActiveVideo;
+@property (nonatomic, readwrite) BOOL fullscreen;
+
+- (void)closeAndAnimate:(BOOL)animate;
+- (void)orderFront:(id)sender animate:(BOOL)animate;
+- (void)orderOut:(id)sender animate:(BOOL)animate;
+
+- (VLCVoutView *)videoView;
+
+@end
diff --git a/modules/gui/macosx/VLCWindow.m b/modules/gui/macosx/VLCWindow.m
new file mode 100644 (file)
index 0000000..a92418f
--- /dev/null
@@ -0,0 +1,195 @@
+/*****************************************************************************
+ * Windows.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2012-2018 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
+ *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCMain.h"
+#import "VLCWindow.h"
+#import "VLCVideoWindowCommon.h"
+#import "CompatibilityFixes.h"
+
+/*****************************************************************************
+ * VLCWindow
+ *
+ *  Missing extension to NSWindow
+ *****************************************************************************/
+
+@interface VLCWindow()
+{
+    BOOL b_canBecomeKeyWindow;
+    BOOL b_isset_canBecomeKeyWindow;
+    BOOL b_canBecomeMainWindow;
+    BOOL b_isset_canBecomeMainWindow;
+}
+@end
+
+@implementation VLCWindow
+
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)styleMask
+                  backing:(NSBackingStoreType)backingType defer:(BOOL)flag
+{
+    self = [super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag];
+    if (self) {
+        /* we don't want this window to be restored on relaunch */
+        [self setRestorable:NO];
+    }
+    return self;
+}
+
+- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey
+{
+    b_isset_canBecomeKeyWindow = YES;
+    b_canBecomeKeyWindow = canBecomeKey;
+}
+
+- (BOOL)canBecomeKeyWindow
+{
+    if (b_isset_canBecomeKeyWindow)
+        return b_canBecomeKeyWindow;
+
+    return [super canBecomeKeyWindow];
+}
+
+- (void)setCanBecomeMainWindow: (BOOL)canBecomeMain
+{
+    b_isset_canBecomeMainWindow = YES;
+    b_canBecomeMainWindow = canBecomeMain;
+}
+
+- (BOOL)canBecomeMainWindow
+{
+    if (b_isset_canBecomeMainWindow)
+        return b_canBecomeMainWindow;
+
+    return [super canBecomeMainWindow];
+}
+
+- (void)closeAndAnimate:(BOOL)animate
+{
+    // No animation, just close
+    if (!animate) {
+        [super close];
+        return;
+    }
+
+    // Animate window alpha value
+    [self setAlphaValue:1.0];
+    __unsafe_unretained typeof(self) this = self;
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
+        [[NSAnimationContext currentContext] setDuration:0.9];
+        [[this animator] setAlphaValue:0.0];
+    } completionHandler:^{
+        [this close];
+    }];
+}
+
+- (void)orderOut:(id)sender animate:(BOOL)animate
+{
+    if (!animate) {
+        [super orderOut:sender];
+        return;
+    }
+
+    if ([self alphaValue] == 0.0) {
+        [super orderOut:self];
+        return;
+    }
+    __unsafe_unretained typeof(self) this = self;
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
+        [[NSAnimationContext currentContext] setDuration:0.5];
+        [[this animator] setAlphaValue:0.0];
+    } completionHandler:^{
+        [this orderOut:self];
+    }];
+}
+
+- (void)orderFront:(id)sender animate:(BOOL)animate
+{
+    if (!animate) {
+        [super orderFront:sender];
+        [self setAlphaValue:1.0];
+        return;
+    }
+
+    if (![self isVisible]) {
+        [self setAlphaValue:0.0];
+        [super orderFront:sender];
+    } else if ([self alphaValue] == 1.0) {
+        [super orderFront:self];
+        return;
+    }
+
+    [NSAnimationContext beginGrouping];
+    [[NSAnimationContext currentContext] setDuration:0.5];
+    [[self animator] setAlphaValue:1.0];
+    [NSAnimationContext endGrouping];
+}
+
+- (VLCVoutView *)videoView
+{
+    NSArray *o_subViews = [[self contentView] subviews];
+    if ([o_subViews count] > 0) {
+        id o_vout_view = [o_subViews firstObject];
+
+        if ([o_vout_view class] == [VLCVoutView class])
+            return (VLCVoutView *)o_vout_view;
+    }
+
+    return nil;
+}
+
+- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
+{
+    if (!screen)
+        screen = [self screen];
+    NSRect screenRect = [screen frame];
+    NSRect constrainedRect = [super constrainFrameRect:frameRect toScreen:screen];
+
+    /*
+     * Ugly workaround!
+     * With Mavericks, there is a nasty bug resulting in grey bars on top in fullscreen mode.
+     * It looks like this is enforced by the os because the window is in the way for the menu bar.
+     *
+     * According to the documentation, this constraining can be changed by overwriting this
+     * method. But in this situation, even the received frameRect is already contrained with the
+     * menu bars height substracted. This case is detected here, and the full height is
+     * enforced again.
+     *
+     * See #9469 and radar://15583566
+     */
+
+    BOOL b_inFullscreen = [self fullscreen] || ([self respondsToSelector:@selector(inFullscreenTransition)] && [(VLCVideoWindowCommon *)self inFullscreenTransition]);
+
+    if ((OSX_MAVERICKS_AND_HIGHER && !OSX_YOSEMITE_AND_HIGHER) &&
+        b_inFullscreen &&
+        constrainedRect.size.width == screenRect.size.width &&
+        constrainedRect.size.height != screenRect.size.height &&
+        fabs(screenRect.size.height - constrainedRect.size.height) <= 25.) {
+        msg_Dbg(getIntf(), "Contrain window height %.1f to screen height %.1f",
+                constrainedRect.size.height, screenRect.size.height);
+        constrainedRect.size.height = screenRect.size.height;
+    }
+
+    return constrainedRect;
+}
+
+@end
diff --git a/modules/gui/macosx/Windows.h b/modules/gui/macosx/Windows.h
deleted file mode 100644 (file)
index 07e698e..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*****************************************************************************
- * Windows.h: MacOS X interface module
- *****************************************************************************
- * Copyright (C) 2012-2014 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
- *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#import <Cocoa/Cocoa.h>
-
-/*****************************************************************************
- * VLCWindow
- *
- *  Missing extension to NSWindow
- *****************************************************************************/
-
-@class VLCVoutView;
-
-@interface VLCWindow : NSWindow <NSAnimationDelegate>
-
-@property (readwrite) BOOL canBecomeKeyWindow;
-@property (readwrite) BOOL canBecomeMainWindow;
-
-@property (nonatomic, readwrite) BOOL hasActiveVideo;
-@property (nonatomic, readwrite) BOOL fullscreen;
-
-- (void)closeAndAnimate:(BOOL)animate;
-- (void)orderFront:(id)sender animate:(BOOL)animate;
-- (void)orderOut:(id)sender animate:(BOOL)animate;
-
-- (VLCVoutView *)videoView;
-
-@end
-
-
-static const float f_min_video_height = 70.0;
-
-@class VLCControlsBarCommon;
-
-/*****************************************************************************
- * VLCVideoWindowCommon
- *
- *  Common code for main window, detached window and extra video window
- *****************************************************************************/
-
-@interface VLCVideoWindowCommon : VLCWindow <NSWindowDelegate, NSAnimationDelegate>
-
-@property (weak) IBOutlet NSLayoutConstraint *videoViewBottomConstraint;
-
-@property (nonatomic, weak) IBOutlet VLCVoutView* videoView;
-@property (nonatomic, weak) IBOutlet VLCControlsBarCommon* controlsBar;
-@property (readonly) BOOL inFullscreenTransition;
-@property (readonly) BOOL windowShouldExitFullscreenWhenFinished;
-@property (readwrite, assign) NSRect previousSavedFrame;
-@property (nonatomic, readwrite, assign) NSSize nativeVideoSize;
-
-- (void)setWindowLevel:(NSInteger)i_state;
-- (void)resizeWindow;
-
-- (NSRect)getWindowRectForProposedVideoViewSize:(NSSize)size;
-
-- (void)setTitle:(NSString *)title;
-
-/* fullscreen handling */
-- (void)enterFullscreenWithAnimation:(BOOL)b_animation;
-- (void)leaveFullscreenWithAnimation:(BOOL)b_animation;
-
-/* lion fullscreen handling */
-- (void)hideControlsBar;
-- (void)showControlsBar;
-
-- (void)windowWillEnterFullScreen:(NSNotification *)notification;
-- (void)windowDidEnterFullScreen:(NSNotification *)notification;
-- (void)windowWillExitFullScreen:(NSNotification *)notification;
-
-@end
diff --git a/modules/gui/macosx/Windows.m b/modules/gui/macosx/Windows.m
deleted file mode 100644 (file)
index 300c99d..0000000
+++ /dev/null
@@ -1,1010 +0,0 @@
-/*****************************************************************************
- * Windows.m: MacOS X interface module
- *****************************************************************************
- * Copyright (C) 2012-2014 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
- *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#import "Windows.h"
-#import "VLCMain.h"
-#import "VLCCoreInteraction.h"
-#import "VLCControlsBarCommon.h"
-#import "VLCVoutView.h"
-#import "CompatibilityFixes.h"
-#import "NSScreen+VLCAdditions.h"
-
-/*****************************************************************************
- * VLCWindow
- *
- *  Missing extension to NSWindow
- *****************************************************************************/
-
-@interface VLCWindow()
-{
-    BOOL b_canBecomeKeyWindow;
-    BOOL b_isset_canBecomeKeyWindow;
-    BOOL b_canBecomeMainWindow;
-    BOOL b_isset_canBecomeMainWindow;
-}
-@end
-
-@implementation VLCWindow
-
-- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)styleMask
-                  backing:(NSBackingStoreType)backingType defer:(BOOL)flag
-{
-    self = [super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag];
-    if (self) {
-        /* we don't want this window to be restored on relaunch */
-        [self setRestorable:NO];
-    }
-    return self;
-}
-
-- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey
-{
-    b_isset_canBecomeKeyWindow = YES;
-    b_canBecomeKeyWindow = canBecomeKey;
-}
-
-- (BOOL)canBecomeKeyWindow
-{
-    if (b_isset_canBecomeKeyWindow)
-        return b_canBecomeKeyWindow;
-
-    return [super canBecomeKeyWindow];
-}
-
-- (void)setCanBecomeMainWindow: (BOOL)canBecomeMain
-{
-    b_isset_canBecomeMainWindow = YES;
-    b_canBecomeMainWindow = canBecomeMain;
-}
-
-- (BOOL)canBecomeMainWindow
-{
-    if (b_isset_canBecomeMainWindow)
-        return b_canBecomeMainWindow;
-
-    return [super canBecomeMainWindow];
-}
-
-- (void)closeAndAnimate:(BOOL)animate
-{
-    // No animation, just close
-    if (!animate) {
-        [super close];
-        return;
-    }
-
-    // Animate window alpha value
-    [self setAlphaValue:1.0];
-    __unsafe_unretained typeof(self) this = self;
-    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
-        [[NSAnimationContext currentContext] setDuration:0.9];
-        [[this animator] setAlphaValue:0.0];
-    } completionHandler:^{
-        [this close];
-    }];
-}
-
-- (void)orderOut:(id)sender animate:(BOOL)animate
-{
-    if (!animate) {
-        [super orderOut:sender];
-        return;
-    }
-
-    if ([self alphaValue] == 0.0) {
-        [super orderOut:self];
-        return;
-    }
-    __unsafe_unretained typeof(self) this = self;
-    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
-        [[NSAnimationContext currentContext] setDuration:0.5];
-        [[this animator] setAlphaValue:0.0];
-    } completionHandler:^{
-        [this orderOut:self];
-    }];
-}
-
-- (void)orderFront:(id)sender animate:(BOOL)animate
-{
-    if (!animate) {
-        [super orderFront:sender];
-        [self setAlphaValue:1.0];
-        return;
-    }
-
-    if (![self isVisible]) {
-        [self setAlphaValue:0.0];
-        [super orderFront:sender];
-    } else if ([self alphaValue] == 1.0) {
-        [super orderFront:self];
-        return;
-    }
-
-    [NSAnimationContext beginGrouping];
-    [[NSAnimationContext currentContext] setDuration:0.5];
-    [[self animator] setAlphaValue:1.0];
-    [NSAnimationContext endGrouping];
-}
-
-- (VLCVoutView *)videoView
-{
-    NSArray *o_subViews = [[self contentView] subviews];
-    if ([o_subViews count] > 0) {
-        id o_vout_view = [o_subViews firstObject];
-
-        if ([o_vout_view class] == [VLCVoutView class])
-            return (VLCVoutView *)o_vout_view;
-    }
-
-    return nil;
-}
-
-- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
-{
-    if (!screen)
-        screen = [self screen];
-    NSRect screenRect = [screen frame];
-    NSRect constrainedRect = [super constrainFrameRect:frameRect toScreen:screen];
-
-    /*
-     * Ugly workaround!
-     * With Mavericks, there is a nasty bug resulting in grey bars on top in fullscreen mode.
-     * It looks like this is enforced by the os because the window is in the way for the menu bar.
-     *
-     * According to the documentation, this constraining can be changed by overwriting this
-     * method. But in this situation, even the received frameRect is already contrained with the
-     * menu bars height substracted. This case is detected here, and the full height is
-     * enforced again.
-     *
-     * See #9469 and radar://15583566
-     */
-
-    BOOL b_inFullscreen = [self fullscreen] || ([self respondsToSelector:@selector(inFullscreenTransition)] && [(VLCVideoWindowCommon *)self inFullscreenTransition]);
-
-    if((OSX_MAVERICKS_AND_HIGHER && !OSX_YOSEMITE_AND_HIGHER) && b_inFullscreen && constrainedRect.size.width == screenRect.size.width
-          && constrainedRect.size.height != screenRect.size.height
-          && fabs(screenRect.size.height - constrainedRect.size.height) <= 25.) {
-
-        msg_Dbg(getIntf(), "Contrain window height %.1f to screen height %.1f",
-                constrainedRect.size.height, screenRect.size.height);
-        constrainedRect.size.height = screenRect.size.height;
-    }
-
-    return constrainedRect;
-}
-
-@end
-
-/*****************************************************************************
- * VLCVideoWindowCommon
- *
- *  Common code for main window, detached window and extra video window
- *****************************************************************************/
-
-@interface VLCVideoWindowCommon()
-{
-    // variables for fullscreen handling
-    VLCVideoWindowCommon *o_current_video_window;
-    VLCWindow       * o_fullscreen_window;
-    NSViewAnimation * o_fullscreen_anim1;
-    NSViewAnimation * o_fullscreen_anim2;
-    NSView          * o_temp_view;
-
-    NSInteger i_originalLevel;
-
-    BOOL b_video_view_was_hidden;
-
-    NSRect frameBeforeLionFullscreen;
-}
-
-- (void)customZoom:(id)sender;
-- (void)hasBecomeFullscreen;
-- (void)hasEndedFullscreen;
-@end
-
-@implementation VLCVideoWindowCommon
-
-#pragma mark -
-#pragma mark Init
-
-- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)styleMask
-                  backing:(NSBackingStoreType)backingType defer:(BOOL)flag
-{
-    self = [super initWithContentRect:contentRect styleMask:styleMask
-                              backing:backingType defer:flag];
-
-    /* we want to be moveable regardless of our style */
-    [self setMovableByWindowBackground: YES];
-    [self setCanBecomeKeyWindow:YES];
-
-    o_temp_view = [[NSView alloc] init];
-    [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
-
-    return self;
-}
-
-- (void)awakeFromNib
-{
-    BOOL b_nativeFullscreenMode = var_InheritBool(getIntf(), "macosx-nativefullscreenmode");
-
-    if (b_nativeFullscreenMode) {
-        [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
-    } else if (OSX_EL_CAPITAN_AND_HIGHER) {
-        // Native fullscreen seems to be default on El Capitan, this disables it explicitely
-        [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
-    }
-
-    [super awakeFromNib];
-}
-
-- (void)setTitle:(NSString *)title
-{
-    if (!title || [title length] < 1)
-        return;
-
-    [super setTitle: title];
-}
-
-#pragma mark -
-#pragma mark zoom / minimize / close
-
-- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
-{
-    SEL s_menuAction = [menuItem action];
-
-    if ((s_menuAction == @selector(performClose:)) || (s_menuAction == @selector(performMiniaturize:)) || (s_menuAction == @selector(performZoom:)))
-        return YES;
-
-    return [super validateMenuItem:menuItem];
-}
-
-- (BOOL)windowShouldClose:(id)sender
-{
-    return YES;
-}
-
-- (void)performClose:(id)sender
-{
-    if (!([self styleMask] & NSTitledWindowMask)) {
-        [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowWillCloseNotification object:self];
-
-        [self close];
-    } else
-        [super performClose: sender];
-}
-
-- (void)performMiniaturize:(id)sender
-{
-    if (!([self styleMask] & NSTitledWindowMask))
-        [self miniaturize: sender];
-    else
-        [super performMiniaturize: sender];
-}
-
-- (void)performZoom:(id)sender
-{
-    if (!([self styleMask] & NSTitledWindowMask))
-        [self customZoom: sender];
-    else
-        [super performZoom: sender];
-}
-
-- (void)zoom:(id)sender
-{
-    if (!([self styleMask] & NSTitledWindowMask))
-        [self customZoom: sender];
-    else
-        [super zoom: sender];
-}
-
-/**
- * Given a proposed frame rectangle, return a modified version
- * which will fit inside the screen.
- *
- * This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
- *    Authors:  Scott Christley <scottc@net-community.com>, Venkat Ajjanagadde <venkat@ocbi.com>,
- *              Felipe A. Rodriguez <far@ix.netcom.com>, Richard Frith-Macdonald <richard@brainstorm.co.uk>
- *    Copyright (C) 1996 Free Software Foundation, Inc.
- */
-- (NSRect) customConstrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
-{
-    NSRect screenRect = [screen visibleFrame];
-    CGFloat difference;
-
-    /* Move top edge of the window inside the screen */
-    difference = NSMaxY (frameRect) - NSMaxY (screenRect);
-    if (difference > 0) {
-        frameRect.origin.y -= difference;
-    }
-
-    /* If the window is resizable, resize it (if needed) so that the
-     bottom edge is on the screen or can be on the screen when the user moves
-     the window */
-    difference = NSMaxY (screenRect) - NSMaxY (frameRect);
-    if (self.styleMask & NSResizableWindowMask) {
-        CGFloat difference2;
-
-        difference2 = screenRect.origin.y - frameRect.origin.y;
-        difference2 -= difference;
-        // Take in account the space between the top of window and the top of the
-        // screen which can be used to move the bottom of the window on the screen
-        if (difference2 > 0) {
-            frameRect.size.height -= difference2;
-            frameRect.origin.y += difference2;
-        }
-
-        /* Ensure that resizing doesn't makewindow smaller than minimum */
-        difference2 = [self minSize].height - frameRect.size.height;
-        if (difference2 > 0) {
-            frameRect.size.height += difference2;
-            frameRect.origin.y -= difference2;
-        }
-    }
-
-    return frameRect;
-}
-
-#define DIST 3
-
-/**
- Zooms the receiver.   This method calls the delegate method
- windowShouldZoom:toFrame: to determine if the window should
- be allowed to zoom to full screen.
- *
- * This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
- *    Authors:  Scott Christley <scottc@net-community.com>, Venkat Ajjanagadde <venkat@ocbi.com>,
- *              Felipe A. Rodriguez <far@ix.netcom.com>, Richard Frith-Macdonald <richard@brainstorm.co.uk>
- *    Copyright (C) 1996 Free Software Foundation, Inc.
- */
-- (void) customZoom: (id)sender
-{
-    NSRect maxRect = [[self screen] visibleFrame];
-    NSRect currentFrame = [self frame];
-
-    if ([[self delegate] respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)]) {
-        maxRect = [[self delegate] windowWillUseStandardFrame: self defaultFrame: maxRect];
-    }
-
-    maxRect = [self customConstrainFrameRect: maxRect toScreen: [self screen]];
-
-    // Compare the new frame with the current one
-    if ((fabs(NSMaxX(maxRect) - NSMaxX(currentFrame)) < DIST)
-        && (fabs(NSMaxY(maxRect) - NSMaxY(currentFrame)) < DIST)
-        && (fabs(NSMinX(maxRect) - NSMinX(currentFrame)) < DIST)
-        && (fabs(NSMinY(maxRect) - NSMinY(currentFrame)) < DIST)) {
-        // Already in zoomed mode, reset user frame, if stored
-        if ([self frameAutosaveName] != nil) {
-            [self setFrame: self.previousSavedFrame display: YES animate: YES];
-            [self saveFrameUsingName: [self frameAutosaveName]];
-        }
-        return;
-    }
-
-    if ([self frameAutosaveName] != nil) {
-        [self saveFrameUsingName: [self frameAutosaveName]];
-        self.previousSavedFrame = [self frame];
-    }
-
-    [self setFrame: maxRect display: YES animate: YES];
-}
-
-#pragma mark -
-#pragma mark Video window resizing logic
-
-- (void)setWindowLevel:(NSInteger)i_state
-{
-    if (var_InheritBool(getIntf(), "video-wallpaper") || [self level] < NSNormalWindowLevel)
-        return;
-
-    if (!self.fullscreen && !_inFullscreenTransition)
-        [self setLevel: i_state];
-
-    // save it for restore if window is currently minimized or in fullscreen
-    i_originalLevel = i_state;
-}
-
-- (NSRect)getWindowRectForProposedVideoViewSize:(NSSize)size
-{
-    NSSize windowMinSize = [self minSize];
-    NSRect screenFrame = [[self screen] visibleFrame];
-
-    NSRect topleftbase = NSMakeRect(0, [self frame].size.height, 0, 0);
-    NSPoint topleftscreen = [self convertRectToScreen: topleftbase].origin;
-
-    CGFloat f_width = size.width;
-    CGFloat f_height = size.height;
-    if (f_width < windowMinSize.width)
-        f_width = windowMinSize.width;
-    if (f_height < f_min_video_height)
-        f_height = f_min_video_height;
-
-    /* Calculate the window's new size */
-    NSRect new_frame;
-    new_frame.size.width = [self frame].size.width - [_videoView frame].size.width + f_width;
-    new_frame.size.height = [self frame].size.height - [_videoView frame].size.height + f_height;
-    new_frame.origin.x = topleftscreen.x;
-    new_frame.origin.y = topleftscreen.y - new_frame.size.height;
-
-    /* make sure the window doesn't exceed the screen size the window is on */
-    if (new_frame.size.width > screenFrame.size.width) {
-        new_frame.size.width = screenFrame.size.width;
-        new_frame.origin.x = screenFrame.origin.x;
-    }
-    if (new_frame.size.height > screenFrame.size.height) {
-        new_frame.size.height = screenFrame.size.height;
-        new_frame.origin.y = screenFrame.origin.y;
-    }
-    if (new_frame.origin.y < screenFrame.origin.y)
-        new_frame.origin.y = screenFrame.origin.y;
-
-    CGFloat right_screen_point = screenFrame.origin.x + screenFrame.size.width;
-    CGFloat right_window_point = new_frame.origin.x + new_frame.size.width;
-    if (right_window_point > right_screen_point)
-        new_frame.origin.x -= (right_window_point - right_screen_point);
-
-    return new_frame;
-}
-
-- (void)resizeWindow
-{
-    // VOUT_WINDOW_SET_SIZE is triggered when exiting fullscreen. This event is ignored here
-    // to avoid interference with the animation.
-    if ([self fullscreen] || _inFullscreenTransition)
-        return;
-
-    NSRect window_rect = [self getWindowRectForProposedVideoViewSize:self.nativeVideoSize];
-    [[self animator] setFrame:window_rect display:YES];
-}
-
-- (void)setNativeVideoSize:(NSSize)size
-{
-    _nativeVideoSize = size;
-
-    if (var_InheritBool(getIntf(), "macosx-video-autoresize") && !var_InheritBool(getIntf(), "video-wallpaper"))
-        [self resizeWindow];
-}
-
-- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
-{
-    if (![[VLCMain sharedInstance] activeVideoPlayback] || self.nativeVideoSize.width == 0. || self.nativeVideoSize.height == 0. || window != self)
-        return proposedFrameSize;
-
-    // needed when entering lion fullscreen mode
-    if (_inFullscreenTransition || [self fullscreen])
-        return proposedFrameSize;
-
-    if ([_videoView isHidden])
-        return proposedFrameSize;
-
-    if ([[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]) {
-        NSRect videoWindowFrame = [self frame];
-        NSRect viewRect = [_videoView convertRect:[_videoView bounds] toView: nil];
-        NSRect contentRect = [self contentRectForFrameRect:videoWindowFrame];
-        CGFloat marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
-        CGFloat marginx = contentRect.size.width - viewRect.size.width;
-
-        proposedFrameSize.height = (proposedFrameSize.width - marginx) * self.nativeVideoSize.height / self.nativeVideoSize.width + marginy;
-    }
-
-    return proposedFrameSize;
-}
-
-- (void)windowWillMiniaturize:(NSNotification *)notification
-{
-    // Set level to normal as a workaround for Mavericks bug causing window
-    // to vanish from screen, see radar://15473716
-    i_originalLevel = [self level];
-    [self setLevel: NSNormalWindowLevel];
-}
-
-- (void)windowDidDeminiaturize:(NSNotification *)notification
-{
-    [self setLevel: i_originalLevel];
-}
-
-#pragma mark -
-#pragma mark Lion native fullscreen handling
-
-- (void)hideControlsBar
-{
-    [[self.controlsBar bottomBarView] setHidden: YES];
-    self.videoViewBottomConstraint.priority = 1;
-}
-
-- (void)showControlsBar
-{
-    [[self.controlsBar bottomBarView] setHidden: NO];
-    self.videoViewBottomConstraint.priority = 999;
-}
-
-- (void)becomeKeyWindow
-{
-    [super becomeKeyWindow];
-
-    // change fspanel state for the case when multiple windows are in fullscreen
-    if ([self hasActiveVideo] && [self fullscreen])
-        [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive];
-    else
-        [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
-}
-
-- (void)resignKeyWindow
-{
-    [super resignKeyWindow];
-
-    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
-}
-
--(NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow *)window
-{
-    if (window == self) {
-        return [NSArray arrayWithObject:window];
-    }
-
-    return nil;
-}
-
-- (NSArray*)customWindowsToExitFullScreenForWindow:(NSWindow*)window
-{
-    if (window == self) {
-        return [NSArray arrayWithObject:window];
-    }
-
-    return nil;
-}
-
-- (void)window:window startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration
-{
-    [window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
-
-    NSScreen *screen = [window screen];
-    NSRect screenFrame = [screen frame];
-
-    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
-        [context setDuration:0.5 * duration];
-        [[window animator] setFrame:screenFrame display:YES];
-    } completionHandler:nil];
-}
-
-- (void)window:window startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration
-{
-    [window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
-    [[window animator] setFrame:frameBeforeLionFullscreen display:YES animate:YES];
-
-    [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
-        [context setDuration:0.5 * duration];
-        [[window animator] setFrame:frameBeforeLionFullscreen display:YES animate:YES];
-    } completionHandler:nil];
-}
-
-- (void)windowWillEnterFullScreen:(NSNotification *)notification
-{
-    _windowShouldExitFullscreenWhenFinished = [[VLCMain sharedInstance] activeVideoPlayback];
-
-    NSInteger i_currLevel = [self level];
-    // self.fullscreen and _inFullscreenTransition must not be true yet
-    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
-    [self setLevel:NSNormalWindowLevel];
-    i_originalLevel = i_currLevel;
-
-    _inFullscreenTransition = YES;
-
-    var_SetBool(pl_Get(getIntf()), "fullscreen", true);
-
-    frameBeforeLionFullscreen = [self frame];
-
-    if ([self hasActiveVideo]) {
-        vout_thread_t *p_vout = getVoutForActiveWindow();
-        if (p_vout) {
-            var_SetBool(p_vout, "fullscreen", true);
-            vlc_object_release(p_vout);
-        }
-    }
-
-    if (![_videoView isHidden]) {
-        [self hideControlsBar];
-    }
-
-    [self setMovableByWindowBackground: NO];
-}
-
-- (void)windowDidEnterFullScreen:(NSNotification *)notification
-{
-    // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
-    // But this creates some problems when leaving fs over remote intfs, so activate app here.
-    [NSApp activateIgnoringOtherApps:YES];
-
-    [self setFullscreen: YES];
-    _inFullscreenTransition = NO;
-
-    if ([self hasActiveVideo]) {
-        [[[[VLCMain sharedInstance] mainWindow] fspanel] setVoutWasUpdated:self];
-        if (![_videoView isHidden])
-            [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive];
-    }
-
-    NSArray *subviews = [[self videoView] subviews];
-    NSUInteger count = [subviews count];
-
-    for (NSUInteger x = 0; x < count; x++) {
-        if ([[subviews objectAtIndex:x] respondsToSelector:@selector(reshape)])
-            [[subviews objectAtIndex:x] reshape];
-    }
-}
-
-- (void)windowWillExitFullScreen:(NSNotification *)notification
-{
-    _inFullscreenTransition = YES;
-    [self setFullscreen: NO];
-
-    if ([self hasActiveVideo]) {
-        var_SetBool(pl_Get(getIntf()), "fullscreen", false);
-
-        vout_thread_t *p_vout = getVoutForActiveWindow();
-        if (p_vout) {
-            var_SetBool(p_vout, "fullscreen", false);
-            vlc_object_release(p_vout);
-        }
-    }
-
-    [NSCursor setHiddenUntilMouseMoves: NO];
-    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
-
-    if (![_videoView isHidden]) {
-        [self showControlsBar];
-    }
-
-    [self setMovableByWindowBackground: YES];
-}
-
-- (void)windowDidExitFullScreen:(NSNotification *)notification
-{
-    _inFullscreenTransition = NO;
-
-    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: i_originalLevel];
-    [self setLevel:i_originalLevel];
-}
-
-#pragma mark -
-#pragma mark Fullscreen Logic
-
-- (void)enterFullscreenWithAnimation:(BOOL)b_animation
-{
-    NSMutableDictionary *dict1, *dict2;
-    NSScreen *screen;
-    NSRect screen_rect;
-    NSRect rect;
-    BOOL blackout_other_displays = var_InheritBool(getIntf(), "macosx-black");
-
-    screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(getIntf(), "macosx-vdev")];
-
-    if (!screen) {
-        msg_Dbg(getIntf(), "chosen screen isn't present, using current screen for fullscreen mode");
-        screen = [self screen];
-    }
-    if (!screen) {
-        msg_Dbg(getIntf(), "Using deepest screen");
-        screen = [NSScreen deepestScreen];
-    }
-
-    screen_rect = [screen frame];
-
-    if (self.controlsBar)
-        [self.controlsBar setFullscreenState:YES];
-    [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:YES];
-
-    if (blackout_other_displays)
-        [screen blackoutOtherScreens];
-
-    /* Make sure we don't see the window flashes in float-on-top mode */
-    NSInteger i_currLevel = [self level];
-    // self.fullscreen must not be true yet
-    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
-    [self setLevel:NSNormalWindowLevel];
-    i_originalLevel = i_currLevel; // would be overwritten by previous call
-
-    /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
-    if (!o_fullscreen_window) {
-        /* We can't change the styleMask of an already created NSWindow, so we create another window, and do eye catching stuff */
-
-        rect = [[_videoView superview] convertRect: [_videoView frame] toView: nil]; /* Convert to Window base coord */
-        rect.origin.x += [self frame].origin.x;
-        rect.origin.y += [self frame].origin.y;
-        o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
-        [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
-        [o_fullscreen_window setCanBecomeKeyWindow: YES];
-        [o_fullscreen_window setCanBecomeMainWindow: YES];
-        [o_fullscreen_window setHasActiveVideo: YES];
-        [o_fullscreen_window setFullscreen: YES];
-
-        /* Make sure video view gets visible in case the playlist was visible before */
-        b_video_view_was_hidden = [_videoView isHidden];
-        [_videoView setHidden: NO];
-        _videoView.translatesAutoresizingMaskIntoConstraints = YES;
-
-        if (!b_animation) {
-            /* We don't animate if we are not visible, instead we
-             * simply fade the display */
-            CGDisplayFadeReservationToken token;
-
-            if (blackout_other_displays) {
-                CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
-                CGDisplayFade(token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
-            }
-
-            NSDisableScreenUpdates();
-            [[_videoView superview] replaceSubview:_videoView with:o_temp_view];
-            [o_temp_view setFrame:[_videoView frame]];
-            [[o_fullscreen_window contentView] addSubview:_videoView];
-            [_videoView setFrame: [[o_fullscreen_window contentView] frame]];
-            [_videoView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
-            NSEnableScreenUpdates();
-
-            [screen setFullscreenPresentationOptions];
-
-            [o_fullscreen_window setFrame:screen_rect display:YES animate:NO];
-
-            [o_fullscreen_window orderFront:self animate:YES];
-
-            [o_fullscreen_window setLevel:NSNormalWindowLevel];
-
-            if (blackout_other_displays) {
-                CGDisplayFade(token, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
-                CGReleaseDisplayFadeReservation(token);
-            }
-
-            /* Will release the lock */
-            [self hasBecomeFullscreen];
-
-            return;
-        }
-
-        /* Make sure we don't see the _videoView disappearing of the screen during this operation */
-        NSDisableScreenUpdates();
-        [[_videoView superview] replaceSubview:_videoView with:o_temp_view];
-        [o_temp_view setFrame:[_videoView frame]];
-        [[o_fullscreen_window contentView] addSubview:_videoView];
-        [_videoView setFrame: [[o_fullscreen_window contentView] frame]];
-        [_videoView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
-
-        [o_fullscreen_window makeKeyAndOrderFront:self];
-        NSEnableScreenUpdates();
-    }
-
-    /* We are in fullscreen (and no animation is running) */
-    if ([self fullscreen]) {
-        /* Make sure we are hidden */
-        [self orderOut: self];
-
-        return;
-    }
-
-    if (o_fullscreen_anim1) {
-        [o_fullscreen_anim1 stopAnimation];
-    }
-    if (o_fullscreen_anim2) {
-        [o_fullscreen_anim2 stopAnimation];
-    }
-
-    [screen setFullscreenPresentationOptions];
-
-    dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
-    dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
-
-    [dict1 setObject:self forKey:NSViewAnimationTargetKey];
-    [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
-
-    [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
-    [dict2 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
-    [dict2 setObject:[NSValue valueWithRect:screen_rect] forKey:NSViewAnimationEndFrameKey];
-
-    /* Strategy with NSAnimation allocation:
-     - Keep at most 2 animation at a time
-     - leaveFullscreen/enterFullscreen are the only responsible for releasing and alloc-ing
-     */
-    o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict1]];
-    o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict2]];
-
-    [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
-    [o_fullscreen_anim1 setDuration: 0.3];
-    [o_fullscreen_anim1 setFrameRate: 30];
-    [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
-    [o_fullscreen_anim2 setDuration: 0.2];
-    [o_fullscreen_anim2 setFrameRate: 30];
-
-    [o_fullscreen_anim2 setDelegate: self];
-    [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
-
-    [o_fullscreen_anim1 startAnimation];
-    /* fullscreenAnimation will be unlocked when animation ends */
-
-    _inFullscreenTransition = YES;
-}
-
-- (void)hasBecomeFullscreen
-{
-    if ([[_videoView subviews] count] > 0)
-        [o_fullscreen_window makeFirstResponder: [[_videoView subviews] firstObject]];
-
-    [o_fullscreen_window makeKeyWindow];
-    [o_fullscreen_window setAcceptsMouseMovedEvents: YES];
-
-    /* tell the fspanel to move itself to front next time it's triggered */
-    [[[[VLCMain sharedInstance] mainWindow] fspanel] setVoutWasUpdated:o_fullscreen_window];
-    [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive];
-
-    if ([self isVisible])
-        [self orderOut: self];
-
-    _inFullscreenTransition = NO;
-    [self setFullscreen:YES];
-}
-
-- (void)leaveFullscreenWithAnimation:(BOOL)b_animation
-{
-    NSMutableDictionary *dict1, *dict2;
-    NSRect frame;
-    BOOL blackout_other_displays = var_InheritBool(getIntf(), "macosx-black");
-
-    if (self.controlsBar)
-        [self.controlsBar setFullscreenState:NO];
-    [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:NO];
-
-    /* We always try to do so */
-    [NSScreen unblackoutScreens];
-
-    [[_videoView window] makeKeyAndOrderFront: nil];
-
-    /* Don't do anything if o_fullscreen_window is already closed */
-    if (!o_fullscreen_window) {
-        return;
-    }
-
-    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive];
-    [[o_fullscreen_window screen] setNonFullscreenPresentationOptions];
-
-    if (o_fullscreen_anim1) {
-        [o_fullscreen_anim1 stopAnimation];
-        o_fullscreen_anim1 = nil;
-    }
-    if (o_fullscreen_anim2) {
-        [o_fullscreen_anim2 stopAnimation];
-        o_fullscreen_anim2 = nil;
-    }
-
-    _inFullscreenTransition = YES;
-    [self setFullscreen:NO];
-
-    if (!b_animation) {
-        /* We don't animate if we are not visible, instead we
-         * simply fade the display */
-        CGDisplayFadeReservationToken token;
-
-        if (blackout_other_displays) {
-            CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
-            CGDisplayFade(token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
-        }
-
-        [self setAlphaValue:1.0];
-        [self orderFront: self];
-
-        /* Will release the lock */
-        [self hasEndedFullscreen];
-
-        if (blackout_other_displays) {
-            CGDisplayFade(token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
-            CGReleaseDisplayFadeReservation(token);
-        }
-
-        return;
-    }
-
-    [self setAlphaValue: 0.0];
-    [self orderFront: self];
-    [[_videoView window] orderFront: self];
-
-    frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
-    frame.origin.x += [self frame].origin.x;
-    frame.origin.y += [self frame].origin.y;
-
-    dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
-    [dict2 setObject:self forKey:NSViewAnimationTargetKey];
-    [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
-
-    o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict2]];
-
-    [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
-    [o_fullscreen_anim2 setDuration: 0.3];
-    [o_fullscreen_anim2 setFrameRate: 30];
-
-    [o_fullscreen_anim2 setDelegate: self];
-
-    dict1 = [[NSMutableDictionary alloc] initWithCapacity:3];
-
-    [dict1 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
-    [dict1 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
-    [dict1 setObject:[NSValue valueWithRect:frame] forKey:NSViewAnimationEndFrameKey];
-
-    o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict1]];
-
-    [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
-    [o_fullscreen_anim1 setDuration: 0.2];
-    [o_fullscreen_anim1 setFrameRate: 30];
-    [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
-
-    /* Make sure o_fullscreen_window is the frontmost window */
-    [o_fullscreen_window orderFront: self];
-
-    [o_fullscreen_anim1 startAnimation];
-    /* fullscreenAnimation will be unlocked when animation ends */
-}
-
-- (void)hasEndedFullscreen
-{
-    _inFullscreenTransition = NO;
-
-    /* This function is private and should be only triggered at the end of the fullscreen change animation */
-    /* Make sure we don't see the _videoView disappearing of the screen during this operation */
-    NSDisableScreenUpdates();
-    [_videoView removeFromSuperviewWithoutNeedingDisplay];
-    [[o_temp_view superview] replaceSubview:o_temp_view with:_videoView];
-    // TODO Replace tmpView by an existing view (e.g. middle view)
-    // TODO Use constraints for fullscreen window, reinstate constraints once the video view is added to the main window again
-    [_videoView setFrame:[o_temp_view frame]];
-    if ([[_videoView subviews] count] > 0)
-        [self makeFirstResponder: [[_videoView subviews] firstObject]];
-
-    [_videoView setHidden: b_video_view_was_hidden];
-
-    [self makeKeyAndOrderFront:self];
-
-    [o_fullscreen_window orderOut: self];
-    NSEnableScreenUpdates();
-
-    o_fullscreen_window = nil;
-
-    [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: i_originalLevel];
-    [self setLevel:i_originalLevel];
-
-    [self setAlphaValue: config_GetFloat("macosx-opaqueness")];
-}
-
-- (void)animationDidEnd:(NSAnimation*)animation
-{
-    NSArray *viewAnimations;
-    if ([animation currentValue] < 1.0)
-        return;
-
-    /* Fullscreen ended or started (we are a delegate only for leaveFullscreen's/enterFullscren's anim2) */
-    viewAnimations = [o_fullscreen_anim2 viewAnimations];
-    if ([viewAnimations count] >=1 &&
-        [[[viewAnimations firstObject] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect]) {
-        /* Fullscreen ended */
-        [self hasEndedFullscreen];
-    } else
-    /* Fullscreen started */
-        [self hasBecomeFullscreen];
-}
-
-@end
index 96b9f67..d8537d7 100644 (file)
@@ -552,6 +552,8 @@ modules/gui/macosx/VLCUIWidgets.h
 modules/gui/macosx/VLCUIWidgets.m
 modules/gui/macosx/VLCVideoEffectsWindowController.h
 modules/gui/macosx/VLCVideoEffectsWindowController.m
+modules/gui/macosx/VLCVideoWindowCommon.h
+modules/gui/macosx/VLCVideoWindowCommon.m
 modules/gui/macosx/VLCVolumeSlider.h
 modules/gui/macosx/VLCVolumeSlider.m
 modules/gui/macosx/VLCVolumeSliderCell.h
@@ -560,10 +562,10 @@ modules/gui/macosx/VLCVoutView.h
 modules/gui/macosx/VLCVoutView.m
 modules/gui/macosx/VLCVideoOutputProvider.h
 modules/gui/macosx/VLCVideoOutputProvider.m
+modules/gui/macosx/VLCWindow.h
+modules/gui/macosx/VLCWindow.m
 modules/gui/macosx/VLCWrappableTextField.h
 modules/gui/macosx/VLCWrappableTextField.m
-modules/gui/macosx/Windows.h
-modules/gui/macosx/Windows.m
 modules/gui/macosx/applescript.h
 modules/gui/macosx/applescript.m
 modules/gui/macosx/helpers.h