Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dispatcher_input_configuration.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 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: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 
20 #ifndef MIR_INPUT_ANDROID_DISPATCHER_INPUT_CONFIGURATION_H_
21 #define MIR_INPUT_ANDROID_DISPATCHER_INPUT_CONFIGURATION_H_
22 
24 
25 #include "mir/cached_ptr.h"
26 
27 #include <utils/RefBase.h>
28 #include <utils/StrongPointer.h>
29 
30 #include <functional>
31 
32 namespace droidinput = android;
33 
34 namespace android
35 {
36 class InputReaderInterface;
37 class InputReaderPolicyInterface;
38 class InputDispatcherPolicyInterface;
39 class InputDispatcherInterface;
40 class EventHubInterface;
41 }
42 
43 namespace mir
44 {
45 namespace shell
46 {
47 class InputTargeter;
48 }
49 namespace input
50 {
51 class EventFilter;
52 class CursorListener;
53 class InputReport;
54 class InputRegion;
55 
56 namespace android
57 {
58 class InputRegistrar;
59 class WindowHandleRepository;
60 class InputThread;
61 
62 template <typename Type>
63 class CachedAndroidPtr
64 {
65  droidinput::wp<Type> cache;
66 
67  CachedAndroidPtr(CachedAndroidPtr const&) = delete;
68  CachedAndroidPtr& operator=(CachedAndroidPtr const&) = delete;
69 
70 public:
71  CachedAndroidPtr() = default;
72 
73  droidinput::sp<Type> operator()(std::function<droidinput::sp<Type>()> make)
74  {
75  auto result = cache.promote();
76  if (!result.get())
77  {
78  cache = result = make();
79  }
80  return result;
81  }
82 };
83 
84 class DispatcherInputConfiguration : public input::InputConfiguration
85 {
86 public:
87  DispatcherInputConfiguration(std::shared_ptr<EventFilter> const& event_filter,
88  std::shared_ptr<input::InputRegion> const& input_region,
89  std::shared_ptr<CursorListener> const& cursor_listener,
90  std::shared_ptr<input::InputReport> const& input_report);
91  virtual ~DispatcherInputConfiguration();
92 
93  std::shared_ptr<scene::InputRegistrar> the_input_registrar();
94  std::shared_ptr<shell::InputTargeter> the_input_targeter();
95  std::shared_ptr<input::InputManager> the_input_manager();
96 
97  void set_input_targets(std::shared_ptr<input::InputTargets> const& targets);
98 
99  virtual bool is_key_repeat_enabled();
100 
101 protected:
102  virtual droidinput::sp<droidinput::InputDispatcherInterface> the_dispatcher() = 0;
103 
104  virtual std::shared_ptr<InputThread> the_dispatcher_thread();
105 
106  virtual droidinput::sp<droidinput::InputDispatcherPolicyInterface> the_dispatcher_policy();
107 
108  std::shared_ptr<WindowHandleRepository> the_window_handle_repository();
109 
110  std::shared_ptr<EventFilter> const event_filter;
111  std::shared_ptr<input::InputRegion> const input_region;
112  std::shared_ptr<CursorListener> const cursor_listener;
113  std::shared_ptr<input::InputReport> const input_report;
114 
115  CachedPtr<input::InputManager> input_manager;
116 
117 private:
118  CachedPtr<InputThread> dispatcher_thread;
119  CachedPtr<InputRegistrar> input_registrar;
120 
121  CachedPtr<shell::InputTargeter> input_targeter;
122 
123  CachedAndroidPtr<droidinput::InputDispatcherPolicyInterface> dispatcher_policy;
124 };
125 }
126 }
127 } // namespace mir
128 
129 #endif /* MIR_INPUT_ANDROID_DISPATCHER_INPUT_CONFIGURATION_H_ */
virtual std::shared_ptr< input::InputManager > the_input_manager()=0
virtual std::shared_ptr< shell::InputTargeter > the_input_targeter()=0
virtual std::shared_ptr< scene::InputRegistrar > the_input_registrar()=0
virtual void set_input_targets(std::shared_ptr< input::InputTargets > const &targets)=0

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014