Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
jGNE.cpp File Reference
#include "jGNE.h"
#include <MixedMode.h>
#include <Memory.h>
#include <LowMem.h>
#include <TextUtils.h>

Go to the source code of this file.


struct  Jump
 A 68K jump vector. More...


static void GNEFilter (EventRecord *event, Boolean *result)
OSStatus InstallEventFilter (EventFilterProcPtr filter)
OSStatus RemoveEventFilter ()


static RoutineDescriptor theGNEFilterDescriptor = BUILD_ROUTINE_DESCRIPTOR(uppGetNextEventFilterProcInfo, GNEFilter)
static JumptheGNEFilterJump
static GetNextEventFilterUPP theOldGNEFilterUPP = NULL
static EventFilterProcPtr theEventFilter = NULL
static Str63 theAppName

Class Documentation

struct Jump

A 68K jump vector.

Definition at line 58 of file jGNE.cpp.

Class Members
UniversalProcPtr addr
unsigned short jmp

Function Documentation

static void GNEFilter ( EventRecord *  event,
Boolean result 
) [static]

Definition at line 126 of file jGNE.cpp.

       // call next filter in chain first.
       if (theOldGNEFilterUPP != NULL)
              CallGetNextEventFilterProc(theOldGNEFilterUPP, event, result);

       // now, let the filter proc have a crack at the event.
       if (*result) {
              // only call the filter if called in the current application's context.
              /* if (::EqualString(theAppName, LMGetCurApName(), true, true)) */
                     // prevent recursive calls to the filter.
                     static Boolean inFilter = false;
                     if (! inFilter) {
                            inFilter = true;
                            Boolean filteredEvent = theEventFilter(event);
                            if (filteredEvent) {
                                   // consume the event by making it a nullEvent.
                                   event->what = nullEvent;
                                   *result = false;
                            inFilter = false;

Here is the call graph for this function:

Definition at line 74 of file jGNE.cpp.

       if (theEventFilter == NULL) {
              theEventFilter = filter;

              // record the current application's name.
              StringPtr currentAppName = LMGetCurApName();
              ::BlockMoveData(currentAppName, theAppName, 1 + currentAppName[0]);

              // allocate a jump vector in the System heap, so it will be retained after termination.
              if (theGNEFilterJump == NULL) {
                     theGNEFilterJump = (Jump*) NewPtrSys(sizeof(Jump));
                     if (theGNEFilterJump == NULL)
                            return MemError();
                     theGNEFilterJump->jmp = 0x4EF9;
                     theGNEFilterJump->addr = &theGNEFilterDescriptor;
                     // get previous event filter routine.
                     theOldGNEFilterUPP = LMGetGNEFilter();
              } else {
                     // our previously allocated Jump is still installed, use it.
                     theOldGNEFilterUPP = theGNEFilterJump->addr;
                     theGNEFilterJump->addr = &theGNEFilterDescriptor;
              return noErr;
       return paramErr;

Definition at line 106 of file jGNE.cpp.

       if (theEventFilter != NULL) {
              // It's only truly safe to remove our filter, if nobody else installed one after us.
              if (LMGetGNEFilter() == GetNextEventFilterUPP(theGNEFilterJump)) {
                     // can safely restore the old filter.
                     theGNEFilterJump = NULL;
              } else {
                     // modify the jump instruction to point to the previous filter.
                     theGNEFilterJump->addr = theOldGNEFilterUPP;
              theOldGNEFilterUPP = NULL;
              theEventFilter = NULL;
              return noErr;
       return paramErr;

Variable Documentation

Str63 theAppName [static]

Definition at line 72 of file jGNE.cpp.

Definition at line 70 of file jGNE.cpp.

RoutineDescriptor theGNEFilterDescriptor = BUILD_ROUTINE_DESCRIPTOR(uppGetNextEventFilterProcInfo, GNEFilter) [static]

Definition at line 67 of file jGNE.cpp.

Definition at line 68 of file jGNE.cpp.

GetNextEventFilterUPP theOldGNEFilterUPP = NULL [static]

Definition at line 69 of file jGNE.cpp.