From 4db535db07e3bc48b3cab3367945d3a9faaed762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 2 Jan 2017 20:08:01 +0100 Subject: [PATCH] Use a templated approach for InputRedirection::processFilters Summary: An improvement from the introduction of InputEventSpy. Instead of specifying a std::function as argument, we let the compiler decide what is the best argument. Reviewers: #kwin, #plasma, mart Reviewed By: mart Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3877 --- input.cpp | 5 ----- input.h | 11 ++++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/input.cpp b/input.cpp index 8241d3c8fa..d5a0c55732 100644 --- a/input.cpp +++ b/input.cpp @@ -1882,11 +1882,6 @@ bool InputRedirection::isBreakingPointerConstraints() const return m_pointerConstraintsFilter ? m_pointerConstraintsFilter->isActive() : false; } -void InputRedirection::processFilters(std::function function) -{ - std::any_of(m_filters.constBegin(), m_filters.constEnd(), function); -} - InputDeviceHandler::InputDeviceHandler(InputRedirection *input) : QObject(input) , m_input(input) diff --git a/input.h b/input.h index dd41dcafac..575a2c6d16 100644 --- a/input.h +++ b/input.h @@ -173,10 +173,19 @@ public: * The method @p function is invoked on each input filter. Processing is stopped if * a filter returns @c true for @p function. * + * The UnaryPredicate is defined like the UnaryPredicate of std::any_of. + * The signature of the function should be equivalent to the following: + * @code + * bool function(const InputEventFilter *spy); + * @endcode + * * The intended usage is to std::bind the method to invoke on the filter with all arguments * bind. **/ - void processFilters(std::function function); + template + void processFilters(UnaryPredicate function) { + std::any_of(m_filters.constBegin(), m_filters.constEnd(), function); + } /** * Sends an event through all input event spies.