Skip to content

Commit

Permalink
Fixed visual artifacts when window position was changed
Browse files Browse the repository at this point in the history
  • Loading branch information
sbooth committed May 1, 2011
1 parent bac3165 commit a1342bf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions SFBPopoverWindow.m
Expand Up @@ -186,13 +186,33 @@ - (void) setPopoverPosition:(SFBPopoverPosition)popoverPosition
boundsRect.origin = NSZeroPoint;
NSPoint newArrow = [[self popoverWindowFrame] arrowheadPositionForRect:boundsRect];

// This orderOut: then orderFront: trickery seems to be required to prevent visual artifacts when the new window position
// overlaps the old one. No matter what I tried (flusing, erasing, disabling screen updates) I could not get the display
// to work properly if the window was onscreen
BOOL isVisible = [self isVisible];
BOOL isKey = [self isKeyWindow];
if(isVisible) {
NSDisableScreenUpdates();
[self orderOut:self];
}

contentRect = [self contentRectForFrameRect:boundsRect];
[_popoverContentView setFrame:contentRect];

// Adjust the frame so the attachment point won't change
frameRect.origin = NSMakePoint(oldOrigin.x + (oldArrow.x - newArrow.x), oldOrigin.y + (oldArrow.y - newArrow.y));

[[self popoverWindowFrame] setNeedsDisplay:YES];
[self setFrame:frameRect display:YES];

if(isVisible) {
if(isKey)
[self makeKeyAndOrderFront:self];
else
[self orderFront:self];

NSEnableScreenUpdates();
}
}

- (CGFloat) distance
Expand Down

0 comments on commit a1342bf

Please sign in to comment.