diff options
author | Jamey Sharp <jamey@minilop.net> | 2005-12-08 05:51:19 +0000 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2005-12-08 05:51:19 +0000 |
commit | 9a0d030c3920aedeff037625c8d8417e399d66bc (patch) | |
tree | 5427b56fc9f28c67e0a23bfd6067ce029b3a9f00 /xcb | |
parent | 81e33a421d63294ed7c52f146231b11aaf777012 (diff) |
Rename XCBConnect to XCBConnectToFD, and implement XCBConnect and
XCBConnectToDisplayWithAuthInfo, as specified by the XcbApi
documentation. Provide a trivial implementation of deprecated
XCBConnectBasic for backwards compatibility. Fix XCBParseDisplay to
accept a null screen pointer.
Diffstat (limited to 'xcb')
-rw-r--r-- | xcb/ChangeLog | 9 | ||||
-rw-r--r-- | xcb/src/xcb.h | 6 | ||||
-rw-r--r-- | xcb/src/xcb_conn.c | 2 | ||||
-rw-r--r-- | xcb/src/xcb_util.c | 52 |
4 files changed, 48 insertions, 21 deletions
diff --git a/xcb/ChangeLog b/xcb/ChangeLog index dc485a8..bff9d5e 100644 --- a/xcb/ChangeLog +++ b/xcb/ChangeLog @@ -1,3 +1,12 @@ +2005-12-07 Jamey Sharp <jamey@minilop.net> + + * src/xcb.h, src/xcb_conn.c, src/xcb_util.c: + Rename XCBConnect to XCBConnectToFD, and implement XCBConnect + and XCBConnectToDisplayWithAuthInfo, as specified by the XcbApi + documentation. Provide a trivial implementation of deprecated + XCBConnectBasic for backwards compatibility. Fix XCBParseDisplay + to accept a null screen pointer. + 2005-09-30 Trevor Woerner <twoerner.x@gmail.com> reviewer: Jamey Sharp <jamey@minilop.net> diff --git a/xcb/src/xcb.h b/xcb/src/xcb.h index b4d1a17..84295d9 100644 --- a/xcb/src/xcb.h +++ b/xcb/src/xcb.h @@ -133,7 +133,7 @@ void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext); XCBConnSetupSuccessRep *XCBGetSetup(XCBConnection *c); int XCBGetFileDescriptor(XCBConnection *c); -XCBConnection *XCBConnect(int fd, XCBAuthInfo *auth_info); +XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info); void XCBDisconnect(XCBConnection *c); @@ -144,7 +144,9 @@ int XCBOpen(const char *host, int display); int XCBOpenTCP(const char *host, unsigned short port); int XCBOpenUnix(const char *file); -XCBConnection *XCBConnectBasic(void); +XCBConnection *XCBConnectBasic(void); /* deprecated */ +XCBConnection *XCBConnect(const char *displayname, int *screenp); +XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *display, XCBAuthInfo *auth, int *screen); int XCBSync(XCBConnection *c, XCBGenericError **e); diff --git a/xcb/src/xcb_conn.c b/xcb/src/xcb_conn.c index ac8ab52..0148abf 100644 --- a/xcb/src/xcb_conn.c +++ b/xcb/src/xcb_conn.c @@ -130,7 +130,7 @@ int XCBGetFileDescriptor(XCBConnection *c) return c->fd; } -XCBConnection *XCBConnect(int fd, XCBAuthInfo *auth_info) +XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info) { XCBConnection* c; diff --git a/xcb/src/xcb_util.c b/xcb/src/xcb_util.c index 8395879..07201ef 100644 --- a/xcb/src/xcb_util.c +++ b/xcb/src/xcb_util.c @@ -52,6 +52,9 @@ int XCBPopcount(CARD32 mask) int XCBParseDisplay(const char *name, char **host, int *display, int *screen) { char *colon; + int dummy_screen; + if(!screen) + screen = &dummy_screen; *screen = *display = 0; if(!name || !*name) name = getenv("DISPLAY"); @@ -128,39 +131,52 @@ int XCBOpenUnix(const char *file) return fd; } -XCBConnection *XCBConnectBasic() +XCBConnection *XCBConnect(const char *displayname, int *screenp) { - int fd, display = 0, screen = 0; + int fd, display = 0; char *host; XCBConnection *c; XCBAuthInfo auth; - if(!XCBParseDisplay(0, &host, &display, &screen)) - { - fprintf(stderr, "Invalid DISPLAY\n"); - abort(); - } + if(!XCBParseDisplay(displayname, &host, &display, screenp)) + return 0; fd = XCBOpen(host, display); free(host); if(fd == -1) - { - perror("XCBOpen"); - abort(); - } + return 0; XCBGetAuthInfo(fd, &auth); - c = XCBConnect(fd, &auth); - if(!c) - { - perror("XCBConnect"); - abort(); - } - + c = XCBConnectToFD(fd, &auth); free(auth.name); free(auth.data); return c; } +XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *displayname, XCBAuthInfo *auth, int *screenp) +{ + int fd, display = 0; + char *host; + + if(!XCBParseDisplay(displayname, &host, &display, screenp)) + return 0; + fd = XCBOpen(host, display); + free(host); + if(fd == -1) + return 0; + + return XCBConnectToFD(fd, auth); +} + +/* backwards compatible interface: remove before 1.0 release */ +XCBConnection *XCBConnectBasic() +{ + XCBConnection *c = XCBConnect(0, 0); + if(c) + return c; + perror("XCBConnect"); + abort(); +} + int XCBSync(XCBConnection *c, XCBGenericError **e) { XCBGetInputFocusRep *reply = XCBGetInputFocusReply(c, XCBGetInputFocus(c), e); |