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>
66 event_queue_t(wl_event_queue *q);
67 friend class display_t;
69 event_queue_t() =
default;
70 event_queue_t(
const event_queue_t&) =
default;
71 event_queue_t(event_queue_t&&)
noexcept =
default;
72 event_queue_t& operator=(
const event_queue_t&) =
default;
73 event_queue_t& operator=(event_queue_t&&)
noexcept =
default;
74 ~event_queue_t()
noexcept =
default;
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;
374 read_intent(read_intent &&other)
noexcept =
default;
375 read_intent(read_intent
const &other) =
delete;
376 read_intent& operator=(read_intent
const &other) =
delete;
377 read_intent& operator=(read_intent &&other)
noexcept =
delete;
407 read_intent(wl_display *display, wl_event_queue *event_queue =
nullptr);
408 friend class display_t;
411 wl_event_queue *event_queue =
nullptr;
412 bool finalized =
false;
478 class display_t :
public proxy_t
482 display_t(proxy_t
const &wrapped_proxy, construct_proxy_wrapper_tag );
494 display_t(display_t &&d)
noexcept;
495 display_t(
const display_t &d) =
delete;
496 display_t &operator=(
const display_t &d) =
delete;
497 display_t &operator=(display_t &&d)
noexcept;
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 proxy_create_wrapper()
create proxy wrapper for this display
display_t(const std::string &name={})
Connect to a Wayland display.
int dispatch_pending() const
Dispatch main queue events without reading from the display fd.
int dispatch_queue(const event_queue_t &queue) const
Dispatch events in an event queue.
int get_error() const
Retrieve the last error that occurred on a display.
event_queue_t create_queue() const
Create a new event queue for this display.
int dispatch() const
Process incoming events.
int dispatch_queue_pending(const event_queue_t &queue) const
Dispatch pending events in an event queue.
int roundtrip_queue(const event_queue_t &queue) const
Block until all pending request are processed by the server.
registry_t get_registry()
get global registry object
int get_fd() const
Get a display context's file descriptor.
callback_t sync()
asynchronous roundtrip
int roundtrip() const
Block until all pending request are processed by the server.
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.
read_intent obtain_queue_read_intent(const event_queue_t &queue) const
Announce calling thread's intention to read events from the Wayland display file descriptor.
std::tuple< int, bool > flush() const
Send all buffered requests on the display to the server.
read_intent obtain_read_intent() const
Announce calling thread's intention to read events from the Wayland display file descriptor.
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.