Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
application_session.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 <racarr@canonical.com>
17  */
18 
19 #ifndef MIR_SHELL_APPLICATION_SESSION_H_
20 #define MIR_SHELL_APPLICATION_SESSION_H_
21 
22 #include "mir/shell/session.h"
23 
24 #include <map>
25 
26 namespace mir
27 {
28 namespace frontend
29 {
30 class EventSink;
31 }
32 namespace shell
33 {
34 class SurfaceFactory;
35 class Surface;
36 class SnapshotStrategy;
37 class SessionListener;
38 
40 {
41 public:
43  std::shared_ptr<SurfaceFactory> const& surface_factory,
44  std::string const& session_name,
45  std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
46  std::shared_ptr<SessionListener> const& session_listener,
47  std::shared_ptr<frontend::EventSink> const& sink);
48 
50 
53  std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const;
54 
55  void take_snapshot(SnapshotCallback const& snapshot_taken);
56  std::shared_ptr<Surface> default_surface() const;
57 
58  std::string name() const;
59 
61 
62  void hide();
63  void show();
64 
66  int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value);
67 
69 
70 protected:
71  ApplicationSession(ApplicationSession const&) = delete;
73 
74 private:
75  std::shared_ptr<SurfaceFactory> const surface_factory;
76  std::string const session_name;
77  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
78  std::shared_ptr<SessionListener> const session_listener;
79  std::shared_ptr<frontend::EventSink> const event_sink;
80 
81  frontend::SurfaceId next_id();
82 
83  std::atomic<int> next_surface_id;
84 
85  typedef std::map<frontend::SurfaceId, std::shared_ptr<Surface>> Surfaces;
86  Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;
87  std::mutex mutable surfaces_mutex;
88  Surfaces surfaces;
89 };
90 
91 }
92 } // namespace mir
93 
94 #endif // MIR_SHELL_APPLICATION_SESSION_H_

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013