Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
session_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012-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: Thomas Voss <thomas.voss@canonical.com>
17  */
18 
19 #ifndef MIR_SCENE_APPLICATION_MANAGER_H_
20 #define MIR_SCENE_APPLICATION_MANAGER_H_
21 
23 
24 #include <mutex>
25 #include <memory>
26 #include <vector>
27 
28 namespace mir
29 {
30 
31 namespace shell
32 {
33 class FocusSetter;
34 }
35 
36 namespace scene
37 {
38 class SessionContainer;
39 class SessionEventSink;
40 class SessionListener;
41 class SnapshotStrategy;
42 class SurfaceCoordinator;
43 class PromptSessionManager;
44 
45 
47 {
48 public:
49  explicit SessionManager(std::shared_ptr<SurfaceCoordinator> const& surface_coordinator,
50  std::shared_ptr<SessionContainer> const& app_container,
51  std::shared_ptr<shell::FocusSetter> const& focus_setter,
52  std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
53  std::shared_ptr<SessionEventSink> const& session_event_sink,
54  std::shared_ptr<SessionListener> const& session_listener,
55  std::shared_ptr<PromptSessionManager> const& prompt_session_manager);
56  virtual ~SessionManager() noexcept;
57 
58  virtual std::shared_ptr<frontend::Session> open_session(
59  pid_t client_pid,
60  std::string const& name,
61  std::shared_ptr<frontend::EventSink> const& sink) override;
62 
63  virtual void close_session(std::shared_ptr<frontend::Session> const& session) override;
64 
65  void focus_next() override;
66  std::weak_ptr<Session> focussed_application() const;
67  void set_focus_to(std::shared_ptr<Session> const& focus) override;
68 
69  void handle_surface_created(std::shared_ptr<frontend::Session> const& session) override;
70 
71  std::shared_ptr<frontend::PromptSession> start_prompt_session_for(std::shared_ptr<frontend::Session> const& session,
72  PromptSessionCreationParameters const& params) override;
73  void add_prompt_provider_for(std::shared_ptr<frontend::PromptSession> const& prompt_session,
74  std::shared_ptr<frontend::Session> const& session) override;
75  void stop_prompt_session(std::shared_ptr<frontend::PromptSession> const& prompt_session) override;
76 
77 protected:
78  SessionManager(const SessionManager&) = delete;
79  SessionManager& operator=(const SessionManager&) = delete;
80 
81 private:
82  std::shared_ptr<SurfaceCoordinator> const surface_coordinator;
83  std::shared_ptr<SessionContainer> const app_container;
84  std::shared_ptr<shell::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  std::shared_ptr<PromptSessionManager> const prompt_session_manager;
89 
90  std::mutex mutex;
91  std::weak_ptr<Session> focus_application;
92 
93  void set_focus_to_locked(std::unique_lock<std::mutex> const& lock, std::shared_ptr<Session> const& next_focus);
94 };
95 
96 }
97 }
98 
99 #endif // MIR_SCENE_APPLICATION_MANAGER_H_
All things Mir.
Definition: aging_buffer.h:24
Definition: session_coordinator.h:31
Interface used by the Shell to propagate changes in the focus model to interested views e...
Definition: focus_setter.h:33
void handle_surface_created(std::shared_ptr< frontend::Session > const &session) override
Definition: session_manager.cpp:160
void add_prompt_provider_for(std::shared_ptr< frontend::PromptSession > const &prompt_session, std::shared_ptr< frontend::Session > const &session) override
Definition: session_manager.cpp:175
SessionManager(std::shared_ptr< SurfaceCoordinator > const &surface_coordinator, std::shared_ptr< SessionContainer > const &app_container, std::shared_ptr< shell::FocusSetter > const &focus_setter, std::shared_ptr< SnapshotStrategy > const &snapshot_strategy, std::shared_ptr< SessionEventSink > const &session_event_sink, std::shared_ptr< SessionListener > const &session_listener, std::shared_ptr< PromptSessionManager > const &prompt_session_manager)
Definition: session_manager.h:46
virtual void close_session(std::shared_ptr< frontend::Session > const &session) override
Definition: session_manager.cpp:122
void set_focus_to(std::shared_ptr< Session > const &focus) override
Definition: session_manager.cpp:116
SessionManager & operator=(const SessionManager &)=delete
std::shared_ptr< frontend::PromptSession > start_prompt_session_for(std::shared_ptr< frontend::Session > const &session, PromptSessionCreationParameters const &params) override
Definition: session_manager.cpp:165
void stop_prompt_session(std::shared_ptr< frontend::PromptSession > const &prompt_session) override
Definition: session_manager.cpp:185
virtual ~SessionManager() noexcept
Definition: session_manager.cpp:59
Definition: prompt_session_creation_parameters.h:29
std::weak_ptr< Session > focussed_application() const
Definition: session_manager.cpp:155
void focus_next() override
Definition: session_manager.cpp:140
virtual std::shared_ptr< frontend::Session > open_session(pid_t client_pid, std::string const &name, std::shared_ptr< frontend::EventSink > const &sink) override
Definition: session_manager.cpp:79

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014