diff options
| author | Jim Blandy | 1992-10-19 18:31:34 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-10-19 18:31:34 +0000 |
| commit | 11edeb0334ccce2d985c0624404565038fa2cbf4 (patch) | |
| tree | eb8615d1abcbb3fee27728ded401eac9e69999eb | |
| parent | 2247b0fc583c4350007d2201bf28b05e82256c7d (diff) | |
| download | emacs-11edeb0334ccce2d985c0624404565038fa2cbf4.tar.gz emacs-11edeb0334ccce2d985c0624404565038fa2cbf4.zip | |
* xterm.c (compose_status): New variable.
(XTread_socket): Pass it by reference to XLookupString.
* xterm.c: Clean up some of the caps lock handling:
(x_shift_lock_mask): New variable.
(x_find_modifier_mappings): Set it, based on the modifier mappings.
(x_convert_modifiers): Use x_shift_lock_mask, instead of assuming
that the lock bit always means to shift the character.
(XTread_socket): When handling KeyPress events, don't pass an
XComposeStatus structure along to XLookupString. When handling
MappingNotify events, call XRefreshKeyboardMapping for both
MappingModifier and MappingKeyboard events, not just the latter.
| -rw-r--r-- | src/xterm.c | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/src/xterm.c b/src/xterm.c index 1bbdf5782cf..19816dc9bb7 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1431,18 +1431,23 @@ unsigned int x_mouse_grabbed; | |||
| 1431 | /* Which modifier keys are on which modifier bits? | 1431 | /* Which modifier keys are on which modifier bits? |
| 1432 | 1432 | ||
| 1433 | With each keystroke, X returns eight bits indicating which modifier | 1433 | With each keystroke, X returns eight bits indicating which modifier |
| 1434 | keys were held down when the key was pressed. The low three bits | 1434 | keys were held down when the key was pressed. The interpretation |
| 1435 | indicate the state of the shift, shift lock, caps lock, and control | 1435 | of the top five modifier bits depends on what keys are attached |
| 1436 | keys; their interpretation is fixed. However, the interpretation | ||
| 1437 | of the other five modifier bits depends on what keys are attached | ||
| 1438 | to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5 | 1436 | to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5 |
| 1439 | is the meta bit. | 1437 | is the meta bit. |
| 1440 | 1438 | ||
| 1441 | x_meta_mod_mask is a mask containing the bits used for the meta key. | 1439 | x_meta_mod_mask is a mask containing the bits used for the meta key. |
| 1442 | It may have more than one bit set, if more than one modifier bit | 1440 | It may have more than one bit set, if more than one modifier bit |
| 1443 | has meta keys on it. Basically, if EVENT is a KeyPress event, | 1441 | has meta keys on it. Basically, if EVENT is a KeyPress event, |
| 1444 | the meta key is pressed if (EVENT.state & x_meta_mod_mask) != 0. */ | 1442 | the meta key is pressed if (EVENT.state & x_meta_mod_mask) != 0. |
| 1445 | static int x_meta_mod_mask; | 1443 | |
| 1444 | x_shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the | ||
| 1445 | lock modifier bit, or zero otherwise. Non-alphabetic keys should | ||
| 1446 | only be affected by the lock modifier bit if XK_Shift_Lock is in | ||
| 1447 | use; XK_Caps_Lock should only affect alphabetic keys. With this | ||
| 1448 | arrangement, the lock modifier should shift the character if | ||
| 1449 | (EVENT.state & x_shift_lock_mask) != 0. */ | ||
| 1450 | static int x_meta_mod_mask, x_shift_lock_mask; | ||
| 1446 | 1451 | ||
| 1447 | /* Initialize mode_switch_bit and modifier_meaning. */ | 1452 | /* Initialize mode_switch_bit and modifier_meaning. */ |
| 1448 | static void | 1453 | static void |
| @@ -1455,6 +1460,7 @@ x_find_modifier_meanings () | |||
| 1455 | int alt_mod_mask = 0; | 1460 | int alt_mod_mask = 0; |
| 1456 | 1461 | ||
| 1457 | x_meta_mod_mask = 0; | 1462 | x_meta_mod_mask = 0; |
| 1463 | x_shift_lock_mask = 0; | ||
| 1458 | 1464 | ||
| 1459 | XDisplayKeycodes (x_current_display, &min_code, &max_code); | 1465 | XDisplayKeycodes (x_current_display, &min_code, &max_code); |
| 1460 | syms = XGetKeyboardMapping (x_current_display, | 1466 | syms = XGetKeyboardMapping (x_current_display, |
| @@ -1462,10 +1468,8 @@ x_find_modifier_meanings () | |||
| 1462 | &syms_per_code); | 1468 | &syms_per_code); |
| 1463 | mods = XGetModifierMapping (x_current_display); | 1469 | mods = XGetModifierMapping (x_current_display); |
| 1464 | 1470 | ||
| 1465 | /* If CapsLock is on the lock modifier, then only letters should be | 1471 | /* Scan the modifier table to see which modifier bits the Meta and |
| 1466 | affected; since XLookupString takes care of this for us, the lock | 1472 | Alt keysyms are on. */ |
| 1467 | modifier shouldn't set shift_modifier. However, if ShiftLock is | ||
| 1468 | on the lock modifier, then lock should mean shift. */ | ||
| 1469 | { | 1473 | { |
| 1470 | int row, col; /* The row and column in the modifier table. */ | 1474 | int row, col; /* The row and column in the modifier table. */ |
| 1471 | 1475 | ||
| @@ -1494,6 +1498,12 @@ x_find_modifier_meanings () | |||
| 1494 | case XK_Alt_R: | 1498 | case XK_Alt_R: |
| 1495 | alt_mod_mask |= (1 << row); | 1499 | alt_mod_mask |= (1 << row); |
| 1496 | break; | 1500 | break; |
| 1501 | |||
| 1502 | case XK_Shift_Lock: | ||
| 1503 | /* Ignore this if it's not on the lock modifier. */ | ||
| 1504 | if ((1 << row) == LockMask) | ||
| 1505 | x_shift_lock_mask = LockMask; | ||
| 1506 | break; | ||
| 1497 | } | 1507 | } |
| 1498 | } | 1508 | } |
| 1499 | } | 1509 | } |
| @@ -1516,9 +1526,9 @@ static Lisp_Object | |||
| 1516 | x_convert_modifiers (state) | 1526 | x_convert_modifiers (state) |
| 1517 | unsigned int state; | 1527 | unsigned int state; |
| 1518 | { | 1528 | { |
| 1519 | return ( ((state & (ShiftMask | LockMask)) ? shift_modifier : 0) | 1529 | return ( ((state & (ShiftMask | x_shift_lock_mask)) ? shift_modifier : 0) |
| 1520 | | ((state & ControlMask) ? ctrl_modifier : 0) | 1530 | | ((state & ControlMask) ? ctrl_modifier : 0) |
| 1521 | | ((state & x_meta_mod_mask) ? meta_modifier : 0)); | 1531 | | ((state & x_meta_mod_mask) ? meta_modifier : 0)); |
| 1522 | } | 1532 | } |
| 1523 | 1533 | ||
| 1524 | extern struct frame *x_window_to_scrollbar (); | 1534 | extern struct frame *x_window_to_scrollbar (); |
| @@ -1746,6 +1756,15 @@ XTmouse_position (f, x, y, time) | |||
| 1746 | sometimes don't work. */ | 1756 | sometimes don't work. */ |
| 1747 | static Time enter_timestamp; | 1757 | static Time enter_timestamp; |
| 1748 | 1758 | ||
| 1759 | /* This holds the state XLookupString needs to implement dead keys | ||
| 1760 | and other tricks known as "compose processing". _X Window System_ | ||
| 1761 | says that a portable program can't use this, but Stephen Gildea assures | ||
| 1762 | me that letting the compiler initialize it to zeros will work okay. | ||
| 1763 | |||
| 1764 | This must be defined outside of XTread_socket, for the same reasons | ||
| 1765 | given for enter_timestamp, above. */ | ||
| 1766 | static XComposeStatus compose_status; | ||
| 1767 | |||
| 1749 | /* Communication with window managers. */ | 1768 | /* Communication with window managers. */ |
| 1750 | Atom Xatom_wm_protocols; | 1769 | Atom Xatom_wm_protocols; |
| 1751 | 1770 | ||
| @@ -2030,7 +2049,6 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 2030 | if (f != 0) | 2049 | if (f != 0) |
| 2031 | { | 2050 | { |
| 2032 | KeySym keysym; | 2051 | KeySym keysym; |
| 2033 | XComposeStatus status; | ||
| 2034 | char copy_buffer[80]; | 2052 | char copy_buffer[80]; |
| 2035 | int modifiers = event.xkey.state; | 2053 | int modifiers = event.xkey.state; |
| 2036 | 2054 | ||
| @@ -2041,12 +2059,10 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 2041 | just clear the meta-key flag to get the 'pure' character. */ | 2059 | just clear the meta-key flag to get the 'pure' character. */ |
| 2042 | event.xkey.state &= ~Mod1Mask; | 2060 | event.xkey.state &= ~Mod1Mask; |
| 2043 | 2061 | ||
| 2044 | /* This will have to go some day... */ | 2062 | /* This will have to go some day... */ |
| 2045 | nbytes = XLookupString (&event.xkey, | 2063 | nbytes = |
| 2046 | copy_buffer, | 2064 | XLookupString (&event.xkey, copy_buffer, 80, &keysym, |
| 2047 | 80, | 2065 | &compose_status); |
| 2048 | &keysym, | ||
| 2049 | &status); | ||
| 2050 | 2066 | ||
| 2051 | /* Strip off the vendor-specific keysym bit, and take a shot | 2067 | /* Strip off the vendor-specific keysym bit, and take a shot |
| 2052 | at recognizing the codes. HP servers have extra keysyms | 2068 | at recognizing the codes. HP servers have extra keysyms |
| @@ -2400,12 +2416,16 @@ XTread_socket (sd, bufp, numchars, waitp, expected) | |||
| 2400 | #endif /* ! defined (HAVE_X11) */ | 2416 | #endif /* ! defined (HAVE_X11) */ |
| 2401 | 2417 | ||
| 2402 | case MappingNotify: | 2418 | case MappingNotify: |
| 2403 | if (event.xmapping.request == MappingKeyboard) | 2419 | /* Someone has changed the keyboard mapping - update the |
| 2404 | /* Someone has changed the keyboard mapping - flush the | 2420 | local cache. */ |
| 2405 | local cache. */ | 2421 | switch (event.xmapping.request) |
| 2406 | XRefreshKeyboardMapping (&event.xmapping); | 2422 | { |
| 2407 | else if (event.xmapping.request == MappingModifier) | 2423 | case MappingModifier: |
| 2408 | x_find_modifier_meanings (); | 2424 | x_find_modifier_meanings (); |
| 2425 | /* This is meant to fall through. */ | ||
| 2426 | case MappingKeyboard: | ||
| 2427 | XRefreshKeyboardMapping (&event.xmapping); | ||
| 2428 | } | ||
| 2409 | break; | 2429 | break; |
| 2410 | 2430 | ||
| 2411 | default: | 2431 | default: |