Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions wayland/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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_fixes>(
wl_registry, name, version,
&wl_fixes_interface,
DESIRED_WL_FIXES_VERSION
));
}
else if (!strcmp(wl_seat_interface.name, interface)
&& version >= MINIMUM_WL_SEAT_VERSION)
{
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 3 additions & 1 deletion wayland/Display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "cursor/CursorManagerBase.hpp"
#include "Seat.hpp"
#include "XkbPointer.hpp"
#include "wayland/WaylandPointer.hpp"

#include <forward_list>

Expand All @@ -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;
Expand All @@ -34,6 +35,7 @@ class Display {
std::forward_list<Seat> _seats;

// Optional protocols
WaylandPointer<wl_fixes> _fixes;
WaylandPointer<wl_shm> _shm; // Only needed for wl-cursor theme cursors
WaylandPointer<wp_content_type_manager_v1> _content_type_manager;
WaylandPointer<wp_fractional_scale_manager_v1> _fractional_scale_manager;
Expand Down
4 changes: 4 additions & 0 deletions wayland/WaylandPointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading