shithub: Nail

Download patch

ref: 0cd0d013de0f13501b5247c70a8619bfb57c97f7
parent: 893c8afdd86aa3c4840f996bfe8dbb25587bc0ea
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Nov 4 12:54:24 EST 2020

only return events once

--- a/comp.c
+++ b/comp.c
@@ -107,7 +107,7 @@
 			else if(matchmesg(&mbox, ev.text))
 				mesgopen(ev.text, nil);
 			else if(!(ev.flags & 0x2))
-				winsendevent(&mbox, &ev);
+				winreturn(&mbox, &ev);
 			free(a);
 			break;
 		case 'x':
@@ -118,7 +118,7 @@
 				if(strcmp(p->name, f[0]) == 0)
 					p->fn(c, &f[1], nf - 1);
 			if(p->name == nil && !(ev.flags & 0x2))
-				winsendevent(&mbox, &ev);
+				winreturn(&mbox, &ev);
 			break;
 		break;
 		}
--- a/mail.h
+++ b/mail.h
@@ -156,7 +156,7 @@
 void	winclose(Win*);
 void	wintagwrite(Win*, char*);
 int	winevent(Win*, Event*);
-void	winsendevent(Win*, Event*);
+void	winreturn(Win*, Event*);
 int	wineval(Win*, char*, ...);
 int	winread(Win*, int, int, char*, int);
 char	*matchaddr(Win*, Event*);
--- a/mbox.c
+++ b/mbox.c
@@ -701,7 +701,7 @@
 		else if(matchmesg(&mbox, ev->text))
 			mesgopen(ev->text, nil);
 		else
-			winsendevent(&mbox, ev);
+			winreturn(&mbox, ev);
 		free(a);
 		break;
 	case 'x':
@@ -712,7 +712,7 @@
 			if(strcmp(p->name, f[0]) == 0 && p->fn != nil)
 				p->fn(&f[1], nf - 1);
 		if(p->fn == nil)
-			winsendevent(&mbox, ev);
+			winreturn(&mbox, ev);
 		break;
 	break;
 	}
--- a/mesg.c
+++ b/mesg.c
@@ -364,7 +364,7 @@
 			else if(matchmesg(m, ev.text))
 				mesgopen(ev.text, nil);
 			else
-				winsendevent(m, &ev);
+				winreturn(m, &ev);
 			free(a);
 			break;
 		case 'x':
@@ -378,7 +378,7 @@
 				}
 			}
 			if(p->fn == nil)
-				winsendevent(m, &ev);
+				winreturn(m, &ev);
 			break;
 		}
 	}
--- a/win.c
+++ b/win.c
@@ -6,6 +6,13 @@
 
 #include "mail.h"
 
+enum {
+	AFbuiltin	= 1<<0,
+	AFexpand	= 1<<1,
+	AFfilename	= 1<<2,
+	AFargbtn	= 1<<3,
+};
+
 static int
 procrd(Biobufhdr *f, void *buf, long len)
 {
@@ -73,8 +80,10 @@
 }
 
 void
-winsendevent(Win *w, Event *e)
+winreturn(Win *w, Event *e)
 {
+	if(e->flags & (AFexpand|AFargbtn))
+		return;
 	fprint(w->revent, "%c%c%d %d\n", e->action, e->type, e->q0, e->q1);
 }