mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 06:38:36 +00:00
Fixing bug 336216, tabs don't do mouse tracking correctly across key window changes. Patch by Aaron Schulman <aschulm@gmail.com>, r=stuart.morgan, sr=pink
This commit is contained in:
parent
5258761af1
commit
7f7066ead9
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Geoff Beier <me@mollyandgeoff.com>
|
||||
* Aaron Schulman <aschulm@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -56,6 +57,7 @@
|
||||
-(void)unregisterTabButtonsForTracking;
|
||||
-(void)initOverflowMenu;
|
||||
-(NSRect)tabsRect;
|
||||
-(BOOL)isMouseInside;
|
||||
|
||||
@end
|
||||
|
||||
@ -116,6 +118,7 @@ static const int kOverflowButtonMargin = 1;
|
||||
[mBackgroundImage release];
|
||||
[mButtonDividerImage release];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -351,6 +354,34 @@ static const int kOverflowButtonMargin = 1;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToWindow
|
||||
{
|
||||
// setup the tab bar to recieve notifications of key window changes
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
[nc removeObserver:self name:NSWindowDidBecomeKeyNotification object:[self window]];
|
||||
[nc removeObserver:self name:NSWindowDidResignKeyNotification object:[self window]];
|
||||
if ([self window]) {
|
||||
[nc addObserver:self selector:@selector(handleWindowIsKey:)
|
||||
name:NSWindowDidBecomeKeyNotification object:[self window]];
|
||||
[nc addObserver:self selector:@selector(handleWindowResignKey:)
|
||||
name:NSWindowDidResignKeyNotification object:[self window]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleWindowIsKey:(NSWindow *)inWindow
|
||||
{
|
||||
// set tab bar dirty because the location of the mouse is inside the tab bar
|
||||
if ([self isMouseInside])
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)handleWindowResignKey:(NSWindow *)inWindow
|
||||
{
|
||||
// set tab bar dirty when the mouse is inside because the window does not respond to mouse hovering events when it is not key
|
||||
if ([self isMouseInside])
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
// causes tab buttons to stop reacting to mouse events
|
||||
-(void)unregisterTabButtonsForTracking
|
||||
{
|
||||
@ -486,6 +517,13 @@ static const int kOverflowButtonMargin = 1;
|
||||
return rect;
|
||||
}
|
||||
|
||||
-(BOOL)isMouseInside
|
||||
{
|
||||
NSPoint mousePointInWindow = [[self window] convertScreenToBase:[NSEvent mouseLocation]];
|
||||
NSPoint mousePointInView = [[self superview] convertPoint:mousePointInWindow fromView:nil];
|
||||
return NSMouseInRect(mousePointInView, [self frame], NO);
|
||||
}
|
||||
|
||||
-(BOOL)isVisible
|
||||
{
|
||||
return mVisible;
|
||||
|
@ -138,7 +138,7 @@ static NSImage* gTabButtonDividerImage = nil;
|
||||
}
|
||||
|
||||
NSPoint patternOrigin = [controlView convertPoint:NSMakePoint(0.0f, 0.0f) toView:nil];
|
||||
|
||||
NSWindow *window = [[mTabViewItem tabView] window];
|
||||
if ([mTabViewItem tabState] == NSSelectedTab) {
|
||||
// move things down a little, to give the impression of being pulled forward
|
||||
labelRect.origin.y -= kTabSelectOffset;
|
||||
@ -152,7 +152,7 @@ static NSImage* gTabButtonDividerImage = nil;
|
||||
[gActiveTabBg drawTiledInRect:rect origin:patternOrigin operation: NSCompositeSourceOver];
|
||||
[gTabLeft compositeToPoint:NSMakePoint(rect.origin.x, rect.origin.y) operation:NSCompositeSourceOver];
|
||||
[gTabRight compositeToPoint:NSMakePoint(NSMaxX(bgRect), bgRect.origin.y) operation:NSCompositeSourceOver];
|
||||
} else if ([self mouseWithin] && ![self dragTarget]) {
|
||||
} else if ([self mouseWithin] && ![self dragTarget] && [window isKeyWindow]) {
|
||||
[gTabMouseOverBg drawTiledInRect:rect origin:patternOrigin operation:NSCompositeSourceOver];
|
||||
}
|
||||
// TODO: Make this look nicer
|
||||
|
Loading…
x
Reference in New Issue
Block a user