~moody/drawterm

d3f8a34644eac932c33b18f94076a2950a8a2f93 — Jacob Moody a month ago 6c58f8e
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.
1 files changed, 5 insertions(+), 3 deletions(-)

M gui-wl/wl-cb.c
M gui-wl/wl-cb.c => gui-wl/wl-cb.c +5 -3
@@ 116,6 116,7 @@ static struct {
	Rendez z;
	QLock lk;
	int active;
	long keytime;
	int32_t key;
	int32_t rate;
	int32_t delay;


@@ 131,18 132,18 @@ void
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 @@ keyboard_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t
	kbdkey(utf32, state);
	qlock(&repeatstate.lk);
	repeatstate.active = state;
	repeatstate.keytime = time;
	repeatstate.key = utf32;
	qunlock(&repeatstate.lk);
	wakeup(&repeatstate.z);