summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rio/wind.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-10-21 17:00:12 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-10-21 17:00:12 +0200
commitbf13408df23bb1fe92d6aaf81ff45044d3e1d1f7 (patch)
tree636bcc854a3bb1a82655b5fe17cfc5820edb9dc6 /sys/src/cmd/rio/wind.c
parent5374d09d35ee47ae73bc17fa363c270c2c141315 (diff)
rio: various fixes
use notefd in killprocs() insead of postnote() as the process might'v exited. the notefd stays valid even if the particular process it was originaly opend on exited. remove the Window.pid field as its not needed. dup() the notefd for interruptproc as the window might'v gone away and closed the notefd file descriptor, resulting in us writing to the wrong thing. use snprint() instead of sprint() for safety. fix bogus debug fprint(). add missing "visible" flushimage() after Reshaped winctl message got handled. i assumed wsetname()/nameimage() would be enough, it but does a invisible flush so softscreen doesnt get updated immidiately. do not make allocimage() failure in scrtemps() fatal. it wont draw the window properly, but it gives the user a chance to delete some windows to recover.
Diffstat (limited to 'sys/src/cmd/rio/wind.c')
-rw-r--r--sys/src/cmd/rio/wind.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index 259626486..b45a3624d 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -70,7 +70,7 @@ wsetname(Window *w)
int i, n;
char err[ERRMAX];
- n = sprint(w->name, "window.%d.%d", w->id, w->namecount++);
+ n = snprint(w->name, sizeof(w->name)-2, "window.%d.%d", w->id, w->namecount++);
for(i='A'; i<='Z'; i++){
if(nameimage(w->i, w->name, 1) > 0)
return;
@@ -446,6 +446,7 @@ interruptproc(void *v)
notefd = v;
write(*notefd, "interrupt", 9);
+ close(*notefd);
free(notefd);
}
@@ -672,7 +673,7 @@ wkeyctl(Window *w, Rune r)
w->qh = w->nr;
wshow(w, w->qh);
notefd = emalloc(sizeof(int));
- *notefd = w->notefd;
+ *notefd = dup(w->notefd, -1);
proccreate(interruptproc, notefd, 4096);
return;
case Kack: /* ^F: file name completion */
@@ -838,7 +839,7 @@ wplumb(Window *w)
p0--;
while(p1<w->nr && w->r[p1]!=' ' && w->r[p1]!='\t' && w->r[p1]!='\n')
p1++;
- sprint(buf, "click=%d", w->q0-p0);
+ snprint(buf, sizeof(buf), "click=%d", w->q0-p0);
m->attr = plumbunpackattr(buf);
}
if(p1-p0 > messagesize-1024){
@@ -1088,6 +1089,7 @@ wctlmesg(Window *w, int m, Rectangle r, Image *i)
strcpy(buf, w->name);
wresize(w, i, m==Moved);
proccreate(deletetimeoutproc, estrdup(buf), 4096);
+ flushimage(display, 1);
break;
case Refresh:
if(w->deleted || Dx(w->screenr)<=0 || !rectclip(&r, w->i->r) || w->mouseopen)
@@ -1335,20 +1337,23 @@ wclosewin(Window *w)
void
wsetpid(Window *w, int pid, int dolabel)
{
- char buf[128];
- int fd;
-
- w->pid = pid;
- if(dolabel){
- sprint(buf, "rc %d", pid);
- free(w->label);
- w->label = estrdup(buf);
+ char buf[64];
+ int ofd;
+
+ ofd = w->notefd;
+ if(pid <= 0)
+ w->notefd = -1;
+ else {
+ if(dolabel){
+ snprint(buf, sizeof(buf), "rc %d", pid);
+ free(w->label);
+ w->label = estrdup(buf);
+ }
+ snprint(buf, sizeof(buf), "/proc/%d/notepg", pid);
+ w->notefd = open(buf, OWRITE|OCEXEC);
}
- sprint(buf, "/proc/%d/notepg", pid);
- fd = open(buf, OWRITE|OCEXEC);
- if(w->notefd > 0)
- close(w->notefd);
- w->notefd = fd;
+ if(ofd >= 0)
+ close(ofd);
}
void