[vlc-commits] macosx: minor code style and readability fixes

Marvin Scholz git at videolan.org
Tue Oct 9 10:58:20 CEST 2018


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Tue Oct  9 08:23:44 2018 +0200| [3918b11015f7e28a738af26aefb1e2a19c096fd3] | committer: Marvin Scholz

macosx: minor code style and readability fixes

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

 modules/gui/macosx/VLCMainWindow.m | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m
index cc88fb1499..bc8a1a24d7 100644
--- a/modules/gui/macosx/VLCMainWindow.m
+++ b/modules/gui/macosx/VLCMainWindow.m
@@ -147,9 +147,6 @@ static const float f_min_window_height = 307.;
      * General setup
      */
 
-    NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
-    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-
     BOOL splitViewShouldBeHidden = NO;
 
     [self setDelegate:self];
@@ -219,6 +216,7 @@ static const float f_min_window_height = 307.;
     [_fspanel showWindow:self];
 
     // Check for first run and show metadata network access question
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     if (![defaults objectForKey:@"VLCFirstRun"]) {
         [defaults setObject:[NSDate date] forKey:@"VLCFirstRun"];
 
@@ -237,20 +235,34 @@ static const float f_min_window_height = 307.;
     [_playlistScrollView setBorderType:NSNoBorder];
     [_sidebarScrollView setBorderType:NSNoBorder];
 
-    [defaultCenter addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
-    [defaultCenter addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
-    [defaultCenter addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
-    [defaultCenter addObserver: self selector: @selector(mainSplitViewDidResizeSubviews:) name: NSSplitViewDidResizeSubviewsNotification object:_splitView];
+    // Register for NSNotifications about Window and SplitView changes
+    NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
+    [defaultCenter addObserver:self
+                      selector:@selector(someWindowWillClose:)
+                          name:NSWindowWillCloseNotification
+                        object:nil];
+    [defaultCenter addObserver:self
+                      selector:@selector(someWindowWillMiniaturize:)
+                          name:NSWindowWillMiniaturizeNotification
+                        object:nil];
+    [defaultCenter addObserver:self
+                      selector:@selector(applicationWillTerminate:)
+                          name:NSApplicationWillTerminateNotification
+                        object:nil];
+    [defaultCenter addObserver:self
+                      selector:@selector(mainSplitViewDidResizeSubviews:)
+                          name:NSSplitViewDidResizeSubviewsNotification
+                        object:_splitView];
 
     if (splitViewShouldBeHidden) {
         [self hideSplitView:YES];
         f_lastSplitViewHeight = 300;
     }
 
-    /* sanity check for the window size */
-    NSRect frame = [self frame];
-    NSSize screenSize = [[self screen] frame].size;
-    if (screenSize.width <= frame.size.width || screenSize.height <= frame.size.height) {
+    // Resize MainWindow to the screen size, if it exceeds the screens size
+    NSSize windowSize = self.frame.size;
+    NSSize screenSize = self.screen.frame.size;
+    if (screenSize.width <= windowSize.width || screenSize.height <= windowSize.height) {
         self.nativeVideoSize = screenSize;
         [self resizeWindow];
     }



More information about the vlc-commits mailing list