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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-08-01 12:04:48 +02:00
parent 9a91f519c3
commit 013374b8c1
3 changed files with 19 additions and 0 deletions

View File

@ -68,6 +68,7 @@ typedef XID KeySym64;
#endif /*_XSERVER64*/ #endif /*_XSERVER64*/
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include <X11/Xlib-xcb.h> #include <X11/Xlib-xcb.h>

View File

@ -10,8 +10,11 @@
#include <X11/Xdefs.h> #include <X11/Xdefs.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include "include/gc.h"
#include "Xnest.h" #include "Xnest.h"
#include "xnest-xcb.h" #include "xnest-xcb.h"
#include "XNGC.h"
#include "Display.h" #include "Display.h"
@ -29,3 +32,15 @@ void xnest_upstream_setup(void) {
xcb_screen_next (&iter); xcb_screen_next (&iter);
xnestUpstreamInfo.screenInfo = iter.data; 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;
}

View File

@ -19,4 +19,7 @@ extern struct xnest_upstream_info xnestUpstreamInfo;
/* fetch upstream connection's xcb setup data */ /* fetch upstream connection's xcb setup data */
void xnest_upstream_setup(void); void xnest_upstream_setup(void);
/* retrieve upstream GC XID for our xserver GC */
uint32_t xnest_upstream_gc(GCPtr pGC);
#endif /* __XNEST__XCB_H */ #endif /* __XNEST__XCB_H */