Skip to content

Commit 73e0679

Browse files
committed
Add support for more event key modifiers for x11 (capslock, numlock & switch modes
* it's currently using default bits reserved for switch modes & caps/num lock by X11. * However, it can differs depend on keyboard layout. The real bit values are available in KeysymTable. * but this change woul mean change of interface
1 parent 1779ad9 commit 73e0679

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

shiny/driver/internal/x11key/x11key.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ func isKeypad(keysym uint32) bool {
8989
}
9090

9191
// KeyModifiers returns mobile/event/key modifiers type from xproto mod state
92+
// ModCapsLock, ModNumLock & ModLevel3Shift are currently implemented using default general modifier bits
93+
// it should be method of KeysymTable with current keyboard mapping
9294
func KeyModifiers(state uint16) (m key.Modifiers) {
9395
if state&ShiftMask != 0 {
9496
m |= key.ModShift
@@ -102,6 +104,18 @@ func KeyModifiers(state uint16) (m key.Modifiers) {
102104
if state&Mod4Mask != 0 {
103105
m |= key.ModMeta
104106
}
107+
if state&LockMask != 0 {
108+
m |= key.ModCapsLock
109+
}
110+
if state&Mod2Mask != 0 { // TODO should goes from t.NumLockMod instead because it's dynamic
111+
m |= key.ModNumLock
112+
}
113+
if state&Mod5Mask != 0 { // TODO should goes from t.ISOLevel3ShiftMod instead because it's dynamic
114+
m |= key.ModLevel3Shift
115+
}
116+
if state&Mod5Mask != 0 { // TODO should goes from t.ModeSwitchMod instead because it's dynamic
117+
m |= key.ModModeSwitch
118+
}
105119
return m
106120
}
107121

0 commit comments

Comments
 (0)