Mir
event_filter_chain_dispatcher.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #ifndef MIR_INPUT_EVENT_FILTER_CHAIN_DISPATCHER_H_
20 #define MIR_INPUT_EVENT_FILTER_CHAIN_DISPATCHER_H_
21 
24 
25 #include <vector>
26 #include <mutex>
27 
28 namespace mir
29 {
30 namespace input
31 {
32 
34 {
35 public:
37  std::initializer_list<std::shared_ptr<EventFilter> const> const& values,
38  std::shared_ptr<InputDispatcher> const& next_dispatcher);
39 
40  // CompositeEventFilter
41  bool handle(MirEvent const& event) override;
42  void append(std::shared_ptr<EventFilter> const& filter) override;
43  void prepend(std::shared_ptr<EventFilter> const& filter) override;
44 
45  // InputDispatcher
46  bool dispatch(MirEvent const& event) override;
47  void start() override;
48  void stop() override;
49 
50 private:
51  std::mutex filter_guard;
52 
53  std::vector<std::weak_ptr<EventFilter>> filters;
54  std::shared_ptr<InputDispatcher> const next_dispatcher;
55 };
56 
57 }
58 }
59 
60 #endif // MIR_INPUT_EVENT_FILTER_CHAIN_DISPATCHER_H_
All things Mir.
Definition: atomic_callback.h:25
The InputDispatchers role is to decide what should happen with user input events. ...
Definition: input_dispatcher.h:38
void start() override
Definition: event_filter_chain_dispatcher.cpp:74
bool dispatch(MirEvent const &event) override
Definition: event_filter_chain_dispatcher.cpp:65
void prepend(std::shared_ptr< EventFilter > const &filter) override
Definition: event_filter_chain_dispatcher.cpp:58
void append(std::shared_ptr< EventFilter > const &filter) override
Definition: event_filter_chain_dispatcher.cpp:51
void stop() override
Definition: event_filter_chain_dispatcher.cpp:79
Definition: composite_event_filter.h:31
bool handle(MirEvent const &event) override
Definition: event_filter_chain_dispatcher.cpp:32
Definition: event_filter_chain_dispatcher.h:33
EventFilterChainDispatcher(std::initializer_list< std::shared_ptr< EventFilter > const > const &values, std::shared_ptr< InputDispatcher > const &next_dispatcher)
Definition: event_filter_chain_dispatcher.cpp:23
Definition: event.h:30

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016