9term, mc: conspire to handle hidpi displays
9term now uses the low bit of ws.ws_ypixel to signal whether this is a hidpi display, and mc adjusts the font it uses for columnation accordingly. Makes 'lc' work right on hidpi displays. Change-Id: I52928871ffb7f4c6fd6722f3d59f1836379148c6 Reviewed-on: https://plan9port-review.googlesource.com/2760 Reviewed-by: Russ Cox <rsc@swtch.com>
This commit is contained in:
parent
657f699ef7
commit
d296c18e37
2 changed files with 26 additions and 1 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
#include <draw.h>
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
|
|
||||||
#define debug 0
|
#define debug 0
|
||||||
|
|
@ -75,7 +76,14 @@ updatewinsize(int row, int col, int dx, int dy)
|
||||||
ws.ws_row = row;
|
ws.ws_row = row;
|
||||||
ws.ws_col = col;
|
ws.ws_col = col;
|
||||||
ws.ws_xpixel = dx;
|
ws.ws_xpixel = dx;
|
||||||
|
|
||||||
|
|
||||||
|
// Leave "is this a hidpi display" in the low bit of the ypixel height for mc.
|
||||||
|
dy &= ~1;
|
||||||
|
if(display->dpi >= DefaultDPI*3/2)
|
||||||
|
dy |= 1;
|
||||||
ws.ws_ypixel = dy;
|
ws.ws_ypixel = dy;
|
||||||
|
|
||||||
if(ws.ws_row != ows.ws_row || ws.ws_col != ows.ws_col){
|
if(ws.ws_row != ows.ws_row || ws.ws_col != ows.ws_col){
|
||||||
if(ioctl(rcfd, TIOCSWINSZ, &ws) < 0)
|
if(ioctl(rcfd, TIOCSWINSZ, &ws) < 0)
|
||||||
fprint(2, "ioctl: %r\n");
|
fprint(2, "ioctl: %r\n");
|
||||||
|
|
|
||||||
|
|
@ -268,9 +268,10 @@ void
|
||||||
getwidth(void)
|
getwidth(void)
|
||||||
{
|
{
|
||||||
CFsys *fs;
|
CFsys *fs;
|
||||||
char buf[500], *p, *f[10];
|
char buf[500], *p, *q, *f[10];
|
||||||
int fd, n, nf;
|
int fd, n, nf;
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
|
Font *f1;
|
||||||
|
|
||||||
if((p = getenv("winid")) != nil){
|
if((p = getenv("winid")) != nil){
|
||||||
fs = nsmount("acme", "");
|
fs = nsmount("acme", "");
|
||||||
|
|
@ -306,6 +307,22 @@ getwidth(void)
|
||||||
if(ws.ws_xpixel == 0)
|
if(ws.ws_xpixel == 0)
|
||||||
font = nil;
|
font = nil;
|
||||||
if(font){
|
if(font){
|
||||||
|
// 9term leaves "is this a hidpi display" in the low bit of the ypixel height.
|
||||||
|
if(ws.ws_ypixel&1) {
|
||||||
|
// need hidpi font.
|
||||||
|
// loadhifpi creates a font that crashes in stringwidth,
|
||||||
|
// for reasons i don't understand.
|
||||||
|
// do it ourselves
|
||||||
|
p = getenv("font");
|
||||||
|
q = strchr(p, ',');
|
||||||
|
f1 = nil;
|
||||||
|
if(q != nil)
|
||||||
|
f1 = openfont(nil, q+1);
|
||||||
|
if(f1 != nil)
|
||||||
|
font = f1;
|
||||||
|
else
|
||||||
|
ws.ws_xpixel /= 2;
|
||||||
|
}
|
||||||
mintab = stringwidth(font, "0");
|
mintab = stringwidth(font, "0");
|
||||||
if((p = getenv("tabstop")) != nil)
|
if((p = getenv("tabstop")) != nil)
|
||||||
tabwid = atoi(p)*mintab;
|
tabwid = atoi(p)*mintab;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue