Bug 877767 - Draw window title on top of everything in drawintitlebar mode. r=smichaud

This commit is contained in:
Markus Stange 2013-06-29 03:02:53 +02:00
parent d1ae2a4b08
commit 258d1b8399
2 changed files with 39 additions and 0 deletions

View File

@ -105,6 +105,18 @@ class GLManager;
@interface NSView (Undocumented)
// Draws the title string of a window.
// Present on NSThemeFrame since at least 10.6.
// _drawTitleBar is somewhat complex, and has changed over the years
// since OS X 10.6. But in that time it's never done anything that
// would break when called outside of -[NSView drawRect:] (which we
// sometimes do), or whose output can't be redirected to a
// CGContextRef object (which we also sometimes do). This is likely
// to remain true for the indefinite future. However we should
// check _drawTitleBar in each new major version of OS X. For more
// information see bug 877767.
- (void)_drawTitleBar:(NSRect)aRect;
// Returns an NSRect that is the bounding box for all an NSView's dirty
// rectangles (ones that need to be redrawn). The full list of dirty
// rectangles can be obtained by calling -[NSView _dirtyRegion] and then

View File

@ -151,6 +151,7 @@ uint32_t nsChildView::sLastInputEventCount = 0;
- (void)clearCorners;
// Overlay drawing functions for traditional CGContext drawing
- (void)drawTitleString;
- (void)drawTitlebarHighlight;
- (void)maskTopCornersInContext:(CGContextRef)aContext;
@ -2096,6 +2097,11 @@ nsChildView::UpdateTitlebarImageBuffer()
NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:[frameView isFlipped]];
[NSGraphicsContext setCurrentContext:context];
// Draw the title string.
if ([frameView respondsToSelector:@selector(_drawTitleBar:)]) {
[frameView _drawTitleBar:[frameView bounds]];
}
// Draw the titlebar controls into the titlebar image.
for (id view in [window titlebarControls]) {
NSRect viewFrame = [view frame];
@ -3101,6 +3107,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
}
if ([self isCoveringTitlebar]) {
[self drawTitleString];
[self drawTitlebarHighlight];
[self maskTopCornersInContext:aContext];
}
@ -3270,6 +3277,26 @@ NSEvent* gLastDragMouseDownEvent = nil;
CGContextRestoreGState(aContext);
}
- (void)drawTitleString
{
NSView* frameView = [[[self window] contentView] superview];
if (![frameView respondsToSelector:@selector(_drawTitleBar:)]) {
return;
}
NSGraphicsContext* oldContext = [NSGraphicsContext currentContext];
CGContextRef ctx = (CGContextRef)[oldContext graphicsPort];
CGContextSaveGState(ctx);
if ([oldContext isFlipped] != [frameView isFlipped]) {
CGContextTranslateCTM(ctx, 0, [self bounds].size.height);
CGContextScaleCTM(ctx, 1, -1);
}
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:[frameView isFlipped]]];
[frameView _drawTitleBar:[frameView bounds]];
CGContextRestoreGState(ctx);
[NSGraphicsContext setCurrentContext:oldContext];
}
- (void)drawTitlebarHighlight
{
DrawTitlebarHighlight([self bounds].size, [self cornerRadius],