From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <8052e9979e33ecff799bacd84d2f565c@vitanuova.com> To: 9fans@cse.psu.edu Subject: Re: Re: [9fans] Anyone to try to convert Acme to full UI (w/graphics) Date: Thu, 26 Oct 2006 19:35:11 +0100 From: rog@vitanuova.com In-Reply-To: <123d17ac591ffb286e0a7aff61e1bd12@mail.gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: d724cbe0-ead1-11e9-9d60-3106f5b1d025 > Dealing with different screen resolutions kind of sucks though, it > could be that it's my rc scripting and understanding of the rio > control namespace isn't very good yet. possibly the first program i wrote when i first started using plan 9 was to deal with this issue. i've attached it - it's tiny. all it does is convert proportional coordinates [0..1] to screen coords [0..max]. for instance, winpos 0.6 0.0 0.4 100p gives a 100 pixel high rectangle that covers the right 40% of the screen. i use it like this: window -r `{winpos 0 0.05 1 1} acme -l acme.dump perhaps this might help? #include #include int makecoord(char*, int, int); int getscreensize(int*, int*, int*, int*); void main(int argc, char **argv) { int scrminx, scrminy, scrmaxx, scrmaxy; int minx, miny, sizex, sizey, maxx, maxy; /* usage: winpos xorg yorg xsize ysize */ if (argc != 5) { fprint(2, "usage: winpos xorg yorg xsize ysize\n"); exits("usage"); } if (getscreensize(&scrminx, &scrminy, &scrmaxx, &scrmaxy) == -1) { fprint(2, "winpos: couldn't get screen size: %r\n"); exits("no screen"); } minx = makecoord(argv[1], scrminx, scrmaxx); miny = makecoord(argv[2], scrminy, scrmaxy); sizex = makecoord(argv[3], scrminx, scrmaxx); sizey = makecoord(argv[4], scrminy, scrmaxy); if (sizex > (scrmaxx - scrminx)) sizex = scrmaxx - scrminx; if (sizey > (scrmaxy - scrminy)) sizey = scrmaxy - scrminy; if (minx + sizex > scrmaxx) minx = scrmaxx - sizex; if (miny + sizey > scrmaxy) miny = scrmaxy - sizey; maxx = minx + sizex; maxy = miny + sizey; print("%d %d %d %d\n", minx, miny, maxx, maxy); exits(0); } int makecoord(char *spec, int min, int max) { if (spec[0] == 0) return 0; if (spec[strlen(spec) - 1] == 'p') return atoi(spec); return atof(spec) * (max - min) + min; } int getscreensize(int *minx, int *miny, int *maxx, int *maxy) { char buf[12*12+1]; int fd; buf[sizeof(buf) - 1] = 0; fd = open("#i/draw/new", OREAD); if(fd < 0) return -1; if(read(fd, buf, sizeof buf - 1) != sizeof buf - 1){ close(fd); return -1; } close(fd); *minx = atoi(buf+4*12); *miny = atoi(buf+5*12); *maxx = atoi(buf+6*12); *maxy = atoi(buf+7*12); return 0; }