fixed up messaging

git-svn-id: svn://10.0.0.236/trunk@8092 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dcone%netscape.com
1998-08-17 15:18:28 +00:00
parent d108641113
commit 9be255dd28
5 changed files with 257 additions and 309 deletions

View File

@@ -20,7 +20,7 @@
#include "nsIAppShell.h"
#include "nsWindow.h"
#include <stdlib.h>
#include "nsMacMessagePump.h"
//XtAppContext gAppContext;
@@ -53,87 +53,15 @@ void nsAppShell::Create(int* argc, char ** argv)
// Enter a message handler loop
//
//-------------------------------------------------------------------------
nsresult nsAppShell::Run()
{
EventRecord theevent;
RgnHandle fMouseRgn=NULL;
long sleep=0;
PRInt16 haveevent;
WindowPtr whichwindow;
#define SUSPENDRESUMEMESSAGE 0x01
#define MOUSEMOVEDMESSAGE 0xFA
mRunning = TRUE;
nsMacMessagePump *macpump;
while(mRunning)
{
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);
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;
}
}
}
mMessages = new nsMacMessenger();
macpump = new nsMacMessagePump( mMessages );
macpump->DoMessagePump();
//if (mDispatchListener)
//mDispatchListener->AfterDispatch();
@@ -143,103 +71,14 @@ WindowPtr whichwindow;
//-------------------------------------------------------------------------
//
// Handle and pass on Idle events
// nsAppShell constructor
//
//-------------------------------------------------------------------------
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
//
//-------------------------------------------------------------------------
void nsAppShell::Exit()
{
mRunning = FALSE;
if(mMessages)
mMessages->Quit();
}
//-------------------------------------------------------------------------
@@ -251,6 +90,7 @@ nsAppShell::nsAppShell()
{
mRefCnt = 0;
mDispatchListener = 0;
mMessages = 0;
}
//-------------------------------------------------------------------------