Fixed compilation of 3Dconnexion/libspacenav wit Qt4
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiNativeEvent(GUIApplicationNativeEventAware *app);
|
||||
~GuiNativeEvent();
|
||||
|
||||
@@ -37,7 +37,7 @@ void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
|
||||
} else {
|
||||
Base::Console().Log("Connected to spacenav daemon\n");
|
||||
QSocketNotifier* SpacenavNotifier = new QSocketNotifier(spnav_fd(), QSocketNotifier::Read, this);
|
||||
connect(SpacenavNotifier, &QSocketNotifier::activated, this, &GuiNativeEvent::pollSpacenav);
|
||||
connect(SpacenavNotifier, SIGNAL(activated(int)), this, SLOT(pollSpacenav()));
|
||||
mainApp->setSpaceballPresent(true);
|
||||
}
|
||||
}
|
||||
@@ -68,3 +68,5 @@ void Gui::GuiNativeEvent::pollSpacenav()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "3Dconnexion/moc_GuiNativeEventLinux.cpp"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <QObject>
|
||||
|
||||
class QMainWindow;
|
||||
class GUIApplicationNativeEventAware;
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
@@ -13,7 +12,7 @@ namespace Gui
|
||||
class GuiNativeEvent : public QObject
|
||||
{
|
||||
#include "GuiNativeEventCommon.h"
|
||||
private:
|
||||
private slots:
|
||||
void pollSpacenav();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
Implementation by Torsten Sadowski 2018
|
||||
*/
|
||||
|
||||
#include "SpaceballEvent.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "GuiNativeEventLinuxX11.h"
|
||||
|
||||
#include "GuiApplicationNativeEventAware.h"
|
||||
#include "SpaceballEvent.h"
|
||||
#include <FCConfig.h>
|
||||
#include <Base/Console.h>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <QX11Info>
|
||||
#include <spnav.h>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <X11/Xlib.h>
|
||||
#include "GuiRawInputEventFilter.h"
|
||||
#undef Bool
|
||||
#undef CursorShape
|
||||
@@ -57,26 +57,33 @@ void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
|
||||
mainApp->setSpaceballPresent(true);
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
static auto evFilter( [](void *msg, long *result){
|
||||
Q_UNUSED(result);
|
||||
auto inst(dynamic_cast<Gui::GUIApplicationNativeEventAware *>(QApplication::instance()));
|
||||
if (inst) {
|
||||
return inst->nativeEvent->xcbEventFilter(static_cast<const xcb_client_message_event_t *>(msg));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
mainApp->installNativeEventFilter(new Gui::RawInputEventFilter(evFilter));
|
||||
//static auto evFilter( [](void *msg, long *result){
|
||||
// Q_UNUSED(result);
|
||||
// auto inst(dynamic_cast<Gui::GUIApplicationNativeEventAware *>(QApplication::instance()));
|
||||
// if (inst) {
|
||||
// return inst->nativeEvent->xcbEventFilter(static_cast<const xcb_client_message_event_t *>(msg));
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// } );
|
||||
//mainApp->installNativeEventFilter(new Gui::RawInputEventFilter(evFilter));
|
||||
mainApp->installNativeEventFilter(new Gui::RawInputEventFilter(&xcbEventFilter));
|
||||
#endif // #if QT_VERSION >= 0x050000
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
bool Gui::GuiNativeEvent::xcbEventFilter(const xcb_client_message_event_t *xcb_ev)
|
||||
bool Gui::GuiNativeEvent::xcbEventFilter(void *xcb_void, long* result)
|
||||
{
|
||||
spnav_event navEvent;
|
||||
Q_UNUSED(result);
|
||||
auto inst(dynamic_cast<Gui::GUIApplicationNativeEventAware *>(QApplication::instance()));
|
||||
if (!inst)
|
||||
return false;
|
||||
|
||||
spnav_event navEvent;
|
||||
|
||||
const xcb_client_message_event_t* xcb_ev = static_cast<const xcb_client_message_event_t*>(xcb_void);
|
||||
// Qt4 used XEvents in native event filters, but Qt5 changed to XCB. The
|
||||
// SpaceNavigator API only works with XEvent, so we need to construct a
|
||||
// temporary XEvent with just enough information for spnav_x11_event()
|
||||
@@ -110,7 +117,7 @@ bool Gui::GuiNativeEvent::xcbEventFilter(const xcb_client_message_event_t *xcb_e
|
||||
motionDataArray[4] = -navEvent.motion.rz;
|
||||
motionDataArray[5] = -navEvent.motion.ry;
|
||||
|
||||
mainApp->postMotionEvent(&motionDataArray[0]);
|
||||
inst->postMotionEvent(&motionDataArray[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -123,7 +130,7 @@ bool Gui::GuiNativeEvent::xcbEventFilter(const xcb_client_message_event_t *xcb_e
|
||||
} else {
|
||||
buttonEvent->setButtonStatus(Spaceball::BUTTON_RELEASED);
|
||||
}
|
||||
mainApp->postButtonEvent(navEvent.button.bnum, navEvent.button.press);
|
||||
inst->postButtonEvent(navEvent.button.bnum, navEvent.button.press);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@@ -156,7 +163,7 @@ bool Gui::GuiNativeEvent::x11EventFilter(XEvent *event)
|
||||
nMotionEvents--;
|
||||
if (nMotionEvents == 0)
|
||||
{
|
||||
mainApp->postMotionEvent(&motionDataArray);
|
||||
mainApp->postMotionEvent(&motionDataArray[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -236,7 +243,7 @@ bool Gui::GuiNativeEvent::x11EventFilter(XEvent *event)
|
||||
|
||||
if (navEvent.type == SPNAV_EVENT_BUTTON)
|
||||
{
|
||||
this->postButtonEvent(navEvent.button.bnum, navEvent.button.press);
|
||||
mainApp->postButtonEvent(navEvent.button.bnum, navEvent.button.press);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -244,3 +251,5 @@ bool Gui::GuiNativeEvent::x11EventFilter(XEvent *event)
|
||||
return true;
|
||||
}
|
||||
#endif // if/else QT_VERSION >= 0x050000
|
||||
|
||||
#include "3Dconnexion/moc_GuiNativeEventLinuxX11.cpp"
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Gui
|
||||
#include "GuiNativeEventCommon.h"
|
||||
public:
|
||||
#if QT_VERSION >= 0x050000
|
||||
bool xcbEventFilter(const xcb_client_message_event_t *message);
|
||||
static bool xcbEventFilter(void *message, long* result);
|
||||
#else
|
||||
bool x11EventFilter(XEvent *event);
|
||||
#endif // if/else QT_VERSION >= 0x050000
|
||||
|
||||
@@ -155,3 +155,5 @@ void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
|
||||
Base::Console().Log("3Dconnexion driver initialized. Client ID: %d\n", tdxClientID);
|
||||
mainApp->setSpaceballPresent(true);
|
||||
}
|
||||
|
||||
#include "3Dconnexion/moc_GuiNativeEventMac.cpp"
|
||||
|
||||
@@ -949,3 +949,4 @@ Error:
|
||||
return processed;
|
||||
}
|
||||
|
||||
#include "3Dconnexion/moc_GuiNativeEventWin32.cpp"
|
||||
|
||||
@@ -122,9 +122,15 @@ IF(SPNAV_FOUND)
|
||||
SET(FreeCADGui_SDK_SRCS
|
||||
3Dconnexion/GuiNativeEventLinuxX11.cpp
|
||||
)
|
||||
SET(FreeCADGui_SDK_MOC_HDRS
|
||||
3Dconnexion/GuiNativeEventLinuxX11.h
|
||||
)
|
||||
else(SPNAV_USE_X11)
|
||||
SET(FreeCADGui_SDK_SRCS
|
||||
3Dconnexion/GuiNativeEventLinux.cpp
|
||||
)
|
||||
SET(FreeCADGui_SDK_MOC_HDRS
|
||||
3Dconnexion/GuiNativeEventLinux.h
|
||||
)
|
||||
endif(SPNAV_USE_X11)
|
||||
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
|
||||
@@ -210,6 +216,9 @@ SET(FreeCADGui_SDK_SRCS
|
||||
3Dconnexion/GuiNativeEventWin32.cpp
|
||||
)
|
||||
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
|
||||
SET(FreeCADGui_SDK_MOC_HDRS
|
||||
3Dconnexion/GuiNativeEventWin32.h
|
||||
)
|
||||
endif(FREECAD_USE_3DCONNEXION AND MSVC)
|
||||
|
||||
if(FREECAD_USE_3DCONNEXION AND APPLE)
|
||||
@@ -217,6 +226,9 @@ SET(FreeCADGui_SDK_SRCS
|
||||
3Dconnexion/GuiNativeEventMac.cpp
|
||||
)
|
||||
SOURCE_GROUP("3D connexion SDK" FILES ${FreeCADGui_SDK_SRCS})
|
||||
SET(FreeCADGui_SDK_MOC_HDRS
|
||||
3Dconnexion/GuiNativeEventMac.h
|
||||
)
|
||||
endif(FREECAD_USE_3DCONNEXION AND APPLE)
|
||||
|
||||
set(Gui_MOC_HDRS
|
||||
@@ -327,6 +339,7 @@ set(Gui_MOC_HDRS
|
||||
TaskView/TaskView.h
|
||||
DAGView/DAGView.h
|
||||
DAGView/DAGModel.h
|
||||
${FreeCADGui_SDK_MOC_HDRS}
|
||||
)
|
||||
|
||||
fc_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS})
|
||||
@@ -1171,6 +1184,7 @@ SET(FreeCADGui_SRCS
|
||||
ManualAlignment.h
|
||||
TransactionObject.h
|
||||
WinNativeGestureRecognizers.h
|
||||
${FreeCADGui_SDK_MOC_HDRS}
|
||||
)
|
||||
|
||||
SET(FreeCADGui_SRCS
|
||||
|
||||
@@ -31,6 +31,20 @@
|
||||
#include "SpaceballEvent.h"
|
||||
#include "Application.h"
|
||||
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
#if defined(Q_OS_LINUX)
|
||||
#if defined(SPNAV_USE_X11)
|
||||
#include "3Dconnexion/GuiNativeEventLinuxX11.h"
|
||||
#else
|
||||
#include "3Dconnexion/GuiNativeEventLinux.h"
|
||||
#endif
|
||||
#elif defined(Q_OS_WIN)
|
||||
#include "3Dconnexion/GuiNativeEventWin32.h"
|
||||
#elif defined(Q_OS_MACX)
|
||||
#include "3Dconnexion/GuiNativeEventMac.h"
|
||||
#endif // Platform switch
|
||||
#endif // Spacemice
|
||||
|
||||
Gui::GUIApplicationNativeEventAware::GUIApplicationNativeEventAware(int &argc, char *argv[]) :
|
||||
QApplication (argc, argv)
|
||||
{
|
||||
|
||||
@@ -29,22 +29,11 @@
|
||||
|
||||
class QMainWindow;
|
||||
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
#if defined(Q_OS_LINUX)
|
||||
#if defined(SPNAV_USE_X11)
|
||||
#include "3Dconnexion/GuiNativeEventLinuxX11.h"
|
||||
#else
|
||||
#include "3Dconnexion/GuiNativeEventLinux.h"
|
||||
#endif
|
||||
#elif defined(Q_OS_WIN)
|
||||
#include "3Dconnexion/GuiNativeEventWin32.h"
|
||||
#elif defined(Q_OS_MACX)
|
||||
#include "3Dconnexion/GuiNativeEventMac.h"
|
||||
#endif // Platform switch
|
||||
#endif // Spacemice
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
class GuiNativeEvent;
|
||||
#endif // Spacemice
|
||||
class GUIApplicationNativeEventAware : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -63,7 +52,7 @@ namespace Gui
|
||||
float convertPrefToSensitivity(int value);
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
GuiNativeEvent *nativeEvent;
|
||||
friend void GuiNativeEvent::initSpaceball(QMainWindow *window);
|
||||
// friend void GuiNativeEvent::initSpaceball(QMainWindow *window);
|
||||
#endif
|
||||
}; // end class GUIApplicationNativeEventAware
|
||||
} // end namespace Gui
|
||||
|
||||
Reference in New Issue
Block a user