]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/Windows.m
macosx/CAS: implement basic error checking for the stream-out settings
[vlc] / modules / gui / macosx / Windows.m
index d710a3a13ef3fb35bbaabfe38a5ee03e6e750a30..4155f72f6a3505f84bd286cdbbb7a76e239a391b 100644 (file)
  *  Common code for main window, detached window and extra video window
  *****************************************************************************/
 
+@interface VLCVideoWindowCommon (Internal)
+- (void)customZoom:(id)sender;
+- (void)hasBecomeFullscreen;
+- (void)leaveFullscreenAndFadeOut:(BOOL)fadeout;
+- (void)hasEndedFullscreen;
+@end
+
 @implementation VLCVideoWindowCommon
 
 @synthesize videoView=o_video_view;
 
 - (void)setTitle:(NSString *)title
 {
+    if (!title || [title length] < 1)
+        return;
+
     if (b_dark_interface && o_titlebar_view)
         [o_titlebar_view setWindowTitle: title];
 
 #pragma mark -
 #pragma mark Video window resizing logic
 
-- (void)resizeWindow
+- (NSRect)getWindowRectForProposedVideoViewSize:(NSSize)size
 {
-    if ([[VLCMainWindow sharedInstance] fullscreen])
-        return;
-
     NSSize windowMinSize = [self minSize];
     NSRect screenFrame = [[self screen] visibleFrame];
 
     NSPoint topleftbase = NSMakePoint(0, [self frame].size.height);
     NSPoint topleftscreen = [self convertBaseToScreen: topleftbase];
 
-    unsigned int i_width = nativeVideoSize.width;
-    unsigned int i_height = nativeVideoSize.height;
+    unsigned int i_width = size.width;
+    unsigned int i_height = size.height;
     if (i_width < windowMinSize.width)
         i_width = windowMinSize.width;
     if (i_height < f_min_video_height)
     if (right_window_point > right_screen_point)
         new_frame.origin.x -= (right_window_point - right_screen_point);
 
-    [[self animator] setFrame:new_frame display:YES];
+    return new_frame;
+}
+
+- (void)resizeWindow
+{
+    if ([[VLCMainWindow sharedInstance] fullscreen])
+        return;
+
+    NSRect window_rect = [self getWindowRectForProposedVideoViewSize:nativeVideoSize];
+    [[self animator] setFrame:window_rect display:YES];
 }
 
 - (void)setNativeVideoSize:(NSSize)size
 
     if (o_controls_bar)
         [o_controls_bar setFullscreenState:YES];
+    [[[VLCMainWindow sharedInstance] controlsBar] setFullscreenState:YES];
 
     [[VLCMainWindow sharedInstance] recreateHideMouseTimer];
 
                 CGDisplayFade(token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
             }
 
-            if ([screen mainScreen])
-                [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
+            NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
+            if ([screen hasMenuBar])
+                presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
+            if ([screen hasMenuBar] || [screen hasDock])
+                presentationOpts |= NSApplicationPresentationAutoHideDock;
+            [NSApp setPresentationOptions:presentationOpts];
 
             [[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
             [o_temp_view setFrame:[o_video_view frame]];
         [o_fullscreen_anim2 release];
     }
 
-    if ([screen mainScreen])
-        [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
+    NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
+    if ([screen hasMenuBar])
+        presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
+    if ([screen hasMenuBar] || [screen hasDock])
+        presentationOpts |= NSApplicationPresentationAutoHideDock;
+    [NSApp setPresentationOptions:presentationOpts];
 
     dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
     dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
 
     if (o_controls_bar)
         [o_controls_bar setFullscreenState:NO];
+    [[[VLCMainWindow sharedInstance] controlsBar] setFullscreenState:NO];
 
     /* We always try to do so */
     [NSScreen unblackoutScreens];
 - (void)hasEndedFullscreen
 {
     [[VLCMainWindow sharedInstance] setFullscreen: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 o_video_view disappearing of the screen during this operation */
     NSDisableScreenUpdates();