commit 8cb7983083a94e2bdedcd24ca4ba0ccbefcf61b8 from: Russ Cox date: Tue Jul 01 12:50:05 2008 UTC devdraw: add %F for fullscreen on OS X commit - b61a5ce81e17c77c4a8e9869f33d41f6facc6a9d commit + 8cb7983083a94e2bdedcd24ca4ba0ccbefcf61b8 blob - c8c05705618c9e4c29a054a74eefa459498f099a blob + b322fe00513338f108423aa3c183cb030bf9667b --- src/cmd/devdraw/osx-screen.c +++ src/cmd/devdraw/osx-screen.c @@ -3,8 +3,6 @@ #define Cursor OSXCursor #include #include // for full screen - - #undef Rect #undef Point #undef Cursor @@ -24,6 +22,9 @@ #include "devdraw.h" #include "glendapng.h" +AUTOFRAMEWORK(Carbon) +AUTOFRAMEWORK(QuickTime) + #define panic sysfatal extern Rectangle mouserect; @@ -36,7 +37,7 @@ struct { Rectangle screenr; Memimage *screenimage; int isfullscreen; - Rectangle nonfullscreenr; + ulong fullscreentime; Point xy; int buttons; @@ -63,7 +64,7 @@ enum static void screenproc(void*); static void eresized(int); -static void fullscreen(int); +static void fullscreen(void); static void seticon(void); static OSStatus quithandler(EventHandlerCallRef, EventRef, void*); @@ -255,7 +256,7 @@ eventhandler(EventHandlerCallRef next, EventRef event, exit(0); case CmdFullScreen: - fullscreen(1); + fullscreen(); break; default: @@ -414,9 +415,10 @@ kbdevent(EventRef event) case kEventRawKeyDown: case kEventRawKeyRepeat: if(mod == cmdKey){ - if(ch == 'F' && osx.isfullscreen){ - fullscreen(0); - break; + if(ch == 'F' || ch == 'f'){ + if(osx.isfullscreen && msec() - osx.fullscreentime > 500) + fullscreen(); + return noErr; } return eventNotHandledErr; } @@ -483,8 +485,10 @@ eresized(int new) CGDataProviderRelease(provider); // CGImageCreate did incref mouserect = m->r; - if(new) + if(new){ mouseresized = 1; + mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons, msec()); + } // termreplacescreenimage(m); _drawreplacescreenimage(m); // frees old osx.screenimage if any if(osx.image) @@ -517,8 +521,24 @@ _flushmemscreen(Rectangle r) } void -fullscreen(int x) +fullscreen(void) { + static Ptr restore; + static WindowRef oldwindow; + + if(osx.isfullscreen){ + EndFullScreen(restore, 0); + osx.window = oldwindow; + ShowWindow(osx.window); + osx.isfullscreen = 0; + }else{ + HideWindow(osx.window); + oldwindow = osx.window; + BeginFullScreen(&restore, 0, 0, 0, &osx.window, 0, 0); + osx.isfullscreen = 1; + osx.fullscreentime = msec(); + } + eresized(1); } void