From 6b14e213a37c7e61c5dfa12e4f2eeec6ed53206e Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 7 Aug 2024 17:34:28 +0200 Subject: [PATCH] Xnest: use XIDs directly, instead of Xlib's GC Now that no Xlib drawing functions used anymore, we can finally switch over to using GC XID's directly, instead of Xlib's GC struct. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Cursor.c | 6 +++--- hw/xnest/Display.c | 9 +++++++-- hw/xnest/Display.h | 2 +- hw/xnest/GC.c | 16 +++++++++++----- hw/xnest/XNGC.h | 2 +- hw/xnest/xcb.c | 6 ++---- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index f6fed8d14..11e4a42cf 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -54,7 +54,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) .foreground = 1L, }; - xcb_aux_change_gc(xnestUpstreamInfo.conn, xnestBitmapGC->gid, valuemask, &values); + xcb_aux_change_gc(xnestUpstreamInfo.conn, xnestBitmapGC, valuemask, &values); uint32_t const winId = xnestDefaultWindows[pScreen->myNum]; @@ -69,7 +69,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) xcb_put_image(xnestUpstreamInfo.conn, XCB_IMAGE_FORMAT_XY_BITMAP, source, - xnestBitmapGC->gid, + xnestBitmapGC, pCursor->bits->width, pCursor->bits->height, 0, // x @@ -82,7 +82,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) xcb_put_image(xnestUpstreamInfo.conn, XCB_IMAGE_FORMAT_XY_BITMAP, mask, - xnestBitmapGC->gid, + xnestBitmapGC, pCursor->bits->width, pCursor->bits->height, 0, // x diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index 44e3b52dc..64b2e552d 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -51,7 +51,7 @@ int xnestNumPixmapFormats; Drawable xnestDefaultDrawables[MAXDEPTH + 1]; Pixmap xnestIconBitmap; Pixmap xnestScreenSaverPixmap; -GC xnestBitmapGC; +uint32_t xnestBitmapGC; unsigned long xnestEventMask; static int _X_NORETURN @@ -155,7 +155,12 @@ xnestOpenDisplay(int argc, char *argv[]) xnestDefaultDrawables[xnestPixmapFormats[i].depth] = pixmap; } - xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL); + xnestBitmapGC = xcb_generate_id(xnestUpstreamInfo.conn); + xcb_create_gc(xnestUpstreamInfo.conn, + xnestBitmapGC, + xnestDefaultDrawables[1], + 0, + NULL); if (!(xnestUserGeometry & XValue)) xnestX = 0; diff --git a/hw/xnest/Display.h b/hw/xnest/Display.h index a39337c85..633012456 100644 --- a/hw/xnest/Display.h +++ b/hw/xnest/Display.h @@ -35,7 +35,7 @@ extern int xnestNumPixmapFormats; extern Drawable xnestDefaultDrawables[MAXDEPTH + 1]; extern Pixmap xnestIconBitmap; extern Pixmap xnestScreenSaverPixmap; -extern GC xnestBitmapGC; +extern uint32_t xnestBitmapGC; extern unsigned long xnestEventMask; void xnestOpenDisplay(int argc, char *argv[]); diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c index bed50e0d8..5e574e3b4 100644 --- a/hw/xnest/GC.c +++ b/hw/xnest/GC.c @@ -83,9 +83,12 @@ xnestCreateGC(GCPtr pGC) pGC->miTranslate = 1; - xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay, - xnestDefaultDrawables[pGC->depth], - 0L, NULL); + xnestGCPriv(pGC)->gc = xcb_generate_id(xnestUpstreamInfo.conn); + xcb_create_gc(xnestUpstreamInfo.conn, + xnestGCPriv(pGC)->gc, + xnestDefaultDrawables[pGC->depth], + 0, + NULL); return TRUE; } @@ -189,13 +192,16 @@ xnestChangeGC(GCPtr pGC, unsigned long mask) void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) { - XCopyGC(xnestDisplay, xnestGC(pGCSrc), mask, xnestGC(pGCDst)); + xcb_copy_gc(xnestUpstreamInfo.conn, + xnestGC(pGCSrc), + xnestGC(pGCDst), + mask); } void xnestDestroyGC(GCPtr pGC) { - XFreeGC(xnestDisplay, xnestGC(pGC)); + xcb_free_gc(xnestUpstreamInfo.conn, xnestGC(pGC)); } void diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h index d4f3578ce..512f4627f 100644 --- a/hw/xnest/XNGC.h +++ b/hw/xnest/XNGC.h @@ -21,7 +21,7 @@ is" without express or implied warranty. #include "include/privates.h" typedef struct { - GC gc; + uint32_t gc; } xnestPrivGC; extern DevPrivateKeyRec xnestGCPrivateKeyRec; diff --git a/hw/xnest/xcb.c b/hw/xnest/xcb.c index 18fbc09ff..83284361d 100644 --- a/hw/xnest/xcb.c +++ b/hw/xnest/xcb.c @@ -38,9 +38,7 @@ uint32_t xnest_upstream_gc(GCPtr pGC) { if (pGC == NULL) return 0; xnestPrivGC *priv = dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey); - if ((priv == NULL) || (priv->gc == NULL)) return 0; + if (priv == NULL) return 0; - // make sure Xlib's GC cache is written out before using (server side) GC. - XFlushGC(xnestDisplay, priv->gc); - return priv->gc->gid; + return priv->gc; }