Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:31

0001 /***********************************************************
0002 
0003 Copyright 1987, 1988, 1998  The Open Group
0004 
0005 Permission to use, copy, modify, distribute, and sell this software and its
0006 documentation for any purpose is hereby granted without fee, provided that
0007 the above copyright notice appear in all copies and that both that
0008 copyright notice and this permission notice appear in supporting
0009 documentation.
0010 
0011 The above copyright notice and this permission notice shall be included in
0012 all copies or substantial portions of the Software.
0013 
0014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0017 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0018 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0019 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0020 
0021 Except as contained in this notice, the name of The Open Group shall not be
0022 used in advertising or otherwise to promote the sale, use or other dealings
0023 in this Software without prior written authorization from The Open Group.
0024 
0025 
0026 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
0027 
0028                         All Rights Reserved
0029 
0030 Permission to use, copy, modify, and distribute this software and its
0031 documentation for any purpose and without fee is hereby granted,
0032 provided that the above copyright notice appear in all copies and that
0033 both that copyright notice and this permission notice appear in
0034 supporting documentation, and that the name of Digital not be
0035 used in advertising or publicity pertaining to distribution of the
0036 software without specific, written prior permission.
0037 
0038 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
0039 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
0040 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
0041 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
0042 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
0043 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
0044 SOFTWARE.
0045 
0046 ******************************************************************/
0047 
0048 /*
0049  * TranslateI.h - Header file private to translation management
0050  *
0051  * Author:  Gabe Beged-Dov, HP
0052  *
0053  * Former Author:   Charles Haynes
0054  *      Digital Equipment Corporation
0055  *      Western Research Laboratory
0056  * Date:    Sat Aug 29 1987
0057  */
0058 
0059 /*#define REFCNT_TRANSLATIONS*/
0060 #define CACHE_TRANSLATIONS
0061 
0062 #define TM_NO_MATCH (-2)
0063 
0064 #define _XtRStateTablePair "_XtStateTablePair"
0065 
0066 typedef unsigned char TMByteCard;
0067 typedef unsigned short TMShortCard;
0068 typedef unsigned long TMLongCard;
0069 typedef short TMShortInt;
0070 
0071 typedef struct _TMTypeMatchRec *TMTypeMatch;
0072 typedef struct _TMModifierMatchRec *TMModifierMatch;
0073 typedef struct _TMEventRec *TMEventPtr;
0074 
0075 typedef Boolean (*MatchProc)(TMTypeMatch typeMatch,
0076                  TMModifierMatch modMatch,
0077                  TMEventPtr eventSeq);
0078 
0079 typedef struct _ModToKeysymTable {
0080     Modifiers mask;
0081     int count;
0082     int idx;
0083 } ModToKeysymTable;
0084 
0085 typedef struct _LateBindings {
0086     unsigned int knot:1;
0087     unsigned int pair:1;
0088     unsigned short ref_count;   /* garbage collection */
0089     KeySym keysym;
0090 } LateBindings, *LateBindingsPtr;
0091 
0092 typedef short ModifierMask;
0093 
0094 typedef struct _ActionsRec *ActionPtr;
0095 typedef struct _ActionsRec {
0096     int idx;            /* index into quarkTable to find proc */
0097     String *params;     /* pointer to array of params */
0098     Cardinal num_params;    /* number of params */
0099     ActionPtr next;     /* next action to perform */
0100 } ActionRec;
0101 
0102 typedef struct _XtStateRec *StatePtr;
0103 typedef struct _XtStateRec {
0104     unsigned int    isCycleStart:1;
0105     unsigned int    isCycleEnd:1;
0106     TMShortCard     typeIndex;
0107     TMShortCard     modIndex;
0108     ActionPtr       actions;    /* rhs list of actions to perform */
0109     StatePtr        nextLevel;
0110 }StateRec;
0111 
0112 
0113 #define XtTableReplace  0
0114 #define XtTableAugment  1
0115 #define XtTableOverride 2
0116 #define XtTableUnmerge  3
0117 
0118 typedef unsigned int _XtTranslateOp;
0119 
0120 /*
0121  * New Definitions
0122  */
0123 typedef struct _TMModifierMatchRec{
0124     TMLongCard   modifiers;
0125     TMLongCard   modifierMask;
0126     LateBindingsPtr lateModifiers;
0127     Boolean  standard;
0128 }TMModifierMatchRec;
0129 
0130 typedef struct _TMTypeMatchRec{
0131     TMLongCard   eventType;
0132     TMLongCard   eventCode;
0133     TMLongCard   eventCodeMask;
0134     MatchProc    matchEvent;
0135 }TMTypeMatchRec;
0136 
0137 typedef struct _TMBranchHeadRec {
0138     unsigned int    isSimple:1;
0139     unsigned int    hasActions:1;
0140     unsigned int    hasCycles:1;
0141     unsigned int    more:13;
0142     TMShortCard     typeIndex;
0143     TMShortCard     modIndex;
0144 }TMBranchHeadRec, *TMBranchHead;
0145 
0146 /* NOTE: elements of this structure must match those of
0147  * TMComplexStateTreeRec and TMParseStateTreeRec.
0148  */
0149 typedef struct _TMSimpleStateTreeRec{
0150     unsigned int    isSimple:1;
0151     unsigned int    isAccelerator:1;
0152     unsigned int    mappingNotifyInterest:1;
0153     unsigned int    refCount:13;
0154     TMShortCard     numBranchHeads;
0155     TMShortCard     numQuarks;   /* # of entries in quarkTbl */
0156     TMShortCard     unused;      /* to ensure same alignment */
0157     TMBranchHeadRec *branchHeadTbl;
0158     XrmQuark        *quarkTbl;  /* table of quarkified rhs*/
0159 }TMSimpleStateTreeRec, *TMSimpleStateTree;
0160 
0161 /* NOTE: elements of this structure must match those of
0162  * TMSimpleStateTreeRec and TMParseStateTreeRec.
0163  */
0164 typedef struct _TMComplexStateTreeRec{
0165     unsigned int    isSimple:1;
0166     unsigned int    isAccelerator:1;
0167     unsigned int    mappingNotifyInterest:1;
0168     unsigned int    refCount:13;
0169     TMShortCard     numBranchHeads;
0170     TMShortCard     numQuarks;   /* # of entries in quarkTbl */
0171     TMShortCard     numComplexBranchHeads;
0172     TMBranchHeadRec *branchHeadTbl;
0173     XrmQuark        *quarkTbl;  /* table of quarkified rhs*/
0174     StatePtr        *complexBranchHeadTbl;
0175 }TMComplexStateTreeRec, *TMComplexStateTree;
0176 
0177 /* NOTE: elements of this structure must match those of
0178  * TMSimpleStateTreeRec and TMComplexStateTreeRec.
0179  */
0180 typedef struct _TMParseStateTreeRec{
0181     unsigned int    isSimple:1;
0182     unsigned int    isAccelerator:1;
0183     unsigned int    mappingNotifyInterest:1;
0184     unsigned int    isStackQuarks:1;
0185     unsigned int    isStackBranchHeads:1;
0186     unsigned int    isStackComplexBranchHeads:1;
0187     unsigned int    unused:10; /* to ensure correct alignment */
0188     TMShortCard     numBranchHeads;
0189     TMShortCard     numQuarks;   /* # of entries in quarkTbl */
0190     TMShortCard     numComplexBranchHeads;
0191     TMBranchHeadRec *branchHeadTbl;
0192     XrmQuark        *quarkTbl;  /* table of quarkified rhs*/
0193     StatePtr        *complexBranchHeadTbl;
0194     TMShortCard     branchHeadTblSize;
0195     TMShortCard     quarkTblSize; /*total size of quarkTbl */
0196     TMShortCard     complexBranchHeadTblSize;
0197     StatePtr        head;
0198 }TMParseStateTreeRec, *TMParseStateTree;
0199 
0200 typedef union _TMStateTreeRec{
0201     TMSimpleStateTreeRec    simple;
0202     TMParseStateTreeRec     parse;
0203     TMComplexStateTreeRec   complex;
0204 }*TMStateTree, **TMStateTreePtr, **TMStateTreeList;
0205 
0206 typedef struct _TMSimpleBindProcsRec {
0207     XtActionProc    *procs;
0208 }TMSimpleBindProcsRec, *TMSimpleBindProcs;
0209 
0210 typedef struct _TMComplexBindProcsRec {
0211     Widget      widget;     /*widgetID to pass to action Proc*/
0212     XtTranslations  aXlations;
0213     XtActionProc    *procs;
0214 }TMComplexBindProcsRec, *TMComplexBindProcs;
0215 
0216 typedef struct _TMSimpleBindDataRec {
0217     unsigned int        isComplex:1;    /* must be first */
0218     TMSimpleBindProcsRec    bindTbl[1]; /* variable length */
0219 }TMSimpleBindDataRec, *TMSimpleBindData;
0220 
0221 typedef struct _TMComplexBindDataRec {
0222     unsigned int        isComplex:1;    /* must be first */
0223     struct _ATranslationData    *accel_context; /* for GetValues */
0224     TMComplexBindProcsRec   bindTbl[1];     /* variable length */
0225 }TMComplexBindDataRec, *TMComplexBindData;
0226 
0227 typedef union _TMBindDataRec{
0228     TMSimpleBindDataRec     simple;
0229     TMComplexBindDataRec    complex;
0230 }*TMBindData;
0231 
0232 typedef struct _TranslationData{
0233     unsigned char       hasBindings;    /* must be first */
0234     unsigned char       operation; /*replace,augment,override*/
0235     TMShortCard         numStateTrees;
0236     struct _TranslationData     *composers[2];
0237     EventMask           eventMask;
0238     TMStateTree         stateTreeTbl[1]; /* variable length */
0239 }TranslationData;
0240 
0241 /*
0242  * ATranslations is returned by GetValues for translations that contain
0243  * accelerators.  The TM can differentiate between this and TranslationData
0244  * (that don't have a bindTbl) by looking at the first field (hasBindings)
0245  * of either structure.  All ATranslationData structures associated with a
0246  * widget are chained off the BindData record of the widget.
0247  */
0248 typedef struct _ATranslationData{
0249     unsigned char       hasBindings;    /* must be first */
0250     unsigned char       operation;
0251     struct _TranslationData *xlations;  /* actual translations */
0252     struct _ATranslationData    *next;      /* chain the contexts together */
0253     TMComplexBindProcsRec   bindTbl[1]; /* accelerator bindings */
0254 }ATranslationData, *ATranslations;
0255 
0256 typedef struct _TMConvertRec {
0257     XtTranslations  old; /* table to merge into */
0258     XtTranslations  new; /* table to merge from */
0259 } TMConvertRec;
0260 
0261 #define _XtEventTimerEventType ((TMLongCard)~0L)
0262 #define KeysymModMask       (1L<<27) /* private to TM */
0263 #define AnyButtonMask       (1L<<28) /* private to TM */
0264 
0265 typedef struct _EventRec {
0266     TMLongCard modifiers;
0267     TMLongCard modifierMask;
0268     LateBindingsPtr lateModifiers;
0269     TMLongCard eventType;
0270     TMLongCard eventCode;
0271     TMLongCard eventCodeMask;
0272     MatchProc matchEvent;
0273     Boolean standard;
0274 } Event;
0275 
0276 typedef struct _EventSeqRec *EventSeqPtr;
0277 typedef struct _EventSeqRec {
0278     Event event;    /* X event description */
0279     StatePtr state; /* private to state table builder */
0280     EventSeqPtr next;   /* next event on line */
0281     ActionPtr actions;  /* r.h.s.   list of actions to perform */
0282 } EventSeqRec;
0283 
0284 typedef EventSeqRec EventRec;
0285 typedef EventSeqPtr EventPtr;
0286 
0287 typedef struct _TMEventRec {
0288     XEvent *xev;
0289     Event event;
0290 }TMEventRec;
0291 
0292 typedef struct _ActionHookRec {
0293     struct _ActionHookRec* next; /* must remain first */
0294     XtAppContext app;
0295     XtActionHookProc proc;
0296     XtPointer closure;
0297 } ActionHookRec, *ActionHook;
0298 
0299 /* choose a number between 2 and 8 */
0300 #define TMKEYCACHELOG2 6
0301 #define TMKEYCACHESIZE (1<<TMKEYCACHELOG2)
0302 
0303 typedef struct _KeyCacheRec {
0304     unsigned char modifiers_return[256]; /* constant per KeyCode, key proc */
0305     KeyCode keycode[TMKEYCACHESIZE];
0306     unsigned char modifiers[TMKEYCACHESIZE];
0307     KeySym keysym[TMKEYCACHESIZE];
0308 } TMKeyCache;
0309 
0310 typedef struct _TMKeyContextRec {
0311     XEvent *event;
0312     unsigned long serial;
0313     KeySym keysym;
0314     Modifiers modifiers;
0315     TMKeyCache keycache;  /* keep this last, to keep offsets to others small */
0316 } TMKeyContextRec, *TMKeyContext;
0317 
0318 typedef struct _TMGlobalRec{
0319     TMTypeMatchRec      **typeMatchSegmentTbl;
0320     TMShortCard         numTypeMatches;
0321     TMShortCard         numTypeMatchSegments;
0322     TMShortCard         typeMatchSegmentTblSize;
0323     TMModifierMatchRec      **modMatchSegmentTbl;
0324     TMShortCard         numModMatches;
0325     TMShortCard         numModMatchSegments;
0326     TMShortCard         modMatchSegmentTblSize;
0327     Boolean         newMatchSemantics;
0328 #ifdef TRACE_TM
0329     XtTranslations      *tmTbl;
0330     TMShortCard         numTms;
0331     TMShortCard         tmTblSize;
0332     struct _TMBindCacheRec  **bindCacheTbl;
0333     TMShortCard         numBindCache;
0334     TMShortCard         bindCacheTblSize;
0335     TMShortCard         numLateBindings;
0336     TMShortCard         numBranchHeads;
0337     TMShortCard         numComplexStates;
0338     TMShortCard         numComplexActions;
0339 #endif /* TRACE_TM */
0340 }TMGlobalRec;
0341 
0342 _XFUNCPROTOBEGIN
0343 
0344 extern TMGlobalRec _XtGlobalTM;
0345 
0346 #define TM_MOD_SEGMENT_SIZE     16
0347 #define TM_TYPE_SEGMENT_SIZE    16
0348 
0349 #define TMGetTypeMatch(idx) \
0350   ((TMTypeMatch) \
0351    &((_XtGlobalTM.typeMatchSegmentTbl[((idx) >> 4)])[(idx) & 15]))
0352 #define TMGetModifierMatch(idx) \
0353   ((TMModifierMatch) \
0354    &((_XtGlobalTM.modMatchSegmentTbl[(idx) >> 4])[(idx) & 15]))
0355 
0356 /* Useful Access Macros */
0357 #define TMNewMatchSemantics() (_XtGlobalTM.newMatchSemantics)
0358 #define TMBranchMore(branch) (branch->more)
0359 #define TMComplexBranchHead(tree, br) \
0360   (((TMComplexStateTree)tree)->complexBranchHeadTbl[TMBranchMore(br)])
0361 
0362 #define TMGetComplexBindEntry(bindData, idx) \
0363   ((TMComplexBindProcs)&(((TMComplexBindData)bindData)->bindTbl[idx]))
0364 
0365 #define TMGetSimpleBindEntry(bindData, idx) \
0366   ((TMSimpleBindProcs)&(((TMSimpleBindData)bindData)->bindTbl[idx]))
0367 
0368 
0369 #define _InitializeKeysymTables(dpy, pd) \
0370     if (pd->keysyms == NULL) \
0371         _XtBuildKeysymTables(dpy, pd)
0372 
0373 /*
0374  * Internal Functions
0375  */
0376 
0377 extern void _XtPopup(
0378     Widget      /* widget */,
0379     XtGrabKind  /* grab_kind */,
0380     _XtBoolean  /* spring_loaded */
0381 );
0382 
0383 extern _XtString _XtPrintXlations(
0384     Widget      /* w */,
0385     XtTranslations  /* xlations */,
0386     Widget      /* accelWidget */,
0387     _XtBoolean      /* includeRHS */
0388 );
0389 
0390 extern void _XtRegisterGrabs(
0391     Widget  /* widget */
0392 );
0393 
0394 extern XtPointer _XtInitializeActionData(
0395     struct _XtActionsRec *  /* actions */,
0396     Cardinal            /* count */,
0397     _XtBoolean          /* inPlace */
0398 );
0399 
0400 extern void _XtAddEventSeqToStateTree(
0401     EventSeqPtr     /* eventSeq */,
0402     TMParseStateTree    /* stateTree */
0403 );
0404 
0405 extern Boolean _XtMatchUsingStandardMods(
0406     TMTypeMatch     /* typeMatch */,
0407     TMModifierMatch /* modMatch */,
0408     TMEventPtr      /* eventSeq */
0409 );
0410 
0411 extern Boolean _XtMatchUsingDontCareMods(
0412     TMTypeMatch     /* typeMatch */,
0413     TMModifierMatch /* modMatch */,
0414     TMEventPtr      /* eventSeq */
0415 );
0416 
0417 extern Boolean _XtRegularMatch(
0418     TMTypeMatch     /* typeMatch */,
0419     TMModifierMatch /* modMatch */,
0420     TMEventPtr      /* eventSeq */
0421 );
0422 
0423 extern Boolean _XtMatchAtom(
0424     TMTypeMatch     /* typeMatch */,
0425     TMModifierMatch /* modMatch */,
0426     TMEventPtr      /* eventSeq */
0427 );
0428 
0429 extern void _XtTranslateEvent(
0430     Widget      /* widget */,
0431     XEvent*     /* event */
0432 );
0433 
0434 #include "CallbackI.h"
0435 #include "EventI.h"
0436 #include "HookObjI.h"
0437 #include "PassivGraI.h"
0438 #include "ThreadsI.h"
0439 #include "InitialI.h"
0440 #include "ResourceI.h"
0441 #include "StringDefs.h"
0442 
0443 extern void _XtBuildKeysymTables(Display *dpy, XtPerDisplay pd);
0444 
0445 #ifndef NO_MIT_HACKS
0446 extern void  _XtDisplayTranslations(
0447     Widget      /* widget */,
0448     XEvent*     /* event */,
0449     String*     /* params */,
0450     Cardinal*       /* num_params */
0451 );
0452 
0453 extern void  _XtDisplayAccelerators(
0454     Widget      /* widget */,
0455     XEvent*     /* event */,
0456     String*     /* params */,
0457     Cardinal*       /* num_params */
0458 );
0459 
0460 extern void _XtDisplayInstalledAccelerators(
0461     Widget      /* widget */,
0462     XEvent*     /* event */,
0463     String*     /* params */,
0464     Cardinal*       /* num_params */
0465 );
0466 #endif /* ifndef NO_MIT_HACKS */
0467 
0468 extern void _XtPopupInitialize(
0469     XtAppContext    /* app_context */
0470 );
0471 
0472 extern void _XtBindActions(
0473     Widget  /* widget */,
0474     XtTM    /* tm_rec */
0475 );
0476 
0477 extern Boolean _XtComputeLateBindings(
0478     Display*        /* dpy */,
0479     LateBindingsPtr /* lateModifiers */,
0480     Modifiers*      /* computed */,
0481     Modifiers*      /* computedMask */
0482 );
0483 
0484 extern XtTranslations _XtCreateXlations(
0485     TMStateTree *   /* stateTrees */,
0486     TMShortCard     /* numStateTrees */,
0487     XtTranslations  /* first */,
0488     XtTranslations  /* second */
0489 );
0490 
0491 extern Boolean _XtCvtMergeTranslations(
0492     Display*    /* dpy */,
0493     XrmValuePtr /* args */,
0494     Cardinal*   /* num_args */,
0495     XrmValuePtr /* from */,
0496     XrmValuePtr /* to */,
0497     XtPointer*  /* closure_ret */
0498 );
0499 
0500 void _XtRemoveStateTreeByIndex(
0501     XtTranslations  /* xlations */,
0502     TMShortCard /* i */);
0503 
0504 void _XtFreeTranslations(
0505     XtAppContext    /* app */,
0506     XrmValuePtr     /* toVal */,
0507     XtPointer       /* closure */,
0508     XrmValuePtr     /* args */,
0509     Cardinal*       /* num_args */
0510 );
0511 
0512 extern TMShortCard _XtGetModifierIndex(
0513     Event*  /* event */
0514 );
0515 
0516 extern TMShortCard _XtGetQuarkIndex(
0517     TMParseStateTree    /* stateTreePtr */,
0518     XrmQuark        /* quark */
0519 );
0520 
0521 extern XtTranslations _XtGetTranslationValue(
0522     Widget      /* widget */
0523 );
0524 
0525 extern TMShortCard _XtGetTypeIndex(
0526     Event*  /* event */
0527 );
0528 
0529 extern void _XtGrabInitialize(
0530     XtAppContext    /* app */
0531 );
0532 
0533 extern void _XtInstallTranslations(
0534     Widget      /* widget */
0535 );
0536 
0537 extern void _XtRemoveTranslations(
0538     Widget      /* widget */
0539 );
0540 
0541 extern void _XtDestroyTMData(
0542     Widget      /* widget */
0543 );
0544 
0545 extern void _XtMergeTranslations(
0546     Widget      /* widget */,
0547     XtTranslations  /* newXlations */,
0548     _XtTranslateOp  /* operation */
0549 );
0550 
0551 extern void _XtActionInitialize(
0552     XtAppContext    /* app */
0553 );
0554 
0555 extern TMStateTree _XtParseTreeToStateTree(
0556     TMParseStateTree    /* parseTree */
0557 );
0558 
0559 extern String _XtPrintActions(
0560     ActionRec*  /* actions */,
0561     XrmQuark*   /* quarkTbl */
0562 );
0563 
0564 extern String _XtPrintState(
0565     TMStateTree /* stateTree */,
0566     TMBranchHead /* branchHead */);
0567 
0568 extern String _XtPrintEventSeq(
0569     EventSeqPtr /* eventSeq */,
0570     Display*    /* dpy */
0571 );
0572 
0573 typedef Boolean (*_XtTraversalProc)(
0574     StatePtr    /* state */,
0575     XtPointer   /* data */
0576 );
0577 
0578 extern void _XtTraverseStateTree(
0579     TMStateTree     /* tree */,
0580     _XtTraversalProc    /* func */,
0581     XtPointer       /* data */
0582 );
0583 
0584 extern void _XtTranslateInitialize(
0585     void
0586 );
0587 
0588 extern void _XtAddTMConverters(
0589     ConverterTable  /* table */
0590 );
0591 
0592 extern void _XtUnbindActions(
0593     Widget      /* widget */,
0594     XtTranslations  /* xlations */,
0595     TMBindData      /* bindData */
0596 );
0597 
0598 extern void _XtUnmergeTranslations(
0599     Widget      /* widget */,
0600     XtTranslations  /* xlations */
0601 );
0602 
0603 /* TMKey.c */
0604 extern void _XtAllocTMContext(XtPerDisplay pd);
0605 
0606 _XFUNCPROTOEND