]> git.sesse.net Git - vlc/commitdiff
macosx: show reveal-in-finder menu replacement at a similar position as the original one
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Wed, 5 Mar 2014 17:42:48 +0000 (18:42 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Wed, 5 Mar 2014 17:44:57 +0000 (18:44 +0100)
modules/gui/macosx/MainWindowTitle.m

index bd2bfcd69ce2599ad0cf3039ac9b744c4cb0914d..fbbb7b020adb02308342550133860f5a0129c4d8 100644 (file)
         [contextMenu release];
 
     NSURL * representedURL = [[self window] representedURL];
-    if (! representedURL)
+    if (!representedURL)
         return;
 
     NSArray * pathComponents;
     [currentItem setImage: icon];
     [currentItem setTarget: self];
 
-    [NSMenu popUpContextMenu: contextMenu withEvent: o_event forView: [self superview]];
+    // center the context menu similar to the white interface
+    CGFloat menuWidth = [contextMenu size].width;
+    NSRect windowFrame = [[self window] frame];
+    NSPoint point;
+
+    CGFloat fullButtonWidth = 0.;
+    if([[VLCMain sharedInstance] nativeFullscreenMode])
+        fullButtonWidth = 20.;
+
+    // assumes 60 px for the window buttons
+    point.x = (windowFrame.size.width - 60. - fullButtonWidth) / 2. - menuWidth / 2. + 60. - 20.;
+    point.y = windowFrame.size.height + 1.;
+    if (point.x < 0)
+        point.x = 10;
+
+    NSEvent *fakeMouseEvent = [NSEvent mouseEventWithType:NSRightMouseDown
+                                                 location:point
+                                            modifierFlags:0
+                                                timestamp:0
+                                             windowNumber:[[self window] windowNumber]
+                                                  context:nil
+                                              eventNumber:0
+                                               clickCount:0
+                                                 pressure:0];
+    [NSMenu popUpContextMenu: contextMenu withEvent: fakeMouseEvent forView: [self superview]];
 }
 
 - (IBAction)revealInFinder:(id)sender