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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-08-07 17:34:28 +02:00
parent c263e6220b
commit 6b14e213a3
6 changed files with 25 additions and 16 deletions

View File

@ -54,7 +54,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
.foreground = 1L, .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]; uint32_t const winId = xnestDefaultWindows[pScreen->myNum];
@ -69,7 +69,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
xcb_put_image(xnestUpstreamInfo.conn, xcb_put_image(xnestUpstreamInfo.conn,
XCB_IMAGE_FORMAT_XY_BITMAP, XCB_IMAGE_FORMAT_XY_BITMAP,
source, source,
xnestBitmapGC->gid, xnestBitmapGC,
pCursor->bits->width, pCursor->bits->width,
pCursor->bits->height, pCursor->bits->height,
0, // x 0, // x
@ -82,7 +82,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
xcb_put_image(xnestUpstreamInfo.conn, xcb_put_image(xnestUpstreamInfo.conn,
XCB_IMAGE_FORMAT_XY_BITMAP, XCB_IMAGE_FORMAT_XY_BITMAP,
mask, mask,
xnestBitmapGC->gid, xnestBitmapGC,
pCursor->bits->width, pCursor->bits->width,
pCursor->bits->height, pCursor->bits->height,
0, // x 0, // x

View File

@ -51,7 +51,7 @@ int xnestNumPixmapFormats;
Drawable xnestDefaultDrawables[MAXDEPTH + 1]; Drawable xnestDefaultDrawables[MAXDEPTH + 1];
Pixmap xnestIconBitmap; Pixmap xnestIconBitmap;
Pixmap xnestScreenSaverPixmap; Pixmap xnestScreenSaverPixmap;
GC xnestBitmapGC; uint32_t xnestBitmapGC;
unsigned long xnestEventMask; unsigned long xnestEventMask;
static int _X_NORETURN static int _X_NORETURN
@ -155,7 +155,12 @@ xnestOpenDisplay(int argc, char *argv[])
xnestDefaultDrawables[xnestPixmapFormats[i].depth] = pixmap; 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)) if (!(xnestUserGeometry & XValue))
xnestX = 0; xnestX = 0;

View File

@ -35,7 +35,7 @@ extern int xnestNumPixmapFormats;
extern Drawable xnestDefaultDrawables[MAXDEPTH + 1]; extern Drawable xnestDefaultDrawables[MAXDEPTH + 1];
extern Pixmap xnestIconBitmap; extern Pixmap xnestIconBitmap;
extern Pixmap xnestScreenSaverPixmap; extern Pixmap xnestScreenSaverPixmap;
extern GC xnestBitmapGC; extern uint32_t xnestBitmapGC;
extern unsigned long xnestEventMask; extern unsigned long xnestEventMask;
void xnestOpenDisplay(int argc, char *argv[]); void xnestOpenDisplay(int argc, char *argv[]);

View File

@ -83,9 +83,12 @@ xnestCreateGC(GCPtr pGC)
pGC->miTranslate = 1; pGC->miTranslate = 1;
xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay, xnestGCPriv(pGC)->gc = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_gc(xnestUpstreamInfo.conn,
xnestGCPriv(pGC)->gc,
xnestDefaultDrawables[pGC->depth], xnestDefaultDrawables[pGC->depth],
0L, NULL); 0,
NULL);
return TRUE; return TRUE;
} }
@ -189,13 +192,16 @@ xnestChangeGC(GCPtr pGC, unsigned long mask)
void void
xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) 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 void
xnestDestroyGC(GCPtr pGC) xnestDestroyGC(GCPtr pGC)
{ {
XFreeGC(xnestDisplay, xnestGC(pGC)); xcb_free_gc(xnestUpstreamInfo.conn, xnestGC(pGC));
} }
void void

View File

@ -21,7 +21,7 @@ is" without express or implied warranty.
#include "include/privates.h" #include "include/privates.h"
typedef struct { typedef struct {
GC gc; uint32_t gc;
} xnestPrivGC; } xnestPrivGC;
extern DevPrivateKeyRec xnestGCPrivateKeyRec; extern DevPrivateKeyRec xnestGCPrivateKeyRec;

View File

@ -38,9 +38,7 @@ uint32_t xnest_upstream_gc(GCPtr pGC) {
if (pGC == NULL) return 0; if (pGC == NULL) return 0;
xnestPrivGC *priv = dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey); 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. return priv->gc;
XFlushGC(xnestDisplay, priv->gc);
return priv->gc->gid;
} }