MCPcopy Create free account
hub / github.com/SimHacker/micropolis / GetKeySym

Function GetKeySym

micropolis-activity/src/tk/tkbind.c:1477–1556  ·  view source on GitHub ↗
(dispPtr, eventPtr)

Source from the content-addressed store, hash-verified

1475 *
1476 * Results:
1477 * The return value is the KeySym corresponding to
1478 * eventPtr, or NoSymbol if no matching Keysym could be
1479 * found.
1480 *
1481 * Side effects:
1482 * In the first call for a given display, keycode-to-
1483 * KeySym maps get loaded.
1484 *
1485 *----------------------------------------------------------------------
1486 */
1487
1488static KeySym
1489GetKeySym(dispPtr, eventPtr)
1490 register TkDisplay *dispPtr; /* Display in which to
1491 * map keycode. */
1492 register XEvent *eventPtr; /* Description of X event. */
1493{
1494 KeySym *symPtr;
1495 KeySym sym;
1496
1497 /*
1498 * Read the key mapping information from the server if
1499 * we don't have it already.
1500 */
1501
1502 if (dispPtr->symsPerCode == 0) {
1503 Display *dpy = dispPtr->display;
1504
1505#ifdef IS_LINUX
1506 XDisplayKeycodes(dpy, &dispPtr->firstKeycode, &dispPtr->lastKeycode);
1507#else
1508 dispPtr->firstKeycode =
1509 dpy->min_keycode;
1510 dispPtr->lastKeycode =
1511 dpy->max_keycode;
1512#endif
1513 dispPtr->keySyms = XGetKeyboardMapping(dpy,
1514 dispPtr->firstKeycode, dispPtr->lastKeycode + 1
1515 - dispPtr->firstKeycode, &dispPtr->symsPerCode);
1516 }
1517
1518 /*
1519 * Compute the lower-case KeySym for this keycode. May
1520 * have to convert an upper-case KeySym to a lower-case
1521 * one if the list only has a single element.
1522 */
1523
1524 if ((eventPtr->xkey.keycode < dispPtr->firstKeycode)
1525 || (eventPtr->xkey.keycode > dispPtr->lastKeycode)) {
1526 return NoSymbol;
1527 }
1528 symPtr = &dispPtr->keySyms[(eventPtr->xkey.keycode
1529 - dispPtr->firstKeycode) * dispPtr->symsPerCode];
1530 sym = *symPtr;
1531 if ((dispPtr->symsPerCode == 1) || (symPtr[1] == NoSymbol)) {
1532 if ((sym >= XK_A) && (sym <= XK_Z)) {
1533 sym += (XK_a - XK_A);
1534 } else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis)) {

Callers 1

Tk_BindEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected