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 
17 #ifndef MIRAL_INTERNAL_CLIENT_H
18 #define MIRAL_INTERNAL_CLIENT_H
19 
20 #include <functional>
21 #include <memory>
22 #include <string>
23 
24 namespace mir { class Server; namespace scene { class Session; }}
25 
26 struct wl_display;
27 
28 namespace miral
29 {
38 {
39 public:
41  std::function<void(struct ::wl_display* display)> client_code,
42  std::function<void(std::weak_ptr<mir::scene::Session> const session)> connect_notification);
43 
44  template <typename ClientObject>
45  explicit StartupInternalClient(ClientObject const& client_object) :
46  StartupInternalClient(client_object, client_object) {}
47 
49 
50  void operator()(mir::Server& server);
51 
52 private:
53  class Self;
54  std::shared_ptr<Self> internal_client;
55 };
56 
58 {
59 public:
62 
63  void operator()(mir::Server& server);
64 
65  void launch(
66  std::function<void(struct ::wl_display* display)> const& wayland_fd,
67  std::function<void(std::weak_ptr<mir::scene::Session> const session)> const& connect_notification) const;
68 
69  template <typename ClientObject>
70  void launch(ClientObject& client_object) const
71  {
72  launch(
73  [&](struct ::wl_display* display) { client_object(display); },
74  [&](std::weak_ptr<mir::scene::Session> const session) { client_object(session); });
75  }
76 
77 private:
78  struct Self;
79  std::shared_ptr<Self> self;
80 };
81 }
82 
83 #endif //MIRAL_INTERNAL_CLIENT_H
Definition: internal_client.h:58
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:70
Wrapper for running an internal Mir client at startup.
Definition: internal_client.h:38
void operator()(mir::Server &server)
StartupInternalClient(ClientObject const &client_object)
Definition: internal_client.h:45
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:22
Mir Abstraction Layer.
Definition: floating_window_manager.h:29

Copyright © 2012-2022 Canonical Ltd.
Generated on śro, 1 cze 2022, 16:52:55 UTC
This documentation is licensed under the GPL version 2 or 3.