From e6ca8acba98c414a93866583f17f1f6c7216f555 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Thu, 12 Nov 2015 15:42:00 +0100 Subject: [PATCH] Possible fix for issue #265. Check mask when accepting textbox input. --- source/keyb.c | 2 +- source/textbox.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/keyb.c b/source/keyb.c index 4d8b4166..4b5ae350 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -142,7 +142,7 @@ int abe_test_action ( KeyBindingAction action, unsigned int mask, KeySym key ) if ( kb->keysym == key ) { // Bits 13 and 14 of the modifiers together are the group number, and // should be ignored when looking up key bindings - if ( ( mask & ~( NumlockMask | ( 1 << 13 ) | ( 1 << 14 ) ) ) == kb->modmask ) { + if ( ( mask & ~( LockMask | NumlockMask | ( 1 << 13 ) | ( 1 << 14 ) ) ) == kb->modmask ) { return TRUE; } } diff --git a/source/textbox.c b/source/textbox.c index 0fb9002b..1241b73f 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -42,6 +42,10 @@ #define SIDE_MARGIN 1 +// Use this so we can ignore numlock mask. +// TODO: maybe use something smarter here.. +extern unsigned int NumlockMask; + /** * Font + font color cache. * Avoid re-loading font on every change on every textbox. @@ -568,7 +572,9 @@ int textbox_keypress ( textbox *tb, XIC xic, XEvent *ev ) else if ( abe_test_action ( ACCEPT_ENTRY, ev->xkey.state, key ) ) { return -1; } - else if ( !iscntrl ( *pad ) ) { + // 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 ) ) ) { textbox_insert ( tb, tb->cursor, pad ); textbox_cursor_inc ( tb ); return 1;