xclient

Header: kmsroots/xclient.h

Table of contents (click to go)

Macros

Enums

Unions

Structs

  1. kmr_xcb_window

  2. kmr_xcb_window_create_info

  3. kmr_xcb_window_handle_event_info

Functions

  1. kmr_xcb_window_create()

  2. kmr_xcb_window_destroy()

  3. kmr_xcb_window_handle_event()

Function Pointers

  1. kmr_xcb_renderer_impl()

API Documentation

kmr_xcb_window

struct kmr_xcb_window
xcb_connection_t *conn;
xcb_window_t window;
xcb_intern_atom_reply_t *delWindow;
conn
A structure that contain all data that XCB needs to communicate
with an X server.
window
Stores the XID of the current window. XID is neeed to create
windows and manage its properties
delWindow
Used to by kmr_xcb_window_wait_for_event() to verify when
the window manager attempts to destroy the window.

kmr_xcb_window_create_info

struct kmr_xcb_window_create_info
const char *display;
int *screen;
const char *appName;
uint16_t width;
uint16_t height;
bool fullscreen;
bool transparent;
display
The X server’s display name. When set to NULL, the DISPLAY
environment variable is used.
screen
Number for the screen that should be connected. When set to NULL,
the screen number is set to 0.
appName
Sets the window name. Can not be more than 60 characters.
width
Width of window in pixels
height
Height of window in pixels
fullscreen
Set to true to go fullscreen, false to display normal window.
transparent
Set to true to have fully transparent window. False will display black background.

kmr_xcb_window_create

struct kmr_xcb_window *kmr_xcb_window_create(struct kmr_xcb_window_create_info *xcbWindowInfo);

Create an xcb client window instance (can be fullscreen).

Parameters:
xcbWindowInfo
Pointer to a struct kmr_xcb_window_create_info contains all information
required to created an xcb client and some added window configuration options.
Returns:
on success: pointer to a struct kmr_xcb_window
on failure: NULL

kmr_xcb_window_destroy

void kmr_xcb_window_destroy(struct kmr_xcb_window *xcb);

Frees any allocated memory and closes FD’s (if open) created after kmr_xcb_window_create() call.

Parameters:
xcb
Must past a valid pointer to a struct kmr_xcb_window
/* Free'd members with fd's closed */
struct kmr_xcb_window {
        xcb_connection_t        *conn;
        xcb_window_t            window;
        xcb_intern_atom_reply_t *delWindow;
};

kmr_xcb_window_make_visible

void kmr_xcb_window_make_visible(struct kmr_xcb_window *xcb);

Creates the window that we display on by informing server to map the window to the screen. NOTE: If window is created before vulkan can establish VkSurfaceKHR/VkFramebuffer objects it leads to window being in a deadlock state. With no way of recovery without a power recycle.

Validation layers report

vkCreateFramebuffer(): VkFramebufferCreateInfo attachment #0 mip level 0 has width (1848) smaller than the corresponding framebuffer width (1920).

Parameters:
xcb
Pointer to a struct kmr_xcb_window contains all objects necessary
for an xcb client window to display.

kmr_xcb_renderer_impl

void kmr_xcb_renderer_impl(volatile bool*, uint8_t*, int*, void*);
typedef void (*kmr_xcb_renderer_impl)(volatile bool*, uint8_t*, void*);

Function pointer used by struct kmr_xcb_window_wait_for_event_info Allows 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 vulkan
swapchain image being used.
void *
A pointer to any arbitrary data the custom renderer may want pass
during rendering operations.

kmr_xcb_window_handle_event_info

struct kmr_xcb_window_handle_event_info
struct kmr_xcb_window *xcbWindowObject;
kmr_xcb_renderer_impl renderer;
void *rendererData;
uint8_t *rendererCurrentBuffer;
volatile bool *rendererRunning;
xcbWindowObject
Pointer to a struct kmr_xcb_window contains all objects necessary
to manage xcb client.
renderer
Function pointer that allows custom external renderers to be
executed by the api.
rendererData
Pointer to an optional address that will be passed though.
This address may be the address of a struct. Reference passed
depends on external render 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

kmr_xcb_window_handle_event

int kmr_xcb_window_handle_event(struct kmr_xcb_window_handle_event_info *xcbEventInfo);

In an X program, everything is driven by events. This functions calls xcb_poll_for_event which doesn’t block operations and returns events from X server when available. The main event watched by function is KEY_PRESSING, when either the ‘Q’ or ‘ESC’ keys are pressed the function will return failure status.

Function is meant to be utilized as a while loop conditional/expression.

See: https://xcb.freedesktop.org/tutorial/events

Parameters:
xcbEventInfo
Pointer to a struct kmr_xcb_window_wait_for_event_info contains all
objects necessary for an xcb client to run and pointer to custom renderer
to execute and the arguments used by said renderer.
Returns:
on success: 1
on failure: 0