Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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/shell/session.h"
23 
24 #include <map>
25 
26 namespace mir
27 {
28 namespace frontend
29 {
30 class EventSink;
31 }
32 namespace shell
33 {
34 class SurfaceFactory;
35 class Surface;
36 class SessionListener;
37 }
38 
39 namespace scene
40 {
41 class SnapshotStrategy;
42 
44 {
45 public:
47  std::shared_ptr<shell::SurfaceFactory> const& surface_factory,
48  pid_t pid,
49  std::string const& session_name,
50  std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
51  std::shared_ptr<shell::SessionListener> const& session_listener,
52  std::shared_ptr<frontend::EventSink> const& sink);
53 
55 
58  std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const;
59 
60  void take_snapshot(shell::SnapshotCallback const& snapshot_taken);
61  std::shared_ptr<shell::Surface> default_surface() const;
62 
63  std::string name() const;
64  pid_t process_id() const override;
65 
67 
68  void hide();
69  void show();
70 
72  int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value);
73 
75 
76 protected:
77  ApplicationSession(ApplicationSession const&) = delete;
79 
80 private:
81  std::shared_ptr<shell::SurfaceFactory> const surface_factory;
82  pid_t const pid;
83  std::string const session_name;
84  std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
85  std::shared_ptr<shell::SessionListener> const session_listener;
86  std::shared_ptr<frontend::EventSink> const event_sink;
87 
88  frontend::SurfaceId next_id();
89 
90  std::atomic<int> next_surface_id;
91 
92  typedef std::map<frontend::SurfaceId, std::shared_ptr<shell::Surface>> Surfaces;
93  Surfaces::const_iterator checked_find(frontend::SurfaceId id) const;
94  std::mutex mutable surfaces_mutex;
95  Surfaces surfaces;
96 };
97 
98 }
99 } // namespace mir
100 
101 #endif // MIR_SCENE_APPLICATION_SESSION_H_
void destroy_surface(frontend::SurfaceId surface)
Definition: application_session.cpp:122
Definition: surface_creation_parameters.h:38
Definition: session.h:33
pid_t process_id() const override
Definition: application_session.cpp:141
Definition: surface.h:37
Definition: application_session.h:43
void hide()
Definition: application_session.cpp:155
ApplicationSession & operator=(ApplicationSession const &)=delete
void send_display_config(graphics::DisplayConfiguration const &info)
Definition: application_session.cpp:183
ApplicationSession(std::shared_ptr< shell::SurfaceFactory > const &surface_factory, pid_t pid, std::string const &session_name, std::shared_ptr< SnapshotStrategy > const &snapshot_strategy, std::shared_ptr< shell::SessionListener > const &session_listener, std::shared_ptr< frontend::EventSink > const &sink)
std::function< void(Snapshot const &)> SnapshotCallback
Definition: snapshot.h:39
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire...
Definition: common.h:34
std::shared_ptr< shell::Surface > default_surface() const
Definition: application_session.cpp:112
MirLifecycleState
Definition: common.h:75
Definition: int_wrapper.h:27
void take_snapshot(shell::SnapshotCallback const &snapshot_taken)
Definition: application_session.cpp:104
~ApplicationSession()
Definition: application_session.cpp:57
std::shared_ptr< frontend::Surface > get_surface(frontend::SurfaceId surface) const
Definition: application_session.cpp:97
void force_requests_to_complete()
Definition: application_session.cpp:146
int configure_surface(frontend::SurfaceId id, MirSurfaceAttrib attrib, int value)
Definition: application_session.cpp:173
Definition: session_listener.h:31
void set_lifecycle_state(MirLifecycleState state)
Definition: application_session.cpp:188
std::string name() const
Definition: application_session.cpp:136
void show()
Definition: application_session.cpp:164
frontend::SurfaceId create_surface(shell::SurfaceCreationParameters const &params)
Definition: application_session.cpp:72
Definition: surface_factory.h:34
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:159

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