mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
change lock modifiers
This commit is contained in:
parent
9ce26cffc5
commit
6f4bbeb452
@ -175,33 +175,21 @@ void SetKeyboard(char *layout) {
|
|||||||
|
|
||||||
void SetKeyboardModifiers(int num_lock, int caps_lock, int scroll_lock) {
|
void SetKeyboardModifiers(int num_lock, int caps_lock, int scroll_lock) {
|
||||||
Display *display = getXDisplay();
|
Display *display = getXDisplay();
|
||||||
Bool state;
|
|
||||||
Atom atom;
|
|
||||||
|
|
||||||
// set num lock
|
if (num_lock != -1) {
|
||||||
atom = XInternAtom(display, "Num Lock", 0);
|
XkbLockModifiers(display, XkbUseCoreKbd, 16, num_lock * 16);
|
||||||
XkbGetNamedIndicator(display, atom, NULL, &state, NULL, NULL);
|
|
||||||
//printf("Num Lock is %s\n", state ? "on" : "off");
|
|
||||||
if(num_lock != -1 && state != num_lock) {
|
|
||||||
XKey(XK_Num_Lock, 1);
|
|
||||||
XKey(XK_Num_Lock, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set caps lock
|
if (caps_lock != -1) {
|
||||||
atom = XInternAtom(display, "Caps Lock", 0);
|
XkbLockModifiers(display, XkbUseCoreKbd, 2, caps_lock * 2);
|
||||||
XkbGetNamedIndicator(display, atom, NULL, &state, NULL, NULL);
|
|
||||||
//printf("Caps Lock is %s\n", state ? "on" : "off");
|
|
||||||
if(caps_lock != -1 && state != caps_lock) {
|
|
||||||
XKey(XK_Caps_Lock, 1);
|
|
||||||
XKey(XK_Caps_Lock, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set scroll lock
|
if (scroll_lock != -1) {
|
||||||
atom = XInternAtom(display, "Scroll Lock", 0);
|
XKeyboardControl values;
|
||||||
XkbGetNamedIndicator(display, atom, NULL, &state, NULL, NULL);
|
values.led_mode = scroll_lock ? LedModeOn : LedModeOff;
|
||||||
//printf("Scroll Lock is %s\n", state ? "on" : "off");
|
values.led = 3;
|
||||||
if(scroll_lock != -1 && state != scroll_lock) {
|
XChangeKeyboardControl(display, KBLedMode, &values);
|
||||||
XKey(XK_Scroll_Lock, 1);
|
|
||||||
XKey(XK_Scroll_Lock, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
#include <libclipboard.h>
|
#include <libclipboard.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user