Skip to content

Commit

Permalink
if you click on the gear icon to bring up the contextual menu, and th…
Browse files Browse the repository at this point in the history
…en click on the gear icon again, it used to load the Flash view instead of simply closing the contextual menu; now it doesn't. that was an annoying bug

Signed-off-by: Jonathan 'Wolf' Rentzsch <jwr.git@redshed.net>
  • Loading branch information
Simone Manganelli authored and rentzsch committed Jul 14, 2009
1 parent 99ffac0 commit 4f29315
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Plugin/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ THE SOFTWARE.
NSString *_src;
NSString *_videoId;
NSString *_launchedAppBundleIdentifier;

BOOL _contextMenuIsVisible;
}

+ (NSView *)plugInViewWithArguments:(NSDictionary *)arguments;
Expand Down
17 changes: 13 additions & 4 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
if (self) {
_hasH264Version = NO;
_hasHDH264Version = NO;
_contextMenuIsVisible = NO;
defaultWhitelist = [NSArray arrayWithObjects: @"com.apple.frontrow",
@"com.apple.dashboard.client",
@"com.apple.ScreenSaver.Engine",
Expand Down Expand Up @@ -475,7 +476,7 @@ - (BOOL) _gearVisible
return NSWidth( bounds ) > 32 && NSHeight( bounds ) > 32;
}

- (void) mouseDown:(NSEvent *)event
- (BOOL) mouseEventIsWithinGearIconBorders:(NSEvent *)event
{
float margin = 5.0;
float gearImageHeight = 16.0;
Expand All @@ -499,7 +500,13 @@ - (void) mouseDown:(NSEvent *)event
(localMouseLocation.y <= (viewHeight - margin)) );
}

if (xCoordWithinGearImage && yCoordWithinGearImage) {
return (xCoordWithinGearImage && yCoordWithinGearImage);
}

- (void) mouseDown:(NSEvent *)event
{
if ([self mouseEventIsWithinGearIconBorders:event]) {
_contextMenuIsVisible = YES;
[NSMenu popUpContextMenu:[self menuForEvent:event] withEvent:event forView:self];
} else {
mouseIsDown = YES;
Expand Down Expand Up @@ -535,13 +542,15 @@ - (void) mouseUp:(NSEvent *)event
// Now that we track the mouse for mouse-over when the mouse is up
// for drawing the gear only on mouse-over, we don't remove it here.

if (mouseInside) {
if (mouseInside && (! _contextMenuIsVisible) ) {
if ([self _isOptionPressed] && ![self _isHostWhitelisted]) {
[self _askToAddCurrentSiteToWhitelist];
} else {
[self _convertTypesForContainer];
}
}
} else {
_contextMenuIsVisible = NO;
}
}

- (BOOL) _isOptionPressed
Expand Down

0 comments on commit 4f29315

Please sign in to comment.