From c51e4e76d23472e303c179b44246fb80f6d93372 Mon Sep 17 00:00:00 2001 From: malc Date: Fri, 14 Dec 2012 19:53:25 +0400 Subject: [PATCH] Tweak keyboard processing Should work with NEO layout (no idea if it really does work all that well though). Thanks to Andreas Leha for heads up and hints on how to reproduce the problem. --- main.ml | 6 +++++- wsi.ml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/main.ml b/main.ml index 12725e4..3f5a039 100644 --- a/main.ml +++ b/main.ml @@ -3071,7 +3071,11 @@ let textentrykeyboard | 0xff9f | 0xffff -> () (* delete *) - | _ when key != 0 && key land 0xff00 != 0xff00 -> + | _ when key != 0 + && key land 0xff00 != 0xff00 (* keyboard *) + && key land 0xfe00 != 0xfe00 (* xkb *) + && key land 0xfd00 != 0xfd00 (* 3270 *) + -> begin match onkey text key with | TEdone text -> ondone text; diff --git a/wsi.ml b/wsi.ml index d8d1e8d..32f4c34 100644 --- a/wsi.ml +++ b/wsi.ml @@ -62,6 +62,7 @@ type state = ; mutable h : int ; mutable fs : fs ; mutable curcurs : cursor + ; mutable capslmask : int } and fs = | NoFs @@ -88,6 +89,7 @@ let state = ; fs = NoFs ; stringatom = 31 ; curcurs = CURSOR_INHERIT + ; capslmask = 0 } ;; @@ -178,6 +180,43 @@ let updkmap sock resp = loop 0; ;; +let updmodmap sock resp = + let n = r8 resp 1 in + let len = r16 resp 4 in + let data = + if len > 0 + then readstr sock (len*4) + else "" + in + let modmap = Array.make_matrix 8 n 0xffffff in + let rec loop l = if l = 8 then () else + let p = l*n in + let rec loop1 m = if m = n then () else + let p = p+m in + let code = r8 data p in + modmap.(l).(m) <- code; + if l = 1 + then ( + let ki = code - state.mink in + if ki >= 0 + then + let a = state.keymap.(ki) in + let rec capsloop i = if i = Array.length a || i > 3 then () else + let s = a.(i) in + if s = 0xffe5 + then state.capslmask <- 2 + else capsloop (i+1) + in + capsloop 0; + ); + loop1 (m+1) + in + loop1 0; + loop (l+1) + in + loop 0; +;; + let sendwithrep sock s f = Queue.push f state.fifo; sendstr1 s 0 (String.length s) sock; @@ -333,8 +372,13 @@ let sendeventreq propagate destwid mask data = s; ;; +let getmodifiermappingreq () = + let s = "\119u\001\000" in + s; +;; + let getkeysym code mask = - let index = (mask land 1) lxor ((mask land 2) lsr 1) in + let index = (mask land 1) lxor ((mask land state.capslmask) lsr 1) in let index = index lor ((mask land 0x80) lsr 5) in let keysym = state.keymap.(code-state.mink).(index) in if index = 1 && keysym = 0 @@ -431,6 +475,10 @@ let readresp sock = state.keymap <- [||]; let s = getkeymapreq state.mink (state.maxk-state.mink-1) in sendwithrep sock s (updkmap sock); + state.capslmask <- 0; + let s = getmodifiermappingreq () in + sendwithrep sock s (updmodmap sock); + | 33 -> (* clientmessage *) let atom = r32 resp 8 in @@ -638,6 +686,9 @@ let setup sock screennum w h = let s = getkeymapreq state.mink (state.maxk-state.mink) in sendwithrep sock s (updkmap sock); + let s = getmodifiermappingreq () in + sendwithrep sock s (updmodmap sock); + let s = openfontreq (wid+1) "cursor" in sendstr s sock; -- 2.11.4.GIT