From 55905845f3eeb3756f532484f1fd313b0ab2ca2a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 25 Nov 2012 23:38:14 -0500 Subject: devdraw: add forcedpi toggled by Fn+F3 on Mac R=rsc http://codereview.appspot.com/6846104 --- src/cmd/devdraw/cocoa-screen.m | 4 ++-- src/cmd/devdraw/cocoa-srv.c | 12 ++++++++++++ src/cmd/devdraw/devdraw.c | 6 +++++- src/cmd/devdraw/devdraw.h | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index a2ff3d40..c6389e9b 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -399,8 +399,8 @@ initimg(void) return i; } -static void -resizeimg() +void +resizeimg(void) { [win.img release]; _drawreplacescreenimage(initimg()); diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index 864aed7a..810d3150 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -367,6 +367,8 @@ abortcompose(void) keystroke(Kalt); } +void resizeimg(void); + void keystroke(int c) { @@ -379,6 +381,16 @@ keystroke(int c) nk = 0; return; } + if(c == KF+3) { + if(forcedpi) + forcedpi = 0; + else if(displaydpi >= 200) + forcedpi = 100; + else + forcedpi = 225; + resizeimg(); + return; + } if(!alting){ kputc(c); return; diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 3fabd34e..2e3fd7a0 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -11,6 +11,7 @@ #include "devdraw.h" extern void _flushmemscreen(Rectangle); +int forcedpi = 0; int displaydpi = 100; #define NHASH (1<<5) @@ -1101,7 +1102,10 @@ _drawmsgwrite(void *v, int n) err = "unknown query"; goto error; case 'd': /* dpi */ - fmtprint(&fmt, "%11d ", displaydpi); + if(forcedpi) + fmtprint(&fmt, "%11d ", forcedpi); + else + fmtprint(&fmt, "%11d ", displaydpi); break; } } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 454cfe03..f768735f 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -7,3 +7,4 @@ int mouseswap(int); void abortcompose(void); extern int displaydpi; +extern int forcedpi; -- cgit v1.2.3