mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Fixed: #1147 Make OVQT work on MacOS
This commit is contained in:
parent
9a9ea61516
commit
012e2cc886
7 changed files with 53 additions and 26 deletions
|
@ -879,7 +879,6 @@ bool CDriverGL::swapBuffers()
|
|||
}
|
||||
|
||||
[_ctx flushBuffer];
|
||||
[containerView() display];
|
||||
|
||||
#elif defined (NL_OS_UNIX)
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ bool GlWndProc(CDriverGL *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
#elif defined (NL_OS_MAC)
|
||||
|
||||
bool GlWndProc(CDriverGL *driver, NSEvent* e);
|
||||
bool GlWndProc(CDriverGL *driver, const void* e);
|
||||
|
||||
#elif defined (NL_OS_UNIX)
|
||||
|
||||
|
@ -705,7 +705,7 @@ private:
|
|||
|
||||
#elif defined(NL_OS_MAC)
|
||||
|
||||
friend bool GlWndProc(CDriverGL*, NSEvent*);
|
||||
friend bool GlWndProc(CDriverGL*, const void*);
|
||||
friend void windowDidMove(NSWindow*, CDriverGL*);
|
||||
friend void viewDidResize(NSView*, CDriverGL*);
|
||||
|
||||
|
|
|
@ -165,20 +165,21 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
|
|||
|
||||
#elif defined (NL_OS_MAC)
|
||||
|
||||
bool GlWndProc(CDriverGL *driver, NSEvent* e)
|
||||
bool GlWndProc(CDriverGL *driver, const void* e)
|
||||
{
|
||||
H_AUTO_OGL(GlWndProc)
|
||||
|
||||
// NSLog(@"NSEvent in GlWndProc %@", e);
|
||||
|
||||
if(!driver)
|
||||
return false;
|
||||
|
||||
switch([e type])
|
||||
NSEvent* event = [NSEvent eventWithEventRef:e];
|
||||
// NSLog(@"NSEvent in GlWndProc %@", event);
|
||||
|
||||
switch([event type])
|
||||
{
|
||||
/* TODO handle window activate, close, etc. */
|
||||
default:
|
||||
return driver->_EventEmitter.processMessage(e);
|
||||
return driver->_EventEmitter.processMessage(event);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -967,7 +968,6 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
|
|||
[[containerView() window] makeFirstResponder:_glView];
|
||||
|
||||
[_ctx flushBuffer];
|
||||
[containerView() display];
|
||||
|
||||
_EventEmitter.init(this, _glView);
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
if(!server && !_server)
|
||||
nlerror("no server to post events to");
|
||||
|
||||
// TODO like internal server in unix event emitter... review!
|
||||
if(!server)
|
||||
server = _server;
|
||||
|
||||
|
@ -247,7 +248,6 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
if((mouseX < 0.0 || mouseX > 1.0 || mouseY < 0.0 || mouseY > 1.0) &&
|
||||
event.type != NSKeyDown && event.type != NSKeyUp)
|
||||
{
|
||||
[NSApp sendEvent:event];
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -399,16 +399,15 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
default:
|
||||
{
|
||||
nlwarning("Unknown event type. dropping.");
|
||||
// NSLog(@"%@", event);
|
||||
NSLog(@"%@", event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[NSApp sendEvent:event];
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef bool (*cocoaProc)(NL3D::IDriver*, NSEvent* e);
|
||||
typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
|
||||
|
||||
void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */)
|
||||
{
|
||||
|
@ -429,17 +428,18 @@ void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */)
|
|||
cocoaProc proc = (cocoaProc)_driver->getWindowProc();
|
||||
|
||||
if(proc)
|
||||
proc(_driver, event);
|
||||
proc(_driver, [event eventRef]);
|
||||
}
|
||||
else
|
||||
{
|
||||
processMessage(event, &server);
|
||||
}
|
||||
|
||||
[NSApp sendEvent:event];
|
||||
}
|
||||
|
||||
// TODO like internal server in unix event emitter... review!
|
||||
_server = &server;
|
||||
// _server->pump();
|
||||
}
|
||||
|
||||
void CCocoaEventEmitter::emulateMouseRawMode(bool enable)
|
||||
|
|
|
@ -40,7 +40,7 @@ QT4_ADD_RESOURCES( OBJECT_VIEWER_RC_SRCS ${OBJECT_VIEWER_RCS} )
|
|||
QT4_WRAP_CPP( OBJECT_VIEWER_MOC_SRCS ${OBJECT_VIEWER_HDR} )
|
||||
QT4_WRAP_UI( OBJECT_VIEWER_UI_HDRS ${OBJECT_VIEWER_UIS} )
|
||||
|
||||
ADD_EXECUTABLE(object_viewer_qt WIN32 ${OBJECT_VIEWER_SRC} ${OBJECT_VIEWER_MOC_SRCS} ${OBJECT_VIEWER_RC_SRCS} ${OBJECT_VIEWER_UI_HDRS})
|
||||
ADD_EXECUTABLE(object_viewer_qt WIN32 MACOSX_BUNDLE ${OBJECT_VIEWER_SRC} ${OBJECT_VIEWER_MOC_SRCS} ${OBJECT_VIEWER_RC_SRCS} ${OBJECT_VIEWER_UI_HDRS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(object_viewer_qt
|
||||
nelmisc
|
||||
|
@ -60,4 +60,4 @@ IF(WITH_PCH)
|
|||
ADD_NATIVE_PRECOMPILED_HEADER(object_viewer_qt ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp)
|
||||
ENDIF(WITH_PCH)
|
||||
|
||||
INSTALL(TARGETS object_viewer_qt RUNTIME DESTINATION bin COMPONENT runtime)
|
||||
INSTALL(TARGETS object_viewer_qt RUNTIME DESTINATION bin COMPONENT runtime BUNDLE DESTINATION /Applications)
|
||||
|
|
|
@ -60,11 +60,11 @@ void CGraphicsViewport::init()
|
|||
//H_AUTO2
|
||||
nldebug("CGraphicsViewport::init");
|
||||
|
||||
#ifdef NL_OS_UNIX
|
||||
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
|
||||
makeCurrent();
|
||||
#endif // NL_OS_UNIX
|
||||
#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
|
||||
|
||||
Modules::objView().init(winId(), width(), height());
|
||||
Modules::objView().init((nlWindow)winId(), width(), height());
|
||||
Modules::psEdit().init();
|
||||
|
||||
setMouseTracking(true);
|
||||
|
@ -115,7 +115,7 @@ void CGraphicsViewport::resizeEvent(QResizeEvent *resizeEvent)
|
|||
Modules::objView().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height());
|
||||
}
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
|
||||
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
@ -133,7 +133,30 @@ bool CGraphicsViewport::winEvent(MSG * message, long * result)
|
|||
|
||||
return false;
|
||||
}
|
||||
#else // NL_OS_UNIX
|
||||
|
||||
#elif defined(NL_OS_MAC)
|
||||
|
||||
typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
|
||||
|
||||
bool CGraphicsViewport::macEvent(EventHandlerCallRef caller, EventRef event)
|
||||
{
|
||||
if(caller)
|
||||
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
|
||||
|
||||
if (Modules::objView().getDriver() && Modules::objView().getDriver()->isActive())
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(Modules::objView().getDriver())->getDriver();
|
||||
if (driver)
|
||||
{
|
||||
cocoaProc proc = (cocoaProc)driver->getWindowProc();
|
||||
return proc(driver, event);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined(NL_OS_UNIX)
|
||||
|
||||
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
|
||||
|
||||
|
|
|
@ -33,9 +33,12 @@
|
|||
|
||||
// Project includes
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
/* TODO every platform should use QWidget */
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
typedef QWidget QNLWidget;
|
||||
#else // NL_OS_UNIX
|
||||
#elif defined(NL_OS_MAC)
|
||||
typedef QWidget QNLWidget;
|
||||
#elif defined(NL_OS_UNIX)
|
||||
typedef QGLWidget QNLWidget;
|
||||
#endif // NL_OS_UNIX
|
||||
|
||||
|
@ -73,9 +76,11 @@ private Q_SLOTS:
|
|||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *resizeEvent);
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
virtual bool winEvent(MSG * message, long * result);
|
||||
#else // NL_OS_UNIX
|
||||
#elif defined(NL_OS_MAC)
|
||||
virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
|
||||
#elif defined(NL_OS_UNIX)
|
||||
virtual bool x11Event(XEvent *event);
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue