From 637f3c5f82c63f5b35c880064d5b801a19f4a986 Mon Sep 17 00:00:00 2001 From: Joseph <119084558+DerjenigeUberMensch@users.noreply.github.com> Date: Fri, 16 Feb 2024 20:17:01 +0000 Subject: [PATCH] Add files via upload --- xcb_trl.c | 48 +++++++++++++++++++++++++++++++++++++++++++++--- xcb_trl.h | 31 ++++++++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/xcb_trl.c b/xcb_trl.c index 02393b9..015fec4 100644 --- a/xcb_trl.c +++ b/xcb_trl.c @@ -341,13 +341,13 @@ XCBGetWindowGeometryReply(XCBDisplay *display, XCBGeometryCookie cookie) inline XCBAtomCookie -XCBInternalAtomCookie(XCBDisplay *display, const char *name, int only_if_exists) +XCBInternAtomCookie(XCBDisplay *display, const char *name, int only_if_exists) { return xcb_intern_atom(display, only_if_exists, strlen(name), name); } inline XCBAtom -XCBInternalAtomReply(XCBDisplay *display, XCBAtomCookie cookie) +XCBInternAtomReply(XCBDisplay *display, XCBAtomCookie cookie) { XCBGenericError **e = NULL; xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(display, cookie, e); @@ -508,6 +508,18 @@ XCBPollForQueuedEvent(XCBDisplay *display) } +inline XCBPointerCookie +XCBQueryPointerCookie(XCBDisplay *display, XCBWindow window) +{ + return xcb_query_pointer(display, window); +} + +inline XCBPointerReply +XCBQueryPointerReply(XCBDisplay *display, XCBPointerCookie cookie) +{ + XCBGenericError **err; + return xcb_query_pointer_reply(display, cookie, err); +} inline XCBCookie @@ -528,7 +540,7 @@ u8 depth, unsigned int class, XCBVisualId visual, u32 valuemask, const u32 *valu return id; } -inline XCBGC +inline XCBGC XCBCreateGC(XCBDisplay *display, XCBDrawable drawable, u32 valuemask, const void *valuelist) { @@ -537,6 +549,36 @@ u32 valuemask, const void *valuelist) return id; } +inline int +XCBSetLineAttributes(XCBDisplay *display, XCBGC gc, u32 linewidth, u32 linestyle, u32 capstyle, u32 joinstyle) +{ + u32 gcvalist[3]; + int index = 0; + //gcvalist = { linestyle, capstyle, joinstyle }; + u32 mask = 0; + if(linewidth) + { mask |= XCB_GC_LINE_WIDTH; + gcvalist[index++] = linewidth; + } + if(capstyle) + { mask |= XCB_GC_CAP_STYLE; + gcvalist[index++] = capstyle; + } + if(joinstyle) + { mask |= XCB_GC_JOIN_STYLE; + gcvalist[index++] = joinstyle; + } + + /* This returns a cookie but changing the gc isnt doesnt really require a reply as you are directly manupulating your own gc + * However the XServer Doesnt know that yet which is why a cookie is returned + * (void) is cast cause we dont care about the cookie i.e. unused + */ + (void)xcb_change_gc(display, gc, mask, gcvalist); + /* X11 src/SetLStyle.c always returns 1 (for some reason) */ + return 1; +} + + inline XCBCookie XCBChangeGC(XCBDisplay *display, XCBGC gc, u32 valuemask, const void *valuelist) { diff --git a/xcb_trl.h b/xcb_trl.h index 06ab2cc..a8548a8 100644 --- a/xcb_trl.h +++ b/xcb_trl.h @@ -8,6 +8,8 @@ #include #include #include +#include + typedef xcb_connection_t XCBConnection; typedef xcb_connection_t XCBDisplay; @@ -42,6 +44,21 @@ typedef xcb_font_t XCBFont; typedef xcb_generic_event_t XCBGenericEvent; typedef xcb_generic_error_t XCBGenericError; +typedef xcb_query_pointer_cookie_t XCBPointerCookie; +typedef xcb_query_pointer_reply_t XCBPointerReply; + +/* Xinerama */ + +typedef xcb_xinerama_screen_info_t XCBXineramaScreenInfo; +typedef xcb_xinerama_is_active_cookie_t XCBXineramaIsActiveCookie; +typedef xcb_xinerama_is_active_reply_t XCBXineramaIsActiveReply; + +typedef xcb_xinerama_query_screens_reply_t XCBXineramaQueryScreensReply; +typedef xcb_xinerama_query_screens_cookie_t XCBXineramaQueryScreensCookie; + + + + @@ -123,6 +140,7 @@ extern uint16_t XCBDisplayWidth(XCBDisplay *display, int screen); */ extern uint16_t XCBDisplayHeight(XCBDisplay *display, int screen); extern uint8_t XCBDisplayDepth(XCBDisplay *display, int screen); +extern uint8_t XCBDefaultDepth(XCBDisplay *display, int screen); extern XCBCookie XCBSelectInput(XCBDisplay *display, XCBWindow window, uint32_t mask); /* */ @@ -139,6 +157,8 @@ extern XCBCookie XCBRaiseWindowIf(XCBDisplay *display, XCBWindow window); extern XCBCookie XCBLowerWindowIf(XCBDisplay *display, XCBWindow window); extern XCBCookie XCBSetWindowBorderWidth(XCBDisplay *display, XCBWindow window, uint32_t border_width); extern XCBCookie XCBSetSibling(XCBDisplay *display, XCBWindow window, XCBWindow sibling); +extern XCBAtomCookie XCBInternAtomCookie(XCBDisplay *display, const char *name, int only_if_exists); +extern XCBAtom XCBInternAtomReply(XCBDisplay *display, XCBAtomCookie cookie); extern XCBWindowAttributesCookie XGetWindowAttributesCookie(XCBDisplay *display, XCBWindow window); extern XCBWindowAttributes *XCBGetWindowAttributesReply(XCBDisplay *display, XCBWindowAttributesCookie cookie); @@ -150,7 +170,8 @@ extern XCBCursor XCBCreateFontCursor(XCBDisplay *display, int shape); extern XCBCookie XCBFreeCursor(XCBDisplay *display, XCBCursor cursor); - +extern XCBPointerCookie XCBQueryPointerCookie(XCBDisplay *display); +extern XCBPointerReply XCBQueryPointerReply(XCBDisplay *display, XCBPointerCookie cookie); /* fonts */ /**/ extern XCBCookie XCBOpenFont(XCBDisplay *display, XCBFont id, const char *name); @@ -273,9 +294,13 @@ extern XCBCookie XCBMapWindow(XCBDisplay *display, XCBWindow window); /* windows*/ extern XCBWindow XCBCreateWindow(XCBDisplay *display, XCBWindow parent, int x, int y, unsigned int width, unsigned int height, int border_width, uint8_t depth, unsigned int _class, XCBVisualId visual, uint32_t valuemask, const uint32_t *value_list); + + /* GC */ -extern XCBGC XCBCreateGC(XCBDisplay *display, XCBDrawable drawable, -uint32_t valuemask, const void *valuelist); +/* RETURN: GC id (identification number) */ +extern XCBGC XCBCreateGC(XCBDisplay *display, XCBDrawable drawable, uint32_t valuemask, const void *valuelist); +/* RETURN: 1, always cause why not */ +extern int XCBSetLineAttributes(XCBDisplay *display, XCBGC gc, uint32_t linewidth, uint32_t linestyle, uint32_t capstyle, uint32_t joinstyle); /* Valuemasks XCB_GC_FUNCTION