rio: only the current window may change the cursor, fix typo screen->r vs w->screenr in drag()

This commit is contained in:
cinap_lenrek 2016-05-14 18:14:08 +02:00
parent 06a0dc5319
commit 81f867f4fb
3 changed files with 17 additions and 14 deletions

View file

@ -964,7 +964,7 @@ drag(Window *w)
p = mouse->xy; p = mouse->xy;
riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil); riosetcursor(inborder(r, p) ? corners[whichcorner(r, p)] : nil);
menuing = FALSE; 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); flushimage(display, 1);
while(mouse->buttons) while(mouse->buttons)
readmouse(mousectl); readmouse(mousectl);

View file

@ -1099,7 +1099,7 @@ wsendctlmesg(Window *w, int type, Rectangle r, void *p)
int int
wctlmesg(Window *w, int m, Rectangle r, void *p) wctlmesg(Window *w, int m, Rectangle r, void *p)
{ {
char buf[64]; char *oldname;
Image *i = p; Image *i = p;
switch(m){ switch(m){
@ -1115,10 +1115,10 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
freeimage(i); freeimage(i);
break; break;
} }
oldname = estrdup(w->name);
w->screenr = r; w->screenr = r;
strcpy(buf, w->name);
wresize(w, i); wresize(w, i);
proccreate(deletetimeoutproc, estrdup(buf), 4096); proccreate(deletetimeoutproc, oldname, 4096);
if(Dx(r)<=0){ /* window got hidden, if we had the input, drop it */ if(Dx(r)<=0){ /* window got hidden, if we had the input, drop it */
if(w==input) if(w==input)
input = nil; input = nil;
@ -1157,8 +1157,10 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
wsendctlmesg(oi, Repaint, ZR, nil); wsendctlmesg(oi, Repaint, ZR, nil);
} }
wclose(oi); wclose(oi);
} else } else {
input = w; input = w;
wsetcursor(w, FALSE);
}
w->wctlready = 1; w->wctlready = 1;
if(m!=Topped && w==input) if(m!=Topped && w==input)
break; break;
@ -1295,16 +1297,15 @@ wsetcursor(Window *w, int force)
if(menuing || sweeping) if(menuing || sweeping)
return; return;
if(w==nil || w->i==nil || Dx(w->screenr)<=0) if(w==nil || Dx(w->screenr)<=0 || wpointto(mouse->xy)!=w)
p = nil; p = nil;
else if(wpointto(mouse->xy) == w){ else {
p = w->cursorp; p = w->cursorp;
if(p==nil && w->holding) if(p==nil && w->holding)
p = &whitearrow; p = &whitearrow;
}else }
p = nil; if(p && force) /* force cursor reload */
if(force) /* force cursor reload */ lastcursor = nil;
lastcursor = (void*)~0;
riosetcursor(p); riosetcursor(p);
} }
@ -1373,7 +1374,7 @@ wclunk(Window *w)
w->deleted = TRUE; w->deleted = TRUE;
if(w == input){ if(w == input){
input = nil; input = nil;
wsetcursor(w, FALSE); riosetcursor(nil);
} }
if(w == wkeyboard) if(w == wkeyboard)
wkeyboard = nil; wkeyboard = nil;

View file

@ -333,7 +333,8 @@ xfidclose(Xfid *x)
break; break;
case Qcursor: case Qcursor:
w->cursorp = nil; w->cursorp = nil;
wsetcursor(w, FALSE); if(w==input)
wsetcursor(w, FALSE);
break; break;
case Qkbd: case Qkbd:
w->kbdopen = FALSE; w->kbdopen = FALSE;
@ -478,7 +479,8 @@ xfidwrite(Xfid *x)
memmove(w->cursor.clr, x->data+2*4, 2*2*16); memmove(w->cursor.clr, x->data+2*4, 2*2*16);
w->cursorp = &w->cursor; w->cursorp = &w->cursor;
} }
wsetcursor(w, !sweeping && !menuing); if(w==input)
wsetcursor(w, TRUE);
break; break;
case Qlabel: case Qlabel: