Skip to content

Commit

Permalink
Add support for more event key modifiers for x11 (capslock, numlock &…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
misak113 committed Jan 3, 2021
1 parent 1779ad9 commit 73e0679
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions shiny/driver/internal/x11key/x11key.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func isKeypad(keysym uint32) bool {
}

// KeyModifiers returns mobile/event/key modifiers type from xproto mod state
// ModCapsLock, ModNumLock & ModLevel3Shift are currently implemented using default general modifier bits
// it should be method of KeysymTable with current keyboard mapping
func KeyModifiers(state uint16) (m key.Modifiers) {
if state&ShiftMask != 0 {
m |= key.ModShift
Expand All @@ -102,6 +104,18 @@ func KeyModifiers(state uint16) (m key.Modifiers) {
if state&Mod4Mask != 0 {
m |= key.ModMeta
}
if state&LockMask != 0 {
m |= key.ModCapsLock
}
if state&Mod2Mask != 0 { // TODO should goes from t.NumLockMod instead because it's dynamic
m |= key.ModNumLock
}
if state&Mod5Mask != 0 { // TODO should goes from t.ISOLevel3ShiftMod instead because it's dynamic
m |= key.ModLevel3Shift
}
if state&Mod5Mask != 0 { // TODO should goes from t.ModeSwitchMod instead because it's dynamic
m |= key.ModModeSwitch
}
return m
}

Expand Down

0 comments on commit 73e0679

Please sign in to comment.