Xnest: use xcb_put_image() for creating cursors

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-31 16:37:51 +02:00
parent 3ab0bec860
commit 6684b2b2af

View File

@ -40,7 +40,6 @@ xnestCursorFuncRec xnestCursorFuncs = { NULL };
Bool Bool
xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{ {
XImage *ximage;
unsigned long valuemask; unsigned long valuemask;
XGCValues values; XGCValues values;
@ -55,37 +54,41 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
XChangeGC(xnestDisplay, xnestBitmapGC, valuemask, &values); XChangeGC(xnestDisplay, xnestBitmapGC, valuemask, &values);
uint32_t winId = xnestDefaultWindows[pScreen->myNum]; uint32_t const winId = xnestDefaultWindows[pScreen->myNum];
Pixmap source = xcb_generate_id(xnestUpstreamInfo.conn); Pixmap const source = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn, 1, source, winId, pCursor->bits->width, pCursor->bits->height); xcb_create_pixmap(xnestUpstreamInfo.conn, 1, source, winId, pCursor->bits->width, pCursor->bits->height);
Pixmap mask = xcb_generate_id(xnestUpstreamInfo.conn); Pixmap const mask = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn, 1, mask, winId, pCursor->bits->width, pCursor->bits->height); xcb_create_pixmap(xnestUpstreamInfo.conn, 1, mask, winId, pCursor->bits->width, pCursor->bits->height);
ximage = XCreateImage(xnestDisplay, int const pixmap_len = BitmapBytePad(pCursor->bits->width) * pCursor->bits->height;
xnestDefaultVisual(pScreen),
1, XYBitmap, 0,
(char *) pCursor->bits->source,
pCursor->bits->width,
pCursor->bits->height, BitmapPad(xnestDisplay), 0);
XPutImage(xnestDisplay, source, xnestBitmapGC, ximage, xcb_put_image(xnestUpstreamInfo.conn,
0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); XCB_IMAGE_FORMAT_XY_BITMAP,
source,
xnestBitmapGC->gid,
pCursor->bits->width,
pCursor->bits->height,
0, // x
0, // y
0, // left_pad
1, // depth
pixmap_len,
(uint8_t*) pCursor->bits->source);
XFree(ximage); xcb_put_image(xnestUpstreamInfo.conn,
XCB_IMAGE_FORMAT_XY_BITMAP,
ximage = XCreateImage(xnestDisplay, mask,
xnestDefaultVisual(pScreen), xnestBitmapGC->gid,
1, XYBitmap, 0, pCursor->bits->width,
(char *) pCursor->bits->mask, pCursor->bits->height,
pCursor->bits->width, 0, // x
pCursor->bits->height, BitmapPad(xnestDisplay), 0); 0, // y
0, // left_pad
XPutImage(xnestDisplay, mask, xnestBitmapGC, ximage, 1, // depth
0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); pixmap_len,
(uint8_t*) pCursor->bits->mask);
XFree(ximage);
xnestSetCursorPriv(pCursor, pScreen, calloc(1, sizeof(xnestPrivCursor))); xnestSetCursorPriv(pCursor, pScreen, calloc(1, sizeof(xnestPrivCursor)));
uint32_t cursor = xcb_generate_id(xnestUpstreamInfo.conn); uint32_t cursor = xcb_generate_id(xnestUpstreamInfo.conn);