Better resize handling. [rsc] --rw-rw-r-- M 140560 rsc sys 6471 Nov 1 08:53 sys/src/games/memo.c /n/sourcesdump/2005/1101/plan9/sys/src/games/memo.c:4,9 - /n/sourcesdump/2005/1102/plan9/sys/src/games/memo.c:4,14 #include #include + enum { + Facesize = 48 + }; + + void memoinit(void); void redraw(void); void eresized(int); /n/sourcesdump/2005/1101/plan9/sys/src/games/memo.c:180,189 - /n/sourcesdump/2005/1102/plan9/sys/src/games/memo.c:185,203 void eresized(int new) { + double sq; + Point p; + if(new && getwindow(display, Refnone) < 0){ fprint(2, "can't reattach to window"); exits("resized"); } + + sq = sqrt(level); + p = Pt(Dx(screen->r)+8, Dy(screen->r)+8); + if(!new || !eqpt(p, Pt(Facesize*sq+sq*4+17, Facesize*sq+sq*4+17))) + resize(Facesize*sq+sq*4+17); + allocblocks(); draw(screen, screen->r, back, nil, ZP); redraw(); /n/sourcesdump/2005/1101/plan9/sys/src/games/memo.c:192,198 - /n/sourcesdump/2005/1102/plan9/sys/src/games/memo.c:206,212 void redraw(void) { - int i, nx, ny; + int i; Rectangle r; Point p; /n/sourcesdump/2005/1101/plan9/sys/src/games/memo.c:290,298 - /n/sourcesdump/2005/1102/plan9/sys/src/games/memo.c:304,309 return i; } - enum { - Facesize = 48 }; - void allocblocks(void) { /n/sourcesdump/2005/1101/plan9/sys/src/games/memo.c:300,306 - /n/sourcesdump/2005/1102/plan9/sys/src/games/memo.c:311,316 ushort i, x, y, sq; sq = sqrt(level); - resize(Facesize*sq+sq*4+17); r = insetrect(screen->r, 5); r.max.x = r.min.x+Facesize*sq+sq*4-1; r.max.y = r.min.y+Facesize*sq+sq*4-1;