Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
surface_stack.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 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 #ifndef MIR_SURFACES_SURFACESTACK_H_
20 #define MIR_SURFACES_SURFACESTACK_H_
21 
22 #include "surface_stack_model.h"
23 
24 #include "mir/compositor/scene.h"
25 #include "mir/surfaces/depth_id.h"
27 
28 #include <memory>
29 #include <vector>
30 #include <mutex>
31 #include <map>
32 
33 namespace mir
34 {
35 namespace compositor
36 {
37 class RenderableCollection;
38 class FilterForScene;
39 class OperatorForScene;
40 }
41 
42 namespace frontend
43 {
44 struct SurfaceCreationParameters;
45 }
46 
47 namespace input
48 {
49 class InputChannelFactory;
50 class InputChannel;
51 }
52 
55 namespace surfaces
56 {
57 class SurfaceFactory;
58 class InputRegistrar;
59 class Surface;
60 
62 {
63 public:
64  explicit SurfaceStack(std::shared_ptr<SurfaceFactory> const& surface_factory,
65  std::shared_ptr<InputRegistrar> const& input_registrar);
66  virtual ~SurfaceStack() noexcept(true) {}
67 
68  // From Scene
72  virtual void set_change_callback(std::function<void()> const& f);
73 
74  // From InputTargets
75  void for_each(std::function<void(std::shared_ptr<input::InputChannel> const&)> const& callback);
76 
77  // From SurfaceStackModel
78  virtual std::weak_ptr<Surface> create_surface(const shell::SurfaceCreationParameters& params);
79 
80  virtual void destroy_surface(std::weak_ptr<Surface> const& surface);
81 
82  virtual void raise(std::weak_ptr<Surface> const& surface);
83 
84  virtual void lock();
85  virtual void unlock();
86 
87 private:
88  SurfaceStack(const SurfaceStack&) = delete;
89  SurfaceStack& operator=(const SurfaceStack&) = delete;
90 
91  void emit_change_notification();
92 
93  std::recursive_mutex guard;
94  std::shared_ptr<SurfaceFactory> const surface_factory;
95  std::shared_ptr<InputRegistrar> const input_registrar;
96 
97  typedef std::vector<std::shared_ptr<Surface>> Layer;
98  std::map<DepthId, Layer> layers_by_depth;
99 
100  std::mutex notify_change_mutex;
101  std::function<void()> notify_change;
102 };
103 
104 }
105 }
106 
107 #endif /* MIR_SURFACES_SURFACESTACK_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013