mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
*** empty log message ***
This commit is contained in:
parent
4ac569d2bc
commit
e31bfdac43
@ -34,6 +34,7 @@
|
|||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
|
||||||
////////////////////////// Global Objects .....
|
////////////////////////// Global Objects .....
|
||||||
|
|
||||||
TypeHandle osxGraphicsWindow::_type_handle;
|
TypeHandle osxGraphicsWindow::_type_handle;
|
||||||
osxGraphicsWindow * osxGraphicsWindow::FullScreenWindow = NULL;
|
osxGraphicsWindow * osxGraphicsWindow::FullScreenWindow = NULL;
|
||||||
|
|
||||||
@ -153,13 +154,13 @@ static void CompositeGLBufferIntoWindow (AGLContext ctx, Rect *bufferRect, GrafP
|
|||||||
GrafPtr portSave = NULL;
|
GrafPtr portSave = NULL;
|
||||||
Boolean portChanged = QDSwapPort(out_port, &portSave);
|
Boolean portChanged = QDSwapPort(out_port, &portSave);
|
||||||
|
|
||||||
CopyBits( GetPortBitMapForCopyBits (pGWorld), GetPortBitMapForCopyBits (out_port), &src_rect, &ddrc_rect, srcCopy, 0 );
|
CopyBits(GetPortBitMapForCopyBits (pGWorld), GetPortBitMapForCopyBits (out_port), &src_rect, &ddrc_rect, srcCopy, 0);
|
||||||
|
|
||||||
if (portChanged)
|
if (portChanged)
|
||||||
QDSwapPort(portSave, NULL);
|
QDSwapPort(portSave, NULL);
|
||||||
|
|
||||||
DisposeGWorld( pGWorld );
|
DisposeGWorld(pGWorld);
|
||||||
DisposePtr ( image );
|
DisposePtr(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -174,8 +175,8 @@ OSStatus osxGraphicsWindow::event_handler(EventHandlerCallRef myHandler, EventRe
|
|||||||
UInt32 the_class = GetEventClass(event);
|
UInt32 the_class = GetEventClass(event);
|
||||||
UInt32 kind = GetEventKind(event);
|
UInt32 kind = GetEventKind(event);
|
||||||
|
|
||||||
WindowRef window = NULL;
|
WindowRef window = _osx_window // NULL;
|
||||||
GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
// GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
||||||
|
|
||||||
if (osxdisplay_cat.is_spam())
|
if (osxdisplay_cat.is_spam())
|
||||||
{
|
{
|
||||||
@ -185,6 +186,7 @@ OSStatus osxGraphicsWindow::event_handler(EventHandlerCallRef myHandler, EventRe
|
|||||||
switch (the_class)
|
switch (the_class)
|
||||||
{
|
{
|
||||||
case kEventClassMouse:
|
case kEventClassMouse:
|
||||||
|
osxdisplay_cat.info() << "Mouse movement handled by Window handler\n";
|
||||||
result = handleWindowMouseEvents (myHandler, event);
|
result = handleWindowMouseEvents (myHandler, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -289,17 +291,21 @@ void osxGraphicsWindow::SystemCloseWindow()
|
|||||||
|
|
||||||
static pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void *userData)
|
static pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void *userData)
|
||||||
{
|
{
|
||||||
#pragma unused (userData)
|
osxGraphicsWindow* osx_win = (osxGraphicsWindow *)userData;
|
||||||
|
|
||||||
WindowRef window = NULL;
|
|
||||||
GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
|
||||||
|
|
||||||
if (window != NULL)
|
|
||||||
{
|
|
||||||
osxGraphicsWindow *osx_win = osxGraphicsWindow::GetCurrentOSxWindow(window);
|
|
||||||
if (osx_win != (osxGraphicsWindow *)NULL)
|
if (osx_win != (osxGraphicsWindow *)NULL)
|
||||||
return osx_win->event_handler(myHandler, event);
|
return osx_win->event_handler(myHandler, event);
|
||||||
}
|
|
||||||
|
//#pragma unused (userData)
|
||||||
|
|
||||||
|
// WindowRef window = NULL;
|
||||||
|
// GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
||||||
|
|
||||||
|
// if (window != NULL)
|
||||||
|
// {
|
||||||
|
// osxGraphicsWindow *osx_win = osxGraphicsWindow::GetCurrentOSxWindow(window);
|
||||||
|
// if (osx_win != (osxGraphicsWindow *)NULL)
|
||||||
|
// return osx_win->event_handler(myHandler, event);
|
||||||
|
// }
|
||||||
|
|
||||||
return eventNotHandledErr;
|
return eventNotHandledErr;
|
||||||
}
|
}
|
||||||
@ -318,7 +324,7 @@ void osxGraphicsWindow::DoResize(void)
|
|||||||
osxdisplay_cat.info() << "In Resize....." << _properties << "\n";
|
osxdisplay_cat.info() << "In Resize....." << _properties << "\n";
|
||||||
|
|
||||||
// only in window mode .. not full screen
|
// only in window mode .. not full screen
|
||||||
if(_osx_window != NULL && _is_fullscreen == false && _properties.has_size())
|
if(_osx_window != NULL && !_is_fullscreen && _properties.has_size())
|
||||||
{
|
{
|
||||||
Rect rectPort = {0,0,0,0};
|
Rect rectPort = {0,0,0,0};
|
||||||
CGRect viewRect = {{0.0f, 0.0f}, {0.0f, 0.0f}};
|
CGRect viewRect = {{0.0f, 0.0f}, {0.0f, 0.0f}};
|
||||||
@ -335,11 +341,10 @@ void osxGraphicsWindow::DoResize(void)
|
|||||||
if (osxdisplay_cat.is_debug())
|
if (osxdisplay_cat.is_debug())
|
||||||
osxdisplay_cat.debug() << " Resizing Window " << viewRect.size.width << " " << viewRect.size.height << "\n";
|
osxdisplay_cat.debug() << " Resizing Window " << viewRect.size.width << " " << viewRect.size.height << "\n";
|
||||||
|
|
||||||
//cerr << " Resizing Window " << viewRect.size.width << " " << viewRect.size.height << "\n";
|
|
||||||
|
|
||||||
// ping gl
|
// ping gl
|
||||||
aglUpdateContext (aglGetCurrentContext());
|
aglUpdateContext (aglGetCurrentContext());
|
||||||
aglReportError("aglUpdateContext .. This is a Resize..");
|
aglReportError("aglUpdateContext .. This is a Resize..");
|
||||||
|
osxdisplay_cat.info() << "Resize Complete.....\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -363,10 +368,8 @@ static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef even
|
|||||||
UInt32 kind = GetEventKind (event);
|
UInt32 kind = GetEventKind (event);
|
||||||
|
|
||||||
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, (void*) &window);
|
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, (void*) &window);
|
||||||
|
|
||||||
osx_win = osxGraphicsWindow::GetCurrentOSxWindow(window);
|
osx_win = osxGraphicsWindow::GetCurrentOSxWindow(window);
|
||||||
|
if (osx_win == NULL)
|
||||||
if(osx_win == NULL)
|
|
||||||
return eventNotHandledErr;
|
return eventNotHandledErr;
|
||||||
|
|
||||||
switch (the_class)
|
switch (the_class)
|
||||||
@ -406,6 +409,7 @@ static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef even
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kEventClassMouse:
|
case kEventClassMouse:
|
||||||
|
osxdisplay_cat.info() << "Mouse movement handled by Application handler\n";
|
||||||
//if(osxGraphicsWindow::FullScreenWindow != NULL)
|
//if(osxGraphicsWindow::FullScreenWindow != NULL)
|
||||||
result = osx_win->handleWindowMouseEvents (myHandler, event);
|
result = osx_win->handleWindowMouseEvents (myHandler, event);
|
||||||
//result = noErr;
|
//result = noErr;
|
||||||
@ -430,10 +434,9 @@ OSStatus osxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, Even
|
|||||||
if(ret != noErr)
|
if(ret != noErr)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
text = (UniChar*) NewPtr(actualSize);
|
text = (UniChar*)NewPtr(actualSize);
|
||||||
if(text!= NULL)
|
if(text!= NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
ret = GetEventParameter (theTextEvent, kEventParamTextInputSendText,typeUnicodeText, NULL, actualSize, NULL, text);
|
ret = GetEventParameter (theTextEvent, kEventParamTextInputSendText,typeUnicodeText, NULL, actualSize, NULL, text);
|
||||||
if(ret != noErr)
|
if(ret != noErr)
|
||||||
return ret;
|
return ret;
|
||||||
@ -564,7 +567,6 @@ osxGraphicsWindow::~osxGraphicsWindow()
|
|||||||
ReleaseSystemResources();
|
ReleaseSystemResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
// Function: osxGraphicsWindow::get_context
|
// Function: osxGraphicsWindow::get_context
|
||||||
// Access: private..
|
// Access: private..
|
||||||
@ -693,7 +695,7 @@ bool osxGraphicsWindow::begin_frame(FrameMode mode, Thread *current_thread)
|
|||||||
|
|
||||||
begin_frame_spam(mode);
|
begin_frame_spam(mode);
|
||||||
if (_gsg == (GraphicsStateGuardian *)NULL ||
|
if (_gsg == (GraphicsStateGuardian *)NULL ||
|
||||||
(_osx_window == NULL && _is_fullscreen != true))
|
(_osx_window == NULL && !_is_fullscreen))
|
||||||
{
|
{
|
||||||
// not powered up .. just abort..
|
// not powered up .. just abort..
|
||||||
return false;
|
return false;
|
||||||
@ -735,7 +737,7 @@ bool osxGraphicsWindow::begin_frame(FrameMode mode, Thread *current_thread)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aglSetDrawable (get_ggs_context(),GetWindowPort (_osx_window)))
|
if (!aglSetDrawable (get_ggs_context(), GetWindowPort (_osx_window)))
|
||||||
{
|
{
|
||||||
osxdisplay_cat.error() << "Error aglSetDrawable \n";
|
osxdisplay_cat.error() << "Error aglSetDrawable \n";
|
||||||
aglReportError("aglSetDrawable");
|
aglReportError("aglSetDrawable");
|
||||||
@ -803,6 +805,7 @@ void osxGraphicsWindow::end_flip()
|
|||||||
{
|
{
|
||||||
// cerr << " end_flip [" << _ID << "]\n";
|
// cerr << " end_flip [" << _ID << "]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void osxGraphicsWindow::begin_flip()
|
void osxGraphicsWindow::begin_flip()
|
||||||
{
|
{
|
||||||
// this forces a rip to proper context
|
// this forces a rip to proper context
|
||||||
@ -835,16 +838,6 @@ void osxGraphicsWindow::begin_flip()
|
|||||||
|
|
||||||
aglSwapBuffers (get_ggs_context());
|
aglSwapBuffers (get_ggs_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if(_is_fullscreen)
|
|
||||||
aglSwapBuffers (get_ggs_context());
|
|
||||||
else
|
|
||||||
aglSwapBuffers (get_context());
|
|
||||||
|
|
||||||
|
|
||||||
aglReportError("aglSwapBuffers");
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -877,7 +870,7 @@ void osxGraphicsWindow::close_window()
|
|||||||
// UInt32 lo;
|
// UInt32 lo;
|
||||||
// UInt32 hi;
|
// UInt32 hi;
|
||||||
// };
|
// };
|
||||||
|
//
|
||||||
//extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn);
|
//extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn);
|
||||||
//extern OSErr CPSEnableForegroundOperation( struct CPSProcessSerNum *psn);
|
//extern OSErr CPSEnableForegroundOperation( struct CPSProcessSerNum *psn);
|
||||||
//extern OSErr CPSSetProcessName ( struct CPSProcessSerNum *psn, char *processname);
|
//extern OSErr CPSSetProcessName ( struct CPSProcessSerNum *psn, char *processname);
|
||||||
@ -917,7 +910,7 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool GlobalInits = false;
|
static bool GlobalInits = false;
|
||||||
if (GlobalInits != true)
|
if (!GlobalInits)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// one time aplication inits.. to get a window open from a standalone aplication..
|
// one time aplication inits.. to get a window open from a standalone aplication..
|
||||||
@ -936,17 +929,21 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties)
|
|||||||
{ kEventClassKeyboard, kEventRawKeyUp } ,
|
{ kEventClassKeyboard, kEventRawKeyUp } ,
|
||||||
{ kEventClassKeyboard, kEventRawKeyRepeat },
|
{ kEventClassKeyboard, kEventRawKeyRepeat },
|
||||||
{ kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
|
{ kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
|
||||||
{kEventClassTextInput, kEventTextInputUnicodeForKeyEvent},
|
{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
EventHandlerUPP gEvtHandler = NewEventHandlerUPP(appEvtHndlr);
|
EventHandlerUPP gEvtHandler = NewEventHandlerUPP(appEvtHndlr);
|
||||||
err = InstallApplicationEventHandler (gEvtHandler, GetEventTypeCount (list1) , list1, this, &ref1 );
|
err = InstallApplicationEventHandler (gEvtHandler, GetEventTypeCount (list1) , list1, this, &ref1 );
|
||||||
GlobalInits = true;
|
GlobalInits = true;
|
||||||
|
|
||||||
|
// Replicating the hacky code with more document/support code which should do the same thing
|
||||||
|
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
SetFrontProcess(&psn);
|
SetFrontProcess(&psn);
|
||||||
|
|
||||||
|
// Hacky code
|
||||||
|
|
||||||
// struct CPSProcessSerNum PSN;
|
// struct CPSProcessSerNum PSN;
|
||||||
// GetCurrentProcess((ProcessSerialNumber *)&PSN);
|
// GetCurrentProcess((ProcessSerialNumber *)&PSN);
|
||||||
// err = CPSGetCurrentProcess(&PSN);
|
// err = CPSGetCurrentProcess(&PSN);
|
||||||
@ -1010,7 +1007,6 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// lets use this as a crome based window..
|
|
||||||
Rect r;
|
Rect r;
|
||||||
if (req_properties.has_origin())
|
if (req_properties.has_origin())
|
||||||
{
|
{
|
||||||
@ -1102,7 +1098,7 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties)
|
|||||||
|
|
||||||
SetWRefCon (_osx_window, (long) this); // point to the window record in the ref con of the window
|
SetWRefCon (_osx_window, (long) this); // point to the window record in the ref con of the window
|
||||||
gWinEvtHandler = NewEventHandlerUPP(windowEvtHndlr);
|
gWinEvtHandler = NewEventHandlerUPP(windowEvtHndlr);
|
||||||
InstallWindowEventHandler (_osx_window, gWinEvtHandler, GetEventTypeCount (list), list, (void*)this, NULL); // add event handler
|
InstallWindowEventHandler(_osx_window, gWinEvtHandler, GetEventTypeCount(list), list, (void*)this, NULL); // add event handler
|
||||||
ShowWindow (_osx_window);
|
ShowWindow (_osx_window);
|
||||||
|
|
||||||
if(buildGL(false) != noErr)
|
if(buildGL(false) != noErr)
|
||||||
@ -1169,47 +1165,22 @@ void osxGraphicsWindow::process_events()
|
|||||||
{
|
{
|
||||||
GraphicsWindow::process_events();
|
GraphicsWindow::process_events();
|
||||||
|
|
||||||
if (!osx_disable_event_loop) {
|
if (!osx_disable_event_loop)
|
||||||
|
{
|
||||||
EventRef theEvent;
|
EventRef theEvent;
|
||||||
EventTargetRef theTarget;
|
EventTargetRef theTarget = GetEventDispatcherTarget();
|
||||||
theTarget = GetEventDispatcherTarget();
|
|
||||||
|
|
||||||
if (!_properties.has_parent_window())
|
if (!_properties.has_parent_window())
|
||||||
{
|
{
|
||||||
// while (ReceiveNextEvent(0, NULL,kEventDurationForever,true, &theEvent)== noErr)
|
while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &theEvent)== noErr)
|
||||||
while (ReceiveNextEvent(0, NULL,kEventDurationNoWait,true, &theEvent)== noErr)
|
|
||||||
{
|
{
|
||||||
// cerr << "--------------------------------------------Dispatch Event " << pass++ << "\n";
|
|
||||||
SendEventToEventTarget (theEvent, theTarget);
|
SendEventToEventTarget (theEvent, theTarget);
|
||||||
ReleaseEvent(theEvent);
|
ReleaseEvent(theEvent);
|
||||||
// cerr << "------------------------------------Done Dispatch \n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// handle display config changes meaing we need to update the GL context via the resize function and check for windwo dimension changes
|
|
||||||
// also note we redraw the content here as it could be lost in a display config change
|
|
||||||
//void handleWindowDMEvent (void *userData, short theMessage, void *notifyData)
|
|
||||||
//{
|
|
||||||
// if (kDMNotifyEvent == theMessage)
|
|
||||||
// { // post change notifications only
|
|
||||||
// osxGraphicsWindow * osxwin = NULL;
|
|
||||||
// WindowRef window = (WindowRef) userData;
|
|
||||||
// if (window)
|
|
||||||
// osxwin = osxGraphicsWindow::GetCurrentOSxWindow (window);
|
|
||||||
// if (osxwin) { // have a valid OpenGl window
|
|
||||||
// Rect rectPort;
|
|
||||||
// CGRect viewRect = {{0.0f, 0.0f}, {0.0f, 0.0f}};
|
|
||||||
// GetWindowPortBounds (window, &rectPort);
|
|
||||||
// viewRect.size.width = (float) (rectPort.right - rectPort.left);
|
|
||||||
// viewRect.size.height = (float) (rectPort.bottom - rectPort.top);
|
|
||||||
// //resizeGL (pContextInfo->aglContext, &pContextInfo->camera, pContextInfo->shapeSize, viewRect);
|
|
||||||
// InvalWindowRect (window, &rectPort); // force redrow
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: osxGraphicsWindow::handleKeyInput()
|
// Function: osxGraphicsWindow::handleKeyInput()
|
||||||
// Access: virtual, protected
|
// Access: virtual, protected
|
||||||
@ -1293,7 +1264,7 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
GrafPtr savePort;
|
GrafPtr savePort;
|
||||||
Boolean portChanged = QDSwapPort(GetWindowPort(_osx_window), &savePort);
|
Boolean portChanged = QDSwapPort(GetWindowPort(_osx_window), &savePort);
|
||||||
|
|
||||||
GlobalToLocal( &qdGlobalPoint );
|
GlobalToLocal(&qdGlobalPoint);
|
||||||
|
|
||||||
if (portChanged)
|
if (portChanged)
|
||||||
QDSwapPort(savePort, NULL);
|
QDSwapPort(savePort, NULL);
|
||||||
@ -1652,7 +1623,6 @@ bool osxGraphicsWindow::do_reshape_request(int x_origin, int y_origin, bool has_
|
|||||||
osxdisplay_cat.info() << "Do Reshape\n";
|
osxdisplay_cat.info() << "Do Reshape\n";
|
||||||
|
|
||||||
if (_properties.get_fullscreen()) {
|
if (_properties.get_fullscreen()) {
|
||||||
// Can't resize fullscreen windows that easily.
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1680,8 +1650,6 @@ bool osxGraphicsWindow::do_reshape_request(int x_origin, int y_origin, bool has_
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: osxGraphicsWindow::set_properties_now
|
// Function: osxGraphicsWindow::set_properties_now
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
Loading…
x
Reference in New Issue
Block a user