comparison src/event-Xt.c @ 187:b405438285a2 r20-3b20

Import from CVS: tag r20-3b20
author cvs
date Mon, 13 Aug 2007 09:56:28 +0200
parents 3d6bfa290dbd
children 489f57a838ef
comparison
equal deleted inserted replaced
186:24ac94803b48 187:b405438285a2
37 #include "events.h" 37 #include "events.h"
38 #include "frame.h" 38 #include "frame.h"
39 #include "objects-x.h" 39 #include "objects-x.h"
40 #include "process.h" 40 #include "process.h"
41 #include "redisplay.h" 41 #include "redisplay.h"
42 #include "elhash.h"
42 43
43 #include "systime.h" 44 #include "systime.h"
44 #include "sysproc.h" /* for MAXDESC */ 45 #include "sysproc.h" /* for MAXDESC */
45 46
46 #include "xintrinsicp.h" /* CoreP.h needs this */ 47 #include "xintrinsicp.h" /* CoreP.h needs this */
118 #endif 119 #endif
119 120
120 static int last_quit_check_signal_tick_count; 121 static int last_quit_check_signal_tick_count;
121 122
122 Lisp_Object Qkey_mapping; 123 Lisp_Object Qkey_mapping;
124 Lisp_Object Qsans_modifiers;
123 125
124 126
125 /************************************************************************/ 127 /************************************************************************/
126 /* keymap handling */ 128 /* keymap handling */
127 /************************************************************************/ 129 /************************************************************************/
169 static void 171 static void
170 x_reset_key_mapping (struct device *d) 172 x_reset_key_mapping (struct device *d)
171 { 173 {
172 Display *display = DEVICE_X_DISPLAY (d); 174 Display *display = DEVICE_X_DISPLAY (d);
173 struct x_device *xd = DEVICE_X_DATA (d); 175 struct x_device *xd = DEVICE_X_DATA (d);
176 KeySym *keysym, *keysym_end;
177 Lisp_Object hashtable;
178 int key_code_count, keysyms_per_code;
179
174 if (xd->x_keysym_map) 180 if (xd->x_keysym_map)
175 XFree ((char *) xd->x_keysym_map); 181 XFree ((char *) xd->x_keysym_map);
176 XDisplayKeycodes (display, 182 XDisplayKeycodes (display,
177 &xd->x_keysym_map_min_code, 183 &xd->x_keysym_map_min_code,
178 &xd->x_keysym_map_max_code); 184 &xd->x_keysym_map_max_code);
179 xd->x_keysym_map = XGetKeyboardMapping (display, 185 key_code_count = xd->x_keysym_map_max_code - xd->x_keysym_map_min_code + 1;
180 xd->x_keysym_map_min_code, 186 xd->x_keysym_map =
181 xd->x_keysym_map_max_code - 187 XGetKeyboardMapping (display, xd->x_keysym_map_min_code, key_code_count,
182 xd->x_keysym_map_min_code + 1, 188 &xd->x_keysym_map_keysyms_per_code);
183 &xd->x_keysym_map_keysyms_per_code); 189
190 xd->x_keysym_map_hashtable = hashtable =
191 make_lisp_hashtable (128, HASHTABLE_NONWEAK, HASHTABLE_EQUAL);
192
193 for (keysym = xd->x_keysym_map,
194 keysyms_per_code = xd->x_keysym_map_keysyms_per_code,
195 keysym_end = keysym + (key_code_count * keysyms_per_code);
196 keysym < keysym_end;
197 keysym += keysyms_per_code)
198 {
199 int j;
200 char *keysym_name;
201
202 if (keysym[0] == NoSymbol)
203 continue;
204
205 if ((keysym_name = XKeysymToString (keysym[0])) != NULL)
206 Fputhash (build_string (keysym_name), Qsans_modifiers, hashtable);
207
208 for (j = 1; j < keysyms_per_code; j++)
209 {
210 if (keysym[j] == keysym[0] ||
211 keysym[j] == NoSymbol)
212 continue;
213
214 if ((keysym_name = XKeysymToString (keysym[j])) != NULL)
215 {
216 Lisp_Object name = build_string (keysym_name);
217 if (NILP (Fgethash (name, hashtable, Qnil)))
218 Fputhash (name, Qt, hashtable);
219 }
220 }
221 }
184 } 222 }
185 223
186 static CONST char * 224 static CONST char *
187 index_to_name (int indice) 225 index_to_name (int indice)
188 { 226 {
391 } 429 }
392 430
393 void 431 void
394 x_init_modifier_mapping (struct device *d) 432 x_init_modifier_mapping (struct device *d)
395 { 433 {
396 DEVICE_X_DATA (d)->x_keysym_map = 0; 434 struct x_device *xd = DEVICE_X_DATA (d);
397 DEVICE_X_DATA (d)->x_modifier_keymap = 0; 435 xd->x_keysym_map_hashtable = Qnil;
436 xd->x_keysym_map = NULL;
437 xd->x_modifier_keymap = NULL;
398 x_reset_modifier_mapping (d); 438 x_reset_modifier_mapping (d);
399 } 439 }
400 440
401 static int 441 static int
402 x_key_is_modifier_p (KeyCode keycode, struct device *d) 442 x_key_is_modifier_p (KeyCode keycode, struct device *d)
646 case 0: return Qnil; 686 case 0: return Qnil;
647 default: 687 default:
648 if (simple_p) return Qnil; 688 if (simple_p) return Qnil;
649 /* !!#### not Mule-ized */ 689 /* !!#### not Mule-ized */
650 name = XKeysymToString (keysym); 690 name = XKeysymToString (keysym);
651 if (!name || !name[0]) /* this shouldn't happen... */ 691 if (!name || !name[0])
652 { 692 /* This happens if there is a mismatch between the Xlib of
653 char buf [255]; 693 XEmacs and the Xlib of the X server...
654 sprintf (buf, "unknown_keysym_0x%X", (int) keysym); 694
655 return KEYSYM (buf); 695 Let's hard-code in some knowledge of common keysyms introduced
656 } 696 in recent X11 releases. Snarfed from X11/keysymdef.h
697
698 Probably we should add some stuff here for X11R6. */
699 switch (keysym)
700 {
701 case 0xFF95: return KEYSYM ("kp-home");
702 case 0xFF96: return KEYSYM ("kp-left");
703 case 0xFF97: return KEYSYM ("kp-up");
704 case 0xFF98: return KEYSYM ("kp-right");
705 case 0xFF99: return KEYSYM ("kp-down");
706 case 0xFF9A: return KEYSYM ("kp-prior");
707 case 0xFF9B: return KEYSYM ("kp-next");
708 case 0xFF9C: return KEYSYM ("kp-end");
709 case 0xFF9D: return KEYSYM ("kp-begin");
710 case 0xFF9E: return KEYSYM ("kp-insert");
711 case 0xFF9F: return KEYSYM ("kp-delete");
712
713 case 0x1005FF10: return KEYSYM ("SunF36"); /* labeled F11 */
714 case 0x1005FF11: return KEYSYM ("SunF37"); /* labeled F12 */
715 default:
716 {
717 char buf [64];
718 sprintf (buf, "unknown-keysym-0x%X", (int) keysym);
719 return KEYSYM (buf);
720 }
721 }
657 /* If it's got a one-character name, that's good enough. */ 722 /* If it's got a one-character name, that's good enough. */
658 if (!name[1]) 723 if (!name[1])
659 return make_char (name[0]); 724 return make_char (name[0]);
660 725
661 /* If it's in the "Keyboard" character set, downcase it. 726 /* If it's in the "Keyboard" character set, downcase it.
2612 2677
2613 void 2678 void
2614 syms_of_event_Xt (void) 2679 syms_of_event_Xt (void)
2615 { 2680 {
2616 defsymbol (&Qkey_mapping, "key-mapping"); 2681 defsymbol (&Qkey_mapping, "key-mapping");
2682 defsymbol (&Qsans_modifiers, "sans-modifiers");
2617 } 2683 }
2618 2684
2619 void 2685 void
2620 vars_of_event_Xt (void) 2686 vars_of_event_Xt (void)
2621 { 2687 {