1
/* $Xorg: TranslateI.h,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
3
/***********************************************************
5
Copyright 1987, 1988, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
28
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
32
Permission to use, copy, modify, and distribute this software and its
33
documentation for any purpose and without fee is hereby granted,
34
provided that the above copyright notice appear in all copies and that
35
both that copyright notice and this permission notice appear in
36
supporting documentation, and that the name of Digital not be
37
used in advertising or publicity pertaining to distribution of the
38
software without specific, written prior permission.
40
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48
******************************************************************/
49
/* $XFree86: xc/lib/Xt/TranslateI.h,v 1.3 2001/12/14 19:56:32 dawes Exp $ */
52
* TranslateI.h - Header file private to translation management
54
* Author: Gabe Beged-Dov, HP
56
* Former Author: Charles Haynes
57
* Digital Equipment Corporation
58
* Western Research Laboratory
59
* Date: Sat Aug 29 1987
62
/*#define REFCNT_TRANSLATIONS*/
63
#define CACHE_TRANSLATIONS
65
#define TM_NO_MATCH (-2)
67
#define _XtRStateTablePair "_XtStateTablePair"
69
typedef unsigned char TMByteCard;
70
typedef unsigned short TMShortCard;
71
typedef unsigned long TMLongCard;
72
typedef short TMShortInt;
74
typedef struct _TMTypeMatchRec *TMTypeMatch;
75
typedef struct _TMModifierMatchRec *TMModifierMatch;
76
typedef struct _TMEventRec *TMEventPtr;
78
typedef Boolean (*MatchProc)(TMTypeMatch typeMatch,
79
TMModifierMatch modMatch,
82
typedef struct _ModToKeysymTable {
88
typedef struct _LateBindings {
91
unsigned short ref_count; /* garbage collection */
93
} LateBindings, *LateBindingsPtr;
95
typedef short ModifierMask;
97
typedef struct _ActionsRec *ActionPtr;
98
typedef struct _ActionsRec {
99
int idx; /* index into quarkTable to find proc */
100
String *params; /* pointer to array of params */
101
Cardinal num_params; /* number of params */
102
ActionPtr next; /* next action to perform */
105
typedef struct _XtStateRec *StatePtr;
106
typedef struct _XtStateRec {
107
unsigned int isCycleStart:1;
108
unsigned int isCycleEnd:1;
109
TMShortCard typeIndex;
110
TMShortCard modIndex;
111
ActionPtr actions; /* rhs list of actions to perform */
116
#define XtTableReplace 0
117
#define XtTableAugment 1
118
#define XtTableOverride 2
119
#define XtTableUnmerge 3
121
typedef unsigned int _XtTranslateOp;
126
typedef struct _TMModifierMatchRec{
127
TMLongCard modifiers;
128
TMLongCard modifierMask;
129
LateBindingsPtr lateModifiers;
133
typedef struct _TMTypeMatchRec{
134
TMLongCard eventType;
135
TMLongCard eventCode;
136
TMLongCard eventCodeMask;
137
MatchProc matchEvent;
140
typedef struct _TMBranchHeadRec {
141
unsigned int isSimple:1;
142
unsigned int hasActions:1;
143
unsigned int hasCycles:1;
144
unsigned int more:13;
145
TMShortCard typeIndex;
146
TMShortCard modIndex;
147
}TMBranchHeadRec, *TMBranchHead;
149
/* NOTE: elements of this structure must match those of
150
* TMComplexStateTreeRec and TMParseStateTreeRec.
152
typedef struct _TMSimpleStateTreeRec{
153
unsigned int isSimple:1;
154
unsigned int isAccelerator:1;
155
unsigned int mappingNotifyInterest:1;
156
unsigned int refCount:13;
157
TMShortCard numBranchHeads;
158
TMShortCard numQuarks; /* # of entries in quarkTbl */
159
TMShortCard unused; /* to ensure same alignment */
160
TMBranchHeadRec *branchHeadTbl;
161
XrmQuark *quarkTbl; /* table of quarkified rhs*/
162
}TMSimpleStateTreeRec, *TMSimpleStateTree;
164
/* NOTE: elements of this structure must match those of
165
* TMSimpleStateTreeRec and TMParseStateTreeRec.
167
typedef struct _TMComplexStateTreeRec{
168
unsigned int isSimple:1;
169
unsigned int isAccelerator:1;
170
unsigned int mappingNotifyInterest:1;
171
unsigned int refCount:13;
172
TMShortCard numBranchHeads;
173
TMShortCard numQuarks; /* # of entries in quarkTbl */
174
TMShortCard numComplexBranchHeads;
175
TMBranchHeadRec *branchHeadTbl;
176
XrmQuark *quarkTbl; /* table of quarkified rhs*/
177
StatePtr *complexBranchHeadTbl;
178
}TMComplexStateTreeRec, *TMComplexStateTree;
180
/* NOTE: elements of this structure must match those of
181
* TMSimpleStateTreeRec and TMComplexStateTreeRec.
183
typedef struct _TMParseStateTreeRec{
184
unsigned int isSimple:1;
185
unsigned int isAccelerator:1;
186
unsigned int mappingNotifyInterest:1;
187
unsigned int isStackQuarks:1;
188
unsigned int isStackBranchHeads:1;
189
unsigned int isStackComplexBranchHeads:1;
190
unsigned int unused:10; /* to ensure correct alignment */
191
TMShortCard numBranchHeads;
192
TMShortCard numQuarks; /* # of entries in quarkTbl */
193
TMShortCard numComplexBranchHeads;
194
TMBranchHeadRec *branchHeadTbl;
195
XrmQuark *quarkTbl; /* table of quarkified rhs*/
196
StatePtr *complexBranchHeadTbl;
197
TMShortCard branchHeadTblSize;
198
TMShortCard quarkTblSize; /*total size of quarkTbl */
199
TMShortCard complexBranchHeadTblSize;
201
}TMParseStateTreeRec, *TMParseStateTree;
203
typedef union _TMStateTreeRec{
204
TMSimpleStateTreeRec simple;
205
TMParseStateTreeRec parse;
206
TMComplexStateTreeRec complex;
207
}*TMStateTree, **TMStateTreePtr, **TMStateTreeList;
209
typedef struct _TMSimpleBindProcsRec {
211
}TMSimpleBindProcsRec, *TMSimpleBindProcs;
213
typedef struct _TMComplexBindProcsRec {
214
Widget widget; /*widgetID to pass to action Proc*/
215
XtTranslations aXlations;
217
}TMComplexBindProcsRec, *TMComplexBindProcs;
219
typedef struct _TMSimpleBindDataRec {
220
unsigned int isComplex:1; /* must be first */
221
TMSimpleBindProcsRec bindTbl[1]; /* variable length */
222
}TMSimpleBindDataRec, *TMSimpleBindData;
224
typedef struct _TMComplexBindDataRec {
225
unsigned int isComplex:1; /* must be first */
226
struct _ATranslationData *accel_context; /* for GetValues */
227
TMComplexBindProcsRec bindTbl[1]; /* variable length */
228
}TMComplexBindDataRec, *TMComplexBindData;
230
typedef union _TMBindDataRec{
231
TMSimpleBindDataRec simple;
232
TMComplexBindDataRec complex;
235
typedef struct _TranslationData{
236
unsigned char hasBindings; /* must be first */
237
unsigned char operation; /*replace,augment,override*/
238
TMShortCard numStateTrees;
239
struct _TranslationData *composers[2];
241
TMStateTree stateTreeTbl[1]; /* variable length */
245
* ATranslations is returned by GetValues for translations that contain
246
* accelerators. The TM can differentiate between this and TranslationData
247
* (that don't have a bindTbl) by looking at the first field (hasBindings)
248
* of either structure. All ATranslationData structures associated with a
249
* widget are chained off the BindData record of the widget.
251
typedef struct _ATranslationData{
252
unsigned char hasBindings; /* must be first */
253
unsigned char operation;
254
struct _TranslationData *xlations; /* actual translations */
255
struct _ATranslationData *next; /* chain the contexts together */
256
TMComplexBindProcsRec bindTbl[1]; /* accelerator bindings */
257
}ATranslationData, *ATranslations;
259
typedef struct _TMConvertRec {
260
XtTranslations old; /* table to merge into */
261
XtTranslations new; /* table to merge from */
264
#define _XtEventTimerEventType ((TMLongCard)~0L)
265
#define KeysymModMask (1L<<27) /* private to TM */
266
#define AnyButtonMask (1L<<28) /* private to TM */
268
typedef struct _EventRec {
269
TMLongCard modifiers;
270
TMLongCard modifierMask;
271
LateBindingsPtr lateModifiers;
272
TMLongCard eventType;
273
TMLongCard eventCode;
274
TMLongCard eventCodeMask;
275
MatchProc matchEvent;
279
typedef struct _EventSeqRec *EventSeqPtr;
280
typedef struct _EventSeqRec {
281
Event event; /* X event description */
282
StatePtr state; /* private to state table builder */
283
EventSeqPtr next; /* next event on line */
284
ActionPtr actions; /* r.h.s. list of actions to perform */
287
typedef EventSeqRec EventRec;
288
typedef EventSeqPtr EventPtr;
290
typedef struct _TMEventRec {
295
typedef struct _ActionHookRec {
296
struct _ActionHookRec* next; /* must remain first */
298
XtActionHookProc proc;
300
} ActionHookRec, *ActionHook;
302
/* choose a number between 2 and 8 */
303
#define TMKEYCACHELOG2 6
304
#define TMKEYCACHESIZE (1<<TMKEYCACHELOG2)
306
typedef struct _KeyCacheRec {
307
unsigned char modifiers_return[256]; /* constant per KeyCode, key proc */
308
KeyCode keycode[TMKEYCACHESIZE];
309
unsigned char modifiers[TMKEYCACHESIZE];
310
KeySym keysym[TMKEYCACHESIZE];
313
typedef struct _TMKeyContextRec {
315
unsigned long serial;
318
TMKeyCache keycache; /* keep this last, to keep offsets to others small */
319
} TMKeyContextRec, *TMKeyContext;
321
typedef struct _TMGlobalRec{
322
TMTypeMatchRec **typeMatchSegmentTbl;
323
TMShortCard numTypeMatches;
324
TMShortCard numTypeMatchSegments;
325
TMShortCard typeMatchSegmentTblSize;
326
TMModifierMatchRec **modMatchSegmentTbl;
327
TMShortCard numModMatches;
328
TMShortCard numModMatchSegments;
329
TMShortCard modMatchSegmentTblSize;
330
Boolean newMatchSemantics;
332
XtTranslations *tmTbl;
334
TMShortCard tmTblSize;
335
struct _TMBindCacheRec **bindCacheTbl;
336
TMShortCard numBindCache;
337
TMShortCard bindCacheTblSize;
338
TMShortCard numLateBindings;
339
TMShortCard numBranchHeads;
340
TMShortCard numComplexStates;
341
TMShortCard numComplexActions;
342
#endif /* TRACE_TM */
345
extern TMGlobalRec _XtGlobalTM;
347
#define TM_MOD_SEGMENT_SIZE 16
348
#define TM_TYPE_SEGMENT_SIZE 16
350
#define TMGetTypeMatch(idx) \
352
&((_XtGlobalTM.typeMatchSegmentTbl[((idx) >> 4)])[(idx) & 15]))
353
#define TMGetModifierMatch(idx) \
355
&((_XtGlobalTM.modMatchSegmentTbl[(idx) >> 4])[(idx) & 15]))
357
/* Useful Access Macros */
358
#define TMNewMatchSemantics() (_XtGlobalTM.newMatchSemantics)
359
#define TMBranchMore(branch) (branch->more)
360
#define TMComplexBranchHead(tree, br) \
361
(((TMComplexStateTree)tree)->complexBranchHeadTbl[TMBranchMore(br)])
363
#define TMGetComplexBindEntry(bindData, idx) \
364
((TMComplexBindProcs)&(((TMComplexBindData)bindData)->bindTbl[idx]))
366
#define TMGetSimpleBindEntry(bindData, idx) \
367
((TMSimpleBindProcs)&(((TMSimpleBindData)bindData)->bindTbl[idx]))
370
#define _InitializeKeysymTables(dpy, pd) \
371
if (pd->keysyms == NULL) \
372
_XtBuildKeysymTables(dpy, pd)
378
extern void _XtPopup(
379
#if NeedFunctionPrototypes
381
XtGrabKind /* grab_kind */,
382
_XtBoolean /* spring_loaded */
386
extern String _XtPrintXlations(
387
#if NeedFunctionPrototypes
389
XtTranslations /* xlations */,
390
Widget /* accelWidget */,
391
_XtBoolean /* includeRHS */
395
extern void _XtRegisterGrabs(
396
#if NeedFunctionPrototypes
401
extern XtPointer _XtInitializeActionData(
402
#if NeedFunctionPrototypes
403
struct _XtActionsRec * /* actions */,
404
Cardinal /* count */,
405
_XtBoolean /* inPlace */
409
extern void _XtAddEventSeqToStateTree(
410
#if NeedFunctionPrototypes
411
EventSeqPtr /* eventSeq */,
412
TMParseStateTree /* stateTree */
416
extern Boolean _XtMatchUsingStandardMods(
417
#if NeedFunctionPrototypes
418
TMTypeMatch /* typeMatch */,
419
TMModifierMatch /* modMatch */,
420
TMEventPtr /* eventSeq */
424
extern Boolean _XtMatchUsingDontCareMods(
425
#if NeedFunctionPrototypes
426
TMTypeMatch /* typeMatch */,
427
TMModifierMatch /* modMatch */,
428
TMEventPtr /* eventSeq */
432
extern Boolean _XtRegularMatch(
433
#if NeedFunctionPrototypes
434
TMTypeMatch /* typeMatch */,
435
TMModifierMatch /* modMatch */,
436
TMEventPtr /* eventSeq */
440
extern Boolean _XtMatchAtom(
441
#if NeedFunctionPrototypes
442
TMTypeMatch /* typeMatch */,
443
TMModifierMatch /* modMatch */,
444
TMEventPtr /* eventSeq */
448
extern void _XtTranslateEvent(
449
#if NeedFunctionPrototypes
455
#include "CallbackI.h"
457
#include "HookObjI.h"
458
#include "PassivGraI.h"
459
#include "ThreadsI.h"
460
#include "InitialI.h"
461
#include "ResourceI.h"
462
#include "StringDefs.h"
464
extern void _XtBuildKeysymTables(Display *dpy, XtPerDisplay pd);
467
extern void _XtDisplayTranslations(
468
#if NeedFunctionPrototypes
471
String* /* params */,
472
Cardinal* /* num_params */
476
extern void _XtDisplayAccelerators(
477
#if NeedFunctionPrototypes
480
String* /* params */,
481
Cardinal* /* num_params */
485
extern void _XtDisplayInstalledAccelerators(
486
#if NeedFunctionPrototypes
489
String* /* params */,
490
Cardinal* /* num_params */
493
#endif /* ifndef NO_MIT_HACKS */
495
extern void _XtPopupInitialize(
496
#if NeedFunctionPrototypes
497
XtAppContext /* app_context */
501
extern void _XtBindActions(
502
#if NeedFunctionPrototypes
508
extern Boolean _XtComputeLateBindings(
509
#if NeedFunctionPrototypes
511
LateBindingsPtr /* lateModifiers */,
512
Modifiers* /* computed */,
513
Modifiers* /* computedMask */
517
extern XtTranslations _XtCreateXlations(
518
#if NeedFunctionPrototypes
519
TMStateTree * /* stateTrees */,
520
TMShortCard /* numStateTrees */,
521
XtTranslations /* first */,
522
XtTranslations /* second */
526
extern Boolean _XtCvtMergeTranslations(
527
#if NeedFunctionPrototypes
529
XrmValuePtr /* args */,
530
Cardinal* /* num_args */,
531
XrmValuePtr /* from */,
532
XrmValuePtr /* to */,
533
XtPointer* /* closure_ret */
537
void _XtFreeTranslations(
538
#if NeedFunctionPrototypes
539
XtAppContext /* app */,
540
XrmValuePtr /* toVal */,
541
XtPointer /* closure */,
542
XrmValuePtr /* args */,
543
Cardinal* /* num_args */
547
extern TMShortCard _XtGetModifierIndex(
548
#if NeedFunctionPrototypes
553
extern TMShortCard _XtGetQuarkIndex(
554
#if NeedFunctionPrototypes
555
TMParseStateTree /* stateTreePtr */,
560
extern XtTranslations _XtGetTranslationValue(
561
#if NeedFunctionPrototypes
566
extern TMShortCard _XtGetTypeIndex(
567
#if NeedFunctionPrototypes
572
extern void _XtGrabInitialize(
573
#if NeedFunctionPrototypes
574
XtAppContext /* app */
578
extern void _XtInstallTranslations(
579
#if NeedFunctionPrototypes
584
extern void _XtRemoveTranslations(
585
#if NeedFunctionPrototypes
590
extern void _XtDestroyTMData(
591
#if NeedFunctionPrototypes
596
extern void _XtMergeTranslations(
597
#if NeedFunctionPrototypes
599
XtTranslations /* newXlations */,
600
_XtTranslateOp /* operation */
604
extern void _XtActionInitialize(
605
#if NeedFunctionPrototypes
606
XtAppContext /* app */
610
extern TMStateTree _XtParseTreeToStateTree(
611
#if NeedFunctionPrototypes
612
TMParseStateTree /* parseTree */
616
extern String _XtPrintActions(
617
#if NeedFunctionPrototypes
618
ActionRec* /* actions */,
619
XrmQuark* /* quarkTbl */
623
extern String _XtPrintEventSeq(
624
#if NeedFunctionPrototypes
625
EventSeqPtr /* eventSeq */,
630
typedef Boolean (*_XtTraversalProc)(
631
#if NeedFunctionPrototypes
632
StatePtr /* state */,
637
extern void _XtTraverseStateTree(
638
#if NeedFunctionPrototypes
639
TMStateTree /* tree */,
640
_XtTraversalProc /* func */,
645
extern void _XtTranslateInitialize(
646
#if NeedFunctionPrototypes
651
extern void _XtAddTMConverters(
652
#if NeedFunctionPrototypes
653
ConverterTable /* table */
657
extern void _XtUnbindActions(
658
#if NeedFunctionPrototypes
660
XtTranslations /* xlations */,
661
TMBindData /* bindData */
665
extern void _XtUnmergeTranslations(
666
#if NeedFunctionPrototypes
668
XtTranslations /* xlations */
673
extern void _XtAllocTMContext(XtPerDisplay pd);