diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp index 965f6ffcc5..65d4d231c8 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.cpp +++ b/src/plugins/platforms/xlib/qxlibintegration.cpp @@ -68,7 +68,7 @@ QXlibIntegration::QXlibIntegration() XInitThreads(); - mPrimaryScreen = new QXlibScreen(); + mPrimaryScreen = new QXlibScreen(mNativeInterface); mScreens.append(mPrimaryScreen); screenAdded(mPrimaryScreen); } diff --git a/src/plugins/platforms/xlib/qxlibintegration.h b/src/plugins/platforms/xlib/qxlibintegration.h index b76c6e85d8..76c3f13ff6 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.h +++ b/src/plugins/platforms/xlib/qxlibintegration.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE class QXlibScreen; +class QXlibNativeInterface; class QXlibIntegration : public QPlatformIntegration { @@ -82,7 +83,7 @@ private: QList mScreens; QPlatformFontDatabase *mFontDb; QPlatformClipboard *mClipboard; - QPlatformNativeInterface *mNativeInterface; + QXlibNativeInterface *mNativeInterface; QAbstractEventDispatcher *mEventDispatcher; }; diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.cpp b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp index 06f11773bb..0519a365cf 100644 --- a/src/plugins/platforms/xlib/qxlibnativeinterface.cpp +++ b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp @@ -92,6 +92,17 @@ void * QXlibNativeInterface::nativeResourceForWindow(const QByteArray &resourceS } return result; } +QPlatformNativeInterface::EventFilter QXlibNativeInterface::setEventFilter(const QByteArray &eventType, QPlatformNativeInterface::EventFilter filter) +{ + EventFilter oldFilter = m_eventFilters.value(eventType); + m_eventFilters.insert(eventType, filter); + return oldFilter; +} + +QPlatformNativeInterface::EventFilter QXlibNativeInterface::eventFilterForEventType(const QByteArray& eventType) const +{ + return m_eventFilters.value(eventType); +} void * QXlibNativeInterface::displayForWindow(QWindow *window) { diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.h b/src/plugins/platforms/xlib/qxlibnativeinterface.h index 8f68e61caf..9ec4ab51c8 100644 --- a/src/plugins/platforms/xlib/qxlibnativeinterface.h +++ b/src/plugins/platforms/xlib/qxlibnativeinterface.h @@ -60,6 +60,9 @@ public: void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window); + EventFilter setEventFilter(const QByteArray &eventType, EventFilter filter); + EventFilter eventFilterForEventType(const QByteArray& eventType) const; + void *displayForWindow(QWindow *window); void *eglDisplayForWindow(QWindow *window); void *connectionForWindow(QWindow *window); @@ -68,6 +71,7 @@ public: void *eglContextForWindow(QWindow *window); private: + QHash m_eventFilters; static QXlibScreen *qPlatformScreenForWindow(QWindow *window); }; diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp index ed6f77d830..fc903708b3 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.cpp +++ b/src/plugins/platforms/xlib/qxlibscreen.cpp @@ -50,6 +50,7 @@ #include "qxlibstatic.h" #include "qxlibclipboard.h" #include "qxlibdisplay.h" +#include "qxlibnativeinterface.h" #include #include @@ -190,8 +191,9 @@ qDebug() << "qt_x_errhandler" << err->error_code; return 0; } -QXlibScreen::QXlibScreen() - : mFormat(QImage::Format_RGB32) +QXlibScreen::QXlibScreen(QXlibNativeInterface *nativeInterface) + : mNativeInterface(nativeInterface) + , mFormat(QImage::Format_RGB32) #if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) , mEGLDisplay(0) #endif @@ -263,6 +265,11 @@ unsigned long QXlibScreen::whitePixel() bool QXlibScreen::handleEvent(XEvent *xe) { + if (QPlatformNativeInterface::EventFilter filter = mNativeInterface->eventFilterForEventType(QByteArrayLiteral("XEvent"))) { + if (filter(xe, 0)) + return true; + } + int quit = false; QXlibWindow *platformWindow = QXlibWindow::platformWindowForXWindow(xe->xany.window); if (!platformWindow) diff --git a/src/plugins/platforms/xlib/qxlibscreen.h b/src/plugins/platforms/xlib/qxlibscreen.h index 3404243c2c..c6672c3540 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.h +++ b/src/plugins/platforms/xlib/qxlibscreen.h @@ -55,7 +55,7 @@ class QXlibScreen : public QObject, public QPlatformScreen { Q_OBJECT public: - QXlibScreen(); + QXlibScreen(QXlibNativeInterface *nativeInterface); ~QXlibScreen(); @@ -93,6 +93,7 @@ public slots: private: void handleSelectionRequest(XEvent *event); + QXlibNativeInterface *mNativeInterface; QRect mGeometry; QSizeF mPhysicalSize; int mDepth;