rio: fix wrong frame colors when moving non-current window

When a window is moved or reshaped, that implicitely tops
the window and makes it current. The conseqence of this
is that we always have to redraw the window as if it where
a current window in any case. This was handled for Reshaped
windows, but not when the window was just moved. We now
handle both cases the exact same way, getting rid of the
Moved wctl message.
This commit is contained in:
cinap_lenrek 2016-02-13 16:36:24 +01:00
parent eeb96dca21
commit c3867623ae
3 changed files with 25 additions and 40 deletions

View file

@ -60,7 +60,6 @@ enum /* control messages */
{ {
Wakeup, Wakeup,
Reshaped, Reshaped,
Moved,
Topped, Topped,
Repaint, Repaint,
Refresh, Refresh,
@ -210,9 +209,9 @@ void wmovemouse(Window*, Point);
void wpaste(Window*); void wpaste(Window*);
void wplumb(Window*); void wplumb(Window*);
void wlook(Window*); void wlook(Window*);
void wrefresh(Window*, Rectangle); void wrefresh(Window*);
void wrepaint(Window*); void wrepaint(Window*);
void wresize(Window*, Image*, int); void wresize(Window*, Image*);
void wscrdraw(Window*); void wscrdraw(Window*);
void wscroll(Window*, int); void wscroll(Window*, int);
void wselect(Window*); void wselect(Window*);

View file

@ -28,8 +28,7 @@ void unhide(int);
void newtile(int); void newtile(int);
Image *sweep(void); Image *sweep(void);
Image *bandsize(Window*); Image *bandsize(Window*);
Image* drag(Window*, Rectangle*); Image* drag(Window*);
void refresh(Rectangle);
void resized(void); void resized(void);
Channel *exitchan; /* chan(int) */ Channel *exitchan; /* chan(int) */
Channel *winclosechan; /* chan(Window*); */ Channel *winclosechan; /* chan(Window*); */
@ -457,7 +456,6 @@ mousethread(void*)
int sending, inside, scrolling, moving, band; int sending, inside, scrolling, moving, band;
Window *w, *winput; Window *w, *winput;
Image *i; Image *i;
Rectangle r;
Point xy; Point xy;
Mouse tmp; Mouse tmp;
enum { enum {
@ -546,13 +544,10 @@ mousethread(void*)
if(band) if(band)
i = bandsize(winput); i = bandsize(winput);
else else
i = drag(winput, &r); i = drag(winput);
sweeping = 0; sweeping = 0;
if(i != nil){ if(i != nil){
if(band) wsendctlmesg(winput, Reshaped, i->r, i);
wsendctlmesg(winput, Reshaped, i->r, i);
else
wsendctlmesg(winput, Moved, r, i);
cornercursor(winput, mouse->xy, 1); cornercursor(winput, mouse->xy, 1);
} }
if(wclose(winput) == 0) if(wclose(winput) == 0)
@ -931,7 +926,7 @@ drawborder(Rectangle r, int show)
} }
Image* Image*
drag(Window *w, Rectangle *rp) drag(Window *w)
{ {
Point p, op, d, dm, om; Point p, op, d, dm, om;
Rectangle r; Rectangle r;
@ -964,7 +959,6 @@ drag(Window *w, Rectangle *rp)
readmouse(mousectl); readmouse(mousectl);
return nil; return nil;
} }
*rp = r;
return allocwindow(wscreen, r, Refbackup, DNofill); return allocwindow(wscreen, r, Refbackup, DNofill);
} }
@ -1135,15 +1129,14 @@ move(void)
{ {
Window *w; Window *w;
Image *i; Image *i;
Rectangle r;
w = pointto(FALSE); w = pointto(FALSE);
if(w == nil) if(w == nil)
return; return;
incref(w); incref(w);
i = drag(w, &r); i = drag(w);
if(i) if(i)
wsendctlmesg(w, Moved, r, i); wsendctlmesg(w, Reshaped, i->r, i);
cornercursor(w, mouse->xy, 1); cornercursor(w, mouse->xy, 1);
wclose(w); wclose(w);
} }

View file

@ -87,13 +87,10 @@ wsetname(Window *w)
} }
void void
wresize(Window *w, Image *i, int move) wresize(Window *w, Image *i)
{ {
Rectangle r, or; Rectangle r;
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);
freeimage(w->i); freeimage(w->i);
w->i = i; w->i = i;
w->mc.image = i; w->mc.image = i;
@ -102,19 +99,15 @@ wresize(Window *w, Image *i, int move)
w->scrollr.max.x = r.min.x+Scrollwid; w->scrollr.max.x = r.min.x+Scrollwid;
w->lastsr = ZR; w->lastsr = ZR;
r.min.x += Scrollwid+Scrollgap; r.min.x += Scrollwid+Scrollgap;
if(move) frclear(w, FALSE);
frsetrects(w, r, w->i); frinit(w, r, w->font, w->i, cols);
else{ wsetcols(w, 1);
frclear(w, FALSE); w->maxtab = maxtab*stringwidth(w->font, "0");
frinit(w, r, w->font, w->i, cols); r = insetrect(w->i->r, Selborder);
wsetcols(w, 1); draw(w->i, r, cols[BACK], nil, w->entire.min);
w->maxtab = maxtab*stringwidth(w->font, "0"); wfill(w);
r = insetrect(w->i->r, Selborder); wsetselect(w, w->q0, w->q1);
draw(w->i, r, cols[BACK], nil, w->entire.min); wscrdraw(w);
wfill(w);
wsetselect(w, w->q0, w->q1);
wscrdraw(w);
}
wborder(w, Selborder); wborder(w, Selborder);
wsetname(w); wsetname(w);
w->topped = ++topped; w->topped = ++topped;
@ -124,9 +117,10 @@ wresize(Window *w, Image *i, int move)
} }
void void
wrefresh(Window *w, Rectangle r) wrefresh(Window *w)
{ {
/* BUG: rectangle is ignored */ Rectangle r;
if(w == input) if(w == input)
wborder(w, Selborder); wborder(w, Selborder);
else else
@ -1127,7 +1121,6 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
if(p!=nil) if(p!=nil)
sendp((Channel*)p, w); sendp((Channel*)p, w);
break; break;
case Moved:
case Reshaped: case Reshaped:
if(w->deleted){ if(w->deleted){
freeimage(i); freeimage(i);
@ -1135,7 +1128,7 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
} }
w->screenr = r; w->screenr = r;
strcpy(buf, w->name); strcpy(buf, w->name);
wresize(w, i, m==Moved); wresize(w, i);
proccreate(deletetimeoutproc, estrdup(buf), 4096); proccreate(deletetimeoutproc, estrdup(buf), 4096);
flushimage(display, 1); flushimage(display, 1);
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 */
@ -1189,9 +1182,9 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
flushimage(display, 1); flushimage(display, 1);
break; break;
case Refresh: case Refresh:
if(w->i==nil || Dx(w->screenr)<=0 || !rectclip(&r, w->i->r) || w->mouseopen) if(w->i==nil || Dx(w->screenr)<=0 || w->mouseopen)
break; break;
wrefresh(w, r); wrefresh(w);
flushimage(display, 1); flushimage(display, 1);
break; break;
case Movemouse: case Movemouse: