2006-03-17 23:35:39 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-11-06 15:35:24 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-08-25 23:02:50 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-11-06 15:35:24 +00:00
|
|
|
*
|
2004-08-25 23:02:50 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2001-11-06 15:35:24 +00:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
2006-01-05 17:07:01 +00:00
|
|
|
* Contributor(s):
|
|
|
|
* Josh Aas <josh@mozilla.com>
|
2001-11-06 15:35:24 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-08-25 23:02:50 +00:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-11-06 15:35:24 +00:00
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-08-25 23:02:50 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-11-06 15:35:24 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-08-25 23:02:50 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-11-06 15:35:24 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsCocoaWindow.h"
|
|
|
|
|
2006-04-06 07:41:34 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-11-06 15:35:24 +00:00
|
|
|
#include "nsIServiceManager.h" // for drag and drop
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIDragService.h"
|
|
|
|
#include "nsIDragSession.h"
|
|
|
|
#include "nsIDragSessionMac.h"
|
|
|
|
#include "nsIScreen.h"
|
|
|
|
#include "nsIScreenManager.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsMacResources.h"
|
|
|
|
#include "nsIRollupListener.h"
|
2006-04-07 04:51:16 +00:00
|
|
|
#include "nsChildView.h"
|
2006-04-06 07:41:34 +00:00
|
|
|
#include "nsIAppShell.h"
|
|
|
|
#include "nsIAppShellService.h"
|
|
|
|
#include "nsIBaseWindow.h"
|
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
|
|
#include "nsIXULWindow.h"
|
2001-11-06 15:35:24 +00:00
|
|
|
|
|
|
|
// Define Class IDs -- i hate having to do this
|
|
|
|
static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
|
|
|
|
2006-03-07 20:02:09 +00:00
|
|
|
// externs defined in nsChildView.mm
|
2001-11-06 15:35:24 +00:00
|
|
|
extern nsIRollupListener * gRollupListener;
|
|
|
|
extern nsIWidget * gRollupWidget;
|
2006-04-07 04:51:16 +00:00
|
|
|
extern BOOL gSomeMenuBarPainted;
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2006-04-06 07:41:34 +00:00
|
|
|
#define NS_APPSHELLSERVICE_CONTRACTID "@mozilla.org/appshell/appShellService;1"
|
|
|
|
|
|
|
|
// call getHiddenWindowNativeMenu, don't use this directly
|
2006-04-07 04:51:16 +00:00
|
|
|
static nsIMenuBar* gHiddenWindowMenuBar;
|
2006-04-06 07:41:34 +00:00
|
|
|
|
2003-09-08 00:31:50 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(nsCocoaWindow, Inherited)
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2006-03-10 20:51:48 +00:00
|
|
|
|
2006-04-06 05:31:16 +00:00
|
|
|
// get the highest point on any screen
|
|
|
|
static float HighestPointOnAnyScreen()
|
2006-03-10 20:51:48 +00:00
|
|
|
{
|
|
|
|
float highestScreenPoint = 0.0;
|
|
|
|
NSArray* allScreens = [NSScreen screens];
|
|
|
|
for (unsigned int i = 0; i < [allScreens count]; i++) {
|
|
|
|
NSRect currScreenFrame = [[allScreens objectAtIndex:i] frame];
|
|
|
|
float currScreenHighestPoint = currScreenFrame.origin.y + currScreenFrame.size.height;
|
|
|
|
if (currScreenHighestPoint > highestScreenPoint)
|
|
|
|
highestScreenPoint = currScreenHighestPoint;
|
|
|
|
}
|
2006-04-06 05:31:16 +00:00
|
|
|
return highestScreenPoint;
|
|
|
|
}
|
|
|
|
|
2006-03-10 20:51:48 +00:00
|
|
|
|
2006-04-06 05:31:16 +00:00
|
|
|
/*
|
|
|
|
* Gecko rects (nsRect) contain an origin (x,y) in a coordinate
|
|
|
|
* system with (0,0) in the top-left of the screen. Cocoa rects
|
|
|
|
* (NSRect) contain an origin (x,y) in a coordinate system with
|
|
|
|
* (0,0) in the bottom-left of the screen. Both nsRect and NSRect
|
|
|
|
* contain width/height info, with no difference in their use.
|
|
|
|
*/
|
|
|
|
static NSRect geckoRectToCocoaRect(const nsRect &geckoRect)
|
|
|
|
{
|
2006-03-10 20:51:48 +00:00
|
|
|
// We only need to change the Y coordinate by starting with the screen
|
|
|
|
// height, subtracting the gecko Y coordinate, and subtracting the
|
|
|
|
// height.
|
|
|
|
return NSMakeRect(geckoRect.x,
|
2006-04-06 05:31:16 +00:00
|
|
|
HighestPointOnAnyScreen() - geckoRect.y - geckoRect.height,
|
2006-03-10 20:51:48 +00:00
|
|
|
geckoRect.width,
|
|
|
|
geckoRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-06 05:31:16 +00:00
|
|
|
/*
|
|
|
|
* See explanation for geckoRectToCocoaRect, guess what this does...
|
|
|
|
*/
|
|
|
|
static nsRect cocoaRectToGeckoRect(const NSRect &cocoaRect)
|
|
|
|
{
|
|
|
|
// We only need to change the Y coordinate by starting with the screen
|
|
|
|
// height, subtracting the gecko Y coordinate, and subtracting the
|
|
|
|
// height.
|
|
|
|
|
|
|
|
return nsRect((nscoord)cocoaRect.origin.x,
|
|
|
|
(nscoord)(HighestPointOnAnyScreen() - (cocoaRect.origin.y + cocoaRect.size.height)),
|
|
|
|
(nscoord)cocoaRect.size.width,
|
|
|
|
(nscoord)cocoaRect.size.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
//
|
|
|
|
// nsCocoaWindow constructor
|
|
|
|
//
|
2005-10-07 23:31:45 +00:00
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
nsCocoaWindow::nsCocoaWindow()
|
2006-02-07 19:15:42 +00:00
|
|
|
: mParent(nsnull)
|
2006-02-07 21:00:46 +00:00
|
|
|
, mWindow(nil)
|
2006-02-10 21:39:30 +00:00
|
|
|
, mIsSheet(PR_FALSE)
|
2001-11-19 15:02:23 +00:00
|
|
|
, mIsResizing(PR_FALSE)
|
2001-11-06 15:35:24 +00:00
|
|
|
, mWindowMadeHere(PR_FALSE)
|
2006-02-10 21:39:30 +00:00
|
|
|
, mVisible(PR_FALSE)
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsCocoaWindow destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsCocoaWindow::~nsCocoaWindow()
|
|
|
|
{
|
2005-10-07 23:31:45 +00:00
|
|
|
if (mWindow && mWindowMadeHere) {
|
2002-03-11 02:39:45 +00:00
|
|
|
[mWindow autorelease];
|
|
|
|
[mDelegate autorelease];
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-06 07:41:34 +00:00
|
|
|
static nsIMenuBar* GetHiddenWindowMenuBar()
|
|
|
|
{
|
|
|
|
if (gHiddenWindowMenuBar)
|
|
|
|
return gHiddenWindowMenuBar;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
|
|
|
if (!appShell) {
|
|
|
|
NS_WARNING("Couldn't get AppShellService in order to get hidden window ref");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULWindow> hiddenWindow;
|
|
|
|
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
|
|
|
|
if (!hiddenWindow) {
|
|
|
|
NS_WARNING("Couldn't get hidden window from appshell");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
|
|
|
|
baseHiddenWindow = do_GetInterface(hiddenWindow);
|
|
|
|
if (!baseHiddenWindow) {
|
|
|
|
NS_WARNING("Couldn't get nsIBaseWindow from hidden window (nsIXULWindow)");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> hiddenWindowWidget;
|
|
|
|
if (NS_FAILED(baseHiddenWindow->GetMainWidget(getter_AddRefs(hiddenWindowWidget)))) {
|
|
|
|
NS_WARNING("Couldn't get nsIWidget from hidden window (nsIBaseWindow)");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIWidget* hiddenWindowWidgetNoCOMPtr = hiddenWindowWidget;
|
|
|
|
nsIMenuBar* geckoMenuBar = NS_STATIC_CAST(nsCocoaWindow*, hiddenWindowWidgetNoCOMPtr)->GetMenuBar();
|
|
|
|
|
|
|
|
if (geckoMenuBar) {
|
|
|
|
gHiddenWindowMenuBar = geckoMenuBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gHiddenWindowMenuBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Utility method for implementing both Create(nsIWidget ...) and
|
|
|
|
// Create(nsNativeWidget...)
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
|
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData,
|
2006-02-10 21:39:30 +00:00
|
|
|
nsNativeWidget aNativeWindow)
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
2006-01-11 19:09:20 +00:00
|
|
|
Inherited::BaseCreate(aParent, aRect, aHandleEventFunction, aContext, aAppShell,
|
|
|
|
aToolkit, aInitData);
|
2006-02-07 19:15:42 +00:00
|
|
|
|
|
|
|
mParent = aParent;
|
2006-02-08 06:09:44 +00:00
|
|
|
|
2006-02-10 21:39:30 +00:00
|
|
|
// create a window if we aren't given one, always create if this should be a popup
|
|
|
|
if (!aNativeWindow || (aInitData && aInitData->mWindowType == eWindowType_popup)) {
|
|
|
|
// decide on a window type
|
|
|
|
PRBool allOrDefault = PR_FALSE;
|
2005-10-07 23:31:45 +00:00
|
|
|
if (aInitData) {
|
2006-02-10 21:39:30 +00:00
|
|
|
allOrDefault = aInitData->mBorderStyle == eBorderStyle_all ||
|
|
|
|
aInitData->mBorderStyle == eBorderStyle_default;
|
2001-11-19 15:02:23 +00:00
|
|
|
mWindowType = aInitData->mWindowType;
|
2006-02-10 21:39:30 +00:00
|
|
|
// if a toplevel window was requested without a titlebar, use a dialog
|
2006-02-08 06:09:44 +00:00
|
|
|
if (mWindowType == eWindowType_toplevel &&
|
|
|
|
(aInitData->mBorderStyle == eBorderStyle_none ||
|
2006-02-10 21:39:30 +00:00
|
|
|
!allOrDefault &&
|
|
|
|
!(aInitData->mBorderStyle & eBorderStyle_title)))
|
|
|
|
mWindowType = eWindowType_dialog;
|
2006-02-08 06:09:44 +00:00
|
|
|
}
|
2005-10-07 23:31:45 +00:00
|
|
|
else {
|
2006-02-10 21:39:30 +00:00
|
|
|
allOrDefault = PR_TRUE;
|
|
|
|
mWindowType = eWindowType_toplevel;
|
2005-02-16 05:14:59 +00:00
|
|
|
}
|
2001-11-19 15:02:23 +00:00
|
|
|
|
2006-02-08 06:09:44 +00:00
|
|
|
#ifdef MOZ_MACBROWSER
|
|
|
|
if (mWindowType == eWindowType_popup)
|
|
|
|
return NS_OK;
|
|
|
|
#endif
|
|
|
|
|
2006-02-10 21:39:30 +00:00
|
|
|
// we default to NSBorderlessWindowMask, add features if needed
|
|
|
|
unsigned int features = NSBorderlessWindowMask;
|
|
|
|
|
|
|
|
// Configure the window we will create based on the window type
|
|
|
|
switch (mWindowType)
|
|
|
|
{
|
|
|
|
case eWindowType_child:
|
|
|
|
// In Carbon, we made this a window of type kPlainWindowClass.
|
|
|
|
// I think that is pretty much equiv to NSBorderlessWindowMask.
|
|
|
|
break;
|
|
|
|
case eWindowType_dialog:
|
|
|
|
if (aInitData) {
|
|
|
|
// we never give dialogs a close button
|
|
|
|
switch (aInitData->mBorderStyle)
|
|
|
|
{
|
|
|
|
case eBorderStyle_none:
|
|
|
|
break;
|
|
|
|
case eBorderStyle_default:
|
|
|
|
features |= NSTitledWindowMask;
|
|
|
|
break;
|
|
|
|
case eBorderStyle_all:
|
|
|
|
features |= NSTitledWindowMask;
|
|
|
|
features |= NSResizableWindowMask;
|
|
|
|
features |= NSMiniaturizableWindowMask;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (aInitData->mBorderStyle & eBorderStyle_title) {
|
|
|
|
features |= NSTitledWindowMask;
|
|
|
|
features |= NSMiniaturizableWindowMask;
|
|
|
|
}
|
|
|
|
if (aInitData->mBorderStyle & eBorderStyle_resizeh) {
|
|
|
|
features |= NSResizableWindowMask;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
features |= NSTitledWindowMask;
|
|
|
|
features |= NSMiniaturizableWindowMask;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eWindowType_sheet:
|
|
|
|
if (aInitData) {
|
|
|
|
nsWindowType parentType;
|
|
|
|
aParent->GetWindowType(parentType);
|
|
|
|
if (parentType != eWindowType_invisible) {
|
|
|
|
// at this point we make the window a sheet
|
|
|
|
mIsSheet = PR_TRUE;
|
|
|
|
if (aInitData->mBorderStyle & eBorderStyle_resizeh) {
|
|
|
|
features = NSResizableWindowMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
features = NSMiniaturizableWindowMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
features = NSMiniaturizableWindowMask;
|
|
|
|
}
|
|
|
|
break;
|
2006-03-17 23:35:39 +00:00
|
|
|
case eWindowType_popup:
|
|
|
|
features |= NSBorderlessWindowMask;
|
|
|
|
break;
|
2006-02-10 21:39:30 +00:00
|
|
|
case eWindowType_toplevel:
|
|
|
|
features |= NSTitledWindowMask;
|
|
|
|
features |= NSMiniaturizableWindowMask;
|
|
|
|
if (allOrDefault || aInitData->mBorderStyle & eBorderStyle_close)
|
|
|
|
features |= NSClosableWindowMask;
|
|
|
|
if (allOrDefault || aInitData->mBorderStyle & eBorderStyle_resizeh)
|
|
|
|
features |= NSResizableWindowMask;
|
|
|
|
break;
|
|
|
|
case eWindowType_invisible:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Unhandled window type!");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2006-03-10 20:51:48 +00:00
|
|
|
/*
|
|
|
|
* We pass a content area rect to initialize the native Cocoa window. The
|
|
|
|
* content rect we give is the same size as the size we're given by gecko.
|
|
|
|
* The origin we're given for non-popup windows is moved down by the height
|
|
|
|
* of the menu bar so that an origin of (0,100) from gecko puts the window
|
|
|
|
* 100 pixels below the top of the available desktop area. We also move the
|
|
|
|
* origin down by the height of a title bar if it exists. This is so the
|
|
|
|
* origin that gecko gives us for the top-left of the window turns out to
|
|
|
|
* be the top-left of the window we create. This is how it was done in
|
|
|
|
* Carbon. If it ought to be different we'll probably need to look at all
|
|
|
|
* the callers.
|
|
|
|
*
|
|
|
|
* Note: This means that if you put a secondary screen on top of your main
|
|
|
|
* screen and open a window in the top screen, it'll be incorrectly shifted
|
|
|
|
* down by the height of the menu bar. Same thing would happen in Carbon.
|
|
|
|
*
|
|
|
|
* Note: If you pass a rect with 0,0 for an origin, the window ends up in a
|
|
|
|
* weird place for some reason. This stops that without breaking popups.
|
|
|
|
*/
|
|
|
|
NSRect rect = geckoRectToCocoaRect(aRect);
|
|
|
|
|
|
|
|
// compensate for difference between frame and content area height (e.g. title bar)
|
|
|
|
NSRect newWindowFrame = [NSWindow frameRectForContentRect:rect styleMask:features];
|
2006-03-17 23:35:39 +00:00
|
|
|
|
2006-03-10 20:51:48 +00:00
|
|
|
rect.origin.y -= (newWindowFrame.size.height - rect.size.height);
|
|
|
|
|
|
|
|
if (mWindowType != eWindowType_popup)
|
|
|
|
rect.origin.y -= ::GetMBarHeight();
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
NSLog(@"Top-level window being created at Cocoa rect: %f, %f, %f, %f\n",
|
|
|
|
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
|
|
|
#endif
|
|
|
|
|
2006-02-10 21:39:30 +00:00
|
|
|
// create the window
|
2001-11-06 15:35:24 +00:00
|
|
|
mWindow = [[NSWindow alloc] initWithContentRect:rect styleMask:features
|
2005-10-07 23:31:45 +00:00
|
|
|
backing:NSBackingStoreBuffered defer:NO];
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2006-03-17 23:35:39 +00:00
|
|
|
if (mWindowType == eWindowType_popup) {
|
|
|
|
[mWindow setLevel:NSPopUpMenuWindowLevel];
|
|
|
|
[mWindow setHasShadow:YES];
|
|
|
|
}
|
|
|
|
|
2006-02-10 21:39:30 +00:00
|
|
|
[mWindow setReleasedWhenClosed:NO];
|
2002-03-11 02:56:59 +00:00
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
// register for mouse-moved events. The default is to ignore them for perf reasons.
|
|
|
|
[mWindow setAcceptsMouseMovedEvents:YES];
|
|
|
|
|
|
|
|
// setup our notification delegate. Note that setDelegate: does NOT retain.
|
|
|
|
mDelegate = [[WindowDelegate alloc] initWithGeckoWindow:this];
|
|
|
|
[mWindow setDelegate:mDelegate];
|
|
|
|
|
2006-02-10 21:39:30 +00:00
|
|
|
mWindowMadeHere = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mWindow = (NSWindow*)aNativeWindow;
|
|
|
|
mVisible = PR_TRUE;
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create a nsCocoaWindow using a native window provided by the application
|
|
|
|
//
|
2006-02-10 21:39:30 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::Create(nsNativeWidget aNativeWindow,
|
2001-11-06 15:35:24 +00:00
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData)
|
|
|
|
{
|
|
|
|
return(StandardCreate(nsnull, aRect, aHandleEventFunction,
|
|
|
|
aContext, aAppShell, aToolkit, aInitData,
|
2006-02-10 21:39:30 +00:00
|
|
|
aNativeWindow));
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-19 15:02:23 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::Create(nsIWidget* aParent,
|
2001-11-06 15:35:24 +00:00
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData)
|
|
|
|
{
|
2001-11-19 15:02:23 +00:00
|
|
|
return(StandardCreate(aParent, aRect, aHandleEventFunction,
|
2005-10-07 23:31:45 +00:00
|
|
|
aContext, aAppShell, aToolkit, aInitData, nsnull));
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void*
|
|
|
|
nsCocoaWindow::GetNativeData(PRUint32 aDataType)
|
|
|
|
{
|
|
|
|
void* retVal = nsnull;
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
switch (aDataType) {
|
2001-11-08 21:47:44 +00:00
|
|
|
// to emulate how windows works, we always have to return a NSView
|
|
|
|
// for NS_NATIVE_WIDGET
|
|
|
|
case NS_NATIVE_WIDGET:
|
|
|
|
case NS_NATIVE_DISPLAY:
|
2001-11-06 15:35:24 +00:00
|
|
|
retVal = [mWindow contentView];
|
|
|
|
break;
|
|
|
|
|
2001-11-08 21:47:44 +00:00
|
|
|
case NS_NATIVE_WINDOW:
|
|
|
|
retVal = mWindow;
|
2001-11-06 15:35:24 +00:00
|
|
|
break;
|
2001-11-08 21:47:44 +00:00
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
case NS_NATIVE_GRAPHIC: // quickdraw port of top view (for now)
|
2001-11-06 15:35:24 +00:00
|
|
|
retVal = [[mWindow contentView] qdPort];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2002-02-12 08:30:01 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCocoaWindow::IsVisible(PRBool & aState)
|
|
|
|
{
|
|
|
|
aState = mVisible;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Hide or show this window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsCocoaWindow::Show(PRBool bState)
|
|
|
|
{
|
2006-04-06 07:41:34 +00:00
|
|
|
if (bState) {
|
2006-04-25 19:20:31 +00:00
|
|
|
if (mWindowType == eWindowType_popup) {
|
|
|
|
[mWindow orderFront:nil];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
[mWindow makeKeyAndOrderFront:nil];
|
|
|
|
}
|
2006-04-06 07:41:34 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-04-25 19:20:31 +00:00
|
|
|
[mWindow orderOut:nil];
|
2006-04-06 07:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mVisible = bState;
|
|
|
|
|
|
|
|
return NS_OK;
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-28 23:10:04 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::Enable(PRBool aState)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsCocoaWindow::IsEnabled(PRBool *aState)
|
|
|
|
{
|
|
|
|
if (aState)
|
|
|
|
*aState = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-09 01:29:18 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::ConstrainPosition(PRBool aAllowSlop,
|
|
|
|
PRInt32 *aX, PRInt32 *aY)
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Move this window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsCocoaWindow::Move(PRInt32 aX, PRInt32 aY)
|
2001-11-19 15:02:23 +00:00
|
|
|
{
|
2005-10-07 23:31:45 +00:00
|
|
|
if (mWindow) {
|
2001-11-19 15:02:23 +00:00
|
|
|
// if we're a popup, we have to convert from our parent widget's coord
|
|
|
|
// system to the global coord system first because the (x,y) we're given
|
|
|
|
// is in its coordinate system.
|
2006-02-22 23:15:25 +00:00
|
|
|
if (mWindowType == eWindowType_popup) {
|
2001-11-19 15:02:23 +00:00
|
|
|
nsRect localRect, globalRect;
|
|
|
|
localRect.x = aX;
|
|
|
|
localRect.y = aY;
|
2006-02-07 19:15:42 +00:00
|
|
|
if (mParent) {
|
|
|
|
mParent->WidgetToScreen(localRect,globalRect);
|
2001-11-19 15:02:23 +00:00
|
|
|
aX=globalRect.x;
|
|
|
|
aY=globalRect.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
NSPoint coord = {aX, aY};
|
|
|
|
|
2001-11-19 15:02:23 +00:00
|
|
|
// the point we have assumes that the screen origin is the top-left. Well,
|
|
|
|
// it's not. Use the screen object to convert.
|
|
|
|
//FIXME -- doesn't work on monitors other than primary
|
|
|
|
NSRect screenRect = [[NSScreen mainScreen] frame];
|
|
|
|
coord.y = (screenRect.origin.y + screenRect.size.height) - coord.y;
|
2005-10-07 23:31:45 +00:00
|
|
|
//printf("final coords %f %f\n", coord.x, coord.y);
|
|
|
|
//printf("- window coords before %f %f\n", [mWindow frame].origin.x, [mWindow frame].origin.y);
|
2001-11-06 15:35:24 +00:00
|
|
|
[mWindow setFrameTopLeftPoint:coord];
|
2005-10-07 23:31:45 +00:00
|
|
|
//printf("- window coords after %f %f\n", [mWindow frame].origin.x, [mWindow frame].origin.y);
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Position the window behind the given window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2003-10-07 01:19:51 +00:00
|
|
|
NS_METHOD nsCocoaWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
|
|
|
nsIWidget *aWidget, PRBool aActivate)
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// zoom/restore
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsCocoaWindow::SetSizeMode(PRInt32 aMode)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
void nsCocoaWindow::CalculateAndSetZoomedSize()
|
|
|
|
{
|
|
|
|
|
|
|
|
} // CalculateAndSetZoomedSize
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
|
|
|
{
|
|
|
|
Move(aX, aY);
|
|
|
|
Resize(aWidth, aHeight, aRepaint);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Resize this window
|
|
|
|
//
|
|
|
|
NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
|
|
|
{
|
2005-10-07 23:31:45 +00:00
|
|
|
if (mWindow) {
|
2001-11-06 15:35:24 +00:00
|
|
|
NSRect newBounds = [mWindow frame];
|
|
|
|
newBounds.size.width = aWidth;
|
2005-10-07 23:31:45 +00:00
|
|
|
if (mWindowType == eWindowType_popup)
|
2001-11-19 15:02:23 +00:00
|
|
|
newBounds.size.height = aHeight;
|
|
|
|
else
|
|
|
|
newBounds.size.height = aHeight + kTitleBarHeight; // add height of title bar
|
2001-11-06 15:35:24 +00:00
|
|
|
StartResizing();
|
|
|
|
[mWindow setFrame:newBounds display:NO];
|
|
|
|
StopResizing();
|
|
|
|
}
|
|
|
|
|
|
|
|
mBounds.width = aWidth;
|
|
|
|
mBounds.height = aHeight;
|
|
|
|
|
|
|
|
// tell gecko to update all the child widgets
|
|
|
|
ReportSizeEvent();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-04-06 05:31:16 +00:00
|
|
|
// We return the origin for the entire window (title bar and all) but
|
|
|
|
// the size of the content area. I have no idea why it was originally done
|
|
|
|
// this way, but it matches Carbon and makes things work nicely.
|
2005-10-07 23:31:45 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(nsRect &aRect)
|
|
|
|
{
|
2006-04-06 05:31:16 +00:00
|
|
|
nsRect windowFrame = cocoaRectToGeckoRect([mWindow frame]);
|
|
|
|
aRect.x = windowFrame.x;
|
|
|
|
aRect.y = windowFrame.y;
|
|
|
|
aRect.width = mBounds.width;
|
|
|
|
aRect.height = mBounds.height;
|
|
|
|
// printf("GetScreenBounds: output: %d,%d,%d,%d\n", aRect.x, aRect.y, aRect.width, aRect.height);
|
2001-11-06 15:35:24 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
PRBool nsCocoaWindow::OnPaint(nsPaintEvent &event)
|
|
|
|
{
|
|
|
|
return PR_TRUE; // don't dispatch the update event
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Set this window's title
|
|
|
|
//
|
2004-04-18 23:18:23 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::SetTitle(const nsAString& aTitle)
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
2004-04-18 23:18:23 +00:00
|
|
|
const nsString& strTitle = PromiseFlatString(aTitle);
|
|
|
|
NSString* title = [NSString stringWithCharacters:strTitle.get() length:strTitle.Length()];
|
2001-11-06 15:35:24 +00:00
|
|
|
[mWindow setTitle:title];
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Pass notification of some drag event to Gecko
|
|
|
|
//
|
|
|
|
// The drag manager has let us know that something related to a drag has
|
|
|
|
// occurred in this window. It could be any number of things, ranging from
|
|
|
|
// a drop, to a drag enter/leave, or a drag over event. The actual event
|
|
|
|
// is passed in |aMessage| and is passed along to our event hanlder so Gecko
|
|
|
|
// knows about it.
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsCocoaWindow::DragEvent ( unsigned int aMessage, Point aMouseGlobal, UInt16 aKeyModifiers )
|
|
|
|
{
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Like ::BringToFront, but constrains the window to its z-level
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2005-10-07 23:31:45 +00:00
|
|
|
void nsCocoaWindow::ComeToFront()
|
|
|
|
{
|
2001-11-06 15:35:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsCocoaWindow::ResetInputState()
|
|
|
|
{
|
2005-10-07 23:31:45 +00:00
|
|
|
// return mMacEventHandler->ResetInputState();
|
2001-11-06 15:35:24 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Invokes callback and ProcessEvent method on Event Listener object
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCocoaWindow::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus)
|
|
|
|
{
|
|
|
|
aStatus = nsEventStatus_eIgnore;
|
|
|
|
|
|
|
|
nsIWidget* aWidget = event->widget;
|
|
|
|
NS_IF_ADDREF(aWidget);
|
|
|
|
|
|
|
|
if (nsnull != mMenuListener){
|
|
|
|
if(NS_MENU_EVENT == event->eventStructType)
|
2005-10-07 23:31:45 +00:00
|
|
|
aStatus = mMenuListener->MenuSelected(static_cast<nsMenuEvent&>(*event));
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
if (mEventCallback)
|
|
|
|
aStatus = (*mEventCallback)(event);
|
|
|
|
|
|
|
|
// Dispatch to event listener if event was not consumed
|
|
|
|
if ((aStatus != nsEventStatus_eConsumeNoDefault) && (mEventListener != nsnull))
|
|
|
|
aStatus = mEventListener->ProcessEvent(*event);
|
|
|
|
|
|
|
|
NS_IF_RELEASE(aWidget);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCocoaWindow::ReportSizeEvent()
|
|
|
|
{
|
2001-11-08 21:47:44 +00:00
|
|
|
// nsEvent
|
2005-04-28 23:48:28 +00:00
|
|
|
nsSizeEvent sizeEvent(PR_TRUE, NS_SIZE, this);
|
2005-10-07 23:31:45 +00:00
|
|
|
sizeEvent.time = PR_IntervalNow();
|
2001-11-08 21:47:44 +00:00
|
|
|
|
|
|
|
// nsSizeEvent
|
2005-10-07 23:31:45 +00:00
|
|
|
sizeEvent.windowSize = &mBounds;
|
|
|
|
sizeEvent.mWinWidth = mBounds.width;
|
|
|
|
sizeEvent.mWinHeight = mBounds.height;
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2001-11-08 21:47:44 +00:00
|
|
|
// dispatch event
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
DispatchEvent(&sizeEvent, status);
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::SetMenuBar(nsIMenuBar *aMenuBar)
|
|
|
|
{
|
|
|
|
if (mMenuBar)
|
|
|
|
mMenuBar->SetParent(nsnull);
|
|
|
|
mMenuBar = aMenuBar;
|
2006-04-07 04:51:16 +00:00
|
|
|
|
|
|
|
// We paint the hidden window menu bar if no other menu bar has been painted
|
|
|
|
// yet so that some reasonable menu bar is displayed when the app starts up.
|
|
|
|
if (!gSomeMenuBarPainted && mMenuBar && (GetHiddenWindowMenuBar() == mMenuBar))
|
|
|
|
mMenuBar->Paint();
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
return NS_OK;
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
NS_IMETHODIMP nsCocoaWindow::ShowMenuBar(PRBool aShow)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
nsIMenuBar* nsCocoaWindow::GetMenuBar()
|
|
|
|
{
|
|
|
|
return mMenuBar;
|
|
|
|
}
|
2001-11-06 15:35:24 +00:00
|
|
|
|
|
|
|
|
2006-03-07 20:02:09 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
@implementation WindowDelegate
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithGeckoWindow:(nsCocoaWindow*)geckoWind
|
|
|
|
{
|
|
|
|
[super init];
|
|
|
|
mGeckoWindow = geckoWind;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-02-22 23:15:25 +00:00
|
|
|
|
2006-04-06 19:14:02 +00:00
|
|
|
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize
|
|
|
|
{
|
|
|
|
// roll up any popups
|
|
|
|
if (gRollupListener != nsnull && gRollupWidget != nsnull)
|
|
|
|
gRollupListener->Rollup();
|
|
|
|
|
|
|
|
return proposedFrameSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
- (void)windowDidResize:(NSNotification *)aNotification
|
|
|
|
{
|
2006-03-07 20:02:09 +00:00
|
|
|
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.
|
|
|
|
NSRect frameRect = [[aNotification object] frame];
|
|
|
|
mGeckoWindow->Resize (NS_STATIC_CAST(PRInt32,frameRect.size.width),
|
|
|
|
NS_STATIC_CAST(PRInt32,frameRect.size.height - nsCocoaWindow::kTitleBarHeight), PR_TRUE);
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)windowDidBecomeMain:(NSNotification *)aNotification
|
|
|
|
{
|
2005-10-07 23:31:45 +00:00
|
|
|
nsIMenuBar* myMenuBar = mGeckoWindow->GetMenuBar();
|
2006-04-06 07:41:34 +00:00
|
|
|
if (myMenuBar) {
|
|
|
|
// printf("painting window menu bar due to window becoming main\n");
|
2005-10-07 23:31:45 +00:00
|
|
|
myMenuBar->Paint();
|
2006-04-06 07:41:34 +00:00
|
|
|
}
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)windowDidResignMain:(NSNotification *)aNotification
|
|
|
|
{
|
2006-03-07 20:02:09 +00:00
|
|
|
// roll up any popups
|
|
|
|
if (gRollupListener != nsnull && gRollupWidget != nsnull)
|
|
|
|
gRollupListener->Rollup();
|
|
|
|
|
2006-04-06 07:41:34 +00:00
|
|
|
nsCOMPtr<nsIMenuBar> hiddenWindowMenuBar = GetHiddenWindowMenuBar();
|
|
|
|
if (hiddenWindowMenuBar) {
|
2006-04-21 20:35:00 +00:00
|
|
|
// printf("painting hidden window menu bar due to window losing main status\n");
|
2006-04-06 07:41:34 +00:00
|
|
|
hiddenWindowMenuBar->Paint();
|
|
|
|
}
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-07 20:02:09 +00:00
|
|
|
- (void)windowWillMove:(NSNotification *)aNotification
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
2006-03-07 20:02:09 +00:00
|
|
|
// roll up any popups
|
|
|
|
if (gRollupListener != nsnull && gRollupWidget != nsnull)
|
|
|
|
gRollupListener->Rollup();
|
2001-11-06 15:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-17 05:16:59 +00:00
|
|
|
- (BOOL)windowShouldClose:(id)sender
|
2006-02-22 23:15:25 +00:00
|
|
|
{
|
2006-03-17 05:16:59 +00:00
|
|
|
// We only want to send NS_XUL_CLOSE and let gecko close the window
|
2006-02-22 23:15:25 +00:00
|
|
|
nsGUIEvent guiEvent(PR_TRUE, NS_XUL_CLOSE, mGeckoWindow);
|
|
|
|
guiEvent.time = PR_IntervalNow();
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
mGeckoWindow->DispatchEvent(&guiEvent, status);
|
2006-03-17 05:16:59 +00:00
|
|
|
return NO; // gecko will do it
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-25 19:20:31 +00:00
|
|
|
- (void)windowWillClose:(NSNotification *)aNotification
|
2006-03-17 05:16:59 +00:00
|
|
|
{
|
|
|
|
// roll up any popups
|
|
|
|
if (gRollupListener != nsnull && gRollupWidget != nsnull)
|
|
|
|
gRollupListener->Rollup();
|
2006-02-22 23:15:25 +00:00
|
|
|
}
|
|
|
|
|
2005-10-07 23:31:45 +00:00
|
|
|
|
2006-03-07 20:02:09 +00:00
|
|
|
- (void)windowWillMiniaturize:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
// roll up any popups
|
|
|
|
if (gRollupListener != nsnull && gRollupWidget != nsnull)
|
|
|
|
gRollupListener->Rollup();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-25 19:20:31 +00:00
|
|
|
- (void)sendGotFocusAndActivate
|
|
|
|
{
|
|
|
|
if (!mGeckoWindow)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
|
|
|
|
nsGUIEvent focusGuiEvent(PR_TRUE, NS_GOTFOCUS, mGeckoWindow);
|
|
|
|
focusGuiEvent.time = PR_IntervalNow();
|
|
|
|
mGeckoWindow->DispatchEvent(&focusGuiEvent, status);
|
|
|
|
|
|
|
|
nsGUIEvent activateGuiEvent(PR_TRUE, NS_ACTIVATE, mGeckoWindow);
|
|
|
|
activateGuiEvent.time = PR_IntervalNow();
|
|
|
|
mGeckoWindow->DispatchEvent(&activateGuiEvent, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)sendLostFocusAndDeactivate
|
|
|
|
{
|
|
|
|
if (!mGeckoWindow)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
|
|
|
|
nsGUIEvent deactivateGuiEvent(PR_TRUE, NS_DEACTIVATE, mGeckoWindow);
|
|
|
|
deactivateGuiEvent.time = PR_IntervalNow();
|
|
|
|
mGeckoWindow->DispatchEvent(&deactivateGuiEvent, status);
|
|
|
|
|
|
|
|
nsGUIEvent lostfocusGuiEvent(PR_TRUE, NS_LOSTFOCUS, mGeckoWindow);
|
|
|
|
lostfocusGuiEvent.time = PR_IntervalNow();
|
|
|
|
mGeckoWindow->DispatchEvent(&lostfocusGuiEvent, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-09 01:29:18 +00:00
|
|
|
@end
|