tdevdraw: make OS X resizer unobtrusive - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit fcce05982b4a611d20f05978fbb0819e6163785d
 (DIR) parent 4464a8778de8a8d214548b7fe73da64c19b7a71c
 (HTM) Author: David Jeannot <djeannot24@gmail.com>
       Date:   Thu, 19 Jan 2012 15:14:17 -0500
       
       devdraw: make OS X resizer unobtrusive
       
       R=rsc
       CC=plan9port.codebot
       http://codereview.appspot.com/5558051
       
       Diffstat:
         M src/cmd/devdraw/cocoa-screen.m      |      35 +++++++++++++++++++++++++++----
       
       1 file changed, 31 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m
       t@@ -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*);
        
       t@@ -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
       t@@ -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