Allow Caps Lock state from X11 to override default

This commit is contained in:
Aaron Culliney 2014-03-30 13:20:56 -07:00
parent 1d95df15c6
commit afcc95c2f4

View File

@ -364,7 +364,14 @@ static int keysym_to_scancode(void) {
case XK_Control_R:
rc = SCODE_R_CTRL; break;
case XK_Caps_Lock:
rc = SCODE_CAPS; break;
{
// NOTE : emulator initially sets state based on a user preference. But if the user actually taps the Caps Lock
// key, then sync to system state.
unsigned int caps_state = 0;
XkbGetIndicatorState(display, XkbUseCoreKbd, &caps_state);
caps_lock = (caps_state & 0x01);
rc = -1; break;
}
case XK_BackSpace:
rc = SCODE_BS; break;
case XK_Insert:
@ -556,12 +563,6 @@ void video_sync(int block) {
// also process other input events
post_image();
// sync to the capslock state (which could be modified outside this app)
unsigned int caps_state = 0;
XkbGetIndicatorState(display, XkbUseCoreKbd, &caps_state);
// caps_lock = (caps_state & 0x01); -- NOTE: synching to caps_lock in X11 leads to a broken work flow if switching
// between a terminal app and the emulator, so disable this
bool keyevent = true;
do {
#ifdef HAVE_X11_SHM