diff --git a/source/textbox.c b/source/textbox.c index 8aa6b250..6e1679a5 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -45,6 +45,7 @@ // Use this so we can ignore numlock mask. // TODO: maybe use something smarter here.. extern unsigned int NumlockMask; +extern unsigned int ModeSwitchMask; /** * Font + font color cache. @@ -574,7 +575,7 @@ int textbox_keypress ( textbox *tb, XIC xic, XEvent *ev ) } // Filter When alt/ctrl/etc is pressed do not accept the character. // Ignore others (numlock, shift,..). - else if ( !iscntrl ( *pad ) && 0 == ( ev->xkey.state & ~( NumlockMask | ( 1 << 12 ) | ( 1 << 13 ) | ShiftMask | LockMask ) ) ) { + else if ( !iscntrl ( *pad ) && 0 == ( ev->xkey.state & ~( ModeSwitchMask | NumlockMask | ( 1 << 12 ) | ( 1 << 13 ) | ShiftMask | LockMask ) ) ) { textbox_insert ( tb, tb->cursor, pad ); textbox_cursor_inc ( tb ); return 1; diff --git a/source/x11-helper.c b/source/x11-helper.c index a602c9a5..cda8c674 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -58,6 +58,7 @@ Atom netatoms[NUM_NETATOMS]; const char *netatom_names[] = { EWMH_ATOMS ( ATOM_CHAR ) }; // Mask indicating num-lock. unsigned int NumlockMask = 0; +unsigned int ModeSwitchMask = 0; extern Colormap map; @@ -369,11 +370,15 @@ static void x11_figure_out_numlock_mask ( Display *display ) { XModifierKeymap *modmap = XGetModifierMapping ( display ); KeyCode kc = XKeysymToKeycode ( display, XK_Num_Lock ); + KeyCode kc_ms = XKeysymToKeycode ( display, XK_Mode_switch); for ( int i = 0; i < 8; i++ ) { for ( int j = 0; j < ( int ) modmap->max_keypermod; j++ ) { if ( modmap->modifiermap[i * modmap->max_keypermod + j] == kc ) { NumlockMask = ( 1 << i ); } + if ( modmap->modifiermap[i * modmap->max_keypermod + j] == kc_ms ) { + ModeSwitchMask = ( 1 << i ); + } } } XFreeModifiermap ( modmap );