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(
380 XtGrabKind /* grab_kind */,
381 _XtBoolean /* spring_loaded */
384 extern String _XtPrintXlations(
386 XtTranslations /* xlations */,
387 Widget /* accelWidget */,
388 _XtBoolean /* includeRHS */
391 extern void _XtRegisterGrabs(
395 extern XtPointer _XtInitializeActionData(
396 struct _XtActionsRec * /* actions */,
397 Cardinal /* count */,
398 _XtBoolean /* inPlace */
401 extern void _XtAddEventSeqToStateTree(
402 EventSeqPtr /* eventSeq */,
403 TMParseStateTree /* stateTree */
406 extern Boolean _XtMatchUsingStandardMods(
407 TMTypeMatch /* typeMatch */,
408 TMModifierMatch /* modMatch */,
409 TMEventPtr /* eventSeq */
412 extern Boolean _XtMatchUsingDontCareMods(
413 TMTypeMatch /* typeMatch */,
414 TMModifierMatch /* modMatch */,
415 TMEventPtr /* eventSeq */
418 extern Boolean _XtRegularMatch(
419 TMTypeMatch /* typeMatch */,
420 TMModifierMatch /* modMatch */,
421 TMEventPtr /* eventSeq */
424 extern Boolean _XtMatchAtom(
425 TMTypeMatch /* typeMatch */,
426 TMModifierMatch /* modMatch */,
427 TMEventPtr /* eventSeq */
430 extern void _XtTranslateEvent(
435 #include "CallbackI.h"
437 #include "HookObjI.h"
438 #include "PassivGraI.h"
439 #include "ThreadsI.h"
440 #include "InitialI.h"
441 #include "ResourceI.h"
442 #include "StringDefs.h"
444 extern void _XtBuildKeysymTables(Display *dpy, XtPerDisplay pd);
447 extern void _XtDisplayTranslations(
450 String* /* params */,
451 Cardinal* /* num_params */
454 extern void _XtDisplayAccelerators(
457 String* /* params */,
458 Cardinal* /* num_params */
461 extern void _XtDisplayInstalledAccelerators(
464 String* /* params */,
465 Cardinal* /* num_params */
467 #endif /* ifndef NO_MIT_HACKS */
469 extern void _XtPopupInitialize(
470 XtAppContext /* app_context */
473 extern void _XtBindActions(
478 extern Boolean _XtComputeLateBindings(
480 LateBindingsPtr /* lateModifiers */,
481 Modifiers* /* computed */,
482 Modifiers* /* computedMask */
485 extern XtTranslations _XtCreateXlations(
486 TMStateTree * /* stateTrees */,
487 TMShortCard /* numStateTrees */,
488 XtTranslations /* first */,
489 XtTranslations /* second */
492 extern Boolean _XtCvtMergeTranslations(
494 XrmValuePtr /* args */,
495 Cardinal* /* num_args */,
496 XrmValuePtr /* from */,
497 XrmValuePtr /* to */,
498 XtPointer* /* closure_ret */
501 void _XtRemoveStateTreeByIndex(
502 XtTranslations /* xlations */,
503 TMShortCard /* i */);
505 void _XtFreeTranslations(
506 XtAppContext /* app */,
507 XrmValuePtr /* toVal */,
508 XtPointer /* closure */,
509 XrmValuePtr /* args */,
510 Cardinal* /* num_args */
513 extern TMShortCard _XtGetModifierIndex(
517 extern TMShortCard _XtGetQuarkIndex(
518 TMParseStateTree /* stateTreePtr */,
522 extern XtTranslations _XtGetTranslationValue(
526 extern TMShortCard _XtGetTypeIndex(
530 extern void _XtGrabInitialize(
531 XtAppContext /* app */
534 extern void _XtInstallTranslations(
538 extern void _XtRemoveTranslations(
542 extern void _XtDestroyTMData(
546 extern void _XtMergeTranslations(
548 XtTranslations /* newXlations */,
549 _XtTranslateOp /* operation */
552 extern void _XtActionInitialize(
553 XtAppContext /* app */
556 extern TMStateTree _XtParseTreeToStateTree(
557 TMParseStateTree /* parseTree */
560 extern String _XtPrintActions(
561 ActionRec* /* actions */,
562 XrmQuark* /* quarkTbl */
565 extern String _XtPrintState(
566 TMStateTree /* stateTree */,
567 TMBranchHead /* branchHead */);
569 extern String _XtPrintEventSeq(
570 EventSeqPtr /* eventSeq */,
574 typedef Boolean (*_XtTraversalProc)(
575 StatePtr /* state */,
579 extern void _XtTraverseStateTree(
580 TMStateTree /* tree */,
581 _XtTraversalProc /* func */,
585 extern void _XtTranslateInitialize(
589 extern void _XtAddTMConverters(
590 ConverterTable /* table */
593 extern void _XtUnbindActions(
595 XtTranslations /* xlations */,
596 TMBindData /* bindData */
599 extern void _XtUnmergeTranslations(
601 XtTranslations /* xlations */
605 extern void _XtAllocTMContext(XtPerDisplay pd);