update to libxcb 1.3
This commit is contained in:
parent
528fed7c9d
commit
8e91f6fca8
9
dist/libxcb/NEWS
vendored
9
dist/libxcb/NEWS
vendored
@ -1,3 +1,12 @@
|
||||
Release 1.3 (2009-05-29)
|
||||
========================
|
||||
* Copy full IPv4 mapping (Bug #20665)
|
||||
* Fix XID allocation
|
||||
* Use poll() instead of select() when available
|
||||
* Fix local socket connection on Hurd
|
||||
* Fix XDM-AUTHORIZATION-1
|
||||
* Disable Nagle on TCP socket
|
||||
|
||||
Release 1.2 (2009-02-17)
|
||||
========================
|
||||
* Stop packaging auto-generated C files into tarball.
|
||||
|
17
dist/libxcb/configure.ac
vendored
17
dist/libxcb/configure.ac
vendored
@ -3,7 +3,7 @@
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([libxcb],
|
||||
1.2,
|
||||
1.3,
|
||||
[xcb@lists.freedesktop.org])
|
||||
AC_CONFIG_SRCDIR([xcb.pc.in])
|
||||
AM_INIT_AUTOMAKE([foreign dist-bzip2])
|
||||
@ -32,7 +32,7 @@ fi
|
||||
AC_SUBST(HTML_CHECK_RESULT)
|
||||
|
||||
# Checks for pkg-config packages
|
||||
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.1)
|
||||
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.5)
|
||||
NEEDED="pthread-stubs xau >= 0.99.2"
|
||||
PKG_CHECK_MODULES(NEEDED, $NEEDED)
|
||||
|
||||
@ -58,6 +58,10 @@ XCBPROTO_XCBINCLUDEDIR=`$PKG_CONFIG --variable=xcbincludedir xcb-proto`
|
||||
AC_MSG_RESULT($XCBPROTO_XCBINCLUDEDIR)
|
||||
AC_SUBST(XCBPROTO_XCBINCLUDEDIR)
|
||||
|
||||
# Find the xcb-proto version
|
||||
XCBPROTO_VERSION=`$PKG_CONFIG --modversion xcb-proto`
|
||||
AC_SUBST(XCBPROTO_VERSION)
|
||||
|
||||
# Find the xcbgen Python package
|
||||
AC_MSG_CHECKING(XCBPROTO_XCBPYTHONDIR)
|
||||
XCBPROTO_XCBPYTHONDIR=`$PKG_CONFIG --variable=pythondir xcb-proto`
|
||||
@ -116,6 +120,15 @@ AC_PREREQ([2.59c], [], [AC_SUBST([htmldir], [m4_ifset([AC_PACKAGE_TARNAME],
|
||||
|
||||
XCB_CHECK_DOXYGEN()
|
||||
|
||||
case $host_os in
|
||||
# darwin has poll() but can't be used to poll character devices
|
||||
# darwin10 (SnowLeopard) should be tested as well once released
|
||||
darwin7*) ;; darwin8*) ;; darwin9*) ;;
|
||||
*)
|
||||
AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
|
||||
;;
|
||||
esac
|
||||
|
||||
XCB_EXTENSION(Composite, "yes")
|
||||
XCB_EXTENSION(Damage, "yes")
|
||||
XCB_EXTENSION(DPMS, "yes")
|
||||
|
2
dist/libxcb/src/Makefile.am
vendored
2
dist/libxcb/src/Makefile.am
vendored
@ -75,7 +75,7 @@ EXTSOURCES += randr.c
|
||||
EXTENSION_XML += randr.xml
|
||||
if BUILD_RANDR
|
||||
lib_LTLIBRARIES += libxcb-randr.la
|
||||
libxcb_randr_la_LDFLAGS = -version-info 0:0:0
|
||||
libxcb_randr_la_LDFLAGS = -version-info 1:0:0
|
||||
libxcb_randr_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_randr_la_SOURCES = randr.c randr.h
|
||||
endif
|
||||
|
20
dist/libxcb/src/c_client.py
vendored
20
dist/libxcb/src/c_client.py
vendored
@ -135,6 +135,9 @@ def c_open(self):
|
||||
_ns = self.namespace
|
||||
_ns.c_ext_global_name = _n(_ns.prefix + ('id',))
|
||||
|
||||
# Build the type-name collision avoidance table used by c_enum
|
||||
build_collision_table()
|
||||
|
||||
_h_setlevel(0)
|
||||
_c_setlevel(0)
|
||||
|
||||
@ -216,13 +219,26 @@ def c_close(self):
|
||||
cfile.write('\n')
|
||||
cfile.close()
|
||||
|
||||
def build_collision_table():
|
||||
global namecount
|
||||
namecount = {}
|
||||
|
||||
for v in module.types.values():
|
||||
name = _t(v[0])
|
||||
namecount[name] = (namecount.get(name) or 0) + 1
|
||||
|
||||
def c_enum(self, name):
|
||||
'''
|
||||
Exported function that handles enum declarations.
|
||||
'''
|
||||
|
||||
tname = _t(name)
|
||||
if namecount[tname] > 1:
|
||||
tname = _t(name + ('enum',))
|
||||
|
||||
_h_setlevel(0)
|
||||
_h('')
|
||||
_h('typedef enum %s {', _t(name))
|
||||
_h('typedef enum %s {', tname)
|
||||
|
||||
count = len(self.values)
|
||||
|
||||
@ -232,7 +248,7 @@ def c_enum(self, name):
|
||||
comma = ',' if count > 0 else ''
|
||||
_h(' %s%s%s%s', _n(name + (enam,)).upper(), equals, eval, comma)
|
||||
|
||||
_h('} %s;', _t(name))
|
||||
_h('} %s;', tname)
|
||||
|
||||
def _c_type_setup(self, name, postfix):
|
||||
'''
|
||||
|
64
dist/libxcb/src/xcb_auth.c
vendored
64
dist/libxcb/src/xcb_auth.c
vendored
@ -49,11 +49,21 @@ enum auth_protos {
|
||||
N_AUTH_PROTOS
|
||||
};
|
||||
|
||||
#define AUTH_PROTO_XDM_AUTHORIZATION "XDM-AUTHORIZATION-1"
|
||||
#define AUTH_PROTO_MIT_MAGIC_COOKIE "MIT-MAGIC-COOKIE-1"
|
||||
|
||||
static char *authnames[N_AUTH_PROTOS] = {
|
||||
#ifdef HASXDMAUTH
|
||||
"XDM-AUTHORIZATION-1",
|
||||
AUTH_PROTO_XDM_AUTHORIZATION,
|
||||
#endif
|
||||
"MIT-MAGIC-COOKIE-1",
|
||||
AUTH_PROTO_MIT_MAGIC_COOKIE,
|
||||
};
|
||||
|
||||
static int authnameslen[N_AUTH_PROTOS] = {
|
||||
#ifdef HASXDMAUTH
|
||||
sizeof(AUTH_PROTO_XDM_AUTHORIZATION) - 1,
|
||||
#endif
|
||||
sizeof(AUTH_PROTO_MIT_MAGIC_COOKIE) - 1,
|
||||
};
|
||||
|
||||
static size_t memdup(char **dst, void *src, size_t len)
|
||||
@ -70,7 +80,7 @@ static size_t memdup(char **dst, void *src, size_t len)
|
||||
|
||||
static int authname_match(enum auth_protos kind, char *name, size_t namelen)
|
||||
{
|
||||
if(strlen(authnames[kind]) != namelen)
|
||||
if(authnameslen[kind] != namelen)
|
||||
return 0;
|
||||
if(memcmp(authnames[kind], name, namelen))
|
||||
return 0;
|
||||
@ -87,8 +97,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
|
||||
unsigned short family;
|
||||
char hostnamebuf[256]; /* big enough for max hostname */
|
||||
char dispbuf[40]; /* big enough to hold more than 2^64 base 10 */
|
||||
int authnamelens[N_AUTH_PROTOS];
|
||||
int i;
|
||||
int dispbuflen;
|
||||
|
||||
family = FamilyLocal; /* 256 */
|
||||
switch(sockname->sa_family)
|
||||
@ -119,7 +128,11 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
|
||||
return 0; /* cannot authenticate this family */
|
||||
}
|
||||
|
||||
snprintf(dispbuf, sizeof(dispbuf), "%d", display);
|
||||
dispbuflen = snprintf(dispbuf, sizeof(dispbuf), "%d", display);
|
||||
if(dispbuflen < 0)
|
||||
return 0;
|
||||
/* snprintf may have truncate our text */
|
||||
dispbuflen = MIN(dispbuflen, sizeof(dispbuf) - 1);
|
||||
|
||||
if (family == FamilyLocal) {
|
||||
if (gethostname(hostnamebuf, sizeof(hostnamebuf)) == -1)
|
||||
@ -128,12 +141,10 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
|
||||
addrlen = strlen(addr);
|
||||
}
|
||||
|
||||
for (i = 0; i < N_AUTH_PROTOS; i++)
|
||||
authnamelens[i] = strlen(authnames[i]);
|
||||
return XauGetBestAuthByAddr (family,
|
||||
(unsigned short) addrlen, addr,
|
||||
(unsigned short) strlen(dispbuf), dispbuf,
|
||||
N_AUTH_PROTOS, authnames, authnamelens);
|
||||
(unsigned short) dispbuflen, dispbuf,
|
||||
N_AUTH_PROTOS, authnames, authnameslen);
|
||||
}
|
||||
|
||||
#ifdef HASXDMAUTH
|
||||
@ -187,7 +198,7 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
|
||||
struct sockaddr_in6 *si6 = (struct sockaddr_in6 *) sockname;
|
||||
if(IN6_IS_ADDR_V4MAPPED(SIN6_ADDR(sockname)))
|
||||
{
|
||||
APPEND(info->data, j, si6->sin6_addr.s6_addr[12]);
|
||||
do_append(info->data, &j, &si6->sin6_addr.s6_addr[12], 4);
|
||||
APPEND(info->data, j, si6->sin6_port);
|
||||
}
|
||||
else
|
||||
@ -239,25 +250,50 @@ int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display)
|
||||
char sockbuf[sizeof(struct sockaddr) + MAXPATHLEN];
|
||||
unsigned int socknamelen = sizeof(sockbuf); /* need extra space */
|
||||
struct sockaddr *sockname = (struct sockaddr *) &sockbuf;
|
||||
int gotsockname = 0;
|
||||
Xauth *authptr = 0;
|
||||
int ret = 1;
|
||||
|
||||
/* Some systems like hpux or Hurd do not expose peer names
|
||||
* for UNIX Domain Sockets, but this is irrelevant,
|
||||
* since compute_auth() ignores the peer name in this
|
||||
* case anyway.*/
|
||||
if (getpeername(fd, sockname, &socknamelen) == -1)
|
||||
{
|
||||
if (sockname->sa_family != AF_UNIX)
|
||||
return 0; /* except for AF_UNIX, sockets should have peernames */
|
||||
if (getsockname(fd, sockname, &socknamelen) == -1)
|
||||
return 0; /* can only authenticate sockets */
|
||||
gotsockname = 1;
|
||||
}
|
||||
|
||||
authptr = get_authptr(sockname, socknamelen, display);
|
||||
if (authptr == 0)
|
||||
return 0; /* cannot find good auth data */
|
||||
|
||||
info->namelen = memdup(&info->name, authptr->name, authptr->name_length);
|
||||
if(info->namelen)
|
||||
if (!info->namelen)
|
||||
goto no_auth; /* out of memory */
|
||||
|
||||
if (!gotsockname && getsockname(fd, sockname, &socknamelen) == -1)
|
||||
{
|
||||
free(info->name);
|
||||
goto no_auth; /* can only authenticate sockets */
|
||||
}
|
||||
|
||||
ret = compute_auth(info, authptr, sockname);
|
||||
if(!ret)
|
||||
{
|
||||
free(info->name);
|
||||
info->name = 0;
|
||||
info->namelen = 0;
|
||||
goto no_auth; /* cannot build auth record */
|
||||
}
|
||||
|
||||
XauDisposeAuth(authptr);
|
||||
return ret;
|
||||
|
||||
no_auth:
|
||||
info->name = 0;
|
||||
info->namelen = 0;
|
||||
XauDisposeAuth(authptr);
|
||||
return 0;
|
||||
}
|
||||
|
36
dist/libxcb/src/xcb_conn.c
vendored
36
dist/libxcb/src/xcb_conn.c
vendored
@ -31,12 +31,16 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/select.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "xcb.h"
|
||||
#include "xcbint.h"
|
||||
#if USE_POLL
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t status;
|
||||
@ -258,7 +262,11 @@ void _xcb_conn_shutdown(xcb_connection_t *c)
|
||||
int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count)
|
||||
{
|
||||
int ret;
|
||||
#if USE_POLL
|
||||
struct pollfd fd;
|
||||
#else
|
||||
fd_set rfds, wfds;
|
||||
#endif
|
||||
|
||||
/* If the thing I should be doing is already being done, wait for it. */
|
||||
if(count ? c->out.writing : c->in.reading)
|
||||
@ -267,20 +275,38 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if USE_POLL
|
||||
memset(&fd, 0, sizeof(fd));
|
||||
fd.fd = c->fd;
|
||||
fd.events = POLLIN;
|
||||
#else
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(c->fd, &rfds);
|
||||
#endif
|
||||
++c->in.reading;
|
||||
|
||||
#if USE_POLL
|
||||
if(count)
|
||||
{
|
||||
fd.events |= POLLOUT;
|
||||
++c->out.writing;
|
||||
}
|
||||
#else
|
||||
FD_ZERO(&wfds);
|
||||
if(count)
|
||||
{
|
||||
FD_SET(c->fd, &wfds);
|
||||
++c->out.writing;
|
||||
}
|
||||
#endif
|
||||
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
do {
|
||||
#if USE_POLL
|
||||
ret = poll(&fd, 1, -1);
|
||||
#else
|
||||
ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
|
||||
#endif
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -291,10 +317,18 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
|
||||
|
||||
if(ret)
|
||||
{
|
||||
#if USE_POLL
|
||||
if((fd.revents & POLLIN) == POLLIN)
|
||||
#else
|
||||
if(FD_ISSET(c->fd, &rfds))
|
||||
#endif
|
||||
ret = ret && _xcb_in_read(c);
|
||||
|
||||
#if USE_POLL
|
||||
if((fd.revents & POLLOUT) == POLLOUT)
|
||||
#else
|
||||
if(FD_ISSET(c->fd, &wfds))
|
||||
#endif
|
||||
ret = ret && write_vec(c, vector, count);
|
||||
}
|
||||
|
||||
|
16
dist/libxcb/src/xcb_in.c
vendored
16
dist/libxcb/src/xcb_in.c
vendored
@ -30,12 +30,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "xcb.h"
|
||||
#include "xcbext.h"
|
||||
#include "xcbint.h"
|
||||
#if USE_POLL
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#define XCB_ERROR 0
|
||||
#define XCB_REPLY 1
|
||||
@ -268,12 +272,22 @@ static int read_block(const int fd, void *buf, const ssize_t len)
|
||||
done += ret;
|
||||
if(ret < 0 && errno == EAGAIN)
|
||||
{
|
||||
#if USE_POLL
|
||||
struct pollfd pfd;
|
||||
pfd.fd = fd;
|
||||
pfd.events = POLLIN;
|
||||
pfd.revents = 0;
|
||||
do {
|
||||
ret = poll(&pfd, 1, -1);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
#else
|
||||
fd_set fds;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(fd, &fds);
|
||||
do {
|
||||
ret = select(fd + 1, &fds, 0, 0, 0);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
#endif
|
||||
}
|
||||
if(ret <= 0)
|
||||
return ret;
|
||||
|
79
dist/libxcb/src/xcb_util.c
vendored
79
dist/libxcb/src/xcb_util.c
vendored
@ -30,6 +30,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#ifdef DNETCONN
|
||||
#include <netdnet/dnetdb.h>
|
||||
#include <netdnet/dn.h>
|
||||
@ -125,7 +126,7 @@ static int _xcb_open_unix(char *protocol, const char *file);
|
||||
static int _xcb_open_decnet(const char *host, char *protocol, const unsigned short port);
|
||||
#endif
|
||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||
static int _xcb_open_abstract(char *protocol, const char *file);
|
||||
static int _xcb_open_abstract(char *protocol, const char *file, size_t filelen);
|
||||
#endif
|
||||
|
||||
static int _xcb_open(char *host, char *protocol, const int display)
|
||||
@ -135,6 +136,7 @@ static int _xcb_open(char *host, char *protocol, const int display)
|
||||
#endif
|
||||
static const char base[] = "/tmp/.X11-unix/X";
|
||||
char file[sizeof(base) + 20];
|
||||
int filelen;
|
||||
|
||||
if(*host)
|
||||
{
|
||||
@ -161,9 +163,13 @@ static int _xcb_open(char *host, char *protocol, const int display)
|
||||
}
|
||||
|
||||
/* display specifies Unix socket */
|
||||
snprintf(file, sizeof(file), "%s%d", base, display);
|
||||
filelen = snprintf(file, sizeof(file), "%s%d", base, display);
|
||||
if(filelen < 0)
|
||||
return -1;
|
||||
/* snprintf may truncate the file */
|
||||
filelen = MIN(filelen, sizeof(file) - 1);
|
||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||
fd = _xcb_open_abstract(protocol, file);
|
||||
fd = _xcb_open_abstract(protocol, file, filelen);
|
||||
if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
|
||||
return fd;
|
||||
|
||||
@ -188,8 +194,9 @@ static int _xcb_open_decnet(const char *host, const char *protocol, const unsign
|
||||
addr.sdn_add.a_len = nodeaddr->n_length;
|
||||
memcpy(addr.sdn_add.a_addr, nodeaddr->n_addr, addr.sdn_add.a_len);
|
||||
|
||||
sprintf((char *)addr.sdn_objname, "X$X%d", port);
|
||||
addr.sdn_objnamel = strlen((char *)addr.sdn_objname);
|
||||
addr.sdn_objnamel = sprintf((char *)addr.sdn_objname, "X$X%d", port);
|
||||
if(addr.sdn_objnamel < 0)
|
||||
return -1;
|
||||
addr.sdn_objnum = 0;
|
||||
|
||||
fd = socket(PF_DECnet, SOCK_STREAM, 0);
|
||||
@ -197,8 +204,9 @@ static int _xcb_open_decnet(const char *host, const char *protocol, const unsign
|
||||
return -1;
|
||||
|
||||
memset(&accessdata, 0, sizeof(accessdata));
|
||||
sprintf((char*)accessdata.acc_acc, "%d", getuid());
|
||||
accessdata.acc_accl = strlen((char *)accessdata.acc_acc);
|
||||
accessdata.acc_accl = sprintf((char*)accessdata.acc_acc, "%d", getuid());
|
||||
if(accessdata.acc_accl < 0)
|
||||
return -1;
|
||||
setsockopt(fd, DNPROTO_NSP, SO_CONACCESS, &accessdata, sizeof(accessdata));
|
||||
|
||||
if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
|
||||
@ -250,6 +258,9 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port)
|
||||
{
|
||||
fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
|
||||
if(fd >= 0) {
|
||||
int on = 1;
|
||||
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
|
||||
|
||||
if (connect(fd, addr->ai_addr, addr->ai_addrlen) >= 0)
|
||||
break;
|
||||
close(fd);
|
||||
@ -284,7 +295,7 @@ static int _xcb_open_unix(char *protocol, const char *file)
|
||||
}
|
||||
|
||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||
static int _xcb_open_abstract(char *protocol, const char *file)
|
||||
static int _xcb_open_abstract(char *protocol, const char *file, size_t filelen)
|
||||
{
|
||||
int fd;
|
||||
struct sockaddr_un addr = {0};
|
||||
@ -295,9 +306,9 @@ static int _xcb_open_abstract(char *protocol, const char *file)
|
||||
|
||||
strcpy(addr.sun_path + 1, file);
|
||||
addr.sun_family = AF_UNIX;
|
||||
namelen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(file);
|
||||
namelen = offsetof(struct sockaddr_un, sun_path) + 1 + filelen;
|
||||
#ifdef HAVE_SOCKADDR_SUN_LEN
|
||||
addr.sun_len = 1 + strlen(file);
|
||||
addr.sun_len = 1 + filelen;
|
||||
#endif
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1)
|
||||
@ -312,39 +323,7 @@ static int _xcb_open_abstract(char *protocol, const char *file)
|
||||
|
||||
xcb_connection_t *xcb_connect(const char *displayname, int *screenp)
|
||||
{
|
||||
int fd, display = 0;
|
||||
char *host;
|
||||
char *protocol;
|
||||
xcb_connection_t *c;
|
||||
xcb_auth_info_t auth;
|
||||
|
||||
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
|
||||
|
||||
#ifdef HAVE_LAUNCHD
|
||||
if(!displayname)
|
||||
displayname = getenv("DISPLAY");
|
||||
if(displayname && strlen(displayname)>11 && !strncmp(displayname, "/tmp/launch", 11))
|
||||
fd = _xcb_open_unix(NULL, displayname);
|
||||
else
|
||||
#endif
|
||||
if(!parsed)
|
||||
return (xcb_connection_t *) &error_connection;
|
||||
else
|
||||
fd = _xcb_open(host, protocol, display);
|
||||
free(host);
|
||||
|
||||
if(fd == -1)
|
||||
return (xcb_connection_t *) &error_connection;
|
||||
|
||||
if(_xcb_get_auth_info(fd, &auth, display))
|
||||
{
|
||||
c = xcb_connect_to_fd(fd, &auth);
|
||||
free(auth.name);
|
||||
free(auth.data);
|
||||
}
|
||||
else
|
||||
c = xcb_connect_to_fd(fd, 0);
|
||||
return c;
|
||||
return xcb_connect_to_display_with_auth_info(displayname, NULL, screenp);
|
||||
}
|
||||
|
||||
xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname, xcb_auth_info_t *auth, int *screenp)
|
||||
@ -352,6 +331,8 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
|
||||
int fd, display = 0;
|
||||
char *host;
|
||||
char *protocol;
|
||||
xcb_auth_info_t ourauth;
|
||||
xcb_connection_t *c;
|
||||
|
||||
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
|
||||
|
||||
@ -371,5 +352,17 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
|
||||
if(fd == -1)
|
||||
return (xcb_connection_t *) &error_connection;
|
||||
|
||||
if(auth)
|
||||
return xcb_connect_to_fd(fd, auth);
|
||||
|
||||
if(_xcb_get_auth_info(fd, &ourauth, display))
|
||||
{
|
||||
c = xcb_connect_to_fd(fd, &ourauth);
|
||||
free(ourauth.name);
|
||||
free(ourauth.data);
|
||||
}
|
||||
else
|
||||
c = xcb_connect_to_fd(fd, 0);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
32
dist/libxcb/src/xcb_xid.c
vendored
32
dist/libxcb/src/xcb_xid.c
vendored
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
|
||||
/* Copyright (C) 2001-2008 Bart Massey and Jamey Sharp.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
/* XID allocators. */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "xcb.h"
|
||||
#include "xcbext.h"
|
||||
@ -39,21 +40,40 @@ uint32_t xcb_generate_id(xcb_connection_t *c)
|
||||
if(c->has_error)
|
||||
return -1;
|
||||
pthread_mutex_lock(&c->xid.lock);
|
||||
if(c->xid.last == c->xid.max)
|
||||
if(c->xid.last >= c->xid.max - c->xid.inc + 1)
|
||||
{
|
||||
xcb_xc_misc_get_xid_range_reply_t *range;
|
||||
range = xcb_xc_misc_get_xid_range_reply(c, xcb_xc_misc_get_xid_range(c), 0);
|
||||
if(!range)
|
||||
assert(c->xid.last == c->xid.max);
|
||||
if (c->xid.last == 0) {
|
||||
/* finish setting up initial range */
|
||||
c->xid.max = c->setup->resource_id_mask;
|
||||
} else {
|
||||
/* check for extension */
|
||||
const xcb_query_extension_reply_t *xc_misc_reply =
|
||||
xcb_get_extension_data(c, &xcb_xc_misc_id);
|
||||
if (!xc_misc_reply) {
|
||||
pthread_mutex_unlock(&c->xid.lock);
|
||||
return -1;
|
||||
}
|
||||
/* get new range */
|
||||
range = xcb_xc_misc_get_xid_range_reply(c,
|
||||
xcb_xc_misc_get_xid_range(c), 0);
|
||||
/* XXX The latter disjunct is what the server returns
|
||||
when it is out of XIDs. Sweet. */
|
||||
if(!range || (range->start_id == 0 && range->count == 1))
|
||||
{
|
||||
pthread_mutex_unlock(&c->xid.lock);
|
||||
return -1;
|
||||
}
|
||||
assert(range->count > 0 && range->start_id > 0);
|
||||
c->xid.last = range->start_id;
|
||||
c->xid.max = range->start_id + (range->count - 1) * c->xid.inc;
|
||||
free(range);
|
||||
}
|
||||
ret = c->xid.last | c->xid.base;
|
||||
} else {
|
||||
c->xid.last += c->xid.inc;
|
||||
}
|
||||
ret = c->xid.last | c->xid.base;
|
||||
pthread_mutex_unlock(&c->xid.lock);
|
||||
return ret;
|
||||
}
|
||||
@ -65,8 +85,8 @@ int _xcb_xid_init(xcb_connection_t *c)
|
||||
if(pthread_mutex_init(&c->xid.lock, 0))
|
||||
return 0;
|
||||
c->xid.last = 0;
|
||||
c->xid.max = 0;
|
||||
c->xid.base = c->setup->resource_id_base;
|
||||
c->xid.max = c->setup->resource_id_mask;
|
||||
c->xid.inc = c->setup->resource_id_mask & -(c->setup->resource_id_mask);
|
||||
return 1;
|
||||
}
|
||||
|
4
dist/libxcb/src/xcbint.h
vendored
4
dist/libxcb/src/xcbint.h
vendored
@ -60,6 +60,10 @@ enum lazy_reply_tag
|
||||
#define offsetof(type,member) ((size_t) &((type *)0)->member)
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#define container_of(pointer,type,member) ((type *)(((char *)(pointer)) - offsetof(type, member)))
|
||||
|
||||
/* xcb_list.c */
|
||||
|
1
dist/libxcb/xcb.pc.in
vendored
1
dist/libxcb/xcb.pc.in
vendored
@ -2,6 +2,7 @@ prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
xcbproto_version=@XCBPROTO_VERSION@
|
||||
|
||||
Name: XCB
|
||||
Description: X-protocol C Binding
|
||||
|
@ -1,2 +1,2 @@
|
||||
major=0
|
||||
major=1
|
||||
minor=0
|
||||
|
Loading…
Reference in New Issue
Block a user