| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | #define CACHE_TRANSLATIONS |
| 61 | |
| 62 | #define TM_NO_MATCH (-2) |
| 63 | |
| 64 | #define _XtRStateTablePair "_XtStateTablePair" |
| 65 | |
| 66 | typedef unsigned char TMByteCard; |
| 67 | typedef unsigned short TMShortCard; |
| 68 | typedef unsigned long TMLongCard; |
| 69 | typedef short TMShortInt; |
| 70 | |
| 71 | typedef struct _TMTypeMatchRec *TMTypeMatch; |
| 72 | typedef struct _TMModifierMatchRec *TMModifierMatch; |
| 73 | typedef struct _TMEventRec *TMEventPtr; |
| 74 | |
| 75 | typedef Boolean (*MatchProc)(TMTypeMatch typeMatch, |
| 76 | TMModifierMatch modMatch, |
| 77 | TMEventPtr eventSeq); |
| 78 | |
| 79 | typedef struct _ModToKeysymTable { |
| 80 | Modifiers mask; |
| 81 | int count; |
| 82 | int idx; |
| 83 | } ModToKeysymTable; |
| 84 | |
| 85 | typedef struct _LateBindings { |
| 86 | unsigned int knot:1; |
| 87 | unsigned int pair:1; |
| 88 | unsigned short ref_count; |
| 89 | KeySym keysym; |
| 90 | } LateBindings, *LateBindingsPtr; |
| 91 | |
| 92 | typedef short ModifierMask; |
| 93 | |
| 94 | typedef struct _ActionsRec *ActionPtr; |
| 95 | typedef struct _ActionsRec { |
| 96 | int idx; |
| 97 | String *params; |
| 98 | Cardinal num_params; |
| 99 | ActionPtr next; |
| 100 | } ActionRec; |
| 101 | |
| 102 | typedef struct _XtStateRec *StatePtr; |
| 103 | typedef struct _XtStateRec { |
| 104 | unsigned int isCycleStart:1; |
| 105 | unsigned int isCycleEnd:1; |
| 106 | TMShortCard typeIndex; |
| 107 | TMShortCard modIndex; |
| 108 | ActionPtr actions; |
| 109 | StatePtr nextLevel; |
| 110 | }StateRec; |
| 111 | |
| 112 | |
| 113 | #define XtTableReplace 0 |
| 114 | #define XtTableAugment 1 |
| 115 | #define XtTableOverride 2 |
| 116 | #define XtTableUnmerge 3 |
| 117 | |
| 118 | typedef unsigned int _XtTranslateOp; |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | typedef struct _TMModifierMatchRec{ |
| 124 | TMLongCard modifiers; |
| 125 | TMLongCard modifierMask; |
| 126 | LateBindingsPtr lateModifiers; |
| 127 | Boolean standard; |
| 128 | }TMModifierMatchRec; |
| 129 | |
| 130 | typedef struct _TMTypeMatchRec{ |
| 131 | TMLongCard eventType; |
| 132 | TMLongCard eventCode; |
| 133 | TMLongCard eventCodeMask; |
| 134 | MatchProc matchEvent; |
| 135 | }TMTypeMatchRec; |
| 136 | |
| 137 | typedef 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 | |
| 147 | |
| 148 | |
| 149 | typedef 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; |
| 156 | TMShortCard unused; |
| 157 | TMBranchHeadRec *branchHeadTbl; |
| 158 | XrmQuark *quarkTbl; |
| 159 | }TMSimpleStateTreeRec, *TMSimpleStateTree; |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | typedef 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; |
| 171 | TMShortCard numComplexBranchHeads; |
| 172 | TMBranchHeadRec *branchHeadTbl; |
| 173 | XrmQuark *quarkTbl; |
| 174 | StatePtr *complexBranchHeadTbl; |
| 175 | }TMComplexStateTreeRec, *TMComplexStateTree; |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | typedef 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; |
| 188 | TMShortCard numBranchHeads; |
| 189 | TMShortCard numQuarks; |
| 190 | TMShortCard numComplexBranchHeads; |
| 191 | TMBranchHeadRec *branchHeadTbl; |
| 192 | XrmQuark *quarkTbl; |
| 193 | StatePtr *complexBranchHeadTbl; |
| 194 | TMShortCard branchHeadTblSize; |
| 195 | TMShortCard quarkTblSize; |
| 196 | TMShortCard complexBranchHeadTblSize; |
| 197 | StatePtr head; |
| 198 | }TMParseStateTreeRec, *TMParseStateTree; |
| 199 | |
| 200 | typedef union _TMStateTreeRec{ |
| 201 | TMSimpleStateTreeRec simple; |
| 202 | TMParseStateTreeRec parse; |
| 203 | TMComplexStateTreeRec complex; |
| 204 | }*TMStateTree, **TMStateTreePtr, **TMStateTreeList; |
| 205 | |
| 206 | typedef struct _TMSimpleBindProcsRec { |
| 207 | XtActionProc *procs; |
| 208 | }TMSimpleBindProcsRec, *TMSimpleBindProcs; |
| 209 | |
| 210 | typedef struct _TMComplexBindProcsRec { |
| 211 | Widget widget; |
| 212 | XtTranslations aXlations; |
| 213 | XtActionProc *procs; |
| 214 | }TMComplexBindProcsRec, *TMComplexBindProcs; |
| 215 | |
| 216 | typedef struct _TMSimpleBindDataRec { |
| 217 | unsigned int isComplex:1; |
| 218 | TMSimpleBindProcsRec bindTbl[1]; |
| 219 | }TMSimpleBindDataRec, *TMSimpleBindData; |
| 220 | |
| 221 | typedef struct _TMComplexBindDataRec { |
| 222 | unsigned int isComplex:1; |
| 223 | struct _ATranslationData *accel_context; |
| 224 | TMComplexBindProcsRec bindTbl[1]; |
| 225 | }TMComplexBindDataRec, *TMComplexBindData; |
| 226 | |
| 227 | typedef union _TMBindDataRec{ |
| 228 | TMSimpleBindDataRec simple; |
| 229 | TMComplexBindDataRec complex; |
| 230 | }*TMBindData; |
| 231 | |
| 232 | typedef struct _TranslationData{ |
| 233 | unsigned char hasBindings; |
| 234 | unsigned char operation; |
| 235 | TMShortCard numStateTrees; |
| 236 | struct _TranslationData *composers[2]; |
| 237 | EventMask eventMask; |
| 238 | TMStateTree stateTreeTbl[1]; |
| 239 | }TranslationData; |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | typedef struct _ATranslationData{ |
| 249 | unsigned char hasBindings; |
| 250 | unsigned char operation; |
| 251 | struct _TranslationData *xlations; |
| 252 | struct _ATranslationData *next; |
| 253 | TMComplexBindProcsRec bindTbl[1]; |
| 254 | }ATranslationData, *ATranslations; |
| 255 | |
| 256 | typedef struct _TMConvertRec { |
| 257 | XtTranslations old; |
| 258 | XtTranslations new; |
| 259 | } TMConvertRec; |
| 260 | |
| 261 | #define _XtEventTimerEventType ((TMLongCard)~0L) |
| 262 | #define KeysymModMask (1L<<27) |
| 263 | #define AnyButtonMask (1L<<28) |
| 264 | |
| 265 | typedef 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 | |
| 276 | typedef struct _EventSeqRec *EventSeqPtr; |
| 277 | typedef struct _EventSeqRec { |
| 278 | Event event; |
| 279 | StatePtr state; |
| 280 | EventSeqPtr next; |
| 281 | ActionPtr actions; |
| 282 | } EventSeqRec; |
| 283 | |
| 284 | typedef EventSeqRec EventRec; |
| 285 | typedef EventSeqPtr EventPtr; |
| 286 | |
| 287 | typedef struct _TMEventRec { |
| 288 | XEvent *xev; |
| 289 | Event event; |
| 290 | }TMEventRec; |
| 291 | |
| 292 | typedef struct _ActionHookRec { |
| 293 | struct _ActionHookRec* next; |
| 294 | XtAppContext app; |
| 295 | XtActionHookProc proc; |
| 296 | XtPointer closure; |
| 297 | } ActionHookRec, *ActionHook; |
| 298 | |
| 299 | |
| 300 | #define TMKEYCACHELOG2 6 |
| 301 | #define TMKEYCACHESIZE (1<<TMKEYCACHELOG2) |
| 302 | |
| 303 | typedef struct _KeyCacheRec { |
| 304 | unsigned char modifiers_return[256]; |
| 305 | KeyCode keycode[TMKEYCACHESIZE]; |
| 306 | unsigned char modifiers[TMKEYCACHESIZE]; |
| 307 | KeySym keysym[TMKEYCACHESIZE]; |
| 308 | } TMKeyCache; |
| 309 | |
| 310 | typedef struct _TMKeyContextRec { |
| 311 | XEvent *event; |
| 312 | unsigned long serial; |
| 313 | KeySym keysym; |
| 314 | Modifiers modifiers; |
| 315 | TMKeyCache keycache; |
| 316 | } TMKeyContextRec, *TMKeyContext; |
| 317 | |
| 318 | typedef 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 |
| 340 | }TMGlobalRec; |
| 341 | |
| 342 | _XFUNCPROTOBEGIN |
| 343 | |
| 344 | extern 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 | |
| 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 | |
| 375 | |
| 376 | |
| 377 | extern void _XtPopup( |
| 378 | Widget , |
| 379 | XtGrabKind , |
| 380 | _XtBoolean |
| 381 | ); |
| 382 | |
| 383 | extern _XtString _XtPrintXlations( |
| 384 | Widget , |
| 385 | XtTranslations , |
| 386 | Widget , |
| 387 | _XtBoolean |
| 388 | ); |
| 389 | |
| 390 | extern void _XtRegisterGrabs( |
| 391 | Widget |
| 392 | ); |
| 393 | |
| 394 | extern XtPointer _XtInitializeActionData( |
| 395 | struct _XtActionsRec * , |
| 396 | Cardinal , |
| 397 | _XtBoolean |
| 398 | ); |
| 399 | |
| 400 | extern void _XtAddEventSeqToStateTree( |
| 401 | EventSeqPtr , |
| 402 | TMParseStateTree |
| 403 | ); |
| 404 | |
| 405 | extern Boolean _XtMatchUsingStandardMods( |
| 406 | TMTypeMatch , |
| 407 | TMModifierMatch , |
| 408 | TMEventPtr |
| 409 | ); |
| 410 | |
| 411 | extern Boolean _XtMatchUsingDontCareMods( |
| 412 | TMTypeMatch , |
| 413 | TMModifierMatch , |
| 414 | TMEventPtr |
| 415 | ); |
| 416 | |
| 417 | extern Boolean _XtRegularMatch( |
| 418 | TMTypeMatch , |
| 419 | TMModifierMatch , |
| 420 | TMEventPtr |
| 421 | ); |
| 422 | |
| 423 | extern Boolean _XtMatchAtom( |
| 424 | TMTypeMatch , |
| 425 | TMModifierMatch , |
| 426 | TMEventPtr |
| 427 | ); |
| 428 | |
| 429 | extern void _XtTranslateEvent( |
| 430 | Widget , |
| 431 | XEvent* |
| 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 | |
| 443 | extern void _XtBuildKeysymTables(Display *dpy, XtPerDisplay pd); |
| 444 | |
| 445 | #ifndef NO_MIT_HACKS |
| 446 | extern void _XtDisplayTranslations( |
| 447 | Widget , |
| 448 | XEvent* , |
| 449 | String* , |
| 450 | Cardinal* |
| 451 | ); |
| 452 | |
| 453 | extern void _XtDisplayAccelerators( |
| 454 | Widget , |
| 455 | XEvent* , |
| 456 | String* , |
| 457 | Cardinal* |
| 458 | ); |
| 459 | |
| 460 | extern void _XtDisplayInstalledAccelerators( |
| 461 | Widget , |
| 462 | XEvent* , |
| 463 | String* , |
| 464 | Cardinal* |
| 465 | ); |
| 466 | #endif |
| 467 | |
| 468 | extern void _XtPopupInitialize( |
| 469 | XtAppContext |
| 470 | ); |
| 471 | |
| 472 | extern void _XtBindActions( |
| 473 | Widget , |
| 474 | XtTM |
| 475 | ); |
| 476 | |
| 477 | extern Boolean _XtComputeLateBindings( |
| 478 | Display* , |
| 479 | LateBindingsPtr , |
| 480 | Modifiers* , |
| 481 | Modifiers* |
| 482 | ); |
| 483 | |
| 484 | extern XtTranslations _XtCreateXlations( |
| 485 | TMStateTree * , |
| 486 | TMShortCard , |
| 487 | XtTranslations , |
| 488 | XtTranslations |
| 489 | ); |
| 490 | |
| 491 | extern Boolean _XtCvtMergeTranslations( |
| 492 | Display* , |
| 493 | XrmValuePtr , |
| 494 | Cardinal* , |
| 495 | XrmValuePtr , |
| 496 | XrmValuePtr , |
| 497 | XtPointer* |
| 498 | ); |
| 499 | |
| 500 | void _XtRemoveStateTreeByIndex( |
| 501 | XtTranslations , |
| 502 | TMShortCard ); |
| 503 | |
| 504 | void _XtFreeTranslations( |
| 505 | XtAppContext , |
| 506 | XrmValuePtr , |
| 507 | XtPointer , |
| 508 | XrmValuePtr , |
| 509 | Cardinal* |
| 510 | ); |
| 511 | |
| 512 | extern TMShortCard _XtGetModifierIndex( |
| 513 | Event* |
| 514 | ); |
| 515 | |
| 516 | extern TMShortCard _XtGetQuarkIndex( |
| 517 | TMParseStateTree , |
| 518 | XrmQuark |
| 519 | ); |
| 520 | |
| 521 | extern XtTranslations _XtGetTranslationValue( |
| 522 | Widget |
| 523 | ); |
| 524 | |
| 525 | extern TMShortCard _XtGetTypeIndex( |
| 526 | Event* |
| 527 | ); |
| 528 | |
| 529 | extern void _XtGrabInitialize( |
| 530 | XtAppContext |
| 531 | ); |
| 532 | |
| 533 | extern void _XtInstallTranslations( |
| 534 | Widget |
| 535 | ); |
| 536 | |
| 537 | extern void _XtRemoveTranslations( |
| 538 | Widget |
| 539 | ); |
| 540 | |
| 541 | extern void _XtDestroyTMData( |
| 542 | Widget |
| 543 | ); |
| 544 | |
| 545 | extern void _XtMergeTranslations( |
| 546 | Widget , |
| 547 | XtTranslations , |
| 548 | _XtTranslateOp |
| 549 | ); |
| 550 | |
| 551 | extern void _XtActionInitialize( |
| 552 | XtAppContext |
| 553 | ); |
| 554 | |
| 555 | extern TMStateTree _XtParseTreeToStateTree( |
| 556 | TMParseStateTree |
| 557 | ); |
| 558 | |
| 559 | extern String _XtPrintActions( |
| 560 | ActionRec* , |
| 561 | XrmQuark* |
| 562 | ); |
| 563 | |
| 564 | extern String _XtPrintState( |
| 565 | TMStateTree , |
| 566 | TMBranchHead ); |
| 567 | |
| 568 | extern String _XtPrintEventSeq( |
| 569 | EventSeqPtr , |
| 570 | Display* |
| 571 | ); |
| 572 | |
| 573 | typedef Boolean (*_XtTraversalProc)( |
| 574 | StatePtr , |
| 575 | XtPointer |
| 576 | ); |
| 577 | |
| 578 | extern void _XtTraverseStateTree( |
| 579 | TMStateTree , |
| 580 | _XtTraversalProc , |
| 581 | XtPointer |
| 582 | ); |
| 583 | |
| 584 | extern void _XtTranslateInitialize( |
| 585 | void |
| 586 | ); |
| 587 | |
| 588 | extern void _XtAddTMConverters( |
| 589 | ConverterTable |
| 590 | ); |
| 591 | |
| 592 | extern void _XtUnbindActions( |
| 593 | Widget , |
| 594 | XtTranslations , |
| 595 | TMBindData |
| 596 | ); |
| 597 | |
| 598 | extern void _XtUnmergeTranslations( |
| 599 | Widget , |
| 600 | XtTranslations |
| 601 | ); |
| 602 | |
| 603 | |
| 604 | extern void _XtAllocTMContext(XtPerDisplay pd); |
| 605 | |
| 606 | _XFUNCPROTOEND |