some subtle input changes

When CapsLock is detected, and we're working with
ASCII input, capitalize it, just as we do with
Shift or Ctrl. Don't consider CapsLock or NumLock
for ncinput_equals_p(). Closes #2555.
This commit is contained in:
nick black 2022-01-12 00:53:17 -05:00
parent b85c1f1dad
commit 7e46e5fbe4
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 17 additions and 17 deletions

View File

@ -1196,7 +1196,8 @@ ncinput_numlock_p(const ncinput* n){
}
// compare two ncinput structs for data equality. NCTYPE_PRESS and
// NCTYPE_UNKNOWN are considered to be equivalent.
// NCTYPE_UNKNOWN are considered to be equivalent. NCKEY_MOD_CAPSLOCK
// and NCKEY_MOD_NUMLOCK are not considered relevant.
static inline bool
ncinput_equal_p(const ncinput* n1, const ncinput* n2){
// don't need to check ->utf8; it's derived from id
@ -1207,7 +1208,8 @@ ncinput_equal_p(const ncinput* n1, const ncinput* n2){
return false;
}
// don't need to check deprecated alt, ctrl, shift
if(n1->modifiers != n2->modifiers){
if((n1->modifiers & ~(NCKEY_MOD_CAPSLOCK | NCKEY_MOD_NUMLOCK))
!= (n2->modifiers & ~(NCKEY_MOD_CAPSLOCK | NCKEY_MOD_NUMLOCK))){
return false;
}
if(n1->evtype != n2->evtype){

View File

@ -487,14 +487,21 @@ mark_pipe_ready(ipipe pipes[static 2]){
static void
load_ncinput(inputctx* ictx, ncinput *tni){
int synth = 0;
if(tni->modifiers & (NCKEY_MOD_CTRL | NCKEY_MOD_SHIFT | NCKEY_MOD_CAPSLOCK)){
// when ctrl/shift are used with an ASCII (0..127) lowercase letter, always
// supply the capitalized form, to maintain compatibility among solutions.
if(tni->id < 0x7f){
if(islower(tni->id)){
tni->id = toupper(tni->id);
}
}
}
if(tni->modifiers == NCKEY_MOD_CTRL){ // exclude all other modifiers
if(ictx->linesigs){
if(isalpha(tni->id)){
if(toupper(tni->id) == 'C'){
synth = SIGINT;
}else if(toupper(tni->id) == 'Z'){
synth = SIGSTOP;
}
if(tni->id == 'C'){
synth = SIGINT;
}else if(tni->id == 'Z'){
synth = SIGSTOP;
}else if(tni->id == '\\'){
synth = SIGQUIT;
}
@ -505,15 +512,6 @@ load_ncinput(inputctx* ictx, ncinput *tni){
send_synth_signal(synth);
return;
}
if(tni->modifiers & (NCKEY_MOD_CTRL | NCKEY_MOD_SHIFT)){
// when ctrl/shift are used with an ASCII (0..127) lowercase letter, always
// supply the capitalized form, to maintain compatibility among solutions.
if(tni->id < 0x7f){
if(islower(tni->id)){
tni->id = toupper(tni->id);
}
}
}
pthread_mutex_lock(&ictx->ilock);
if(ictx->ivalid == ictx->isize){
pthread_mutex_unlock(&ictx->ilock);