Reduce plasmashell frozen time

Summary:
Third part of https://phabricator.kde.org/D10627

According to the documentation at http://doc.qt.io/qt-5/qabstractnativeeventfilter.html

The type of event eventType is specific to the platform plugin chosen
at run-time, and can be used to cast message to the right type.

On X11, eventType is set to "xcb_generic_event_t", and the message can
be casted to a xcb_generic_event_t pointer.

The other eventType are "windows_generic_MSG" and "mac_generic_NSEvent".

No other eventType starts with an 'x'.

Reviewers: #frameworks, #plasma, mwolff, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: mwolff, plasma-devel, davidedmundson

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D10670
This commit is contained in:
Jaime Torres 2018-03-21 19:24:55 +01:00
parent f018779459
commit 33ddaaa23f

View File

@ -62,7 +62,11 @@ void EffectWatcher::init(const QString &property)
bool EffectWatcher::nativeEventFilter(const QByteArray &eventType, void *message, long *result) bool EffectWatcher::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{ {
Q_UNUSED(result); Q_UNUSED(result);
if (eventType != "xcb_generic_event_t") { // A faster comparison than eventType != "xcb_generic_event_t"
// given that eventType can only have the following values:
// "xcb_generic_event_t", "windows_generic_MSG" and "mac_generic_NSEvent"
// According to http://doc.qt.io/qt-5/qabstractnativeeventfilter.html
if (eventType[0] != 'x') {
return false; return false;
} }
xcb_generic_event_t *event = reinterpret_cast<xcb_generic_event_t *>(message); xcb_generic_event_t *event = reinterpret_cast<xcb_generic_event_t *>(message);