diff --git a/README.md b/README.md index 55f8c2e..e7e2167 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Where supported, it also will suppport server-side decorations (failing back to Full list of protocols supported: * [Core protocol](https://wayland.app/protocols/wayland) + * [wl_fixes](https://wayland.app/protocols/wayland#wl_fixes) (optional) * [XDG shell](https://wayland.app/protocols/xdg-shell) (required) * [Content type hint](https://wayland.app/protocols/content-type-v1) (optional) * [Cursor Shape](https://wayland.app/protocols/cursor-shape-v1) (optional) diff --git a/wayland/Display.cpp b/wayland/Display.cpp index 3106311..d9927e1 100644 --- a/wayland/Display.cpp +++ b/wayland/Display.cpp @@ -10,6 +10,9 @@ static constexpr uint32_t MINIMUM_WL_COMPOSITOR_VERSION = 4; static constexpr uint32_t DESIRED_WL_COMPOSITOR_VERSION = 6; +static constexpr uint32_t MINIMUM_WL_FIXES_VERSION = 1; +static constexpr uint32_t DESIRED_WL_FIXES_VERSION = 1; + static constexpr uint32_t MINIMUM_WL_SEAT_VERSION = 7; static constexpr uint32_t DESIRED_WL_SEAT_VERSION = 7; @@ -62,6 +65,15 @@ Display::Display() { DESIRED_WL_COMPOSITOR_VERSION )); } + else if (!strcmp(wl_fixes_interface.name, interface) + && version >= MINIMUM_WL_FIXES_VERSION) + { + self._fixes.reset(do_bind( + wl_registry, name, version, + &wl_fixes_interface, + DESIRED_WL_FIXES_VERSION + )); + } else if (!strcmp(wl_seat_interface.name, interface) && version >= MINIMUM_WL_SEAT_VERSION) { @@ -181,6 +193,10 @@ Display::Display() { _has_fractional_scale = _fractional_scale_manager && _viewporter; } +Display::~Display() { + if (_fixes) wl_fixes_destroy_registry(_fixes.get(), _registry.get()); +} + void Display::poll_events() { while (wl_display_prepare_read(_display.get())) { wl_display_dispatch_pending(_display.get()); diff --git a/wayland/Display.hpp b/wayland/Display.hpp index cc08f61..7fe64fd 100644 --- a/wayland/Display.hpp +++ b/wayland/Display.hpp @@ -3,6 +3,7 @@ #include "cursor/CursorManagerBase.hpp" #include "Seat.hpp" #include "XkbPointer.hpp" +#include "wayland/WaylandPointer.hpp" #include @@ -16,7 +17,7 @@ class Display { Display(); Display(const Display&) = delete; Display(Display&&) noexcept = delete; - ~Display() = default; + ~Display(); Display& operator=(const Display&) = delete; Display& operator=(Display&&) noexcept = delete; @@ -34,6 +35,7 @@ class Display { std::forward_list _seats; // Optional protocols + WaylandPointer _fixes; WaylandPointer _shm; // Only needed for wl-cursor theme cursors WaylandPointer _content_type_manager; WaylandPointer _fractional_scale_manager; diff --git a/wayland/WaylandPointer.hpp b/wayland/WaylandPointer.hpp index b8d6869..eb3a33f 100644 --- a/wayland/WaylandPointer.hpp +++ b/wayland/WaylandPointer.hpp @@ -28,6 +28,10 @@ struct WaylandDeleter { wl_display_disconnect(display); } + void operator()(wl_fixes *fixes) const noexcept { + wl_fixes_destroy(fixes); + } + void operator()(wl_keyboard *wl_keyboard) const noexcept { wl_keyboard_release(wl_keyboard); }