Waltham  0.1.0
Protocol object API Usage

How to use the protocol object APIs in both servers and clients

Unlike in Wayland, Waltham's protocol object API is completely symmetric on server vs. client side. Both sides use opaque interface-typed pointers to refer to protocol objects whose implementation is wth_object.

The methods and virtual function tables are naturally different between server and client side. Server-side function tables are called interfaces and client-side function tables are called listeners : wthp_surface_interface and wthp_surface_listener for example.

Almost all protocol objects get created by sending a request (from a client) or an event (from a server). Calling a generated C function to send will create a wth_object cast to an opaque pointer type. To set the virtual function table, one calls a type-specific setter, e.g. wthp_surface_set_interface() or wthp_surface_set_listener(). The callbacks set this way will be called from inside wth_connection_dispatch().

It is not usually necessary to call the wth_object API directly. Most use cases are covered by the type-safe wrappers created by the code generator. However, it is possible to just cast a typed pointer to a wth_object pointer as necessary.