Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #include "mir/frontend/shell.h"
25 
26 #include <mutex>
27 #include <memory>
28 #include <vector>
29 
30 namespace mir
31 {
32 
33 namespace shell
34 {
35 class SurfaceFactory;
36 class FocusSetter;
37 class SessionListener;
38 }
39 
40 namespace scene
41 {
42 class SessionEventSink;
43 class SessionContainer;
44 class SnapshotStrategy;
45 
47 {
48 public:
49  explicit SessionManager(std::shared_ptr<shell::SurfaceFactory> const& surface_factory,
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<shell::SessionListener> const& session_listener);
55  virtual ~SessionManager();
56 
57  virtual std::shared_ptr<frontend::Session> open_session(
58  pid_t client_pid,
59  std::string const& name,
60  std::shared_ptr<frontend::EventSink> const& sink);
61 
62  virtual void close_session(std::shared_ptr<frontend::Session> const& session);
63 
64  frontend::SurfaceId create_surface_for(std::shared_ptr<frontend::Session> const& session,
65  shell::SurfaceCreationParameters const& params);
66 
67  void focus_next();
68  std::weak_ptr<shell::Session> focussed_application() const;
69  void set_focus_to(std::shared_ptr<shell::Session> const& focus);
70 
71  void handle_surface_created(std::shared_ptr<frontend::Session> const& session);
72 
73 protected:
74  SessionManager(const SessionManager&) = delete;
75  SessionManager& operator=(const SessionManager&) = delete;
76 
77 private:
78  std::shared_ptr<shell::SurfaceFactory> const surface_factory;
79  std::shared_ptr<SessionContainer> const app_container;
80  std::shared_ptr<shell::FocusSetter> const focus_setter;
81  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
82  std::shared_ptr<SessionEventSink> const session_event_sink;
83  std::shared_ptr<shell::SessionListener> const session_listener;
84 
85  std::mutex mutex;
86  std::weak_ptr<shell::Session> focus_application;
87 
88  void set_focus_to_locked(std::unique_lock<std::mutex> const& lock, std::shared_ptr<shell::Session> const& next_focus);
89 };
90 
91 }
92 }
93 
94 #endif // MIR_SCENE_APPLICATION_MANAGER_H_
Definition: surface_creation_parameters.h:38
virtual std::shared_ptr< frontend::Session > open_session(pid_t client_pid, std::string const &name, std::shared_ptr< frontend::EventSink > const &sink)
Definition: session_manager.cpp:76
void handle_surface_created(std::shared_ptr< frontend::Session > const &session)
Definition: session_manager.cpp:168
void set_focus_to(std::shared_ptr< shell::Session > const &focus)
Definition: session_manager.cpp:113
Definition: session_manager.h:46
Definition: focus_controller.h:30
void focus_next()
Definition: session_manager.cpp:134
virtual ~SessionManager()
Definition: session_manager.cpp:56
virtual void close_session(std::shared_ptr< frontend::Session > const &session)
Definition: session_manager.cpp:119
Definition: shell.h:39
SessionManager & operator=(const SessionManager &)=delete
Definition: int_wrapper.h:27
SessionManager(std::shared_ptr< shell::SurfaceFactory > const &surface_factory, 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< shell::SessionListener > const &session_listener)
std::weak_ptr< shell::Session > focussed_application() const
Definition: session_manager.cpp:149
frontend::SurfaceId create_surface_for(std::shared_ptr< frontend::Session > const &session, shell::SurfaceCreationParameters const &params)
Definition: session_manager.cpp:157

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014