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
29struct wl_display;
30struct wl_client;
31struct wl_resource;
32
33namespace mir { class Server; }
34
35namespace miral
36{
37class Window;
38
49{
50public:
53
60 explicit WaylandExtensions(std::string const& default_value);
61
62 void operator()(mir::Server& server) const;
63
69 auto supported_extensions() const -> std::string;
70
75 static auto recommended_extensions() -> std::string;
76
79 auto operator=(WaylandExtensions const&) -> WaylandExtensions&;
80
83 class Context
84 {
85 public:
86 virtual auto display() const -> wl_display* = 0;
87 virtual void run_on_wayland_mainloop(std::function<void()>&& work) const = 0;
88
89 protected:
90 Context() = default;
91 virtual ~Context() = default;
92 Context(Context const&) = delete;
93 Context& operator=(Context const&) = delete;
94 };
95
98 struct Builder
99 {
101 std::string name;
102
108 std::function<std::shared_ptr<void>(Context const* context)> build;
109 };
110
112 using Filter = std::function<bool(Application const& app, char const* protocol)>;
113
116 void set_filter(Filter const& extension_filter);
117
128 static char const* const zwlr_layer_shell_v1;
129
132 static char const* const zxdg_output_manager_v1;
137 void add_extension(Builder const& builder);
138
142
146 static auto recommended() -> std::set<std::string>;
147
152 static auto supported() -> std::set<std::string>;
153
157 auto enable(std::string name) -> WaylandExtensions&;
158
162 auto disable(std::string name) -> WaylandExtensions&;
163
164private:
165 struct Self;
166 std::shared_ptr<Self> self;
167};
168
172auto application_for(wl_client* client) -> Application;
173
177auto application_for(wl_resource* resource) -> Application;
178
186auto window_for(wl_resource* surface) -> Window;
187}
188
189#endif //MIRAL_WAYLAND_EXTENSIONS_H
Context information useful for implementing Wayland extensions.
Definition: wayland_extensions.h:84
virtual auto display() const -> wl_display *=0
Enable configuration of the Wayland extensions enabled at runtime.
Definition: wayland_extensions.h:49
static char const *const zwlr_layer_shell_v1
Supported wayland extensions that are not enabled by default.
Definition: wayland_extensions.h:128
static auto recommended_extensions() -> std::string
Default for extensions to enabled recommended by Mir (colon separated list)
static auto supported() -> std::set< std::string >
The set of Wayland extensions that core Mir supports. Does not include bespoke extensions A superset ...
void add_extension_disabled_by_default(Builder const &builder)
Add a bespoke Wayland extension both to "supported" but not "enabled by default".
WaylandExtensions(std::string const &default_value)
Initialize "enabled by default" to a custom set of extensions (colon separated list).
void add_extension(Builder const &builder)
Add a bespoke Wayland extension both to "supported" and "enabled by default".
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...
static char const *const zxdg_output_manager_v1
Allows clients to retrieve additional information about outputs.
Definition: wayland_extensions.h:132
void operator()(mir::Server &server) const
auto enable(std::string name) -> WaylandExtensions &
Enable a Wayland extension Throws a std::runtime_error if the extension is not supported.
std::function< bool(Application const &app, char const *protocol)> Filter
Definition: wayland_extensions.h:112
auto disable(std::string name) -> WaylandExtensions &
Disable a Wayand extension Throws a std::runtime_error if the extension is not supported.
auto supported_extensions() const -> std::string
All Wayland extensions currently supported (colon separated list). This includes both the recommended...
void set_filter(Filter const &extension_filter)
Set an extension filter callback to control the extensions available to specific clients.
WaylandExtensions()
Default to enabling the extensions recommended by Mir.
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:38
char const * name
Definition: client_types.h:0
Definition: splash_session.h:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:29
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
auto application_for(wl_client *client) -> Application
Get the MirAL application for a wl_client.
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...
STL namespace.
A Builder creates and registers an extension protocol.
Definition: wayland_extensions.h:99
std::function< std::shared_ptr< void >(Context const *context)> build
Functor that creates and registers an extension protocol.
Definition: wayland_extensions.h:108
std::string name
Name of the protocol extension.
Definition: wayland_extensions.h:101

Copyright © 2012-2022 Canonical Ltd.
Generated on Wed Dec 28 21:01:08 UTC 2022
This documentation is licensed under the GPL version 2 or 3.