Fixed: Compilation under Linux

This commit is contained in:
kervala 2016-01-09 15:56:50 +01:00
parent 4877d40b16
commit 090d8a15f0
3 changed files with 54 additions and 7 deletions

View file

@ -51,6 +51,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget)
#endif
#if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#elif defined(NL_OS_MAC)
typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
#else
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
#endif
using namespace NLMISC;
using namespace NL3D;
using namespace std;
@ -735,11 +743,38 @@ namespace NLQT
_Scene->animate ( fdelta);
}
#ifdef USE_QT5
bool CObjectViewerWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
if (getDriver() && getDriver()->isActive())
{
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver();
if (driver)
{
// see what to do with result
#if defined(NL_OS_WINDOWS)
MSG *msg = (MSG*)message;
winProc proc = (winProc)driver->getWindowProc();
return proc(driver, msg->hwnd, msg->message, msg->wParam, msg->lParam);
#elif defined(NL_OS_MAC)
cocoaProc proc = (cocoaProc)driver->getWindowProc();
return proc(driver, message);
#else
x11Proc proc = (x11Proc)driver->getWindowProc();
return proc(driver, message);
#endif
}
}
return false;
}
#else
#if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
bool CObjectViewerWidget::winEvent(MSG * message, long * result)
bool CObjectViewerWidget::winEvent(MSG *message, long *result)
{
if (getDriver() && getDriver()->isActive())
{
@ -756,8 +791,6 @@ namespace NLQT
#elif defined(NL_OS_MAC)
typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event)
{
if(caller)
@ -778,8 +811,6 @@ namespace NLQT
#elif defined(NL_OS_UNIX)
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
bool CObjectViewerWidget::x11Event(XEvent *event)
{
if (getDriver() && getDriver()->isActive())
@ -796,4 +827,6 @@ namespace NLQT
}
#endif
#endif
} /* namespace NLQT */

View file

@ -166,12 +166,18 @@ namespace NLQT
virtual QString name() const {return ("ObjectViewerWidget");}
protected:
#ifdef USE_QT5
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
#else
#if defined(NL_OS_WINDOWS)
virtual bool winEvent(MSG * message, long * result);
#elif defined(NL_OS_MAC)
virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
#elif defined(NL_OS_UNIX)
virtual bool x11Event(XEvent *event);
#endif
#endif
private Q_SLOTS:

View file

@ -56,4 +56,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <nel/misc/types_nl.h>
#include <nel/misc/common.h>
#if defined(NL_OS_WINDOWS)
#define NOMINMAX
#include <Windows.h>
#elif defined(NL_OS_MAC)
#else
#include <X11/Xlib.h>
#endif
#endif