From 9cf63422e2e4abeae940d016806377f2300ad7aa Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 30 Jul 2024 21:02:24 +0200 Subject: [PATCH] xnest: replace XConfigureWindow() calls by xcb_configure_window() Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Window.c | 11 +++++------ hw/xnest/xcb.c | 22 ++++++++++++++++++++++ hw/xnest/xnest-xcb.h | 10 ++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index 3c6b02c39..7a043d7e4 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -191,7 +191,7 @@ void xnestConfigureWindow(WindowPtr pWin, unsigned int mask) { unsigned int valuemask; - XWindowChanges values; + XnWindowChanges values; if (mask & XCB_CONFIG_WINDOW_SIBLING && xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) { @@ -241,8 +241,7 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) xnestWindowPriv(pWin)->border_width = pWin->borderWidth; } - if (valuemask) - XConfigureWindow(xnestDisplay, xnestWindow(pWin), valuemask, &values); + xnest_configure_window(xnestUpstreamInfo.conn, xnestWindow(pWin), valuemask, values); if (mask & XCB_CONFIG_WINDOW_SIBLING && xnestWindowPriv(pWin)->sibling_above != xnestWindowSiblingAbove(pWin)) { @@ -254,7 +253,8 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) /* the top sibling */ valuemask = XCB_CONFIG_WINDOW_STACK_MODE; values.stack_mode = Above; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values); + + xnest_configure_window(xnestUpstreamInfo.conn, xnestWindow(pSib), valuemask, values); xnestWindowPriv(pSib)->sibling_above = XCB_WINDOW_NONE; /* the rest of siblings */ @@ -262,8 +262,7 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) valuemask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; values.sibling = xnestWindowSiblingAbove(pSib); values.stack_mode = Below; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, - &values); + xnest_configure_window(xnestUpstreamInfo.conn, xnestWindow(pSib), valuemask, values); xnestWindowPriv(pSib)->sibling_above = xnestWindowSiblingAbove(pSib); } diff --git a/hw/xnest/xcb.c b/hw/xnest/xcb.c index 5ae1cfed3..8f526ddc4 100644 --- a/hw/xnest/xcb.c +++ b/hw/xnest/xcb.c @@ -66,3 +66,25 @@ void xnest_encode_window_attr(XnSetWindowAttr attr, uint32_t mask, uint32_t *val EXTRA_VALUE(XCB_CW_CURSOR, cursor); #undef EXTRA_VALUE } + +void xnest_configure_window(xcb_connection_t *conn, uint32_t window, + uint32_t mask, XnWindowChanges values) +{ + if (mask) { + uint32_t value_list[16] = { 0 }; + + int idx = 0; + +#define EXTRA_VALUE(flag,val) if (mask & flag) { value_list[idx++] = values.val; } + EXTRA_VALUE(XCB_CONFIG_WINDOW_X, x); + EXTRA_VALUE(XCB_CONFIG_WINDOW_Y, y); + EXTRA_VALUE(XCB_CONFIG_WINDOW_WIDTH, width); + EXTRA_VALUE(XCB_CONFIG_WINDOW_HEIGHT, height); + EXTRA_VALUE(XCB_CONFIG_WINDOW_BORDER_WIDTH, border_width); + EXTRA_VALUE(XCB_CONFIG_WINDOW_SIBLING, sibling); + EXTRA_VALUE(XCB_CONFIG_WINDOW_STACK_MODE, stack_mode); +#undef EXTRA_VALUE + + xcb_configure_window(conn, window, mask, value_list); + } +} diff --git a/hw/xnest/xnest-xcb.h b/hw/xnest/xnest-xcb.h index 85816faee..3422807fc 100644 --- a/hw/xnest/xnest-xcb.h +++ b/hw/xnest/xnest-xcb.h @@ -27,4 +27,14 @@ uint32_t xnestUpstreamGC(GCPtr pGC); typedef XSetWindowAttributes XnSetWindowAttr; void xnest_encode_window_attr(XnSetWindowAttr attr, uint32_t mask, uint32_t *values); +typedef struct { + int x, y; + int width, height; + int border_width; + uint32_t sibling; + int stack_mode; +} XnWindowChanges; + +void xnest_configure_window(xcb_connection_t *conn, uint32_t window, uint32_t mask, XnWindowChanges values); + #endif /* __XNEST__XCB_H */