Xnest: use XCB for upstream connection
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
540043413b
commit
6e4914ffd0
|
@ -39,7 +39,6 @@ is" without express or implied warranty.
|
||||||
#include "icon"
|
#include "icon"
|
||||||
#include "screensaver"
|
#include "screensaver"
|
||||||
|
|
||||||
Display *xnestDisplay = NULL;
|
|
||||||
Colormap *xnestDefaultColormaps;
|
Colormap *xnestDefaultColormaps;
|
||||||
int xnestNumPixmapFormats;
|
int xnestNumPixmapFormats;
|
||||||
Drawable xnestDefaultDrawables[MAXDEPTH + 1];
|
Drawable xnestDefaultDrawables[MAXDEPTH + 1];
|
||||||
|
@ -48,15 +47,6 @@ Pixmap xnestScreenSaverPixmap;
|
||||||
uint32_t xnestBitmapGC;
|
uint32_t xnestBitmapGC;
|
||||||
uint32_t xnestEventMask;
|
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
|
void
|
||||||
xnestOpenDisplay(int argc, char *argv[])
|
xnestOpenDisplay(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -65,16 +55,10 @@ xnestOpenDisplay(int argc, char *argv[])
|
||||||
if (!xnestDoFullGeneration)
|
if (!xnestDoFullGeneration)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XSetIOErrorHandler(x_io_error_handler);
|
|
||||||
|
|
||||||
xnestCloseDisplay();
|
xnestCloseDisplay();
|
||||||
|
|
||||||
xnestDisplay = XOpenDisplay(xnestDisplayName);
|
if (!xnest_upstream_setup(xnestDisplayName))
|
||||||
if (xnestDisplay == NULL)
|
FatalError("Unable to open display \"%s\".\n", xnestDisplayName);
|
||||||
FatalError("Unable to open display \"%s\".\n",
|
|
||||||
XDisplayName(xnestDisplayName));
|
|
||||||
|
|
||||||
xnest_upstream_setup();
|
|
||||||
|
|
||||||
if (xnestParentWindow != (Window) 0)
|
if (xnestParentWindow != (Window) 0)
|
||||||
xnestEventMask = XCB_EVENT_MASK_STRUCTURE_NOTIFY;
|
xnestEventMask = XCB_EVENT_MASK_STRUCTURE_NOTIFY;
|
||||||
|
@ -147,7 +131,7 @@ xnestOpenDisplay(int argc, char *argv[])
|
||||||
void
|
void
|
||||||
xnestCloseDisplay(void)
|
xnestCloseDisplay(void)
|
||||||
{
|
{
|
||||||
if (!xnestDoFullGeneration || !xnestDisplay)
|
if (!xnestDoFullGeneration || !xnestUpstreamInfo.conn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -158,5 +142,8 @@ xnestCloseDisplay(void)
|
||||||
xnestVisualMap = NULL;
|
xnestVisualMap = NULL;
|
||||||
xnestNumVisualMap = 0;
|
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 MAXDEPTH 32
|
||||||
#define MAXVISUALSPERDEPTH 256
|
#define MAXVISUALSPERDEPTH 256
|
||||||
|
|
||||||
extern Display *xnestDisplay;
|
|
||||||
extern int xnestNumPixmapFormats;
|
extern int xnestNumPixmapFormats;
|
||||||
extern Drawable xnestDefaultDrawables[MAXDEPTH + 1];
|
extern Drawable xnestDefaultDrawables[MAXDEPTH + 1];
|
||||||
extern Pixmap xnestIconBitmap;
|
extern Pixmap xnestIconBitmap;
|
||||||
|
|
|
@ -259,7 +259,7 @@ xnestCollectEvents(void)
|
||||||
|
|
||||||
int err = xcb_connection_has_error(xnestUpstreamInfo.conn);
|
int err = xcb_connection_has_error(xnestUpstreamInfo.conn);
|
||||||
if (err) {
|
if (err) {
|
||||||
ErrorF("Xnest: upsream connection error: %d\n", err);
|
ErrorF("Xnest: upstream connection error: %d\n", err);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,13 @@ xnestUpstreamInfoRec xnestUpstreamInfo = { 0 };
|
||||||
XnestVisualRec *xnestVisualMap;
|
XnestVisualRec *xnestVisualMap;
|
||||||
int xnestNumVisualMap;
|
int xnestNumVisualMap;
|
||||||
|
|
||||||
void xnest_upstream_setup(void) {
|
Bool xnest_upstream_setup(const char* displayName)
|
||||||
xnestUpstreamInfo.screenId = DefaultScreen(xnestDisplay);
|
{
|
||||||
|
xnestUpstreamInfo.conn = xcb_connect(displayName, &xnestUpstreamInfo.screenId);
|
||||||
|
if (!xnestUpstreamInfo.conn)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
/* retrieve setup data for our screen */
|
/* retrieve setup data for our screen */
|
||||||
xnestUpstreamInfo.conn = XGetXCBConnection(xnestDisplay);
|
|
||||||
xnestUpstreamInfo.setup = xcb_get_setup(xnestUpstreamInfo.conn);
|
xnestUpstreamInfo.setup = xcb_get_setup(xnestUpstreamInfo.conn);
|
||||||
xcb_screen_iterator_t iter = xcb_setup_roots_iterator (xnestUpstreamInfo.setup);
|
xcb_screen_iterator_t iter = xcb_setup_roots_iterator (xnestUpstreamInfo.setup);
|
||||||
|
|
||||||
|
@ -38,6 +40,8 @@ void xnest_upstream_setup(void) {
|
||||||
xnestUpstreamInfo.screenInfo = iter.data;
|
xnestUpstreamInfo.screenInfo = iter.data;
|
||||||
|
|
||||||
xorg_list_init(&xnestUpstreamInfo.eventQueue.entry);
|
xorg_list_init(&xnestUpstreamInfo.eventQueue.entry);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve upstream GC XID for our xserver GC */
|
/* retrieve upstream GC XID for our xserver GC */
|
||||||
|
|
|
@ -16,7 +16,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
xcb_connection_t *conn;
|
xcb_connection_t *conn;
|
||||||
uint32_t screenId;
|
int screenId;
|
||||||
const xcb_screen_t *screenInfo;
|
const xcb_screen_t *screenInfo;
|
||||||
const xcb_setup_t *setup;
|
const xcb_setup_t *setup;
|
||||||
xnestEventQueue eventQueue;
|
xnestEventQueue eventQueue;
|
||||||
|
@ -24,8 +24,8 @@ typedef struct {
|
||||||
|
|
||||||
extern xnestUpstreamInfoRec xnestUpstreamInfo;
|
extern xnestUpstreamInfoRec xnestUpstreamInfo;
|
||||||
|
|
||||||
/* fetch upstream connection's xcb setup data */
|
/* connect to upstream X server */
|
||||||
void xnest_upstream_setup(void);
|
Bool xnest_upstream_setup(const char* displayName);
|
||||||
|
|
||||||
/* retrieve upstream GC XID for our xserver GC */
|
/* retrieve upstream GC XID for our xserver GC */
|
||||||
uint32_t xnestUpstreamGC(GCPtr pGC);
|
uint32_t xnestUpstreamGC(GCPtr pGC);
|
||||||
|
|
Loading…
Reference in New Issue