From 56c646cb632c9c171a6dadc87ca7adb1fcecd4df Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 30 Aug 2024 19:25:23 +0200 Subject: [PATCH] Xnest: xnestWindowParent macro by xnest_upstream_window_parent() Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Window.c | 21 ++++++++++++++++----- hw/xnest/XNWindow.h | 5 ----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index 008081e3c..97c3b530c 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -43,6 +43,17 @@ is" without express or implied warranty. DevPrivateKeyRec xnestWindowPrivateKeyRec; +/* + * retrieve the Window's parent upstream ID. + * if it's a toplevel window, return the root window instead + */ +static inline xcb_window_t xnest_upstream_window_parent(WindowPtr pWin) +{ + return (pWin->parent ? + xnestWindow(pWin->parent) : + xnest_screen_priv(pWin->drawable.pScreen)->upstream_frame_window); +} + static int xnestFindWindowMatch(WindowPtr pWin, void *ptr) { @@ -121,7 +132,7 @@ xnestCreateWindow(WindowPtr pWin) xcb_aux_create_window(xnestUpstreamInfo.conn, pWin->drawable.depth, xnestWindowPriv(pWin)->window, - xnestWindowParent(pWin), + xnest_upstream_window_parent(pWin), pWin->origin.x - wBorderWidth(pWin), pWin->origin.y - wBorderWidth(pWin), pWin->drawable.width, @@ -132,7 +143,7 @@ xnestCreateWindow(WindowPtr pWin) mask, &attributes); - xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); + xnestWindowPriv(pWin)->parent = xnest_upstream_window_parent(pWin); xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); xnestWindowPriv(pWin)->width = pWin->drawable.width; @@ -188,16 +199,16 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) xcb_params_configure_window_t values; if (mask & XCB_CONFIG_WINDOW_SIBLING && - xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) { + xnestWindowPriv(pWin)->parent != xnest_upstream_window_parent(pWin)) { xcb_reparent_window( xnestUpstreamInfo.conn, xnestWindow(pWin), - xnestWindowParent(pWin), + xnest_upstream_window_parent(pWin), pWin->origin.x - wBorderWidth(pWin), pWin->origin.y - wBorderWidth(pWin)); - xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); + xnestWindowPriv(pWin)->parent = xnest_upstream_window_parent(pWin); xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); xnestWindowPriv(pWin)->sibling_above = XCB_WINDOW_NONE; diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h index 73c748227..15a416123 100644 --- a/hw/xnest/XNWindow.h +++ b/hw/xnest/XNWindow.h @@ -45,11 +45,6 @@ extern DevPrivateKeyRec xnestWindowPrivateKeyRec; #define xnestWindow(pWin) (xnestWindowPriv(pWin)->window) -#define xnestWindowParent(pWin) \ - ((pWin)->parent ? \ - xnestWindow((pWin)->parent) : \ - xnest_screen_priv(pWin->drawable.pScreen)->upstream_frame_window) - #define xnestWindowSiblingAbove(pWin) \ ((pWin)->prevSib ? xnestWindow((pWin)->prevSib) : XCB_WINDOW_NONE)