26#ifndef WAYLAND_CLIENT_HPP
27#define WAYLAND_CLIENT_HPP
37#include <wayland-version.hpp>
38#include <wayland-client-core.h>
39#include <wayland-util.hpp>
85 events_base_t() =
default;
86 events_base_t(
const events_base_t&) =
default;
87 events_base_t(events_base_t&&) noexcept = default;
88 events_base_t& operator=(const events_base_t&) = default;
89 events_base_t& operator=(events_base_t&&) noexcept = default;
90 virtual ~events_base_t() noexcept = default;
149 wl_proxy *proxy =
nullptr;
150 detail::proxy_data_t *data =
nullptr;
151 wrapper_type type = wrapper_type::standard;
152 friend class detail::argument_t;
153 friend struct detail::proxy_data_t;
156 const wl_interface *
interface = nullptr;
162 static int c_dispatcher(
const void *implementation,
void *target,
163 uint32_t opcode,
const wl_message *message,
167 proxy_t marshal_single(uint32_t opcode,
const wl_interface *interface,
168 const std::vector<detail::argument_t>& args, std::uint32_t version = 0);
171 void set_interface(
const wl_interface *iface);
172 void set_copy_constructor(
const std::function<
proxy_t(
proxy_t)>& func);
182 template <
typename...T>
183 void marshal(uint32_t opcode,
const T& ...args)
185 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
186 marshal_single(opcode,
nullptr, v);
190 template <
typename...T>
191 proxy_t marshal_constructor(uint32_t opcode,
const wl_interface *interface,
194 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
195 return marshal_single(opcode, interface, v);
199 template <
typename...T>
200 proxy_t marshal_constructor_versioned(uint32_t opcode,
const wl_interface *interface,
201 uint32_t version,
const T& ...args)
203 std::vector<detail::argument_t> v = { detail::argument_t(args)... };
204 return marshal_single(opcode, interface, v, version);
208 void set_destroy_opcode(uint32_t destroy_opcode);
215 void set_events(std::shared_ptr<detail::events_base_t> events,
216 int(*dispatcher)(uint32_t,
const std::vector<detail::any>&,
const std::shared_ptr<detail::events_base_t>&));
219 std::shared_ptr<detail::events_base_t> get_events();
224 struct construct_proxy_wrapper_tag {};
226 proxy_t(
const proxy_t &wrapped_proxy, construct_proxy_wrapper_tag );
333 operator bool()
const;
407 read_intent(wl_display *display, wl_event_queue *event_queue =
nullptr);
411 wl_event_queue *event_queue =
nullptr;
412 bool finalized =
false;
563 int roundtrip() const;
672 int dispatch() const;
710 int dispatch_pending() const;
722 int get_error() const;
738 std::tuple<
int,
bool> flush() const;
761 operator wl_display*() const;
769#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.