2
* Copyright © 2012 Canonical Ltd.
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.
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.
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/>.
16
* Authored by: Alan Griffiths <alan@octopull.co.uk>
19
#ifndef MIR_SURFACES_SURFACESTACK_H_
20
#define MIR_SURFACES_SURFACESTACK_H_
22
#include "surface_stack_model.h"
24
#include "mir/compositor/scene.h"
25
#include "mir/surfaces/depth_id.h"
26
#include "mir/input/input_targets.h"
37
class RenderableCollection;
39
class OperatorForScene;
44
struct SurfaceCreationParameters;
49
class InputChannelFactory;
53
/// Management of Surface objects. Includes the model (SurfaceStack and Surface
54
/// classes) and controller (SurfaceController) elements of an MVC design.
62
class SurfaceStack : public compositor::Scene, public input::InputTargets, public SurfaceStackModel
65
explicit SurfaceStack(
66
std::shared_ptr<SurfaceFactory> const& surface_factory,
67
std::shared_ptr<InputRegistrar> const& input_registrar,
68
std::shared_ptr<SurfacesReport> const& report);
69
virtual ~SurfaceStack() noexcept(true) {}
72
virtual void for_each_if(compositor::FilterForScene &filter, compositor::OperatorForScene &op);
73
virtual void reverse_for_each_if(compositor::FilterForScene& filter,
74
compositor::OperatorForScene& op);
75
virtual void set_change_callback(std::function<void()> const& f);
78
void for_each(std::function<void(std::shared_ptr<input::InputChannel> const&)> const& callback);
80
// From SurfaceStackModel
81
virtual std::weak_ptr<Surface> create_surface(const shell::SurfaceCreationParameters& params);
83
virtual void destroy_surface(std::weak_ptr<Surface> const& surface);
85
virtual void raise(std::weak_ptr<Surface> const& surface);
88
virtual void unlock();
91
SurfaceStack(const SurfaceStack&) = delete;
92
SurfaceStack& operator=(const SurfaceStack&) = delete;
94
void emit_change_notification();
96
std::recursive_mutex guard;
97
std::shared_ptr<SurfaceFactory> const surface_factory;
98
std::shared_ptr<InputRegistrar> const input_registrar;
99
std::shared_ptr<SurfacesReport> const report;
101
typedef std::vector<std::shared_ptr<Surface>> Layer;
102
std::map<DepthId, Layer> layers_by_depth;
104
std::mutex notify_change_mutex;
105
std::function<void()> notify_change;
111
#endif /* MIR_SURFACES_SURFACESTACK_H_ */