From 91371e3233261cc5a956f1c3f1ae30b20b34b25a Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 8 Aug 2024 10:44:55 +0200 Subject: [PATCH] Xnest: replace XCreatePixmapFromBitmapData() by xcb_put_image() Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Display.c | 3 ++- hw/xnest/xcb.c | 42 ++++++++++++++++++++++++++++++++++++++++++ hw/xnest/xnest-xcb.h | 4 ++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index 0a151d745..567e560ca 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -185,7 +185,8 @@ xnestOpenDisplay(int argc, char *argv[]) (char *) icon_bits, icon_width, icon_height); xnestScreenSaverPixmap = - XCreatePixmapFromBitmapData(xnestDisplay, + xnest_create_pixmap_from_bitmap_data( + xnestUpstreamInfo.conn, xnestUpstreamInfo.screenInfo->root, (char *) screensaver_bits, screensaver_width, diff --git a/hw/xnest/xcb.c b/hw/xnest/xcb.c index 4816a405f..e2050590a 100644 --- a/hw/xnest/xcb.c +++ b/hw/xnest/xcb.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -105,3 +106,44 @@ uint32_t xnest_create_bitmap_from_data( xcb_free_gc(conn, gc); return pix; } + +uint32_t xnest_create_pixmap_from_bitmap_data( + xcb_connection_t *conn, + uint32_t drawable, + const char *data, + uint32_t width, + uint32_t height, + uint32_t fg, + uint32_t bg, + uint16_t depth) +{ + uint32_t pix = xcb_generate_id(xnestUpstreamInfo.conn); + xcb_create_pixmap(conn, depth, pix, drawable, width, height); + + uint32_t gc = xcb_generate_id(xnestUpstreamInfo.conn); + xcb_create_gc(conn, gc, pix, 0, NULL); + + xcb_params_gc_t gcv = { + .foreground = fg, + .background = bg + }; + + xcb_aux_change_gc(conn, gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND, &gcv); + + const int leftPad = 0; + xcb_put_image(conn, + XYBitmap, + pix, + gc, + width, + height, + 0 /* dst_x */, + 0 /* dst_y */, + leftPad, + 1 /* depth */, + BitmapBytePad(width + leftPad) * height, + (uint8_t*)data); + + xcb_free_gc(conn, gc); + return pix; +} diff --git a/hw/xnest/xnest-xcb.h b/hw/xnest/xnest-xcb.h index f3c3a1923..accbd36b2 100644 --- a/hw/xnest/xnest-xcb.h +++ b/hw/xnest/xnest-xcb.h @@ -28,4 +28,8 @@ void xnest_wm_colormap_windows(xcb_connection_t *conn, xcb_window_t w, uint32_t xnest_create_bitmap_from_data(xcb_connection_t *conn, uint32_t drawable, const char *data, uint32_t width, uint32_t height); +uint32_t xnest_create_pixmap_from_bitmap_data(xcb_connection_t *conn, uint32_t drawable, + const char *data, uint32_t width, uint32_t height, + uint32_t fg, uint32_t bg, uint16_t depth); + #endif /* __XNEST__XCB_H */