[vlc-commits] macosx: split windows file to have one class per file

Felix Paul Kühne git at videolan.org
Sun Jun 10 13:45:03 CEST 2018


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Jun 10 11:36:51 2018 +0200| [126fb1184cbc3e9716a903655f71fe45b85d2fb6] | committer: Felix Paul Kühne

macosx: split windows file to have one class per file

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=126fb1184cbc3e9716a903655f71fe45b85d2fb6
---

 .../package/macosx/VLC.xcodeproj/project.pbxproj   |  30 +++-
 modules/gui/macosx/Makefile.am                     |   3 +-
 modules/gui/macosx/VLCFSPanelController.h          |   2 +-
 modules/gui/macosx/VLCMainWindow.h                 |   2 +-
 .../macosx/{Windows.h => VLCVideoWindowCommon.h}   |  26 +--
 .../macosx/{Windows.m => VLCVideoWindowCommon.m}   | 174 +-----------------
 modules/gui/macosx/VLCWindow.h                     |  49 ++++++
 modules/gui/macosx/VLCWindow.m                     | 195 +++++++++++++++++++++
 po/POTFILES.in                                     |   6 +-
 9 files changed, 280 insertions(+), 207 deletions(-)

diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index fe0ee17e5f..595a93fb52 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -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 */; };
@@ -113,6 +112,8 @@
 		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 */; };
@@ -395,6 +396,10 @@
 		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>"; };
@@ -517,8 +522,6 @@
 		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 */
@@ -918,9 +921,21 @@
 			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 */,
@@ -1122,8 +1137,6 @@
 		7D349C9B20CBC8A6003359A1 /* Class Extensions */ = {
 			isa = PBXGroup;
 			children = (
-				E06CF7F416020F6200C698B7 /* Windows.h */,
-				E06CF7F516020F6200C698B7 /* Windows.m */,
 				6B4D50A51E7AB52C004479B5 /* NSScreen+VLCAdditions.h */,
 				6B4D50A61E7AB52C004479B5 /* NSScreen+VLCAdditions.m */,
 				6B4D50941E7A7D16004479B5 /* NSSound+VLCAdditions.h */,
@@ -1483,7 +1496,7 @@
 					};
 				};
 			};
-			buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */;
+			buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */;
 			compatibilityVersion = "Xcode 6.3";
 			developmentRegion = English;
 			hasScannedForEncodings = 1;
@@ -1539,7 +1552,6 @@
 				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 */,
@@ -1558,6 +1570,7 @@
 				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 */,
@@ -1603,6 +1616,7 @@
 				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 */,
@@ -1863,7 +1877,7 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Default;
 		};
