Mir
legacy_scene_change_notification.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 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_SCENE_SIMPLE_OBSERVER_H_
20 #define MIR_SCENE_SIMPLE_OBSERVER_H_
21 
22 #include "mir/scene/observer.h"
23 
24 #include <functional>
25 #include <map>
26 #include <mutex>
27 
28 namespace mir
29 {
30 namespace geometry { class Rectangle; }
31 namespace scene
32 {
33 class SurfaceObserver;
34 
35 // A simple implementation of surface observer which forwards all changes to a provided callback.
36 // Also installs surface observers on each added surface which in turn forward each change to
37 // said callback.
39 {
40 public:
42  std::function<void()> const& scene_notify_change,
43  std::function<void(int)> const& buffer_notify_change);
44 
46  std::function<void()> const& scene_notify_change,
47  std::function<void(int frames, mir::geometry::Rectangle const& damage)> const& damage_notify_change);
48 
50 
51  void surface_added(Surface* surface) override;
52  void surface_removed(Surface* surface) override;
53  void surfaces_reordered() override;
54 
55  void scene_changed() override;
56 
57  void surface_exists(Surface* surface) override;
58  void end_observation() override;
59 
60 private:
61  std::function<void()> const scene_notify_change;
62  std::function<void(int)> const buffer_notify_change;
63  std::function<void(int frames, mir::geometry::Rectangle const& damage)> const damage_notify_change;
64 
65  std::mutex surface_observers_guard;
66  std::map<Surface*, std::weak_ptr<SurfaceObserver>> surface_observers;
67 
68  void add_surface_observer(Surface* surface);
69 };
70 
71 }
72 } // namespace mir
73 
74 #endif // MIR_SCENE_SIMPLE_OBSERVER_H_
All things Mir.
Definition: atomic_callback.h:25
An observer for top level notifications of scene changes. In order to receive more granular change no...
Definition: observer.h:33
surface_removed
Definition: scene_report_tp.h:46
surface_added
Definition: scene_report_tp.h:41
Definition: rectangle.h:33
Definition: legacy_scene_change_notification.h:38
Definition: surface.h:47

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016