Mir
internal_client.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 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 2 or 3 as
6  * 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: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIRAL_INTERNAL_CLIENT_H
20 #define MIRAL_INTERNAL_CLIENT_H
21 
22 #include <mir/client/connection.h>
23 
24 #include <functional>
25 #include <memory>
26 #include <string>
27 
28 namespace mir { class Server; namespace scene { class Session; }}
29 
30 struct wl_display;
31 
32 namespace miral
33 {
42 {
43 public:
44  explicit StartupInternalClient(
45  std::string name,
46  std::function<void(mir::client::Connection connection)> client_code,
47  std::function<void(std::weak_ptr<mir::scene::Session> const session)> connect_notification);
48 
49  template <typename ClientObject>
50  explicit StartupInternalClient(std::string name, ClientObject const& client_object) :
51  StartupInternalClient(name, client_object, client_object) {}
52 
53  explicit StartupInternalClient(
54  std::function<void(struct ::wl_display* display)> client_code,
55  std::function<void(std::weak_ptr<mir::scene::Session> const session)> connect_notification);
56 
57  template <typename ClientObject>
58  explicit StartupInternalClient(ClientObject const& client_object) :
59  StartupInternalClient(client_object, client_object) {}
60 
62 
63  void operator()(mir::Server& server);
64 
65 private:
66  class Self;
67  std::shared_ptr<Self> internal_client;
68 };
69 
71 {
72 public:
75 
76  void operator()(mir::Server& server);
77 
78  void launch(
79  std::string const& name,
80  std::function<void(mir::client::Connection connection)> const& client_code,
81  std::function<void(std::weak_ptr<mir::scene::Session> const session)> const& connect_notification) const;
82 
83  template <typename ClientObject>
84  void launch(std::string const& name, ClientObject& client_object) const
85  {
86  launch(
87  name,
88  [&](mir::client::Connection connection) { client_object(connection); },
89  [&](std::weak_ptr<mir::scene::Session> const session) { client_object(session); });
90  }
91 
92  void launch(
93  std::function<void(struct ::wl_display* display)> const& wayland_fd,
94  std::function<void(std::weak_ptr<mir::scene::Session> const session)> const& connect_notification) const;
95 
96  template <typename ClientObject>
97  void launch(ClientObject& client_object) const
98  {
99  launch(
100  [&](struct ::wl_display* display) { client_object(display); },
101  [&](std::weak_ptr<mir::scene::Session> const session) { client_object(session); });
102  }
103 
104 private:
105  struct Self;
106  std::shared_ptr<Self> self;
107 };
108 }
109 
110 #endif //MIRAL_INTERNAL_CLIENT_H
Definition: splash_session.h:24
StartupInternalClient(ClientObject const &client_object)
Definition: internal_client.h:58
Definition: internal_client.h:70
void operator()(mir::Server &server)
Handle class for MirConnection - provides automatic reference counting.
Definition: connection.h:34
void launch(ClientObject &client_object) const
Definition: internal_client.h:97
void launch(std::string const &name, ClientObject &client_object) const
Definition: internal_client.h:84
char const * name
Definition: client_types.h:177
void operator()(mir::Server &server)
void launch(std::string const &name, std::function< void(mir::client::Connection connection)> const &client_code, std::function< void(std::weak_ptr< mir::scene::Session > const session)> const &connect_notification) const
StartupInternalClient(std::string name, std::function< void(mir::client::Connection connection)> client_code, std::function< void(std::weak_ptr< mir::scene::Session > const session)> connect_notification)
Wrapper for running an internal Mir client at startup.
Definition: internal_client.h:41
Mir Abstraction Layer.
Definition: floating_window_manager.h:29
StartupInternalClient(std::string name, ClientObject const &client_object)
Definition: internal_client.h:50

Copyright © 2012-2019 Canonical Ltd.
Generated on Fri Oct 11 13:53:15 UTC 2019
This documentation is licensed under the GPL version 2 or 3.