-		C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */ = {
+		C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
 				C2F2A6EB09588F1B00018C74 /* Development */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index ace16e1aca..e10209ff49 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -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 \
diff --git a/modules/gui/macosx/VLCFSPanelController.h b/modules/gui/macosx/VLCFSPanelController.h
index 5b86759b0b..78366fd146 100644
--- a/modules/gui/macosx/VLCFSPanelController.h
+++ b/modules/gui/macosx/VLCFSPanelController.h
@@ -26,7 +26,7 @@
 
 #import <Cocoa/Cocoa.h>
 
-#import "Windows.h"
+#import "VLCWindow.h"
 #import "VLCDefaultValueSlider.h"
 #import "VLCTimeField.h"
 
diff --git a/modules/gui/macosx/VLCMainWindow.h b/modules/gui/macosx/VLCMainWindow.h
index ae7fce903d..b9bd614444 100644
--- a/modules/gui/macosx/VLCMainWindow.h
+++ b/modules/gui/macosx/VLCMainWindow.h
@@ -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/Windows.h b/modules/gui/macosx/VLCVideoWindowCommon.h
similarity index 80%
rename from modules/gui/macosx/Windows.h
rename to modules/gui/macosx/VLCVideoWindowCommon.h
index 07e698ecff..8d18a3b6e4 100644
--- a/modules/gui/macosx/Windows.h
+++ b/modules/gui/macosx/VLCVideoWindowCommon.h
@@ -23,36 +23,14 @@
  *****************************************************************************/
 
 #import <Cocoa/Cocoa.h>
-
-/*****************************************************************************
- * VLCWindow
- *
- *  Missing extension to NSWindow
- *****************************************************************************/
+#import "VLCWindow.h"
 
 @class VLCVoutView;
 
- at interface VLCWindow : NSWindow <NSAnimationDelegate>
-
- at property (readwrite) BOOL canBecomeKeyWindow;
- at property (readwrite) BOOL canBecomeMainWindow;
-
- at property (nonatomic, readwrite) BOOL hasActiveVideo;
- at 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;
-
- at end
-
+ at class VLCControlsBarCommon;
 
 static const float f_min_video_height = 70.0;
 
- at class VLCControlsBarCommon;
-
 /*****************************************************************************
  * VLCVideoWindowCommon
  *
diff --git a/modules/gui/macosx/Windows.m b/modules/gui/macosx/VLCVideoWindowCommon.m
similarity index 85%
rename from modules/gui/macosx/Windows.m
rename to modules/gui/macosx/VLCVideoWindowCommon.m
index 300c99d108..6a7e47ad16 100644
--- a/modules/gui/macosx/Windows.m
+++ b/modules/gui/macosx/VLCVideoWindowCommon.m
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * Windows.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2012-2014 VLC authors and VideoLAN
+ * Copyright (C) 2012-2018 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
@@ -22,181 +22,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#import "Windows.h"
 #import "VLCMain.h"
+#import "VLCVideoWindowCommon.h"
+#import "CompatibilityFixes.h"
 #import "VLCCoreInteraction.h"
 #import "VLCControlsBarCommon.h"
-#import "VLCVoutView.h"
-#import "CompatibilityFixes.h"
+#import "VLCMainWindow.h"
 #import "NSScreen+VLCAdditions.h"
 
 /*****************************************************************************
- * VLCWindow
- *
- *  Missing extension to NSWindow
- *****************************************************************************/
-
- at interface VLCWindow()
-{
-    BOOL b_canBecomeKeyWindow;
-    BOOL b_isset_canBecomeKeyWindow;
-    BOOL b_canBecomeMainWindow;
-    BOOL b_isset_canBecomeMainWindow;
-}
- at end
-
- at 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;
-}
-
- at end
-
-/*****************************************************************************
  * VLCVideoWindowCommon
  *
  *  Common code for main window, detached window and extra video window
diff --git a/modules/gui/macosx/VLCWindow.h b/modules/gui/macosx/VLCWindow.h
new file mode 100644
index 0000000000..551e161c65
--- /dev/null
+++ b/modules/gui/macosx/VLCWindow.h
@@ -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
+ *****************************************************************************/
+
+ at class VLCVoutView;
+
+ at interface VLCWindow : NSWindow <NSAnimationDelegate>
+
+ at property (readwrite) BOOL canBecomeKeyWindow;
+ at property (readwrite) BOOL canBecomeMainWindow;
+
+ at property (nonatomic, readwrite) BOOL hasActiveVideo;
+ at 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;
+
+ at end
diff --git a/modules/gui/macosx/VLCWindow.m b/modules/gui/macosx/VLCWindow.m
new file mode 100644
index 0000000000..a92418f166
--- /dev/null
+++ b/modules/gui/macosx/VLCWindow.m
@@ -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
+ *****************************************************************************/
+
+ at interface VLCWindow()
+{
+    BOOL b_canBecomeKeyWindow;
+    BOOL b_isset_canBecomeKeyWindow;
+    BOOL b_canBecomeMainWindow;
+    BOOL b_isset_canBecomeMainWindow;
+}
+ at end
+
+ at 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;
+}
+
+ at end
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 96b9f67617..d8537d7e7b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -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



More information about the vlc-commits mailing list