Removed old code using qt<5.4

This commit is contained in:
andrea
2023-09-09 16:43:54 +02:00
committed by wwmayer
parent 686618411f
commit 9fbc86daa5
2 changed files with 17 additions and 144 deletions

View File

@@ -33,23 +33,22 @@
#include <QX11Info>
#include <spnav.h>
#if QT_VERSION >= 0x050000
#include "GuiRawInputEventFilter.h"
#undef Bool
#undef CursorShape
#undef Expose
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef None
#undef Status
#undef Unsorted
#undef False
#undef True
#undef Complex
#endif // #if QT_VERSION >= 0x050000
#include "GuiRawInputEventFilter.h"
#undef Bool
#undef CursorShape
#undef Expose
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef None
#undef Status
#undef Unsorted
#undef False
#undef True
#undef Complex
Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
: GuiAbstractNativeEvent(app)
@@ -66,26 +65,19 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
{
#if QT_VERSION >= 0x050200
if (!QX11Info::isPlatformX11()) {
Base::Console().Log("Application is not running on X11\n");
return;
}
#endif
if (spnav_x11_open(QX11Info::display(), window->winId()) == -1) {
Base::Console().Log("Couldn't connect to spacenav daemon on X11. Please ignore if you don't have a spacemouse.\n");
} else {
Base::Console().Log("Connected to spacenav daemon on X11\n");
mainApp->setSpaceballPresent(true);
#if QT_VERSION >= 0x050000
mainApp->installNativeEventFilter(new Gui::RawInputEventFilter(&xcbEventFilter));
#endif // #if QT_VERSION >= 0x050000
}
}
#if QT_VERSION >= 0x050000
bool Gui::GuiNativeEvent::xcbEventFilter(void *xcb_void, long* result)
{
Q_UNUSED(result);
@@ -151,117 +143,4 @@ bool Gui::GuiNativeEvent::xcbEventFilter(void *xcb_void, long* result)
} // end switch (navEvent.type) {
}
#else // if QT_VERSION >= 0x050000
bool Gui::GuiNativeEvent::x11EventFilter(XEvent *event)
{
/*
First we check if we have a motion flush event:
- If there are unprocessed motion events we are in a flooding situation.
In that case we wait with generating a Spaceball event.
- A motion event counter of 0 indicates that FreeCAD is ready to process
the event. A Spaceball event, using the saved motion data, is posted.
*/
static Display* display = QX11Info::display();
static Atom motion_flush_event = XInternAtom(display, "FCMotionFlushEvent", false);
static int nMotionEvents = 0;
if (event->type == ClientMessage)
{
Atom message_type = event->xclient.message_type;
if (message_type == motion_flush_event)
{
nMotionEvents--;
if (nMotionEvents == 0)
{
mainApp->postMotionEvent(motionDataArray);
}
return true;
} // XEvent: motion_flush_event
} // XEvent: ClientMessage
/*
From here on we deal with spacenav events only:
- motion: The event data is saved and a self addressed flush event
is sent through the window system (XEvent).
In the case of an event flooding, the motion data is added up.
- button: A Spaceball event is posted (QInputEvent).
*/
spnav_event navEvent;
if (!spnav_x11_event(event, &navEvent))
return false;
if (navEvent.type == SPNAV_EVENT_MOTION)
{
/*
If the motion data of the preceding event has not been processed
through posting an Spaceball event (flooding situation),
the motion data provided by the incoming event is added to the saved data.
*/
int dx, dy, dz, drx, dry, drz;
if (nMotionEvents == 0)
{
dx = 0;
dy = 0;
dz = 0;
drx = 0;
dry = 0;
drz = 0;
}
else
{
dx = motionDataArray[0];
dy = motionDataArray[1];
dz = motionDataArray[2];
drx = motionDataArray[3];
dry = motionDataArray[4];
drz = motionDataArray[5];
}
motionDataArray[0] = -navEvent.motion.x;
motionDataArray[1] = -navEvent.motion.z;
motionDataArray[2] = -navEvent.motion.y;
motionDataArray[3] = -navEvent.motion.rx;
motionDataArray[4] = -navEvent.motion.rz;
motionDataArray[5] = -navEvent.motion.ry;
motionDataArray[0] += dx;
motionDataArray[1] += dy;
motionDataArray[2] += dz;
motionDataArray[3] += drx;
motionDataArray[4] += dry;
motionDataArray[5] += drz;
/*
Send a self addressed flush event through the window system. This will
trigger a Spaceball event if FreeCAD is ready to do so.
*/
nMotionEvents++;
XClientMessageEvent flushEvent;
flushEvent.display = display;
flushEvent.window = event->xclient.window;
flushEvent.type = ClientMessage;
flushEvent.format = 8;
flushEvent.message_type = motion_flush_event;
XSendEvent (display, flushEvent.window, False, 0, (XEvent*)&flushEvent); // siehe spnavd, False, 0
return true;
}
if (navEvent.type == SPNAV_EVENT_BUTTON)
{
mainApp->postButtonEvent(navEvent.button.bnum, navEvent.button.press);
return true;
}
Base::Console().Log("Unknown spaceball event\n");
return true;
}
#endif // if/else QT_VERSION >= 0x050000
#include "3Dconnexion/moc_GuiNativeEventLinuxX11.cpp"

View File

@@ -45,9 +45,7 @@ http://www.3dconnexion.com/forum/viewtopic.php?f=19&t=4968&sid=72c018bdcf0e6edc9
#include <QWidget>
#include <Base/Console.h>
#include "GuiApplicationNativeEventAware.h"
#if QT_VERSION >= 0x050000
#include "GuiRawInputEventFilter.h"
#endif // #if QT_VERSION >= 0x050000
#include "GuiRawInputEventFilter.h"
Gui::GuiNativeEvent* Gui::GuiNativeEvent::gMouseInput = 0;
@@ -277,12 +275,8 @@ void Gui::GuiNativeEvent::initSpaceball(QMainWindow *mainWindow)
if (InitializeRawInput((HWND)mainWindow->winId())) {
gMouseInput = this;
#if QT_VERSION >= 0x050000
qApp->installNativeEventFilter(
new Gui::RawInputEventFilter(Gui::GuiNativeEvent::RawInputEventFilter));
#else
qApp->setEventFilter(Gui::GuiNativeEvent::RawInputEventFilter);
#endif
Base::Console().Log("3Dconnexion device initialized.\n");
}
else {