26#ifndef WAYLAND_CLIENT_HPP
27#define WAYLAND_CLIENT_HPP
36#include <wayland-version.hpp>
37#include <wayland-client-core.h>
38#include <wayland-util.hpp>
84 events_base_t() =
default;
85 events_base_t(
const events_base_t&) =
default;
86 events_base_t(events_base_t&&) noexcept = default;
87 events_base_t& operator=(const events_base_t&) = default;
88 events_base_t& operator=(events_base_t&&) noexcept = default;
89 virtual ~events_base_t() noexcept = default;
148 wl_proxy *proxy =
nullptr;
149 detail::proxy_data_t *data =
nullptr;
150 wrapper_type type = wrapper_type::standard;
151 friend class detail::argument_t;
152 friend struct detail::proxy_data_t;
155 const wl_interface *
interface = nullptr;
161 static int c_dispatcher(
const void *implementation,
void *target,
162 uint32_t opcode,
const wl_message *message,
166 proxy_t marshal_single(uint32_t opcode,
const wl_interface *interface,
167 const std::vector<detail::argument_t>& args, std::uint32_t version = 0);
170 void set_interface(
const wl_interface *iface);
171 void set_copy_constructor(
const std::function<
proxy_t(
proxy_t)>& func);
181 template <
typename...T>
182 void marshal(uint32_t opcode,
const T& ...args)
184 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
185 marshal_single(opcode,
nullptr, v);
189 template <
typename...T>
190 proxy_t marshal_constructor(uint32_t opcode,
const wl_interface *interface,
193 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
194 return marshal_single(opcode, interface, v);
198 template <
typename...T>
199 proxy_t marshal_constructor_versioned(uint32_t opcode,
const wl_interface *interface,
200 uint32_t version,
const T& ...args)
202 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
203 return marshal_single(opcode, interface, v, version);
207 void set_destroy_opcode(uint32_t destroy_opcode);
214 void set_events(std::shared_ptr<detail::events_base_t> events,
215 int(*dispatcher)(uint32_t,
const std::vector<detail::any>&,
const std::shared_ptr<detail::events_base_t>&));
218 std::shared_ptr<detail::events_base_t> get_events();
223 struct construct_proxy_wrapper_tag {};
225 proxy_t(
const proxy_t &wrapped_proxy, construct_proxy_wrapper_tag );
332 operator bool()
const;
406 read_intent(wl_display *display, wl_event_queue *event_queue =
nullptr);
410 wl_event_queue *event_queue =
nullptr;
411 bool finalized =
false;
562 int roundtrip() const;
671 int dispatch() const;
709 int dispatch_pending() const;
721 int get_error() const;
737 std::tuple<
int,
bool> flush() const;
760 operator wl_display*() const;
768#include <wayland-client-protocol.hpp>
Refcounted wrapper for C objects.
Represents a connection to the compositor and acts as a proxy to the display singleton object.
~display_t() noexcept=default
Close a connection to a Wayland display.
display_t(const std::string &name={})
Connect to a Wayland display.
display_t(int fd)
Connect to Wayland display on an already open fd.
display_t(wl_display *display)
Use an existing connection to a Wayland display to construct a waylandpp display_t.
A queue for proxy_t object events.
Represents a protocol object on the client side.
void proxy_release()
Release the wrapped object (if any), making this an empty wrapper.
bool proxy_has_object() const
Check whether this wrapper actually wraps an object.
void set_queue(event_queue_t queue)
Assign a proxy to an event queue.
uint32_t get_id() const
Get the id of a proxy object.
bool operator==(const proxy_t &right) const
Check whether two wrappers refer to the same object.
proxy_t(const proxy_t &p)
Copy Constructior.
uint32_t get_version() const
Get the protocol object version of a proxy object.
wrapper_type get_wrapper_type() const
Get the type of a proxy object.
wl_proxy * c_ptr() const
Get a pointer to the underlying C struct.
std::string get_class() const
Get the interface name (class) of a proxy object.
proxy_t(proxy_t &&p) noexcept
Move Constructior.
proxy_t & operator=(const proxy_t &p)
Assignment operator.
bool operator!=(const proxy_t &right) const
Check whether two wrappers refer to different objects.
proxy_t(wl_proxy *p, wrapper_type t=wrapper_type::standard, event_queue_t const &queue=event_queue_t())
Cronstruct a proxy_t from a wl_proxy pointer.
proxy_t & operator=(proxy_t &&p) noexcept
Move Asignment operator.
Represents an intention to read from the display file descriptor.
void cancel()
Cancel read intent.
bool is_finalized() const
Check whether this intent was already finalized with cancel or read.
void read()
Read events from display file descriptor.
std::function< void(std::string)> log_handler
Type for functions that handle log messages.
void set_log_handler(log_handler handler)
Set C library log handler.