|
|
|
@ -27,20 +27,18 @@
|
|
|
|
|
#include <AGL/agl.h>
|
|
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
|
|
|
|
|
|
|
|
|
////////////////////////// Global Objects .....
|
|
|
|
|
TypeHandle osxGraphicsWindow::_type_handle;
|
|
|
|
|
osxGraphicsWindow * osxGraphicsWindow::FullScreenWindow = NULL;
|
|
|
|
|
|
|
|
|
|
ButtonHandle OSX_TranslateKey( UInt32 key, EventRef event );
|
|
|
|
|
|
|
|
|
|
EventHandlerUPP gEvtHandler; // main event handler
|
|
|
|
|
EventHandlerUPP gWinEvtHandler; // window event handler
|
|
|
|
|
//AbsoluteTime gStartTime;
|
|
|
|
|
|
|
|
|
|
char gErrorMessage[256] = ""; // buffer for error message output
|
|
|
|
|
float gErrorTime = 0.0;
|
|
|
|
|
|
|
|
|
|
static osxGraphicsWindow * FullScreenWindow = NULL;
|
|
|
|
|
|
|
|
|
|
osxGraphicsWindow * GetCurrentOSxWindow (WindowRef window)
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: GetCurrentOSxWindow
|
|
|
|
|
// Access: Static,
|
|
|
|
|
// Description: How to find the active window for events on osx..
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
osxGraphicsWindow * osxGraphicsWindow::GetCurrentOSxWindow (WindowRef window)
|
|
|
|
|
{
|
|
|
|
|
if(FullScreenWindow != NULL)
|
|
|
|
|
return FullScreenWindow;
|
|
|
|
@ -53,8 +51,12 @@ osxGraphicsWindow * GetCurrentOSxWindow (WindowRef window)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: aglReportError
|
|
|
|
|
// Access: public
|
|
|
|
|
// Description: Helper function for AGL error message and Grabing error code if any
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
OSStatus aglReportError (void)
|
|
|
|
|
{
|
|
|
|
|
GLenum err = aglGetError();
|
|
|
|
@ -66,8 +68,13 @@ OSStatus aglReportError (void)
|
|
|
|
|
else
|
|
|
|
|
return (OSStatus) err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InvertGLImage( char *imageData, size_t imageSize, size_t rowBytes )
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: InvertGLImage
|
|
|
|
|
// Access: file scopre, static
|
|
|
|
|
// Description: Helper function invertiung a gl image
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
static void InvertGLImage( char *imageData, size_t imageSize, size_t rowBytes )
|
|
|
|
|
{
|
|
|
|
|
size_t i, j;
|
|
|
|
|
char *tBuffer = (char*) malloc (rowBytes);
|
|
|
|
@ -82,8 +89,13 @@ void InvertGLImage( char *imageData, size_t imageSize, size_t rowBytes )
|
|
|
|
|
free(tBuffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CompositeGLBufferIntoWindow (AGLContext ctx, Rect *bufferRect, GrafPtr out_port)
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: CompositeGLBufferIntoWindow
|
|
|
|
|
// Access: file scopre, static
|
|
|
|
|
// Description: Drop a Gl overlay onto a carbon window..
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
static void CompositeGLBufferIntoWindow (AGLContext ctx, Rect *bufferRect, GrafPtr out_port)
|
|
|
|
|
{
|
|
|
|
|
GWorldPtr pGWorld;
|
|
|
|
|
QDErr err;
|
|
|
|
@ -93,7 +105,6 @@ void CompositeGLBufferIntoWindow (AGLContext ctx, Rect *bufferRect, GrafPtr out_
|
|
|
|
|
long height = (bufferRect->bottom - bufferRect->top);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rect src_rect = {0, 0, height, width};
|
|
|
|
|
Rect ddrc_rect = {0, 0, height, width};
|
|
|
|
|
long rowBytes = width * 4;
|
|
|
|
@ -104,8 +115,6 @@ void CompositeGLBufferIntoWindow (AGLContext ctx, Rect *bufferRect, GrafPtr out_
|
|
|
|
|
return; // no harm in continuing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// printf(" Reading aa Conte Data %d %d\n",height,width);
|
|
|
|
|
|
|
|
|
|
// pull GL content down to our image buffer
|
|
|
|
|
aglSetCurrentContext( ctx );
|
|
|
|
|
glReadPixels (0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, image);
|
|
|
|
@ -131,16 +140,26 @@ void CompositeGLBufferIntoWindow (AGLContext ctx, Rect *bufferRect, GrafPtr out_
|
|
|
|
|
DisposeGWorld( pGWorld );
|
|
|
|
|
DisposePtr ( image );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::SystemCloseWindow
|
|
|
|
|
// Access: private
|
|
|
|
|
// Description: The Windows is closed by a OS resource not by a internal request
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
void osxGraphicsWindow::SystemCloseWindow()
|
|
|
|
|
{
|
|
|
|
|
osxdisplay_cat.debug() << "System Closing Window \n";
|
|
|
|
|
|
|
|
|
|
ReleaseSystemResources();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// window event handler
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: windowEvtHndlr
|
|
|
|
|
// Access: file scope static
|
|
|
|
|
// Description: The C callback for Window Events ..
|
|
|
|
|
//
|
|
|
|
|
// We only hook this up for none fullscreen window... so we only handle system window events..
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
static pascal OSStatus windowEvtHndlr (EventHandlerCallRef myHandler, EventRef event, void* userData)
|
|
|
|
|
{
|
|
|
|
|
#pragma unused (userData)
|
|
|
|
@ -187,9 +206,17 @@ static pascal OSStatus windowEvtHndlr (EventHandlerCallRef myHandler, EventRef e
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::DoResize
|
|
|
|
|
// Access:
|
|
|
|
|
// Description: The C callback for Window Events ..
|
|
|
|
|
//
|
|
|
|
|
// We only hook this up for none fullscreen window... so we only handle system window events..
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
void osxGraphicsWindow::DoResize(void)
|
|
|
|
|
{
|
|
|
|
|
// only in window mode .. not full screen
|
|
|
|
|
if(_osx_window != NULL)
|
|
|
|
|
{
|
|
|
|
|
Rect rectPort = {0,0,0,0};
|
|
|
|
@ -198,22 +225,27 @@ void osxGraphicsWindow::DoResize(void)
|
|
|
|
|
GetWindowPortBounds (_osx_window, &rectPort);
|
|
|
|
|
viewRect.size.width = (float) (rectPort.right - rectPort.left);
|
|
|
|
|
viewRect.size.height = (float) (rectPort.bottom - rectPort.top);
|
|
|
|
|
|
|
|
|
|
// tell panda
|
|
|
|
|
WindowProperties properties;
|
|
|
|
|
properties.set_size((int)viewRect.size.width,(int)viewRect.size.height);
|
|
|
|
|
properties.set_origin((int) rectPort.left,(int)rectPort.top);
|
|
|
|
|
system_changed_properties(properties);
|
|
|
|
|
osxdisplay_cat.debug() << " Resizing Window " << viewRect.size.width << " " << viewRect.size.height << "\n";
|
|
|
|
|
|
|
|
|
|
// ping gl
|
|
|
|
|
aglUpdateContext (aglGetCurrentContext());
|
|
|
|
|
aglReportError();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//printf(" Setting Window Size to %d %d \n",(int)viewRect.size.width,(int)viewRect.size.height);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// application level event handler
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: appEvtHndlr
|
|
|
|
|
// Access:
|
|
|
|
|
// Description: The C callback for APlication Events..
|
|
|
|
|
//
|
|
|
|
|
// Hooked once for application
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef event, void* userData)
|
|
|
|
|
{
|
|
|
|
|
#pragma unused (myHandler)
|
|
|
|
@ -269,7 +301,13 @@ static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef even
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::handleTextInput
|
|
|
|
|
// Access:
|
|
|
|
|
// Description: Trap Unicode Input.
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
OSStatus osxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, EventRef theTextEvent)
|
|
|
|
|
{
|
|
|
|
|
UniChar *text = NULL;
|
|
|
|
@ -288,17 +326,19 @@ OSStatus osxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, Even
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
for(unsigned int x = 0; x < actualSize/sizeof(UniChar); ++x)
|
|
|
|
|
{
|
|
|
|
|
printf(" Push KetStroke %x\n",(int)text[x]);
|
|
|
|
|
_input_devices[0].keystroke(text[x]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DisposePtr((char *)text);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::handleTextInput
|
|
|
|
|
// Access: private..
|
|
|
|
|
// Description: Clean up the OS level messes..
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
void osxGraphicsWindow::ReleaseSystemResources()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -391,11 +431,11 @@ osxGraphicsWindow::~osxGraphicsWindow()
|
|
|
|
|
cerr << " osxGraphicsWindow::~osxGraphicsWindow() \n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void osxGraphicsWindow::make_current()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::get_context
|
|
|
|
|
// Access: private..
|
|
|
|
|
// Description: Helper to Decide whitch context to use if any
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
AGLContext osxGraphicsWindow::get_context(void)
|
|
|
|
|
{
|
|
|
|
|
if(_aglcontext != NULL)
|
|
|
|
@ -403,6 +443,11 @@ AGLContext osxGraphicsWindow::get_context(void)
|
|
|
|
|
|
|
|
|
|
return get_ggs_context();
|
|
|
|
|
}
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::get_ggs_context
|
|
|
|
|
// Access: private..
|
|
|
|
|
// Description:
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
AGLContext osxGraphicsWindow::get_ggs_context(void)
|
|
|
|
|
{
|
|
|
|
@ -415,7 +460,11 @@ AGLContext osxGraphicsWindow::get_ggs_context(void)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::buildGL
|
|
|
|
|
// Access: private..
|
|
|
|
|
// Description: Code of the class.. used to control the GL context Allocation ..
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
OSStatus osxGraphicsWindow::buildGL (void)
|
|
|
|
|
{
|
|
|
|
|
// make sure the ggs is up and runnig..
|
|
|
|
@ -479,20 +528,21 @@ bool osxGraphicsWindow::begin_frame(FrameMode mode) {
|
|
|
|
|
begin_frame_spam();
|
|
|
|
|
if (_gsg == (GraphicsStateGuardian *)NULL || (_osx_window == NULL && _is_fullsreen != true))
|
|
|
|
|
{
|
|
|
|
|
// not powered up .. just abort..
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(_is_fullsreen)
|
|
|
|
|
{
|
|
|
|
|
if (!aglSetCurrentContext(get_context()))
|
|
|
|
|
aglReportError ();
|
|
|
|
|
|
|
|
|
|
// printf(" In Full Screen begin_frame\n");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#ifndef HACK_SCREEN_HASH_CONTEXT
|
|
|
|
|
// if we do not have local contexts we need to do some wor
|
|
|
|
|
GrafPtr OtherWin = (GrafPtr)aglGetDrawable(get_context());
|
|
|
|
|
aglReportError();
|
|
|
|
|
WindowPtr other = GetWindowFromPort(OtherWin);
|
|
|
|
@ -505,6 +555,8 @@ bool osxGraphicsWindow::begin_frame(FrameMode mode) {
|
|
|
|
|
CompositeGLBufferIntoWindow(get_context(),& r,OtherWin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// uggly uggly uggly on a mac ... not a good thing..
|
|
|
|
|
aglSetDrawable (get_context(),GetWindowPort (_osx_window));
|
|
|
|
|
aglReportError();
|
|
|
|
|
|
|
|
|
@ -513,6 +565,13 @@ bool osxGraphicsWindow::begin_frame(FrameMode mode) {
|
|
|
|
|
aglReportError ();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
if (!aglSetCurrentContext(get_context()))
|
|
|
|
|
aglReportError ();
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -611,10 +670,9 @@ extern OSErr CPSSetFrontProcess( struct CPSProcessSerNum *psn);
|
|
|
|
|
// thread. Returns true if the window is successfully
|
|
|
|
|
// opened, or false if there was a problem.
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
bool osxGraphicsWindow::open_window() {
|
|
|
|
|
bool osxGraphicsWindow::open_window()
|
|
|
|
|
{
|
|
|
|
|
OSErr err;
|
|
|
|
|
printf(" In Open Window \n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool GlobalInits = false;
|
|
|
|
|
if(GlobalInits != true)
|
|
|
|
@ -633,6 +691,7 @@ OSErr err;
|
|
|
|
|
{ kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
|
|
|
|
|
{kEventClassTextInput, kEventTextInputUnicodeForKeyEvent},
|
|
|
|
|
};
|
|
|
|
|
EventHandlerUPP gEvtHandler; // main event handler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gEvtHandler = NewEventHandlerUPP(appEvtHndlr);
|
|
|
|
@ -718,13 +777,6 @@ if(_properties.has_fullscreen() && _properties.get_fullscreen() == true)
|
|
|
|
|
if (!aglSetInteger (get_context(), AGL_SWAP_INTERVAL, &swap))
|
|
|
|
|
aglReportError ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CreateNewWindow(//
|
|
|
|
|
// kOverlayWindowClass,
|
|
|
|
|
// kWindowStandardHandlerAttribute,
|
|
|
|
|
// &r, &_osx_window);
|
|
|
|
|
_is_fullsreen =true;
|
|
|
|
|
FullScreenWindow = this;
|
|
|
|
|
}
|
|
|
|
@ -742,6 +794,18 @@ else
|
|
|
|
|
|
|
|
|
|
if (_osx_window)
|
|
|
|
|
{
|
|
|
|
|
EventHandlerUPP gWinEvtHandler; // window event handler
|
|
|
|
|
EventHandlerRef ref;
|
|
|
|
|
EventTypeSpec list[] = { { kEventClassWindow, kEventWindowCollapsing },
|
|
|
|
|
{ kEventClassWindow, kEventWindowShown },
|
|
|
|
|
{ kEventClassWindow, kEventWindowActivated },
|
|
|
|
|
{ kEventClassWindow, kEventWindowClose },
|
|
|
|
|
{ kEventClassWindow, kEventWindowBoundsChanged },
|
|
|
|
|
{ kEventClassWindow, kEventWindowZoomed },
|
|
|
|
|
// { kEventClassKeyboard, kEventRawKeyDown },
|
|
|
|
|
// { kEventClassKeyboard, kEventRawKeyUp } ,
|
|
|
|
|
// { kEventClassKeyboard, kEventRawKeyModifiersChanged }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SetWRefCon (_osx_window, (long) this); // point to the window record in the ref con of the window
|
|
|
|
|
gWinEvtHandler = NewEventHandlerUPP(windowEvtHndlr);
|
|
|
|
@ -769,7 +833,9 @@ else
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//RunApplicationEventLoop();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// pull the size from the real window .. do not trust the requested values?
|
|
|
|
|
WindowProperties properties;
|
|
|
|
|
|
|
|
|
|
_properties.set_foreground(true);
|
|
|
|
@ -794,7 +860,13 @@ else
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::process_events()
|
|
|
|
|
// Access: virtual, protected
|
|
|
|
|
// Description: Required Event upcall . Used to dispatch Window and Aplication Events
|
|
|
|
|
// back into panda
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
void osxGraphicsWindow::process_events()
|
|
|
|
|
{
|
|
|
|
|
GraphicsWindow::process_events();
|
|
|
|
@ -833,24 +905,13 @@ void handleWindowDMEvent (void *userData, short theMessage, void *notifyData)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EventRef theTextEvent;
|
|
|
|
|
UniChar *text;
|
|
|
|
|
UInt32 actualSize;
|
|
|
|
|
|
|
|
|
|
GetEventParameter (theTextEvent, kEventParamTextInputSendText,
|
|
|
|
|
typeUnicodeText, NULL, 0, &actualSize, NULL);
|
|
|
|
|
|
|
|
|
|
text = (UniChar*) NewPtr(actualSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetEventParameter (theTextEvent, kEventParamTextInputSendText,
|
|
|
|
|
typeUnicodeText, NULL, actualSize, NULL, text);
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::process_events()
|
|
|
|
|
// Access: virtual, protected
|
|
|
|
|
// Description: Required Event upcall . Used to dispatch Window and Aplication Events
|
|
|
|
|
// back into panda
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// key input handler
|
|
|
|
|
OSStatus osxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, EventRef event, Boolean keyDown)
|
|
|
|
|
{
|
|
|
|
@ -879,14 +940,22 @@ OSStatus osxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, Event
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function:
|
|
|
|
|
// Access:
|
|
|
|
|
// Description:
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
void osxGraphicsWindow::SystemSetWindowForground(bool forground)
|
|
|
|
|
{
|
|
|
|
|
WindowProperties properties;
|
|
|
|
|
properties.set_foreground(forground);
|
|
|
|
|
system_changed_properties(properties);
|
|
|
|
|
};
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function:
|
|
|
|
|
// Access:
|
|
|
|
|
// Description:
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|
|
|
|
{
|
|
|
|
@ -897,15 +966,18 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
|
|
|
|
|
SetPort( savePort );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function:
|
|
|
|
|
// Access:
|
|
|
|
|
// Description:
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
OSStatus osxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandler, EventRef event)
|
|
|
|
|
{
|
|
|
|
|
WindowRef window = NULL;
|
|
|
|
|
// pRecContext pContextInfo = NULL;
|
|
|
|
|
OSStatus result = eventNotHandledErr;
|
|
|
|
|
UInt32 kind = GetEventKind (event);
|
|
|
|
|
EventMouseButton button = 0;
|
|
|
|
|
// HIPoint location = {0.0f, 0.0f};
|
|
|
|
|
Point qdGlobalPoint = {0, 0};
|
|
|
|
|
UInt32 modifiers = 0;
|
|
|
|
|
long wheelDelta = 0;
|
|
|
|
@ -914,14 +986,8 @@ OSStatus osxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandl
|
|
|
|
|
// Mac OS X v10.1 and later
|
|
|
|
|
// should this be front window???
|
|
|
|
|
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
|
|
|
|
// if (window)
|
|
|
|
|
// pContextInfo = GetCurrentContextInfo (window);
|
|
|
|
|
// if (!pContextInfo)
|
|
|
|
|
// return result; // not an application GLWindow so do not process (there is an exception)
|
|
|
|
|
GetWindowPortBounds (window, &rectPort);
|
|
|
|
|
|
|
|
|
|
//printf(" Got Mouse Event \n");
|
|
|
|
|
|
|
|
|
|
result = CallNextEventHandler(myHandler, event);
|
|
|
|
|
if (eventNotHandledErr == result)
|
|
|
|
|
{ // only handle events not already handled (prevents wierd resize interaction)
|
|
|
|
@ -930,7 +996,6 @@ OSStatus osxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandl
|
|
|
|
|
case kEventMouseDown:
|
|
|
|
|
{
|
|
|
|
|
GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
|
|
|
|
|
// GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); // Mac OS X v10.1 and later
|
|
|
|
|
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
|
|
|
|
|
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
|
|
|
|
SystemPointToLocalPoint(qdGlobalPoint);
|
|
|
|
@ -940,11 +1005,6 @@ OSStatus osxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandl
|
|
|
|
|
button_h = MouseButton::two();
|
|
|
|
|
if(kEventMouseButtonTertiary == button)
|
|
|
|
|
button_h = MouseButton::three();
|
|
|
|
|
|
|
|
|
|
// cerr << " Mouse Down " << location.x << " " << location.y << " "<< button_h << "\n" ;
|
|
|
|
|
// cerr << " Mouse Down " << qdGlobalPoint.h << " " << qdGlobalPoint.v << " "<< button_h << "\n" ;
|
|
|
|
|
// cerr << " Window Port " << rectPort.top << " " << rectPort.bottom ;
|
|
|
|
|
// _input_devices[0].set_pointer_in_window((int)location.x, (int)location.y);
|
|
|
|
|
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
|
|
|
|
_input_devices[0].button_down(button_h);
|
|
|
|
|
}
|
|
|
|
@ -962,20 +1022,12 @@ OSStatus osxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandl
|
|
|
|
|
button_h = MouseButton::two();
|
|
|
|
|
if(kEventMouseButtonTertiary == button)
|
|
|
|
|
button_h = MouseButton::three();
|
|
|
|
|
|
|
|
|
|
// cerr << " Mouse Up " << location.x << " " << location.y << " "<< button_h << "\n";
|
|
|
|
|
// cerr << " Mouse up " << qdGlobalPoint.h << " " << qdGlobalPoint.v << " "<< button_h << "\n" ;
|
|
|
|
|
|
|
|
|
|
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
|
|
|
|
_input_devices[0].button_up(button_h);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case kEventMouseMoved:
|
|
|
|
|
case kEventMouseDragged:
|
|
|
|
|
// GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); // Mac OS X v10.1 and later
|
|
|
|
|
// GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); // Mac OS X v10.1 and later
|
|
|
|
|
// _input_devices[0].set_pointer_in_window((int)location.x, (int)location.y);
|
|
|
|
|
// _input_devices[0].set_pointer_in_window(event.xmotion.x, event.xmotion.y);
|
|
|
|
|
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
|
|
|
|
SystemPointToLocalPoint(qdGlobalPoint);
|
|
|
|
|
|
|
|
|
@ -991,8 +1043,12 @@ OSStatus osxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandl
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ButtonHandle OSX_TranslateKey( UInt32 key, EventRef event)
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::OSX_TranslateKey
|
|
|
|
|
// Access: Private
|
|
|
|
|
// Description: MAC Key Codes to Panda Key Codes
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
ButtonHandle osxGraphicsWindow::OSX_TranslateKey( UInt32 key, EventRef event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1110,8 +1166,11 @@ ButtonHandle OSX_TranslateKey( UInt32 key, EventRef event)
|
|
|
|
|
}
|
|
|
|
|
return nk;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Function: osxGraphicsWindow::HandleModifireDeleta
|
|
|
|
|
// Access: Private
|
|
|
|
|
// Description: Used to emulate key events for the MAC key Modifiers..
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
void osxGraphicsWindow::HandleModifireDeleta(UInt32 newModifiers)
|
|
|
|
|
{
|
|
|
|
|
UInt32 changed = _last_key_modifiers ^ newModifiers;
|
|
|
|
|