devdraw: add %F for fullscreen on OS X
This commit is contained in:
parent
b61a5ce81e
commit
8cb7983083
1 changed files with 30 additions and 10 deletions
|
|
@ -3,8 +3,6 @@
|
||||||
#define Cursor OSXCursor
|
#define Cursor OSXCursor
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#include <QuickTime/QuickTime.h> // for full screen
|
#include <QuickTime/QuickTime.h> // for full screen
|
||||||
|
|
||||||
|
|
||||||
#undef Rect
|
#undef Rect
|
||||||
#undef Point
|
#undef Point
|
||||||
#undef Cursor
|
#undef Cursor
|
||||||
|
|
@ -24,6 +22,9 @@
|
||||||
#include "devdraw.h"
|
#include "devdraw.h"
|
||||||
#include "glendapng.h"
|
#include "glendapng.h"
|
||||||
|
|
||||||
|
AUTOFRAMEWORK(Carbon)
|
||||||
|
AUTOFRAMEWORK(QuickTime)
|
||||||
|
|
||||||
#define panic sysfatal
|
#define panic sysfatal
|
||||||
|
|
||||||
extern Rectangle mouserect;
|
extern Rectangle mouserect;
|
||||||
|
|
@ -36,7 +37,7 @@ struct {
|
||||||
Rectangle screenr;
|
Rectangle screenr;
|
||||||
Memimage *screenimage;
|
Memimage *screenimage;
|
||||||
int isfullscreen;
|
int isfullscreen;
|
||||||
Rectangle nonfullscreenr;
|
ulong fullscreentime;
|
||||||
|
|
||||||
Point xy;
|
Point xy;
|
||||||
int buttons;
|
int buttons;
|
||||||
|
|
@ -63,7 +64,7 @@ enum
|
||||||
|
|
||||||
static void screenproc(void*);
|
static void screenproc(void*);
|
||||||
static void eresized(int);
|
static void eresized(int);
|
||||||
static void fullscreen(int);
|
static void fullscreen(void);
|
||||||
static void seticon(void);
|
static void seticon(void);
|
||||||
|
|
||||||
static OSStatus quithandler(EventHandlerCallRef, EventRef, void*);
|
static OSStatus quithandler(EventHandlerCallRef, EventRef, void*);
|
||||||
|
|
@ -255,7 +256,7 @@ eventhandler(EventHandlerCallRef next, EventRef event, void *arg)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case CmdFullScreen:
|
case CmdFullScreen:
|
||||||
fullscreen(1);
|
fullscreen();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -414,9 +415,10 @@ kbdevent(EventRef event)
|
||||||
case kEventRawKeyDown:
|
case kEventRawKeyDown:
|
||||||
case kEventRawKeyRepeat:
|
case kEventRawKeyRepeat:
|
||||||
if(mod == cmdKey){
|
if(mod == cmdKey){
|
||||||
if(ch == 'F' && osx.isfullscreen){
|
if(ch == 'F' || ch == 'f'){
|
||||||
fullscreen(0);
|
if(osx.isfullscreen && msec() - osx.fullscreentime > 500)
|
||||||
break;
|
fullscreen();
|
||||||
|
return noErr;
|
||||||
}
|
}
|
||||||
return eventNotHandledErr;
|
return eventNotHandledErr;
|
||||||
}
|
}
|
||||||
|
|
@ -483,8 +485,10 @@ eresized(int new)
|
||||||
CGDataProviderRelease(provider); // CGImageCreate did incref
|
CGDataProviderRelease(provider); // CGImageCreate did incref
|
||||||
|
|
||||||
mouserect = m->r;
|
mouserect = m->r;
|
||||||
if(new)
|
if(new){
|
||||||
mouseresized = 1;
|
mouseresized = 1;
|
||||||
|
mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons, msec());
|
||||||
|
}
|
||||||
// termreplacescreenimage(m);
|
// termreplacescreenimage(m);
|
||||||
_drawreplacescreenimage(m); // frees old osx.screenimage if any
|
_drawreplacescreenimage(m); // frees old osx.screenimage if any
|
||||||
if(osx.image)
|
if(osx.image)
|
||||||
|
|
@ -517,8 +521,24 @@ _flushmemscreen(Rectangle r)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue