XCB: Introduce enumeration for event filter types.
Remove QByteArray-construction and hash lookup in the event handling; use an enumeration indexing an array instead. Change-Id: I4d272b32a5ff71c8da58197cf3a0b38c1e61d489 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
This commit is contained in:
parent
ccb059b0e2
commit
e309e7a3e8
@ -498,7 +498,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
|
|||||||
#endif
|
#endif
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
|
||||||
if (QPlatformNativeInterface::EventFilter filter = m_nativeInterface->eventFilterForEventType(QByteArrayLiteral("xcb_generic_event_t")))
|
if (QPlatformNativeInterface::EventFilter filter = m_nativeInterface->eventFilter(QXcbNativeInterface::GenericEventFilter))
|
||||||
handled = filter(event, 0);
|
handled = filter(event, 0);
|
||||||
|
|
||||||
uint response_type = event->response_type & ~0x80;
|
uint response_type = event->response_type & ~0x80;
|
||||||
|
@ -76,6 +76,11 @@ public:
|
|||||||
|
|
||||||
Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
|
Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
|
||||||
|
|
||||||
|
QXcbNativeInterface::QXcbNativeInterface()
|
||||||
|
{
|
||||||
|
qFill(m_eventFilters, m_eventFilters + EventFilterCount, EventFilter(0));
|
||||||
|
}
|
||||||
|
|
||||||
void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
|
void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
|
||||||
{
|
{
|
||||||
QByteArray lowerCaseResource = resourceString.toLower();
|
QByteArray lowerCaseResource = resourceString.toLower();
|
||||||
@ -120,14 +125,17 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr
|
|||||||
|
|
||||||
QPlatformNativeInterface::EventFilter QXcbNativeInterface::setEventFilter(const QByteArray &eventType, QPlatformNativeInterface::EventFilter filter)
|
QPlatformNativeInterface::EventFilter QXcbNativeInterface::setEventFilter(const QByteArray &eventType, QPlatformNativeInterface::EventFilter filter)
|
||||||
{
|
{
|
||||||
EventFilter oldFilter = m_eventFilters.value(eventType);
|
int type = -1;
|
||||||
m_eventFilters.insert(eventType, filter);
|
if (eventType == QByteArrayLiteral("xcb_generic_event_t"))
|
||||||
return oldFilter;
|
type = GenericEventFilter;
|
||||||
|
if (type == -1) {
|
||||||
|
qWarning("%s: Attempt to set invalid event filter type '%s'.",
|
||||||
|
Q_FUNC_INFO, eventType.constData());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
const EventFilter oldFilter = m_eventFilters[type];
|
||||||
QPlatformNativeInterface::EventFilter QXcbNativeInterface::eventFilterForEventType(const QByteArray& eventType) const
|
m_eventFilters[type] = filter;
|
||||||
{
|
return oldFilter;
|
||||||
return m_eventFilters.value(eventType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
|
QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
|
||||||
|
@ -61,11 +61,18 @@ public:
|
|||||||
EglContext
|
EglContext
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EventFilterType {
|
||||||
|
GenericEventFilter,
|
||||||
|
EventFilterCount
|
||||||
|
};
|
||||||
|
|
||||||
|
QXcbNativeInterface();
|
||||||
|
|
||||||
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context);
|
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context);
|
||||||
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
|
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
|
||||||
|
|
||||||
EventFilter setEventFilter(const QByteArray &eventType, EventFilter filter);
|
EventFilter setEventFilter(const QByteArray &eventType, EventFilter filter);
|
||||||
EventFilter eventFilterForEventType(const QByteArray& eventType) const;
|
EventFilter eventFilter(EventFilterType type) const { return m_eventFilters[type]; }
|
||||||
|
|
||||||
void *displayForWindow(QWindow *window);
|
void *displayForWindow(QWindow *window);
|
||||||
void *eglDisplayForWindow(QWindow *window);
|
void *eglDisplayForWindow(QWindow *window);
|
||||||
@ -76,7 +83,7 @@ public:
|
|||||||
void *eglContextForContext(QOpenGLContext *context);
|
void *eglContextForContext(QOpenGLContext *context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QByteArray, EventFilter> m_eventFilters;
|
EventFilter m_eventFilters[EventFilterCount];
|
||||||
|
|
||||||
static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
|
static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user