diff --git a/lib/mac/NSStdLib/SIOUXExport.exp b/lib/mac/NSStdLib/SIOUXExport.exp index d6eedf6eabd..e69de29bb2d 100644 --- a/lib/mac/NSStdLib/SIOUXExport.exp +++ b/lib/mac/NSStdLib/SIOUXExport.exp @@ -1,3 +0,0 @@ -InitializeSIOUX -SIOUXHandleOneEvent -SIOUXSettings diff --git a/lib/mac/NSStdLib/include/macstdlibextras.h b/lib/mac/NSStdLib/include/macstdlibextras.h index 1732ee4989e..552b37cad48 100644 --- a/lib/mac/NSStdLib/include/macstdlibextras.h +++ b/lib/mac/NSStdLib/include/macstdlibextras.h @@ -25,6 +25,14 @@ ANSII headers. */ +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __QUICKDRAW__ +#include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -39,6 +47,7 @@ extern void InitializeMacToolbox(void); // also calls InitializeSIOUX(false) if #if DEBUG extern void InitializeSIOUX(unsigned char isStandAlone); +extern Boolean IsSIOUXWindow(WindowPtr inWindow); #endif /* DEBUG */ #ifdef __cplusplus diff --git a/lib/mac/NSStdLib/src/macstdlibextras.c b/lib/mac/NSStdLib/src/macstdlibextras.c index 41bccbf7b10..5ba89fa76ae 100644 --- a/lib/mac/NSStdLib/src/macstdlibextras.c +++ b/lib/mac/NSStdLib/src/macstdlibextras.c @@ -23,7 +23,7 @@ #include "macstdlibextras.h" -#include +#include #include #include @@ -210,4 +210,9 @@ void InitializeSIOUX(unsigned char isStandAlone) } +Boolean IsSIOUXWindow(WindowPtr inWindow) +{ + return SIOUXIsAppWindow(inWindow); +} + #endif diff --git a/widget/src/mac/nsMacMessagePump.cpp b/widget/src/mac/nsMacMessagePump.cpp index 21a87b23b99..564d70ccf40 100644 --- a/widget/src/mac/nsMacMessagePump.cpp +++ b/widget/src/mac/nsMacMessagePump.cpp @@ -85,9 +85,6 @@ const short kMinWindowWidth = 125; const short kMinWindowHeight = 150; -NS_WIDGET nsMacMessagePump::nsWindowlessMenuEventHandler nsMacMessagePump::gWindowlessMenuEventHandler = nsnull; - - extern nsIRollupListener * gRollupListener; extern nsIWidget * gRollupWidget; @@ -217,6 +214,23 @@ nsMacMessagePump::~nsMacMessagePump() // } + +//================================================================= +/* Return the frontmost window that is not the SIOUX console + */ +WindowPtr nsMacMessagePump::GetFrontApplicationWindow() +{ + WindowPtr firstAppWindow = ::FrontWindow(); + +#if DEBUG + if (IsSIOUXWindow(firstAppWindow)) + firstAppWindow = ::GetNextWindow(firstAppWindow); +#endif + + return firstAppWindow; +} + + //================================================================= /* Runs the message pump for the macintosh * @update dc 08/31/98 @@ -747,7 +761,7 @@ void nsMacMessagePump::DoMouseUp(EventRecord &anEvent) // when the user clicks a widget, keeps the mouse button pressed and // releases it outside the window, the event needs to be reported to // the widget so that it can deactivate itself. - whichWindow = ::FrontWindow(); + whichWindow = GetFrontApplicationWindow(); } DispatchOSEventToRaptor(anEvent, whichWindow); } @@ -771,7 +785,7 @@ void nsMacMessagePump::DoMouseMove(EventRecord &anEvent) partCode = ::FindWindow(anEvent.where, &whichWindow); if (whichWindow == nil) - whichWindow = ::FrontWindow(); + whichWindow = GetFrontApplicationWindow(); /* Disable mouse moved events for windowshaded windows -- this prevents tooltips from popping up in empty space. @@ -808,7 +822,7 @@ void nsMacMessagePump::DoKey(EventRecord &anEvent) //} //else { - PRBool handled = DispatchOSEventToRaptor(anEvent, ::FrontWindow()); + PRBool handled = DispatchOSEventToRaptor(anEvent, GetFrontApplicationWindow()); /* we want to call this if cmdKey is pressed and no other modifier keys are pressed */ if((!handled) && (anEvent.what == keyDown) && (anEvent.modifiers == cmdKey) ) { @@ -849,6 +863,8 @@ void nsMacMessagePump::DoDisk(const EventRecord& anEvent) // DoMenu // //------------------------------------------------------------------------- +extern Boolean SIOUXIsAppWindow(WindowPtr window); + void nsMacMessagePump::DoMenu(EventRecord &anEvent, long menuResult) { // The app can handle its menu commands here or @@ -881,16 +897,8 @@ extern const PRInt16 kAppleMenuID; // Danger Will Robinson!!! - this currently r // Note that we still give Raptor a shot at the event as it will eventually // handle the About... selection - - if (mMessageSink->IsRaptorWindow(::FrontWindow())) - { - DispatchMenuCommandToRaptor(anEvent, menuResult); - } - else - { - if (gWindowlessMenuEventHandler != nsnull) - gWindowlessMenuEventHandler(menuResult); - } + DispatchMenuCommandToRaptor(anEvent, menuResult); + HiliteMenu(0); } @@ -960,9 +968,10 @@ PRBool nsMacMessagePump::DispatchMenuCommandToRaptor( long menuResult) { PRBool handled = PR_FALSE; + WindowPtr theFrontWindow = GetFrontApplicationWindow(); - if (mMessageSink->IsRaptorWindow(::FrontWindow())) - handled = mMessageSink->DispatchMenuCommand(anEvent, menuResult); + if (mMessageSink->IsRaptorWindow(theFrontWindow)) + handled = mMessageSink->DispatchMenuCommand(anEvent, menuResult, theFrontWindow); return handled; } diff --git a/widget/src/mac/nsMacMessagePump.h b/widget/src/mac/nsMacMessagePump.h index 3ba8f7bc751..6d555daf5ed 100644 --- a/widget/src/mac/nsMacMessagePump.h +++ b/widget/src/mac/nsMacMessagePump.h @@ -92,15 +92,8 @@ private: PRBool BrowserIsBusy(); -private: + WindowPtr GetFrontApplicationWindow(); - typedef void (*nsWindowlessMenuEventHandler) (PRInt32 menuResult); - static nsWindowlessMenuEventHandler gWindowlessMenuEventHandler; - -public: - static void SetWindowlessMenuEventHandler(nsWindowlessMenuEventHandler func) - {gWindowlessMenuEventHandler = func;} - }; diff --git a/widget/src/mac/nsMacMessageSink.cpp b/widget/src/mac/nsMacMessageSink.cpp index ed9998704ea..af7554ba6e8 100644 --- a/widget/src/mac/nsMacMessageSink.cpp +++ b/widget/src/mac/nsMacMessageSink.cpp @@ -55,12 +55,12 @@ NS_EXPORT PRBool nsMacMessageSink::DispatchOSEvent( //------------------------------------------------------------------------- NS_EXPORT PRBool nsMacMessageSink::DispatchMenuCommand( EventRecord &anEvent, - long menuResult) + long menuResult, + WindowPtr aWindow) { PRBool eventHandled = PR_FALSE; - nsMacWindow* raptorWindow = GetNSWindowFromMacWindow(::FrontWindow()); - + nsMacWindow* raptorWindow = GetNSWindowFromMacWindow(aWindow); if (raptorWindow) { eventHandled = raptorWindow->HandleMenuCommand(anEvent, menuResult); diff --git a/widget/src/mac/nsMacMessageSink.h b/widget/src/mac/nsMacMessageSink.h index d8530ee3636..8dae2e6ace6 100644 --- a/widget/src/mac/nsMacMessageSink.h +++ b/widget/src/mac/nsMacMessageSink.h @@ -60,7 +60,7 @@ private: public: PRBool DispatchOSEvent(EventRecord &anEvent, WindowPtr aWindow); - PRBool DispatchMenuCommand(EventRecord &anEvent, long menuResult); + PRBool DispatchMenuCommand(EventRecord &anEvent, long menuResult, WindowPtr aWindow); static void AddRaptorWindowToList(WindowPtr wind, nsMacWindow* theRaptorWindow); static void RemoveRaptorWindowFromList(WindowPtr wind);