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

Commit

Permalink
Merge fix for the Clamshell mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Shpakovski committed Sep 3, 2012
1 parent e7104e0 commit 4825d5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
1 change: 0 additions & 1 deletion Popup/PanelController.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@

- (void)openPanel;
- (void)closePanel;
- (NSRect)statusRectInScreenRect:(NSRect *)outScreenRect;

@end
32 changes: 14 additions & 18 deletions Popup/PanelController.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (void)windowDidResignKey:(NSNotification *)notification;
- (void)windowDidResize:(NSNotification *)notification
{
NSWindow *panel = [self window];
NSRect statusRect = [self statusRectInScreenRect:NULL];
NSRect statusRect = [self statusRectForWindow:panel];
NSRect panelRect = [panel frame];

CGFloat statusX = roundf(NSMidX(statusRect));
Expand Down Expand Up @@ -163,42 +163,38 @@ - (void)runSearch

#pragma mark - Public methods

- (NSRect)statusRectInScreenRect:(NSRect *)outScreenRect
- (NSRect)statusRectForWindow:(NSWindow *)window
{
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
NSRect statusRect = NSZeroRect;

StatusItemView *statusItemView = nil;
if ([self.delegate respondsToSelector:@selector(statusItemViewForPanelController:)]) {
if ([self.delegate respondsToSelector:@selector(statusItemViewForPanelController:)])
{
statusItemView = [self.delegate statusItemViewForPanelController:self];
}

NSRect screenRect = NSZeroRect;
NSRect statusRect = NSZeroRect;

if (statusItemView) {
screenRect = statusItemView.window.screen.frame;
if (statusItemView)
{
statusRect = statusItemView.globalRect;
statusRect.origin.y = NSMinY(statusRect) - NSHeight(statusRect);
}
else {
screenRect = self.window.screen.frame;
else
{
statusRect.size = NSMakeSize(STATUS_ITEM_VIEW_WIDTH, [[NSStatusBar systemStatusBar] thickness]);
statusRect.origin.x = roundf((NSWidth(screenRect) - NSWidth(statusRect)) / 2);
statusRect.origin.y = NSHeight(screenRect) - NSHeight(statusRect) * 2;
}

if (outScreenRect) {
*outScreenRect = screenRect;
}

return statusRect;
}

- (void)openPanel
{
NSWindow *panel = [self window];

NSRect screenRect = NSZeroRect;
NSRect statusRect = [self statusRectInScreenRect:&screenRect];
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
NSRect statusRect = [self statusRectForWindow:panel];

NSRect panelRect = [panel frame];
panelRect.size.width = PANEL_WIDTH;
panelRect.origin.x = roundf(NSMidX(statusRect) - NSWidth(panelRect) / 2);
Expand Down

0 comments on commit 4825d5c

Please sign in to comment.