diff options
author | David Jeannot <djeannot24@gmail.com> | 2012-03-05 15:38:59 -0500 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2012-03-05 15:38:59 -0500 |
commit | 7e2a1983e7f39ce6fca05706959d0ea4a9f6961b (patch) | |
tree | 379ddd9e8b580268a440da69bd9fb3a147741b70 | |
parent | 354c6c32f14f723022eacdfc965b0c9857e787f4 (diff) | |
download | plan9port-7e2a1983e7f39ce6fca05706959d0ea4a9f6961b.tar.gz plan9port-7e2a1983e7f39ce6fca05706959d0ea4a9f6961b.tar.bz2 plan9port-7e2a1983e7f39ce6fca05706959d0ea4a9f6961b.zip |
devdraw: fix winsize (-W) on OS X
R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/5749043
-rw-r--r-- | src/cmd/devdraw/cocoa-screen.m | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index bf2d0fdc..3f2bcb8b 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -237,6 +237,12 @@ attachscreen(char *label, char *winsize) } @end +double +min(double a, double b) +{ + return a<b? a : b; +} + enum { Winstyle = NSTitledWindowMask @@ -254,6 +260,7 @@ makewin(char *s) int i, set; sr = [[NSScreen mainScreen] frame]; + r = [[NSScreen mainScreen] visibleFrame]; if(s && *s){ if(parsewinsize(s, &wr, &set) < 0) @@ -263,11 +270,10 @@ makewin(char *s) set = 0; } - /* - * The origin is the left bottom corner for Cocoa. - */ - r.origin.y = sr.size.height-wr.max.y; - r = NSMakeRect(wr.min.x, r.origin.y, Dx(wr), Dy(wr)); + r.origin.x = wr.min.x; + r.origin.y = sr.size.height-wr.max.y; /* winsize is top-left-based */ + r.size.width = min(Dx(wr), r.size.width); + r.size.height = min(Dy(wr), r.size.height); r = [NSWindow contentRectForFrameRect:r styleMask:Winstyle]; |