summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rio/rio.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-01-09 16:32:53 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-01-09 16:32:53 +0100
commit681bcfa96897805c8b13c1ad29aa26841d839347 (patch)
tree3a0f82a50d873b175f8ebd3225e1a091849e57f1 /sys/src/cmd/rio/rio.c
parent1c69f9c023e64225ffca05f955077012880accb4 (diff)
rio: fix window resize and attach race
if a window gets hidden/unhidden/resized too fast, the client might have no chance attaching to that image using winname. so we move the window offscreen instead and delay the freeimage() by doing it in the deletethread().
Diffstat (limited to 'sys/src/cmd/rio/rio.c')
-rw-r--r--sys/src/cmd/rio/rio.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c
index 8dbbf47be..36aec2d64 100644
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -205,7 +205,7 @@ threadmain(int argc, char *argv[])
exitchan = chancreate(sizeof(int), 0);
winclosechan = chancreate(sizeof(Window*), 0);
- deletechan = chancreate(sizeof(char*), 0);
+ deletechan = chancreate(sizeof(Wdelmesg), 0);
timerinit();
threadcreate(keyboardthread, nil, STACK);
@@ -422,30 +422,28 @@ winclosethread(void*)
void
deletethread(void*)
{
- char *s;
- Image *i;
+ Wdelmesg m;
threadsetname("deletethread");
for(;;){
- s = recvp(deletechan);
- i = namedimage(display, s);
- if(i != nil){
+ recv(deletechan, &m);
+ freeimage(m.i);
+ m.i = namedimage(display, m.s);
+ if(m.i != nil){
/* move it off-screen to hide it, since client is slow in letting it go */
- originwindow(i, i->r.min, view->r.max);
+ originwindow(m.i, m.i->r.min, view->r.max);
}
- freeimage(i);
- free(s);
+ freeimage(m.i);
+ free(m.s);
}
}
void
deletetimeoutproc(void *v)
{
- char *s;
-
- s = v;
sleep(750); /* remove window from screen after 3/4 of a second */
- sendp(deletechan, s);
+ send(deletechan, v);
+ free(v);
}
/*