Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mir_connection.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 #ifndef MIR_CLIENT_MIR_CONNECTION_H_
19 #define MIR_CLIENT_MIR_CONNECTION_H_
20 
21 #include <string>
22 #include <memory>
23 #include <unordered_set>
24 #include <unordered_map>
25 
26 #include <mutex>
27 
28 #include "mir_protobuf.pb.h"
29 
32 
33 #include "client_platform.h"
34 #include "client_context.h"
35 
36 #include "mir_wait_handle.h"
37 
38 namespace mir
39 {
41 namespace client
42 {
43 class ConnectionConfiguration;
44 class ClientPlatformFactory;
45 class SurfaceMap;
46 class DisplayConfiguration;
47 class LifecycleControl;
48 
49 namespace rpc
50 {
51 class MirBasicRpcChannel;
52 }
53 }
54 
55 namespace input
56 {
57 namespace receiver
58 {
59 class InputPlatform;
60 }
61 }
62 
63 namespace logging
64 {
65 class Logger;
66 }
67 }
68 
70 {
71 public:
72  MirConnection();
73 
75  ~MirConnection() noexcept;
76 
77  MirConnection(MirConnection const &) = delete;
78  MirConnection& operator=(MirConnection const &) = delete;
79 
81  MirSurfaceParameters const & params,
82  mir_surface_callback callback,
83  void * context);
85  MirSurface *surface,
86  mir_surface_callback callback,
87  void *context);
88 
89  char const * get_error_message();
90  void set_error_message(std::string const& error);
91 
93  const char* app_name,
94  mir_connected_callback callback,
95  void * context);
96 
98 
99  MirWaitHandle* drm_auth_magic(unsigned int magic,
101  void* context);
102 
104 
106 
107  void populate(MirPlatformPackage& platform_package);
110  unsigned int formats_size, unsigned int& valid_formats);
111 
112  std::shared_ptr<mir::client::ClientPlatform> get_client_platform();
113 
114  static bool is_valid(MirConnection *connection);
115 
117 
118  EGLNativeDisplayType egl_native_display();
119 
120  void on_surface_created(int id, MirSurface* surface);
121 
123  void done_display_configure();
124 
125 private:
126  std::recursive_mutex mutex; // Protects all members of *this
127 
128  std::shared_ptr<mir::client::rpc::MirBasicRpcChannel> channel;
129  mir::protobuf::DisplayServer::Stub server;
130  std::shared_ptr<mir::logging::Logger> logger;
131  mir::protobuf::Void void_response;
132  mir::protobuf::Connection connect_result;
133  mir::protobuf::Void ignored;
134  mir::protobuf::ConnectParameters connect_parameters;
135  mir::protobuf::DRMAuthMagicStatus drm_auth_magic_status;
136  mir::protobuf::DisplayConfiguration display_configuration_response;
137 
138  std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory;
139  std::shared_ptr<mir::client::ClientPlatform> platform;
140  std::shared_ptr<EGLNativeDisplayType> native_display;
141 
142  std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform;
143 
144  std::string error_message;
145 
146  MirWaitHandle connect_wait_handle;
147  MirWaitHandle disconnect_wait_handle;
148  MirWaitHandle drm_auth_magic_wait_handle;
149  MirWaitHandle configure_display_wait_handle;
150 
151  std::mutex release_wait_handle_guard;
152  std::vector<MirWaitHandle*> release_wait_handles;
153 
154  std::shared_ptr<mir::client::DisplayConfiguration> const display_configuration;
155 
156  std::shared_ptr<mir::client::LifecycleControl> const lifecycle_control;
157 
158  std::shared_ptr<mir::client::SurfaceMap> surface_map;
159 
160  struct SurfaceRelease;
161 
162  void done_disconnect();
163  void connected(mir_connected_callback callback, void * context);
164  void released(SurfaceRelease );
165  void done_drm_auth_magic(mir_drm_auth_magic_callback callback, void* context);
166  bool validate_user_display_config(MirDisplayConfiguration* config);
167 };
168 
169 #endif /* MIR_CLIENT_MIR_CONNECTION_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013