Xnest: use xcb for creating / destroying pixmaps

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-31 10:07:57 +02:00
parent 43b73eb527
commit e39ebbab54
3 changed files with 29 additions and 22 deletions

View File

@ -26,6 +26,7 @@ is" without express or implied warranty.
#include "mipointrst.h"
#include "Xnest.h"
#include "xnest-xcb.h"
#include "Display.h"
#include "Screen.h"
@ -40,7 +41,6 @@ Bool
xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
XImage *ximage;
Pixmap source, mask;
XColor fg_color, bg_color;
unsigned long valuemask;
XGCValues values;
@ -56,13 +56,13 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
XChangeGC(xnestDisplay, xnestBitmapGC, valuemask, &values);
source = XCreatePixmap(xnestDisplay,
xnestDefaultWindows[pScreen->myNum],
pCursor->bits->width, pCursor->bits->height, 1);
uint32_t winId = xnestDefaultWindows[pScreen->myNum];
mask = XCreatePixmap(xnestDisplay,
xnestDefaultWindows[pScreen->myNum],
pCursor->bits->width, pCursor->bits->height, 1);
Pixmap source = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn, 1, source, winId, pCursor->bits->width, pCursor->bits->height);
Pixmap mask = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn, 1, mask, winId, pCursor->bits->width, pCursor->bits->height);
ximage = XCreateImage(xnestDisplay,
xnestDefaultVisual(pScreen),
@ -101,8 +101,8 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color,
pCursor->bits->xhot, pCursor->bits->yhot);
XFreePixmap(xnestDisplay, source);
XFreePixmap(xnestDisplay, mask);
xcb_free_pixmap(xnestUpstreamInfo.conn, source);
xcb_free_pixmap(xnestUpstreamInfo.conn, mask);
return TRUE;
}

View File

@ -143,9 +143,13 @@ xnestOpenDisplay(int argc, char *argv[])
for (j = 0; j < xnestNumDepths; j++)
if (xnestPixmapFormats[i].depth == 1 ||
xnestPixmapFormats[i].depth == xnestDepths[j]) {
xnestDefaultDrawables[xnestPixmapFormats[i].depth] =
XCreatePixmap(xnestDisplay, xnestUpstreamInfo.screenInfo->root,
1, 1, xnestPixmapFormats[i].depth);
uint32_t pixmap = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn,
xnestPixmapFormats[i].depth,
pixmap,
xnestUpstreamInfo.screenInfo->root,
1, 1);
xnestDefaultDrawables[xnestPixmapFormats[i].depth] = pixmap;
}
xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL);

View File

@ -26,6 +26,7 @@ is" without express or implied warranty.
#include "mi.h"
#include "Xnest.h"
#include "xnest-xcb.h"
#include "Display.h"
#include "Screen.h"
@ -56,11 +57,12 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
pPixmap->refcnt = 1;
pPixmap->devKind = PixmapBytePad(width, depth);
pPixmap->usage_hint = usage_hint;
if (width && height)
xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay,
xnestDefaultWindows[pScreen->myNum],
width, height, depth);
if (width && height) {
uint32_t pixmap = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn, depth, pixmap,
xnestDefaultWindows[pScreen->myNum], width, height);
xnestPixmapPriv(pPixmap)->pixmap = pixmap;
}
else
xnestPixmapPriv(pPixmap)->pixmap = 0;
@ -72,7 +74,7 @@ xnestDestroyPixmap(PixmapPtr pPixmap)
{
if (--pPixmap->refcnt)
return TRUE;
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
xcb_free_pixmap(xnestUpstreamInfo.conn, xnestPixmap(pPixmap));
FreePixmap(pPixmap);
return TRUE;
}
@ -82,10 +84,11 @@ xnestModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, void *pPixData)
{
if(!xnestPixmapPriv(pPixmap)->pixmap && width > 0 && height > 0) {
xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay,
xnestDefaultWindows[pPixmap->drawable.pScreen->myNum],
width, height, depth);
uint32_t pixmap = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn, depth, pixmap,
xnestDefaultWindows[pPixmap->drawable.pScreen->myNum],
width, height);
xnestPixmapPriv(pPixmap)->pixmap = pixmap;
}
return miModifyPixmapHeader(pPixmap, width, height, depth,