Mir
wayland_extensions.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2018-2019 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_WAYLAND_EXTENSIONS_H
20 #define MIRAL_WAYLAND_EXTENSIONS_H
21 
22 #include "application.h"
23 
24 #include <functional>
25 #include <memory>
26 #include <string>
27 
28 struct wl_display;
29 struct wl_client;
30 struct wl_resource;
31 
32 namespace mir { class Server; }
33 
34 namespace miral
35 {
36 class Window;
37 
48 {
49 public:
52 
56  explicit WaylandExtensions(std::string const& default_value);
57 
58  void operator()(mir::Server& server) const;
59 
65  auto supported_extensions() const -> std::string;
66 
69  static auto recommended_extensions() -> std::string;
70 
73  auto operator=(WaylandExtensions const&) -> WaylandExtensions&;
74 
77  class Context
78  {
79  public:
80  virtual auto display() const -> wl_display* = 0;
81  virtual void run_on_wayland_mainloop(std::function<void()>&& work) const = 0;
82 
83  protected:
84  Context() = default;
85  virtual ~Context() = default;
86  Context(Context const&) = delete;
87  Context& operator=(Context const&) = delete;
88  };
89 
92  struct Builder
93  {
95  std::string name;
96 
102  std::function<std::shared_ptr<void>(Context const* context)> build;
103  };
104 
106  using Filter = std::function<bool(Application const& app, char const* protocol)>;
107 
110  void set_filter(Filter const& extension_filter);
111 
114  void add_extension(Builder const& builder);
115 
118  void add_extension_disabled_by_default(Builder const& builder);
119 
120 private:
121  struct Self;
122  std::shared_ptr<Self> self;
123 };
124 
128 auto application_for(wl_client* client) -> Application;
129 
133 auto application_for(wl_resource* resource) -> Application;
134 
142 auto window_for(wl_resource* surface) -> Window;
143 }
144 
145 #endif //MIRAL_WAYLAND_EXTENSIONS_H
Definition: splash_session.h:24
A Builder creates and registers an extension protocol.
Definition: wayland_extensions.h:92
std::string name
Name of the protocol extension.
Definition: wayland_extensions.h:95
std::function< bool(Application const &app, char const *protocol)> Filter
Definition: wayland_extensions.h:106
Context information useful for implementing Wayland extensions.
Definition: wayland_extensions.h:77
auto window_for(wl_resource *surface) -> Window
Get the MirAL Window for a Wayland Surface, XdgSurface, etc. Note that there may not be a correspondi...
Enable configuration of the Wayland extensions enabled at runtime.
Definition: wayland_extensions.h:47
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:37
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
auto application_for(wl_resource *resource) -> Application
Get the MirAL application for a wl_resource.
Mir Abstraction Layer.
Definition: floating_window_manager.h:29

Copyright © 2012-2019 Canonical Ltd.
Generated on Fri May 24 15:24:26 UTC 2019
This documentation is licensed under the GPL version 2 or 3.