Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
android_input_registrar.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: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #ifndef MIR_INPUT_ANDROID_REGISTRAR_H_
20 #define MIR_INPUT_ANDROID_REGISTRAR_H_
21 
23 
25 
26 #include <utils/StrongPointer.h>
27 
28 #include <map>
29 #include <memory>
30 #include <mutex>
31 
32 namespace android
33 {
34 class InputDispatcherInterface;
35 class InputWindowHandle;
36 }
37 
38 namespace droidinput = android;
39 
40 namespace mir
41 {
42 namespace compositor
43 {
44 class Scene;
45 }
46 namespace scene
47 {
48 class Surface;
49 }
50 namespace input
51 {
52 namespace android
53 {
54 class InputConfiguration;
55 class InputTargeter;
56 
58 {
59 public:
60  explicit InputRegistrar(std::shared_ptr<mir::compositor::Scene> const& scene);
61  virtual ~InputRegistrar() noexcept(true);
62 
63  virtual droidinput::sp<droidinput::InputWindowHandle> handle_for_channel(std::shared_ptr<input::InputChannel const> const& channel);
64 
65  void set_dispatcher(std::shared_ptr<droidinput::InputDispatcherInterface> const& dispatcher);
68 private:
69  struct SceneObserver : mir::scene::NullObserver
70  {
71  typedef std::function<void(mir::scene::Surface*)> SurfaceCallback;
72  SceneObserver(SurfaceCallback const& add, SurfaceCallback const& remove);
73  void surface_added(scene::Surface* surface) override;
74  void surface_removed(scene::Surface* surface) override;
75  void surface_exists(scene::Surface* surface) override;
76  void scene_changed() override;
77 
78  SurfaceCallback add, remove;
79  };
80  // weak ptr as input dispatcher already has a strong references to the registrar through the mir::input::android::InputTargetEnumerator
81  std::weak_ptr<droidinput::InputDispatcherInterface> input_dispatcher;
82 
83  std::map<std::shared_ptr<input::InputChannel const>, droidinput::sp<droidinput::InputWindowHandle>> window_handles;
84 
85  std::mutex handles_mutex;
86  std::shared_ptr<compositor::Scene> const scene;
87  std::shared_ptr<SceneObserver> const observer;
88 };
89 
90 }
91 }
92 } // namespace mir
93 
94 #endif // MIR_INPUT_ANDROID_REGISTRAR_H_
All things Mir.
Definition: aging_buffer.h:24
void remove_window_handle_for_surface(mir::scene::Surface *)
virtual droidinput::sp< droidinput::InputWindowHandle > handle_for_channel(std::shared_ptr< input::InputChannel const > const &channel)
Definition: android_input_registrar.h:57
void add_window_handle_for_surface(mir::scene::Surface *)
Definition: null_observer.h:28
surface_removed
Definition: scene_report_tp.h:46
InputRegistrar(std::shared_ptr< mir::compositor::Scene > const &scene)
surface_added
Definition: scene_report_tp.h:41
void set_dispatcher(std::shared_ptr< droidinput::InputDispatcherInterface > const &dispatcher)
Definition: android_input_receiver.h:32
virtual ~InputRegistrar() noexcept(true)
Definition: surface.h:40
Interface internal to mir::input::android used for tracking the assosciation between droidinput::Inpu...
Definition: android_window_handle_repository.h:43

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014