26#ifndef WAYLAND_CLIENT_HPP
27#define WAYLAND_CLIENT_HPP
38#include <wayland-version.hpp>
39#include <wayland-client-core.h>
40#include <wayland-util.hpp>
86 events_base_t() =
default;
87 events_base_t(
const events_base_t&) =
default;
88 events_base_t(events_base_t&&) noexcept = default;
89 events_base_t& operator=(const events_base_t&) = default;
90 events_base_t& operator=(events_base_t&&) noexcept = default;
91 virtual ~events_base_t() noexcept = default;
150 wl_proxy *proxy =
nullptr;
151 detail::proxy_data_t *data =
nullptr;
152 wrapper_type type = wrapper_type::standard;
153 friend class detail::argument_t;
154 friend struct detail::proxy_data_t;
157 const wl_interface *
interface = nullptr;
163 static int c_dispatcher(
const void *implementation,
void *target,
164 uint32_t opcode,
const wl_message *message,
168 proxy_t marshal_single(uint32_t opcode,
const wl_interface *interface,
169 const std::vector<detail::argument_t>& args, std::uint32_t version = 0);
172 void set_interface(
const wl_interface *iface);
173 void set_copy_constructor(
const std::function<
proxy_t(
proxy_t)>& func);
183 template <
typename...T>
184 void marshal(uint32_t opcode,
const T& ...args)
186 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
187 marshal_single(opcode,
nullptr, v);
191 template <
typename...T>
192 proxy_t marshal_constructor(uint32_t opcode,
const wl_interface *interface,
195 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
196 return marshal_single(opcode, interface, v);
200 template <
typename...T>
201 proxy_t marshal_constructor_versioned(uint32_t opcode,
const wl_interface *interface,
202 uint32_t version,
const T& ...args)
204 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
205 return marshal_single(opcode, interface, v, version);
209 void set_destroy_opcode(uint32_t destroy_opcode);
216 void set_events(std::shared_ptr<detail::events_base_t> events,
217 int(*dispatcher)(uint32_t,
const std::vector<detail::any>&,
const std::shared_ptr<detail::events_base_t>&));
220 std::shared_ptr<detail::events_base_t> get_events();
225 struct construct_proxy_wrapper_tag {};
227 proxy_t(
const proxy_t &wrapped_proxy, construct_proxy_wrapper_tag );
334 operator bool()
const;
408 read_intent(wl_display *display, wl_event_queue *event_queue =
nullptr);
412 wl_event_queue *event_queue =
nullptr;
413 bool finalized =
false;
564 int roundtrip() const;
673 int dispatch() const;
711 int dispatch_pending() const;
723 int get_error() const;
739 std::tuple<
int,
bool> flush() const;
762 operator wl_display*() const;
770#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.