roll up popups when we should. Cocoa widgets only. b=325336 r=mento

This commit is contained in:
joshmoz%gmail.com 2006-03-07 20:02:09 +00:00
Родитель 7df0cde2d0
Коммит 391ea713b4
3 изменённых файлов: 61 добавлений и 42 удалений

Просмотреть файл

@ -1880,7 +1880,6 @@ NS_IMETHODIMP nsChildView::CaptureRollupEvents(nsIRollupListener * aListener,
NS_ADDREF(this);
} else {
NS_IF_RELEASE(gRollupListener);
//gRollupListener = nsnull;
NS_IF_RELEASE(gRollupWidget);
}

Просмотреть файл

@ -41,7 +41,6 @@
#undef DARWIN
#import <Cocoa/Cocoa.h>
#include <Controls.h>
#include "nsBaseWidget.h"
@ -142,7 +141,7 @@ public:
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) { return NS_OK; }
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) { return NS_OK; }
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent) { return NS_OK; }
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
// be notified that a some form of drag event needs to go into Gecko
virtual PRBool DragEvent(unsigned int aMessage, Point aMouseGlobal, UInt16 aKeyModifiers);

Просмотреть файл

@ -54,25 +54,13 @@
#include "nsIEventQueueService.h"
#include <Quickdraw.h>
// Define Class IDs -- i hate having to do this
static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID);
// from MacHeaders.c
#ifndef topLeft
#define topLeft(r) (((Point *) &(r))[0])
#endif
#ifndef botRight
#define botRight(r) (((Point *) &(r))[1])
#endif
// externs defined in nsWindow.cpp
// externs defined in nsChildView.mm
extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget;
#define kWindowPositionSlop 20
NS_IMPL_ISUPPORTS_INHERITED0(nsCocoaWindow, Inherited)
//
@ -609,6 +597,26 @@ nsIMenuBar* nsCocoaWindow::GetMenuBar()
}
NS_IMETHODIMP nsCocoaWindow::CaptureRollupEvents(nsIRollupListener * aListener,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
if (aDoCapture) {
NS_IF_RELEASE(gRollupListener);
NS_IF_RELEASE(gRollupWidget);
gRollupListener = aListener;
NS_ADDREF(aListener);
gRollupWidget = this;
NS_ADDREF(this);
} else {
NS_IF_RELEASE(gRollupListener);
NS_IF_RELEASE(gRollupWidget);
}
return NS_OK;
}
@implementation WindowDelegate
@ -622,7 +630,9 @@ nsIMenuBar* nsCocoaWindow::GetMenuBar()
- (void)windowDidResize:(NSNotification *)aNotification
{
if (!mGeckoWindow->IsResizing()) {
if (mGeckoWindow->IsResizing())
return;
// must remember to give Gecko top-left, not straight cocoa origin
// and that Gecko already compensates for the title bar, so we have to
// strip it out here.
@ -630,7 +640,6 @@ nsIMenuBar* nsCocoaWindow::GetMenuBar()
mGeckoWindow->Resize (NS_STATIC_CAST(PRInt32,frameRect.size.width),
NS_STATIC_CAST(PRInt32,frameRect.size.height - nsCocoaWindow::kTitleBarHeight), PR_TRUE);
}
}
- (void)windowDidBecomeMain:(NSNotification *)aNotification
@ -648,28 +657,32 @@ nsIMenuBar* nsCocoaWindow::GetMenuBar()
- (void)windowDidResignMain:(NSNotification *)aNotification
{
//printf(@"got deactivate");
// roll up any popups
if (gRollupListener != nsnull && gRollupWidget != nsnull)
gRollupListener->Rollup();
// tell Gecko that we lost focus
nsGUIEvent guiEvent(PR_TRUE, NS_LOSTFOCUS, mGeckoWindow);
guiEvent.time = PR_IntervalNow();
nsEventStatus status = nsEventStatus_eIgnore;
mGeckoWindow->DispatchEvent(&guiEvent, status);
}
- (void)windowDidBecomeKey:(NSNotification *)aNotification
- (void)windowWillMove:(NSNotification *)aNotification
{
//printf("we're key window\n");
// roll up any popups
if (gRollupListener != nsnull && gRollupWidget != nsnull)
gRollupListener->Rollup();
}
- (void)windowDidResignKey:(NSNotification *)aNotification
{
//printf("we're not the key window\n");
}
- (void)windowDidMove:(NSNotification *)aNotification
{
}
-(void)windowWillClose:(NSNotification *)aNotification
{
// roll up any popups
if (gRollupListener != nsnull && gRollupWidget != nsnull)
gRollupListener->Rollup();
nsGUIEvent guiEvent(PR_TRUE, NS_XUL_CLOSE, mGeckoWindow);
guiEvent.time = PR_IntervalNow();
nsEventStatus status = nsEventStatus_eIgnore;
@ -677,4 +690,12 @@ nsIMenuBar* nsCocoaWindow::GetMenuBar()
}
- (void)windowWillMiniaturize:(NSNotification *)aNotification
{
// roll up any popups
if (gRollupListener != nsnull && gRollupWidget != nsnull)
gRollupListener->Rollup();
}
@end