rio: get rid of window delete thread, fix mysterious disappearing windows
because a client might not handle resize, rio would try to move ther window offsceen after 750 ms. however, it does this by window name, which could have been reassigned by another concurrent rio, causing the wrong window to disappear. now we always move the window offscreen before freeimage(). this way we are sure to still have the right reference to the original window.
This commit is contained in:
parent
96b1debbf8
commit
03e60450c2
3 changed files with 11 additions and 57 deletions
|
@ -341,7 +341,6 @@ Rune* snarf;
|
|||
int scrolling;
|
||||
int maxtab;
|
||||
Channel* winclosechan;
|
||||
Channel* deletechan;
|
||||
char *startdir;
|
||||
int sweeping;
|
||||
int wctlfd;
|
||||
|
|
|
@ -39,7 +39,6 @@ int threadrforkflag = 0; /* should be RFENVG but that hides rio from plumber */
|
|||
void mousethread(void*);
|
||||
void keyboardthread(void*);
|
||||
void winclosethread(void*);
|
||||
void deletethread(void*);
|
||||
void initcmd(void*);
|
||||
Channel* initkbd(void);
|
||||
|
||||
|
@ -190,7 +189,6 @@ threadmain(int argc, char *argv[])
|
|||
|
||||
exitchan = chancreate(sizeof(int), 0);
|
||||
winclosechan = chancreate(sizeof(Window*), 0);
|
||||
deletechan = chancreate(sizeof(char*), 0);
|
||||
|
||||
view = screen;
|
||||
viewr = view->r;
|
||||
|
@ -211,7 +209,6 @@ threadmain(int argc, char *argv[])
|
|||
threadcreate(keyboardthread, nil, STACK);
|
||||
threadcreate(mousethread, nil, STACK);
|
||||
threadcreate(winclosethread, nil, STACK);
|
||||
threadcreate(deletethread, nil, STACK);
|
||||
filsys = filsysinit(xfidinit());
|
||||
|
||||
if(filsys == nil)
|
||||
|
@ -429,37 +426,6 @@ winclosethread(void*)
|
|||
}
|
||||
}
|
||||
|
||||
/* thread to make Deleted windows that the client still holds disappear offscreen after an interval */
|
||||
void
|
||||
deletethread(void*)
|
||||
{
|
||||
char *s;
|
||||
Image *i;
|
||||
|
||||
threadsetname("deletethread");
|
||||
for(;;){
|
||||
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(i, i->r.min, view->r.max);
|
||||
freeimage(i);
|
||||
flushimage(display, 1);
|
||||
}
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
deletetimeoutproc(void *v)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = v;
|
||||
sleep(750); /* remove window from screen after 3/4 of a second */
|
||||
sendp(deletechan, s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Button 6 - keyboard toggle - has been pressed.
|
||||
* Send event to keyboard, wait for button up, send that.
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
#define MOVEIT if(0)
|
||||
|
||||
enum
|
||||
{
|
||||
HiWater = 640000, /* max size of history */
|
||||
|
@ -91,7 +89,7 @@ wresize(Window *w, Image *i)
|
|||
{
|
||||
Rectangle r;
|
||||
|
||||
freeimage(w->i);
|
||||
wclosewin(w);
|
||||
w->i = i;
|
||||
w->mc.image = i;
|
||||
r = insetrect(i->r, Selborder+1);
|
||||
|
@ -1099,7 +1097,6 @@ wsendctlmesg(Window *w, int type, Rectangle r, void *p)
|
|||
int
|
||||
wctlmesg(Window *w, int m, Rectangle r, void *p)
|
||||
{
|
||||
char *oldname;
|
||||
Image *i = p;
|
||||
|
||||
switch(m){
|
||||
|
@ -1115,10 +1112,8 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
|
|||
freeimage(i);
|
||||
break;
|
||||
}
|
||||
oldname = estrdup(w->name);
|
||||
w->screenr = r;
|
||||
wresize(w, i);
|
||||
proccreate(deletetimeoutproc, oldname, 4096);
|
||||
if(Dx(r)<=0){ /* window got hidden, if we had the input, drop it */
|
||||
if(w==input)
|
||||
input = nil;
|
||||
|
@ -1205,14 +1200,13 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
|
|||
wclunk(w);
|
||||
if(w->notefd >= 0)
|
||||
write(w->notefd, "hangup", 6);
|
||||
if(w->i!=nil){
|
||||
proccreate(deletetimeoutproc, estrdup(w->name), 4096);
|
||||
wclosewin(w);
|
||||
}
|
||||
wclosewin(w);
|
||||
flushimage(display, 1);
|
||||
break;
|
||||
case Exited:
|
||||
wclosewin(w);
|
||||
frclear(w, TRUE);
|
||||
flushimage(display, 1);
|
||||
if(w->notefd >= 0)
|
||||
close(w->notefd);
|
||||
chanfree(w->mc.c);
|
||||
|
@ -1397,18 +1391,13 @@ wclunk(Window *w)
|
|||
void
|
||||
wclosewin(Window *w)
|
||||
{
|
||||
Image *i;
|
||||
|
||||
assert(w->deleted==TRUE);
|
||||
|
||||
i = w->i;
|
||||
if(i){
|
||||
w->i = nil;
|
||||
/* 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);
|
||||
flushimage(display, 1);
|
||||
}
|
||||
Image *i = w->i;
|
||||
if(i == nil)
|
||||
return;
|
||||
w->i = nil;
|
||||
/* move it off-screen to hide it, in case client is slow in letting it go */
|
||||
originwindow(i, i->r.min, view->r.max);
|
||||
freeimage(i);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue