xorg modifiers fix mask.

This commit is contained in:
Miroslav Šedivý 2021-01-12 23:35:11 +01:00
parent a0d8f1b880
commit 8a9dceafec
4 changed files with 10 additions and 8 deletions

View File

@ -68,8 +68,10 @@ func (manager *DesktopManagerCtx) SetKeyboardModifiers(mod types.KeyboardModifie
}
func (manager *DesktopManagerCtx) GetKeyboardModifiers() types.KeyboardModifiers {
NumLock := xorg.GetKeyboardModifier(xorg.KBD_NUM_LOCK)
CapsLock := xorg.GetKeyboardModifier(xorg.KBD_CAPS_LOCK)
modifiers := xorg.GetKeyboardModifiers()
NumLock := (modifiers & xorg.KBD_NUM_LOCK) != 0
CapsLock := (modifiers & xorg.KBD_CAPS_LOCK) != 0
return types.KeyboardModifiers{
NumLock: &NumLock,

View File

@ -132,11 +132,11 @@ void XSetKeyboardModifier(int mod, int on) {
XFlush(display);
}
int XGetKeyboardModifier(int mod) {
char XGetKeyboardModifiers() {
XkbStateRec xkbState;
Display *display = getXDisplay();
XkbGetState(display, XkbUseCoreKbd, &xkbState);
return xkbState.locked_mods & mod;
return xkbState.locked_mods;
}
XFixesCursorImage *XGetCursorImage(void) {

View File

@ -17,7 +17,7 @@ import (
"demodesk/neko/internal/types"
)
type KbdModifiers int
type KbdModifiers uint8
const (
KBD_CAPS_LOCK KbdModifiers = 2
@ -230,11 +230,11 @@ func SetKeyboardModifier(mod KbdModifiers, active bool) {
C.XSetKeyboardModifier(C.int(mod), num)
}
func GetKeyboardModifier(mod KbdModifiers) bool {
func GetKeyboardModifiers() KbdModifiers {
mu.Lock()
defer mu.Unlock()
return C.XGetKeyboardModifier(C.int(mod)) == C.int(1)
return KbdModifiers(C.XGetKeyboardModifiers())
}
func GetCursorImage() *types.CursorImage {

View File

@ -27,5 +27,5 @@ short XGetScreenRate();
void SetKeyboardLayout(char *layout);
void XSetKeyboardModifier(int mod, int on);
int XGetKeyboardModifier(int mod);
char XGetKeyboardModifiers();
XFixesCursorImage *XGetCursorImage(void);