[vlc-commits] macosx: show reveal-in-finder menu replacement at a similar position as the original one

David Fuhrmann git at videolan.org
Wed Mar 5 18:51:41 CET 2014


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Wed Mar  5 18:42:48 2014 +0100| [82db99a42f27f630be1bb8433d2a6a0f92542522] | committer: David Fuhrmann

macosx: show reveal-in-finder menu replacement at a similar position as the original one

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

 modules/gui/macosx/MainWindowTitle.m |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/MainWindowTitle.m b/modules/gui/macosx/MainWindowTitle.m
index bd2bfcd..fbbb7b0 100644
--- a/modules/gui/macosx/MainWindowTitle.m
+++ b/modules/gui/macosx/MainWindowTitle.m
@@ -474,7 +474,7 @@
         [contextMenu release];
 
     NSURL * representedURL = [[self window] representedURL];
-    if (! representedURL)
+    if (!representedURL)
         return;
 
     NSArray * pathComponents;
@@ -527,7 +527,31 @@
     [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



More information about the vlc-commits mailing list