summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rio
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-12-07 16:32:04 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-12-07 16:32:04 +0100
commit03e60450c2acc20866867cc5d3649aaed07d0326 (patch)
tree1dcd2180d524e35c2e30f723a15352e2e913d933 /sys/src/cmd/rio
parent96b1debbf869ac135f3a0f22e8fdc57caaa15129 (diff)
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.
Diffstat (limited to 'sys/src/cmd/rio')
-rw-r--r--sys/src/cmd/rio/dat.h1
-rw-r--r--sys/src/cmd/rio/rio.c34
-rw-r--r--sys/src/cmd/rio/wind.c33
3 files changed, 11 insertions, 57 deletions
diff --git a/sys/src/cmd/rio/dat.h b/sys/src/cmd/rio/dat.h
index 72d2023cb..9698914c4 100644
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -341,7 +341,6 @@ Rune* snarf;
int scrolling;
int maxtab;
Channel* winclosechan;
-Channel* deletechan;
char *startdir;
int sweeping;
int wctlfd;
diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c
index 0615084f5..272fa5e71 100644
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -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.
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index 0cbcfc7a8..004990118 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -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