macosx: remove VLCMainWindow singleton
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Tue, 11 Aug 2015 10:44:49 +0000 (12:44 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Tue, 11 Aug 2015 18:17:56 +0000 (20:17 +0200)
modules/gui/macosx/AddonsWindowController.m
modules/gui/macosx/MainMenu.m
modules/gui/macosx/MainWindow.h
modules/gui/macosx/MainWindow.m
modules/gui/macosx/VLCVoutWindowController.m
modules/gui/macosx/VideoView.m
modules/gui/macosx/Windows.m

index f590f01..ceabb5d 100644 (file)
@@ -241,7 +241,7 @@ static void addonsEventsCallback( const vlc_event_t *event, void *data )
 {
     [self _refactorDataModel];
     if (_shouldRefreshSideBarOnAddonChange) {
-        [[VLCMainWindow sharedInstance] performSelector:@selector(reloadSidebar) withObject:nil afterDelay:0.5];
+        [[[VLCMain sharedInstance] mainWindow] performSelector:@selector(reloadSidebar) withObject:nil afterDelay:0.5];
         _shouldRefreshSideBarOnAddonChange = NO;
     }
 }
index 9f3c855..2f3400a 100644 (file)
 
 - (IBAction)showMainWindow:(id)sender
 {
-    [[VLCMainWindow sharedInstance] makeKeyAndOrderFront:sender];
+    [[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:sender];
 }
 
 - (IBAction)showPlaylist:(id)sender
 {
-    [[VLCMainWindow sharedInstance] changePlaylistState: psUserMenuEvent];
+    [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psUserMenuEvent];
 }
 
 #pragma mark - Help and Docs
index 7a2a188..63b197a 100644 (file)
@@ -83,7 +83,7 @@ typedef enum {
     IBOutlet id o_podcast_unsubscribe_ok_btn;
     IBOutlet id o_podcast_unsubscribe_cancel_btn;
 }
-+ (VLCMainWindow *)sharedInstance;
+
 @property (readonly) BOOL nativeFullscreenMode;
 @property (readwrite) BOOL nonembedded;
 
index fbf60bb..73f54dc 100644 (file)
@@ -80,29 +80,6 @@ static const float f_min_window_height = 307.;
 #pragma mark -
 #pragma mark Initialization
 
-static VLCMainWindow *sharedInstance = nil;
-+ (VLCMainWindow *)sharedInstance
-{
-    return sharedInstance;
-}
-
-- (id)initWithContentRect:(NSRect)contentRect
-                styleMask:(NSUInteger)styleMask
-                  backing:(NSBackingStoreType)backingType
-                    defer:(BOOL)flag
-{
-    static dispatch_once_t pred;
-
-    dispatch_once(&pred, ^{
-        sharedInstance = [super initWithContentRect:contentRect
-                                          styleMask:styleMask
-                                            backing:backingType
-                                              defer:flag];
-    });
-
-    return sharedInstance;
-}
-
 - (BOOL)isEvent:(NSEvent *)o_event forKey:(const char *)keyString
 {
     char *key;
index 924d72f..a23653b 100644 (file)
@@ -250,7 +250,7 @@ void WindowClose(vout_window_t *p_wnd)
 
     // should be called before any window resizing occurs
     if (!b_multiple_vout_windows)
-        [[VLCMainWindow sharedInstance] videoplayWillBeStarted];
+        [[[VLCMain sharedInstance] mainWindow] videoplayWillBeStarted];
 
     if (b_multiple_vout_windows && b_video_wallpaper)
         b_video_wallpaper = false;
@@ -262,13 +262,13 @@ void WindowClose(vout_window_t *p_wnd)
         msg_Dbg(VLCIntf, "Creating background / blank window");
         NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")];
         if (!screen)
-            screen = [[VLCMainWindow sharedInstance] screen];
+            screen = [[[VLCMain sharedInstance] mainWindow] screen];
 
         NSRect window_rect;
         if (b_video_wallpaper)
             window_rect = [screen frame];
         else
-            window_rect = [[VLCMainWindow sharedInstance] frame];
+            window_rect = [[[VLCMain sharedInstance] mainWindow] frame];
 
         NSUInteger mask = NSBorderlessWindowMask;
         if (!b_video_deco)
@@ -312,7 +312,7 @@ void WindowClose(vout_window_t *p_wnd)
     } else {
         if ((var_InheritBool(VLCIntf, "embedded-video") && !b_mainwindow_has_video)) {
             // setup embedded video
-            o_new_video_window = [VLCMainWindow sharedInstance];
+            o_new_video_window = [[VLCMain sharedInstance] mainWindow] ;
             o_vout_view = [o_new_video_window videoView];
             b_mainwindow_has_video = YES;
             b_nonembedded = NO;
@@ -377,11 +377,11 @@ void WindowClose(vout_window_t *p_wnd)
     [o_vout_dict setObject:o_new_video_window forKey:[NSValue valueWithPointer:p_wnd]];
 
     [[VLCMain sharedInstance] setActiveVideoPlayback: YES];
-    [[VLCMainWindow sharedInstance] setNonembedded:!b_mainwindow_has_video];
+    [[[VLCMain sharedInstance] mainWindow] setNonembedded:!b_mainwindow_has_video];
 
     // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
     if ([o_new_video_window class] == [VLCMainWindow class])
-        [[VLCMainWindow sharedInstance] changePlaylistState: psVideoStartedOrStoppedEvent];
+        [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
 
     if (b_nonembedded) {
         // events might be posted before window is created, so call them again
@@ -425,7 +425,7 @@ void WindowClose(vout_window_t *p_wnd)
 
     // prevent visible extra window if in fullscreen
     NSDisableScreenUpdates();
-    BOOL b_native = [[VLCMainWindow sharedInstance] nativeFullscreenMode];
+    BOOL b_native = [[[VLCMain sharedInstance] mainWindow] nativeFullscreenMode];
 
     // close fullscreen, without changing fullscreen vars
     if (!b_native && ([o_window fullscreen] || [o_window inFullscreenTransition]))
@@ -453,10 +453,10 @@ void WindowClose(vout_window_t *p_wnd)
 
         // video in main window might get stopped while another vout is open
         if ([o_vout_dict count] > 0)
-            [[VLCMainWindow sharedInstance] setNonembedded:YES];
+            [[[VLCMain sharedInstance] mainWindow] setNonembedded:YES];
 
         // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
-        [[VLCMainWindow sharedInstance] changePlaylistState: psVideoStartedOrStoppedEvent];
+        [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
     }
 }
 
@@ -521,7 +521,7 @@ void WindowClose(vout_window_t *p_wnd)
 
     if (b_nativeFullscreenMode) {
         if(!o_current_window)
-            o_current_window = [VLCMainWindow sharedInstance];
+            o_current_window = [[VLCMain sharedInstance] mainWindow] ;
         assert(o_current_window);
 
         // fullscreen might be triggered twice (vout event)
@@ -588,7 +588,7 @@ void WindowClose(vout_window_t *p_wnd)
     NSInteger currentStatusWindowLevel = self.currentStatusWindowLevel;
 
     VLCMain *main = [VLCMain sharedInstance];
-    [[VLCMainWindow sharedInstance] setWindowLevel:i_level];
+    [[[VLCMain sharedInstance] mainWindow] setWindowLevel:i_level];
     [[main videoEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
     [[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
     [[VLCInfo sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
index 28db66e..2dcf555 100644 (file)
 
 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
 {
-    return [[VLCMainWindow sharedInstance] performKeyEquivalent: o_event];
+    return [[[VLCMain sharedInstance] mainWindow] performKeyEquivalent: o_event];
 }
 
 - (void)mouseDown:(NSEvent *)o_event
index 20d5799..1b0c4f3 100644 (file)
 
     // change fspanel state for the case when multiple windows are in fullscreen
     if ([self hasActiveVideo] && [self fullscreen])
-        [[[VLCMainWindow sharedInstance] fspanel] setActive:nil];
+        [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive:nil];
     else
-        [[[VLCMainWindow sharedInstance] fspanel] setNonActive:nil];
+        [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive:nil];
 }
 
 - (void)resignKeyWindow
 {
     [super resignKeyWindow];
 
-    [[[VLCMainWindow sharedInstance] fspanel] setNonActive:nil];
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive:nil];
 }
 
 -(NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow *)window
     }
 
     if ([self hasActiveVideo])
-        [[VLCMainWindow sharedInstance] recreateHideMouseTimer];
+        [[[VLCMain sharedInstance] mainWindow] recreateHideMouseTimer];
 
     if (_darkInterface) {
         [self.titlebarView removeFromSuperviewWithoutNeedingDisplay];
     _inFullscreenTransition = NO;
 
     if ([self hasActiveVideo]) {
-        [[[VLCMainWindow sharedInstance] fspanel] setVoutWasUpdated: self];
+        [[[[VLCMain sharedInstance] mainWindow] fspanel] setVoutWasUpdated: self];
         if (![_videoView isHidden])
-            [[[VLCMainWindow sharedInstance] fspanel] setActive: nil];
+            [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive: nil];
     }
 
     NSArray *subviews = [[self videoView] subviews];
     }
 
     [NSCursor setHiddenUntilMouseMoves: NO];
-    [[[VLCMainWindow sharedInstance] fspanel] setNonActive: nil];
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive: nil];
 
 
     if (_darkInterface) {
 
     if (self.controlsBar)
         [self.controlsBar setFullscreenState:YES];
-    [[[VLCMainWindow sharedInstance] controlsBar] setFullscreenState:YES];
+    [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:YES];
 
-    [[VLCMainWindow sharedInstance] recreateHideMouseTimer];
+    [[[VLCMain sharedInstance] mainWindow] recreateHideMouseTimer];
 
     if (blackout_other_displays)
         [screen blackoutOtherScreens];
     [o_fullscreen_window setAcceptsMouseMovedEvents: YES];
 
     /* tell the fspanel to move itself to front next time it's triggered */
-    [[[VLCMainWindow sharedInstance] fspanel] setVoutWasUpdated: o_fullscreen_window];
-    [[[VLCMainWindow sharedInstance] fspanel] setActive: nil];
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setVoutWasUpdated: o_fullscreen_window];
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setActive: nil];
 
     if ([self isVisible])
         [self orderOut: self];
 
     if (self.controlsBar)
         [self.controlsBar setFullscreenState:NO];
-    [[[VLCMainWindow sharedInstance] controlsBar] setFullscreenState:NO];
+    [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:NO];
 
     /* We always try to do so */
     [NSScreen unblackoutScreens];
         return;
     }
 
-    [[[VLCMainWindow sharedInstance] fspanel] setNonActive: nil];
+    [[[[VLCMain sharedInstance] mainWindow] fspanel] setNonActive: nil];
     [[o_fullscreen_window screen] setNonFullscreenPresentationOptions];
 
     if (o_fullscreen_anim1) {