Xnest: use XCB for upstream connection
Now that no Xlib operations (besides opening and closing connection) aren't used anymore, we can move over the last pieces and use XCB instead of Xlib for connecting the upstream Xserver. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
4716ee9981
commit
9969258e44
|
@ -37,7 +37,6 @@ is" without express or implied warranty.
|
|||
#include "icon"
|
||||
#include "screensaver"
|
||||
|
||||
Display *xnestDisplay = NULL;
|
||||
Colormap *xnestDefaultColormaps;
|
||||
int xnestNumPixmapFormats;
|
||||
Drawable xnestDefaultDrawables[MAXDEPTH + 1];
|
||||
|
@ -46,15 +45,6 @@ Pixmap xnestScreenSaverPixmap;
|
|||
uint32_t xnestBitmapGC;
|
||||
uint32_t xnestEventMask;
|
||||
|
||||
static int _X_NORETURN
|
||||
x_io_error_handler(Display * dpy)
|
||||
{
|
||||
ErrorF("Lost connection to X server: %s\n", strerror(errno));
|
||||
CloseWellKnownConnections();
|
||||
OsCleanup(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
xnestOpenDisplay(int argc, char *argv[])
|
||||
{
|
||||
|
@ -63,16 +53,10 @@ xnestOpenDisplay(int argc, char *argv[])
|
|||
if (!xnestDoFullGeneration)
|
||||
return;
|
||||
|
||||
XSetIOErrorHandler(x_io_error_handler);
|
||||
|
||||
xnestCloseDisplay();
|
||||
|
||||
xnestDisplay = XOpenDisplay(xnestDisplayName);
|
||||
if (xnestDisplay == NULL)
|
||||
FatalError("Unable to open display \"%s\".\n",
|
||||
XDisplayName(xnestDisplayName));
|
||||
|
||||
xnest_upstream_setup();
|
||||
if (!xnest_upstream_setup(xnestDisplayName))
|
||||
FatalError("Unable to open display \"%s\".\n", xnestDisplayName);
|
||||
|
||||
if (xnestParentWindow != (Window) 0)
|
||||
xnestEventMask = XCB_EVENT_MASK_STRUCTURE_NOTIFY;
|
||||
|
@ -146,7 +130,7 @@ xnestOpenDisplay(int argc, char *argv[])
|
|||
void
|
||||
xnestCloseDisplay(void)
|
||||
{
|
||||
if (!xnestDoFullGeneration || !xnestDisplay)
|
||||
if (!xnestDoFullGeneration || !xnestUpstreamInfo.conn)
|
||||
return;
|
||||
|
||||
/*
|
||||
|
@ -157,5 +141,8 @@ xnestCloseDisplay(void)
|
|||
xnestVisualMap = NULL;
|
||||
xnestNumVisualMap = 0;
|
||||
|
||||
XCloseDisplay(xnestDisplay);
|
||||
xcb_disconnect(xnestUpstreamInfo.conn);
|
||||
xnestUpstreamInfo.conn = NULL;
|
||||
xnestUpstreamInfo.screenInfo = NULL;
|
||||
xnestUpstreamInfo.setup = NULL;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ is" without express or implied warranty.
|
|||
#define MAXDEPTH 32
|
||||
#define MAXVISUALSPERDEPTH 256
|
||||
|
||||
extern Display *xnestDisplay;
|
||||
extern int xnestNumPixmapFormats;
|
||||
extern Drawable xnestDefaultDrawables[MAXDEPTH + 1];
|
||||
extern Pixmap xnestIconBitmap;
|
||||
|
|
|
@ -257,7 +257,7 @@ xnestCollectEvents(void)
|
|||
|
||||
int err = xcb_connection_has_error(xnestUpstreamInfo.conn);
|
||||
if (err) {
|
||||
ErrorF("Xnest: upsream connection error: %d\n", err);
|
||||
ErrorF("Xnest: upstream connection error: %d\n", err);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@ struct xnest_upstream_info xnestUpstreamInfo = { 0 };
|
|||
xnest_visual_t *xnestVisualMap;
|
||||
int xnestNumVisualMap;
|
||||
|
||||
void xnest_upstream_setup(void) {
|
||||
xnestUpstreamInfo.screenId = DefaultScreen(xnestDisplay);
|
||||
Bool xnest_upstream_setup(const char* displayName)
|
||||
{
|
||||
xnestUpstreamInfo.conn = xcb_connect(displayName, &xnestUpstreamInfo.screenId);
|
||||
if (!xnestUpstreamInfo.conn)
|
||||
return FALSE;
|
||||
|
||||
/* retrieve setup data for our screen */
|
||||
xnestUpstreamInfo.conn = XGetXCBConnection(xnestDisplay);
|
||||
xnestUpstreamInfo.setup = xcb_get_setup(xnestUpstreamInfo.conn);
|
||||
xcb_screen_iterator_t iter = xcb_setup_roots_iterator (xnestUpstreamInfo.setup);
|
||||
|
||||
|
@ -39,6 +41,8 @@ void xnest_upstream_setup(void) {
|
|||
xnestUpstreamInfo.screenInfo = iter.data;
|
||||
|
||||
xorg_list_init(&xnestUpstreamInfo.eventQueue.entry);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* retrieve upstream GC XID for our xserver GC */
|
||||
|
|
|
@ -16,7 +16,7 @@ struct xnest_event_queue {
|
|||
|
||||
struct xnest_upstream_info {
|
||||
xcb_connection_t *conn;
|
||||
uint32_t screenId;
|
||||
int screenId;
|
||||
const xcb_screen_t *screenInfo;
|
||||
const xcb_setup_t *setup;
|
||||
struct xnest_event_queue eventQueue;
|
||||
|
@ -24,8 +24,8 @@ struct xnest_upstream_info {
|
|||
|
||||
extern struct xnest_upstream_info xnestUpstreamInfo;
|
||||
|
||||
/* fetch upstream connection's xcb setup data */
|
||||
void xnest_upstream_setup(void);
|
||||
/* connect to upstream X server */
|
||||
Bool xnest_upstream_setup(const char* displayName);
|
||||
|
||||
/* retrieve upstream GC XID for our xserver GC */
|
||||
uint32_t xnest_upstream_gc(GCPtr pGC);
|
||||
|
|
Loading…
Reference in New Issue