From 144e7b27b6675a7ebb21288eb3553d97fb3a55d0 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Mon, 26 Sep 2016 15:45:45 +0200 Subject: [PATCH] DBG+GUI: fixed event native event filters for plugins --- src/dbg/plugin_loader.cpp | 4 ++-- src/gui/Src/main.cpp | 16 ++++++++-------- src/gui/Src/main.h | 14 +++++++++----- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/dbg/plugin_loader.cpp b/src/dbg/plugin_loader.cpp index 4bcd73ab..b85e5bc1 100644 --- a/src/dbg/plugin_loader.cpp +++ b/src/dbg/plugin_loader.cpp @@ -998,7 +998,7 @@ bool pluginwinevent(MSG* message, long* result) PLUG_CB_WINEVENT winevent; winevent.message = message; winevent.result = result; - winevent.retval = false; + winevent.retval = false; //false=handle event, true=ignore event plugincbcall(CB_WINEVENT, &winevent); return winevent.retval; } @@ -1012,7 +1012,7 @@ bool pluginwineventglobal(MSG* message) { PLUG_CB_WINEVENTGLOBAL winevent; winevent.message = message; - winevent.retval = false; + winevent.retval = false; //false=handle event, true=ignore event plugincbcall(CB_WINEVENTGLOBAL, &winevent); return winevent.retval; } diff --git a/src/gui/Src/main.cpp b/src/gui/Src/main.cpp index e26ecdeb..2c324d22 100644 --- a/src/gui/Src/main.cpp +++ b/src/gui/Src/main.cpp @@ -14,17 +14,17 @@ MyApplication::MyApplication(int & argc, char** argv) } #if QT_VERSION < QT_VERSION_CHECK(5,0,0) +bool MyApplication::winEventFilter(MSG* message, long* result) +{ + return DbgWinEvent(message, result); +} + bool MyApplication::globalEventFilter(void* message) { return DbgWinEventGlobal((MSG*)message); } #endif -bool MyApplication::winEventFilter(MSG* message, long* result) -{ - return DbgWinEvent(message, result); -} - bool MyApplication::notify(QObject* receiver, QEvent* event) { bool done = true; @@ -79,8 +79,8 @@ int main(int argc, char* argv[]) #if QT_VERSION < QT_VERSION_CHECK(5,0,0) QAbstractEventDispatcher::instance(application.thread())->setEventFilter(MyApplication::globalEventFilter); #else - x64GlobalFilter* filter = new x64GlobalFilter(); - QAbstractEventDispatcher::instance(application.thread())->installNativeEventFilter(filter); + auto eventFilter = new MyEventFilter(); + application.installNativeEventFilter(eventFilter); #endif // Get the hidden language setting (for testers) @@ -150,7 +150,7 @@ int main(int argc, char* argv[]) //execute the application int result = application.exec(); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - QAbstractEventDispatcher::instance(application.thread())->removeNativeEventFilter(filter); + application.removeNativeEventFilter(eventFilter); #else QAbstractEventDispatcher::instance(application.thread())->setEventFilter(nullptr); #endif diff --git a/src/gui/Src/main.h b/src/gui/Src/main.h index ca92959b..b047b130 100644 --- a/src/gui/Src/main.h +++ b/src/gui/Src/main.h @@ -13,9 +13,9 @@ class MyApplication : public QApplication { public: MyApplication(int & argc, char** argv); - bool notify(QObject* receiver, QEvent* event); - bool winEventFilter(MSG* message, long* result); + bool notify(QObject* receiver, QEvent* event) Q_DECL_OVERRIDE; #if QT_VERSION < QT_VERSION_CHECK(5,0,0) + bool winEventFilter(MSG* message, long* result) Q_DECL_OVERRIDE; static bool globalEventFilter(void* message); #endif }; @@ -30,12 +30,16 @@ struct TranslatedStringStorage extern std::map* TLS_TranslatedStringMap; #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) -class x64GlobalFilter : public QAbstractNativeEventFilter +class MyEventFilter : public QAbstractNativeEventFilter { public: - virtual bool nativeEventFilter(const QByteArray &, void* message, long*) Q_DECL_OVERRIDE + virtual bool nativeEventFilter(const QByteArray & eventType, void* message, long* result) Q_DECL_OVERRIDE { - return DbgWinEventGlobal((MSG*)message); + if(eventType == "windows_dispatcher_MSG") + return DbgWinEventGlobal((MSG*)message); + else if(eventType == "windows_generic_MSG") + return DbgWinEvent((MSG*)message, result); + return false; } }; #endif // QT_VERSION