Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
application_session.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-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 <racarr@canonical.com>
17  */
18 
19 #ifndef MIR_SCENE_APPLICATION_SESSION_H_
20 #define MIR_SCENE_APPLICATION_SESSION_H_
21 
22 #include "mir/scene/session.h"
23 
24 #include <atomic>
25 #include <map>
26 #include <mutex>
27 
28 namespace mir
29 {
30 namespace frontend
31 {
32 class EventSink;
33 }
34 
35 namespace scene
36 {
37 class SessionListener;
38 class Surface;
39 class SurfaceCoordinator;
40 class SnapshotStrategy;
41 
43 {
44 public:
46  std::shared_ptr<SurfaceCoordinator> const& surface_coordinator,
47  pid_t pid,
48  std::string const& session_name,
49  std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
50  std::shared_ptr<SessionListener> const& session_listener,
51  std::shared_ptr<frontend::EventSink> const& sink);
52 
54 
57  std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const;
58 
59  void take_snapshot(SnapshotCallback const& snapshot_taken);
60  std::shared_ptr<Surface> default_surface() const;
61 
62  std::string name() const;
63  pid_t process_id() const override;
64 
66 
67  void hide();
68  void show();
69 
71 
73 
74  void start_prompt_session() override;
75  void stop_prompt_session() override;
76 
77 protected:
78  ApplicationSession(ApplicationSession const&) = delete;
80 
81 private:
82  std::shared_ptr<SurfaceCoordinator> const surface_coordinator;
83  pid_t const pid;
84  std::string const session_name;
85  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
86  std::shared_ptr<SessionListener> const session_listener;
87  std::shared_ptr<frontend::EventSink> const event_sink;
88 
89  frontend::SurfaceId next_id();
90 
91  std::atomic<int> next_surface_id;
92 
93  typedef std::map<frontend::SurfaceId, std::shared_ptr<Surface>> Surfaces;
94  Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;
95  std::mutex mutable surfaces_mutex;
96  Surfaces surfaces;
97 };
98 
99 }
100 } // namespace mir
101 
102 #endif // MIR_SCENE_APPLICATION_SESSION_H_
void destroy_surface(frontend::SurfaceId surface)
Definition: application_session.cpp:126
All things Mir.
Definition: aging_buffer.h:24
pid_t process_id() const override
Definition: application_session.cpp:145
Definition: session.h:33
frontend::SurfaceId create_surface(SurfaceCreationParameters const &params)
Definition: application_session.cpp:74
void take_snapshot(SnapshotCallback const &snapshot_taken)
Definition: application_session.cpp:108
std::function< void(Snapshot const &)> SnapshotCallback
Definition: snapshot.h:39
Definition: application_session.h:42
std::shared_ptr< Surface > default_surface() const
Definition: application_session.cpp:116
void hide()
Definition: application_session.cpp:159
ApplicationSession & operator=(ApplicationSession const &)=delete
void start_prompt_session() override
Definition: application_session.cpp:187
void send_display_config(graphics::DisplayConfiguration const &info)
Definition: application_session.cpp:177
MirLifecycleState
Definition: common.h:89
Definition: int_wrapper.h:27
~ApplicationSession()
Definition: application_session.cpp:59
std::shared_ptr< frontend::Surface > get_surface(frontend::SurfaceId surface) const
Definition: application_session.cpp:101
void force_requests_to_complete()
Definition: application_session.cpp:150
Definition: surface_creation_parameters.h:38
void stop_prompt_session() override
Definition: application_session.cpp:197
void set_lifecycle_state(MirLifecycleState state)
Definition: application_session.cpp:182
ApplicationSession(std::shared_ptr< SurfaceCoordinator > const &surface_coordinator, pid_t pid, std::string const &session_name, std::shared_ptr< SnapshotStrategy > const &snapshot_strategy, std::shared_ptr< SessionListener > const &session_listener, std::shared_ptr< frontend::EventSink > const &sink)
std::string name() const
Definition: application_session.cpp:140
void show()
Definition: application_session.cpp:168
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:159

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