On Sat Apr 20 14:25:53 EDT 2013, j...@corpus-callosum.com wrote:
> Plot doesn't have any redraw in eresized(). It would need to redraw
> the screen and reprocess the data for the new size.
yes. this is a problem for plan 9. you cannot move or hide the plot
window. imho this is pretty antisocial.
i've attached a version that always uses the double-buffer buffer
to allow for resize events. double-buffering now only prevents
the draw from going directly to the screen. it is also possible to
select exit from the menu before the input is exhausted. for
programs like mapdemo, this is important.
a better solution would be to additionally save all the draw commands
(between clears) and if the screen size has changed, recompute. otherwise
if redrawing is necessary, the double-buffer buffer can be reused.
unfortunately, i'm too lazy for that.
> Fixing this
> would probably fix devdraw cocoa versions as well and enable the
> server option.
>
> This could be why devdraw on Mountain Lion also ends up with a
> blank screen.
it would seem that mountain lion devdraw has a bug. devdraw should not
send a resize event until there is a, er, resize event. this spurious
event is an error.
- erikdiff -c /n/dump/2013/0421/sys/src/cmd/plot/plot.c plot.c
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:3,9 - plot.c:3,11
#include
#include "plot.h"
#include
- #include
+ #include
+ #include
+ #include
void define(char*);
void call(char*);
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:106,111 - plot.c:108,114
#define NFSTACK 50
struct fstack{
+ char name[128];
int peekc;
int lineno;
char *corebuf;
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:124,146 - plot.c:127,228
int cnt[NPTS];/* control-polygon vertex counts */
double *pts[NPTS];/* control-polygon vertex pointers */
- extern void m_swapbuf(void);
+ extern void m_swapbuf(void); /* reaching into implementation. ick. */
+ extern Image *offscreen;
void
- eresized(int new){
- if(new && getwindow(display, Refnone) < 0){
- fprint(2, "Can't reattach to window: %r\n");
- exits("resize");
+ resize(Point p)
+ {
+ int fd;
+
+ fd = open("/dev/wctl", OWRITE);
+ if(fd >= 0){
+ fprint(fd, "resize -dx %d -dy %d", p.x+4*2, p.y+4*2);
+ close(fd);
}
+ }
+
+ void
+ resizeto(Point p)
+ {
+ Point s;
+
+ s = (Point){Dx(screen->r), Dy(screen->r)};
+ if(eqpt(p, s))
+ return;
+ resize(p);
+ }
+
+ void
+ eresized(int new)
+ {
+ if(new && getwindow(display, Refnone) < 0)
+ sysfatal("plot: can't reattach to window: %r\n");
+ //resizeto((Point){Dx(offscreen->r)+4, Dy(offscreen->r)+4});
m_swapbuf();
}
+
char *items[]={
"exit",
0
};
Menu menu={items};
+
void
- main(int arc, char *arv[]){
+ mouseproc(void*)
+ {
+ void *v;
+ Rune r;
+ Alt alts[4];
+ Keyboardctl *k;
+ Mousectl *m;
+ Mouse mc;
+ enum{Amouse, Akbd, Aresize, Aend};
+
+ m = initmouse(nil, screen);
+ k = initkeyboard(nil);
+
+ memset(alts, 0, sizeof alts);
+ alts[Amouse].c = m->c;
+ alts[Amouse].v = &mc;
+ alts[Amouse].op = CHANRCV;
+
+ alts[Akbd].c = k->c;
+ alts[Akbd].v = &r;
+ alts[Akbd].op = CHANRCV;
+
+ alts[Aresize].c = m->resizec;
+ alts[Aresize].v = &v;
+ alts[Aresize].op = CHANRCV;
+
+ alts[Aend].op = CHANEND;
+
+ for(;;)
+ switch(alt(alts)){
+ default:
+ sysfatal("mouse!");
+ case Amouse:
+ if(mc.buttons & 4) {
+ if(menuhit(3, m, &menu, nil) == 0)
+ threadexitsall("");
+ }
+ break;
+ case Akbd:
+ switch(r){
+ case 'q':
+ case 0x7f:
+ case 0x04:
+ threadexitsall("");
+ }
+ break;
+ case Aresize:
+ eresized(1);
+ ;
+ }
+ }
+
+ void
+ threadmain(int arc, char *arv[]){
char *ap;
Biobuf *bp;
int fd;
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:147,157 - plot.c:229,240
int i;
int dflag;
char *oflag;
- Mouse m;
+
bp = 0;
fd = dup(0, -1);/* because openpl will close 0! */
dflag=0;
oflag="";
+ argv0 = arv[0];
for(i=1;i!=arc;i++) if(arv[i][0]=='-') switch(arv[i][1]){
case 'd': dflag=1; break;
case 'o': oflag=arv[i]+2; break;
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:158,164 - plot.c:241,249
case 's': fd=server(); break;
}
openpl(ofl