master
ブランチ master
ShaderPlayground / deps / xlibre / include / X11 / TranslateI.h
16.8 KB、606行 生 Blame 履歴
1/***********************************************************
2
3Copyright 1987, 1988, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25
26Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
27
28 All Rights Reserved
29
30Permission to use, copy, modify, and distribute this software and its
31documentation for any purpose and without fee is hereby granted,
32provided that the above copyright notice appear in all copies and that
33both that copyright notice and this permission notice appear in
34supporting documentation, and that the name of Digital not be
35used in advertising or publicity pertaining to distribution of the
36software without specific, written prior permission.
37
38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44SOFTWARE.
45
46******************************************************************/
47
48/*
49 * TranslateI.h - Header file private to translation management
50 *
51 * Author: Gabe Beged-Dov, HP
52 *
53 * Former Author: Charles Haynes
54 * Digital Equipment Corporation
55 * Western Research Laboratory
56 * Date: Sat Aug 29 1987
57 */
58
59/*#define REFCNT_TRANSLATIONS*/
60#define CACHE_TRANSLATIONS
61
62#define TM_NO_MATCH (-2)
63
64#define _XtRStateTablePair "_XtStateTablePair"
65
66typedef unsigned char TMByteCard;
67typedef unsigned short TMShortCard;
68typedef unsigned long TMLongCard;
69typedef short TMShortInt;
70
71typedef struct _TMTypeMatchRec *TMTypeMatch;
72typedef struct _TMModifierMatchRec *TMModifierMatch;
73typedef struct _TMEventRec *TMEventPtr;
74
75typedef Boolean (*MatchProc)(TMTypeMatch typeMatch,
76 TMModifierMatch modMatch,
77 TMEventPtr eventSeq);
78
79typedef struct _ModToKeysymTable {
80 Modifiers mask;
81 int count;
82 int idx;
83} ModToKeysymTable;
84
85typedef struct _LateBindings {
86 unsigned int knot:1;
87 unsigned int pair:1;
88 unsigned short ref_count; /* garbage collection */
89 KeySym keysym;
90} LateBindings, *LateBindingsPtr;
91
92typedef short ModifierMask;
93
94typedef struct _ActionsRec *ActionPtr;
95typedef struct _ActionsRec {
96 int idx; /* index into quarkTable to find proc */
97 String *params; /* pointer to array of params */
98 Cardinal num_params; /* number of params */
99 ActionPtr next; /* next action to perform */
100} ActionRec;
101
102typedef struct _XtStateRec *StatePtr;
103typedef struct _XtStateRec {
104 unsigned int isCycleStart:1;
105 unsigned int isCycleEnd:1;
106 TMShortCard typeIndex;
107 TMShortCard modIndex;
108 ActionPtr actions; /* rhs list of actions to perform */
109 StatePtr nextLevel;
110}StateRec;
111
112
113#define XtTableReplace 0
114#define XtTableAugment 1
115#define XtTableOverride 2
116#define XtTableUnmerge 3
117
118typedef unsigned int _XtTranslateOp;
119
120/*
121 * New Definitions
122 */
123typedef struct _TMModifierMatchRec{
124 TMLongCard modifiers;
125 TMLongCard modifierMask;
126 LateBindingsPtr lateModifiers;
127 Boolean standard;
128}TMModifierMatchRec;
129
130typedef struct _TMTypeMatchRec{
131 TMLongCard eventType;
132 TMLongCard eventCode;
133 TMLongCard eventCodeMask;
134 MatchProc matchEvent;
135}TMTypeMatchRec;
136
137typedef struct _TMBranchHeadRec {
138 unsigned int isSimple:1;
139 unsigned int hasActions:1;
140 unsigned int hasCycles:1;
141 unsigned int more:13;
142 TMShortCard typeIndex;
143 TMShortCard modIndex;
144}TMBranchHeadRec, *TMBranchHead;
145
146/* NOTE: elements of this structure must match those of
147 * TMComplexStateTreeRec and TMParseStateTreeRec.
148 */
149typedef struct _TMSimpleStateTreeRec{
150 unsigned int isSimple:1;
151 unsigned int isAccelerator:1;
152 unsigned int mappingNotifyInterest:1;
153 unsigned int refCount:13;
154 TMShortCard numBranchHeads;
155 TMShortCard numQuarks; /* # of entries in quarkTbl */
156 TMShortCard unused; /* to ensure same alignment */
157 TMBranchHeadRec *branchHeadTbl;
158 XrmQuark *quarkTbl; /* table of quarkified rhs*/
159}TMSimpleStateTreeRec, *TMSimpleStateTree;
160
161/* NOTE: elements of this structure must match those of
162 * TMSimpleStateTreeRec and TMParseStateTreeRec.
163 */
164typedef struct _TMComplexStateTreeRec{
165 unsigned int isSimple:1;
166 unsigned int isAccelerator:1;
167 unsigned int mappingNotifyInterest:1;
168 unsigned int refCount:13;
169 TMShortCard numBranchHeads;
170 TMShortCard numQuarks; /* # of entries in quarkTbl */
171 TMShortCard numComplexBranchHeads;
172 TMBranchHeadRec *branchHeadTbl;
173 XrmQuark *quarkTbl; /* table of quarkified rhs*/
174 StatePtr *complexBranchHeadTbl;
175}TMComplexStateTreeRec, *TMComplexStateTree;
176
177/* NOTE: elements of this structure must match those of
178 * TMSimpleStateTreeRec and TMComplexStateTreeRec.
179 */
180typedef struct _TMParseStateTreeRec{
181 unsigned int isSimple:1;
182 unsigned int isAccelerator:1;
183 unsigned int mappingNotifyInterest:1;
184 unsigned int isStackQuarks:1;
185 unsigned int isStackBranchHeads:1;
186 unsigned int isStackComplexBranchHeads:1;
187 unsigned int unused:10; /* to ensure correct alignment */
188 TMShortCard numBranchHeads;
189 TMShortCard numQuarks; /* # of entries in quarkTbl */
190 TMShortCard numComplexBranchHeads;
191 TMBranchHeadRec *branchHeadTbl;
192 XrmQuark *quarkTbl; /* table of quarkified rhs*/
193 StatePtr *complexBranchHeadTbl;
194 TMShortCard branchHeadTblSize;
195 TMShortCard quarkTblSize; /*total size of quarkTbl */
196 TMShortCard complexBranchHeadTblSize;
197 StatePtr head;
198}TMParseStateTreeRec, *TMParseStateTree;
199
200typedef union _TMStateTreeRec{
201 TMSimpleStateTreeRec simple;
202 TMParseStateTreeRec parse;
203 TMComplexStateTreeRec complex;
204}*TMStateTree, **TMStateTreePtr, **TMStateTreeList;
205
206typedef struct _TMSimpleBindProcsRec {
207 XtActionProc *procs;
208}TMSimpleBindProcsRec, *TMSimpleBindProcs;
209
210typedef struct _TMComplexBindProcsRec {
211 Widget widget; /*widgetID to pass to action Proc*/
212 XtTranslations aXlations;
213 XtActionProc *procs;
214}TMComplexBindProcsRec, *TMComplexBindProcs;
215
216typedef struct _TMSimpleBindDataRec {
217 unsigned int isComplex:1; /* must be first */
218 TMSimpleBindProcsRec bindTbl[1]; /* variable length */
219}TMSimpleBindDataRec, *TMSimpleBindData;
220
221typedef struct _TMComplexBindDataRec {
222 unsigned int isComplex:1; /* must be first */
223 struct _ATranslationData *accel_context; /* for GetValues */
224 TMComplexBindProcsRec bindTbl[1]; /* variable length */
225}TMComplexBindDataRec, *TMComplexBindData;
226
227typedef union _TMBindDataRec{
228 TMSimpleBindDataRec simple;
229 TMComplexBindDataRec complex;
230}*TMBindData;
231
232typedef struct _TranslationData{
233 unsigned char hasBindings; /* must be first */
234 unsigned char operation; /*replace,augment,override*/
235 TMShortCard numStateTrees;
236 struct _TranslationData *composers[2];
237 EventMask eventMask;
238 TMStateTree stateTreeTbl[1]; /* variable length */
239}TranslationData;
240
241/*
242 * ATranslations is returned by GetValues for translations that contain
243 * accelerators. The TM can differentiate between this and TranslationData
244 * (that don't have a bindTbl) by looking at the first field (hasBindings)
245 * of either structure. All ATranslationData structures associated with a
246 * widget are chained off the BindData record of the widget.
247 */
248typedef struct _ATranslationData{
249 unsigned char hasBindings; /* must be first */
250 unsigned char operation;
251 struct _TranslationData *xlations; /* actual translations */
252 struct _ATranslationData *next; /* chain the contexts together */
253 TMComplexBindProcsRec bindTbl[1]; /* accelerator bindings */
254}ATranslationData, *ATranslations;
255
256typedef struct _TMConvertRec {
257 XtTranslations old; /* table to merge into */
258 XtTranslations new; /* table to merge from */
259} TMConvertRec;
260
261#define _XtEventTimerEventType ((TMLongCard)~0L)
262#define KeysymModMask (1L<<27) /* private to TM */
263#define AnyButtonMask (1L<<28) /* private to TM */
264
265typedef struct _EventRec {
266 TMLongCard modifiers;
267 TMLongCard modifierMask;
268 LateBindingsPtr lateModifiers;
269 TMLongCard eventType;
270 TMLongCard eventCode;
271 TMLongCard eventCodeMask;
272 MatchProc matchEvent;
273 Boolean standard;
274} Event;
275
276typedef struct _EventSeqRec *EventSeqPtr;
277typedef struct _EventSeqRec {
278 Event event; /* X event description */
279 StatePtr state; /* private to state table builder */
280 EventSeqPtr next; /* next event on line */
281 ActionPtr actions; /* r.h.s. list of actions to perform */
282} EventSeqRec;
283
284typedef EventSeqRec EventRec;
285typedef EventSeqPtr EventPtr;
286
287typedef struct _TMEventRec {
288 XEvent *xev;
289 Event event;
290}TMEventRec;
291
292typedef struct _ActionHookRec {
293 struct _ActionHookRec* next; /* must remain first */
294 XtAppContext app;
295 XtActionHookProc proc;
296 XtPointer closure;
297} ActionHookRec, *ActionHook;
298
299/* choose a number between 2 and 8 */
300#define TMKEYCACHELOG2 6
301#define TMKEYCACHESIZE (1<<TMKEYCACHELOG2)
302
303typedef struct _KeyCacheRec {
304 unsigned char modifiers_return[256]; /* constant per KeyCode, key proc */
305 KeyCode keycode[TMKEYCACHESIZE];
306 unsigned char modifiers[TMKEYCACHESIZE];
307 KeySym keysym[TMKEYCACHESIZE];
308} TMKeyCache;
309
310typedef struct _TMKeyContextRec {
311 XEvent *event;
312 unsigned long serial;
313 KeySym keysym;
314 Modifiers modifiers;
315 TMKeyCache keycache; /* keep this last, to keep offsets to others small */
316} TMKeyContextRec, *TMKeyContext;
317
318typedef struct _TMGlobalRec{
319 TMTypeMatchRec **typeMatchSegmentTbl;
320 TMShortCard numTypeMatches;
321 TMShortCard numTypeMatchSegments;
322 TMShortCard typeMatchSegmentTblSize;
323 TMModifierMatchRec **modMatchSegmentTbl;
324 TMShortCard numModMatches;
325 TMShortCard numModMatchSegments;
326 TMShortCard modMatchSegmentTblSize;
327 Boolean newMatchSemantics;
328#ifdef TRACE_TM
329 XtTranslations *tmTbl;
330 TMShortCard numTms;
331 TMShortCard tmTblSize;
332 struct _TMBindCacheRec **bindCacheTbl;
333 TMShortCard numBindCache;
334 TMShortCard bindCacheTblSize;
335 TMShortCard numLateBindings;
336 TMShortCard numBranchHeads;
337 TMShortCard numComplexStates;
338 TMShortCard numComplexActions;
339#endif /* TRACE_TM */
340}TMGlobalRec;
341
342_XFUNCPROTOBEGIN
343
344extern TMGlobalRec _XtGlobalTM;
345
346#define TM_MOD_SEGMENT_SIZE 16
347#define TM_TYPE_SEGMENT_SIZE 16
348
349#define TMGetTypeMatch(idx) \
350 ((TMTypeMatch) \
351 &((_XtGlobalTM.typeMatchSegmentTbl[((idx) >> 4)])[(idx) & 15]))
352#define TMGetModifierMatch(idx) \
353 ((TMModifierMatch) \
354 &((_XtGlobalTM.modMatchSegmentTbl[(idx) >> 4])[(idx) & 15]))
355
356/* Useful Access Macros */
357#define TMNewMatchSemantics() (_XtGlobalTM.newMatchSemantics)
358#define TMBranchMore(branch) (branch->more)
359#define TMComplexBranchHead(tree, br) \
360 (((TMComplexStateTree)tree)->complexBranchHeadTbl[TMBranchMore(br)])
361
362#define TMGetComplexBindEntry(bindData, idx) \
363 ((TMComplexBindProcs)&(((TMComplexBindData)bindData)->bindTbl[idx]))
364
365#define TMGetSimpleBindEntry(bindData, idx) \
366 ((TMSimpleBindProcs)&(((TMSimpleBindData)bindData)->bindTbl[idx]))
367
368
369#define _InitializeKeysymTables(dpy, pd) \
370 if (pd->keysyms == NULL) \
371 _XtBuildKeysymTables(dpy, pd)
372
373/*
374 * Internal Functions
375 */
376
377extern void _XtPopup(
378 Widget /* widget */,
379 XtGrabKind /* grab_kind */,
380 _XtBoolean /* spring_loaded */
381);
382
383extern _XtString _XtPrintXlations(
384 Widget /* w */,
385 XtTranslations /* xlations */,
386 Widget /* accelWidget */,
387 _XtBoolean /* includeRHS */
388);
389
390extern void _XtRegisterGrabs(
391 Widget /* widget */
392);
393
394extern XtPointer _XtInitializeActionData(
395 struct _XtActionsRec * /* actions */,
396 Cardinal /* count */,
397 _XtBoolean /* inPlace */
398);
399
400extern void _XtAddEventSeqToStateTree(
401 EventSeqPtr /* eventSeq */,
402 TMParseStateTree /* stateTree */
403);
404
405extern Boolean _XtMatchUsingStandardMods(
406 TMTypeMatch /* typeMatch */,
407 TMModifierMatch /* modMatch */,
408 TMEventPtr /* eventSeq */
409);
410
411extern Boolean _XtMatchUsingDontCareMods(
412 TMTypeMatch /* typeMatch */,
413 TMModifierMatch /* modMatch */,
414 TMEventPtr /* eventSeq */
415);
416
417extern Boolean _XtRegularMatch(
418 TMTypeMatch /* typeMatch */,
419 TMModifierMatch /* modMatch */,
420 TMEventPtr /* eventSeq */
421);
422
423extern Boolean _XtMatchAtom(
424 TMTypeMatch /* typeMatch */,
425 TMModifierMatch /* modMatch */,
426 TMEventPtr /* eventSeq */
427);
428
429extern void _XtTranslateEvent(
430 Widget /* widget */,
431 XEvent* /* event */
432);
433
434#include "CallbackI.h"
435#include "EventI.h"
436#include "HookObjI.h"
437#include "PassivGraI.h"
438#include "ThreadsI.h"
439#include "InitialI.h"
440#include "ResourceI.h"
441#include "StringDefs.h"
442
443extern void _XtBuildKeysymTables(Display *dpy, XtPerDisplay pd);
444
445#ifndef NO_MIT_HACKS
446extern void _XtDisplayTranslations(
447 Widget /* widget */,
448 XEvent* /* event */,
449 String* /* params */,
450 Cardinal* /* num_params */
451);
452
453extern void _XtDisplayAccelerators(
454 Widget /* widget */,
455 XEvent* /* event */,
456 String* /* params */,
457 Cardinal* /* num_params */
458);
459
460extern void _XtDisplayInstalledAccelerators(
461 Widget /* widget */,
462 XEvent* /* event */,
463 String* /* params */,
464 Cardinal* /* num_params */
465);
466#endif /* ifndef NO_MIT_HACKS */
467
468extern void _XtPopupInitialize(
469 XtAppContext /* app_context */
470);
471
472extern void _XtBindActions(
473 Widget /* widget */,
474 XtTM /* tm_rec */
475);
476
477extern Boolean _XtComputeLateBindings(
478 Display* /* dpy */,
479 LateBindingsPtr /* lateModifiers */,
480 Modifiers* /* computed */,
481 Modifiers* /* computedMask */
482);
483
484extern XtTranslations _XtCreateXlations(
485 TMStateTree * /* stateTrees */,
486 TMShortCard /* numStateTrees */,
487 XtTranslations /* first */,
488 XtTranslations /* second */
489);
490
491extern Boolean _XtCvtMergeTranslations(
492 Display* /* dpy */,
493 XrmValuePtr /* args */,
494 Cardinal* /* num_args */,
495 XrmValuePtr /* from */,
496 XrmValuePtr /* to */,
497 XtPointer* /* closure_ret */
498);
499
500void _XtRemoveStateTreeByIndex(
501 XtTranslations /* xlations */,
502 TMShortCard /* i */);
503
504void _XtFreeTranslations(
505 XtAppContext /* app */,
506 XrmValuePtr /* toVal */,
507 XtPointer /* closure */,
508 XrmValuePtr /* args */,
509 Cardinal* /* num_args */
510);
511
512extern TMShortCard _XtGetModifierIndex(
513 Event* /* event */
514);
515
516extern TMShortCard _XtGetQuarkIndex(
517 TMParseStateTree /* stateTreePtr */,
518 XrmQuark /* quark */
519);
520
521extern XtTranslations _XtGetTranslationValue(
522 Widget /* widget */
523);
524
525extern TMShortCard _XtGetTypeIndex(
526 Event* /* event */
527);
528
529extern void _XtGrabInitialize(
530 XtAppContext /* app */
531);
532
533extern void _XtInstallTranslations(
534 Widget /* widget */
535);
536
537extern void _XtRemoveTranslations(
538 Widget /* widget */
539);
540
541extern void _XtDestroyTMData(
542 Widget /* widget */
543);
544
545extern void _XtMergeTranslations(
546 Widget /* widget */,
547 XtTranslations /* newXlations */,
548 _XtTranslateOp /* operation */
549);
550
551extern void _XtActionInitialize(
552 XtAppContext /* app */
553);
554
555extern TMStateTree _XtParseTreeToStateTree(
556 TMParseStateTree /* parseTree */
557);
558
559extern String _XtPrintActions(
560 ActionRec* /* actions */,
561 XrmQuark* /* quarkTbl */
562);
563
564extern String _XtPrintState(
565 TMStateTree /* stateTree */,
566 TMBranchHead /* branchHead */);
567
568extern String _XtPrintEventSeq(
569 EventSeqPtr /* eventSeq */,
570 Display* /* dpy */
571);
572
573typedef Boolean (*_XtTraversalProc)(
574 StatePtr /* state */,
575 XtPointer /* data */
576);
577
578extern void _XtTraverseStateTree(
579 TMStateTree /* tree */,
580 _XtTraversalProc /* func */,
581 XtPointer /* data */
582);
583
584extern void _XtTranslateInitialize(
585 void
586);
587
588extern void _XtAddTMConverters(
589 ConverterTable /* table */
590);
591
592extern void _XtUnbindActions(
593 Widget /* widget */,
594 XtTranslations /* xlations */,
595 TMBindData /* bindData */
596);
597
598extern void _XtUnmergeTranslations(
599 Widget /* widget */,
600 XtTranslations /* xlations */
601);
602
603/* TMKey.c */
604extern void _XtAllocTMContext(XtPerDisplay pd);
605
606_XFUNCPROTOEND