From 33ddaaa23f6b96636c06df08b512ee25757c682d Mon Sep 17 00:00:00 2001 From: Jaime Torres Date: Wed, 21 Mar 2018 19:24:55 +0100 Subject: [PATCH] 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 --- src/plasma/private/effectwatcher.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plasma/private/effectwatcher.cpp b/src/plasma/private/effectwatcher.cpp index 25b48e2d9..82c1c0d0c 100644 --- a/src/plasma/private/effectwatcher.cpp +++ b/src/plasma/private/effectwatcher.cpp @@ -62,7 +62,11 @@ void EffectWatcher::init(const QString &property) bool EffectWatcher::nativeEventFilter(const QByteArray &eventType, void *message, long *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; } xcb_generic_event_t *event = reinterpret_cast(message);