ref: 8033bd69fe3e75c8a38586c8d7881235caeca76b
parent: 91580d40ff086d985333549e8f6bf2a2ae952655
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat Oct 20 11:51:32 EDT 2012
rio: colors, flicker reduction, refresh after mouse close allocate all the colors in iconinit(), remove unused ones like grey. rename darkgrey to paletextcol because thats what it is used for. new approach to window image allocation. we allocate the window with DNofill and let the window fill itself. this reduces flickering especially with (-b) option and makes rio resize feel a lot faster. wrefresh() didnt work. now fixed.
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -317,9 +317,19 @@
Cursor whitearrow;
Cursor query;
Cursor *corners[9];
+
Image *background;
-Image *lightgrey;
-Image *red;
+Image *cols[NCOL];
+Image *titlecol;
+Image *lighttitlecol;
+Image *dholdcol;
+Image *holdcol;
+Image *lightholdcol;
+Image *paleholdcol;
+Image *paletextcol;
+Image *sizecol;
+int reverse; /* there are no pastel paints in the dungeons and dragons world -- rob pike */
+
Window **window;
Window *wkeyboard; /* window of simulated keyboard */
int nwindow;
--- a/sys/src/cmd/rio/data.c
+++ b/sys/src/cmd/rio/data.c
@@ -176,5 +176,28 @@
iconinit(void)
{background = allocimage(display, Rect(0,0,1,1), RGB24, 1, 0x777777FF);
- red = allocimage(display, Rect(0,0,1,1), RGB24, 1, 0xDD0000FF);
+
+ /* greys are multiples of 0x11111100+0xFF, 14* being palest */
+ cols[BACK] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xFFFFFFFF^reverse);
+ cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF^reverse);
+ cols[BORD] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x999999FF^reverse);
+ cols[TEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
+ cols[HTEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
+ if(!reverse) {+ titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreygreen);
+ lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreygreen);
+ } else {+ titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPurpleblue);
+ lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x999999FF);;
+ }
+ dholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DMedblue);
+ lightholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreyblue);
+ paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreyblue);
+ paletextcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
+ sizecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DRed);
+
+ if(reverse == 0)
+ holdcol = dholdcol;
+ else
+ holdcol = paleholdcol;
}
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -46,7 +46,6 @@
char *fontname;
int mainpid;
-int reverse;
enum
{@@ -228,7 +227,7 @@
r = screen->r;
r.max.x = r.min.x+300;
r.max.y = r.min.y+80;
- i = allocwindow(wscreen, r, Refbackup, DWhite);
+ i = allocwindow(wscreen, r, Refbackup, DNofill);
wkeyboard = new(i, FALSE, scrolling, 0, nil, "/bin/rc", kbdargv);
if(wkeyboard == nil)
error("can't create keyboard window");@@ -653,10 +652,10 @@
break;
incref(w);
if(j < nhidden){- im = allocimage(display, r, screen->chan, 0, DWhite);
+ im = allocimage(display, r, screen->chan, 0, DNofill);
r = ZR;
} else
- im = allocwindow(wscreen, r, Refbackup, DWhite);
+ im = allocwindow(wscreen, r, Refbackup, DNofill);
if(im)
wsendctlmesg(w, Reshaped, r, im);
wclose(w);
@@ -846,12 +845,13 @@
p = onscreen(mouse->xy);
r = canonrect(Rpt(p0, p));
if(Dx(r)>5 && Dy(r)>5){- i = allocwindow(wscreen, r, Refnone, 0xEEEEEEFF); /* grey */
+ i = allocwindow(wscreen, r, Refnone, DNofill);
freeimage(oi);
if(i == nil)
goto Rescue;
oi = i;
- border(i, r, Selborder, red, ZP);
+ border(i, r, Selborder, sizecol, ZP);
+ draw(i, insetrect(r, Selborder), cols[BACK], nil, ZP);
flushimage(display, 1);
}
}
@@ -861,11 +861,10 @@
if(i==nil || Dx(i->r)<100 || Dy(i->r)<3*font->height)
goto Rescue;
oi = i;
- i = allocwindow(wscreen, oi->r, Refbackup, DWhite);
+ i = allocwindow(wscreen, oi->r, Refbackup, DNofill);
freeimage(oi);
if(i == nil)
goto Rescue;
- border(i, r, Selborder, red, ZP);
cornercursor(input, mouse->xy, 1);
goto Return;
@@ -890,7 +889,9 @@
originwindow(b, r.min, r.min);
else{freeimage(b);
- *bp = allocwindow(wscreen, r, Refbackup, DRed);
+ b = allocwindow(wscreen, r, Refbackup, DNofill);
+ if(b != nil) draw(b, r, sizecol, nil, ZP);
+ *bp = b;
}
}
@@ -944,7 +945,7 @@
moveto(mousectl, mouse->xy); /* force cursor update; ugly */
menuing = FALSE;
flushimage(display, 1);
- if(mouse->buttons!=0 || (ni=allocwindow(wscreen, r, Refbackup, DWhite))==nil){+ if(mouse->buttons!=0 || (ni=allocwindow(wscreen, r, Refbackup, DNofill))==nil){moveto(mousectl, om);
while(mouse->buttons)
readmouse(mousectl);
@@ -1023,7 +1024,6 @@
Image*
bandsize(Window *w)
{- Image *i;
Rectangle r, or;
Point p, startp;
int which, but;
@@ -1060,11 +1060,7 @@
}
if(abs(p.x-startp.x)+abs(p.y-startp.y) <= 1)
return nil;
- i = allocwindow(wscreen, or, Refbackup, DWhite);
- if(i == nil)
- return nil;
- border(i, r, Selborder, red, ZP);
- return i;
+ return allocwindow(wscreen, or, Refbackup, DNofill);
}
Window*
@@ -1157,7 +1153,7 @@
if(nhidden >= nelem(hidden))
return 0;
incref(w);
- i = allocimage(display, w->screenr, w->i->chan, 0, DWhite);
+ i = allocimage(display, w->screenr, w->i->chan, 0, DNofill);
if(i){if(w == input)
input = nil;
@@ -1180,7 +1176,7 @@
if(j == nhidden)
return -1; /* not hidden */
incref(w);
- i = allocwindow(wscreen, w->i->r, Refbackup, DWhite);
+ i = allocwindow(wscreen, w->i->r, Refbackup, DNofill);
if(i){--nhidden;
memmove(hidden+j, hidden+j+1, (nhidden-j)*sizeof(Window*));
--- a/sys/src/cmd/rio/scrl.c
+++ b/sys/src/cmd/rio/scrl.c
@@ -21,7 +21,7 @@
if(scrtmp)
return;
h = BIG*Dy(screen->r);
- scrtmp = allocimage(display, Rect(0, 0, 32, h), screen->chan, 0, DWhite);
+ scrtmp = allocimage(display, Rect(0, 0, 32, h), screen->chan, 0, DNofill);
if(scrtmp == nil)
error("scrtemps");}
@@ -70,7 +70,7 @@
scrtemps();
if(w->i == nil)
- error("scrdraw");+ return;
r = w->scrollr;
b = scrtmp;
r1 = r;
--- a/sys/src/cmd/rio/wctl.c
+++ b/sys/src/cmd/rio/wctl.c
@@ -330,14 +330,13 @@
argv[3] = nil;
}
if(hideit)
- i = allocimage(display, rect, screen->chan, 0, DWhite);
+ i = allocimage(display, rect, screen->chan, 0, DNofill);
else
- i = allocwindow(wscreen, rect, Refbackup, DWhite);
+ i = allocwindow(wscreen, rect, Refbackup, DNofill);
if(i == nil){strcpy(err, Ewalloc);
return -1;
}
- border(i, rect, Selborder, red, ZP);
new(i, hideit, scrollit, pid, dir, "/bin/rc", argv);
@@ -366,12 +365,11 @@
}
if(eqrect(r, w->screenr))
return 1;
- i = allocwindow(wscreen, r, Refbackup, DWhite);
+ i = allocwindow(wscreen, r, Refbackup, DNofill);
if(i == nil){strcpy(err, Ewalloc);
return -1;
}
- border(i, r, Selborder, red, ZP);
wsendctlmesg(w, Reshaped, i->r, i);
return 1;
case Scroll:
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -21,21 +21,9 @@
MinWater = 20000, /* room to leave available when reallocating */
};
-extern int reverse; /* there are no pastel paints in the dungeons and dragons world -- rob pike */
-
-static int topped;
-static int id;
-
-static Image *cols[NCOL];
-static Image *grey;
-static Image *darkgrey;
+static int topped;
+static int id;
static Cursor *lastcursor;
-static Image *titlecol;
-static Image *lighttitlecol;
-static Image *dholdcol;
-static Image *holdcol;
-static Image *lightholdcol;
-static Image *paleholdcol;
Window*
wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl, int scrolling)
@@ -43,31 +31,6 @@
Window *w;
Rectangle r;
- if(cols[0] == nil){- /* greys are multiples of 0x11111100+0xFF, 14* being palest */
- grey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xEEEEEEFF^reverse);
- darkgrey = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
- cols[BACK] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xFFFFFFFF^reverse);
- cols[HIGH] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xCCCCCCFF^reverse);
- cols[BORD] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x999999FF);
- cols[TEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
- cols[HTEXT] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x000000FF^reverse);
- if(reverse == 0) {- titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreygreen);
- lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreygreen);
- } else {- titlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPurpleblue);
- lighttitlecol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x666666FF^reverse);
- }
- dholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DMedblue);
- lightholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DGreyblue);
- paleholdcol = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPalegreyblue);
-
- if(reverse == 0)
- holdcol = dholdcol;
- else
- holdcol = paleholdcol;
- }
w = emalloc(sizeof(Window));
w->screenr = i->r;
r = insetrect(i->r, Selborder+1);
@@ -162,7 +125,7 @@
}
void
-wrefresh(Window *w, Rectangle)
+wrefresh(Window *w, Rectangle r)
{/* BUG: rectangle is ignored */
if(w == input)
@@ -169,9 +132,8 @@
wborder(w, Selborder);
else
wborder(w, Unselborder);
- if(w->mouseopen)
- return;
- draw(w->i, insetrect(w->i->r, Borderwidth), w->cols[BACK], nil, w->i->r.min);
+ r = insetrect(w->i->r, Selborder);
+ draw(w->i, r, w->cols[BACK], nil, w->entire.min);
w->ticked = 0;
if(w->p0 > 0)
frdrawsel(w, frptofchar(w, 0), 0, w->p0, 0);
@@ -760,7 +722,7 @@
if(w == input)
w->cols[TEXT] = w->cols[HTEXT] = cols[TEXT];
else
- w->cols[TEXT] = w->cols[HTEXT] = darkgrey;
+ w->cols[TEXT] = w->cols[HTEXT] = paletextcol;
}
void
--- a/sys/src/cmd/rio/xfid.c
+++ b/sys/src/cmd/rio/xfid.c
@@ -183,11 +183,10 @@
err = Ebadrect;
else{if(hideit)
- i = allocimage(display, r, screen->chan, 0, DWhite);
+ i = allocimage(display, r, screen->chan, 0, DNofill);
else
- i = allocwindow(wscreen, r, Refbackup, DWhite);
+ i = allocwindow(wscreen, r, Refbackup, DNofill);
if(i){- border(i, r, Selborder, display->black, ZP);
if(pid == 0)
pid = -1; /* make sure we don't pop a shell! - UGH */
w = new(i, hideit, scrollit, pid, nil, nil, nil);
--
⑨