From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=DATE_IN_PAST_03_06, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 25680 invoked from network); 20 Dec 2021 20:46:34 -0000 Received: from 4ess.inri.net (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 20 Dec 2021 20:46:34 -0000 Received: from mail-4316.protonmail.ch ([185.70.43.16]) by 4ess; Mon Dec 20 11:14:15 -0500 2021 Date: Mon, 20 Dec 2021 16:13:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail2; t=1640016842; bh=r5wds3Lnu2slh4s+2+i28rt6DquqsBz2OtQAETtqR8g=; h=Date:To:From:Reply-To:Subject:Message-ID:From:To:Cc; b=adyE0Bp969YEf+Kl3J3r8pqUbAFcNNXZIPAi9Mz4oHvn5QW9WSQNmNml8298i4YQF 49eVtZyiWVoXHeQkiKImb3xvezaMyWU9R9FFrkEjtbmA50MaQAw4Kv4Rcg5aBgbNwT r3WuzYMd+ykFAEkmZwx1XrMn5WlUVLUaStm5PZkKGAtvDbi/GtJp0h77b0QLgSHiid xfKBAgBB62YOWVKs+rj46lxl8xzTv3hAin/W+tWFkDZnZI6znsNEZV5xQsKB24veSP jTiWzifrZD9P8UgS/6c3IPj0Hx9/gTWBmiTP28NJr0hJqouevxTiXT6wm0t0X1f0Pd 5NrXpLdVrDEXw== To: "9front@9front.org" <9front@9front.org> From: Philip Silva Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: app-based session-oriented grid component component Subject: [9front] hidpi Reply-To: 9front@9front.org Precedence: bulk I've been creating patches to enable hidpi to make scrollbars bigger when u= sing > 100 dpi. It's basically 3 patches: 1st one for adding int displaydpi= , 2nd one for adding an entry to plan9.ini and a 3rd very experimental one = that changes scrollbar and border widths including some glitches. (And a 4t= h one that hardcodes 200 dpi in drawterm-metal-cocoa) The extra fields and = most code is just copied from plan9port. (d0e0701, c96d832) I'm using this = since a few months now and it works, the only problems I had: - system wouldn't boot anymore when only applying the libdraw part of the 1= st patch (I fixed that and checked in a fresh install in a VM that it would= just ignore when the new draw command q1d isn't present in devdraw) - glitches: the borders aren't calculated correctly (3rd patch for rio and = acme is very wip) - despite the glitches it works reasonably well with acme and rio but some = applications are quite small then. Not sure how much effort it would be to = patch for compat. with dpi !=3D 100 There is also the field forcedpi that is left largely ignored but generally= is supposed to override displaydpi when necessary. Greetings, Philip -- 1st Patch for libdraw and devdraw: diff c7dcc82b0be805717efbe77c98eaadf3ee1e31af uncommitted --- a/sys/include/ape/draw.h +++ b/sys/include/ape/draw.h @@ -208,6 +208,7 @@ =09Image=09=09*windows; =09Image=09=09*screenimage; =09int=09=09=09_isnewdisplay; +=09int=09=09=09dpi; }; struct Image --- a/sys/include/draw.h +++ b/sys/include/draw.h @@ -200,6 +200,7 @@ =09Image=09=09*windows; =09Image=09=09*screenimage; =09int=09=09_isnewdisplay; +=09int=09=09dpi; }; struct Image --- a/sys/src/9/port/devdraw.c +++ b/sys/src/9/port/devdraw.c @@ -77,6 +77,8 @@ =09int=09=09refreshme; =09int=09=09infoid; =09int=09=09op; +=09int=09=09displaydpi; +=09int=09=09forcedpi; }; struct Refresh @@ -785,6 +789,7 @@ =09cl->slot =3D i; =09cl->clientid =3D ++sdraw.clientid; =09cl->op =3D SoverD; +=09cl->displaydpi=3D100; =09sdraw.client[i] =3D cl; =09return cl; } @@ -1396,6 +1401,7 @@ =09int c, repl, m, y, dstid, scrnid, ni, ci, j, nw, e0, e1, op, ox, oy, oe= size, esize, doflush; =09uchar *u, *a, refresh; =09char *fmt; +=09Fmt f; =09ulong value, chan; =09Rectangle r, clipr; =09Point p, q, *pp, sp; @@ -1643,6 +1649,35 @@ =09=09=09font->nfchar =3D ni; =09=09=09font->ascent =3D a[9]; =09=09=09continue; + +=09=09/* query: 'Q' n[1] queryspec[n] */ +=09=09case 'q': +=09=09=09if(n < 2){ +=09=09=09=09error(Eshortdraw); +=09=09=09} +=09=09=09m =3D 1+1+a[1]; +=09=09=09if(n < m){ +=09=09=09=09error(Eshortdraw); +=09=09=09} +=09=09=09fmtstrinit(&f); +=09=09=09for(c=3D0; cforcedpi) +=09=09=09=09=09=09fmtprint(&f, "%11d ", client->forcedpi); +=09=09=09=09=09else +=09=09=09=09=09=09fmtprint(&f, "%11d ", client->displaydpi); +=09=09=09=09=09break; +=09=09=09=09} +=09=09=09} +=09=09=09client->readdata =3D (uchar*)fmtstrflush(&f); +=09=09=09if(client->readdata =3D=3D nil) +=09=09=09=09error(Enomem); +=09=09=09client->nreaddata =3D strlen((char*)client->readdata); +=09=09=09continue; + =09=09/* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] lef= t[1] width[1] */ =09=09case 'l': --- a/sys/src/libdraw/init.c +++ b/sys/src/libdraw/init.c @@ -197,6 +197,7 @@ Display* initdisplay(char *dev, char *win, void(*error)(Display*, char*)) { +=09uchar *a; =09char buf[128], info[NINFO+1], *t, isnew; =09int n, datafd, ctlfd, reffd; =09Display *disp; @@ -319,6 +320,18 @@ =09if(dir!=3Dnil && dir->qid.vers=3D=3D1)=09/* other way to tell */ =09=09disp->_isnewdisplay =3D 1; =09free(dir); + +=09a =3D bufimage(disp, 3); +=09if(a =3D=3D nil) +=09=09goto Error5; +=09a[0] =3D 'q'; +=09a[1] =3D 1; +=09a[2] =3D 'd'; +=09disp->dpi =3D 100; +=09if(flushimage(disp, 0) >=3D 0){ +=09=09if((read(datafd, info, sizeof info)) =3D=3D 12) +=09=09=09disp->dpi =3D atoi(info); +=09} =09return disp; } -- 2nd Patch for plan9.ini: diff c7dcc82b0be805717efbe77c98eaadf3ee1e31af uncommitted --- a/sys/man/8/plan9.ini +++ b/sys/man/8/plan9.ini @@ -971,6 +971,8 @@ .BR off . The first two specify differing levels of power saving; the third turns the monitor off completely. +.SS \fL*dpi=3D\fIvalue\fP +This is used to specify the screen dpi. .SS NVRAM .SS \fLnvram=3D\fIfile\fP .SS \fLnvrlen=3D\fIlength\fP --- a/sys/src/9/port/devdraw.c +++ b/sys/src/9/port/devdraw.c @@ -765,6 +765,7 @@ drawnewclient(void) { =09Client *cl, **cp; +=09char *p; =09int i; =09for(i=3D0; islot =3D i; =09cl->clientid =3D ++sdraw.clientid; =09cl->op =3D SoverD; -=09cl->displaydpi=3D100; +=09if((p =3D getconf("dpi")) =3D=3D nil || (cl->displaydpi =3D atoi(p)) = =3D=3D 0){ +=09=09cl->displaydpi=3D100; +=09} =09sdraw.client[i] =3D cl; =09return cl; } -- 3rd Patch for rio/acme (proof-of-concept, just to provide an example) diff 75d8e460a00505c2b21a0d06ceb4300c93d9c4d6 uncommitted --- a/sys/include/ape/draw.h +++ b/sys/include/ape/draw.h @@ -69,6 +69,7 @@ =09Displaybufsize=09=3D 8000, =09ICOSSCALE=09=3D 1024, =09Borderwidth =3D=094, +=09DefaultDPI =3D=09100, }; enum @@ -358,6 +359,7 @@ extern Image*=09namedimage(Display*, char*); extern int=09nameimage(Image*, char*, int); extern Image* allocimagemix(Display*, ulong, ulong); +extern int scalesize(Display*, int); /* * Colors --- a/sys/include/draw.h +++ b/sys/include/draw.h @@ -61,6 +61,7 @@ =09Displaybufsize=09=3D 8000, =09ICOSSCALE=09=3D 1024, =09Borderwidth =3D=094, +=09DefaultDPI =3D=09100, }; enum @@ -354,6 +355,7 @@ extern Image*=09namedimage(Display*, char*); extern int=09nameimage(Image*, char*, int); extern Image* allocimagemix(Display*, ulong, ulong); +extern int scalesize(Display*, int); /* * Colors --- a/sys/src/cmd/acme/dat.h +++ b/sys/src/cmd/acme/dat.h @@ -473,11 +473,14 @@ =09BUFSIZE =3D Maxblock+IOHDRSZ,=09/* size from fbufalloc() */ =09RBUFSIZE =3D BUFSIZE/sizeof(Rune), =09EVENTSIZE =3D 256, -=09Scrollwid =3D 12,=09/* width of scroll bar */ -=09Scrollgap =3D 4,=09/* gap right of scroll bar */ -=09Margin =3D 4,=09/* margin around text */ -=09Border =3D 2,=09/* line between rows, cols, windows */ }; + +// like in p9p c96d832 +#define Scrollwid scalesize(display, 12)=09/* width of scroll bar */ +#define Scrollgap scalesize(display, 4)=09/* gap right of scroll bar */ +#define Margin scalesize(display, 4)=09/* margin around text */ +#define Border scalesize(display, 2)=09/* line between rows, cols, windows= */ +#define ButtonBorder scalesize(display, 2) #define=09QID(w,q)=09((w<<8)|(q)) #define=09WIN(q)=09((((ulong)(q).path)>>8) & 0xFFFFFF) --- a/sys/src/cmd/rio/wind.c +++ b/sys/src/cmd/rio/wind.c @@ -12,6 +12,14 @@ #include "dat.h" #include "fns.h" +static int +wscale(Window *w, int n) +{ + if(w =3D=3D nil || w->i =3D=3D nil) + return n; + return scalesize(w->i->display, n); +} + Window* wlookid(int id) { @@ -308,7 +316,7 @@ =09=09else =09=09=09col =3D lighttitlecol; =09} -=09border(w->i, w->i->r, Selborder, col, ZP); +=09border(w->i, w->i->r, wscale(w, Selborder), col, ZP); } static void @@ -353,17 +361,17 @@ =09w->i =3D i; =09w->mc.image =3D i; -=09r =3D insetrect(i->r, Selborder+1); +=09r =3D insetrect(i->r, wscale(w, Selborder)+wscale(w, 1)); =09w->scrollr =3D r; -=09w->scrollr.max.x =3D r.min.x+Scrollwid; +=09w->scrollr.max.x =3D r.min.x+wscale(w, Scrollwid); =09w->lastsr =3D ZR; -=09r.min.x +=3D Scrollwid+Scrollgap; +=09r.min.x +=3D wscale(w, Scrollwid)+wscale(w, Scrollgap); =09frclear(w, FALSE); =09frinit(w, r, w->font, w->i, cols); =09wsetcols(w, w =3D=3D input); =09w->maxtab =3D maxtab*stringwidth(w->font, "0"); =09if(!w->mouseopen || !w->winnameread){ -=09=09r =3D insetrect(w->i->r, Selborder); +=09=09r =3D insetrect(w->i->r, wscale(w, Selborder)); =09=09draw(w->i, r, cols[BACK], nil, w->entire.min); =09=09wfill(w); =09=09wsetselect(w, w->q0, w->q1); @@ -370,7 +378,7 @@ =09=09wscrdraw(w); =09} =09if(w =3D=3D input) -=09=09wborder(w, Selborder); +=09=09wborder(w, wscale(w, Selborder)); =09else =09=09wborder(w, Unselborder); =09flushimage(display, 1); @@ -390,9 +398,9 @@ =09if(!w->mouseopen || !w->winnameread) =09=09frredraw(w); =09if(w =3D=3D input) -=09=09wborder(w, Selborder); +=09=09wborder(w, wscale(w, Selborder)); =09else -=09=09wborder(w, Unselborder); +=09=09wborder(w, wscale(w, Unselborder)); } static void @@ -401,9 +409,9 @@ =09Rectangle r; =09if(w =3D=3D input) -=09=09wborder(w, Selborder); +=09=09wborder(w, wscale(w, Selborder)); =09else -=09=09wborder(w, Unselborder); +=09=09wborder(w, wscale(w, Unselborder)); =09r =3D insetrect(w->i->r, Selborder); =09draw(w->i, r, w->cols[BACK], nil, w->entire.min); =09wfill(w); @@ -1249,7 +1257,7 @@ =09w =3D emalloc(sizeof(Window)); =09w->screenr =3D i->r; -=09r =3D insetrect(i->r, Selborder+1); +=09r =3D insetrect(i->r, wscale(w, Selborder)+wscale(w, 1)); =09w->i =3D i; =09w->mc =3D *mc; =09w->ck =3D ck; @@ -1263,9 +1271,9 @@ =09w->complete =3D chancreate(sizeof(Completion*), 0); =09w->gone =3D chancreate(sizeof(char*), 0); =09w->scrollr =3D r; -=09w->scrollr.max.x =3D r.min.x+Scrollwid; +=09w->scrollr.max.x =3D r.min.x+wscale(w, Scrollwid); =09w->lastsr =3D ZR; -=09r.min.x +=3D Scrollwid+Scrollgap; +=09r.min.x +=3D wscale(w, Scrollwid)+wscale(w, Scrollgap); =09frinit(w, r, font, i, cols); =09w->maxtab =3D maxtab*stringwidth(font, "0"); =09w->topped =3D ++topped; @@ -1274,9 +1282,9 @@ =09w->scrolling =3D scrolling; =09w->dir =3D estrdup(startdir); =09w->label =3D estrdup(""); -=09r =3D insetrect(w->i->r, Selborder); +=09r =3D insetrect(w->i->r, wscale(w, Selborder)); =09draw(w->i, r, cols[BACK], nil, w->entire.min); -=09wborder(w, Selborder); +=09wborder(w, wscale(w, Selborder)); =09wscrdraw(w); =09incref(w);=09/* ref will be removed after mounting; avoids delete befor= e ready to be deleted */ =09return w; --- a/sys/src/libdraw/init.c +++ b/sys/src/libdraw/init.c @@ -452,5 +465,13 @@ =09p =3D d->bufp; =09d->bufp +=3D n; =09return p; +} + +int +scalesize(Display *d, int n) +{ +=09if(d =3D=3D nil || d->dpi <=3D DefaultDPI) +=09=09return n; +=09return (n*d->dpi+DefaultDPI/2)/DefaultDPI; } -- 4th Patch (drawterm-metal-cocoa - I've been using this most of the time): diff 0b7990cf2b84e7a80cf3f3a9e7eadca10d51a2c5 uncommitted --- a/include/draw.h +++ b/include/draw.h @@ -193,6 +193,7 @@ =09Image=09=09*windows; =09Image=09=09*screenimage; =09int=09=09_isnewdisplay; +=09int=09=09dpi; }; struct Image --- a/kern/devdraw.c +++ b/kern/devdraw.c @@ -76,6 +76,8 @@ =09int=09=09refreshme; =09int=09=09infoid; =09int=09=09op; +=09int=09=09displaydpi; +=09int=09=09forcedpi; }; struct Refresh @@ -166,6 +168,8 @@ =09Client*=09=09drawclientofpath(ulong); =09DImage*=09allocdimage(Memimage*); +int displaydpi =3D 200; + static=09char Enodrawimage[] =3D=09"unknown id for draw image"; static=09char Enodrawscreen[] =3D=09"unknown id for draw screen"; static=09char Eshortdraw[] =3D=09"short draw message"; @@ -783,6 +787,7 @@ =09cl->slot =3D i; =09cl->clientid =3D ++sdraw.clientid; =09cl->op =3D SoverD; +=09cl->displaydpi =3D displaydpi; =09sdraw.client[i] =3D cl; =09return cl; } @@ -1408,6 +1413,7 @@ =09int c, repl, m, y, dstid, scrnid, ni, ci, j, nw, e0, e1, op, ox, oy, oe= size, esize, doflush; =09uchar *u, *a, refresh; =09char *fmt; +=09Fmt f; =09ulong value, chan; =09Rectangle r, clipr; =09Point p, q, *pp, sp; @@ -1654,6 +1660,34 @@ =09=09=09memset(font->fchar, 0, ni*sizeof(FChar)); =09=09=09font->nfchar =3D ni; =09=09=09font->ascent =3D a[9]; +=09=09=09continue; + +=09=09/* query: 'Q' n[1] queryspec[n] */ +=09=09case 'q': +=09=09=09if(n < 2) +=09=09=09=09error(Eshortdraw); +=09=09=09m =3D 1+1+a[1]; +=09=09=09if(n < m) +=09=09=09=09error(Eshortdraw); +=09=09=09fmtstrinit(&f); +=09=09=09for(c=3D0; cforcedpi) +=09=09=09=09=09=09fmtprint(&f, "%11d ", client->forcedpi); +=09=09=09=09=09else { +=09=09=09=09=09=09fmtprint(&f, "%11d ", client->displaydpi); +=09=09=09=09=09} +=09=09=09=09=09break; +=09=09=09=09} +=09=09=09} +=09=09=09client->readdata =3D (uchar*)fmtstrflush(&f); +=09=09=09if(client->readdata =3D=3D nil) +=09=09=09=09error(Enomem); +=09=09=09client->nreaddata =3D strlen((char*)client->readdata); =09=09=09continue; =09=09/* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] lef= t[1] width[1] */