.. _program_listing_file_include_miral_miral_wayland_extensions.h: Program Listing for File wayland_extensions.h ============================================= |exhale_lsh| :ref:`Return to documentation for file <file_include_miral_miral_wayland_extensions.h>` (``include/miral/miral/wayland_extensions.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * Copyright © Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 or 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIRAL_WAYLAND_EXTENSIONS_H #define MIRAL_WAYLAND_EXTENSIONS_H #include "application.h" #include <functional> #include <memory> #include <string> #include <optional> #include <set> struct wl_display; struct wl_client; struct wl_resource; namespace mir { class Server; } namespace miral { class Window; class WaylandExtensions { public: WaylandExtensions(); void operator()(mir::Server& server) const; ~WaylandExtensions(); WaylandExtensions(WaylandExtensions const&); auto operator=(WaylandExtensions const&) -> WaylandExtensions&; auto all_supported() const -> std::set<std::string>; class Context { public: virtual auto display() const -> wl_display* = 0; virtual void run_on_wayland_mainloop(std::function<void()>&& work) const = 0; protected: Context() = default; virtual ~Context() = default; Context(Context const&) = delete; Context& operator=(Context const&) = delete; }; struct Builder { std::string name; std::function<std::shared_ptr<void>(Context const* context)> build; }; class EnableInfo { public: auto app() const -> Application const&; auto name() const -> const char*; auto user_preference() const -> std::optional<bool>; private: friend WaylandExtensions; EnableInfo(Application const& app, const char* name, std::optional<bool> user_preference); struct Self; std::unique_ptr<Self> const self; }; using Filter = std::function<bool(Application const& app, char const* protocol)>; using EnableCallback = std::function<bool(EnableInfo const& info)>; static char const* const zwlr_layer_shell_v1; static char const* const zxdg_output_manager_v1; static char const* const zwlr_foreign_toplevel_manager_v1; static char const* const zwp_virtual_keyboard_manager_v1; static const char* const zwp_input_method_v1; static const char* const zwp_input_panel_v1; static char const* const zwp_input_method_manager_v2; static char const* const zwlr_screencopy_manager_v1; static char const* const zwlr_virtual_pointer_manager_v1; static char const* const ext_session_lock_manager_v1; void add_extension(Builder const& builder); void add_extension_disabled_by_default(Builder const& builder); static auto recommended() -> std::set<std::string>; static auto supported() -> std::set<std::string>; auto enable(std::string name) -> WaylandExtensions&; auto disable(std::string name) -> WaylandExtensions&; auto conditionally_enable(std::string name, EnableCallback const& callback) -> WaylandExtensions&; private: struct Self; std::shared_ptr<Self> self; }; auto application_for(wl_client* client) -> Application; auto application_for(wl_resource* resource) -> Application; auto window_for(wl_resource* surface) -> Window; } #endif //MIRAL_WAYLAND_EXTENSIONS_H