mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-28 09:14:18 -04:00
Port native event filter to Qt 5.
This commit is contained in:
parent
03a330a4dd
commit
3b07098731
2 changed files with 24 additions and 19 deletions
|
@ -18,13 +18,37 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
|
|
||||||
#include "autotype/AutoType.h"
|
#include "autotype/AutoType.h"
|
||||||
|
|
||||||
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX)
|
||||||
|
class XcbEventFilter : public QAbstractNativeEventFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) Q_DECL_OVERRIDE
|
||||||
|
{
|
||||||
|
Q_UNUSED(result)
|
||||||
|
|
||||||
|
if (eventType == QByteArrayLiteral("xcb_generic_event_t")) {
|
||||||
|
int retCode = autoType()->callEventFilter(message);
|
||||||
|
if (retCode == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
Application::Application(int& argc, char** argv)
|
Application::Application(int& argc, char** argv)
|
||||||
: QApplication(argc, argv)
|
: QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX)
|
||||||
|
installNativeEventFilter(new XcbEventFilter());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::event(QEvent* event)
|
bool Application::event(QEvent* event)
|
||||||
|
@ -37,19 +61,3 @@ bool Application::event(QEvent* event)
|
||||||
|
|
||||||
return QApplication::event(event);
|
return QApplication::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
bool Application::x11EventFilter(XEvent* event)
|
|
||||||
{
|
|
||||||
int retCode = autoType()->callEventFilter(event);
|
|
||||||
|
|
||||||
if (retCode == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (retCode == 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QApplication::x11EventFilter(event);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -31,9 +31,6 @@ public:
|
||||||
Application(int& argc, char** argv);
|
Application(int& argc, char** argv);
|
||||||
|
|
||||||
bool event(QEvent* event) Q_DECL_OVERRIDE;
|
bool event(QEvent* event) Q_DECL_OVERRIDE;
|
||||||
#ifdef Q_WS_X11
|
|
||||||
bool x11EventFilter(XEvent* event) Q_DECL_OVERRIDE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void openFile(const QString& filename);
|
void openFile(const QString& filename);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue