From: Christophe Rhodes csr21@cantab.net
Samium Gromoff _deepfire@feelingofgreen.ru writes:
Of course I'm sending the CLX part to a wrong list.
That's OK :-)
What it does?
- CLX part
First, it tells CLX to ask the X server to enable XKEYBOARD. This part wants to be performed conditionally, depending on the extension's existence, obviously, which I skipped.
Next, it defines keysym -> CL character mappings for the Cyrillic part of Unicode.
OK, this looks cool. (The conditional bit shouldn't be hard; take a look a the BIG-REQUESTS bit.)
Ok, I've done the conditional bit by generalising it somewhat, and factoring in BIG-REQUESTS. The only changes are against CLX.
Perhaps "auto-init-fn" is a stupid name for that keyword parameter, but I couldn't come up with anything better.
regards, Samium Gromoff
diff --git a/big-requests.lisp b/big-requests.lisp --- a/big-requests.lisp +++ b/big-requests.lisp @@ -19,7 +19,8 @@ ;;; ;;; The name of this extension is "BIG-REQUESTS" (Big Requests ;;; Extension, section 4) -(define-extension "BIG-REQUESTS") +(define-extension "BIG-REQUESTS" + :auto-init-fn enable-big-requests)
(defun enable-big-requests (display) (declare (type display display)) diff --git a/clx.asd b/clx.asd --- a/clx.asd +++ b/clx.asd @@ -70,6 +70,7 @@ ((:file "shape") (:file "big-requests") (:file "xvidmode") + (:file "xkeyboard") (:xrender-source-file "xrender") (:file "glx") (:file "gl" :depends-on ("glx")) diff --git a/display.lisp b/display.lisp --- a/display.lisp +++ b/display.lisp @@ -392,9 +392,10 @@ gethostname(3) - is used instead." (initialize-resource-allocator disp) (initialize-predefined-atoms disp) (initialize-extensions disp) - (when (assoc "BIG-REQUESTS" (display-extension-alist disp) - :test #'string=) - (enable-big-requests disp)) + (loop :for (name event-list errors auto-init-fn) :in *extensions* :do + (when (and (assoc (symbol-name name) (display-extension-alist disp) :test #'string=) + auto-init-fn) + (funcall auto-init-fn disp))) (setq ok-p t)) (unless ok-p (close-display disp :abort t))) disp)) diff --git a/input.lisp b/input.lisp --- a/input.lisp +++ b/input.lisp @@ -83,7 +83,7 @@
(defvar *extensions* nil) ;; alist of (extension-name-symbol events errors)
-(defmacro define-extension (name &key events errors) +(defmacro define-extension (name &key events errors auto-init-fn) ;; Define extension NAME with EVENTS and ERRORS. ;; Note: The case of NAME is important. ;; To define the request, Use: @@ -96,7 +96,7 @@ (let ((name-symbol (kintern name)) ;; Intern name in the keyword package (event-list (mapcar #'canonicalize-event-name events))) `(eval-when (:compile-toplevel :load-toplevel :execute) - (setq *extensions* (cons (list ',name-symbol ',event-list ',errors) + (setq *extensions* (cons (list ',name-symbol ',event-list ',errors ',auto-init-fn) (delete ',name-symbol *extensions* :key #'car))))))
(eval-when (:compile-toplevel :load-toplevel :execute) diff --git a/keysyms.lisp b/keysyms.lisp --- a/keysyms.lisp +++ b/keysyms.lisp @@ -157,6 +157,100 @@ (define-keysym #} 125) (define-keysym #~ 126)
+;; (define-keysym #\SERBIAN_dje (keysym 6 #xa1)) +;; (define-keysym #\MACEDONIA_gje (keysym 6 #xa2)) +(define-keysym #\CYRILLIC_small_letter_io (keysym 6 #xa3)) +;; (define-keysym #\UKRAINIAN_ie (keysym 6 #xa4)) +;; (define-keysym #\MACEDONIA_dse (keysym 6 #xa5)) +;; (define-keysym #\UKRAINIAN_i (keysym 6 #xa6)) +;; (define-keysym #\UKRAINIAN_yi (keysym 6 #xa7)) +(define-keysym #\CYRILLIC_small_letter_je (keysym 6 #xa8)) +(define-keysym #\CYRILLIC_small_letter_lje (keysym 6 #xa9)) +(define-keysym #\CYRILLIC_small_letter_nje (keysym 6 #xaa)) +;; (define-keysym #\SERBIAN_tshe (keysym 6 #xab)) +;; (define-keysym #\MACEDONIA_kje (keysym 6 #xac)) +;; (define-keysym #\BYELORUSSIAN_shortu (keysym 6 #xae)) +(define-keysym #\CYRILLIC_small_letter_dzhe (keysym 6 #xaf)) +;; (define-keysym #\NUMEROSIGN (keysym 6 #xb0)) +;; (define-keysym #\SERBIAN_DJE (keysym 6 #xb1)) +;; (define-keysym #\MACEDONIA_GJE (keysym 6 #xb2)) +(define-keysym #\CYRILLIC_CAPITAL_LETTER_IO (keysym 6 #xb3)) +;; (define-keysym #\UKRAINIAN_IE (keysym 6 #xb4)) +;; (define-keysym #\MACEDONIA_DSE (keysym 6 #xb5)) +;; (define-keysym #\UKRAINIAN_I (keysym 6 #xb6)) +;; (define-keysym #\UKRAINIAN_YI (keysym 6 #xb7)) +(define-keysym #\CYRILLIC_CAPITAL_LETTER_JE (keysym 6 #xb8)) +(define-keysym #\CYRILLIC_CAPITAL_LETTER_LJE (keysym 6 #xb9)) +(define-keysym #\CYRILLIC_CAPITAL_LETTER_NJE (keysym 6 #xba)) +;; (define-keysym #\SERBIAN_TSHE (keysym 6 #xbb)) +;; (define-keysym #\MACEDONIA_KJE (keysym 6 #xbc)) +;; (define-keysym #\BYELORUSSIAN_SHORTU (keysym 6 #xbe)) +(define-keysym #\CYRILLIC_CAPITAL_LETTER_DZHE (keysym 6 #xbf)) +(define-keysym #\CYRILLIC_small_letter_yu (keysym 6 #xc0)) +(define-keysym #\CYRILLIC_small_letter_a (keysym 6 #xc1)) +(define-keysym #\CYRILLIC_small_letter_be (keysym 6 #xc2)) +(define-keysym #\CYRILLIC_small_letter_tse (keysym 6 #xc3)) +(define-keysym #\CYRILLIC_small_letter_de (keysym 6 #xc4)) +(define-keysym #\CYRILLIC_small_letter_ie (keysym 6 #xc5)) +(define-keysym #\CYRILLIC_small_letter_ef (keysym 6 #xc6)) +(define-keysym #\CYRILLIC_small_letter_ghe (keysym 6 #xc7)) +(define-keysym #\CYRILLIC_small_letter_ha (keysym 6 #xc8)) +(define-keysym #\CYRILLIC_small_letter_i (keysym 6 #xc9)) +(define-keysym #\CYRILLIC_small_letter_short_i (keysym 6 #xca)) +(define-keysym #\CYRILLIC_small_letter_ka (keysym 6 #xcb)) +(define-keysym #\CYRILLIC_small_letter_el (keysym 6 #xcc)) +(define-keysym #\CYRILLIC_small_letter_em (keysym 6 #xcd)) +(define-keysym #\CYRILLIC_small_letter_en (keysym 6 #xce)) +(define-keysym #\CYRILLIC_small_letter_o (keysym 6 #xcf)) +(define-keysym #\CYRILLIC_small_letter_pe (keysym 6 #xd0)) +(define-keysym #\CYRILLIC_small_letter_ya (keysym 6 #xd1)) +(define-keysym #\CYRILLIC_small_letter_er (keysym 6 #xd2)) +(define-keysym #\CYRILLIC_small_letter_es (keysym 6 #xd3)) +(define-keysym #\CYRILLIC_small_letter_te (keysym 6 #xd4)) +(define-keysym #\CYRILLIC_small_letter_u (keysym 6 #xd5)) +(define-keysym #\CYRILLIC_small_letter_zhe (keysym 6 #xd6)) +(define-keysym #\CYRILLIC_small_letter_ve (keysym 6 #xd7)) +(define-keysym #\CYRILLIC_small_letter_soft_sign (keysym 6 #xd8)) +(define-keysym #\CYRILLIC_small_letter_yeru (keysym 6 #xd9)) +(define-keysym #\CYRILLIC_small_letter_ze (keysym 6 #xda)) +(define-keysym #\CYRILLIC_small_letter_sha (keysym 6 #xdb)) +(define-keysym #\CYRILLIC_small_letter_e (keysym 6 #xdc)) +(define-keysym #\CYRILLIC_small_letter_shcha (keysym 6 #xdd)) +(define-keysym #\CYRILLIC_small_letter_che (keysym 6 #xde)) +(define-keysym #\CYRILLIC_small_letter_hard_sign (keysym 6 #xdf)) +(define-keysym #\CYRILLIC_capital_letter_YU (keysym 6 #xe0)) +(define-keysym #\CYRILLIC_capital_letter_A (keysym 6 #xe1)) +(define-keysym #\CYRILLIC_capital_letter_BE (keysym 6 #xe2)) +(define-keysym #\CYRILLIC_capital_letter_TSE (keysym 6 #xe3)) +(define-keysym #\CYRILLIC_capital_letter_DE (keysym 6 #xe4)) +(define-keysym #\CYRILLIC_capital_letter_IE (keysym 6 #xe5)) +(define-keysym #\CYRILLIC_capital_letter_EF (keysym 6 #xe6)) +(define-keysym #\CYRILLIC_capital_letter_GHE (keysym 6 #xe7)) +(define-keysym #\CYRILLIC_capital_letter_HA (keysym 6 #xe8)) +(define-keysym #\CYRILLIC_capital_letter_I (keysym 6 #xe9)) +(define-keysym #\CYRILLIC_capital_letter_SHORT_I (keysym 6 #xea)) +(define-keysym #\CYRILLIC_capital_letter_KA (keysym 6 #xeb)) +(define-keysym #\CYRILLIC_capital_letter_EL (keysym 6 #xec)) +(define-keysym #\CYRILLIC_capital_letter_EM (keysym 6 #xed)) +(define-keysym #\CYRILLIC_capital_letter_EN (keysym 6 #xee)) +(define-keysym #\CYRILLIC_capital_letter_O (keysym 6 #xef)) +(define-keysym #\CYRILLIC_capital_letter_PE (keysym 6 #xf0)) +(define-keysym #\CYRILLIC_capital_letter_YA (keysym 6 #xf1)) +(define-keysym #\CYRILLIC_capital_letter_ER (keysym 6 #xf2)) +(define-keysym #\CYRILLIC_capital_letter_ES (keysym 6 #xf3)) +(define-keysym #\CYRILLIC_capital_letter_TE (keysym 6 #xf4)) +(define-keysym #\CYRILLIC_capital_letter_U (keysym 6 #xf5)) +(define-keysym #\CYRILLIC_capital_letter_ZHE (keysym 6 #xf6)) +(define-keysym #\CYRILLIC_capital_letter_VE (keysym 6 #xf7)) +(define-keysym #\CYRILLIC_capital_letter_SOFT_SIGN (keysym 6 #xf8)) +(define-keysym #\CYRILLIC_capital_letter_YERU (keysym 6 #xf9)) +(define-keysym #\CYRILLIC_capital_letter_ZE (keysym 6 #xfa)) +(define-keysym #\CYRILLIC_capital_letter_SHA (keysym 6 #xfb)) +(define-keysym #\CYRILLIC_capital_letter_E (keysym 6 #xfc)) +(define-keysym #\CYRILLIC_capital_letter_SHCHA (keysym 6 #xfd)) +(define-keysym #\CYRILLIC_capital_letter_CHE (keysym 6 #xfe)) +(define-keysym #\CYRILLIC_capital_letter_HARD_SIGN (keysym 6 #xff)) + (progn ;; Semi-standard characters (define-keysym #\rubout (keysym 255 255)) ; :tty (define-keysym #\tab (keysym 255 009)) ; :tty diff --git a/translate.lisp b/translate.lisp --- a/translate.lisp +++ b/translate.lisp @@ -290,11 +290,11 @@ ;; entry for keysym-index zero set to the uppercase keysym ;; (this is normally where the lowercase keysym goes), and the ;; entry for keysym-index one is zero. - (cond ((zerop keysym-index) ; Lowercase alphabetic keysyms - (keysym-downcase keysym)) - ((and (zerop keysym) (plusp keysym-index)) ; Get the uppercase keysym - (aref mapping keycode 0)) - (t keysym)))) + (cond ((zerop keysym-index) ; Lowercase alphabetic keysyms + (keysym-downcase keysym)) + ((and (zerop keysym) (plusp keysym-index)) ; Get the uppercase keysym + (aref mapping keycode 0)) + (t keysym))))
(defun keysym->character (display keysym &optional (state 0)) ;; Find the character associated with a keysym. diff --git a/xkeyboard.lisp b/xkeyboard.lisp --- /dev/null +++ b/xkeyboard.lisp @@ -0,0 +1,20 @@ +(in-package :xlib) + +(define-extension "XKEYBOARD" + :events () + :errors (xf86-xkeyboard-keyboard) + :auto-init-fn xkb-enable) + +(define-condition xf86-xkeyboard-keyboard (request-error) ()) + +(define-error xf86-xkeyboard-keyboard decode-core-error) + +(defconstant +xkb-enable+ 0) + +(defun xkb-enable (display) + (declare (type display display)) + (with-buffer-request-and-reply (display (extension-opcode display "XKEYBOARD") nil :sizes (8 16)) + ((data +xkb-enable+) + (card16 1) + (card16 0)) + (values (boolean-get 8))))