comparison src/event-Xt.c @ 3171:4cad7ff4a200

[xemacs-hg @ 2005-12-24 19:53:53 by aidan] Incremental changes to improve Russian C-x processing--support punctuation, XFree86 and Sun keyboards, document the facility.
author aidan
date Sat, 24 Dec 2005 19:54:01 +0000
parents 77f5a5135b3a
children 33b9323388c5
comparison
equal deleted inserted replaced
3170:db0631f96757 3171:4cad7ff4a200
70 #ifdef WIN32_ANY 70 #ifdef WIN32_ANY
71 extern int mswindows_is_blocking; 71 extern int mswindows_is_blocking;
72 #endif 72 #endif
73 73
74 /* For Russian C-x processing. */ 74 /* For Russian C-x processing. */
75 #define FIRST_ALPHABETIC_QWERTY_KEYCODE 24 75 Lisp_Object Vx_us_keymap_description;
76 #define LAST_ALPHABETIC_QWERTY_KEYCODE 58 76 Fixnum Vx_us_keymap_first_keycode;
77 77
78 /* used in glyphs-x.c */ 78 /* used in glyphs-x.c */
79 void enqueue_focus_event (Widget wants_it, Lisp_Object frame, int in_p); 79 void enqueue_focus_event (Widget wants_it, Lisp_Object frame, int in_p);
80 static void handle_focus_event_1 (struct frame *f, int in_p); 80 static void handle_focus_event_1 (struct frame *f, int in_p);
81 static void handle_focus_event_2 (Window w, struct frame *f, int in_p); 81 static void handle_focus_event_2 (Window w, struct frame *f, int in_p);
1113 Multi_key sequence, or a "dead" key prefix, or XIM 1113 Multi_key sequence, or a "dead" key prefix, or XIM
1114 input. Ignore it. */ 1114 input. Ignore it. */
1115 if (NILP (keysym)) 1115 if (NILP (keysym))
1116 return 0; 1116 return 0;
1117 1117
1118 /* If we have the map from keycodes to the US layout for our
1119 keyboard available, store the US layout interpretation of
1120 that key in the event structure, in case a binding lookup
1121 fails and we want to fall back to the US layout binding.
1122
1123 This _might_ be possible within an XKB framework, changing
1124 the keyboard to a US XKB layout for a moment at startup,
1125 storing the correspondance, and changing it back. But that
1126 won't work on non-XKB servers, it makes our already slow
1127 startup slower, and it's not clear that it's really any
1128 easier or more maintainable than storing a correspondence in
1129 Lisp. */
1130
1131 if (!NILP(Vx_us_keymap_description) &&
1132 VECTORP(Vx_us_keymap_description) &&
1133 ev->keycode >= (unsigned)Vx_us_keymap_first_keycode &&
1134 ev->keycode
1135 < (unsigned)XVECTOR_LENGTH(Vx_us_keymap_description))
1136 {
1137 Lisp_Object entr = XVECTOR_DATA(Vx_us_keymap_description)
1138 [ev->keycode - Vx_us_keymap_first_keycode];
1139 Ichar alternate = '\0';
1140
1141 if (!NILP (entr))
1142 {
1143 if (CHARP(entr))
1144 {
1145 alternate = XCHAR(entr);
1146 }
1147 else if (VECTORP(entr))
1148 {
1149 if (modifiers & XEMACS_MOD_SHIFT
1150 && XVECTOR_LENGTH(Vx_us_keymap_description) > 1)
1151 {
1152 entr = XVECTOR_DATA(entr)[1];
1153 if (CHARP(entr))
1154 {
1155 alternate = XCHAR(entr);
1156 }
1157 }
1158 else if (XVECTOR_LENGTH(Vx_us_keymap_description)
1159 > 0)
1160 {
1161 entr = XVECTOR_DATA(entr)[0];
1162 if (CHARP(entr))
1163 {
1164 alternate = XCHAR(entr);
1165 }
1166 }
1167 }
1168 if ('\0' != alternate)
1169 {
1170 SET_EVENT_KEY_ALT_KEYCHARS(emacs_event, KEYCHAR_QWERTY,
1171 alternate);
1172 }
1173 }
1174 }
1175
1118 /* More Caps_Lock garbage: Caps_Lock should *only* add the 1176 /* More Caps_Lock garbage: Caps_Lock should *only* add the
1119 shift modifier to two-case keys (that is, A-Z and 1177 shift modifier to two-case keys (that is, A-Z and
1120 related characters). So at this point (after looking up 1178 related characters). So at this point (after looking up
1121 the keysym) if the keysym isn't a dual-case alphabetic, 1179 the keysym) if the keysym isn't a dual-case alphabetic,
1122 and if the caps lock key was down but the shift key 1180 and if the caps lock key was down but the shift key
1128 The right thing to do here is to have pass a third, pointer, 1186 The right thing to do here is to have pass a third, pointer,
1129 argument to x_to_emacs_keysym, where it should store the 1187 argument to x_to_emacs_keysym, where it should store the
1130 intermediate KeySym it used to calculate the string XEmacs 1188 intermediate KeySym it used to calculate the string XEmacs
1131 keysym. Then we can call keysym_obeys_caps_lock_p with 1189 keysym. Then we can call keysym_obeys_caps_lock_p with
1132 exactly the right argument. */ 1190 exactly the right argument. */
1191
1133 /* !!#### maybe fix for Mule 1192 /* !!#### maybe fix for Mule
1134 1193
1135 Hard, in the absence of a full case infrastructure for 1194 Hard, in the absence of a full case infrastructure for
1136 Mule characters. When 1195 Mule characters. When
1137 (downcase (make-char 'cyrillic-iso8859-5 73)) 1196 (downcase (make-char 'cyrillic-iso8859-5 73))
1151 and unshifted version of this key, apply the shift bit. 1210 and unshifted version of this key, apply the shift bit.
1152 Non-graphics, like Backspace and F1 get the shift bit 1211 Non-graphics, like Backspace and F1 get the shift bit
1153 in the modifiers slot. Neither the characters "a", 1212 in the modifiers slot. Neither the characters "a",
1154 "A", "2", nor "@" normally have the shift bit set. 1213 "A", "2", nor "@" normally have the shift bit set.
1155 However, "F1" normally does. */ 1214 However, "F1" normally does. */
1215
1156 if (modifiers & XEMACS_MOD_SHIFT) 1216 if (modifiers & XEMACS_MOD_SHIFT)
1157 { 1217 {
1158 int Mode_switch_p = *state & xd->ModeMask; 1218 int Mode_switch_p = *state & xd->ModeMask;
1159 KeySym bot = XLookupKeysym (ev, Mode_switch_p ? 2 : 0); 1219 KeySym bot = XLookupKeysym (ev, Mode_switch_p ? 2 : 0);
1160 KeySym top = XLookupKeysym (ev, Mode_switch_p ? 3 : 1); 1220 KeySym top = XLookupKeysym (ev, Mode_switch_p ? 3 : 1);
1163 } 1223 }
1164 set_event_type (emacs_event, key_press_event); 1224 set_event_type (emacs_event, key_press_event);
1165 SET_EVENT_TIMESTAMP (emacs_event, ev->time); 1225 SET_EVENT_TIMESTAMP (emacs_event, ev->time);
1166 SET_EVENT_KEY_MODIFIERS (emacs_event, modifiers); 1226 SET_EVENT_KEY_MODIFIERS (emacs_event, modifiers);
1167 SET_EVENT_KEY_KEYSYM (emacs_event, keysym); 1227 SET_EVENT_KEY_KEYSYM (emacs_event, keysym);
1168
1169 if (ev->keycode >= FIRST_ALPHABETIC_QWERTY_KEYCODE
1170 && ev->keycode <= LAST_ALPHABETIC_QWERTY_KEYCODE)
1171 {
1172 /* This correspondence isn't guaranteed by the standards, to
1173 my knowledge. Also, it's incomplete--doesn't include the
1174 upper-case characters, etc--I need to get some feedback
1175 on it once this is out in the world and actually being
1176 used by Russians. */
1177 static const Ascbyte qwerty_map[] =
1178 { 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
1179 '[', ']', '\015', '\014',
1180 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l',
1181 ';', '\'', '`', 0, '\\',
1182 'z', 'x', 'c', 'v', 'b', 'n', 'm' };
1183 Ichar val = qwerty_map
1184 [ev->keycode - FIRST_ALPHABETIC_QWERTY_KEYCODE];
1185 if (val)
1186 {
1187 SET_EVENT_KEY_ALT_KEYCHARS(emacs_event, KEYCHAR_QWERTY,
1188 val);
1189 }
1190 }
1191 } 1228 }
1192 else /* Mouse press/release event */ 1229 else /* Mouse press/release event */
1193 { 1230 {
1194 XButtonEvent *ev = &x_event->xbutton; 1231 XButtonEvent *ev = &x_event->xbutton;
1195 struct frame *frame = x_window_to_frame (d, ev->window); 1232 struct frame *frame = x_window_to_frame (d, ev->window);
3153 1 == non-verbose output 3190 1 == non-verbose output
3154 2 == verbose output 3191 2 == verbose output
3155 */ ); 3192 */ );
3156 debug_x_events = 0; 3193 debug_x_events = 0;
3157 #endif 3194 #endif
3195 DEFVAR_LISP ("x-us-keymap-description", &Vx_us_keymap_description /*
3196 X11-specific vector describing the current keyboard hardware, and how to map
3197 from its keycodes to those alphanumeric and punctuation characters that
3198 would be produced by it if a US layout were configured in software.
3199
3200 We use this to make possible the usage of standard key bindings on keyboards
3201 where the keys that those bindings assume are not available; for example, on
3202 a Russian keyboard, one can type C-Cyrillic_che C-Cyrillic_a and have XEmacs
3203 use the binding for C-x C-f, rather than give an error message that
3204 C-Cyrillic_che C-Cyrillic_a is not bound.
3205
3206 Entries are either nil, which means the corresponding key code does not map
3207 to a non-function key in the US layout, a single character, meaning it maps to
3208 that character, or a vector of two characters, the first indicating the
3209 unshifted mapping, the second the shifted mapping for the US layout.
3210
3211 `x-us-keymap-first-keycode' tells XEmacs the keycode of the first entry in
3212 this vector.
3213 */ );
3214 Vx_us_keymap_description = Qnil;
3215
3216 DEFVAR_INT ("x-us-keymap-first-keycode", &Vx_us_keymap_first_keycode /*
3217 The X11 keycode that the first entry in `x-us-keymap-description'
3218 corresponds to. See the documentation for that variable.
3219
3220 The X11 documentation for XDisplayKeycodes says this can never be less than
3221 8, but XEmacs doesn't enforce any limitation on what you set it to.
3222 */ );
3223 Vx_us_keymap_first_keycode = 0;
3158 } 3224 }
3159 3225
3160 /* This mess is a hack that patches the shell widget to treat visual inheritance 3226 /* This mess is a hack that patches the shell widget to treat visual inheritance
3161 the same as colormap and depth inheritance */ 3227 the same as colormap and depth inheritance */
3162 3228