Mir
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 override;
58  std::shared_ptr<Surface> surface(frontend::SurfaceId surface) const override;
59 
60  void take_snapshot(SnapshotCallback const& snapshot_taken) override;
61  std::shared_ptr<Surface> default_surface() const override;
62 
63  std::string name() const override;
64  pid_t process_id() const override;
65 
66  void force_requests_to_complete() override;
67 
68  void hide() override;
69  void show() override;
70 
71  void send_display_config(graphics::DisplayConfiguration const& info) override;
72 
73  void set_lifecycle_state(MirLifecycleState state) override;
74 
75  void start_prompt_session() override;
76  void stop_prompt_session() override;
77  void suspend_prompt_session() override;
78  void resume_prompt_session() override;
79 
80 protected:
81  ApplicationSession(ApplicationSession const&) = delete;
83 
84 private:
85  std::shared_ptr<SurfaceCoordinator> const surface_coordinator;
86  pid_t const pid;
87  std::string const session_name;
88  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
89  std::shared_ptr<SessionListener> const session_listener;
90  std::shared_ptr<frontend::EventSink> const event_sink;
91 
92  frontend::SurfaceId next_id();
93 
94  std::atomic<int> next_surface_id;
95 
96  typedef std::map<frontend::SurfaceId, std::shared_ptr<Surface>> Surfaces;
97  Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;
98  std::mutex mutable surfaces_mutex;
99  Surfaces surfaces;
100 };
101 
102 }
103 } // namespace mir
104 
105 #endif // MIR_SCENE_APPLICATION_SESSION_H_
All things Mir.
Definition: buffer_stream.h:37
frontend::SurfaceId create_surface(SurfaceCreationParameters const &params) override
Definition: application_session.cpp:80
void destroy_surface(frontend::SurfaceId surface) override
Definition: application_session.cpp:150
void show() override
Definition: application_session.cpp:192
std::shared_ptr< Surface > default_surface() const override
Definition: application_session.cpp:140
void send_display_config(graphics::DisplayConfiguration const &info) override
Definition: application_session.cpp:201
pid_t process_id() const override
Definition: application_session.cpp:169
Definition: session.h:34
void suspend_prompt_session() override
Definition: application_session.cpp:222
std::function< void(Snapshot const &)> SnapshotCallback
Definition: snapshot.h:39
std::shared_ptr< Surface > surface(frontend::SurfaceId surface) const override
Definition: application_session.cpp:125
Definition: application_session.h:42
void set_lifecycle_state(MirLifecycleState state) override
Definition: application_session.cpp:206
void hide() override
Definition: application_session.cpp:183
ApplicationSession & operator=(ApplicationSession const &)=delete
std::shared_ptr< frontend::Surface > get_surface(frontend::SurfaceId surface) const override
Definition: application_session.cpp:120
void start_prompt_session() override
Definition: application_session.cpp:211
MirLifecycleState
Definition: common.h:96
Definition: int_wrapper.h:27
void take_snapshot(SnapshotCallback const &snapshot_taken) override
Definition: application_session.cpp:132
~ApplicationSession()
Definition: application_session.cpp:65
void resume_prompt_session() override
Definition: application_session.cpp:227
Definition: surface_creation_parameters.h:41
void stop_prompt_session() override
Definition: application_session.cpp:217
void force_requests_to_complete() override
Definition: application_session.cpp:174
std::string name() const override
Definition: application_session.cpp:164
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)
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:159

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015