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=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13282 invoked from network); 20 Dec 2021 19:07:34 -0000 Received: from 4ess.inri.net (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 20 Dec 2021 19:07:34 -0000 Received: from mail-ua1-f43.google.com ([209.85.222.43]) by 4ess; Mon Dec 20 13:28:40 -0500 2021 Received: by mail-ua1-f43.google.com with SMTP id 107so19238483uaj.10 for <9front@9front.org>; Mon, 20 Dec 2021 10:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=ORIvtWRZOpsRr1UtHiPbdriU6x0AJZ7Xxfl+BEI5V7M=; b=a9z7iVeAacV7ucQ6op1d7R6DAAzmxhB7k1oZOe9NAjb6Uz8trrobpqHYGA9Zpll/b+ uH/FNdqDwWAh+qYT132PsLYNgzfMb4zzlx97WGK8EBhIw4rPa382LKWMDuCqjKE7Zp/V GkBIlZJiiVTvDnCFZ887fDzs2UrgeLFb5tH0sla7nMKkP4LY8Ccoq76rLVMuUXaYqfMP uJy8yr70QEWlZ59h8kLhuVea0cHsphuSZm29On7JNGYEuu1sUWcVx90DUoSundiP3DHR xb9efTp3pMb0KhxVX+w8JxwLJn6ramzywKjpdq4hvr9YffvQlqXDs7TtJaNtaPhrZrms Cjgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=ORIvtWRZOpsRr1UtHiPbdriU6x0AJZ7Xxfl+BEI5V7M=; b=4kKSe8R08D00lbEwhhN5fePEvSXhoQfQSTR39FLYT+lsz1SgIUhTCpecjODLwP0U/5 pVrD+ejXwzQ+q0wktCDh+2LcLPXEoOTN+Ikwf6ma6ucoaVaXZn3tNau1IO9EGDsVXtdj OVpSTS0cstYphR22XWvHvWZkmUlxYrRUOeftTxMz/Fq8us94+zHEqPhqPhyy/okq/xbi +Pr6YJigAkMpqhJ5V+l6g72ZNniuOuo4j16++Ks8Ym60y045fyh2E52wJbDbI5awCmS1 lEWgobnUNbxF/gM0CEgF+xJKlDCUoWPfO6+GO6TiMsfA+1JQH65z9C5KiTT4ukBj4dhh CwMw== X-Gm-Message-State: AOAM5332xRlh4JUaro9oZGJioA+blgSVQuud+8EcCULQoFXGlJjXIZ8H kBSwlr1j36w3Ca3NI4Teit2Os3vxcwfgnhIMcgxLBWIUz8M= X-Google-Smtp-Source: ABdhPJz5xbvWnB8GOu+YK38tfbQcNc69aYJLusv7EeQ3HOOzwymkvJ3o7BniwzAC+cdA54uy2BLljsd1eCnPWgUvuuM= X-Received: by 2002:a67:fe49:: with SMTP id m9mr1027061vsr.32.1640024913206; Mon, 20 Dec 2021 10:28:33 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a59:ab8c:0:b0:248:ba1c:c015 with HTTP; Mon, 20 Dec 2021 10:28:32 -0800 (PST) In-Reply-To: <4828C18115F30E3A05899AE665C7651F@9lab.org> References: <4828C18115F30E3A05899AE665C7651F@9lab.org> From: hiro <23hiro@gmail.com> Date: Mon, 20 Dec 2021 19:28:32 +0100 Message-ID: To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: managed RESTful realtime-java map/reduce-scale optimizer Subject: Re: [9front] hidpi Reply-To: 9front@9front.org Precedence: bulk Yeah this links to a relevant discussion that shows how the code considers only macos. The idea was that linux users should just send a patch. But this doesn't solve the issue that even if the hardware reports the correct dpi to the computer, and the OS correctly forwards this information to graphical clients, and drawterm implements this interface, we still don't know the user's actual need of scale. Due to variable distance to the screen and variable quality of user's eyes, the hardware reporting of DPI becomes quite irrelevant. So for simplicity I propose devdraw and thus drawterm does *not* get an interface. On 12/20/21, igor@9lab.org wrote: > Hi Philip, > > This reminds me of a plan9port feature to change DPI (useful > on a high res display, e.g. Retina display). Are you trying > to achieve something similar as this: > > =E2=80=A2 https://groups.google.com/g/plan9port-dev/c/rXtpIufTrbM > =E2=80=A2 > https://github.com/9fans/plan9port/blob/master/src/cmd/devdraw/devdraw.c#= L976 > > Cheers, > Igor > > Quoth Philip Silva : >> I've been creating patches to enable hidpi to make scrollbars bigger whe= n >> using > 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 4th 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 th= e >> 1st 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 a= nd >> acme is very wip) >> - despite the glitches it works reasonably well with acme and rio but so= me >> 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 @@ >> Image *windows; >> Image *screenimage; >> int _isnewdisplay; >> + int dpi; >> }; >> >> struct Image >> --- a/sys/include/draw.h >> +++ b/sys/include/draw.h >> @@ -200,6 +200,7 @@ >> Image *windows; >> Image *screenimage; >> int _isnewdisplay; >> + int dpi; >> }; >> >> struct Image >> --- a/sys/src/9/port/devdraw.c >> +++ b/sys/src/9/port/devdraw.c >> @@ -77,6 +77,8 @@ >> int refreshme; >> int infoid; >> int op; >> + int displaydpi; >> + int forcedpi; >> }; >> >> struct Refresh >> @@ -785,6 +789,7 @@ >> cl->slot =3D i; >> cl->clientid =3D ++sdraw.clientid; >> cl->op =3D SoverD; >> + cl->displaydpi=3D100; >> sdraw.client[i] =3D cl; >> return cl; >> } >> @@ -1396,6 +1401,7 @@ >> int c, repl, m, y, dstid, scrnid, ni, ci, j, nw, e0, e1, op, ox, oy, >> oesize, esize, doflush; >> uchar *u, *a, refresh; >> char *fmt; >> + Fmt f; >> ulong value, chan; >> Rectangle r, clipr; >> Point p, q, *pp, sp; >> @@ -1643,6 +1649,35 @@ >> font->nfchar =3D ni; >> font->ascent =3D a[9]; >> continue; >> + >> + /* query: 'Q' n[1] queryspec[n] */ >> + case 'q': >> + if(n < 2){ >> + error(Eshortdraw); >> + } >> + m =3D 1+1+a[1]; >> + if(n < m){ >> + error(Eshortdraw); >> + } >> + fmtstrinit(&f); >> + for(c=3D0; c> + switch(a[2+c]){ >> + default: >> + error("unknown query"); >> + case 'd': /* dpi */ >> + if(client->forcedpi) >> + fmtprint(&f, "%11d ", client->forcedpi); >> + else >> + fmtprint(&f, "%11d ", client->displaydpi); >> + break; >> + } >> + } >> + client->readdata =3D (uchar*)fmtstrflush(&f); >> + if(client->readdata =3D=3D nil) >> + error(Enomem); >> + client->nreaddata =3D strlen((char*)client->readdata); >> + continue; >> + >> >> /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] >> left[1] width[1] */ >> case '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*)) >> { >> + uchar *a; >> char buf[128], info[NINFO+1], *t, isnew; >> int n, datafd, ctlfd, reffd; >> Display *disp; >> @@ -319,6 +320,18 @@ >> if(dir!=3Dnil && dir->qid.vers=3D=3D1) /* other way to tell */ >> disp->_isnewdisplay =3D 1; >> free(dir); >> + >> + a =3D bufimage(disp, 3); >> + if(a =3D=3D nil) >> + goto Error5; >> + a[0] =3D 'q'; >> + a[1] =3D 1; >> + a[2] =3D 'd'; >> + disp->dpi =3D 100; >> + if(flushimage(disp, 0) >=3D 0){ >> + if((read(datafd, info, sizeof info)) =3D=3D 12) >> + disp->dpi =3D atoi(info); >> + } >> >> return 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) >> { >> Client *cl, **cp; >> + char *p; >> int i; >> >> for(i=3D0; i> @@ -789,7 +790,9 @@ >> cl->slot =3D i; >> cl->clientid =3D ++sdraw.clientid; >> cl->op =3D SoverD; >> - cl->displaydpi=3D100; >> + if((p =3D getconf("dpi")) =3D=3D nil || (cl->displaydpi =3D atoi(p)) = =3D=3D 0){ >> + cl->displaydpi=3D100; >> + } >> sdraw.client[i] =3D cl; >> return 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 @@ >> Displaybufsize =3D 8000, >> ICOSSCALE =3D 1024, >> Borderwidth =3D 4, >> + DefaultDPI =3D 100, >> }; >> >> enum >> @@ -358,6 +359,7 @@ >> extern Image* namedimage(Display*, char*); >> extern int nameimage(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 @@ >> Displaybufsize =3D 8000, >> ICOSSCALE =3D 1024, >> Borderwidth =3D 4, >> + DefaultDPI =3D 100, >> }; >> >> enum >> @@ -354,6 +355,7 @@ >> extern Image* namedimage(Display*, char*); >> extern int nameimage(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 @@ >> BUFSIZE =3D Maxblock+IOHDRSZ, /* size from fbufalloc() */ >> RBUFSIZE =3D BUFSIZE/sizeof(Rune), >> EVENTSIZE =3D 256, >> - Scrollwid =3D 12, /* width of scroll bar */ >> - Scrollgap =3D 4, /* gap right of scroll bar */ >> - Margin =3D 4, /* margin around text */ >> - Border =3D 2, /* line between rows, cols, windows */ >> }; >> + >> +// like in p9p c96d832 >> +#define Scrollwid scalesize(display, 12) /* width of scroll bar */ >> +#define Scrollgap scalesize(display, 4) /* gap right of scroll bar */ >> +#define Margin scalesize(display, 4) /* margin around text */ >> +#define Border scalesize(display, 2) /* line between rows, cols, window= s >> */ >> +#define ButtonBorder scalesize(display, 2) >> >> #define QID(w,q) ((w<<8)|(q)) >> #define WIN(q) ((((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 @@ >> else >> col =3D lighttitlecol; >> } >> - border(w->i, w->i->r, Selborder, col, ZP); >> + border(w->i, w->i->r, wscale(w, Selborder), col, ZP); >> } >> >> static void >> @@ -353,17 +361,17 @@ >> >> w->i =3D i; >> w->mc.image =3D i; >> - r =3D insetrect(i->r, Selborder+1); >> + r =3D insetrect(i->r, wscale(w, Selborder)+wscale(w, 1)); >> w->scrollr =3D r; >> - w->scrollr.max.x =3D r.min.x+Scrollwid; >> + w->scrollr.max.x =3D r.min.x+wscale(w, Scrollwid); >> w->lastsr =3D ZR; >> - r.min.x +=3D Scrollwid+Scrollgap; >> + r.min.x +=3D wscale(w, Scrollwid)+wscale(w, Scrollgap); >> frclear(w, FALSE); >> frinit(w, r, w->font, w->i, cols); >> wsetcols(w, w =3D=3D input); >> w->maxtab =3D maxtab*stringwidth(w->font, "0"); >> if(!w->mouseopen || !w->winnameread){ >> - r =3D insetrect(w->i->r, Selborder); >> + r =3D insetrect(w->i->r, wscale(w, Selborder)); >> draw(w->i, r, cols[BACK], nil, w->entire.min); >> wfill(w); >> wsetselect(w, w->q0, w->q1); >> @@ -370,7 +378,7 @@ >> wscrdraw(w); >> } >> if(w =3D=3D input) >> - wborder(w, Selborder); >> + wborder(w, wscale(w, Selborder)); >> else >> wborder(w, Unselborder); >> flushimage(display, 1); >> @@ -390,9 +398,9 @@ >> if(!w->mouseopen || !w->winnameread) >> frredraw(w); >> if(w =3D=3D input) >> - wborder(w, Selborder); >> + wborder(w, wscale(w, Selborder)); >> else >> - wborder(w, Unselborder); >> + wborder(w, wscale(w, Unselborder)); >> } >> >> static void >> @@ -401,9 +409,9 @@ >> Rectangle r; >> >> if(w =3D=3D input) >> - wborder(w, Selborder); >> + wborder(w, wscale(w, Selborder)); >> else >> - wborder(w, Unselborder); >> + wborder(w, wscale(w, Unselborder)); >> r =3D insetrect(w->i->r, Selborder); >> draw(w->i, r, w->cols[BACK], nil, w->entire.min); >> wfill(w); >> @@ -1249,7 +1257,7 @@ >> >> w =3D emalloc(sizeof(Window)); >> w->screenr =3D i->r; >> - r =3D insetrect(i->r, Selborder+1); >> + r =3D insetrect(i->r, wscale(w, Selborder)+wscale(w, 1)); >> w->i =3D i; >> w->mc =3D *mc; >> w->ck =3D ck; >> @@ -1263,9 +1271,9 @@ >> w->complete =3D chancreate(sizeof(Completion*), 0); >> w->gone =3D chancreate(sizeof(char*), 0); >> w->scrollr =3D r; >> - w->scrollr.max.x =3D r.min.x+Scrollwid; >> + w->scrollr.max.x =3D r.min.x+wscale(w, Scrollwid); >> w->lastsr =3D ZR; >> - r.min.x +=3D Scrollwid+Scrollgap; >> + r.min.x +=3D wscale(w, Scrollwid)+wscale(w, Scrollgap); >> frinit(w, r, font, i, cols); >> w->maxtab =3D maxtab*stringwidth(font, "0"); >> w->topped =3D ++topped; >> @@ -1274,9 +1282,9 @@ >> w->scrolling =3D scrolling; >> w->dir =3D estrdup(startdir); >> w->label =3D estrdup(""); >> - r =3D insetrect(w->i->r, Selborder); >> + r =3D insetrect(w->i->r, wscale(w, Selborder)); >> draw(w->i, r, cols[BACK], nil, w->entire.min); >> - wborder(w, Selborder); >> + wborder(w, wscale(w, Selborder)); >> wscrdraw(w); >> incref(w); /* ref will be removed after mounting; avoids delete before >> ready to be deleted */ >> return w; >> --- a/sys/src/libdraw/init.c >> +++ b/sys/src/libdraw/init.c >> @@ -452,5 +465,13 @@ >> p =3D d->bufp; >> d->bufp +=3D n; >> return p; >> +} >> + >> +int >> +scalesize(Display *d, int n) >> +{ >> + if(d =3D=3D nil || d->dpi <=3D DefaultDPI) >> + return n; >> + return (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 @@ >> Image *windows; >> Image *screenimage; >> int _isnewdisplay; >> + int dpi; >> }; >> >> struct Image >> --- a/kern/devdraw.c >> +++ b/kern/devdraw.c >> @@ -76,6 +76,8 @@ >> int refreshme; >> int infoid; >> int op; >> + int displaydpi; >> + int forcedpi; >> }; >> >> struct Refresh >> @@ -166,6 +168,8 @@ >> Client* drawclientofpath(ulong); >> DImage* allocdimage(Memimage*); >> >> +int displaydpi =3D 200; >> + >> static char Enodrawimage[] =3D "unknown id for draw image"; >> static char Enodrawscreen[] =3D "unknown id for draw screen"; >> static char Eshortdraw[] =3D "short draw message"; >> @@ -783,6 +787,7 @@ >> cl->slot =3D i; >> cl->clientid =3D ++sdraw.clientid; >> cl->op =3D SoverD; >> + cl->displaydpi =3D displaydpi; >> sdraw.client[i] =3D cl; >> return cl; >> } >> @@ -1408,6 +1413,7 @@ >> int c, repl, m, y, dstid, scrnid, ni, ci, j, nw, e0, e1, op, ox, oy, >> oesize, esize, doflush; >> uchar *u, *a, refresh; >> char *fmt; >> + Fmt f; >> ulong value, chan; >> Rectangle r, clipr; >> Point p, q, *pp, sp; >> @@ -1654,6 +1660,34 @@ >> memset(font->fchar, 0, ni*sizeof(FChar)); >> font->nfchar =3D ni; >> font->ascent =3D a[9]; >> + continue; >> + >> + /* query: 'Q' n[1] queryspec[n] */ >> + case 'q': >> + if(n < 2) >> + error(Eshortdraw); >> + m =3D 1+1+a[1]; >> + if(n < m) >> + error(Eshortdraw); >> + fmtstrinit(&f); >> + for(c=3D0; c> + switch(a[2+c]){ >> + default: >> + error("unknown query"); >> + break; >> + case 'd': /* dpi */ >> + if(client->forcedpi) >> + fmtprint(&f, "%11d ", client->forcedpi); >> + else { >> + fmtprint(&f, "%11d ", client->displaydpi); >> + } >> + break; >> + } >> + } >> + client->readdata =3D (uchar*)fmtstrflush(&f); >> + if(client->readdata =3D=3D nil) >> + error(Enomem); >> + client->nreaddata =3D strlen((char*)client->readdata); >> continue; >> >> /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] >> left[1] width[1] */ >> >> > >