ref: 5f54eaddba800ec81c65ab17fa17ddd91cc66470
parent: 1cfdab50fa986d686d45a765e629d128a0f40c44
parent: b4759c21867e844d3007160466e33bfc801671bb
author: cinap_lenrek <[email protected]>
date: Thu Jan 10 18:12:37 EST 2013
merge
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -38,7 +38,6 @@
typedef struct Ref Ref;
typedef struct Timer Timer;
typedef struct Wctlmesg Wctlmesg;
-typedef struct Wdelmesg Wdelmesg;
typedef struct Window Window;
typedef struct Xfid Xfid;
@@ -79,12 +78,6 @@
int type;
Rectangle r;
void *p;
-};
-
-struct Wdelmesg
-{
- char *s;
- Image *i;
};
struct Conswritemesg
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -205,7 +205,7 @@
exitchan = chancreate(sizeof(int), 0);
winclosechan = chancreate(sizeof(Window*), 0);
- deletechan = chancreate(sizeof(Wdelmesg), 0);
+ deletechan = chancreate(sizeof(char*), 0);
timerinit();
threadcreate(keyboardthread, nil, STACK);
@@ -422,19 +422,19 @@
void
deletethread(void*)
{
- Wdelmesg m;
+ char *s;
+ Image *i;
threadsetname("deletethread");
for(;;){
- recv(deletechan, &m);
- freeimage(m.i);
- m.i = namedimage(display, m.s);
- if(m.i != nil){
+ s = recvp(deletechan);
+ i = namedimage(display, s);
+ if(i != nil){
/* move it off-screen to hide it, since client is slow in letting it go */
- originwindow(m.i, m.i->r.min, view->r.max);
+ originwindow(i, i->r.min, view->r.max);
}
- freeimage(m.i);
- free(m.s);
+ freeimage(i);
+ free(s);
}
}
@@ -441,9 +441,11 @@
void
deletetimeoutproc(void *v)
{
+ char *s;
+
+ s = v;
sleep(750); /* remove window from screen after 3/4 of a second */
- send(deletechan, v);
- free(v);
+ sendp(deletechan, s);
}
/*
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -88,35 +88,13 @@
wresize(Window *w, Image *i, int move)
{
Rectangle r, or;
- Wdelmesg *m;
or = w->i->r;
if(move || (Dx(or)==Dx(i->r) && Dy(or)==Dy(i->r)))
draw(i, i->r, w->i, nil, w->i->r.min);
-
- m = emalloc(sizeof(Wdelmesg));
- m->s = estrdup(w->name);
- m->i = w->i;
-
+ freeimage(w->i);
w->i = i;
w->mc.image = i;
-
- if(w->mouseopen){
- /*
- * do not freeimage() here because the client might be in
- * the process of attaching that image using winname.
- * move the old window offscreen unless its completely
- * hidden by the new window and let deletetimeoutproc
- * free the image after some delay.
- */
- if(!rectinrect(or, w->screenr))
- originwindow(m->i, or.min, view->r.max);
- } else {
- freeimage(m->i);
- m->i = nil;
- }
- proccreate(deletetimeoutproc, m, 4096);
-
r = insetrect(i->r, Selborder+1);
w->scrollr = r;
w->scrollr.max.x = r.min.x+Scrollwid;
@@ -1092,6 +1070,7 @@
int
wctlmesg(Window *w, int m, Rectangle r, void *p)
{
+ char buf[64];
Image *i = p;
switch(m){
@@ -1109,7 +1088,9 @@
break;
}
w->screenr = r;
+ strcpy(buf, w->name);
wresize(w, i, m==Moved);
+ proccreate(deletetimeoutproc, estrdup(buf), 4096);
flushimage(display, 1);
if(Dx(r)<=0){ /* window got hidden, if we had the input, drop it */
if(w==input)
@@ -1196,6 +1177,7 @@
break;
wclunk(w);
write(w->notefd, "hangup", 6);
+ proccreate(deletetimeoutproc, estrdup(w->name), 4096);
wclosewin(w);
break;
case Exited:
@@ -1379,13 +1361,14 @@
void
wclosewin(Window *w)
{
- Wdelmesg m;
+ Image *i;
- m.i = w->i;
- if(m.i){
+ i = w->i;
+ if(i){
w->i = nil;
- m.s = estrdup(w->name);
- send(deletechan, &m);
+ /* move it off-screen to hide it, in case client is slow in letting it go */
+ MOVEIT originwindow(i, i->r.min, view->r.max);
+ freeimage(i);
}
}