Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Fix mini player location at edge of screen, multiple screens (fixes #108
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kbhomes committed Apr 7, 2014
1 parent d2ce93a commit 4460a3c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions google-music-mac/Popup/PopupPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,29 @@ - (void)showRelativeToRect:(NSRect)rect ofView:(NSView *)view preferredEdge:(NSR
[popupDelegate popupWillShow];

NSRect statusRect = [view.window convertRectToScreen:view.bounds];
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
NSRect screenRect = [[NSScreen mainScreen] frame];

NSRect frame = NSMakeRect(statusRect.origin.x,
statusRect.origin.y - self.frame.size.height - 2,
self.frame.size.width,
self.frame.size.height);

frame.origin.x = NSMidX(statusRect) - (frame.size.width / 2);
[popupView setArrowX:(NSMidX(statusRect) - NSMinX(frame))];

// Check if the frame goes off screen.
if (NSMaxX(frame) > NSMaxX(screenRect)) {
frame.origin.x -= NSMaxX(frame) - NSMaxX(screenRect);
}

CGFloat arrowX = NSMidX(statusRect) - NSMinX(frame);
[popupView setArrowX:arrowX];

statusRect.origin.x -= statusRect.size.width / 2;

[self setAlphaValue:0];
[self setFrame:frame display:YES];
[self makeKeyAndOrderFront:nil];
[self.popupView setNeedsDisplay:YES];

[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.15];
Expand Down

0 comments on commit 4460a3c

Please sign in to comment.