shithub: evdump

Download patch

ref: 704fd75a2713ba68da7b929b87012a5db21c883e
parent: e6ab6580d5ee2874ac33ca763bb6e0ae53dc35c5
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Nov 21 11:53:01 EST 2021

reset kbmap when not current window

--- a/evdump.c
+++ b/evdump.c
@@ -20,7 +20,7 @@
 static K k[10*128];
 static int nk;
 static int kbd;
-static Biobuf *kbmap;
+static Biobuf *kbmap, *wctl;
 
 static char *
 k2s(Rune r)
@@ -132,6 +132,33 @@
 }
 
 static void
+wctlproc(void *)
+{
+	char s[256], *t[8];
+	int wctl, n;
+
+	if((wctl = open("/dev/wctl", OREAD)) < 0)
+		sysfatal("%r");
+	for(;;){
+		if((n = read(wctl, s, sizeof(s)-1)) <= 0)
+			break;
+		s[n] = 0;
+		if(tokenize(s, t, nelem(t)) < 6)
+			continue;
+
+		if(strcmp(t[4], "current") == 0)
+			kmset();
+		else if(strcmp(t[4], "notcurrent") == 0)
+			kmreset();
+
+		print("wctl %s %s\n", t[4], t[5]);
+	}
+	close(wctl);
+
+	threadexits(nil);
+}
+
+static void
 kbproc(void *)
 {
 	char *s, buf[128], buf2[128];
@@ -243,6 +270,7 @@
 	a[Cresize].c = mctl->resizec;
 
 	proccreate(kbproc, nil, mainstacksize);
+	proccreate(wctlproc, nil, mainstacksize);
 
 	for (;;) {
 		draw(screen, screen->r, display->black, nil, ZP);