From 013374b8c18e429209ef82f29c895c2f80997746 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 1 Aug 2024 12:04:48 +0200 Subject: [PATCH] Xnest: add helper for retrieving GC XID on upstream connection Upcoming patches will need to retieve GC's XIDs on the upstream connection. Moving this out into separate .c file, in order to not creating more dependencies on Xlib headers, which we wanna get rid of. For now, looking at the Xlib GC structure, attached to our DDX GCs. When all users of the Xlib GC have gone (ie. moved all consumers to xcb), we'll create the GC via xcb directly, thus replacing the Xlib GC struct by XID - the interface of this helper will remain the same. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Xnest.h | 1 + hw/xnest/xcb.c | 15 +++++++++++++++ hw/xnest/xnest-xcb.h | 3 +++ 3 files changed, 19 insertions(+) diff --git a/hw/xnest/Xnest.h b/hw/xnest/Xnest.h index 8fd0066c2..d24491206 100644 --- a/hw/xnest/Xnest.h +++ b/hw/xnest/Xnest.h @@ -68,6 +68,7 @@ typedef XID KeySym64; #endif /*_XSERVER64*/ #include +#include #include #include #include diff --git a/hw/xnest/xcb.c b/hw/xnest/xcb.c index a93628886..18fbc09ff 100644 --- a/hw/xnest/xcb.c +++ b/hw/xnest/xcb.c @@ -10,8 +10,11 @@ #include #include +#include "include/gc.h" + #include "Xnest.h" #include "xnest-xcb.h" +#include "XNGC.h" #include "Display.h" @@ -29,3 +32,15 @@ void xnest_upstream_setup(void) { xcb_screen_next (&iter); xnestUpstreamInfo.screenInfo = iter.data; } + +/* retrieve upstream GC XID for our xserver GC */ +uint32_t xnest_upstream_gc(GCPtr pGC) { + if (pGC == NULL) return 0; + + xnestPrivGC *priv = dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey); + if ((priv == NULL) || (priv->gc == NULL)) return 0; + + // make sure Xlib's GC cache is written out before using (server side) GC. + XFlushGC(xnestDisplay, priv->gc); + return priv->gc->gid; +} diff --git a/hw/xnest/xnest-xcb.h b/hw/xnest/xnest-xcb.h index 391e84d22..3c35e04dc 100644 --- a/hw/xnest/xnest-xcb.h +++ b/hw/xnest/xnest-xcb.h @@ -19,4 +19,7 @@ extern struct xnest_upstream_info xnestUpstreamInfo; /* fetch upstream connection's xcb setup data */ void xnest_upstream_setup(void); +/* retrieve upstream GC XID for our xserver GC */ +uint32_t xnest_upstream_gc(GCPtr pGC); + #endif /* __XNEST__XCB_H */