зеркало из https://github.com/mozilla/gecko-dev.git
updated message pump
This commit is contained in:
Родитель
19a57e8289
Коммит
91b3551004
|
@ -18,13 +18,8 @@
|
||||||
|
|
||||||
#include "nsAppShell.h"
|
#include "nsAppShell.h"
|
||||||
#include "nsIAppShell.h"
|
#include "nsIAppShell.h"
|
||||||
|
#include "nsWindow.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Fonts.h>
|
|
||||||
#include <TextEdit.h>
|
|
||||||
#include <Dialogs.h>
|
|
||||||
#include <Traps.h>
|
|
||||||
#include <Events.h>
|
|
||||||
#include <Menus.h>
|
|
||||||
|
|
||||||
|
|
||||||
//XtAppContext gAppContext;
|
//XtAppContext gAppContext;
|
||||||
|
@ -40,7 +35,6 @@ NS_IMPL_ISUPPORTS(nsAppShell,kIAppShellIID);
|
||||||
void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
||||||
{
|
{
|
||||||
mDispatchListener = aDispatchListener;
|
mDispatchListener = aDispatchListener;
|
||||||
mToolKit = new nsToolkit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -51,7 +45,7 @@ void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
||||||
|
|
||||||
void nsAppShell::Create(int* argc, char ** argv)
|
void nsAppShell::Create(int* argc, char ** argv)
|
||||||
{
|
{
|
||||||
|
mToolKit = new nsToolkit();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -66,16 +60,78 @@ EventRecord theevent;
|
||||||
RgnHandle fMouseRgn=NULL;
|
RgnHandle fMouseRgn=NULL;
|
||||||
long sleep=0;
|
long sleep=0;
|
||||||
PRInt16 haveevent;
|
PRInt16 haveevent;
|
||||||
|
WindowPtr whichwindow;
|
||||||
|
|
||||||
|
#define SUSPENDRESUMEMESSAGE 0x01
|
||||||
|
#define MOUSEMOVEDMESSAGE 0xFA
|
||||||
|
|
||||||
mRunning = TRUE;
|
mRunning = TRUE;
|
||||||
|
|
||||||
|
|
||||||
while(mRunning)
|
while(mRunning)
|
||||||
{
|
{
|
||||||
haveevent = WaitNextEvent(everyEvent,&theevent,sleep,fMouseRgn);
|
haveevent = ::WaitNextEvent(everyEvent,&theevent,sleep,fMouseRgn);
|
||||||
if(haveevent)
|
if(haveevent)
|
||||||
{
|
{
|
||||||
switch(theevent.what)
|
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;
|
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
|
// Exit a message handler loop
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
|
|
||||||
#include "nsIAppShell.h"
|
#include "nsIAppShell.h"
|
||||||
#include "nsToolKit.h"
|
#include "nsToolKit.h"
|
||||||
|
#include <Fonts.h>
|
||||||
|
#include <TextEdit.h>
|
||||||
|
#include <Dialogs.h>
|
||||||
|
#include <Traps.h>
|
||||||
|
#include <Events.h>
|
||||||
|
#include <Menus.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,12 +36,19 @@
|
||||||
class nsAppShell : public nsIAppShell
|
class nsAppShell : public nsIAppShell
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
//Widget mTopLevel;
|
|
||||||
//XtAppContext mAppContext;
|
|
||||||
nsDispatchListener* mDispatchListener;
|
nsDispatchListener* mDispatchListener;
|
||||||
nsToolkit* mToolKit;
|
nsToolkit* mToolKit;
|
||||||
PRBool mRunning;
|
PRBool mRunning;
|
||||||
|
|
||||||
|
|
||||||
|
// CLASS METHODS
|
||||||
|
private:
|
||||||
|
void DoMouseDown(EventRecord *aTheEvent);
|
||||||
|
void IdleWidgets();
|
||||||
|
void doKey(EventRecord *aTheEvent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
nsAppShell();
|
nsAppShell();
|
||||||
virtual ~nsAppShell();
|
virtual ~nsAppShell();
|
||||||
|
@ -47,6 +60,8 @@ class nsAppShell : public nsIAppShell
|
||||||
virtual void Create(int* argc, char ** argv);
|
virtual void Create(int* argc, char ** argv);
|
||||||
virtual nsresult Run();
|
virtual nsresult Run();
|
||||||
virtual void Exit();
|
virtual void Exit();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual void SetDispatchListener(nsDispatchListener* aDispatchListener);
|
virtual void SetDispatchListener(nsDispatchListener* aDispatchListener);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче