shiny: handle capslock correctly in x11driver
Turn rune returned by x11key.Lookup to upper case if the capslock bit
is set in the state.
Change-Id: Ie9ad67ce7f80a669cbf34194f563dfb1845efa21
Reviewed-on: https://go-review.googlesource.com/c/exp/+/175083
Reviewed-by: Nigel Tao <nigeltao@golang.org>
diff --git a/shiny/driver/internal/x11key/x11key.go b/shiny/driver/internal/x11key/x11key.go
index d123541..3bad0ed 100644
--- a/shiny/driver/internal/x11key/x11key.go
+++ b/shiny/driver/internal/x11key/x11key.go
@@ -8,6 +8,8 @@
package x11key // import "golang.org/x/exp/shiny/driver/internal/x11key"
import (
+ "unicode"
+
"golang.org/x/mobile/event/key"
)
@@ -49,10 +51,16 @@
// TODO: distinguish the regular '2' key and number-pad '2' key (with
// Num-Lock).
c = asciiKeycodes[unshifted]
+ if state&LockMask != 0 {
+ r = unicode.ToUpper(r)
+ }
} else if nuk := nonUnicodeKeycodes[unshifted]; nuk != key.CodeUnknown {
r, c = -1, nuk
} else if uk, isUnicode := keysymCodePoints[r]; isUnicode {
r = uk
+ if state&LockMask != 0 {
+ r = unicode.ToUpper(r)
+ }
}
return r, c