]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/rio/rio.c
rio: get rid of window delete thread, fix mysterious disappearing windows
[plan9front.git] / sys / src / cmd / rio / rio.c
index c715f22ca1e15a4775b804b1b507b53e9223220f..272fa5e716295cffd8131d9816c93005ee1ef08e 100644 (file)
@@ -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);
 
@@ -121,7 +120,6 @@ void
 threadmain(int argc, char *argv[])
 {
        char *initstr, *kbdin, *s;
-       static void *arg[1];
        char buf[256];
        Image *i;
        Rectangle r;
@@ -191,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;
@@ -212,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)
@@ -386,7 +382,7 @@ whichrect(Rectangle r, Point p, int which)
        case 7: /* bottom edge */
                r = Rect(r.min.x, r.min.y, r.max.x, p.y+1);
                break;
-       case 3:         /* left edge */
+       case 3: /* left edge */
                r = Rect(p.x, r.min.y, r.max.x, r.max.y);
                break;
        }
@@ -430,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.
@@ -840,9 +805,9 @@ Point
 onscreen(Point p)
 {
        p.x = max(screen->clipr.min.x, p.x);
-       p.x = min(screen->clipr.max.x, p.x);
+       p.x = min(screen->clipr.max.x-1, p.x);
        p.y = max(screen->clipr.min.y, p.y);
-       p.y = min(screen->clipr.max.y, p.y);
+       p.y = min(screen->clipr.max.y-1, p.y);
        return p;
 }
 
@@ -964,7 +929,7 @@ drag(Window *w)
        p = mouse->xy;
        riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil);
        menuing = FALSE;
-       if(mouse->buttons!=0 || !goodrect(r) || eqrect(r, screen->r)){
+       if(mouse->buttons!=0 || !goodrect(r) || eqrect(r, w->screenr)){
                flushimage(display, 1);
                while(mouse->buttons)
                        readmouse(mousectl);
@@ -978,27 +943,27 @@ bandsize(Window *w)
 {
        Rectangle r, or;
        Point p, startp;
-       int which, but;
+       int which, owhich, but;
 
-       p = mouse->xy;
+       owhich = -1;
+       or = w->screenr;
        but = mouse->buttons;
-       which = whichcorner(w->screenr, p);
-       riosetcursor(corners[which]);
-       r = whichrect(w->screenr, p, which);
-       drawborder(r, 1);
-       or = r;
-       startp = p;
-       
-       while(mouse->buttons==but){
+       startp = onscreen(mouse->xy);
+       drawborder(or, 1);
+       while(mouse->buttons == but) {
                p = onscreen(mouse->xy);
-               r = whichrect(w->screenr, p, which);
+               which = whichcorner(or, p);
+               if(which != owhich && which != 4 && (owhich|~which) & 1){
+                       owhich = which;
+                       riosetcursor(corners[which]);
+               }
+               r = whichrect(or, p, owhich);
                if(!eqrect(r, or) && goodrect(r)){
-                       drawborder(r, 1);
                        or = r;
+                       drawborder(r, 1);
                }
                readmouse(mousectl);
        }
-       p = mouse->xy;
        drawborder(or, 0);
        if(mouse->buttons!=0 || !goodrect(or) || eqrect(or, w->screenr)
        || abs(p.x-startp.x)+abs(p.y-startp.y) <= 1){