From 540f20c743669bb7d413ee1711da010bbaedb44d Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Tue, 11 Aug 1998 20:17:06 +0000 Subject: [PATCH] updated message pump git-svn-id: svn://10.0.0.236/trunk@7767 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/mac/nsAppShell.cpp | 164 ++++++++++++++++++++++++-- mozilla/widget/src/mac/nsAppShell.h | 19 ++- 2 files changed, 172 insertions(+), 11 deletions(-) diff --git a/mozilla/widget/src/mac/nsAppShell.cpp b/mozilla/widget/src/mac/nsAppShell.cpp index 3162151b62c..7a464bcb487 100644 --- a/mozilla/widget/src/mac/nsAppShell.cpp +++ b/mozilla/widget/src/mac/nsAppShell.cpp @@ -18,13 +18,8 @@ #include "nsAppShell.h" #include "nsIAppShell.h" +#include "nsWindow.h" #include -#include -#include -#include -#include -#include -#include //XtAppContext gAppContext; @@ -40,7 +35,6 @@ NS_IMPL_ISUPPORTS(nsAppShell,kIAppShellIID); void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener) { mDispatchListener = aDispatchListener; - mToolKit = new nsToolkit(); } //------------------------------------------------------------------------- @@ -51,7 +45,7 @@ void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener) void nsAppShell::Create(int* argc, char ** argv) { - + mToolKit = new nsToolkit(); } //------------------------------------------------------------------------- @@ -66,16 +60,78 @@ EventRecord theevent; RgnHandle fMouseRgn=NULL; long sleep=0; PRInt16 haveevent; +WindowPtr whichwindow; + +#define SUSPENDRESUMEMESSAGE 0x01 +#define MOUSEMOVEDMESSAGE 0xFA mRunning = TRUE; + while(mRunning) { - haveevent = WaitNextEvent(everyEvent,&theevent,sleep,fMouseRgn); + haveevent = ::WaitNextEvent(everyEvent,&theevent,sleep,fMouseRgn); if(haveevent) { switch(theevent.what) { + case nullEvent: + IdleWidgets(); + break; + case diskEvt: + if(theevent.message<0) + { + // error, bad disk mount + } + break; + case keyUp: + break; + case keyDown: + case autoKey: + doKey(&theevent); + break; + this->Exit(); + break; + case mouseDown: + DoMouseDown(&theevent); + break; + case mouseUp: + break; + case updateEvt: + whichwindow = (WindowPtr)theevent.message; + break; + case activateEvt: + whichwindow = (WindowPtr)theevent.message; + if(theevent.modifiers & activeFlag) + { + ::BringToFront(whichwindow); + ::HiliteWindow(whichwindow,TRUE); + } + else + { + ::HiliteWindow(whichwindow,FALSE); + } + break; + case osEvt: + unsigned char evtype; + + whichwindow = (WindowPtr)theevent.message; + evtype = (unsigned char) (theevent.message>>24)&0x00ff; + switch(evtype) + { + case MOUSEMOVEDMESSAGE: + break; + case SUSPENDRESUMEMESSAGE: + if(theevent.message&0x00000001) + { + // resume message + } + else + { + // suspend message + } + } + break; } } } @@ -86,6 +142,96 @@ PRInt16 haveevent; return NS_OK; } +//------------------------------------------------------------------------- +// +// Handle and pass on Idle events +// +//------------------------------------------------------------------------- +void nsAppShell::IdleWidgets() +{ +WindowPtr whichwindow; +PRInt16 partcode; +nsWindow *thewindow; +nsIWidget *thewidget; + + whichwindow = ::FrontWindow(); + while(whichwindow) + { + // idle the widget + thewindow = (nsWindow*)(((WindowPeek)whichwindow)->refCon); + + whichwindow = (WindowPtr)((WindowPeek)whichwindow)->nextWindow; + } + +} + +//------------------------------------------------------------------------- +// +// Handle the mousedown event +// +//------------------------------------------------------------------------- +void nsAppShell::DoMouseDown(EventRecord *aTheEvent) +{ +WindowPtr whichwindow; +PRInt16 partcode; +nsWindow *thewindow; +nsIWidget *thewidget; + + partcode = FindWindow(aTheEvent->where,&whichwindow); + + if(whichwindow!=0) + { + thewindow = (nsWindow*)(((WindowPeek)whichwindow)->refCon); + thewidget = thewindow->FindWidgetHit(aTheEvent->where); + + switch(partcode) + { + case inSysWindow: + break; + case inContent: + break; + case inDrag: + break; + case inGrow: + break; + case inGoAway: + break; + case inZoomIn: + case inZoomOut: + break; + case inMenuBar: + break; + } + } +} + +//------------------------------------------------------------------------- +// +// Handle the key events +// +//------------------------------------------------------------------------- +void nsAppShell::doKey(EventRecord *aTheEvent) +{ +char ch; +WindowPtr whichwindow; + + ch = (char)(aTheEvent->message & charCodeMask); + if(aTheEvent->modifiers&cmdKey) + { + // do a menu key command + } + else + { + whichwindow = FrontWindow(); + if(whichwindow) + { + // generate a keydown event for the widget + } + } + + +} + //------------------------------------------------------------------------- // // Exit a message handler loop diff --git a/mozilla/widget/src/mac/nsAppShell.h b/mozilla/widget/src/mac/nsAppShell.h index 7d093b321ff..4f8ec1bb4bf 100644 --- a/mozilla/widget/src/mac/nsAppShell.h +++ b/mozilla/widget/src/mac/nsAppShell.h @@ -21,6 +21,12 @@ #include "nsIAppShell.h" #include "nsToolKit.h" +#include +#include +#include +#include +#include +#include /** @@ -30,12 +36,19 @@ class nsAppShell : public nsIAppShell { private: - //Widget mTopLevel; - //XtAppContext mAppContext; nsDispatchListener* mDispatchListener; nsToolkit* mToolKit; PRBool mRunning; + + // CLASS METHODS + private: + void DoMouseDown(EventRecord *aTheEvent); + void IdleWidgets(); + void doKey(EventRecord *aTheEvent); + + + public: nsAppShell(); virtual ~nsAppShell(); @@ -47,6 +60,8 @@ class nsAppShell : public nsIAppShell virtual void Create(int* argc, char ** argv); virtual nsresult Run(); virtual void Exit(); + + virtual void SetDispatchListener(nsDispatchListener* aDispatchListener);