comparison lisp/x-win-xfree86.el @ 5639:1d1f385c9149

Call XKeysymToString() much less, it leaks. src/ChangeLog addition: 2012-01-08 Aidan Kehoe <kehoea@parhasard.net> * device-x.c: * device-x.c (syms_of_device_x): Move #'x-keysym-on-keyboard{,-sans-modifiers}-p to Lisp, the hash table no longer stores the X keysyms, so we need to manipulate any strings we have been handed. * event-Xt.c (x_has_keysym): Don't call XKeysymToString() here, it leaks; trust x_keysym_to_emacs_keysym() instead. * event-Xt.c (x_keysym_to_emacs_keysym): No longer leak when looking up the strings for keysyms of the form UABCD. lisp/ChangeLog addition: 2012-01-08 Aidan Kehoe <kehoea@parhasard.net> * x-init.el: * x-init.el (pseudo-canonicalize-keysym): New. * x-init.el: Move #'x-keysym-on-keyboard-sans-modifiers-p, #'x-keysym-on-keyboard-p here from device-x.c, some string manipulation it now needs to do is far easier in Lisp. * x-win-xfree86.el: * x-win-xfree86.el (x-win-init-xfree86): No longer call #'x-keysym-on-keyboard{,-sans-modifiers}-p, implement it ourselves cheaply.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 08 Jan 2012 20:41:37 +0000
parents 8861440b1aa4
children
comparison
equal deleted inserted replaced
5638:4050bbef9bf6 5639:1d1f385c9149
37 ;; For no obvious reason, shift-F1 is called F13, although Meta-F1 and 37 ;; For no obvious reason, shift-F1 is called F13, although Meta-F1 and
38 ;; Control-F1 have normal names. 38 ;; Control-F1 have normal names.
39 39
40 ;;; Code: 40 ;;; Code:
41 41
42 (globally-declare-fboundp
43 '(x-keysym-on-keyboard-p x-keysym-on-keyboard-sans-modifiers-p))
44
45 (defun x-win-init-xfree86 (device) 42 (defun x-win-init-xfree86 (device)
46 43
47 ;; We know this keyboard is an XFree86 keyboard. As such, we can predict 44 ;; We know this keyboard is an XFree86 keyboard. As such, we can predict
48 ;; what key scan codes will correspond to the keys on US keyboard layout, 45 ;; what key scan codes will correspond to the keys on US keyboard layout,
49 ;; and we can use that information to fall back to the US layout when 46 ;; and we can use that information to fall back to the US layout when
72 nil nil ?7 ?8 ?9 ?- ?4 ?5 ?6 ?+ ?1 ?2 ?3 ?0 ?\. nil nil 69 nil nil ?7 ?8 ?9 ?- ?4 ?5 ?6 ?+ ?1 ?2 ?3 ?0 ?\. nil nil
73 [?< ?>] nil nil nil nil nil nil nil nil nil nil nil nil 70 [?< ?>] nil nil nil nil nil nil nil nil nil nil nil nil
74 nil nil nil nil nil ?/ nil nil nil nil nil nil nil nil 71 nil nil nil nil nil ?/ nil nil nil nil nil nil nil nil
75 nil nil nil nil nil ?=]) 72 nil nil nil nil nil ?=])
76 73
77 (when (x-keysym-on-keyboard-p 'iso-left-tab device)
78 (define-key function-key-map 'iso-left-tab [(shift tab)]))
79
80 (loop for (key sane-key) in 74 (loop for (key sane-key) in
81 '((f13 f1) 75 '((f13 f1)
82 (f14 f2) 76 (f14 f2)
83 (f15 f3) 77 (f15 f3)
84 (f16 f4) 78 (f16 f4)
92 (f24 f12)) 86 (f24 f12))
93 ;; Get the correct value for function-key-map 87 ;; Get the correct value for function-key-map
94 with function-key-map = (symbol-value-in-console 'function-key-map 88 with function-key-map = (symbol-value-in-console 'function-key-map
95 (device-console device) 89 (device-console device)
96 function-key-map) 90 function-key-map)
91 with x-keysym-hash-table = (x-keysym-hash-table device)
92
93 initially
94 (when (gethash 'iso-left-tab x-keysym-hash-table)
95 (define-key function-key-map 'iso-left-tab [(shift tab)]))
97 96
98 do 97 do
99 (when (and (x-keysym-on-keyboard-p key device) 98 (when (not (memq (gethash key x-keysym-hash-table) '(nil sans-modifiers)))
100 (not (x-keysym-on-keyboard-sans-modifiers-p key device)))
101 ;; define also the control, meta, and meta-control versions. 99 ;; define also the control, meta, and meta-control versions.
102 (loop for mods in '(() (control) (meta) (meta control)) do 100 (loop for mods in '(() (control) (meta) (meta control)) do
103 (define-key function-key-map `[(,@mods ,key)] `[(shift ,@mods ,sane-key)]) 101 (define-key function-key-map `[(,@mods ,key)]
104 )))) 102 `[(shift ,@mods ,sane-key)])))))
105 103
106 ;;; x-win-xfree86.el ends here 104 ;;; x-win-xfree86.el ends here