wclient
Header: kmsroots/wclient.h
Table of contents (click to go)
Macros
Enums
Unions
Structs
Functions
Function Pointers
API Documentation
Well format documentation
https://wayland.app/protocols/
kmr_wc_interface_type
-
enum kmr_wc_interface_type
-
KMR_WC_INTERFACE_NULL
-
KMR_WC_INTERFACE_WL_COMPOSITOR
-
KMR_WC_INTERFACE_XDG_WM_BASE
-
KMR_WC_INTERFACE_WL_SHM
-
KMR_WC_INTERFACE_WL_SEAT
-
KMR_WC_INTERFACE_ZWP_FULLSCREEN_SHELL_V1
-
KMR_WC_INTERFACE_ALL
Values may be or’d together to select wayland interface to bind to.
KMR_WC_INTERFACE_NULL- Bind no supported wayland interfaces to a client
KMR_WC_INTERFACE_WL_COMPOSITOR- Bind client to wl_compositor interface
KMR_WC_INTERFACE_XDG_WM_BASE- Bind client to xdg_wm_base interface
KMR_WC_INTERFACE_WL_SHM- Bind client to wl_shm interface
KMR_WC_INTERFACE_WL_SEAT- Bind client to wl_seat interface
KMR_WC_INTERFACE_ZWP_FULLSCREEN_SHELL_V1- Bind client to zwp_fullscreen_shell_v1 interface
KMR_WC_INTERFACE_ALL- Bind to all supported global interfaces to a client
-
KMR_WC_INTERFACE_NULL
kmr_wc_core
-
struct kmr_wc_core
-
kmr_wc_interface_type iType;
-
struct wl_display *wlDisplay;
-
struct wl_registry *wlRegistry;
-
struct wl_compositor *wlCompositor;
-
struct xdg_wm_base *xdgWmBase;
-
struct wl_shm *wlShm;
-
struct wl_seat *wlSeat;
-
struct zwp_fullscreen_shell_v1 *fullScreenShell;
iType- Wayland objects/interfaces to bind to client. These objects/interfacesdefines what requests are possible by a given wayland client.
wlDisplay- A global object representing the whole connection to wayland server.This is object ID 1 which is pre-allocated and can be utilzed tobootstrap all other objects.
wlRegistry- A global object used to recieve events from the server. Events may includemonitor hotplugging for instance.
wlCompositor- A singleton global object representing the compositor itself largely utilized toallocate surfaces & regions to put pixels into. The compositor itself will combinethe contents of multiple surfaces and put them into one displayable output.
xdgWmBase- A singleton global object that enables clients to turn their surfaces(rectangle box of pixels) into windows in a desktop environment.
wlShm- A singleton global object that provides support for shared memory.Used to create a simple way of getting pixels from client to compositor.Pixels are stored in an unsigned 8 bit integer the buffer is createdwith mmap(2).
wlSeat- A singleton global object used to represent a group ofhot-pluggable input devices.
fullScreenShell- A singleton global object that has an interface that allow fordisplaying of fullscreen surfaces.
-
kmr_wc_interface_type iType;
kmr_wc_core_create_info
-
struct kmr_wc_core_create_info
-
kmr_wc_interface_type iType;
-
const char *displayName;
iType- Wayland global objects to include or exclude when the registry emits events
displayName- Specify the wayland server unix domain socket a client should communicate with.This will set the
$WAYLAND_DISPLAYvariable to the desired display.PassingNULLwill result in opening unix domain socket/run/user/1000/wayland-0.
-
kmr_wc_interface_type iType;
kmr_wc_core_create
-
struct kmr_wc_core *kmr_wc_core_create(struct kmr_wc_core_create_info *coreInfo);
Establishes connection to the wayland display server and sets up client specified global objects that each define what requests and events are possible.
- Parameters:
- coreInfoPointer to a
structkmr_wc_core_create_infowhich containsthe name of the server to connected to and the client specifiedglobals to bind to a given wayland client. Only if the serversupports these globals. - Returns:
- on success: pointer to a
structkmr_wc_coreon failure: NULL
kmr_wc_core_destroy
-
void kmr_wc_core_destroy(struct kmr_wc_core *core);
Frees any allocated memory and closes FD’s (if open) created after
kmr_wc_core_create()call./* Free'd members with fd's closed */ struct kmr_wc_core { struct wl_display *wlDisplay; struct wl_registry *wlRegistry; struct wl_compositor *wlCompositor; struct xdg_wm_base *xdgWmBase; struct wl_shm *wlShm; struct wl_seat *wlSeat; struct zwp_fullscreen_shell_v1 *fullScreenShell; }
kmr_wc_shm_buffer
-
struct kmr_wc_shm_buffer
-
shmFd- A file descriptor to an open wayland shared memory object.
shmPoolSize- The size of the amount of bytes in a given buffer pixels.[Value = width * height * bytesPerPixel]
shmPoolData- Actual linear buffer to put pixel data into inorder to display.The buffer itself created via mmap(2).
kmr_wc_buffer_handle
kmr_wc_buffer
-
struct kmr_wc_buffer
-
int bufferCount;
-
struct kmr_wc_shm_buffer *shmBufferObjects;
-
struct kmr_wc_buffer_handle *wlBufferHandles;
bufferCount- The amount of wayland buffers allocated from a given wl_shm_pool.
shmBufferObjects- Pointer to an array of
structkmr_wc_shm_buffercontaining allinformation required to populate/release wayland shared memorypixel buffer. wlBufferHandles- Pointer to an array of
structkmr_wc_buffer_handlecontainingcompositor assigned buffer object.
-
int bufferCount;
kmr_wc_buffer_create_info
-
struct kmr_wc_buffer_create_info
-
struct kmr_wc_core *core;
-
int bufferCount;
-
int width;
-
int height;
-
int bytesPerPixel;
-
uint64_t pixelFormat;
core- Must pass a valid pointer to all binded/exposed wayland core interfaces(important interfaces used: wl_shm)
bufferCount- The amount of buffers to allocate when storing pixel data
2is generally a good option as it allows for double buffering width- Amount of pixel horizontally (i.e
3840,1920, …) height- Amount of pixel vertically (i.e
2160,1080, …) bytesPerPixel- The amount of bytes per pixel generally going to be
4bytes (32 bits) pixelFormat- Memory layout of an individual pixel
-
struct kmr_wc_core *core;
kmr_wc_buffer_create
-
struct kmr_wc_buffer *kmr_wc_buffer_create(struct kmr_wc_buffer_create_info *bufferInfo);
Adds way to get pixels from client to compositor by creating writable shared memory buffers.
- Parameters:
- bufferInfoMust pass a valid pointer to a
structkmr_wc_buffer_create_infowhich gives details of how a buffer should be allocated and howmany to allocations to make. - Returns:
- on success: pointer to a
structkmr_wc_bufferon failure: NULL
kmr_wc_buffer_destroy
-
void kmr_wc_buffer_destroy(struct kmr_wc_buffer *buffer);
Frees any allocated memory and closes FD’s (if open) created after
kmr_wc_buffer_create()call.- Parameters:
- bufferMust pass a valid pointer to a
structkmr_wc_buffer.
/* Free'd members with fd's closed */ struct kmr_wc_buffer { struct kmr_wc_shm_buffer { int shmFd; uint8_t *shmPoolData; } *shmBufferObjects; struct kmr_wc_buffer_handle { struct wl_buffer *buffer; } *wlBufferHandles; }
kmr_wc_renderer_impl
-
void kmr_wc_renderer_impl(volatile bool*, uint8_t*, int*, void*);
typedef void (*kmr_wc_renderer_impl)(volatile bool*, uint8_t*, void*);
Function pointer used by
structkmr_wc_surface_create_infoAllows to pass the address of an external function you want to run Given that the arguments of the function are a pointer to a boolean, pointer to an integer, and a pointer to void data type- volatile bool *
- A pointer to a boolean determining if the renderer is running.Used to exit rendering operations.
- uint8_t *
- A pointer to an unsigned 8 bit integer determining current shmbuffer being rendered to used.
- void *
- A pointer to any arbitrary data the custom renderer may want passduring rendering operations.
kmr_wc_surface
-
struct kmr_wc_surface
-
struct xdg_toplevel *xdgToplevel;
-
struct xdg_surface *xdgSurface;
-
struct wl_surface *wlSurface;
-
struct wl_callback *wlCallback;
-
uint8_t bufferCount;
-
struct kmr_wc_buffer_handle *wlBufferHandles;
-
void *rendererInfo;
xdgToplevel- An interface with many requests and events to manage application windows
xdgSurface- Top level surface for the window. Useful if one wants to createa tree of surfaces. Provides additional requests for assigningroles.
wlSurfacewlCallback- The amount of pixel (
uint8_t) buffers allocated.The array length ofstructkmr_wc_buffer_handle. bufferCount- Amount of elements in pointer to array of
wlBufferHandles wlBufferHandles- A pointer to an array of
structkmr_wc_buffer_handle.Which holds astructwl_buffer the pixel storage placeunderstood by compositor. rendererInfo- Used by the implementation to free data. DO NOT MODIFY.
-
struct xdg_toplevel *xdgToplevel;
kmr_wc_surface_create_info
-
struct kmr_wc_surface_create_info
-
struct kmr_wc_core *core;
-
struct kmr_wc_buffer *buffer;
-
uint8_t bufferCount;
-
const char *appName;
-
bool fullscreen;
-
kmr_wc_renderer_impl renderer;
-
void *rendererData;
-
uint8_t *rendererCurrentBuffer;
-
volatile bool *rendererRunning;
core- Pointer to a
structkmr_wc_corecontains all objects/interfacesnecessary for a client to run. buffer- Must pass a valid pointer to a
structkmr_wc_bufferneed to attachwill be attached to surface. Thus nothing will be displayed. Passingthis variable also enables in API swapping between shm buffers. appName- Sets the window name.
fullscreen- Determines if window should be fullscreen or not
renderer- Function pointer that allows custom external renderers to be executed by the apiwhen before registering a frame wl_callback. Renderer before presenting
rendererData- Pointer to an optional address. This address may be the address of a struct.Reference passed depends on external renderer function.
rendererCurrentBuffer- Pointer to an integer used by the api to update the current displayable buffer.
rendererRunning- Pointer to a boolean that determines if a given window/surface is actively running.
-
struct kmr_wc_core *core;
kmr_wc_surface_create
-
struct kmr_wc_surface *kmr_wc_surface_create(struct kmr_wc_surface_create_info *surfaceInfo);
Creates a surface to place pixels in and a window for displaying surface pixels.
- Parameters:
- surfaceInfoMust pass a valid pointer to a
structkmr_wc_surface_create_infowhich gives details on what buffers are associated with surfaceobject, the name of the window, and how the window should be displayed. - Returns:
- on success: pointer to a
structkmr_wc_surfaceon failure: NULL
kmr_wc_surface_destroy
-
void kmr_wc_surface_destroy(struct kmr_wc_surface *surface);
Frees any allocated memory and closes FD’s (if open) created after
kmr_wc_surface_create()call.- Parameters:
- surfaceMust pass a valid pointer to a
structkmr_wc_surface.
/* Free'd members with fd's closed */ struct kmr_wc_surface { struct xdg_toplevel *xdgToplevel; struct xdg_surface *xdgSurface; struct wl_surface *wlSurface; void *rendererInfo; }