mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
xorg modifiers fix mask.
This commit is contained in:
parent
a0d8f1b880
commit
8a9dceafec
@ -68,8 +68,10 @@ func (manager *DesktopManagerCtx) SetKeyboardModifiers(mod types.KeyboardModifie
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetKeyboardModifiers() types.KeyboardModifiers {
|
func (manager *DesktopManagerCtx) GetKeyboardModifiers() types.KeyboardModifiers {
|
||||||
NumLock := xorg.GetKeyboardModifier(xorg.KBD_NUM_LOCK)
|
modifiers := xorg.GetKeyboardModifiers()
|
||||||
CapsLock := xorg.GetKeyboardModifier(xorg.KBD_CAPS_LOCK)
|
|
||||||
|
NumLock := (modifiers & xorg.KBD_NUM_LOCK) != 0
|
||||||
|
CapsLock := (modifiers & xorg.KBD_CAPS_LOCK) != 0
|
||||||
|
|
||||||
return types.KeyboardModifiers{
|
return types.KeyboardModifiers{
|
||||||
NumLock: &NumLock,
|
NumLock: &NumLock,
|
||||||
|
@ -132,11 +132,11 @@ void XSetKeyboardModifier(int mod, int on) {
|
|||||||
XFlush(display);
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
int XGetKeyboardModifier(int mod) {
|
char XGetKeyboardModifiers() {
|
||||||
XkbStateRec xkbState;
|
XkbStateRec xkbState;
|
||||||
Display *display = getXDisplay();
|
Display *display = getXDisplay();
|
||||||
XkbGetState(display, XkbUseCoreKbd, &xkbState);
|
XkbGetState(display, XkbUseCoreKbd, &xkbState);
|
||||||
return xkbState.locked_mods & mod;
|
return xkbState.locked_mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFixesCursorImage *XGetCursorImage(void) {
|
XFixesCursorImage *XGetCursorImage(void) {
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type KbdModifiers int
|
type KbdModifiers uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
KBD_CAPS_LOCK KbdModifiers = 2
|
KBD_CAPS_LOCK KbdModifiers = 2
|
||||||
@ -230,11 +230,11 @@ func SetKeyboardModifier(mod KbdModifiers, active bool) {
|
|||||||
C.XSetKeyboardModifier(C.int(mod), num)
|
C.XSetKeyboardModifier(C.int(mod), num)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetKeyboardModifier(mod KbdModifiers) bool {
|
func GetKeyboardModifiers() KbdModifiers {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
|
||||||
return C.XGetKeyboardModifier(C.int(mod)) == C.int(1)
|
return KbdModifiers(C.XGetKeyboardModifiers())
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCursorImage() *types.CursorImage {
|
func GetCursorImage() *types.CursorImage {
|
||||||
|
@ -27,5 +27,5 @@ short XGetScreenRate();
|
|||||||
|
|
||||||
void SetKeyboardLayout(char *layout);
|
void SetKeyboardLayout(char *layout);
|
||||||
void XSetKeyboardModifier(int mod, int on);
|
void XSetKeyboardModifier(int mod, int on);
|
||||||
int XGetKeyboardModifier(int mod);
|
char XGetKeyboardModifiers();
|
||||||
XFixesCursorImage *XGetCursorImage(void);
|
XFixesCursorImage *XGetCursorImage(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user