aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2017-01-02 20:08:01 +0100
committerMartin Gräßlin <[email protected]>2017-01-02 20:08:05 +0100
commit4db535db07e3bc48b3cab3367945d3a9faaed762 (patch)
tree297499acc31c04e7b214928b47722c0d5b74eea0
parenta8db967505958ff4ee1a528213a30ca8905cdb25 (diff)
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
-rw-r--r--input.cpp5
-rw-r--r--input.h11
2 files changed, 10 insertions, 6 deletions
diff --git a/input.cpp b/input.cpp
index 8241d3c..d5a0c55 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<bool(InputEventFilter*)> 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 dd41dca..575a2c6 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<bool(InputEventFilter*)> function);
+ template <class UnaryPredicate>
+ void processFilters(UnaryPredicate function) {
+ std::any_of(m_filters.constBegin(), m_filters.constEnd(), function);
+ }
/**
* Sends an event through all input event spies.