]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/MainWindowTitle.m
macosx: fix issue which caused automatic video resizing even if disabled
[vlc] / modules / gui / macosx / MainWindowTitle.m
index 0405b6d5fd00c893a8245f3ffa9891efb9fac4e4..bd2bfcd69ce2599ad0cf3039ac9b744c4cb0914d 100644 (file)
 
     [self loadButtonIcons];
     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(controlTintChanged:) name: NSControlTintDidChangeNotification object: nil];
-
-    [o_red_btn setImage: o_red_img];
-    [o_red_btn setAlternateImage: o_red_on_img];
-    [[o_red_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
-    [[o_red_btn cell] setTag: 0];
-    [o_yellow_btn setImage: o_yellow_img];
-    [o_yellow_btn setAlternateImage: o_yellow_on_img];
-    [[o_yellow_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
-    [[o_yellow_btn cell] setTag: 1];
-    [o_green_btn setImage: o_green_img];
-    [o_green_btn setAlternateImage: o_green_on_img];
-    [[o_green_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
-    [[o_green_btn cell] setTag: 2];
-    [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
-    [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"window-fullscreen-on"]];
-    [[o_fullscreen_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
-    [[o_fullscreen_btn cell] setTag: 3];
 }
 
 - (void)controlTintChanged:(NSNotification *)notification
 
 - (void)loadButtonIcons
 {
-    if (!OSX_SNOW_LEOPARD)
-    {
-        if( [NSColor currentControlTint] == NSBlueControlTint )
+    if (!OSX_SNOW_LEOPARD) {
+        if ([NSColor currentControlTint] == NSBlueControlTint)
         {
             o_red_img = [[NSImage imageNamed:@"lion-window-close"] retain];
             o_red_over_img = [[NSImage imageNamed:@"lion-window-close-over"] retain];
             o_green_on_img = [[NSImage imageNamed:@"lion-window-zoom-on-graphite"] retain];
         }
     } else {
-        if( [NSColor currentControlTint] == NSBlueControlTint )
+        if ([NSColor currentControlTint] == NSBlueControlTint)
         {
             o_red_img = [[NSImage imageNamed:@"snowleo-window-close"] retain];
             o_red_over_img = [[NSImage imageNamed:@"snowleo-window-close-over"] retain];
             o_green_on_img = [[NSImage imageNamed:@"snowleo-window-zoom-on-graphite"] retain];
         }
     }
+
+    [o_red_btn setImage: o_red_img];
+    [o_red_btn setAlternateImage: o_red_on_img];
+    [[o_red_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
+    [[o_red_btn cell] setTag: 0];
+    [o_yellow_btn setImage: o_yellow_img];
+    [o_yellow_btn setAlternateImage: o_yellow_on_img];
+    [[o_yellow_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
+    [[o_yellow_btn cell] setTag: 1];
+    [o_green_btn setImage: o_green_img];
+    [o_green_btn setAlternateImage: o_green_on_img];
+    [[o_green_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
+    [[o_green_btn cell] setTag: 2];
+    [o_fullscreen_btn setImage: [NSImage imageNamed:@"window-fullscreen"]];
+    [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"window-fullscreen-on"]];
+    [[o_fullscreen_btn cell] setShowsBorderOnlyWhileMouseInside: YES];
+    [[o_fullscreen_btn cell] setTag: 3];
 }
 
 - (BOOL)mouseDownCanMoveWindow
         [[self window] miniaturize: sender];
     else if (sender == o_green_btn)
         [[self window] performZoom: sender];
-    else if (sender == o_fullscreen_btn)
-    {
-        // set fs directly to true, as the vars can be already true in some configs
-        var_SetBool( pl_Get( VLCIntf ), "fullscreen", true );
+    else if (sender == o_fullscreen_btn) {
+        // same action as native fs button
+        [[self window] toggleFullScreen:self];
 
-        vout_thread_t *p_vout = getVout();
-        if( p_vout )
-        {
-            var_SetBool( p_vout, "fullscreen", true );
-            vlc_object_release( p_vout );
-        }
-    }
-    else
-        msg_Err( VLCIntf, "unknown button action sender" );
+    } else
+        msg_Err(VLCIntf, "unknown button action sender");
 
     [self setWindowButtonOver: NO];
     [self setWindowFullscreenButtonOver: NO];
 
 - (void)setWindowTitle:(NSString *)title
 {
-    if (!o_window_title_shadow)
-    {
+    if (!o_window_title_shadow) {
         o_window_title_shadow = [[NSShadow alloc] init];
         [o_window_title_shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];
         [o_window_title_shadow setShadowOffset:NSMakeSize(0.0, -1.5)];
 
 - (void)setWindowButtonOver:(BOOL)b_value
 {
-    if( b_value )
-    {
+    if (b_value) {
         [o_red_btn setImage: o_red_over_img];
         [o_yellow_btn setImage: o_yellow_over_img];
         [o_green_btn setImage: o_green_over_img];
-    }
-    else
-    {
+    } else {
         [o_red_btn setImage: o_red_img];
         [o_yellow_btn setImage: o_yellow_img];
         [o_green_btn setImage: o_green_img];
 - (void)mouseDown:(NSEvent *)event
 {
     NSPoint ml = [self convertPoint: [event locationInWindow] fromView: self];
-    if([[self window] frame].size.height - ml.y) <= 22. && [event clickCount] == 2) {
+    if (([[self window] frame].size.height - ml.y) <= 22. && [event clickCount] == 2) {
         //Get settings from "System Preferences" >  "Appearance" > "Double-click on windows title bar to minimize"
         NSString *const MDAppleMiniaturizeOnDoubleClickKey = @"AppleMiniaturizeOnDoubleClick";
         NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
     id theControlView = [self controlView];
     if ([theControlView respondsToSelector: @selector(extendedAccessibilityIsAttributeSettable:)]) {
         NSNumber *theValue = [theControlView extendedAccessibilityIsAttributeSettable: theAttributeName];
-        if (theValue) {
+        if (theValue)
             return [theValue boolValue]; // same basic strategy we use in -accessibilityAttributeValue:
-        }
     }
     return [super accessibilityIsAttributeSettable: theAttributeName];
 }
                 if (windowFrame.size.width < winMinSize.width)
                     windowFrame.size.width = winMinSize.width;
 
-                if (windowFrame.size.height < winMinSize.height)
-                {
+                if (windowFrame.size.height < winMinSize.height) {
                     windowFrame.size.height = winMinSize.height;
                     windowFrame.origin.y = oldOriginY;
                 }
 }
 
 - (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName {
-    return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool: NO] : nil); // make the Subrole attribute we added non-settable
+    return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool:NO] : nil); // make the Subrole attribute we added non-settable
 }
 
 - (void)accessibilityPerformAction: (NSString*)theActionName {
     if ([theActionName isEqualToString: NSAccessibilityPressAction]) {
-        if ([self isEnabled]) {
+        if ([self isEnabled])
             [self performClick: nil];
-        }
-    } else {
+    } else
         [super accessibilityPerformAction: theActionName];
-    }
 }
 
 @end
     NSImage * icon;
     NSMenuItem * currentItem;
     NSMutableString * currentPath;
-    NSSize iconSize = NSMakeSize( 16., 16. );
+    NSSize iconSize = NSMakeSize(16., 16.);
     for (NSUInteger i = count - 1; i > 0; i--) {
         currentPath = [NSMutableString stringWithCapacity:1024];
         for (NSUInteger y = 0; y < i; y++)
         [currentItem setImage: icon];
     }
 
-    if ([[pathComponents objectAtIndex: 1] isEqualToString:@"Volumes"]) {
+    if ([[pathComponents objectAtIndex:1] isEqualToString:@"Volumes"]) {
         /* we don't want to show the Volumes item, since the Cocoa does it neither */
         currentItem = [contextMenu itemWithTitle:[[NSFileManager defaultManager] displayNameAtPath: @"/Volumes"]];
         if (currentItem)
     NSUInteger count = [contextMenu numberOfItems];
     NSUInteger selectedItem = [contextMenu indexOfItem: sender];
 
-    if (selectedItem == count - 1)  // the fake computer item
-    {
+    if (selectedItem == count - 1) { // the fake computer item
         [[NSWorkspace sharedWorkspace] selectFile: @"/" inFileViewerRootedAtPath: @""];
         return;
     }
     if (! representedURL)
         return;
 
-    if (selectedItem == 0) // the actual file, let's save time
-    {
+    if (selectedItem == 0) { // the actual file, let's save time
         [[NSWorkspace sharedWorkspace] selectFile: [representedURL path] inFileViewerRootedAtPath: [representedURL path]];
         return;
     }
 
 - (void)rightMouseDown:(NSEvent *)o_event
 {
-    if( [o_event type] == NSRightMouseDown )
+    if ([o_event type] == NSRightMouseDown)
         [self showRightClickMenuWithEvent:o_event];
 
     [super mouseDown: o_event];