ref: dd78daef41e76d4ec915afc6b468800510c077d9
parent: 1f5a91b06083d47de0a85f432e1c4213c0a12095
author: Jacob Moody <moody@posixcafe.org>
date: Wed Oct 13 13:50:27 EDT 2021
gui-wl: use event time in repeatstate The previous method of using the rune would cause false positives in repeatproc when the user would press the same key twice within the repeatstate.delay timeframe. So instead we use event time which should be unique for each key press.
--- a/gui-wl/wl-cb.c
+++ b/gui-wl/wl-cb.c
@@ -116,6 +116,7 @@
Rendez z;
QLock lk;
int active;
+ long keytime;
int32_t key;
int32_t rate;
int32_t delay;
@@ -131,18 +132,18 @@
repeatproc(void*)
{
int ms;
- int32_t key;
+ long keytime;
for(;;){
ksleep(&repeatstate.z, isactive, 0);
qlock(&repeatstate.lk);
- key = repeatstate.key;
+ keytime = repeatstate.keytime;
qunlock(&repeatstate.lk);
osmsleep(repeatstate.delay);
repeat:
qlock(&repeatstate.lk);
- if(repeatstate.active == 0 || key != repeatstate.key){
+ if(repeatstate.active == 0 || keytime != repeatstate.keytime){
qunlock(&repeatstate.lk);
continue;
}
@@ -210,6 +211,7 @@
kbdkey(utf32, state);
qlock(&repeatstate.lk);
repeatstate.active = state;
+ repeatstate.keytime = time;
repeatstate.key = utf32;
qunlock(&repeatstate.lk);
wakeup(&repeatstate.z);