Commit Diff


commit - c28224992a8e0093f3629afb747c8a1a876683e3
commit + c96d832508cc6a8db1420b93242af08ec08be720
blob - 75745aff077a85862fa03a2a9b5a0e84d8ddcdaa
blob + 1005bae98162cae884817b376d0c1e5ee3c01255
--- src/cmd/acme/acme.c
+++ src/cmd/acme/acme.c
@@ -142,7 +142,7 @@ threadmain(int argc, char *argv[])
 		free(p);
 	}
 	if(maxtab == 0)
-		maxtab = 4; 
+		maxtab = 4;
 	if(loadfile)
 		rowloadfonts(loadfile);
 	putenv("font", fontnames[0]);
@@ -333,7 +333,7 @@ shutdown(void *v, char *msg)
 	for(i=0; ignotes[i]; i++)
 		if(strncmp(ignotes[i], msg, strlen(ignotes[i])) == 0)
 			return 1;
-	
+
 	killprocs();
 	if(!dumping && strcmp(msg, "kill")!=0 && strcmp(msg, "exit")!=0 && getpid()==mainpid){
 		dumping = TRUE;
@@ -534,7 +534,7 @@ mousethread(void *v)
 	if(cplumb == nil)
 		alts[MPlumb].op = CHANNOP;
 	alts[NMALT].op = CHANEND;
-	
+
 	for(;;){
 		qlock(&row.lk);
 		flushwarnings();
@@ -545,6 +545,7 @@ mousethread(void *v)
 			if(getwindow(display, Refnone) < 0)
 				error("attach to window");
 			draw(screen, screen->r, display->white, nil, ZP);
+			iconinit();
 			scrlresize();
 			rowresize(&row, screen->clipr);
 			break;
@@ -959,19 +960,25 @@ iconinit(void)
 	Rectangle r;
 	Image *tmp;
 
-	/* Blue */
-	tagcols[BACK] = allocimagemix(display, DPalebluegreen, DWhite);
-	tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPalegreygreen);
-	tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue);
-	tagcols[TEXT] = display->black;
-	tagcols[HTEXT] = display->black;
-
-	/* Yellow */
-	textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite);
-	textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow);
-	textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DYellowgreen);
-	textcols[TEXT] = display->black;
-	textcols[HTEXT] = display->black;
+	if(tagcols[BACK] == nil) {
+		/* Blue */
+		tagcols[BACK] = allocimagemix(display, DPalebluegreen, DWhite);
+		tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPalegreygreen);
+		tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue);
+		tagcols[TEXT] = display->black;
+		tagcols[HTEXT] = display->black;
+	
+		/* Yellow */
+		textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite);
+		textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow);
+		textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DYellowgreen);
+		textcols[TEXT] = display->black;
+		textcols[HTEXT] = display->black;
+	}
+	
+	r = Rect(0, 0, Scrollwid+ButtonBorder, font->height+1);
+	if(button && eqrect(r, button->r))
+		return;
 
 	if(button){
 		freeimage(button);
@@ -979,18 +986,17 @@ iconinit(void)
 		freeimage(colbutton);
 	}
 
-	r = Rect(0, 0, Scrollwid+2, font->height+1);
 	button = allocimage(display, r, screen->chan, 0, DNofill);
 	draw(button, r, tagcols[BACK], nil, r.min);
-	r.max.x -= 2;
-	border(button, r, 2, tagcols[BORD], ZP);
+	r.max.x -= ButtonBorder;
+	border(button, r, ButtonBorder, tagcols[BORD], ZP);
 
 	r = button->r;
 	modbutton = allocimage(display, r, screen->chan, 0, DNofill);
 	draw(modbutton, r, tagcols[BACK], nil, r.min);
-	r.max.x -= 2;
-	border(modbutton, r, 2, tagcols[BORD], ZP);
-	r = insetrect(r, 2);
+	r.max.x -= ButtonBorder;
+	border(modbutton, r, ButtonBorder, tagcols[BORD], ZP);
+	r = insetrect(r, ButtonBorder);
 	tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DMedblue);
 	draw(modbutton, r, tmp, nil, ZP);
 	freeimage(tmp);
blob - 72860db3385d80b0afa27ad76345a25ea19ddb5f
blob + d0feb0953dd096476c64174b312eda4ad6642e14
--- src/cmd/acme/dat.h
+++ src/cmd/acme/dat.h
@@ -463,11 +463,13 @@ enum
 	BUFSIZE = Maxblock+IOHDRSZ,	/* size from fbufalloc() */
 	RBUFSIZE = BUFSIZE/sizeof(Rune),
 	EVENTSIZE = 256,
-	Scrollwid = 12,	/* width of scroll bar */
-	Scrollgap = 4,	/* gap right of scroll bar */
-	Margin = 4,	/* margin around text */
-	Border = 2	/* line between rows, cols, windows */
 };
+
+#define Scrollwid scalesize(display, 12)
+#define Scrollgap scalesize(display, 4)
+#define Margin scalesize(display, 4)
+#define Border scalesize(display, 2)
+#define ButtonBorder scalesize(display, 2)
 
 #define	QID(w,q)	((w<<8)|(q))
 #define	WIN(q)	((((ulong)(q).path)>>8) & 0xFFFFFF)