Source

Mirror / src / cursor.cpp

#include "cursor.h"

xcb_cursor_context_t *cursorContextInit(xcb_connection_t *conn, xcb_screen_t *screen)
{
    xcb_cursor_context_t *context;
    if (xcb_cursor_context_new(conn, screen, &context)  < 0)
    {
        return nullptr;
    }
    return context;
}

void setCursor(xcb_connection_t *conn, xcb_cursor_context_t *context, xcb_window_t window, std::string cursorName)
{
    xcb_cursor_t cursorId = xcb_cursor_load_cursor(context, cursorName.c_str());
    uint32_t values[] = {cursorId};
    xcb_change_window_attributes(conn, window, XCB_CW_CURSOR, values);
    xcb_flush(conn);
}

void cursorContextDelete(xcb_cursor_context_t* context)
{
    xcb_cursor_context_free(context);
}