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 #include <set>
28 
29 struct wl_display;
30 struct wl_client;
31 struct wl_resource;
32 
33 namespace mir { class Server; }
34 
35 namespace miral
36 {
37 class Window;
38 
49 {
50 public:
53 
54  void operator()(mir::Server& server) const;
55 
59 
64  auto all_supported() const -> std::set<std::string>;
65 
68  class Context
69  {
70  public:
71  virtual auto display() const -> wl_display* = 0;
72  virtual void run_on_wayland_mainloop(std::function<void()>&& work) const = 0;
73 
74  protected:
75  Context() = default;
76  virtual ~Context() = default;
77  Context(Context const&) = delete;
78  Context& operator=(Context const&) = delete;
79  };
80 
83  struct Builder
84  {
86  std::string name;
87 
93  std::function<std::shared_ptr<void>(Context const* context)> build;
94  };
95 
97  using Filter = std::function<bool(Application const& app, char const* protocol)>;
98 
101  void set_filter(Filter const& extension_filter);
102 
108  static char const* const zwlr_layer_shell_v1;
114 
117  static char const* const zxdg_output_manager_v1;
118 
123  static char const* const zwlr_foreign_toplevel_manager_v1;
126  void add_extension(Builder const& builder);
129 
133 
137  static auto recommended() -> std::set<std::string>;
138 
143  static auto supported() -> std::set<std::string>;
144 
148  auto enable(std::string name) -> WaylandExtensions&;
149 
153  auto disable(std::string name) -> WaylandExtensions&;
154 
155 private:
156  struct Self;
157  std::shared_ptr<Self> self;
158 };
159 
163 auto application_for(wl_client* client) -> Application;
164 
168 auto application_for(wl_resource* resource) -> Application;
169 
177 auto window_for(wl_resource* surface) -> Window;
178 }
179 
180 #endif //MIRAL_WAYLAND_EXTENSIONS_H
miral
Mir Abstraction Layer.
Definition: floating_window_manager.h:31
miral::application_for
auto application_for(wl_client *client) -> Application
Get the MirAL application for a wl_client.
miral::WaylandExtensions::operator=
auto operator=(WaylandExtensions const &) -> WaylandExtensions &
miral::WaylandExtensions::Builder::name
std::string name
Name of the protocol extension.
Definition: wayland_extensions.h:86
miral::WaylandExtensions::Context::display
virtual auto display() const -> wl_display *=0
miral::WaylandExtensions::add_extension
void add_extension(Builder const &builder)
Add a bespoke Wayland extension both to "supported" and "enabled by default".
miral::Application
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
miral::WaylandExtensions::WaylandExtensions
WaylandExtensions(WaylandExtensions const &)
miral::Window
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:38
miral::WaylandExtensions::WaylandExtensions
WaylandExtensions()
Default to enabling the extensions recommended by Mir.
miral::WaylandExtensions::operator()
void operator()(mir::Server &server) const
mir
Definition: splash_session.h:24
miral::window_for
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...
miral::WaylandExtensions::enable
auto enable(std::string name) -> WaylandExtensions &
Enable a Wayland extension Throws a std::runtime_error if the extension is not supported.
miral::WaylandExtensions::add_extension_disabled_by_default
void add_extension_disabled_by_default(Builder const &builder)
Add a bespoke Wayland extension both to "supported" but not "enabled by default".
miral::WaylandExtensions::disable
auto disable(std::string name) -> WaylandExtensions &
Disable a Wayand extension Throws a std::runtime_error if the extension is not supported.
miral::WaylandExtensions::recommended
static auto recommended() -> std::set< std::string >
The set of Wayland extensions that Mir recommends. Also the set that is enabled by default upon const...
miral::WaylandExtensions::zwlr_foreign_toplevel_manager_v1
static char const *const zwlr_foreign_toplevel_manager_v1
Allows a client to get information and gain control over all toplevels of all clients Useful for task...
Definition: wayland_extensions.h:123
miral::WaylandExtensions::Context
Context information useful for implementing Wayland extensions.
Definition: wayland_extensions.h:69
miral::WaylandExtensions::zwlr_layer_shell_v1
static char const *const zwlr_layer_shell_v1
Supported wayland extensions that are not enabled by default.
Definition: wayland_extensions.h:113
miral::WaylandExtensions::zxdg_output_manager_v1
static char const *const zxdg_output_manager_v1
Allows clients to retrieve additional information about outputs.
Definition: wayland_extensions.h:117
miral::WaylandExtensions::~WaylandExtensions
~WaylandExtensions()
miral::WaylandExtensions::supported
static auto supported() -> std::set< std::string >
The set of Wayland extensions that core Mir supports. Does not include bespoke extensions A superset ...
miral::WaylandExtensions::all_supported
auto all_supported() const -> std::set< std::string >
All Wayland extensions supported. This includes both the supported() provided by Mir and any extensio...
miral::WaylandExtensions::Builder
A Builder creates and registers an extension protocol.
Definition: wayland_extensions.h:84
miral::WaylandExtensions::Builder::build
std::function< std::shared_ptr< void >Context const *context)> build
Functor that creates and registers an extension protocol.
Definition: wayland_extensions.h:93
miral::WaylandExtensions::Filter
std::function< bool(Application const &app, char const *protocol)> Filter
Definition: wayland_extensions.h:97
miral::WaylandExtensions
Enable configuration of the Wayland extensions enabled at runtime.
Definition: wayland_extensions.h:49
miral::WaylandExtensions::set_filter
void set_filter(Filter const &extension_filter)
Set an extension filter callback to control the extensions available to specific clients.
application.h

Copyright © 2012-2020 Canonical Ltd.
Generated on Sun Oct 4 22:38:34 UTC 2020
This documentation is licensed under the GPL version 2 or 3.