mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 529891 - Use a better workaround for context menu clicking while the application is inactive. r=josh
--HG-- extra : rebase_source : bdad5f1c76222b39ef20fc6d9e2e6f66417f8005
This commit is contained in:
parent
db70dc729f
commit
ad6bbe0601
@ -2980,10 +2980,28 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
// Returning NO from this method only disallows ordering on mousedown - in order
|
||||
// to prevent it for mouseup too, we need to call [NSApp preventWindowOrdering]
|
||||
// when handling the mousedown event.
|
||||
- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent*)aEvent
|
||||
{
|
||||
// Always using system-provided window ordering for normal windows.
|
||||
if (![[self window] isKindOfClass:[PopupWindow class]])
|
||||
return NO;
|
||||
|
||||
// Don't reorder when we're already accepting mouse events, for example
|
||||
// because we're a context menu.
|
||||
return ChildViewMouseTracker::WindowAcceptsEvent([self window], aEvent);
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent*)theEvent
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
if ([self shouldDelayWindowOrderingForEvent:theEvent]) {
|
||||
[NSApp preventWindowOrdering];
|
||||
}
|
||||
|
||||
// If we've already seen this event due to direct dispatch from menuForEvent:
|
||||
// just bail; if not, remember it.
|
||||
if (mLastMouseDownEvent == theEvent) {
|
||||
|
@ -2247,53 +2247,6 @@ ContentPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
||||
case NSScrollWheel:
|
||||
[target scrollWheel:anEvent];
|
||||
break;
|
||||
case NSLeftMouseDown:
|
||||
if ([NSApp isActive]) {
|
||||
[target mouseDown:anEvent];
|
||||
} else if (mIsContextMenu) {
|
||||
[target mouseDown:anEvent];
|
||||
// If we're in a context menu and our NSApp isn't active (i.e. if
|
||||
// we're in a context menu raised by a right mouse-down event), we
|
||||
// don't want the OS to send the coming NSLeftMouseUp event to NSApp
|
||||
// via the window server, but we do want our ChildView to receive an
|
||||
// NSLeftMouseUp event (and to send a Gecko NS_MOUSE_BUTTON_UP event
|
||||
// to the corresponding nsChildView object). If our NSApp isn't
|
||||
// active when it receives the coming NSLeftMouseUp via the window
|
||||
// server, our app will (in effect) become partially activated,
|
||||
// which has strange side effects: For example, if another app's
|
||||
// window had the focus, that window will lose the focus and the
|
||||
// other app's main menu will be completely disabled (though it will
|
||||
// continue to be displayed).
|
||||
// A side effect of not allowing the coming NSLeftMouseUp event to be
|
||||
// sent to NSApp via the window server is that our custom context
|
||||
// menus will roll up whenever the user left-clicks on them, whether
|
||||
// or not the left-click hit an active menu item. This is how native
|
||||
// context menus behave, but wasn't how our custom context menus
|
||||
// behaved previously (on the trunk or e.g. in Firefox 2.0.0.4).
|
||||
// If our ChildView's corresponding nsChildView object doesn't
|
||||
// dispatch an NS_MOUSE_BUTTON_UP event, none of our active menu items
|
||||
// will "work" on an NSLeftMouseUp.
|
||||
NSEvent *newEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
|
||||
location:windowLocation
|
||||
modifierFlags:nsCocoaUtils::GetCocoaEventModifierFlags(anEvent)
|
||||
timestamp:GetCurrentEventTime()
|
||||
windowNumber:[self windowNumber]
|
||||
context:nil
|
||||
eventNumber:0
|
||||
clickCount:1
|
||||
pressure:0.0];
|
||||
[target mouseUp:newEvent];
|
||||
RollUpPopups();
|
||||
} else {
|
||||
// If our NSApp isn't active and we're not a context menu (i.e. if
|
||||
// we're an ordinary popup window), activate us before sending the
|
||||
// event to its target. This prevents us from being used in the
|
||||
// background, and resolves bmo bug 434097 (another app focus
|
||||
// wierdness bug).
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
[target mouseDown:anEvent];
|
||||
}
|
||||
break;
|
||||
case NSLeftMouseUp:
|
||||
[target mouseUp:anEvent];
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user