Contextmenu doesn't disappear correctly when Firefox is in background. Also, Firefox doesn't dismiss context menu when it is in the background and a user clicks on another application. b=339945 r=cbarrett sr=roc

This commit is contained in:
joshmoz@gmail.com 2007-05-17 19:06:59 -07:00
parent 63bdea3a2a
commit cf1b2fda7d
3 changed files with 34 additions and 0 deletions

View File

@ -1133,6 +1133,10 @@ NS_IMETHODIMP nsCocoaWindow::GetAnimatedResize(PRUint16* aAnimation)
- (void)windowDidBecomeMain:(NSNotification *)aNotification
{
// roll up any popups
if (gRollupListener != nsnull && gRollupWidget != nsnull)
gRollupListener->Rollup();
NSWindow* window = [aNotification object];
if (window)
[WindowDelegate paintMenubarForWindow:window];

View File

@ -95,6 +95,8 @@ protected:
nsresult RegisterForSleepWakeNotifcations();
void RemoveSleepWakeNotifcations();
void RegisterForAllProcessMouseEvents();
protected:
bool mInited;

View File

@ -47,15 +47,22 @@
#include <mach/mach_interface.h>
#include <mach/mach_init.h>
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
#import <IOKit/pwr_mgt/IOPMLib.h>
#import <IOKit/IOMessage.h>
#include "nsWidgetAtoms.h"
#include "nsIRollupListener.h"
#include "nsIWidget.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
// defined in nsChildView.mm
extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget;
static io_connect_t gRootPort = MACH_PORT_NULL;
// Static thread local storage index of the Toolkit
@ -89,6 +96,7 @@ nsToolkit::Init(PRThread * aThread)
mInited = true;
RegisterForSleepWakeNotifcations();
RegisterForAllProcessMouseEvents();
return NS_OK;
}
@ -173,6 +181,26 @@ nsToolkit::RemoveSleepWakeNotifcations()
}
static OSStatus AllAppMouseEventHandler(EventHandlerCallRef aCaller, EventRef aEvent, void* aRefcon)
{
if (![NSApp isActive]) {
if (gRollupListener != nsnull && gRollupWidget != nsnull)
gRollupListener->Rollup();
}
return noErr;
}
void
nsToolkit::RegisterForAllProcessMouseEvents()
{
EventTypeSpec kEvents[] = {{kEventClassMouse, kEventMouseDown}};
InstallEventHandler(GetEventMonitorTarget(), AllAppMouseEventHandler, GetEventTypeCount(kEvents), kEvents, 0, NULL);
}
// Return the nsIToolkit for the current thread. If a toolkit does not
// yet exist, then one will be created...
NS_METHOD NS_GetCurrentToolkit(nsIToolkit* *aResult)