aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/devdraw
diff options
context:
space:
mode:
authorDavid Jeannot <djeannot24@gmail.com>2012-01-19 15:14:17 -0500
committerRuss Cox <rsc@swtch.com>2012-01-19 15:14:17 -0500
commitfcce05982b4a611d20f05978fbb0819e6163785d (patch)
treeb72f89ec5aed0292a2e7cb08416cf5e2532cffd2 /src/cmd/devdraw
parent4464a8778de8a8d214548b7fe73da64c19b7a71c (diff)
downloadplan9port-fcce05982b4a611d20f05978fbb0819e6163785d.tar.gz
plan9port-fcce05982b4a611d20f05978fbb0819e6163785d.tar.bz2
plan9port-fcce05982b4a611d20f05978fbb0819e6163785d.zip
devdraw: make OS X resizer unobtrusive
R=rsc CC=plan9port.codebot http://codereview.appspot.com/5558051
Diffstat (limited to 'src/cmd/devdraw')
-rw-r--r--src/cmd/devdraw/cocoa-screen.m35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m
index c434c91f..0f37d715 100644
--- a/src/cmd/devdraw/cocoa-screen.m
+++ b/src/cmd/devdraw/cocoa-screen.m
@@ -118,6 +118,7 @@ static void makewin(char*);
static void sendmouse(void);
static void setcursor0(Cursor*);
static void togglefs(void);
+static void acceptresizing(int);
static NSCursor* makecursor(Cursor*);
@@ -163,6 +164,7 @@ static NSCursor* makecursor(Cursor*);
return YES;
}
- (void)applicationDidBecomeActive:(id)arg{ in.willactivate = 0;}
+- (void)windowWillEnterFullScreen:(id)arg{ acceptresizing(1);}
- (void)windowDidEnterFullScreen:(id)arg{ win.isnfs = 1; hidebars(1);}
- (void)windowWillExitFullScreen:(id)arg{ win.isnfs = 0; hidebars(0);}
- (void)windowDidExitFullScreen:(id)arg
@@ -678,19 +680,44 @@ updatecursor(void)
}
static void
+acceptresizing(int set)
+{
+ uint old, style;
+
+ old = [WIN styleMask];
+
+ if((old | NSResizableWindowMask) != Winstyle)
+ return; /* when entering new fullscreen */
+
+ if(set)
+ style = Winstyle;
+ else
+ style = Winstyle & ~NSResizableWindowMask;
+
+ if(style != old)
+ [WIN setStyleMask:style];
+}
+
+static void
getmousepos(void)
{
- NSPoint p;
+ NSPoint p, q;
p = [WIN mouseLocationOutsideOfEventStream];
- p = [win.content convertPoint:p fromView:nil];
- in.mpos.x = round(p.x);
- in.mpos.y = round(p.y);
+ q = [win.content convertPoint:p fromView:nil];
+ in.mpos.x = round(q.x);
+ in.mpos.y = round(q.y);
updatecursor();
if(win.isnfs || win.isofs)
hidebars(1);
+ else if(OSX_VERSION>=100700 && [WIN inLiveResize]==0){
+ if(p.x<12 && p.y<12 && p.x>2 && p.y>2)
+ acceptresizing(0);
+ else
+ acceptresizing(1);
+ }
}
static void