Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
session_manager.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: Thomas Voss <thomas.voss@canonical.com>
17  */
18 
19 #ifndef MIR_SHELL_APPLICATION_MANAGER_H_
20 #define MIR_SHELL_APPLICATION_MANAGER_H_
21 
23 #include "mir/frontend/shell.h"
25 
26 #include <mutex>
27 #include <memory>
28 #include <vector>
29 
30 namespace mir
31 {
32 
33 namespace frontend
34 {
35 class EventSink;
36 }
38 namespace shell
39 {
40 class SurfaceFactory;
41 class SessionContainer;
42 class FocusSequence;
43 class FocusSetter;
44 class Session;
45 class InputRegistrar;
46 class SnapshotStrategy;
47 class SessionEventSink;
48 class SessionListener;
49 struct SurfaceCreationParameters;
50 
52 {
53 public:
54  explicit SessionManager(std::shared_ptr<SurfaceFactory> const& surface_factory,
55  std::shared_ptr<SessionContainer> const& app_container,
56  std::shared_ptr<FocusSequence> const& focus_sequence,
57  std::shared_ptr<FocusSetter> const& focus_setter,
58  std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
59  std::shared_ptr<SessionEventSink> const& session_event_sink,
60  std::shared_ptr<SessionListener> const& session_listener);
61  virtual ~SessionManager();
62 
63  virtual std::shared_ptr<frontend::Session> open_session(
64  std::string const& name, std::shared_ptr<frontend::EventSink> const& sink);
65  virtual void close_session(std::shared_ptr<frontend::Session> const& session);
66 
67  frontend::SurfaceId create_surface_for(std::shared_ptr<frontend::Session> const& session,
68  SurfaceCreationParameters const& params);
69 
70  void focus_next();
71  std::weak_ptr<Session> focussed_application() const;
72  void set_focus_to(std::shared_ptr<Session> const& focus);
73 
74  void handle_surface_created(std::shared_ptr<frontend::Session> const& session);
75 
76 protected:
77  SessionManager(const SessionManager&) = delete;
78  SessionManager& operator=(const SessionManager&) = delete;
79 
80 private:
81  std::shared_ptr<SurfaceFactory> const surface_factory;
82  std::shared_ptr<SessionContainer> const app_container;
83  std::shared_ptr<FocusSequence> const focus_sequence;
84  std::shared_ptr<FocusSetter> const focus_setter;
85  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
86  std::shared_ptr<SessionEventSink> const session_event_sink;
87  std::shared_ptr<SessionListener> const session_listener;
88 
89  std::mutex mutex;
90  std::weak_ptr<Session> focus_application;
91 
92  void set_focus_to_locked(std::unique_lock<std::mutex> const& lock, std::shared_ptr<Session> const& next_focus);
93 };
94 
95 }
96 }
97 
98 #endif // MIR_SHELL_APPLICATION_MANAGER_H_

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