From 04d4986004049a128a80d013deb643590ed8b5e3 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 23 Oct 2025 13:36:21 +0200 Subject: [PATCH] dix: split ProcCreateWindow() into upper and lower half In order to reduce complexity of wrapped core request handlers with PanoramiX, split the ProcCreateWindow() function into two pieces: the upper half is the usual (non-PanoramiX) handler, while the lower one is what's called by both the usual handler, as well as the PanoramiX' one. We're already passing in the request parameters as separate pointers, so follow-up commits can easily change PanoramiX handler to not tweaking the request buffer directly anymore. Another one is letting PanoramiXCreateWindow() be called by ProcCreateWindow explicitly (when enabled), so we don't need to wrap the core request proc vector anymore. Once that's done, the swapping can also be moved into ProcCreateWindow(). Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/panoramiXprocs.c | 3 ++- dix/dispatch.c | 27 ++++++++++++++++----------- dix/window_priv.h | 6 ++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 246a21ccc1..6cadc38494 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -36,6 +36,7 @@ Equipment Corporation. #include "dix/rpcbuf_priv.h" #include "dix/screenint_priv.h" #include "dix/server_priv.h" +#include "dix/window_priv.h" #include "os/osdep.h" #include "Xext/panoramiX.h" #include "Xext/panoramiXsrv.h" @@ -154,7 +155,7 @@ PanoramiXCreateWindow(ClientPtr client) *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[walkScreenIdx].id; if (orig_visual != CopyFromParent) stuff->visual = PanoramiXTranslateVisualID(walkScreenIdx, orig_visual); - result = (*SavedProcVector[X_CreateWindow]) (client); + result = DoCreateWindowReq(client, stuff, (XID*)&stuff[1]); if (result != Success) break; }); diff --git a/dix/dispatch.c b/dix/dispatch.c index 95a5aa350b..b1b06f2219 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -732,23 +732,15 @@ CreateConnectionBlock(void) return TRUE; } -int -ProcCreateWindow(ClientPtr client) +int DoCreateWindowReq(ClientPtr client, xCreateWindowReq *stuff, XID *xids) { WindowPtr pParent, pWin; - - REQUEST(xCreateWindowReq); - int len, rc; - - REQUEST_AT_LEAST_SIZE(xCreateWindowReq); + int rc; LEGAL_NEW_RESOURCE(stuff->wid, client); rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess); if (rc != Success) return rc; - len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); - if (Ones(stuff->mask) != len) - return BadLength; if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; @@ -756,7 +748,7 @@ ProcCreateWindow(ClientPtr client) pWin = dixCreateWindow(stuff->wid, pParent, stuff->x, stuff->y, stuff->width, stuff->height, stuff->borderWidth, stuff->class, - stuff->mask, (XID *) &stuff[1], + stuff->mask, (XID *) xids, (int) stuff->depth, client, stuff->visual, &rc); if (pWin) { Mask mask = pWin->eventMask; @@ -769,6 +761,19 @@ ProcCreateWindow(ClientPtr client) return rc; } +int +ProcCreateWindow(ClientPtr client) +{ + REQUEST(xCreateWindowReq); + REQUEST_AT_LEAST_SIZE(xCreateWindowReq); + + int len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); + if (Ones(stuff->mask) != len) + return BadLength; + + return DoCreateWindowReq(client, stuff, (XID*)&stuff[1]); +} + int ProcChangeWindowAttributes(ClientPtr client) { diff --git a/dix/window_priv.h b/dix/window_priv.h index af6ab917c4..3753e2f247 100644 --- a/dix/window_priv.h +++ b/dix/window_priv.h @@ -53,4 +53,10 @@ Bool MakeWindowOptional(WindowPtr pWin); */ Bool dixWindowIsRoot(Window window); +/* + * @brief lower part of X_CreateWindow request handler. + * Called by ProcCreateWindow() as well as PanoramiXCreateWindow() + */ +int DoCreateWindowReq(ClientPtr client, xCreateWindowReq *stuff, XID *xids); + #endif /* _XSERVER_DIX_WINDOW_PRIV_H */