Mir
internal_client.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016-2020 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 <functional>
23 #include <memory>
24 #include <string>
25 
26 namespace mir { class Server; namespace scene { class Session; }}
27 
28 struct wl_display;
29 
30 namespace miral
31 {
40 {
41 public:
43  std::function<void(struct ::wl_display* display)> client_code,
44  std::function<void(std::weak_ptr<mir::scene::Session> const session)> connect_notification);
45 
46  template <typename ClientObject>
47  explicit StartupInternalClient(ClientObject const& client_object) :
48  StartupInternalClient(client_object, client_object) {}
49 
51 
52  void operator()(mir::Server& server);
53 
54 private:
55  class Self;
56  std::shared_ptr<Self> internal_client;
57 };
58 
60 {
61 public:
64 
65  void operator()(mir::Server& server);
66 
67  void launch(
68  std::function<void(struct ::wl_display* display)> const& wayland_fd,
69  std::function<void(std::weak_ptr<mir::scene::Session> const session)> const& connect_notification) const;
70 
71  template <typename ClientObject>
72  void launch(ClientObject& client_object) const
73  {
74  launch(
75  [&](struct ::wl_display* display) { client_object(display); },
76  [&](std::weak_ptr<mir::scene::Session> const session) { client_object(session); });
77  }
78 
79 private:
80  struct Self;
81  std::shared_ptr<Self> self;
82 };
83 }
84 
85 #endif //MIRAL_INTERNAL_CLIENT_H
Definition: internal_client.h:60
void operator()(mir::Server &server)
void launch(std::function< void(struct ::wl_display *display)> const &wayland_fd, std::function< void(std::weak_ptr< mir::scene::Session > const session)> const &connect_notification) const
void launch(ClientObject &client_object) const
Definition: internal_client.h:72
Wrapper for running an internal Mir client at startup.
Definition: internal_client.h:40
void operator()(mir::Server &server)
StartupInternalClient(ClientObject const &client_object)
Definition: internal_client.h:47
StartupInternalClient(std::function< void(struct ::wl_display *display)> client_code, std::function< void(std::weak_ptr< mir::scene::Session > const session)> connect_notification)
Definition: splash_session.h:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:31

Copyright © 2012-2021 Canonical Ltd.
Generated on Thu Jun 17 07:34:44 UTC 2021
This documentation is licensed under the GPL version 2 or 3.