Compare commits
235 Commits
libxcb-1.9
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
93e6da2e2e | ||
|
6a7661f60a | ||
|
daf2c53976 | ||
|
021e887de9 | ||
|
124690ba63 | ||
|
ebea71700f | ||
|
622152ee42 | ||
|
4574ab269b | ||
|
b78d304531 | ||
|
389f22d1cb | ||
|
86a478032b | ||
|
c268499c30 | ||
|
c671b9b30a | ||
|
3c946010c8 | ||
|
02a7bbed39 | ||
|
18c3f055e7 | ||
|
453115f7ee | ||
|
f11691a098 | ||
|
cc4b93c9cd | ||
|
1519334652 | ||
|
038636786a | ||
|
8935793f1f | ||
|
095255531b | ||
|
ccdef1a8a5 | ||
|
18e109d755 | ||
|
fd04ab24a5 | ||
|
4d1a578dd5 | ||
|
e2a3e80eb8 | ||
|
3333d5bde8 | ||
|
973b510e95 | ||
|
cb8c70f5a6 | ||
|
33f3dbe369 | ||
|
c9513aac2d | ||
|
06e1ef43bb | ||
|
d53ad60d77 | ||
|
e2ee5aabe9 | ||
|
9dcb081708 | ||
|
7d798d3ccb | ||
|
7071b4a13c | ||
|
ee60239b73 | ||
|
3123dfe723 | ||
|
816407655f | ||
|
c2c4a2cd19 | ||
|
ddafdba11f | ||
|
43fbf03e54 | ||
|
233d7b7f1f | ||
|
dc28118747 | ||
|
26396bf156 | ||
|
a503167f75 | ||
|
3c76c0579f | ||
|
bdc3f21a52 | ||
|
068af21cb3 | ||
|
4d678b162b | ||
|
21414e7c44 | ||
|
4b0d9d3868 | ||
|
cd0fba98a2 | ||
|
2ef8655987 | ||
|
4cbcac4eca | ||
|
f01f3c378e | ||
|
704e0a91b1 | ||
|
4b40b44cb6 | ||
|
78c492deaa | ||
|
8f7e4c4e9f | ||
|
f9f4b00aad | ||
|
59e271e15b | ||
|
21324989b7 | ||
|
656c08c542 | ||
|
be1745c8eb | ||
|
58f37377c8 | ||
|
7bac366953 | ||
|
02ff3eadf4 | ||
|
542befe40a | ||
|
8287ebd7b7 | ||
|
bbda345a71 | ||
|
7e0f166579 | ||
|
a3e9821bec | ||
|
c7aa4e682f | ||
|
d10194a321 | ||
|
fad81b6342 | ||
|
f830eb93c9 | ||
|
ee9dfc9a76 | ||
|
0c2c5d50f8 | ||
|
9bce1f72e3 | ||
|
65b298c7ca | ||
|
32a9084546 | ||
|
8740a288ca | ||
|
d34785a34f | ||
|
b11fca06f7 | ||
|
095353ff1a | ||
|
b3516102b4 | ||
|
c03388ff9e | ||
|
7758257567 | ||
|
32a2189183 | ||
|
6e0378ebbf | ||
|
4033d39d4d | ||
|
b15c96f950 | ||
|
c5d923d8ff | ||
|
5b40681c88 | ||
|
f85661c3bc | ||
|
8584c0e095 | ||
|
658fb4a5f0 | ||
|
b15aa6bd4e | ||
|
cc04cfb41b | ||
|
25f9e7e45a | ||
|
bbdf1d133f | ||
|
ff6cb3913b | ||
|
cb621341a6 | ||
|
c49aa98594 | ||
|
a90be9955d | ||
|
f9f925107e | ||
|
17f9bda6c2 | ||
|
c65005e9d0 | ||
|
6872e92582 | ||
|
8bf8b62316 | ||
|
ec435aebd6 | ||
|
89498d1d45 | ||
|
2871d4b1b8 | ||
|
30976e5255 | ||
|
0ab52cbcc6 | ||
|
80341d5df3 | ||
|
86ea6645d9 | ||
|
70d32ce7d8 | ||
|
12d23b934f | ||
|
1b37d6ad3a | ||
|
e3ec1f7463 | ||
|
5353c0216e | ||
|
c6f3fb2529 | ||
|
912cd97a6d | ||
|
422458b663 | ||
|
b1e4a3bbd8 | ||
|
6234225b4b | ||
|
18ff453edd | ||
|
d905b88618 | ||
|
17f6e04493 | ||
|
51a0d57acc | ||
|
4a915c0dba | ||
|
fda1fb4ed4 | ||
|
265d38882c | ||
|
bbca7b82f8 | ||
|
fdb291b414 | ||
|
a7c75be5b1 | ||
|
277ea629de | ||
|
382d306d6c | ||
|
d74d066949 | ||
|
b0e6c2de09 | ||
|
c4e40f646b | ||
|
355d4d6ab9 | ||
|
966fba6ba4 | ||
|
a5e90ae6a1 | ||
|
529e3bfc20 | ||
|
74f552c1b3 | ||
|
23f57ac8bf | ||
|
7f07b57be5 | ||
|
d1e8ec96fc | ||
|
c5c6cfa4d2 | ||
|
70ea5da64b | ||
|
7e6af51b4e | ||
|
8221d249b7 | ||
|
e3c728ee3d | ||
|
cae2e39856 | ||
|
bfbf83b1d8 | ||
|
285d566a5c | ||
|
285838cfe4 | ||
|
49a61c8b45 | ||
|
125135452a | ||
|
bc5a104754 | ||
|
72e45969ff | ||
|
d978a4f69b | ||
|
29e419c584 | ||
|
be0fe56c3b | ||
|
e2813e1cde | ||
|
32de4c4213 | ||
|
1f6cd9f1fc | ||
|
cb686b5767 | ||
|
2fb14e5883 | ||
|
4dcbfd77b7 | ||
|
d84dd752ef | ||
|
4ffa6f83b9 | ||
|
d7eb0bdf3b | ||
|
e4061b8f00 | ||
|
3cdd524cad | ||
|
c056adcd92 | ||
|
412928f113 | ||
|
9ba6aa759e | ||
|
942eabaae3 | ||
|
517cb0e888 | ||
|
0a17b61a89 | ||
|
414b1037c5 | ||
|
c4f2c70bc3 | ||
|
e7263931af | ||
|
3b72a2c9d1 | ||
|
010872f611 | ||
|
f653464554 | ||
|
9c2a6dc20c | ||
|
ea4406a8e0 | ||
|
a1299eb2a2 | ||
|
b30b11ac49 | ||
|
ce5395eb46 | ||
|
18f0afab3f | ||
|
5d1dbb468b | ||
|
c7c5b710f2 | ||
|
e8663a9358 | ||
|
af8067cbf4 | ||
|
83f28ef865 | ||
|
cca6074090 | ||
|
7a9373078e | ||
|
93d733e85d | ||
|
79019541e7 | ||
|
7983bf0fbd | ||
|
7b53fb0f9b | ||
|
98c227a222 | ||
|
d04a4a03a9 | ||
|
f4d5b84800 | ||
|
e4e0c6eec8 | ||
|
f1405d9fe4 | ||
|
ac47e0ecdb | ||
|
c52f2891b4 | ||
|
a8d11c36ed | ||
|
cbe54c97b3 | ||
|
6746ab1549 | ||
|
b6d8c8fe61 | ||
|
e3b34ad346 | ||
|
50fb3a6312 | ||
|
dd01db570c | ||
|
0289348f2c | ||
|
b9efd2a09a | ||
|
5648ddd2b9 | ||
|
cb51f271b2 | ||
|
bc6a4f557f | ||
|
45619dc71e | ||
|
a1e67b141a | ||
|
8b6bb1a719 | ||
|
9ae84ad187 | ||
|
1b33867fa9 | ||
|
e602b653c1 |
|
@ -0,0 +1,3 @@
|
|||
begin-language: "Autoconf-without-aclocal-m4"
|
||||
args: --cache=build-aux
|
||||
end-language: "Autoconf-without-aclocal-m4"
|
|
@ -1,30 +1,28 @@
|
|||
aclocal.m4
|
||||
autom4te.cache
|
||||
compile
|
||||
depcomp
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
configure.lineno
|
||||
.deps
|
||||
.dirstamp
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
||||
*.loT
|
||||
*.la
|
||||
Makefile
|
||||
Makefile.in
|
||||
stamp-h1
|
||||
*.o
|
||||
*.pc
|
||||
*.tar.bz2
|
||||
*.tar.gz
|
||||
.deps
|
||||
.dirstamp
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
build-aux
|
||||
config.h*
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
configure.lineno
|
||||
libtool
|
||||
m4/l*.m4
|
||||
mkinstalldirs
|
||||
stamp-h1
|
||||
ChangeLog
|
||||
INSTALL
|
||||
check-pc-requires.log
|
||||
check-pc-requires.trs
|
||||
test-suite.log
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
|
||||
#
|
||||
# This CI uses the freedesktop.org ci-templates.
|
||||
# Please see the ci-templates documentation for details:
|
||||
# https://freedesktop.pages.freedesktop.org/ci-templates/
|
||||
|
||||
.templates_sha: &template_sha b791bd48996e3ced9ca13f1c5ee82be8540b8adb # see https://docs.gitlab.com/ee/ci/yaml/#includefile
|
||||
|
||||
|
||||
include:
|
||||
# Arch container builder template
|
||||
- project: 'freedesktop/ci-templates'
|
||||
ref: *template_sha
|
||||
file: '/templates/arch.yml'
|
||||
- project: 'freedesktop/ci-templates'
|
||||
ref: *template_sha
|
||||
file: '/templates/ci-fairy.yml'
|
||||
- template: Security/SAST.gitlab-ci.yml
|
||||
|
||||
|
||||
stages:
|
||||
- prep # prep work like rebuilding the container images if there is a change
|
||||
- install xcbproto
|
||||
- build # for actually building and testing things in a container
|
||||
- test
|
||||
- deploy
|
||||
|
||||
|
||||
variables:
|
||||
FDO_UPSTREAM_REPO: 'xorg/lib/libxcb'
|
||||
# The tag should be updated each time the list of packages is updated.
|
||||
# Changing a tag forces the associated image to be rebuilt.
|
||||
# Note: the tag has no meaning, we use a date format purely for readability
|
||||
FDO_DISTRIBUTION_TAG: '2023-08-21.0'
|
||||
FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake libtool make xorg-util-macros python doxygen graphviz check libxslt libxau libxdmcp'
|
||||
|
||||
|
||||
#
|
||||
# Verify that commit messages are as expected
|
||||
#
|
||||
check-commits:
|
||||
extends:
|
||||
- .fdo.ci-fairy
|
||||
stage: prep
|
||||
script:
|
||||
- ci-fairy check-commits --junit-xml=results.xml
|
||||
except:
|
||||
- master@xorg/lib/libxcb
|
||||
variables:
|
||||
GIT_DEPTH: 100
|
||||
artifacts:
|
||||
reports:
|
||||
junit: results.xml
|
||||
|
||||
#
|
||||
# Verify that the merge request has the allow-collaboration checkbox ticked
|
||||
#
|
||||
check-merge-request:
|
||||
extends:
|
||||
- .fdo.ci-fairy
|
||||
stage: deploy
|
||||
script:
|
||||
- ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
|
||||
artifacts:
|
||||
when: on_failure
|
||||
reports:
|
||||
junit: results.xml
|
||||
allow_failure: true
|
||||
|
||||
|
||||
#
|
||||
# Build a container with the given tag and the packages pre-installed.
|
||||
# This only happens if/when the tag changes, otherwise the existing image is
|
||||
# re-used.
|
||||
#
|
||||
container-prep:
|
||||
extends:
|
||||
- .fdo.container-build@arch
|
||||
stage: prep
|
||||
variables:
|
||||
GIT_STRATEGY: none
|
||||
|
||||
#
|
||||
# Build latest xcbproto from git, instead of relying on the container
|
||||
# to package a new enough version.
|
||||
#
|
||||
xcbproto-build:
|
||||
extends:
|
||||
- .fdo.distribution-image@arch
|
||||
stage: install xcbproto
|
||||
script:
|
||||
- export INSTDIR="$PWD/_inst"
|
||||
- git clone --depth=1 https://gitlab.freedesktop.org/xorg/proto/xcbproto
|
||||
- pushd xcbproto > /dev/null
|
||||
- mkdir _builddir
|
||||
- pushd _builddir > /dev/null
|
||||
- ../autogen.sh --disable-silent-rules --prefix="$INSTDIR"
|
||||
- make -j${FDO_CI_CONCURRENT:-4} install
|
||||
- popd > /dev/null
|
||||
- popd > /dev/null
|
||||
variables:
|
||||
artifacts:
|
||||
paths:
|
||||
- _inst
|
||||
|
||||
#
|
||||
# The default build, runs on the image built above.
|
||||
#
|
||||
build:
|
||||
stage: build
|
||||
extends:
|
||||
- .fdo.distribution-image@arch
|
||||
script:
|
||||
- export INSTDIR="$PWD/_inst"
|
||||
- export PKG_CONFIG_PATH=$(find $INSTDIR/ -name '*.pc' -printf "%h:")
|
||||
- autoreconf -ivf
|
||||
- mkdir _builddir
|
||||
- pushd _builddir > /dev/null
|
||||
- ../configure --disable-silent-rules --enable-devel-docs --with-doxygen
|
||||
- make
|
||||
- make check
|
||||
- make distcheck
|
||||
- popd > /dev/null
|
229
INSTALL
229
INSTALL
|
@ -1,229 +0,0 @@
|
|||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
37
Makefile.am
37
Makefile.am
|
@ -1,4 +1,6 @@
|
|||
SUBDIRS=src tests doc
|
||||
ACLOCAL_AMFLAGS=-I m4
|
||||
|
||||
SUBDIRS=src tests doc man
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
|
@ -10,15 +12,24 @@ endif
|
|||
if BUILD_DAMAGE
|
||||
pkgconfig_DATA += xcb-damage.pc
|
||||
endif
|
||||
if BUILD_DBE
|
||||
pkgconfig_DATA += xcb-dbe.pc
|
||||
endif
|
||||
if BUILD_DPMS
|
||||
pkgconfig_DATA += xcb-dpms.pc
|
||||
endif
|
||||
if BUILD_DRI2
|
||||
pkgconfig_DATA += xcb-dri2.pc
|
||||
endif
|
||||
if BUILD_DRI3
|
||||
pkgconfig_DATA += xcb-dri3.pc
|
||||
endif
|
||||
if BUILD_GLX
|
||||
pkgconfig_DATA += xcb-glx.pc
|
||||
endif
|
||||
if BUILD_PRESENT
|
||||
pkgconfig_DATA += xcb-present.pc
|
||||
endif
|
||||
if BUILD_RANDR
|
||||
pkgconfig_DATA += xcb-randr.pc
|
||||
endif
|
||||
|
@ -76,10 +87,32 @@ endif
|
|||
if BUILD_XVMC
|
||||
pkgconfig_DATA += xcb-xvmc.pc
|
||||
endif
|
||||
if BUILD_GE
|
||||
pkgconfig_DATA += xcb-ge.pc
|
||||
endif
|
||||
|
||||
|
||||
AM_TESTS_ENVIRONMENT = \
|
||||
AM_SRCDIR=${srcdir}
|
||||
|
||||
TESTS=check-pc-requires
|
||||
|
||||
EXTRA_DIST = \
|
||||
tools/README \
|
||||
tools/api_conv.pl \
|
||||
tools/constants \
|
||||
autogen.sh
|
||||
autogen.sh \
|
||||
README.md \
|
||||
$(TESTS)
|
||||
|
||||
MAINTAINERCLEANFILES = ChangeLog INSTALL
|
||||
|
||||
.PHONY: ChangeLog INSTALL
|
||||
|
||||
INSTALL:
|
||||
$(INSTALL_CMD)
|
||||
|
||||
ChangeLog:
|
||||
$(CHANGELOG_CMD)
|
||||
|
||||
dist-hook: ChangeLog INSTALL
|
||||
|
|
109
NEWS
109
NEWS
|
@ -1,6 +1,113 @@
|
|||
Release 1.14 (2020-02-22)
|
||||
=========================
|
||||
* Add xcb_total_read() and xcb_total_written() API
|
||||
* Support check >= 0.13 API (for make check)
|
||||
* Bug fix to handle EINTR from recvmsg
|
||||
* Only require pthread-stubs on non-Linux platforms
|
||||
|
||||
Release 1.13.1 (2018-09-27)
|
||||
===========================
|
||||
* Don't flag extra reply in xcb_take_socket
|
||||
|
||||
Release 1.13 (2018-02-28)
|
||||
=========================
|
||||
* Add support for variable-sized lists of FDs
|
||||
* Poll for events when blocking waiting for special events
|
||||
* xinput: Enable XInput extension by default
|
||||
* ge: Add explicit support for GenericEvent extension
|
||||
* Fix documentation warnings from clang
|
||||
* Cosmetic cleanups
|
||||
|
||||
Release 1.12 (2016-05-18)
|
||||
=========================
|
||||
* configure: Various fixes for dri3 and FD passing support
|
||||
* configure: Don't report all the warning CFLAGS
|
||||
* configure: Disable Xevie and Xprint by default
|
||||
* Add support for various new constructs in the XML schema
|
||||
* Make some functions also accept connections in an error state
|
||||
* Never return NULL from xcb_get_setup()
|
||||
* Use Requires.private in .pc files to avoid overlinking
|
||||
* Fix align-pads for switches which start at unaligned positions
|
||||
* Use anonymous structs for some nested structs
|
||||
* Also generate accessors for variable-sized events and requests
|
||||
* Improved python3 compatibility
|
||||
* Generate C99 initializers instead of comments
|
||||
* Various simplifications to the python code
|
||||
* Fix line breaks in xcb-requests manual page
|
||||
* Always close FDs in xcb_send_fd()
|
||||
* Fix thread-safety issues with FD passing
|
||||
* Add xcb_send_request_with_fds() and xcb_send_request_with_fds64()
|
||||
* Fix endless loop with too many outstanding FDs to send
|
||||
* Link with winsock library on MinGW
|
||||
* Disable some unfinished API for some server-side code by default
|
||||
* Use align-offsets computed by xcb-proto instead of low bits of pointers
|
||||
* Fix iterator interaction with align padding
|
||||
* Stop serializing padding by default
|
||||
* Increase unix socket send buffer to at least 64KiB
|
||||
|
||||
Release 1.11.1 (2015-09-06)
|
||||
===========================
|
||||
* Expose 64-bit sequence numbers for XLib
|
||||
* Fix some hangs related to xcb_wait_for_special_event()
|
||||
|
||||
Release 1.11 (2014-08-01)
|
||||
=========================
|
||||
* Force structures with 64-bit fields to be packed
|
||||
* Add support for <pad align="n">
|
||||
* Use X.org's build machinery from xorg-macros
|
||||
* Fix leak with xcb_disconnect() and connections in an error state
|
||||
* Make xcb_disconnect(NULL) safe
|
||||
* Use less #include statements in generated code
|
||||
* Automatically validate the Requires lines in our .pc.in files
|
||||
* Fix a race that resulted in a failed assertion
|
||||
* Improve launchd secure socket support
|
||||
* Improve API documentation
|
||||
* Remove trailing whitespaces
|
||||
* c_client.py: prefix all monkey-patched fields with c_
|
||||
* c_client.py: make the man page output deterministic
|
||||
* c_client.py: remove useless generated comments
|
||||
* xcb.h: add 'struct' before xcb_setup_t, xcb_query_extension_reply_t
|
||||
|
||||
Release 1.10 (2013-12-22)
|
||||
=========================
|
||||
* Bump libxcb-xkb SONAME due to ABI break introduced in 1.9.2
|
||||
* Enable libxcb-xkb by default
|
||||
* Bump libxcb-sync SONAME
|
||||
* c_client.py: Fix _sizeof() functions
|
||||
* c_client.py: Do not create pointers in unions
|
||||
* c_client.py: Always initialize xcb_align_to
|
||||
* Re-introduce xcb_ge_event_t (deprecated, xcb_ge_generic_event_t should be
|
||||
used instead)
|
||||
* Fix alignment issues in FD passing code
|
||||
* Fix poll() if POLLIN == ROLLRDNORM|POLLRDBAND
|
||||
* Use /usr/spool/sockets/X11/ on HP-UX for UNIX sockets
|
||||
* Make xsltproc optional
|
||||
|
||||
Release 1.9.3 (2013-11-07)
|
||||
==========================
|
||||
* Check if we need to define _XOPEN_SOURCE for struct msghdr.msg_control
|
||||
* Add configure option to enable or disable fd passing with sendmsg
|
||||
* Switch to using the CMSG_* macros for FD passing
|
||||
* Initialize automake earlier (bugfix for #66413)
|
||||
|
||||
Release 1.9.2 (2013-11-07)
|
||||
==========================
|
||||
* Add Present extension
|
||||
* Add DRI3 library
|
||||
* Add event queue splitting
|
||||
* Add support for receiving fds in replies
|
||||
* Add xcb_send_fd API
|
||||
* Remove xcb_ge_event_t from xcb.h
|
||||
* c_client.py: Inject full_sequence into GE events
|
||||
* c_client.py: Handle multiple expr. in a bitcase
|
||||
|
||||
Release 1.9.1 (2013-05-30)
|
||||
==========================
|
||||
* Fix python code to work with python-3
|
||||
* Security fix for integer overflow in read_packet() [CVE-2013-2064]
|
||||
|
||||
Release 1.9 (2012-10-05)
|
||||
========================
|
||||
|
||||
* Always include "config.h" at the start of all C source files.
|
||||
* Add AC_USE_SYSTEM_EXTENSIONS to allow use of more system functionality
|
||||
* Return connection failure if display string specifies non-existent screen
|
||||
|
|
|
@ -2,7 +2,7 @@ About libxcb
|
|||
============
|
||||
|
||||
libxcb provides an interface to the X Window System protocol, which
|
||||
replaces the current Xlib interface. It has several advantages over
|
||||
replaces the traditional Xlib interface. It has several advantages over
|
||||
Xlib, including:
|
||||
- size: small, simple library, and lower memory footprint
|
||||
- latency hiding: batch several requests and wait for the replies later
|
||||
|
@ -10,27 +10,32 @@ Xlib, including:
|
|||
- proven thread support: transparently access XCB from multiple threads
|
||||
- easy extension implementation: interfaces auto-generated from XML-XCB
|
||||
|
||||
Xlib can also use XCB as a transport layer, allowing software to make
|
||||
Xlib also uses XCB as a transport layer, allowing software to make
|
||||
requests and receive responses with both, which eases porting to XCB.
|
||||
However, client programs, libraries, and toolkits will gain the most
|
||||
benefit from a native XCB port.
|
||||
|
||||
More information about xcb is available from our website:
|
||||
|
||||
Please report any issues you find to the freedesktop.org bug tracker,
|
||||
at:
|
||||
https://xcb.freedesktop.org/
|
||||
|
||||
<https://bugs.freedesktop.org/enter_bug.cgi?product=XCB>
|
||||
Please report any issues you find to the freedesktop.org bug tracker at:
|
||||
|
||||
https://gitlab.freedesktop.org/xorg/lib/libxcb/issues
|
||||
|
||||
Discussion about XCB occurs on the XCB mailing list:
|
||||
|
||||
<mailto:xcb at lists.freedesktop.org>
|
||||
<http://lists.freedesktop.org/mailman/listinfo/xcb>
|
||||
https://lists.freedesktop.org/mailman/listinfo/xcb
|
||||
|
||||
You can obtain the latest development versions of XCB using GIT.
|
||||
For anonymous checkouts, use:
|
||||
You can obtain the latest development versions of XCB using GIT from
|
||||
the libxcb code repository at:
|
||||
|
||||
git clone git://anongit.freedesktop.org/git/xcb/libxcb
|
||||
https://gitlab.freedesktop.org/xorg/lib/libxcb
|
||||
|
||||
For developers, use:
|
||||
For anonymous checkouts, use:
|
||||
|
||||
git clone git+ssh://git.freedesktop.org/git/xcb/libxcb
|
||||
git clone https://gitlab.freedesktop.org/xorg/lib/libxcb.git
|
||||
|
||||
For developers, use:
|
||||
|
||||
git clone git@gitlab.freedesktop.org:xorg/lib/libxcb.git
|
142
acinclude.m4
142
acinclude.m4
|
@ -1,142 +0,0 @@
|
|||
dnl Detection and configuration of the visibility feature of gcc
|
||||
dnl Vincent Torri 2006-02-11
|
||||
dnl
|
||||
dnl XCB_CHECK_VISIBILITY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl Check the visibility feature of gcc
|
||||
dnl
|
||||
AC_DEFUN([XCB_CHECK_VISIBILITY],
|
||||
[
|
||||
AC_MSG_CHECKING([whether ${CC} supports symbol visibility])
|
||||
|
||||
save_CFLAGS=${CFLAGS}
|
||||
CFLAGS="$CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#pragma GCC visibility push(hidden)
|
||||
extern void f(int);
|
||||
#pragma GCC visibility pop
|
||||
]],
|
||||
[[]]
|
||||
)],
|
||||
[AC_DEFINE(
|
||||
GCC_HAS_VISIBILITY,
|
||||
[],
|
||||
[Defined if GCC supports the visibility feature])
|
||||
m4_if([$1], [], [:], [$1])
|
||||
AC_MSG_RESULT(yes)],
|
||||
[m4_if([$2], [], [:], [$2])
|
||||
AC_MSG_RESULT(no)])
|
||||
|
||||
CFLAGS=${save_CFLAGS}
|
||||
])
|
||||
|
||||
dnl Configure script for doxygen
|
||||
dnl Vincent Torri 2006-05-11
|
||||
dnl
|
||||
dnl XCB_CHECK_DOXYGEN([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl Test for the doxygen program, and define BUILD_DOCS and DOXYGEN.
|
||||
dnl
|
||||
AC_DEFUN([XCB_CHECK_DOXYGEN],
|
||||
[
|
||||
DOXYGEN="doxygen"
|
||||
|
||||
dnl
|
||||
dnl Disable the build of the documentation
|
||||
dnl
|
||||
AC_ARG_ENABLE(
|
||||
[build_docs],
|
||||
AC_HELP_STRING(
|
||||
[--disable-build-docs],
|
||||
[Disable the build of the documentation]),
|
||||
[if test x"$enableval" != x"yes" ; then
|
||||
enable_build_docs="no"
|
||||
else
|
||||
enable_build_docs="yes"
|
||||
fi],
|
||||
[enable_build_docs="yes"])
|
||||
|
||||
if test "$enable_build_docs" = "no" ; then
|
||||
BUILD_DOCS=no
|
||||
else
|
||||
dnl
|
||||
dnl Get the prefix where doxygen is installed.
|
||||
dnl
|
||||
AC_ARG_WITH(
|
||||
[doxygen],
|
||||
AC_HELP_STRING(
|
||||
[--with-doxygen=FILE],
|
||||
[doxygen program to use (eg /usr/bin/doxygen)]),
|
||||
dnl
|
||||
dnl Check the given doxygen program.
|
||||
dnl
|
||||
[DOXYGEN=${withval}
|
||||
AC_CHECK_PROG(
|
||||
[BUILD_DOCS],
|
||||
[${DOXYGEN}],
|
||||
[yes],
|
||||
[no])
|
||||
if test $BUILD_DOCS = no; then
|
||||
echo "WARNING:"
|
||||
echo "The doxygen program you specified:"
|
||||
echo "$DOXYGEN"
|
||||
echo "was not found. Please check the path and make sure "
|
||||
echo "the program exists and is executable."
|
||||
AC_MSG_WARN(
|
||||
[Warning: no doxygen detected. Documentation will not be built])
|
||||
fi],
|
||||
[AC_CHECK_PROG(
|
||||
[BUILD_DOCS],
|
||||
[${DOXYGEN}],
|
||||
[yes],
|
||||
[no])
|
||||
if test ${BUILD_DOCS} = no; then
|
||||
echo "WARNING:"
|
||||
echo "The doxygen program was not found in your execute"
|
||||
echo "You may have doxygen installed somewhere not covered by your path."
|
||||
echo ""
|
||||
echo "If this is the case make sure you have the packages installed, AND"
|
||||
echo "that the doxygen program is in your execute path (see your"
|
||||
echo "shell manual page on setting the \$PATH environment variable), OR"
|
||||
echo "alternatively, specify the program to use with --with-doxygen."
|
||||
AC_MSG_WARN(
|
||||
[Warning: no doxygen detected. Documentation will not be built])
|
||||
fi])
|
||||
AC_PATH_PROG(DOT, dot, no)
|
||||
if test "$DOT" = "no"; then
|
||||
AC_MSG_WARN([Warning: no dot detected. Documentation will not be built])
|
||||
BUILD_DOCS="no"
|
||||
fi
|
||||
fi
|
||||
AC_MSG_CHECKING([whether documentation is built])
|
||||
AC_MSG_RESULT([${BUILD_DOCS}])
|
||||
|
||||
dnl
|
||||
dnl Substitution
|
||||
dnl
|
||||
AC_SUBST([DOXYGEN])
|
||||
|
||||
AM_CONDITIONAL(BUILD_DOCS, test "x$BUILD_DOCS" = "xyes")
|
||||
|
||||
])
|
||||
|
||||
dnl Detection and configuration of the visibility feature of gcc
|
||||
dnl Vincent Torri 2006-02-11
|
||||
dnl
|
||||
dnl XCB_EXTENSION(name, default)
|
||||
dnl set the X extension
|
||||
dnl
|
||||
AC_DEFUN([XCB_EXTENSION],
|
||||
[
|
||||
pushdef([UP], translit([$1], [-a-z], [_A-Z]))dnl
|
||||
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
|
||||
|
||||
AC_ARG_ENABLE(DOWN,
|
||||
[AS_HELP_STRING([--enable-[]DOWN], [Build XCB $1 Extension (default: $2)])],
|
||||
[BUILD_[]UP=$enableval],
|
||||
[BUILD_[]UP=$2])
|
||||
|
||||
AM_CONDITIONAL(BUILD_[]UP, [test "x$BUILD_[]UP" = "xyes"])
|
||||
])
|
||||
|
||||
dnl End of acinclude.m4
|
11
autogen.sh
11
autogen.sh
|
@ -1,14 +1,17 @@
|
|||
#! /bin/sh
|
||||
|
||||
srcdir=`dirname $0`
|
||||
srcdir=`dirname "$0"`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
ORIGDIR=`pwd`
|
||||
cd $srcdir
|
||||
cd "$srcdir"
|
||||
|
||||
autoreconf -v --install || exit 1
|
||||
cd $ORIGDIR || exit $?
|
||||
cd "$ORIGDIR" || exit $?
|
||||
|
||||
git config --local --get format.subjectPrefix >/dev/null 2>&1 ||
|
||||
git config --local format.subjectPrefix "PATCH libxcb"
|
||||
|
||||
if test -z "$NOCONFIGURE"; then
|
||||
$srcdir/configure "$@"
|
||||
exec "$srcdir"/configure "$@"
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
#!/bin/sh
|
||||
|
||||
case "$AM_SRCDIR" in
|
||||
"")
|
||||
AM_SRCDIR="."
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
fix=n
|
||||
status=0
|
||||
case "$1" in
|
||||
"-fix")
|
||||
fix=y
|
||||
;;
|
||||
esac
|
||||
|
||||
for inc in src/*.h; do
|
||||
package=xcb-`basename $inc .h`
|
||||
pcin="$AM_SRCDIR"/$package.pc.in
|
||||
if [ -f $pcin ]; then
|
||||
included=`grep '# *include' $inc |
|
||||
sed -e 's/[^<"]*[<"]//' -e 's/[>"]//' |
|
||||
grep -v 'xcb.h\|xproto.h'`
|
||||
requires=`grep '^Requires.private:' $pcin`
|
||||
missing=""
|
||||
for i in $included; do
|
||||
ibase=`basename $i .h`
|
||||
r="xcb-$ibase"
|
||||
rpcin="$AM_SRCDIR"/$r.pc.in
|
||||
if [ -f $rpcin ]; then
|
||||
m="$r"
|
||||
for has in $requires; do
|
||||
if [ $has = $r ]; then
|
||||
m=""
|
||||
fi
|
||||
done
|
||||
case "$m" in
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
case "$missing" in
|
||||
"")
|
||||
missing=$m
|
||||
;;
|
||||
*)
|
||||
missing="$missing $m"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
case "$missing" in
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
if [ "$fix" = "y" ]; then
|
||||
echo $package adding dependency on $missing
|
||||
sed -i '/^Requires.private:/s/$/ '"$missing"'/' $pcin
|
||||
else
|
||||
echo $package missing $missing
|
||||
status=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
exit $status
|
308
configure.ac
308
configure.ac
|
@ -1,63 +1,77 @@
|
|||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Initialize Autoconf
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([libxcb],
|
||||
1.9,
|
||||
[xcb@lists.freedesktop.org])
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT([libxcb],[1.17.0],
|
||||
[https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues],
|
||||
[libxcb])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([xcb.pc.in])
|
||||
AC_CONFIG_HEADERS([src/config.h])
|
||||
|
||||
# Initialize Automake
|
||||
AM_INIT_AUTOMAKE([foreign dist-xz])
|
||||
AM_PATH_PYTHON([3.0])
|
||||
|
||||
# Set common system defines for POSIX extensions, such as _GNU_SOURCE
|
||||
# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
|
||||
# to avoid autoconf errors.
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
# Initialize Automake
|
||||
AM_INIT_AUTOMAKE([foreign dist-bzip2])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
# Initialize libtool
|
||||
LT_PREREQ([2.2])
|
||||
LT_INIT([win32-dll])
|
||||
|
||||
AM_PATH_PYTHON([2.6])
|
||||
# Require xorg-macros minimum of 1.18 - Initial version
|
||||
m4_ifndef([XORG_MACROS_VERSION],
|
||||
[m4_fatal([must install xorg-macros 1.18 or later before running autoconf/autogen])])
|
||||
XORG_MACROS_VERSION(1.18)
|
||||
XORG_DEFAULT_OPTIONS
|
||||
XORG_ENABLE_DEVEL_DOCS
|
||||
XORG_WITH_DOXYGEN
|
||||
|
||||
PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], [HAVE_CHECK=yes], [HAVE_CHECK=no])
|
||||
AM_CONDITIONAL(HAVE_CHECK, test x$HAVE_CHECK = xyes)
|
||||
|
||||
AC_CONFIG_HEADERS([src/config.h])
|
||||
|
||||
AC_LIBTOOL_WIN32_DLL
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_CC
|
||||
|
||||
AC_PATH_PROG(XSLTPROC, xsltproc, no)
|
||||
if test "$XSLTPROC" = "no"; then
|
||||
AC_MSG_ERROR([XCB requires xsltproc.])
|
||||
# The dot drawing tool is checked by XORG_WITH_DOXYGEN, needed for xcb manual
|
||||
if test x"$HAVE_DOT" = xno; then
|
||||
AC_MSG_WARN([dot not found - doxygen targets will be skipped])
|
||||
fi
|
||||
|
||||
HTML_CHECK_RESULT=false
|
||||
PKG_CHECK_MODULES(CHECK, [check >= 0.9.6], [HAVE_CHECK=yes], [HAVE_CHECK=no])
|
||||
AM_CONDITIONAL(HAVE_CHECK, test x$HAVE_CHECK = xyes)
|
||||
|
||||
XSLTPROC=no
|
||||
HTML_CHECK_RESULT=no
|
||||
if test x"$HAVE_CHECK" = xyes; then
|
||||
if test x"$XSLTPROC" != xno; then
|
||||
HTML_CHECK_RESULT=true
|
||||
fi
|
||||
AC_PATH_PROG(XSLTPROC, xsltproc, no)
|
||||
if test x"$XSLTPROC" != xno; then
|
||||
HTML_CHECK_RESULT=yes
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(HTML_CHECK_RESULT)
|
||||
|
||||
# Checks for pkg-config packages
|
||||
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.7)
|
||||
NEEDED="pthread-stubs xau >= 0.99.2"
|
||||
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.17.0)
|
||||
NEEDED="xau >= 0.99.2"
|
||||
case $host_os in
|
||||
linux*|darwin*|solaris*|dragonfly*|freebsd*|netbsd*) ;;
|
||||
*) NEEDED="$NEEDED pthread-stubs" ;;
|
||||
esac
|
||||
PKG_CHECK_MODULES(NEEDED, $NEEDED)
|
||||
|
||||
have_xdmcp="no"
|
||||
PKG_CHECK_MODULES(XDMCP, xdmcp,
|
||||
AC_CHECK_LIB(Xdmcp, XdmcpWrap,
|
||||
[
|
||||
AC_DEFINE(HASXDMAUTH,1,[Has Wraphelp.c needed for XDM AUTH protocols])
|
||||
NEEDED="$NEEDED xdmcp"
|
||||
have_xdmcp="yes"
|
||||
],
|
||||
[
|
||||
XDMCP_CFLAGS=
|
||||
XDMCP_LIBS=
|
||||
], [$XDMCP_LIBS]),
|
||||
[AC_MSG_RESULT(no)])
|
||||
AC_CHECK_LIB(Xdmcp, XdmcpWrap,
|
||||
[
|
||||
AC_DEFINE(HASXDMAUTH,1,[Has Wraphelp.c needed for XDM AUTH protocols])
|
||||
NEEDED="$NEEDED xdmcp"
|
||||
have_xdmcp="yes"
|
||||
],
|
||||
[
|
||||
XDMCP_CFLAGS=
|
||||
XDMCP_LIBS=
|
||||
], [$XDMCP_LIBS]),
|
||||
[AC_MSG_RESULT(no)])
|
||||
|
||||
AC_SUBST(NEEDED)
|
||||
|
||||
|
@ -77,20 +91,62 @@ XCBPROTO_XCBPYTHONDIR=`$PKG_CONFIG --variable=pythondir xcb-proto`
|
|||
AC_MSG_RESULT($XCBPROTO_XCBPYTHONDIR)
|
||||
AC_SUBST(XCBPROTO_XCBPYTHONDIR)
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_SEARCH_LIBS(getaddrinfo, socket)
|
||||
AC_SEARCH_LIBS(connect, socket)
|
||||
|
||||
# Find support for sending a message from a socket
|
||||
AC_SEARCH_LIBS(sendmsg, socket, [have_sendmsg="yes"], [have_sendmsg="no"])
|
||||
|
||||
# XPG4v2/UNIX95 added msg_control - check to see if we need to define
|
||||
# _XOPEN_SOURCE to get it (such as on Solaris)
|
||||
AC_CHECK_MEMBER([struct msghdr.msg_control], [], [],
|
||||
[
|
||||
AC_INCLUDES_DEFAULT
|
||||
#include <sys/socket.h>
|
||||
])
|
||||
# First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03
|
||||
if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
|
||||
unset ac_cv_member_struct_msghdr_msg_control
|
||||
AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600])
|
||||
AC_CHECK_MEMBER([struct msghdr.msg_control],
|
||||
[AC_DEFINE([_XOPEN_SOURCE], [600],
|
||||
[Defined if needed to expose struct msghdr.msg_control])
|
||||
], [], [
|
||||
#define _XOPEN_SOURCE 600
|
||||
AC_INCLUDES_DEFAULT
|
||||
#include <sys/socket.h>
|
||||
])
|
||||
fi
|
||||
# If that didn't work, fall back to XPG5/UNIX98 with C89
|
||||
if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
|
||||
unset ac_cv_member_struct_msghdr_msg_control
|
||||
AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500])
|
||||
AC_CHECK_MEMBER([struct msghdr.msg_control],
|
||||
[AC_DEFINE([_XOPEN_SOURCE], [500],
|
||||
[Defined if needed to expose struct msghdr.msg_control])
|
||||
], [have_sendmsg="no"], [
|
||||
#define _XOPEN_SOURCE 500
|
||||
AC_INCLUDES_DEFAULT
|
||||
#include <sys/socket.h>
|
||||
])
|
||||
fi
|
||||
|
||||
case x$have_sendmsg in
|
||||
xyes)
|
||||
AC_DEFINE([HAVE_SENDMSG],1,[Define if your platform supports sendmsg])
|
||||
;;
|
||||
esac
|
||||
|
||||
have_win32="no"
|
||||
lt_enable_auto_import=""
|
||||
case $host_os in
|
||||
mingw*)
|
||||
have_win32="yes"
|
||||
lt_enable_auto_import="-Wl,--enable-auto-import"
|
||||
;;
|
||||
have_win32="yes"
|
||||
lt_enable_auto_import="-Wl,--enable-auto-import"
|
||||
;;
|
||||
linux*)
|
||||
AC_DEFINE([HAVE_ABSTRACT_SOCKETS], 1, [Define if your platform supports abstract sockets])
|
||||
;;
|
||||
AC_DEFINE([HAVE_ABSTRACT_SOCKETS], 1, [Define if your platform supports abstract sockets])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(lt_enable_auto_import)
|
||||
|
@ -98,7 +154,7 @@ AM_CONDITIONAL([XCB_HAVE_WIN32], [test "x${have_win32}" = "xyes"])
|
|||
|
||||
dnl define buffer queue size
|
||||
AC_ARG_WITH([queue-size],
|
||||
AC_HELP_STRING([--with-queue-size=SIZE],
|
||||
AS_HELP_STRING([--with-queue-size=SIZE],
|
||||
[Set the XCB buffer queue size (default is 16384)]),
|
||||
[xcb_queue_buffer_size="$withval"],
|
||||
[xcb_queue_buffer_size=16384])
|
||||
|
@ -107,11 +163,11 @@ AC_DEFINE_UNQUOTED(XCB_QUEUE_BUFFER_SIZE, [$xcb_queue_buffer_size],
|
|||
|
||||
dnl check for the sockaddr_un.sun_len member
|
||||
AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
|
||||
[AC_DEFINE(HAVE_SOCKADDR_SUN_LEN,1,[Have the sockaddr_un.sun_len member.])],
|
||||
[],
|
||||
[ #include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
])
|
||||
[AC_DEFINE(HAVE_SOCKADDR_SUN_LEN,1,[Have the sockaddr_un.sun_len member.])],
|
||||
[],
|
||||
[ #include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
])
|
||||
|
||||
dnl check for support for Solaris Trusted Extensions
|
||||
AC_CHECK_HEADERS([tsol/label.h])
|
||||
|
@ -119,99 +175,87 @@ AC_CHECK_FUNCS([is_system_labeled])
|
|||
|
||||
dnl check for IOV_MAX, and fall back to UIO_MAXIOV on BSDish systems
|
||||
AC_CHECK_DECL([IOV_MAX], [],
|
||||
[AC_CHECK_DECL([UIO_MAXIOV], [AC_DEFINE([IOV_MAX], [UIO_MAXIOV])],
|
||||
[AC_DEFINE([IOV_MAX], [16], [Define if not provided by <limits.h>])],
|
||||
[[#include <sys/uio.h>]])],
|
||||
[[#include <limits.h>]])
|
||||
[AC_CHECK_DECL([UIO_MAXIOV], [AC_DEFINE([IOV_MAX], [UIO_MAXIOV])],
|
||||
[AC_DEFINE([IOV_MAX], [16], [Define if not provided by <limits.h>])],
|
||||
[[#include <sys/uio.h>]])],
|
||||
[[#include <limits.h>]])
|
||||
|
||||
xcbincludedir='${includedir}/xcb'
|
||||
AC_SUBST(xcbincludedir)
|
||||
|
||||
if test "x$GCC" = xyes ; then
|
||||
CWARNFLAGS="-Wall -pedantic -Wpointer-arith \
|
||||
-Wstrict-prototypes -Wmissing-declarations -Wnested-externs"
|
||||
else
|
||||
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
|
||||
if test "x$SUNCC" = "xyes"; then
|
||||
CWARNFLAGS="-v"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(CWARNFLAGS)
|
||||
|
||||
XCB_CHECK_VISIBILITY()
|
||||
|
||||
# htmldir is not defined prior to autoconf 2.59c, so on earlier versions
|
||||
# set an equivalent value.
|
||||
AC_PREREQ([2.59c], [], [AC_SUBST([htmldir], [m4_ifset([AC_PACKAGE_TARNAME],
|
||||
['${datadir}/doc/${PACKAGE_TARNAME}'],
|
||||
['${datadir}/doc/${PACKAGE}'])
|
||||
])])
|
||||
|
||||
XCB_CHECK_DOXYGEN()
|
||||
|
||||
AC_CHECK_FUNC(getaddrinfo, [AC_DEFINE(HAVE_GETADDRINFO, 1, [getaddrinfo() function is available])], )
|
||||
|
||||
case $host_os in
|
||||
# darwin through Snow Leopard has poll() but can't be used to poll character devices.
|
||||
darwin@<:@789@:>@*|darwin10*) ;;
|
||||
darwin*)
|
||||
_ac_xorg_macosx_version_min=""
|
||||
if echo $CPPFLAGS $CFLAGS | grep -q mmacosx-version-min ; then
|
||||
_ac_xorg_macosx_version_min=`echo $CPPFLAGS $CFLAGS | sed 's/^.*-mmacosx-version-min=\(@<:@^ @:>@*\).*$/\1/'`
|
||||
else
|
||||
_ac_xorg_macosx_version_min=$MACOSX_DEPLOYMENT_TARGET
|
||||
fi
|
||||
case $_ac_xorg_macosx_version_min in
|
||||
10.@<:@0123456@:>@|10.@<:@0123456@:>@.*) ;;
|
||||
*)
|
||||
AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
|
||||
;;
|
||||
esac
|
||||
unset _ac_xorg_macosx_version_min
|
||||
;;
|
||||
*)
|
||||
AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
|
||||
;;
|
||||
# darwin through Snow Leopard has poll() but can't be used to poll character devices.
|
||||
darwin@<:@789@:>@*|darwin10*) ;;
|
||||
darwin*)
|
||||
_ac_xorg_macosx_version_min=""
|
||||
if echo $CPPFLAGS $CFLAGS | grep -q mmacosx-version-min ; then
|
||||
_ac_xorg_macosx_version_min=`echo $CPPFLAGS $CFLAGS | sed 's/^.*-mmacosx-version-min=\(@<:@^ @:>@*\).*$/\1/'`
|
||||
else
|
||||
_ac_xorg_macosx_version_min=$MACOSX_DEPLOYMENT_TARGET
|
||||
fi
|
||||
case $_ac_xorg_macosx_version_min in
|
||||
10.@<:@0123456@:>@|10.@<:@0123456@:>@.*) ;;
|
||||
*)
|
||||
AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
|
||||
;;
|
||||
esac
|
||||
unset _ac_xorg_macosx_version_min
|
||||
;;
|
||||
*)
|
||||
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")
|
||||
XCB_EXTENSION(DRI2, "yes")
|
||||
XCB_EXTENSION(GLX, "yes")
|
||||
XCB_EXTENSION(RandR, "yes")
|
||||
XCB_EXTENSION(Record, "yes")
|
||||
XCB_EXTENSION(Render, "yes")
|
||||
XCB_EXTENSION(Resource, "yes")
|
||||
XCB_EXTENSION(Screensaver, "yes")
|
||||
XCB_EXTENSION(Shape, "yes")
|
||||
XCB_EXTENSION(Shm, "yes")
|
||||
XCB_EXTENSION(Sync, "yes")
|
||||
XCB_EXTENSION(Xevie, "yes")
|
||||
XCB_EXTENSION(XFixes, "yes")
|
||||
XCB_EXTENSION(XFree86-DRI, "yes")
|
||||
XCB_EXTENSION(Xinerama, "yes")
|
||||
XCB_EXTENSION(XInput, "no")
|
||||
XCB_EXTENSION(XKB, "no")
|
||||
XCB_EXTENSION(Xprint, "yes")
|
||||
XCB_EXTENSION(SELinux, "no")
|
||||
XCB_EXTENSION(XTest, "yes")
|
||||
XCB_EXTENSION(Xv, "yes")
|
||||
XCB_EXTENSION(XvMC, "yes")
|
||||
dnl Link with winsock for socket functions on MinGW
|
||||
case $host_os in
|
||||
*mingw*)
|
||||
AC_CHECK_LIB([ws2_32],[main])
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
|
||||
if test "x$LAUNCHD" = xauto; then
|
||||
unset LAUNCHD
|
||||
AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin])
|
||||
fi
|
||||
XCB_EXTENSION(Composite, yes)
|
||||
XCB_EXTENSION(Damage, yes)
|
||||
XCB_EXTENSION(Dbe, yes)
|
||||
XCB_EXTENSION(DPMS, yes)
|
||||
XCB_EXTENSION(DRI2, yes)
|
||||
XCB_EXTENSION(DRI3, $have_sendmsg)
|
||||
XCB_EXTENSION(GE, no)
|
||||
XCB_EXTENSION(GLX, yes)
|
||||
XCB_EXTENSION(Present, yes)
|
||||
XCB_EXTENSION(RandR, yes)
|
||||
XCB_EXTENSION(Record, yes)
|
||||
XCB_EXTENSION(Render, yes)
|
||||
XCB_EXTENSION(Resource, yes)
|
||||
XCB_EXTENSION(Screensaver, yes)
|
||||
XCB_EXTENSION(Shape, yes)
|
||||
XCB_EXTENSION(Shm, yes)
|
||||
XCB_EXTENSION(Sync, yes)
|
||||
XCB_EXTENSION(Xevie, no)
|
||||
XCB_EXTENSION(XFixes, yes)
|
||||
XCB_EXTENSION(XFree86-DRI, yes)
|
||||
XCB_EXTENSION(Xinerama, yes)
|
||||
XCB_EXTENSION(XInput, yes)
|
||||
XCB_EXTENSION(XKB, yes)
|
||||
XCB_EXTENSION(Xprint, no)
|
||||
XCB_EXTENSION(SELinux, no)
|
||||
XCB_EXTENSION(XTest, yes)
|
||||
XCB_EXTENSION(Xv, yes)
|
||||
XCB_EXTENSION(XvMC, yes)
|
||||
|
||||
if test "x$LAUNCHD" = xyes ; then
|
||||
AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
|
||||
fi
|
||||
AC_ARG_WITH(serverside-support, AS_HELP_STRING([--with-serverside-support], [Build with support for server-side usage of xcb. This is still EXPERIMENTAL! ABI/API may change! (default: no)]), [XCB_SERVERSIDE_SUPPORT=$withval], [XCB_SERVERSIDE_SUPPORT=no])
|
||||
|
||||
AM_CONDITIONAL(XCB_SERVERSIDE_SUPPORT, test "x$XCB_SERVERSIDE_SUPPORT" = "xyes")
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
doc/Makefile
|
||||
man/Makefile
|
||||
src/Makefile
|
||||
tests/Makefile
|
||||
])
|
||||
|
@ -220,9 +264,13 @@ AC_CONFIG_FILES([
|
|||
xcb.pc
|
||||
xcb-composite.pc
|
||||
xcb-damage.pc
|
||||
xcb-dbe.pc
|
||||
xcb-dpms.pc
|
||||
xcb-dri2.pc
|
||||
xcb-dri3.pc
|
||||
xcb-ge.pc
|
||||
xcb-glx.pc
|
||||
xcb-present.pc
|
||||
xcb-randr.pc
|
||||
xcb-record.pc
|
||||
xcb-render.pc
|
||||
|
@ -257,14 +305,19 @@ echo " Package: ${PACKAGE_NAME} ${PACKAGE_VERSION}"
|
|||
echo ""
|
||||
echo " Configuration"
|
||||
echo " XDM support.........: ${have_xdmcp}"
|
||||
echo " sendmsg fd passing..: ${have_sendmsg}"
|
||||
echo " Build unit tests....: ${HAVE_CHECK}"
|
||||
echo " with html results.: ${HTML_CHECK_RESULT}"
|
||||
echo " XCB buffer size.....: ${xcb_queue_buffer_size}"
|
||||
echo ""
|
||||
echo " X11 extensions"
|
||||
echo " Composite...........: ${BUILD_COMPOSITE}"
|
||||
echo " Damage..............: ${BUILD_DAMAGE}"
|
||||
echo " Dbe.................: ${BUILD_DBE}"
|
||||
echo " Dpms................: ${BUILD_DPMS}"
|
||||
echo " Dri2................: ${BUILD_DRI2}"
|
||||
echo " Dri3................: ${BUILD_DRI3}"
|
||||
echo " GenericEvent........: ${BUILD_GE}"
|
||||
echo " Glx.................: ${BUILD_GLX}"
|
||||
echo " Randr...............: ${BUILD_RANDR}"
|
||||
echo " Record..............: ${BUILD_RECORD}"
|
||||
|
@ -289,7 +342,6 @@ echo ""
|
|||
echo " Used CFLAGS:"
|
||||
echo " CPPFLAGS............: ${CPPFLAGS}"
|
||||
echo " CFLAGS..............: ${CFLAGS}"
|
||||
echo " Warning CFLAGS......: ${CWARNFLAGS}"
|
||||
echo ""
|
||||
echo " Installation:"
|
||||
echo " Prefix..............: ${prefix}"
|
||||
|
|
|
@ -8,7 +8,9 @@ xkb_issues
|
|||
|
||||
docdirs = $(srcdir)/tutorial
|
||||
|
||||
if BUILD_DOCS
|
||||
if ENABLE_DEVEL_DOCS
|
||||
if HAVE_DOXYGEN
|
||||
if HAVE_DOT
|
||||
|
||||
docdirs += manual
|
||||
|
||||
|
@ -21,6 +23,8 @@ clean-local:
|
|||
rm -rf manual/
|
||||
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
all-local: $(docdirs)
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
<li><a class="subsection" href="#DoesBackingStore">DoesBackingStore</a>
|
||||
<li><a class="subsection" href="#EventMaskOfScreen">EventMaskOfScreen</a>
|
||||
</ol>
|
||||
<li><a class="subsection" href="#misc">Miscellaneaous macros</a>
|
||||
<li><a class="subsection" href="#misc">Miscellaneous macros</a>
|
||||
<ol>
|
||||
<li><a class="subsection" href="#DisplayOfScreen">DisplayOfScreen</a>
|
||||
<li><a class="subsection" href="#DisplayCells">DisplayCells / CellsOfScreen</a>
|
||||
|
@ -1331,7 +1331,7 @@ main ()
|
|||
/* We draw the polygonal line */
|
||||
xcb_poly_line (c, XCB_COORD_MODE_PREVIOUS, win, foreground, 4, polyline);
|
||||
|
||||
/* We draw the segements */
|
||||
/* We draw the segments */
|
||||
xcb_poly_segment (c, win, foreground, 2, segments);
|
||||
|
||||
/* We draw the rectangles */
|
||||
|
@ -1470,10 +1470,10 @@ xcb_change_window_attributes (c, win, XCB_CW_EVENT_MASK, values);
|
|||
</pre>
|
||||
<div class="emph">
|
||||
<p>
|
||||
Note: A common bug programmers do is adding code to handle new
|
||||
Note: A common bug programmers have is adding code to handle new
|
||||
event types in their program, while forgetting to add the
|
||||
masks for these events in the creation of the window. Such a
|
||||
programmer then should sit down for hours debugging his
|
||||
programmer would then sit there for hours debugging their
|
||||
program, wondering "Why doesn't my program notice that I
|
||||
released the button?", only to find that they registered for
|
||||
button press events but not for button release events.
|
||||
|
@ -1830,7 +1830,7 @@ typedef xcb_enter_notify_event_t xcb_leave_notify_event_t;
|
|||
keyboard focus using the window manager (often by clicking
|
||||
on the title bar of the desired window). Once our window
|
||||
has the keyboard focus, every key press or key release will
|
||||
cause an event to be sent to our program (if it regsitered
|
||||
cause an event to be sent to our program (if it registered
|
||||
for these event types...).
|
||||
</p>
|
||||
<li class="subsubtitle"><a name="keypress">Keyboard press and release events</a>
|
||||
|
@ -2090,7 +2090,7 @@ xcb_void_cookie_t xcb_open_font (xcb_connection_t *c,
|
|||
Once a font is opened, you have to create a Graphic Context
|
||||
that will contain the informations about the color of the
|
||||
foreground and the background used when you draw a text in a
|
||||
Drawable. Here is an exemple of a Graphic Context that will
|
||||
Drawable. Here is an example of a Graphic Context that will
|
||||
allow us to draw an opened font with a black foreground and a
|
||||
white background:
|
||||
</p>
|
||||
|
@ -2297,9 +2297,7 @@ int main ()
|
|||
values[0] = screen->white_pixel;
|
||||
values[1] =
|
||||
XCB_EVENT_MASK_KEY_RELEASE |
|
||||
XCB_EVENT_MASK_BUTTON_PRESS |
|
||||
XCB_EVENT_MASK_EXPOSURE |
|
||||
XCB_EVENT_MASK_POINTER_MOTION;
|
||||
XCB_EVENT_MASK_EXPOSURE;
|
||||
cookie_window = xcb_create_window_checked (c,
|
||||
screen->root_depth,
|
||||
window, screen->root,
|
||||
|
@ -2404,7 +2402,7 @@ xcb_void_cookie_t xcb_change_property (xcb_connection_t *c, /* Connection
|
|||
const void *data); /* Data */
|
||||
</pre>
|
||||
<p>
|
||||
The <span class="code">mode</span> parameter coud be one of
|
||||
The <span class="code">mode</span> parameter could be one of
|
||||
the following values (defined in enumeration xcb_prop_mode_t in
|
||||
the xproto.h header file):
|
||||
</p>
|
||||
|
@ -2939,7 +2937,7 @@ xcb_get_window_attributes_reply_t *xcb_get_window_attributes_reply (xcb_connecti
|
|||
latter case, each time the mouse moves onto your window, the
|
||||
screen color map will be replaced by your window's color map,
|
||||
and you'll see all the other windows on screen change their
|
||||
colors into something quite bizzare. In fact, this is the
|
||||
colors into something quite bizarre. In fact, this is the
|
||||
effect you get with X applications that use the "-install"
|
||||
command line option.
|
||||
</p>
|
||||
|
@ -3302,10 +3300,10 @@ xcb_void_cookie_t xcb_free_pixmap (xcb_connection_t *c, /* Pointer to the
|
|||
<li class="title"><a name="mousecursor">Messing with the mouse cursor</a>
|
||||
<p>
|
||||
It it possible to modify the shape of the mouse pointer (also
|
||||
called the X pointer) when in certain states, as we otfen see in
|
||||
called the X pointer) when in certain states, as we often see in
|
||||
programs. For example, a busy application would often display
|
||||
the sand clock over its main window, to give the user a visual
|
||||
hint that he should wait. Let's see how we can change the mouse
|
||||
the hourglass cursor over its main window, to give the user a visual
|
||||
hint that they should wait. Let's see how we can change the mouse
|
||||
cursor of our windows.
|
||||
</p>
|
||||
<ol>
|
||||
|
@ -3341,7 +3339,7 @@ xcb_void_cookie_t xcb_create_glyph_cursor (xcb_connection_t *c,
|
|||
</p>
|
||||
<p>
|
||||
So we first open that font (see <a href="#loadfont">Loading a Font</a>)
|
||||
and create the new cursor. As for every X ressource, we have to
|
||||
and create the new cursor. As for every X resource, we have to
|
||||
ask for an X id with <span class="code">xcb_generate_id</span>
|
||||
first:
|
||||
</p>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
[wrap-git]
|
||||
url = https://gitea.gigo-games.dk/frederik/libxcb.git
|
||||
revision = HEAD
|
||||
depth = 1
|
|
@ -0,0 +1,70 @@
|
|||
dnl Detection and configuration of the visibility feature of gcc
|
||||
dnl Vincent Torri 2006-02-11
|
||||
dnl
|
||||
dnl XCB_CHECK_VISIBILITY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl Check the visibility feature of gcc
|
||||
dnl
|
||||
AC_DEFUN([XCB_CHECK_VISIBILITY],
|
||||
[
|
||||
AC_MSG_CHECKING([whether ${CC} supports symbol visibility])
|
||||
|
||||
save_CFLAGS=${CFLAGS}
|
||||
CFLAGS="$CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#pragma GCC visibility push(hidden)
|
||||
extern void f(int);
|
||||
#pragma GCC visibility pop
|
||||
]],
|
||||
[[]]
|
||||
)],
|
||||
[AC_DEFINE(
|
||||
GCC_HAS_VISIBILITY,
|
||||
[],
|
||||
[Defined if GCC supports the visibility feature])
|
||||
m4_if([$1], [], [:], [$1])
|
||||
AC_MSG_RESULT(yes)],
|
||||
[m4_if([$2], [], [:], [$2])
|
||||
AC_MSG_RESULT(no)])
|
||||
|
||||
CFLAGS=${save_CFLAGS}
|
||||
])
|
||||
|
||||
dnl Detection and configuration of the visibility feature of gcc
|
||||
dnl Vincent Torri 2006-02-11
|
||||
dnl
|
||||
dnl XCB_EXTENSION(name, default)
|
||||
dnl set the X extension
|
||||
dnl
|
||||
AC_DEFUN([XCB_EXTENSION],
|
||||
[dnl
|
||||
pushdef([UP], translit([$1], [-a-z], [_A-Z]))dnl
|
||||
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
|
||||
dnl
|
||||
m4_if([$2], [yes], [m4_define([xcb_defopt], [yes])],
|
||||
[$2], [no], [m4_define([xcb_defopt], [no])],
|
||||
m4_define([xcb_defopt], [auto]))dnl
|
||||
|
||||
AC_ARG_ENABLE(DOWN,
|
||||
[AS_HELP_STRING([--enable-[]DOWN],
|
||||
[Build XCB $1 Extension (default: ]xcb_defopt[)])],
|
||||
[BUILD_[]UP=$enableval],
|
||||
[BUILD_[]UP=xcb_defopt])
|
||||
dnl
|
||||
m4_if(xcb_defopt, [auto], [
|
||||
# This extension has a default value of "auto" and depends on the value of $2
|
||||
if test "x$BUILD_[]UP" = "xauto" ; then
|
||||
BUILD_[]UP=$2
|
||||
fi
|
||||
if test "x$BUILD_[]UP" = "xyes" ; then
|
||||
if test "x$2" = "xno" ; then
|
||||
AC_MSG_ERROR([Extension []UP requested, but dependencies are not met])
|
||||
fi
|
||||
fi])
|
||||
|
||||
m4_undefine([xcb_defopt])dnl
|
||||
AM_CONDITIONAL(BUILD_[]UP, [test "x$BUILD_[]UP" = "xyes"])
|
||||
])
|
||||
|
||||
dnl End of acinclude.m4
|
|
@ -0,0 +1 @@
|
|||
*.[0-9]
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
libmandir = $(LIB_MAN_DIR)
|
||||
|
||||
libman_PRE = \
|
||||
xcb-examples.man \
|
||||
xcb-requests.man
|
||||
|
||||
libman_DATA = $(libman_PRE:man=$(LIB_MAN_SUFFIX))
|
||||
|
||||
EXTRA_DIST = $(libman_PRE)
|
||||
|
||||
CLEANFILES = $(libman_DATA)
|
||||
|
||||
# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
|
||||
SUFFIXES = .$(LIB_MAN_SUFFIX) .man
|
||||
|
||||
.man.$(LIB_MAN_SUFFIX):
|
||||
$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
|
|
@ -1,4 +1,4 @@
|
|||
.TH xcb-examples 3 2011-12-11 "XCB" "XCB examples"
|
||||
.TH xcb-examples __libmansuffix__ __xorgversion__ "XCB examples"
|
||||
.ad l
|
||||
.SH NAME
|
||||
xcb-examples \- manpage examples
|
||||
|
@ -45,15 +45,15 @@ it on xcb@lists.freedesktop.org.
|
|||
|
||||
.SH CODING STYLE
|
||||
|
||||
Every example uses 4 spaces for indention.
|
||||
Every example uses 4 spaces for indentation.
|
||||
|
||||
Comments are in asterisks, like /* this */.
|
||||
|
||||
No line is longer than 80 characters (including indention).
|
||||
No line is longer than 80 characters (including indentation).
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR xcb_connect (3),
|
||||
.BR xcb_get_property (3),
|
||||
.BR xcb_flush (3)
|
||||
.BR xcb_connect (__libmansuffix__),
|
||||
.BR xcb_get_property (__libmansuffix__),
|
||||
.BR xcb_flush (__libmansuffix__)
|
||||
.SH AUTHOR
|
||||
Michael Stapelberg <michael+xcb at stapelberg dot de>
|
|
@ -1,4 +1,4 @@
|
|||
.TH xcb-requests 3 2011-12-11 "XCB" "XCB examples"
|
||||
.TH xcb-requests __libmansuffix__ __xorgversion__ "XCB examples"
|
||||
.ad l
|
||||
.SH NAME
|
||||
xcb-requests \- about request manpages
|
||||
|
@ -36,7 +36,7 @@ void my_example(xcb_connection *conn) {
|
|||
cookie = xcb_intern_atom(conn, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
|
||||
/* ... do other work here if possible ... */
|
||||
if ((reply = xcb_intern_atom_reply(conn, cookie, NULL))) {
|
||||
printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
|
||||
printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
|
||||
}
|
||||
free(reply);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void my_example(xcb_connection *conn, xcb_window_t window) {
|
|||
cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
|
||||
/* ... do other work here if possible ... */
|
||||
if ((reply = xcb_intern_atom_reply(c, cookie, &error))) {
|
||||
printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
|
||||
printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
|
||||
free(reply);
|
||||
} else {
|
||||
fprintf(stderr, "X11 Error %d\\n", error->error_code);
|
||||
|
@ -138,7 +138,7 @@ void my_example(xcb_connection *conn, xcb_window_t window) {
|
|||
"_NET_WM_NAME");
|
||||
/* ... do other work here if possible ... */
|
||||
if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) {
|
||||
printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
|
||||
printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
|
||||
free(reply);
|
||||
}
|
||||
|
||||
|
@ -156,10 +156,10 @@ void my_example(xcb_connection *conn, xcb_window_t window) {
|
|||
.fi
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR xcb_map_window (3),
|
||||
.BR xcb_intern_atom (3),
|
||||
.BR xcb_list_fonts (3),
|
||||
.BR xcb_poll_for_event (3),
|
||||
.BR xcb_request_check (3)
|
||||
.BR xcb_map_window (__libmansuffix__),
|
||||
.BR xcb_intern_atom (__libmansuffix__),
|
||||
.BR xcb_list_fonts (__libmansuffix__),
|
||||
.BR xcb_poll_for_event (__libmansuffix__),
|
||||
.BR xcb_request_check (__libmansuffix__)
|
||||
.SH AUTHOR
|
||||
Michael Stapelberg <michael+xcb at stapelberg dot de>
|
|
@ -1,9 +1,13 @@
|
|||
bigreq.*
|
||||
composite.*
|
||||
damage.*
|
||||
dbe.*
|
||||
dpms.*
|
||||
dri2.*
|
||||
dri3.*
|
||||
ge.*
|
||||
glx.*
|
||||
present.*
|
||||
randr.*
|
||||
record.*
|
||||
render.*
|
||||
|
|
|
@ -4,7 +4,7 @@ EXTSOURCES = xproto.c \
|
|||
bigreq.c \
|
||||
xc_misc.c
|
||||
|
||||
AM_CFLAGS = $(CWARNFLAGS) $(NEEDED_CFLAGS) $(XDMCP_CFLAGS)
|
||||
AM_CFLAGS = $(BASE_CFLAGS) $(NEEDED_CFLAGS) $(XDMCP_CFLAGS)
|
||||
libxcb_la_LIBADD = $(NEEDED_LIBS) $(XDMCP_LIBS)
|
||||
libxcb_la_SOURCES = \
|
||||
xcb_conn.c xcb_out.c xcb_in.c xcb_ext.c xcb_xid.c \
|
||||
|
@ -40,6 +40,14 @@ libxcb_damage_la_LIBADD = $(XCB_LIBS)
|
|||
nodist_libxcb_damage_la_SOURCES = damage.c damage.h
|
||||
endif
|
||||
|
||||
EXTSOURCES += dbe.c
|
||||
if BUILD_DBE
|
||||
lib_LTLIBRARIES += libxcb-dbe.la
|
||||
libxcb_dbe_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_dbe_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_dbe_la_SOURCES = dbe.c dbe.h
|
||||
endif
|
||||
|
||||
EXTSOURCES += dpms.c
|
||||
if BUILD_DPMS
|
||||
lib_LTLIBRARIES += libxcb-dpms.la
|
||||
|
@ -56,6 +64,22 @@ libxcb_dri2_la_LIBADD = $(XCB_LIBS)
|
|||
nodist_libxcb_dri2_la_SOURCES = dri2.c dri2.h
|
||||
endif
|
||||
|
||||
EXTSOURCES += dri3.c
|
||||
if BUILD_DRI3
|
||||
lib_LTLIBRARIES += libxcb-dri3.la
|
||||
libxcb_dri3_la_LDFLAGS = -version-info 1:0:1 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_dri3_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_dri3_la_SOURCES = dri3.c dri3.h
|
||||
endif
|
||||
|
||||
EXTSOURCES += present.c
|
||||
if BUILD_PRESENT
|
||||
lib_LTLIBRARIES += libxcb-present.la
|
||||
libxcb_present_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_present_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_present_la_SOURCES = present.c present.h
|
||||
endif
|
||||
|
||||
EXTSOURCES += glx.c
|
||||
if BUILD_GLX
|
||||
lib_LTLIBRARIES += libxcb-glx.la
|
||||
|
@ -123,7 +147,7 @@ endif
|
|||
EXTSOURCES += sync.c
|
||||
if BUILD_SYNC
|
||||
lib_LTLIBRARIES += libxcb-sync.la
|
||||
libxcb_sync_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_sync_la_LDFLAGS = -version-info 1:0:0 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_sync_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_sync_la_SOURCES = sync.c sync.h
|
||||
endif
|
||||
|
@ -163,7 +187,7 @@ endif
|
|||
EXTSOURCES += xinput.c
|
||||
if BUILD_XINPUT
|
||||
lib_LTLIBRARIES += libxcb-xinput.la
|
||||
libxcb_xinput_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_xinput_la_LDFLAGS = -version-info 1:0:1 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_xinput_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_xinput_la_SOURCES = xinput.c xinput.h
|
||||
endif
|
||||
|
@ -171,7 +195,7 @@ endif
|
|||
EXTSOURCES += xkb.c
|
||||
if BUILD_XKB
|
||||
lib_LTLIBRARIES += libxcb-xkb.la
|
||||
libxcb_xkb_la_LDFLAGS = -version-info 0:0:0 -no-undefined
|
||||
libxcb_xkb_la_LDFLAGS = -version-info 1:0:0 -no-undefined
|
||||
libxcb_xkb_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_xkb_la_SOURCES = xkb.c xkb.h
|
||||
endif
|
||||
|
@ -216,6 +240,13 @@ libxcb_xvmc_la_LIBADD = $(XCB_LIBS)
|
|||
nodist_libxcb_xvmc_la_SOURCES = xvmc.c xvmc.h
|
||||
endif
|
||||
|
||||
EXTSOURCES += ge.c
|
||||
if BUILD_GE
|
||||
lib_LTLIBRARIES += libxcb-ge.la
|
||||
libxcb_ge_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
|
||||
libxcb_ge_la_LIBADD = $(XCB_LIBS)
|
||||
nodist_libxcb_ge_la_SOURCES = ge.c ge.h
|
||||
endif
|
||||
|
||||
EXTHEADERS=$(EXTSOURCES:.c=.h)
|
||||
xcbinclude_HEADERS = xcb.h xcbext.h
|
||||
|
@ -225,15 +256,22 @@ endif
|
|||
nodist_xcbinclude_HEADERS = $(EXTHEADERS)
|
||||
noinst_HEADERS = xcbint.h
|
||||
|
||||
STATIC_MANS = man/xcb-examples.3 man/xcb-requests.3
|
||||
BUILT_MANS = man/xcb_*.3
|
||||
man_MANS = $(STATIC_MANS) $(BUILT_MANS)
|
||||
EXTRA_DIST = $(STATIC_MANS)
|
||||
BUILT_MAN_PAGES = man/xcb_*
|
||||
libmandir = $(LIB_MAN_DIR)
|
||||
libman_DATA = $(BUILT_MAN_PAGES)
|
||||
|
||||
BUILT_SOURCES = $(EXTSOURCES) $(BUILT_MANS)
|
||||
CLEANFILES = $(EXTSOURCES) $(EXTHEADERS) $(BUILT_MANS)
|
||||
BUILT_SOURCES = $(EXTSOURCES) $(BUILT_MAN_PAGES)
|
||||
CLEANFILES = $(EXTSOURCES) $(EXTHEADERS) $(BUILT_MAN_PAGES)
|
||||
|
||||
$(EXTSOURCES): c_client.py
|
||||
$(PYTHON) $(srcdir)/c_client.py -p $(XCBPROTO_XCBPYTHONDIR) $(XCBPROTO_XCBINCLUDEDIR)/$(@:.c=.xml)
|
||||
C_CLIENT_PY_EXTRA_ARGS =
|
||||
if XCB_SERVERSIDE_SUPPORT
|
||||
C_CLIENT_PY_EXTRA_ARGS += --server-side
|
||||
endif
|
||||
|
||||
$(man_MANS): $(EXTSOURCES)
|
||||
$(EXTSOURCES): c_client.py $(XCBPROTO_XCBINCLUDEDIR)/$(@:.c=.xml)
|
||||
$(AM_V_GEN)$(PYTHON) $(srcdir)/c_client.py -c "$(PACKAGE_STRING)" -l "$(XORG_MAN_PAGE)" \
|
||||
-s "$(LIB_MAN_SUFFIX)" -p $(XCBPROTO_XCBPYTHONDIR) \
|
||||
$(C_CLIENT_PY_EXTRA_ARGS) \
|
||||
$(XCBPROTO_XCBINCLUDEDIR)/$(@:.c=.xml)
|
||||
|
||||
$(BUILT_MAN_PAGES): $(EXTSOURCES)
|
||||
|
|
1758
src/c_client.py
1758
src/c_client.py
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,2 @@
|
|||
*.3
|
||||
!xcb-examples.3
|
||||
!xcb-requests.3
|
||||
*.[0-9]
|
||||
*.[0-9]x
|
||||
|
|
228
src/xcb.h
228
src/xcb.h
|
@ -29,11 +29,7 @@
|
|||
#define __XCB_H__
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(__solaris__)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/uio.h>
|
||||
|
@ -51,6 +47,36 @@ extern "C" {
|
|||
* @file xcb.h
|
||||
*/
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with older compilers. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For the below checks, we currently assume that __GNUC__ indicates
|
||||
* gcc 3.0 (released 2001) or later, as we require support for C99.
|
||||
*/
|
||||
|
||||
/* Supported in gcc 2.5 and later */
|
||||
#if defined(__GNUC__) || __has_attribute(__const__)
|
||||
#define XCB_CONST_FUNCTION __attribute__((__const__))
|
||||
#else
|
||||
#define XCB_CONST_FUNCTION XCB_PURE_FUNCTION
|
||||
#endif
|
||||
|
||||
/* Supported in gcc 2.7 and later */
|
||||
#if defined(__GNUC__) || __has_attribute(__packed__)
|
||||
#define XCB_PACKED __attribute__((__packed__))
|
||||
#else
|
||||
#define XCB_PACKED
|
||||
#endif
|
||||
|
||||
/* Supported in gcc 2.96 and later */
|
||||
#if defined(__GNUC__) || __has_attribute(__pure__)
|
||||
#define XCB_PURE_FUNCTION __attribute__((__pure__))
|
||||
#else
|
||||
#define XCB_PURE_FUNCTION
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup XCB_Core_API XCB Core API
|
||||
* @brief Core API of the XCB library.
|
||||
|
@ -87,6 +113,9 @@ extern "C" {
|
|||
/** Connection closed because the server does not have a screen matching the display. */
|
||||
#define XCB_CONN_CLOSED_INVALID_SCREEN 6
|
||||
|
||||
/** Connection closed because some FD passing operation failed */
|
||||
#define XCB_CONN_CLOSED_FDPASSING_FAILED 7
|
||||
|
||||
#define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
|
||||
|
||||
/* Opaque structures */
|
||||
|
@ -137,11 +166,26 @@ typedef struct {
|
|||
uint32_t full_sequence; /**< full sequence */
|
||||
} xcb_generic_event_t;
|
||||
|
||||
/**
|
||||
* @brief Raw Generic event.
|
||||
*
|
||||
* A generic event structure as used on the wire, i.e., without the full_sequence field
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t response_type; /**< Type of the response */
|
||||
uint8_t pad0; /**< Padding */
|
||||
uint16_t sequence; /**< Sequence number */
|
||||
uint32_t pad[7]; /**< Padding */
|
||||
} xcb_raw_generic_event_t;
|
||||
|
||||
/**
|
||||
* @brief GE event
|
||||
*
|
||||
* An event as sent by the XGE extension. The length field specifies the
|
||||
* number of 4-byte blocks trailing the struct.
|
||||
*
|
||||
* @deprecated Since some fields in this struct have unfortunate names, it is
|
||||
* recommended to use xcb_ge_generic_event_t instead.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t response_type; /**< Type of the response */
|
||||
|
@ -217,7 +261,7 @@ typedef struct xcb_auth_info_t {
|
|||
|
||||
/**
|
||||
* @brief Forces any buffered output to be written to the server.
|
||||
* @param c: The connection to the X server.
|
||||
* @param c The connection to the X server.
|
||||
* @return > @c 0 on success, <= @c 0 otherwise.
|
||||
*
|
||||
* Forces any buffered output to be written to the server. Blocks
|
||||
|
@ -227,7 +271,7 @@ int xcb_flush(xcb_connection_t *c);
|
|||
|
||||
/**
|
||||
* @brief Returns the maximum request length that this server accepts.
|
||||
* @param c: The connection to the X server.
|
||||
* @param c The connection to the X server.
|
||||
* @return The maximum request length field.
|
||||
*
|
||||
* In the absence of the BIG-REQUESTS extension, returns the
|
||||
|
@ -244,7 +288,7 @@ uint32_t xcb_get_maximum_request_length(xcb_connection_t *c);
|
|||
|
||||
/**
|
||||
* @brief Prefetch the maximum request length without blocking.
|
||||
* @param c: The connection to the X server.
|
||||
* @param c The connection to the X server.
|
||||
*
|
||||
* Without blocking, does as much work as possible toward computing
|
||||
* the maximum request length accepted by the X server.
|
||||
|
@ -266,7 +310,7 @@ void xcb_prefetch_maximum_request_length(xcb_connection_t *c);
|
|||
|
||||
/**
|
||||
* @brief Returns the next event or error from the server.
|
||||
* @param c: The connection to the X server.
|
||||
* @param c The connection to the X server.
|
||||
* @return The next event from the server.
|
||||
*
|
||||
* Returns the next event or error from the server, or returns null in
|
||||
|
@ -277,8 +321,7 @@ xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c);
|
|||
|
||||
/**
|
||||
* @brief Returns the next event or error from the server.
|
||||
* @param c: The connection to the X server.
|
||||
* error status of the operation.
|
||||
* @param c The connection to the X server.
|
||||
* @return The next event from the server.
|
||||
*
|
||||
* Returns the next event or error from the server, if one is
|
||||
|
@ -291,7 +334,7 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c);
|
|||
|
||||
/**
|
||||
* @brief Returns the next event without reading from the connection.
|
||||
* @param c: The connection to the X server.
|
||||
* @param c The connection to the X server.
|
||||
* @return The next already queued event from the server.
|
||||
*
|
||||
* This is a version of xcb_poll_for_event that only examines the
|
||||
|
@ -305,10 +348,42 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c);
|
|||
*/
|
||||
xcb_generic_event_t *xcb_poll_for_queued_event(xcb_connection_t *c);
|
||||
|
||||
typedef struct xcb_special_event xcb_special_event_t;
|
||||
|
||||
/**
|
||||
* @brief Returns the next event from a special queue
|
||||
*/
|
||||
xcb_generic_event_t *xcb_poll_for_special_event(xcb_connection_t *c,
|
||||
xcb_special_event_t *se);
|
||||
|
||||
/**
|
||||
* @brief Returns the next event from a special queue, blocking until one arrives
|
||||
*/
|
||||
xcb_generic_event_t *xcb_wait_for_special_event(xcb_connection_t *c,
|
||||
xcb_special_event_t *se);
|
||||
/**
|
||||
* @typedef typedef struct xcb_extension_t xcb_extension_t
|
||||
*/
|
||||
typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as key for xcb_get_extension_data_t. */
|
||||
|
||||
/**
|
||||
* @brief Listen for a special event
|
||||
*/
|
||||
xcb_special_event_t *xcb_register_for_special_xge(xcb_connection_t *c,
|
||||
xcb_extension_t *ext,
|
||||
uint32_t eid,
|
||||
uint32_t *stamp);
|
||||
|
||||
/**
|
||||
* @brief Stop listening for a special event
|
||||
*/
|
||||
void xcb_unregister_for_special_event(xcb_connection_t *c,
|
||||
xcb_special_event_t *se);
|
||||
|
||||
/**
|
||||
* @brief Return the error for a request, or NULL if none can ever arrive.
|
||||
* @param c: The connection to the X server.
|
||||
* @param cookie: The request cookie.
|
||||
* @param c The connection to the X server.
|
||||
* @param cookie The request cookie.
|
||||
* @return The error for the request, or NULL if none can ever arrive.
|
||||
*
|
||||
* The xcb_void_cookie_t cookie supplied to this function must have resulted
|
||||
|
@ -325,8 +400,8 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
|
|||
|
||||
/**
|
||||
* @brief Discards the reply for a request.
|
||||
* @param c: The connection to the X server.
|
||||
* @param sequence: The request sequence number from a cookie.
|
||||
* @param c The connection to the X server.
|
||||
* @param sequence The request sequence number from a cookie.
|
||||
*
|
||||
* Discards the reply for a request. Additionally, any error generated
|
||||
* by the request is also discarded (unless it was an _unchecked request
|
||||
|
@ -339,18 +414,33 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
|
|||
*/
|
||||
void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
|
||||
|
||||
/**
|
||||
* @brief Discards the reply for a request, given by a 64bit sequence number
|
||||
* @param c The connection to the X server.
|
||||
* @param sequence 64-bit sequence number as returned by xcb_send_request64().
|
||||
*
|
||||
* Discards the reply for a request. Additionally, any error generated
|
||||
* by the request is also discarded (unless it was an _unchecked request
|
||||
* and the error has already arrived).
|
||||
*
|
||||
* This function will not block even if the reply is not yet available.
|
||||
*
|
||||
* Note that the sequence really does have to come from xcb_send_request64();
|
||||
* the cookie sequence number is defined as "unsigned" int and therefore
|
||||
* not 64-bit on all platforms.
|
||||
* This function is not designed to operate on socket-handoff replies.
|
||||
*
|
||||
* Unlike its xcb_discard_reply() counterpart, the given sequence number is not
|
||||
* automatically "widened" to 64-bit.
|
||||
*/
|
||||
void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence);
|
||||
|
||||
/* xcb_ext.c */
|
||||
|
||||
/**
|
||||
* @typedef typedef struct xcb_extension_t xcb_extension_t
|
||||
*/
|
||||
typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as key for xcb_get_extension_data_t. */
|
||||
|
||||
/**
|
||||
* @brief Caches reply information from QueryExtension requests.
|
||||
* @param c: The connection.
|
||||
* @param ext: The extension data.
|
||||
* @param c The connection.
|
||||
* @param ext The extension data.
|
||||
* @return A pointer to the xcb_query_extension_reply_t for the extension.
|
||||
*
|
||||
* This function is the primary interface to the "extension cache",
|
||||
|
@ -363,12 +453,12 @@ typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as k
|
|||
* The result must not be freed. This storage is managed by the cache
|
||||
* itself.
|
||||
*/
|
||||
const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
|
||||
const struct xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
|
||||
|
||||
/**
|
||||
* @brief Prefetch of extension data into the extension cache
|
||||
* @param c: The connection.
|
||||
* @param ext: The extension data.
|
||||
* @param c The connection.
|
||||
* @param ext The extension data.
|
||||
*
|
||||
* This function allows a "prefetch" of extension data into the
|
||||
* extension cache. Invoking the function may cause a call to
|
||||
|
@ -383,7 +473,7 @@ void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
|
|||
|
||||
/**
|
||||
* @brief Access the data returned by the server.
|
||||
* @param c: The connection.
|
||||
* @param c The connection.
|
||||
* @return A pointer to an xcb_setup_t structure.
|
||||
*
|
||||
* Accessor for the data returned by the server when the xcb_connection_t
|
||||
|
@ -399,27 +489,30 @@ void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
|
|||
*
|
||||
* The result must not be freed.
|
||||
*/
|
||||
const xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
|
||||
XCB_PURE_FUNCTION
|
||||
const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
|
||||
|
||||
/**
|
||||
* @brief Access the file descriptor of the connection.
|
||||
* @param c: The connection.
|
||||
* @param c The connection.
|
||||
* @return The file descriptor.
|
||||
*
|
||||
* Accessor for the file descriptor that was passed to the
|
||||
* xcb_connect_to_fd call that returned @p c.
|
||||
*/
|
||||
XCB_PURE_FUNCTION
|
||||
int xcb_get_file_descriptor(xcb_connection_t *c);
|
||||
|
||||
/**
|
||||
* @brief Test whether the connection has shut down due to a fatal error.
|
||||
* @param c: The connection.
|
||||
* @param c The connection.
|
||||
* @return > 0 if the connection is in an error state; 0 otherwise.
|
||||
*
|
||||
* Some errors that occur in the context of an xcb_connection_t
|
||||
* are unrecoverable. When such an error occurs, the
|
||||
* connection is shut down and further operations on the
|
||||
* xcb_connection_t have no effect.
|
||||
* xcb_connection_t have no effect, but memory will not be freed until
|
||||
* xcb_disconnect() is called on the xcb_connection_t.
|
||||
*
|
||||
* @return XCB_CONN_ERROR, because of socket errors, pipe errors or other stream errors.
|
||||
* @return XCB_CONN_CLOSED_EXT_NOTSUPPORTED, when extension not supported.
|
||||
|
@ -428,12 +521,13 @@ int xcb_get_file_descriptor(xcb_connection_t *c);
|
|||
* @return XCB_CONN_CLOSED_PARSE_ERR, error during parsing display string.
|
||||
* @return XCB_CONN_CLOSED_INVALID_SCREEN, because the server does not have a screen matching the display.
|
||||
*/
|
||||
XCB_PURE_FUNCTION
|
||||
int xcb_connection_has_error(xcb_connection_t *c);
|
||||
|
||||
/**
|
||||
* @brief Connects to the X server.
|
||||
* @param fd: The file descriptor.
|
||||
* @param auth_info: Authentication data.
|
||||
* @param fd The file descriptor.
|
||||
* @param auth_info Authentication data.
|
||||
* @return A newly allocated xcb_connection_t structure.
|
||||
*
|
||||
* Connects to an X server, given the open socket @p fd and the
|
||||
|
@ -441,15 +535,20 @@ int xcb_connection_has_error(xcb_connection_t *c);
|
|||
* bidirectionally connected to an X server. If the connection
|
||||
* should be unauthenticated, @p auth_info must be @c
|
||||
* NULL.
|
||||
*
|
||||
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
|
||||
* Callers need to use xcb_connection_has_error() to check for failure.
|
||||
* When finished, use xcb_disconnect() to close the connection and free
|
||||
* the structure.
|
||||
*/
|
||||
xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info);
|
||||
|
||||
/**
|
||||
* @brief Closes the connection.
|
||||
* @param c: The connection.
|
||||
* @param c The connection.
|
||||
*
|
||||
* Closes the file descriptor and frees all memory associated with the
|
||||
* connection @c c.
|
||||
* connection @c c. If @p c is @c NULL, nothing is done.
|
||||
*/
|
||||
void xcb_disconnect(xcb_connection_t *c);
|
||||
|
||||
|
@ -458,10 +557,10 @@ void xcb_disconnect(xcb_connection_t *c);
|
|||
|
||||
/**
|
||||
* @brief Parses a display string name in the form documented by X(7x).
|
||||
* @param name: The name of the display.
|
||||
* @param host: A pointer to a malloc'd copy of the hostname.
|
||||
* @param display: A pointer to the display number.
|
||||
* @param screen: A pointer to the screen number.
|
||||
* @param name The name of the display.
|
||||
* @param host A pointer to a malloc'd copy of the hostname.
|
||||
* @param display A pointer to the display number.
|
||||
* @param screen A pointer to the screen number.
|
||||
* @return 0 on failure, non 0 otherwise.
|
||||
*
|
||||
* Parses the display string name @p display_name in the form
|
||||
|
@ -477,8 +576,8 @@ int xcb_parse_display(const char *name, char **host, int *display, int *screen);
|
|||
|
||||
/**
|
||||
* @brief Connects to the X server.
|
||||
* @param displayname: The name of the display.
|
||||
* @param screenp: A pointer to a preferred screen number.
|
||||
* @param displayname The name of the display.
|
||||
* @param screenp A pointer to a preferred screen number.
|
||||
* @return A newly allocated xcb_connection_t structure.
|
||||
*
|
||||
* Connects to the X server specified by @p displayname. If @p
|
||||
|
@ -486,20 +585,30 @@ int xcb_parse_display(const char *name, char **host, int *display, int *screen);
|
|||
* variable. If a particular screen on that server is preferred, the
|
||||
* int pointed to by @p screenp (if not @c NULL) will be set to that
|
||||
* screen; otherwise the screen will be set to 0.
|
||||
*
|
||||
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
|
||||
* Callers need to use xcb_connection_has_error() to check for failure.
|
||||
* When finished, use xcb_disconnect() to close the connection and free
|
||||
* the structure.
|
||||
*/
|
||||
xcb_connection_t *xcb_connect(const char *displayname, int *screenp);
|
||||
|
||||
/**
|
||||
* @brief Connects to the X server, using an authorization information.
|
||||
* @param display: The name of the display.
|
||||
* @param auth: The authorization information.
|
||||
* @param screen: A pointer to a preferred screen number.
|
||||
* @param display The name of the display.
|
||||
* @param auth The authorization information.
|
||||
* @param screen A pointer to a preferred screen number.
|
||||
* @return A newly allocated xcb_connection_t structure.
|
||||
*
|
||||
* Connects to the X server specified by @p displayname, using the
|
||||
* authorization @p auth. If a particular screen on that server is
|
||||
* preferred, the int pointed to by @p screenp (if not @c NULL) will
|
||||
* be set to that screen; otherwise @p screenp will be set to 0.
|
||||
*
|
||||
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
|
||||
* Callers need to use xcb_connection_has_error() to check for failure.
|
||||
* When finished, use xcb_disconnect() to close the connection and free
|
||||
* the structure.
|
||||
*/
|
||||
xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen);
|
||||
|
||||
|
@ -508,8 +617,8 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb
|
|||
|
||||
/**
|
||||
* @brief Allocates an XID for a new object.
|
||||
* @param c: The connection.
|
||||
* @return A newly allocated XID.
|
||||
* @param c The connection.
|
||||
* @return A newly allocated XID, or -1 on failure.
|
||||
*
|
||||
* Allocates an XID for a new object. Typically used just prior to
|
||||
* various object creation functions, such as xcb_create_window.
|
||||
|
@ -517,6 +626,35 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb
|
|||
uint32_t xcb_generate_id(xcb_connection_t *c);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Obtain number of bytes read from the connection.
|
||||
* @param c The connection
|
||||
* @return Number of bytes read from the server.
|
||||
*
|
||||
* Returns cumulative number of bytes received from the connection.
|
||||
*
|
||||
* This retrieves the total number of bytes read from this connection,
|
||||
* to be used for diagnostic/monitoring/informative purposes.
|
||||
*/
|
||||
|
||||
uint64_t
|
||||
xcb_total_read(xcb_connection_t *c);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Obtain number of bytes written to the connection.
|
||||
* @param c The connection
|
||||
* @return Number of bytes written to the server.
|
||||
*
|
||||
* Returns cumulative number of bytes sent to the connection.
|
||||
*
|
||||
* This retrieves the total number of bytes written to this connection,
|
||||
* to be used for diagnostic/monitoring/informative purposes.
|
||||
*/
|
||||
|
||||
uint64_t
|
||||
xcb_total_written(xcb_connection_t *c);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <X11/Xauth.h>
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __INTERIX
|
||||
/* _don't_ ask. interix has INADDR_LOOPBACK in here. */
|
||||
|
@ -48,6 +47,8 @@
|
|||
#endif
|
||||
#include "xcb_windefs.h"
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
@ -72,7 +73,7 @@ enum 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] = {
|
||||
static const char *authnames[N_AUTH_PROTOS] = {
|
||||
#ifdef HASXDMAUTH
|
||||
AUTH_PROTO_XDM_AUTHORIZATION,
|
||||
#endif
|
||||
|
@ -89,11 +90,11 @@ static int authnameslen[N_AUTH_PROTOS] = {
|
|||
static size_t memdup(char **dst, void *src, size_t len)
|
||||
{
|
||||
if(len)
|
||||
*dst = malloc(len);
|
||||
*dst = malloc(len);
|
||||
else
|
||||
*dst = 0;
|
||||
*dst = 0;
|
||||
if(!*dst)
|
||||
return 0;
|
||||
return 0;
|
||||
memcpy(*dst, src, len);
|
||||
return len;
|
||||
}
|
||||
|
@ -101,9 +102,9 @@ 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(authnameslen[kind] != namelen)
|
||||
return 0;
|
||||
return 0;
|
||||
if(memcmp(authnames[kind], name, namelen))
|
||||
return 0;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -133,6 +134,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, int display)
|
|||
}
|
||||
addr += 12;
|
||||
/* if v4-mapped, fall through. */
|
||||
XCB_ALLOW_FALLTHRU
|
||||
#endif
|
||||
case AF_INET:
|
||||
if(!addr)
|
||||
|
@ -163,7 +165,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, int display)
|
|||
return XauGetBestAuthByAddr (family,
|
||||
(unsigned short) addrlen, addr,
|
||||
(unsigned short) dispbuflen, dispbuf,
|
||||
N_AUTH_PROTOS, authnames, authnameslen);
|
||||
N_AUTH_PROTOS, (char **)authnames, authnameslen);
|
||||
}
|
||||
|
||||
#ifdef HASXDMAUTH
|
||||
|
@ -183,7 +185,7 @@ static void do_append(char *buf, int *idxp, void *val, size_t valsize) {
|
|||
*idxp += valsize;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *sockname)
|
||||
{
|
||||
if (authname_match(AUTH_MC1, authptr->name, authptr->name_length)) {
|
||||
|
@ -195,22 +197,22 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
|
|||
#ifdef HASXDMAUTH
|
||||
#define APPEND(buf,idx,val) do_append((buf),&(idx),&(val),sizeof(val))
|
||||
if (authname_match(AUTH_XA1, authptr->name, authptr->name_length)) {
|
||||
int j;
|
||||
int j;
|
||||
|
||||
info->data = malloc(192 / 8);
|
||||
if(!info->data)
|
||||
return 0;
|
||||
info->data = malloc(192 / 8);
|
||||
if(!info->data)
|
||||
return 0;
|
||||
|
||||
for (j = 0; j < 8; j++)
|
||||
info->data[j] = authptr->data[j];
|
||||
switch(sockname->sa_family) {
|
||||
for (j = 0; j < 8; j++)
|
||||
info->data[j] = authptr->data[j];
|
||||
switch(sockname->sa_family) {
|
||||
case AF_INET:
|
||||
/*block*/ {
|
||||
struct sockaddr_in *si = (struct sockaddr_in *) sockname;
|
||||
APPEND(info->data, j, si->sin_addr.s_addr);
|
||||
APPEND(info->data, j, si->sin_port);
|
||||
}
|
||||
break;
|
||||
struct sockaddr_in *si = (struct sockaddr_in *) sockname;
|
||||
APPEND(info->data, j, si->sin_addr.s_addr);
|
||||
APPEND(info->data, j, si->sin_port);
|
||||
}
|
||||
break;
|
||||
#ifdef AF_INET6
|
||||
case AF_INET6:
|
||||
/*block*/ {
|
||||
|
@ -235,26 +237,26 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
|
|||
#endif
|
||||
case AF_UNIX:
|
||||
/*block*/ {
|
||||
uint32_t fakeaddr = htonl(0xffffffff - next_nonce());
|
||||
uint16_t fakeport = htons(getpid());
|
||||
APPEND(info->data, j, fakeaddr);
|
||||
APPEND(info->data, j, fakeport);
|
||||
}
|
||||
break;
|
||||
uint32_t fakeaddr = htonl(0xffffffff - next_nonce());
|
||||
uint16_t fakeport = htons(getpid());
|
||||
APPEND(info->data, j, fakeaddr);
|
||||
APPEND(info->data, j, fakeport);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
free(info->data);
|
||||
return 0; /* do not know how to build this */
|
||||
}
|
||||
{
|
||||
uint32_t now = htonl(time(0));
|
||||
APPEND(info->data, j, now);
|
||||
}
|
||||
assert(j <= 192 / 8);
|
||||
while (j < 192 / 8)
|
||||
info->data[j++] = 0;
|
||||
info->datalen = j;
|
||||
XdmcpWrap ((unsigned char *) info->data, (unsigned char *) authptr->data + 8, (unsigned char *) info->data, info->datalen);
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
uint32_t now = htonl(time(0));
|
||||
APPEND(info->data, j, now);
|
||||
}
|
||||
assert(j <= 192 / 8);
|
||||
while (j < 192 / 8)
|
||||
info->data[j++] = 0;
|
||||
info->datalen = j;
|
||||
XdmcpWrap ((unsigned char *) info->data, (unsigned char *) authptr->data + 8, (unsigned char *) info->data, info->datalen);
|
||||
return 1;
|
||||
}
|
||||
#undef APPEND
|
||||
#endif
|
||||
|
@ -269,10 +271,17 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
|
|||
to the value returned by either getpeername() or getsockname()
|
||||
(according to POSIX, applications should not assume a particular
|
||||
length for `sockaddr_un.sun_path') */
|
||||
#ifdef _WIN32
|
||||
static struct sockaddr *get_peer_sock_name(int(_stdcall *socket_func)(SOCKET,
|
||||
struct sockaddr *,
|
||||
socklen_t *),
|
||||
int fd)
|
||||
#else
|
||||
static struct sockaddr *get_peer_sock_name(int (*socket_func)(int,
|
||||
struct sockaddr *,
|
||||
socklen_t *),
|
||||
int fd)
|
||||
struct sockaddr *,
|
||||
socklen_t *),
|
||||
int fd)
|
||||
#endif
|
||||
{
|
||||
socklen_t socknamelen = sizeof(struct sockaddr) + INITIAL_SOCKNAME_SLACK;
|
||||
socklen_t actual_socknamelen = socknamelen;
|
||||
|
|
197
src/xcb_conn.c
197
src/xcb_conn.c
|
@ -32,7 +32,6 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
@ -48,7 +47,9 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include "xcb_windefs.h"
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif /* _WIN32 */
|
||||
|
@ -64,21 +65,50 @@ typedef struct {
|
|||
uint16_t length;
|
||||
} xcb_setup_generic_t;
|
||||
|
||||
static const xcb_setup_t xcb_error_setup = {
|
||||
0, /* status: failed (but we wouldn't have a xcb_setup_t in this case) */
|
||||
0, /* pad0 */
|
||||
0, 0, /* protocol version, should be 11.0, but isn't */
|
||||
0, /* length, invalid value */
|
||||
0, /* release_number */
|
||||
0, 0, /* resource_id_{base,mask} */
|
||||
0, /* motion_buffer_size */
|
||||
0, /* vendor_len */
|
||||
0, /* maximum_request_length */
|
||||
0, /* roots_len */
|
||||
0, /* pixmap_formats_len */
|
||||
0, /* image_byte_order */
|
||||
0, /* bitmap_format_bit_order */
|
||||
0, /* bitmap_format_scanline_unit */
|
||||
0, /* bitmap_format_scanline_pad */
|
||||
0, 0, /* {min,max}_keycode */
|
||||
{ 0, 0, 0, 0 } /* pad1 */
|
||||
};
|
||||
|
||||
/* Keep this list in sync with is_static_error_conn()! */
|
||||
static const int xcb_con_error = XCB_CONN_ERROR;
|
||||
static const int xcb_con_closed_mem_er = XCB_CONN_CLOSED_MEM_INSUFFICIENT;
|
||||
static const int xcb_con_closed_parse_er = XCB_CONN_CLOSED_PARSE_ERR;
|
||||
static const int xcb_con_closed_screen_er = XCB_CONN_CLOSED_INVALID_SCREEN;
|
||||
|
||||
static int is_static_error_conn(xcb_connection_t *c)
|
||||
{
|
||||
return c == (xcb_connection_t *) &xcb_con_error ||
|
||||
c == (xcb_connection_t *) &xcb_con_closed_mem_er ||
|
||||
c == (xcb_connection_t *) &xcb_con_closed_parse_er ||
|
||||
c == (xcb_connection_t *) &xcb_con_closed_screen_er;
|
||||
}
|
||||
|
||||
static int set_fd_flags(const int fd)
|
||||
{
|
||||
/* Win32 doesn't have file descriptors and the fcntl function. This block sets the socket in non-blocking mode */
|
||||
|
||||
#ifdef _WIN32
|
||||
u_long iMode = 1; /* non-zero puts it in non-blocking mode, 0 in blocking mode */
|
||||
u_long iMode = 1; /* non-zero puts it in non-blocking mode, 0 in blocking mode */
|
||||
int ret = 0;
|
||||
|
||||
ret = ioctlsocket(fd, FIONBIO, &iMode);
|
||||
if(ret != 0)
|
||||
if(ret != 0)
|
||||
return 0;
|
||||
return 1;
|
||||
#else
|
||||
|
@ -140,6 +170,8 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
|
|||
|
||||
static int read_setup(xcb_connection_t *c)
|
||||
{
|
||||
const char newline = '\n';
|
||||
|
||||
/* Read the server response */
|
||||
c->setup = malloc(sizeof(xcb_setup_generic_t));
|
||||
if(!c->setup)
|
||||
|
@ -165,6 +197,7 @@ static int read_setup(xcb_connection_t *c)
|
|||
{
|
||||
xcb_setup_failed_t *setup = (xcb_setup_failed_t *) c->setup;
|
||||
write(STDERR_FILENO, xcb_setup_failed_reason(setup), xcb_setup_failed_reason_length(setup));
|
||||
write(STDERR_FILENO, &newline, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -172,6 +205,7 @@ static int read_setup(xcb_connection_t *c)
|
|||
{
|
||||
xcb_setup_authenticate_t *setup = (xcb_setup_authenticate_t *) c->setup;
|
||||
write(STDERR_FILENO, xcb_setup_authenticate_reason(setup), xcb_setup_authenticate_reason_length(setup));
|
||||
write(STDERR_FILENO, &newline, 1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -182,42 +216,87 @@ static int read_setup(xcb_connection_t *c)
|
|||
/* precondition: there must be something for us to write. */
|
||||
static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
int n;
|
||||
#endif
|
||||
|
||||
assert(!c->out.queue_len);
|
||||
|
||||
#ifdef _WIN32
|
||||
int i = 0;
|
||||
int ret = 0,err = 0;
|
||||
struct iovec *vec;
|
||||
n = 0;
|
||||
|
||||
/* Could use the WSASend win32 function for scatter/gather i/o but setting up the WSABUF struct from
|
||||
an iovec would require more work and I'm not sure of the benefit....works for now */
|
||||
vec = *vector;
|
||||
while(i < *count)
|
||||
{
|
||||
ret = send(c->fd,vec->iov_base,vec->iov_len,0);
|
||||
if(ret == SOCKET_ERROR)
|
||||
{
|
||||
err = WSAGetLastError();
|
||||
if(err == WSAEWOULDBLOCK)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
n += ret;
|
||||
*vec++;
|
||||
i++;
|
||||
while (*count)
|
||||
{
|
||||
struct iovec *vec = *vector;
|
||||
if (vec->iov_len)
|
||||
{
|
||||
int ret = send(c->fd, vec->iov_base, vec->iov_len, 0);
|
||||
if (ret == SOCKET_ERROR)
|
||||
{
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (ret <= 0)
|
||||
{
|
||||
_xcb_conn_shutdown(c, XCB_CONN_ERROR);
|
||||
return 0;
|
||||
}
|
||||
c->out.total_written += ret;
|
||||
vec->iov_len -= ret;
|
||||
vec->iov_base = (char *)vec->iov_base + ret;
|
||||
}
|
||||
if (vec->iov_len == 0) {
|
||||
(*vector)++;
|
||||
(*count)--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*count)
|
||||
*vector = 0;
|
||||
|
||||
#else
|
||||
n = *count;
|
||||
if (n > IOV_MAX)
|
||||
n = IOV_MAX;
|
||||
n = IOV_MAX;
|
||||
|
||||
n = writev(c->fd, *vector, n);
|
||||
if(n < 0 && errno == EAGAIN)
|
||||
return 1;
|
||||
#endif /* _WIN32 */
|
||||
#if HAVE_SENDMSG
|
||||
if (c->out.out_fd.nfd) {
|
||||
union {
|
||||
struct cmsghdr cmsghdr;
|
||||
char buf[CMSG_SPACE(XCB_MAX_PASS_FD * sizeof(int))];
|
||||
} cmsgbuf;
|
||||
struct msghdr msg = {
|
||||
.msg_name = NULL,
|
||||
.msg_namelen = 0,
|
||||
.msg_iov = *vector,
|
||||
.msg_iovlen = n,
|
||||
.msg_control = cmsgbuf.buf,
|
||||
.msg_controllen = CMSG_LEN(c->out.out_fd.nfd * sizeof (int)),
|
||||
};
|
||||
int i;
|
||||
struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg);
|
||||
|
||||
hdr->cmsg_len = msg.msg_controllen;
|
||||
hdr->cmsg_level = SOL_SOCKET;
|
||||
hdr->cmsg_type = SCM_RIGHTS;
|
||||
memcpy(CMSG_DATA(hdr), c->out.out_fd.fd, c->out.out_fd.nfd * sizeof (int));
|
||||
|
||||
n = sendmsg(c->fd, &msg, 0);
|
||||
if(n < 0 && errno == EAGAIN)
|
||||
return 1;
|
||||
for (i = 0; i < c->out.out_fd.nfd; i++)
|
||||
close(c->out.out_fd.fd[i]);
|
||||
c->out.out_fd.nfd = 0;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
n = writev(c->fd, *vector, n);
|
||||
if(n < 0 && errno == EAGAIN)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(n <= 0)
|
||||
{
|
||||
|
@ -225,20 +304,26 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
|
|||
return 0;
|
||||
}
|
||||
|
||||
c->out.total_written += n;
|
||||
for(; *count; --*count, ++*vector)
|
||||
{
|
||||
int cur = (*vector)->iov_len;
|
||||
if(cur > n)
|
||||
cur = n;
|
||||
(*vector)->iov_len -= cur;
|
||||
(*vector)->iov_base = (char *) (*vector)->iov_base + cur;
|
||||
n -= cur;
|
||||
if(cur) {
|
||||
(*vector)->iov_len -= cur;
|
||||
(*vector)->iov_base = (char *) (*vector)->iov_base + cur;
|
||||
n -= cur;
|
||||
}
|
||||
if((*vector)->iov_len)
|
||||
break;
|
||||
}
|
||||
if(!*count)
|
||||
*vector = 0;
|
||||
assert(n == 0);
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -246,15 +331,15 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
|
|||
|
||||
const xcb_setup_t *xcb_get_setup(xcb_connection_t *c)
|
||||
{
|
||||
if(c->has_error)
|
||||
return 0;
|
||||
if(is_static_error_conn(c))
|
||||
return &xcb_error_setup;
|
||||
/* doesn't need locking because it's never written to. */
|
||||
return c->setup;
|
||||
}
|
||||
|
||||
int xcb_get_file_descriptor(xcb_connection_t *c)
|
||||
{
|
||||
if(c->has_error)
|
||||
if(is_static_error_conn(c))
|
||||
return -1;
|
||||
/* doesn't need locking because it's never written to. */
|
||||
return c->fd;
|
||||
|
@ -282,7 +367,11 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
|
|||
|
||||
c = calloc(1, sizeof(xcb_connection_t));
|
||||
if(!c) {
|
||||
#ifdef _WIN32
|
||||
closesocket(fd);
|
||||
#else
|
||||
close(fd);
|
||||
#endif
|
||||
return _xcb_conn_ret_error(XCB_CONN_CLOSED_MEM_INSUFFICIENT) ;
|
||||
}
|
||||
|
||||
|
@ -308,14 +397,18 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
|
|||
|
||||
void xcb_disconnect(xcb_connection_t *c)
|
||||
{
|
||||
if(c->has_error)
|
||||
if(c == NULL || is_static_error_conn(c))
|
||||
return;
|
||||
|
||||
free(c->setup);
|
||||
|
||||
/* disallow further sends and receives */
|
||||
shutdown(c->fd, SHUT_RDWR);
|
||||
#ifdef _WIN32
|
||||
closesocket(c->fd);
|
||||
#else
|
||||
close(c->fd);
|
||||
#endif
|
||||
|
||||
pthread_mutex_destroy(&c->iolock);
|
||||
_xcb_in_destroy(&c->in);
|
||||
|
@ -341,6 +434,9 @@ void _xcb_conn_shutdown(xcb_connection_t *c, int err)
|
|||
/* Return connection error state.
|
||||
* To make thread-safe, I need a seperate static
|
||||
* variable for every possible error.
|
||||
* has_error is the first field in xcb_connection_t, so just
|
||||
* return a casted int here; checking has_error (and only
|
||||
* has_error) will be safe.
|
||||
*/
|
||||
xcb_connection_t *_xcb_conn_ret_error(int err)
|
||||
{
|
||||
|
@ -443,14 +539,14 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
|
|||
*/
|
||||
int may_read = c->in.reading == 1 || !count;
|
||||
#if USE_POLL
|
||||
if(may_read && (fd.revents & POLLIN) == POLLIN)
|
||||
if(may_read && (fd.revents & POLLIN) != 0)
|
||||
#else
|
||||
if(may_read && FD_ISSET(c->fd, &rfds))
|
||||
#endif
|
||||
ret = ret && _xcb_in_read(c);
|
||||
|
||||
#if USE_POLL
|
||||
if((fd.revents & POLLOUT) == POLLOUT)
|
||||
if((fd.revents & POLLOUT) != 0)
|
||||
#else
|
||||
if(FD_ISSET(c->fd, &wfds))
|
||||
#endif
|
||||
|
@ -463,3 +559,30 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint64_t xcb_total_read(xcb_connection_t *c)
|
||||
{
|
||||
uint64_t n;
|
||||
|
||||
if (xcb_connection_has_error(c))
|
||||
return 0;
|
||||
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
n = c->in.total_read;
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return n;
|
||||
}
|
||||
|
||||
uint64_t xcb_total_written(xcb_connection_t *c)
|
||||
{
|
||||
uint64_t n;
|
||||
|
||||
if (xcb_connection_has_error(c))
|
||||
return 0;
|
||||
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
n = c->out.total_written;
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
459
src/xcb_in.c
459
src/xcb_in.c
|
@ -32,17 +32,14 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "xcb.h"
|
||||
#include "xcbext.h"
|
||||
#include "xcbint.h"
|
||||
#if USE_POLL
|
||||
#include <poll.h>
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
@ -51,6 +48,10 @@
|
|||
#include "xcb_windefs.h"
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "xcb.h"
|
||||
#include "xcbext.h"
|
||||
#include "xcbint.h"
|
||||
|
||||
#define XCB_ERROR 0
|
||||
#define XCB_REPLY 1
|
||||
#define XCB_XGE_EVENT 35
|
||||
|
@ -60,6 +61,23 @@ struct event_list {
|
|||
struct event_list *next;
|
||||
};
|
||||
|
||||
struct xcb_special_event {
|
||||
|
||||
struct xcb_special_event *next;
|
||||
|
||||
/* Match XGE events for the specific extension and event ID (the
|
||||
* first 32 bit word after evtype)
|
||||
*/
|
||||
uint8_t extension;
|
||||
uint32_t eid;
|
||||
uint32_t *stamp;
|
||||
|
||||
struct event_list *events;
|
||||
struct event_list **events_tail;
|
||||
|
||||
pthread_cond_t special_event_cond;
|
||||
};
|
||||
|
||||
struct reply_list {
|
||||
void *reply;
|
||||
struct reply_list *next;
|
||||
|
@ -79,6 +97,11 @@ typedef struct reader_list {
|
|||
struct reader_list *next;
|
||||
} reader_list;
|
||||
|
||||
typedef struct special_list {
|
||||
xcb_special_event_t *se;
|
||||
struct special_list *next;
|
||||
} special_list;
|
||||
|
||||
static void remove_finished_readers(reader_list **prev_reader, uint64_t completed)
|
||||
{
|
||||
while(*prev_reader && XCB_SEQUENCE_COMPARE((*prev_reader)->request, <=, completed))
|
||||
|
@ -90,11 +113,67 @@ static void remove_finished_readers(reader_list **prev_reader, uint64_t complete
|
|||
}
|
||||
}
|
||||
|
||||
#if HAVE_SENDMSG
|
||||
static int read_fds(xcb_connection_t *c, int *fds, int nfd)
|
||||
{
|
||||
int *ifds = &c->in.in_fd.fd[c->in.in_fd.ifd];
|
||||
int infd = c->in.in_fd.nfd - c->in.in_fd.ifd;
|
||||
|
||||
if (nfd > infd)
|
||||
return 0;
|
||||
memcpy(fds, ifds, nfd * sizeof (int));
|
||||
c->in.in_fd.ifd += nfd;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef struct xcb_ge_special_event_t {
|
||||
uint8_t response_type; /**< */
|
||||
uint8_t extension; /**< */
|
||||
uint16_t sequence; /**< */
|
||||
uint32_t length; /**< */
|
||||
uint16_t evtype; /**< */
|
||||
uint8_t pad0[2]; /**< */
|
||||
uint32_t eid; /**< */
|
||||
uint8_t pad1[16]; /**< */
|
||||
} xcb_ge_special_event_t;
|
||||
|
||||
static int event_special(xcb_connection_t *c,
|
||||
struct event_list *event)
|
||||
{
|
||||
struct xcb_special_event *special_event;
|
||||
struct xcb_ge_special_event_t *ges = (void *) event->event;
|
||||
|
||||
/* Special events are always XGE events */
|
||||
if ((ges->response_type & 0x7f) != XCB_XGE_EVENT)
|
||||
return 0;
|
||||
|
||||
for (special_event = c->in.special_events;
|
||||
special_event;
|
||||
special_event = special_event->next)
|
||||
{
|
||||
if (ges->extension == special_event->extension &&
|
||||
ges->eid == special_event->eid)
|
||||
{
|
||||
*special_event->events_tail = event;
|
||||
special_event->events_tail = &event->next;
|
||||
if (special_event->stamp)
|
||||
++(*special_event->stamp);
|
||||
pthread_cond_signal(&special_event->special_event_cond);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_packet(xcb_connection_t *c)
|
||||
{
|
||||
xcb_generic_reply_t genrep;
|
||||
int length = 32;
|
||||
int eventlength = 0; /* length after first 32 bytes for GenericEvents */
|
||||
uint64_t length = 32;
|
||||
uint64_t eventlength = 0; /* length after first 32 bytes for GenericEvents */
|
||||
int nfd = 0; /* Number of file descriptors attached to the reply */
|
||||
uint64_t bufsize;
|
||||
void *buf;
|
||||
pending_reply *pend = 0;
|
||||
struct event_list *event;
|
||||
|
@ -127,9 +206,9 @@ static int read_packet(xcb_connection_t *c)
|
|||
c->in.request_completed = c->in.request_read - 1;
|
||||
}
|
||||
|
||||
while(c->in.pending_replies &&
|
||||
while(c->in.pending_replies &&
|
||||
c->in.pending_replies->workaround != WORKAROUND_EXTERNAL_SOCKET_OWNER &&
|
||||
XCB_SEQUENCE_COMPARE (c->in.pending_replies->last_request, <=, c->in.request_completed))
|
||||
XCB_SEQUENCE_COMPARE (c->in.pending_replies->last_request, <=, c->in.request_completed))
|
||||
{
|
||||
pending_reply *oldpend = c->in.pending_replies;
|
||||
c->in.pending_replies = oldpend->next;
|
||||
|
@ -160,17 +239,32 @@ static int read_packet(xcb_connection_t *c)
|
|||
if(pend && pend->workaround == WORKAROUND_GLX_GET_FB_CONFIGS_BUG)
|
||||
{
|
||||
uint32_t *p = (uint32_t *) c->in.queue;
|
||||
genrep.length = p[2] * p[3] * 2;
|
||||
uint64_t new_length = ((uint64_t)p[2]) * ((uint64_t)p[3]);
|
||||
if(new_length >= (UINT32_MAX / UINT32_C(16)))
|
||||
{
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT);
|
||||
return 0;
|
||||
}
|
||||
genrep.length = (uint32_t)(new_length * UINT64_C(2));
|
||||
}
|
||||
length += genrep.length * 4;
|
||||
length += genrep.length * UINT64_C(4);
|
||||
|
||||
/* XXX a bit of a hack -- we "know" that all FD replys place
|
||||
* the number of fds in the pad0 byte */
|
||||
if (pend && pend->flags & XCB_REQUEST_REPLY_FDS)
|
||||
nfd = genrep.pad0;
|
||||
}
|
||||
|
||||
/* XGE events may have sizes > 32 */
|
||||
if ((genrep.response_type & 0x7f) == XCB_XGE_EVENT)
|
||||
eventlength = genrep.length * 4;
|
||||
eventlength = genrep.length * UINT64_C(4);
|
||||
|
||||
buf = malloc(length + eventlength +
|
||||
(genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t)));
|
||||
bufsize = length + eventlength + nfd * sizeof(int) +
|
||||
(genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t));
|
||||
if (bufsize < INT32_MAX)
|
||||
buf = malloc((size_t) bufsize);
|
||||
else
|
||||
buf = NULL;
|
||||
if(!buf)
|
||||
{
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT);
|
||||
|
@ -193,6 +287,17 @@ static int read_packet(xcb_connection_t *c)
|
|||
}
|
||||
}
|
||||
|
||||
#if HAVE_SENDMSG
|
||||
if (nfd)
|
||||
{
|
||||
if (!read_fds(c, (int *) &((char *) buf)[length], nfd))
|
||||
{
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(pend && (pend->flags & XCB_REQUEST_DISCARD_REPLY))
|
||||
{
|
||||
free(buf);
|
||||
|
@ -232,9 +337,12 @@ static int read_packet(xcb_connection_t *c)
|
|||
}
|
||||
event->event = buf;
|
||||
event->next = 0;
|
||||
*c->in.events_tail = event;
|
||||
c->in.events_tail = &event->next;
|
||||
pthread_cond_signal(&c->in.event_cond);
|
||||
|
||||
if (!event_special(c, event)) {
|
||||
*c->in.events_tail = event;
|
||||
c->in.events_tail = &event->next;
|
||||
pthread_cond_signal(&c->in.event_cond);
|
||||
}
|
||||
return 1; /* I have something for you... */
|
||||
}
|
||||
|
||||
|
@ -263,7 +371,7 @@ static void free_reply_list(struct reply_list *head)
|
|||
}
|
||||
}
|
||||
|
||||
static int read_block(const int fd, void *buf, const ssize_t len)
|
||||
static int read_block(const int fd, void *buf, const intptr_t len)
|
||||
{
|
||||
int done = 0;
|
||||
while(done < len)
|
||||
|
@ -290,11 +398,11 @@ static int read_block(const int fd, void *buf, const ssize_t len)
|
|||
FD_ZERO(&fds);
|
||||
FD_SET(fd, &fds);
|
||||
|
||||
/* Initializing errno here makes sure that for Win32 this loop will execute only once */
|
||||
errno = 0;
|
||||
do {
|
||||
ret = select(fd + 1, &fds, 0, 0, 0);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
/* Initializing errno here makes sure that for Win32 this loop will execute only once */
|
||||
errno = 0;
|
||||
do {
|
||||
ret = select(fd + 1, &fds, 0, 0, 0);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
#endif /* USE_POLL */
|
||||
}
|
||||
if(ret <= 0)
|
||||
|
@ -378,6 +486,26 @@ static void remove_reader(reader_list **prev_reader, reader_list *reader)
|
|||
}
|
||||
}
|
||||
|
||||
static void insert_special(special_list **prev_special, special_list *special, xcb_special_event_t *se)
|
||||
{
|
||||
special->se = se;
|
||||
special->next = *prev_special;
|
||||
*prev_special = special;
|
||||
}
|
||||
|
||||
static void remove_special(special_list **prev_special, special_list *special)
|
||||
{
|
||||
while(*prev_special)
|
||||
{
|
||||
if(*prev_special == special)
|
||||
{
|
||||
*prev_special = (*prev_special)->next;
|
||||
break;
|
||||
}
|
||||
prev_special = &(*prev_special)->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void *wait_for_reply(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e)
|
||||
{
|
||||
void *ret = 0;
|
||||
|
@ -426,6 +554,25 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
|
|||
return ret;
|
||||
}
|
||||
|
||||
void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e)
|
||||
{
|
||||
void *ret;
|
||||
if(e)
|
||||
*e = 0;
|
||||
if(c->has_error)
|
||||
return 0;
|
||||
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
ret = wait_for_reply(c, request, e);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t reply_size)
|
||||
{
|
||||
return (int *) (&((char *) reply)[reply_size]);
|
||||
}
|
||||
|
||||
static void insert_pending_discard(xcb_connection_t *c, pending_reply **prev_next, uint64_t seq)
|
||||
{
|
||||
pending_reply *pend;
|
||||
|
@ -493,6 +640,20 @@ void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence)
|
|||
pthread_mutex_unlock(&c->iolock);
|
||||
}
|
||||
|
||||
void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence)
|
||||
{
|
||||
if(c->has_error)
|
||||
return;
|
||||
|
||||
/* If an error occurred when issuing the request, fail immediately. */
|
||||
if(!sequence)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
discard_reply(c, sequence);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
}
|
||||
|
||||
int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error)
|
||||
{
|
||||
int ret;
|
||||
|
@ -506,6 +667,27 @@ int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply,
|
|||
assert(reply != 0);
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
ret = poll_for_reply(c, widen(c, request), reply, error);
|
||||
if(!ret && c->in.reading == 0 && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
|
||||
ret = poll_for_reply(c, widen(c, request), reply, error);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error)
|
||||
{
|
||||
int ret;
|
||||
if(c->has_error)
|
||||
{
|
||||
*reply = 0;
|
||||
if(error)
|
||||
*error = 0;
|
||||
return 1; /* would not block */
|
||||
}
|
||||
assert(reply != 0);
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
ret = poll_for_reply(c, request, reply, error);
|
||||
if(!ret && c->in.reading == 0 && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
|
||||
ret = poll_for_reply(c, request, reply, error);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return ret;
|
||||
}
|
||||
|
@ -560,11 +742,16 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
|
|||
return 0;
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
request = widen(c, cookie.sequence);
|
||||
if(XCB_SEQUENCE_COMPARE(request, >=, c->in.request_expected)
|
||||
&& XCB_SEQUENCE_COMPARE(request, >, c->in.request_completed))
|
||||
if (XCB_SEQUENCE_COMPARE(request, >, c->in.request_completed))
|
||||
{
|
||||
_xcb_out_send_sync(c);
|
||||
_xcb_out_flush_to(c, c->out.request);
|
||||
if(XCB_SEQUENCE_COMPARE(request, >=, c->in.request_expected))
|
||||
{
|
||||
_xcb_out_send_sync(c);
|
||||
}
|
||||
if (XCB_SEQUENCE_COMPARE(request, >=, c->out.request_expected_written))
|
||||
{
|
||||
_xcb_out_flush_to(c, c->out.request);
|
||||
}
|
||||
}
|
||||
reply = wait_for_reply(c, request, &ret);
|
||||
assert(!reply);
|
||||
|
@ -572,6 +759,134 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
|
|||
return ret;
|
||||
}
|
||||
|
||||
static xcb_generic_event_t *get_special_event(xcb_connection_t *c,
|
||||
xcb_special_event_t *se)
|
||||
{
|
||||
xcb_generic_event_t *event = NULL;
|
||||
struct event_list *events;
|
||||
|
||||
if ((events = se->events) != NULL) {
|
||||
event = events->event;
|
||||
if (!(se->events = events->next))
|
||||
se->events_tail = &se->events;
|
||||
free (events);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
xcb_generic_event_t *xcb_poll_for_special_event(xcb_connection_t *c,
|
||||
xcb_special_event_t *se)
|
||||
{
|
||||
xcb_generic_event_t *event;
|
||||
|
||||
if(c->has_error)
|
||||
return 0;
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
event = get_special_event(c, se);
|
||||
if(!event && c->in.reading == 0 && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
|
||||
event = get_special_event(c, se);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return event;
|
||||
}
|
||||
|
||||
xcb_generic_event_t *xcb_wait_for_special_event(xcb_connection_t *c,
|
||||
xcb_special_event_t *se)
|
||||
{
|
||||
special_list special;
|
||||
xcb_generic_event_t *event;
|
||||
|
||||
if(c->has_error)
|
||||
return 0;
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
|
||||
insert_special(&c->in.special_waiters, &special, se);
|
||||
|
||||
/* get_special_event returns 0 on empty list. */
|
||||
while(!(event = get_special_event(c, se)))
|
||||
if(!_xcb_conn_wait(c, &se->special_event_cond, 0, 0))
|
||||
break;
|
||||
|
||||
remove_special(&c->in.special_waiters, &special);
|
||||
|
||||
_xcb_in_wake_up_next_reader(c);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return event;
|
||||
}
|
||||
|
||||
xcb_special_event_t *
|
||||
xcb_register_for_special_xge(xcb_connection_t *c,
|
||||
xcb_extension_t *ext,
|
||||
uint32_t eid,
|
||||
uint32_t *stamp)
|
||||
{
|
||||
xcb_special_event_t *se;
|
||||
const xcb_query_extension_reply_t *ext_reply;
|
||||
|
||||
if(c->has_error)
|
||||
return NULL;
|
||||
ext_reply = xcb_get_extension_data(c, ext);
|
||||
if (!ext_reply)
|
||||
return NULL;
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
for (se = c->in.special_events; se; se = se->next) {
|
||||
if (se->extension == ext_reply->major_opcode &&
|
||||
se->eid == eid) {
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
se = calloc(1, sizeof(xcb_special_event_t));
|
||||
if (!se) {
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
se->extension = ext_reply->major_opcode;
|
||||
se->eid = eid;
|
||||
|
||||
se->events = NULL;
|
||||
se->events_tail = &se->events;
|
||||
se->stamp = stamp;
|
||||
|
||||
pthread_cond_init(&se->special_event_cond, 0);
|
||||
|
||||
se->next = c->in.special_events;
|
||||
c->in.special_events = se;
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return se;
|
||||
}
|
||||
|
||||
void
|
||||
xcb_unregister_for_special_event(xcb_connection_t *c,
|
||||
xcb_special_event_t *se)
|
||||
{
|
||||
xcb_special_event_t *s, **prev;
|
||||
struct event_list *events, *next;
|
||||
|
||||
if (!se)
|
||||
return;
|
||||
|
||||
if (c->has_error)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
|
||||
for (prev = &c->in.special_events; (s = *prev) != NULL; prev = &(s->next)) {
|
||||
if (s == se) {
|
||||
*prev = se->next;
|
||||
for (events = se->events; events; events = next) {
|
||||
next = events->next;
|
||||
free (events->event);
|
||||
free (events);
|
||||
}
|
||||
pthread_cond_destroy(&se->special_event_cond);
|
||||
free (se);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
}
|
||||
|
||||
/* Private interface */
|
||||
|
||||
int _xcb_in_init(_xcb_in *in)
|
||||
|
@ -621,6 +936,8 @@ void _xcb_in_wake_up_next_reader(xcb_connection_t *c)
|
|||
int pthreadret;
|
||||
if(c->in.readers)
|
||||
pthreadret = pthread_cond_signal(c->in.readers->data);
|
||||
else if(c->in.special_waiters)
|
||||
pthreadret = pthread_cond_signal(&c->in.special_waiters->se->special_event_cond);
|
||||
else
|
||||
pthreadret = pthread_cond_signal(&c->in.event_cond);
|
||||
assert(pthreadret == 0);
|
||||
|
@ -652,21 +969,101 @@ void _xcb_in_replies_done(xcb_connection_t *c)
|
|||
pend = container_of(c->in.pending_replies_tail, struct pending_reply, next);
|
||||
if(pend->workaround == WORKAROUND_EXTERNAL_SOCKET_OWNER)
|
||||
{
|
||||
pend->last_request = c->out.request;
|
||||
pend->workaround = WORKAROUND_NONE;
|
||||
if (XCB_SEQUENCE_COMPARE(pend->first_request, <=, c->out.request)) {
|
||||
pend->last_request = c->out.request;
|
||||
pend->workaround = WORKAROUND_NONE;
|
||||
} else {
|
||||
/* The socket was taken, but no requests were actually sent
|
||||
* so just discard the pending_reply that was created.
|
||||
*/
|
||||
struct pending_reply **prev_next = &c->in.pending_replies;
|
||||
while (*prev_next != pend)
|
||||
prev_next = &(*prev_next)->next;
|
||||
*prev_next = NULL;
|
||||
c->in.pending_replies_tail = prev_next;
|
||||
free(pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int _xcb_in_read(xcb_connection_t *c)
|
||||
{
|
||||
int n = recv(c->fd, c->in.queue + c->in.queue_len, sizeof(c->in.queue) - c->in.queue_len, 0);
|
||||
if(n > 0)
|
||||
int n;
|
||||
|
||||
#if HAVE_SENDMSG
|
||||
struct iovec iov = {
|
||||
.iov_base = c->in.queue + c->in.queue_len,
|
||||
.iov_len = sizeof(c->in.queue) - c->in.queue_len,
|
||||
};
|
||||
union {
|
||||
struct cmsghdr cmsghdr;
|
||||
char buf[CMSG_SPACE(XCB_MAX_PASS_FD * sizeof(int))];
|
||||
} cmsgbuf;
|
||||
struct msghdr msg = {
|
||||
.msg_name = NULL,
|
||||
.msg_namelen = 0,
|
||||
.msg_iov = &iov,
|
||||
.msg_iovlen = 1,
|
||||
.msg_control = cmsgbuf.buf,
|
||||
.msg_controllen = CMSG_SPACE(sizeof(int) * (XCB_MAX_PASS_FD - c->in.in_fd.nfd)),
|
||||
};
|
||||
n = recvmsg(c->fd, &msg, 0);
|
||||
|
||||
/* Check for truncation errors. Only MSG_CTRUNC is
|
||||
* probably possible here, which would indicate that
|
||||
* the sender tried to transmit more than XCB_MAX_PASS_FD
|
||||
* file descriptors.
|
||||
*/
|
||||
if (msg.msg_flags & (MSG_TRUNC|MSG_CTRUNC)) {
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_FDPASSING_FAILED);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
n = recv(c->fd, c->in.queue + c->in.queue_len, sizeof(c->in.queue) - c->in.queue_len, 0);
|
||||
#endif
|
||||
if(n > 0) {
|
||||
#if HAVE_SENDMSG
|
||||
struct cmsghdr *hdr;
|
||||
|
||||
if (msg.msg_controllen >= sizeof (struct cmsghdr)) {
|
||||
for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) {
|
||||
if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) {
|
||||
int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int);
|
||||
memcpy(&c->in.in_fd.fd[c->in.in_fd.nfd], CMSG_DATA(hdr), nfd * sizeof (int));
|
||||
c->in.in_fd.nfd += nfd;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
c->in.total_read += n;
|
||||
c->in.queue_len += n;
|
||||
}
|
||||
while(read_packet(c))
|
||||
/* empty */;
|
||||
#if HAVE_SENDMSG
|
||||
if (c->in.in_fd.nfd) {
|
||||
c->in.in_fd.nfd -= c->in.in_fd.ifd;
|
||||
memmove(&c->in.in_fd.fd[0],
|
||||
&c->in.in_fd.fd[c->in.in_fd.ifd],
|
||||
c->in.in_fd.nfd * sizeof (int));
|
||||
c->in.in_fd.ifd = 0;
|
||||
|
||||
/* If we have any left-over file descriptors after emptying
|
||||
* the input buffer, then the server sent some that we weren't
|
||||
* expecting. Close them and mark the connection as broken;
|
||||
*/
|
||||
if (c->in.queue_len == 0 && c->in.in_fd.nfd != 0) {
|
||||
int i;
|
||||
for (i = 0; i < c->in.in_fd.nfd; i++)
|
||||
close(c->in.in_fd.fd[i]);
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_FDPASSING_FAILED);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
if((n > 0) || (n < 0 && errno == EAGAIN))
|
||||
if((n > 0) || (n < 0 && (errno == EAGAIN || errno == EINTR)))
|
||||
#else
|
||||
if((n > 0) || (n < 0 && WSAGetLastError() == WSAEWOULDBLOCK))
|
||||
#endif /* !_WIN32 */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
typedef struct node {
|
||||
struct node *next;
|
||||
unsigned int key;
|
||||
uint64_t key;
|
||||
void *data;
|
||||
} node;
|
||||
|
||||
|
@ -47,7 +47,7 @@ struct _xcb_map {
|
|||
|
||||
/* Private interface */
|
||||
|
||||
_xcb_map *_xcb_map_new()
|
||||
_xcb_map *_xcb_map_new(void)
|
||||
{
|
||||
_xcb_map *list;
|
||||
list = malloc(sizeof(_xcb_map));
|
||||
|
@ -73,7 +73,7 @@ void _xcb_map_delete(_xcb_map *list, xcb_list_free_func_t do_free)
|
|||
free(list);
|
||||
}
|
||||
|
||||
int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
|
||||
int _xcb_map_put(_xcb_map *list, uint64_t key, void *data)
|
||||
{
|
||||
node *cur = malloc(sizeof(node));
|
||||
if(!cur)
|
||||
|
@ -86,7 +86,7 @@ int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void *_xcb_map_remove(_xcb_map *list, unsigned int key)
|
||||
void *_xcb_map_remove(_xcb_map *list, uint64_t key)
|
||||
{
|
||||
node **cur;
|
||||
for(cur = &list->head; *cur; cur = &(*cur)->next)
|
||||
|
|
165
src/xcb_out.c
165
src/xcb_out.c
|
@ -31,7 +31,11 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "xcb.h"
|
||||
|
@ -103,6 +107,33 @@ static void get_socket_back(xcb_connection_t *c)
|
|||
_xcb_in_replies_done(c);
|
||||
}
|
||||
|
||||
static void prepare_socket_request(xcb_connection_t *c)
|
||||
{
|
||||
/* We're about to append data to out.queue, so we need to
|
||||
* atomically test for an external socket owner *and* some other
|
||||
* thread currently writing.
|
||||
*
|
||||
* If we have an external socket owner, we have to get the socket back
|
||||
* before we can use it again.
|
||||
*
|
||||
* If some other thread is writing to the socket, we assume it's
|
||||
* writing from out.queue, and so we can't stick data there.
|
||||
*
|
||||
* We satisfy this condition by first calling get_socket_back
|
||||
* (which may drop the lock, but will return when XCB owns the
|
||||
* socket again) and then checking for another writing thread and
|
||||
* escaping the loop if we're ready to go.
|
||||
*/
|
||||
for (;;) {
|
||||
if(c->has_error)
|
||||
return;
|
||||
get_socket_back(c);
|
||||
if (!c->out.writing)
|
||||
break;
|
||||
pthread_cond_wait(&c->out.cond, &c->iolock);
|
||||
}
|
||||
}
|
||||
|
||||
/* Public interface */
|
||||
|
||||
void xcb_prefetch_maximum_request_length(xcb_connection_t *c)
|
||||
|
@ -150,15 +181,59 @@ uint32_t xcb_get_maximum_request_length(xcb_connection_t *c)
|
|||
return c->out.maximum_request_length.value;
|
||||
}
|
||||
|
||||
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
|
||||
static void close_fds(int *fds, unsigned int num_fds)
|
||||
{
|
||||
for (unsigned int index = 0; index < num_fds; index++)
|
||||
close(fds[index]);
|
||||
}
|
||||
|
||||
static void send_fds(xcb_connection_t *c, int *fds, unsigned int num_fds)
|
||||
{
|
||||
#if HAVE_SENDMSG
|
||||
/* Calling _xcb_out_flush_to() can drop the iolock and wait on a condition
|
||||
* variable if another thread is currently writing (c->out.writing > 0).
|
||||
* This call waits for writers to be done and thus _xcb_out_flush_to() will
|
||||
* do the work itself (in which case we are a writer and
|
||||
* prepare_socket_request() will wait for us to be done if another threads
|
||||
* tries to send fds, too). Thanks to this, we can atomically write out FDs.
|
||||
*/
|
||||
prepare_socket_request(c);
|
||||
|
||||
while (num_fds > 0) {
|
||||
while (c->out.out_fd.nfd == XCB_MAX_PASS_FD && !c->has_error) {
|
||||
/* XXX: if c->out.writing > 0, this releases the iolock and
|
||||
* potentially allows other threads to interfere with their own fds.
|
||||
*/
|
||||
_xcb_out_flush_to(c, c->out.request);
|
||||
|
||||
if (c->out.out_fd.nfd == XCB_MAX_PASS_FD) {
|
||||
/* We need some request to send FDs with */
|
||||
_xcb_out_send_sync(c);
|
||||
}
|
||||
}
|
||||
if (c->has_error)
|
||||
break;
|
||||
|
||||
c->out.out_fd.fd[c->out.out_fd.nfd++] = fds[0];
|
||||
fds++;
|
||||
num_fds--;
|
||||
}
|
||||
#endif
|
||||
close_fds(fds, num_fds);
|
||||
}
|
||||
|
||||
uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
|
||||
const xcb_protocol_request_t *req, unsigned int num_fds, int *fds)
|
||||
{
|
||||
uint64_t request;
|
||||
uint32_t prefix[2];
|
||||
int veclen = req->count;
|
||||
enum workarounds workaround = WORKAROUND_NONE;
|
||||
|
||||
if(c->has_error)
|
||||
if(c->has_error) {
|
||||
close_fds(fds, num_fds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(c != 0);
|
||||
assert(vector != 0);
|
||||
|
@ -177,6 +252,7 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
|
|||
const xcb_query_extension_reply_t *extension = xcb_get_extension_data(c, req->ext);
|
||||
if(!(extension && extension->present))
|
||||
{
|
||||
close_fds(fds, num_fds);
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_EXT_NOTSUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
@ -207,6 +283,7 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
|
|||
}
|
||||
else if(longlen > xcb_get_maximum_request_length(c))
|
||||
{
|
||||
close_fds(fds, num_fds);
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_REQ_LEN_EXCEED);
|
||||
return 0; /* server can't take this; maybe need BIGREQUESTS? */
|
||||
}
|
||||
|
@ -236,30 +313,66 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
|
|||
|
||||
/* get a sequence number and arrange for delivery. */
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
/* wait for other writing threads to get out of my way. */
|
||||
while(c->out.writing)
|
||||
pthread_cond_wait(&c->out.cond, &c->iolock);
|
||||
get_socket_back(c);
|
||||
|
||||
/* send FDs before establishing a good request number, because this might
|
||||
* call send_sync(), too
|
||||
*/
|
||||
send_fds(c, fds, num_fds);
|
||||
|
||||
prepare_socket_request(c);
|
||||
|
||||
/* send GetInputFocus (sync_req) when 64k-2 requests have been sent without
|
||||
* a reply. */
|
||||
if(req->isvoid && c->out.request == c->in.request_expected + (1 << 16) - 2)
|
||||
send_sync(c);
|
||||
/* Also send sync_req (could use NoOp) at 32-bit wrap to avoid having
|
||||
* a reply.
|
||||
* Also send sync_req (could use NoOp) at 32-bit wrap to avoid having
|
||||
* applications see sequence 0 as that is used to indicate
|
||||
* an error in sending the request */
|
||||
if((unsigned int) (c->out.request + 1) == 0)
|
||||
send_sync(c);
|
||||
* an error in sending the request
|
||||
*/
|
||||
|
||||
while ((req->isvoid && c->out.request == c->in.request_expected + (1 << 16) - 2) ||
|
||||
(unsigned int) (c->out.request + 1) == 0)
|
||||
{
|
||||
send_sync(c);
|
||||
prepare_socket_request(c);
|
||||
}
|
||||
|
||||
/* The above send_sync calls could drop the I/O lock, but this
|
||||
* thread will still exclude any other thread that tries to write,
|
||||
* so the sequence number postconditions still hold. */
|
||||
send_request(c, req->isvoid, workaround, flags, vector, veclen);
|
||||
request = c->has_error ? 0 : c->out.request;
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
return request;
|
||||
}
|
||||
|
||||
/* request number are actually uint64_t internally but keep API compat with unsigned int */
|
||||
unsigned int xcb_send_request_with_fds(xcb_connection_t *c, int flags, struct iovec *vector,
|
||||
const xcb_protocol_request_t *req, unsigned int num_fds, int *fds)
|
||||
{
|
||||
return xcb_send_request_with_fds64(c, flags, vector, req, num_fds, fds);
|
||||
}
|
||||
|
||||
uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
|
||||
{
|
||||
return xcb_send_request_with_fds64(c, flags, vector, req, 0, NULL);
|
||||
}
|
||||
|
||||
/* request number are actually uint64_t internally but keep API compat with unsigned int */
|
||||
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
|
||||
{
|
||||
return xcb_send_request64(c, flags, vector, req);
|
||||
}
|
||||
|
||||
void
|
||||
xcb_send_fd(xcb_connection_t *c, int fd)
|
||||
{
|
||||
int fds[1] = { fd };
|
||||
|
||||
if (c->has_error) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
send_fds(c, &fds[0], 1);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
}
|
||||
|
||||
int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent)
|
||||
{
|
||||
int ret;
|
||||
|
@ -278,8 +391,14 @@ int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), v
|
|||
{
|
||||
c->out.return_socket = return_socket;
|
||||
c->out.socket_closure = closure;
|
||||
if(flags)
|
||||
_xcb_in_expect_reply(c, c->out.request, WORKAROUND_EXTERNAL_SOCKET_OWNER, flags);
|
||||
if(flags) {
|
||||
/* c->out.request + 1 will be the first request sent by the external
|
||||
* socket owner. If the socket is returned before this request is sent
|
||||
* it will be detected in _xcb_in_replies_done and this pending_reply
|
||||
* will be discarded.
|
||||
*/
|
||||
_xcb_in_expect_reply(c, c->out.request + 1, WORKAROUND_EXTERNAL_SOCKET_OWNER, flags);
|
||||
}
|
||||
assert(c->out.request == c->out.request_written);
|
||||
*sent = c->out.request;
|
||||
}
|
||||
|
@ -328,6 +447,7 @@ int _xcb_out_init(_xcb_out *out)
|
|||
|
||||
out->request = 0;
|
||||
out->request_written = 0;
|
||||
out->request_expected_written = 0;
|
||||
|
||||
if(pthread_mutex_init(&out->reqlenlock, 0))
|
||||
return 0;
|
||||
|
@ -338,8 +458,9 @@ int _xcb_out_init(_xcb_out *out)
|
|||
|
||||
void _xcb_out_destroy(_xcb_out *out)
|
||||
{
|
||||
pthread_cond_destroy(&out->cond);
|
||||
pthread_mutex_destroy(&out->reqlenlock);
|
||||
pthread_cond_destroy(&out->cond);
|
||||
pthread_cond_destroy(&out->socket_cond);
|
||||
}
|
||||
|
||||
int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
|
||||
|
@ -348,6 +469,7 @@ int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
|
|||
while(ret && count)
|
||||
ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
|
||||
c->out.request_written = c->out.request;
|
||||
c->out.request_expected_written = c->in.request_expected;
|
||||
pthread_cond_broadcast(&c->out.cond);
|
||||
_xcb_in_wake_up_next_reader(c);
|
||||
return ret;
|
||||
|
@ -355,10 +477,7 @@ int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
|
|||
|
||||
void _xcb_out_send_sync(xcb_connection_t *c)
|
||||
{
|
||||
/* wait for other writing threads to get out of my way. */
|
||||
while(c->out.writing)
|
||||
pthread_cond_wait(&c->out.cond, &c->iolock);
|
||||
get_socket_back(c);
|
||||
prepare_socket_request(c);
|
||||
send_sync(c);
|
||||
}
|
||||
|
||||
|
|
268
src/xcb_util.c
268
src/xcb_util.c
|
@ -36,12 +36,12 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "xcb_windefs.h"
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
@ -60,12 +60,27 @@
|
|||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef __has_builtin
|
||||
# define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
int xcb_popcount(uint32_t mask)
|
||||
{
|
||||
#if __has_builtin(__builtin_popcount)
|
||||
return __builtin_popcount(mask);
|
||||
#else
|
||||
/*
|
||||
* Count the number of bits set to 1 in a 32-bit word.
|
||||
* Algorithm from MIT AI Lab Memo 239: "HAKMEM", ITEM 169.
|
||||
* https://dspace.mit.edu/handle/1721.1/6086
|
||||
*/
|
||||
uint32_t y;
|
||||
y = (mask >> 1) & 033333333333;
|
||||
y = mask - y - ((y >> 1) & 033333333333);
|
||||
return ((y + (y >> 3)) & 030707070707) % 077;
|
||||
#endif
|
||||
}
|
||||
|
||||
int xcb_sumof(uint8_t *list, int len)
|
||||
|
@ -78,6 +93,70 @@ int xcb_sumof(uint8_t *list, int len)
|
|||
return s;
|
||||
}
|
||||
|
||||
/* Return true and parse if name matches <path to socket>[.<screen>]
|
||||
* Upon success:
|
||||
* host = <path to socket>
|
||||
* protocol = "unix"
|
||||
* display = 0
|
||||
* screen = <screen>
|
||||
*/
|
||||
static int _xcb_parse_display_path_to_socket(const char *name, char **host, char **protocol,
|
||||
int *displayp, int *screenp)
|
||||
{
|
||||
struct stat sbuf;
|
||||
/* In addition to the AF_UNIX path, there may be a screen number.
|
||||
* The trailing \0 is already accounted in the size of sun_path. */
|
||||
char path[sizeof(((struct sockaddr_un*)0)->sun_path) + 1 + 10];
|
||||
size_t len;
|
||||
int _screen = 0, res;
|
||||
|
||||
len = strlen(name);
|
||||
if (len >= sizeof(path))
|
||||
return 0;
|
||||
memcpy(path, name, len + 1);
|
||||
res = stat(path, &sbuf);
|
||||
if (0 != res) {
|
||||
unsigned long lscreen;
|
||||
char *dot, *endptr;
|
||||
if (res != -1 || (errno != ENOENT && errno != ENOTDIR))
|
||||
return 0;
|
||||
dot = strrchr(path, '.');
|
||||
if (!dot || dot[1] < '1' || dot[1] > '9')
|
||||
return 0;
|
||||
*dot = '\0';
|
||||
errno = 0;
|
||||
lscreen = strtoul(dot + 1, &endptr, 10);
|
||||
if (lscreen > INT_MAX || !endptr || *endptr || errno)
|
||||
return 0;
|
||||
if (0 != stat(path, &sbuf))
|
||||
return 0;
|
||||
_screen = (int)lscreen;
|
||||
}
|
||||
|
||||
if (host) {
|
||||
*host = strdup(path);
|
||||
if (!*host)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (protocol) {
|
||||
*protocol = strdup("unix");
|
||||
if (!*protocol) {
|
||||
if (host)
|
||||
free(*host);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayp)
|
||||
*displayp = 0;
|
||||
|
||||
if (screenp)
|
||||
*screenp = _screen;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _xcb_parse_display(const char *name, char **host, char **protocol,
|
||||
int *displayp, int *screenp)
|
||||
{
|
||||
|
@ -89,11 +168,13 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol,
|
|||
if(!name)
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_LAUNCHD
|
||||
if(strncmp(name, "/tmp/launch", 11) == 0)
|
||||
slash = NULL;
|
||||
else
|
||||
#endif
|
||||
/* First check for <path to socket>[.<screen>] */
|
||||
if (name[0] == '/')
|
||||
return _xcb_parse_display_path_to_socket(name, host, protocol, displayp, screenp);
|
||||
|
||||
if (strncmp(name, "unix:", 5) == 0)
|
||||
return _xcb_parse_display_path_to_socket(name + 5, host, protocol, displayp, screenp);
|
||||
|
||||
slash = strrchr(name, '/');
|
||||
|
||||
if (slash) {
|
||||
|
@ -168,79 +249,86 @@ static int _xcb_open_abstract(char *protocol, const char *file, size_t filelen);
|
|||
static int _xcb_open(const char *host, char *protocol, const int display)
|
||||
{
|
||||
int fd;
|
||||
#ifdef __hpux
|
||||
static const char unix_base[] = "/usr/spool/sockets/X11/";
|
||||
#else
|
||||
static const char unix_base[] = "/tmp/.X11-unix/X";
|
||||
#endif
|
||||
const char *base = unix_base;
|
||||
size_t filelen;
|
||||
char *file = NULL;
|
||||
int actual_filelen;
|
||||
|
||||
#ifdef HAVE_LAUNCHD
|
||||
if(strncmp(host, "/tmp/launch", 11) == 0) {
|
||||
base = host;
|
||||
host = "";
|
||||
protocol = "unix";
|
||||
}
|
||||
#ifndef _WIN32
|
||||
if (protocol && strcmp("unix", protocol) == 0 && host && host[0] == '/') {
|
||||
/* Full path to socket provided, ignore everything else */
|
||||
filelen = strlen(host) + 1;
|
||||
if (filelen > INT_MAX)
|
||||
return -1;
|
||||
file = malloc(filelen);
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
memcpy(file, host, filelen);
|
||||
actual_filelen = (int)(filelen - 1);
|
||||
} else {
|
||||
#endif
|
||||
|
||||
/* If protocol or host is "unix", fall through to Unix socket code below */
|
||||
if ((!protocol || (strcmp("unix",protocol) != 0)) &&
|
||||
(*host != '\0') && (strcmp("unix",host) != 0))
|
||||
{
|
||||
/* display specifies TCP */
|
||||
unsigned short port = X_TCP_PORT + display;
|
||||
return _xcb_open_tcp(host, protocol, port);
|
||||
}
|
||||
/* If protocol or host is "unix", fall through to Unix socket code below */
|
||||
if ((!protocol || (strcmp("unix",protocol) != 0)) &&
|
||||
(*host != '\0') && (strcmp("unix",host) != 0))
|
||||
{
|
||||
/* display specifies TCP */
|
||||
unsigned short port = X_TCP_PORT + display;
|
||||
return _xcb_open_tcp(host, protocol, port);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
#if defined(HAVE_TSOL_LABEL_H) && defined(HAVE_IS_SYSTEM_LABELED)
|
||||
/* Check special path for Unix sockets under Solaris Trusted Extensions */
|
||||
if (is_system_labeled())
|
||||
{
|
||||
struct stat sbuf;
|
||||
const char *tsol_base = "/var/tsol/doors/.X11-unix/X";
|
||||
char tsol_socket[PATH_MAX];
|
||||
/* Check special path for Unix sockets under Solaris Trusted Extensions */
|
||||
if (is_system_labeled())
|
||||
{
|
||||
const char *tsol_base = "/var/tsol/doors/.X11-unix/X";
|
||||
char tsol_socket[PATH_MAX];
|
||||
struct stat sbuf;
|
||||
|
||||
snprintf(tsol_socket, sizeof(tsol_socket), "%s%d", tsol_base, display);
|
||||
snprintf(tsol_socket, sizeof(tsol_socket), "%s%d", tsol_base, display);
|
||||
|
||||
if (stat(tsol_socket, &sbuf) == 0)
|
||||
base = tsol_base;
|
||||
}
|
||||
if (stat(tsol_socket, &sbuf) == 0)
|
||||
base = tsol_base;
|
||||
else if (errno != ENOENT)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
filelen = strlen(base) + 1 + sizeof(display) * 3 + 1;
|
||||
file = malloc(filelen);
|
||||
if(file == NULL)
|
||||
return -1;
|
||||
filelen = strlen(base) + 1 + sizeof(display) * 3 + 1;
|
||||
file = malloc(filelen);
|
||||
if(file == NULL)
|
||||
return -1;
|
||||
|
||||
/* display specifies Unix socket */
|
||||
#ifdef HAVE_LAUNCHD
|
||||
if(strncmp(base, "/tmp/launch", 11) == 0)
|
||||
actual_filelen = snprintf(file, filelen, "%s:%d", base, display);
|
||||
else
|
||||
#endif
|
||||
/* display specifies Unix socket */
|
||||
actual_filelen = snprintf(file, filelen, "%s%d", base, display);
|
||||
if(actual_filelen < 0)
|
||||
{
|
||||
free(file);
|
||||
return -1;
|
||||
}
|
||||
/* snprintf may truncate the file */
|
||||
filelen = MIN(actual_filelen, filelen - 1);
|
||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||
fd = _xcb_open_abstract(protocol, file, filelen);
|
||||
if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
|
||||
{
|
||||
free(file);
|
||||
return fd;
|
||||
}
|
||||
|
||||
if(actual_filelen < 0)
|
||||
{
|
||||
free(file);
|
||||
return -1;
|
||||
}
|
||||
/* snprintf may truncate the file */
|
||||
filelen = MIN(actual_filelen, filelen - 1);
|
||||
#ifdef HAVE_ABSTRACT_SOCKETS
|
||||
fd = _xcb_open_abstract(protocol, file, filelen);
|
||||
if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
|
||||
{
|
||||
free(file);
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
fd = _xcb_open_unix(protocol, file);
|
||||
free(file);
|
||||
|
||||
if (fd < 0 && !protocol && *host == '\0') {
|
||||
unsigned short port = X_TCP_PORT + display;
|
||||
fd = _xcb_open_tcp(host, protocol, port);
|
||||
unsigned short port = X_TCP_PORT + display;
|
||||
fd = _xcb_open_tcp(host, protocol, port);
|
||||
}
|
||||
|
||||
return fd;
|
||||
|
@ -257,10 +345,10 @@ static int _xcb_socket(int family, int type, int proto)
|
|||
if (fd == -1 && errno == EINVAL)
|
||||
#endif
|
||||
{
|
||||
fd = socket(family, type, proto);
|
||||
fd = socket(family, type, proto);
|
||||
#ifndef _WIN32
|
||||
if (fd >= 0)
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
if (fd >= 0)
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
#endif
|
||||
}
|
||||
return fd;
|
||||
|
@ -268,15 +356,15 @@ static int _xcb_socket(int family, int type, int proto)
|
|||
|
||||
|
||||
static int _xcb_do_connect(int fd, const struct sockaddr* addr, int addrlen) {
|
||||
int on = 1;
|
||||
int on = 1;
|
||||
|
||||
if(fd < 0)
|
||||
return -1;
|
||||
if(fd < 0)
|
||||
return -1;
|
||||
|
||||
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
|
||||
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
|
||||
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
|
||||
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
|
||||
|
||||
return connect(fd, addr, addrlen);
|
||||
return connect(fd, addr, addrlen);
|
||||
}
|
||||
|
||||
static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short port)
|
||||
|
@ -291,13 +379,13 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short
|
|||
|
||||
if (protocol && strcmp("tcp",protocol) && strcmp("inet",protocol)
|
||||
#ifdef AF_INET6
|
||||
&& strcmp("inet6",protocol)
|
||||
&& strcmp("inet6",protocol)
|
||||
#endif
|
||||
)
|
||||
)
|
||||
return -1;
|
||||
|
||||
|
||||
if (*host == '\0')
|
||||
host = "localhost";
|
||||
host = "localhost";
|
||||
|
||||
#if HAVE_GETADDRINFO
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
|
@ -328,7 +416,11 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short
|
|||
fd = _xcb_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
|
||||
if (_xcb_do_connect(fd, addr->ai_addr, addr->ai_addrlen) >= 0)
|
||||
break;
|
||||
#ifdef _WIN32
|
||||
closesocket(fd);
|
||||
#else
|
||||
close(fd);
|
||||
#endif
|
||||
fd = -1;
|
||||
}
|
||||
freeaddrinfo(results);
|
||||
|
@ -354,7 +446,11 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short
|
|||
if(_xcb_do_connect(fd, (struct sockaddr*)&_s, sizeof(_s)) >= 0)
|
||||
break;
|
||||
|
||||
#ifdef _WIN32
|
||||
closesocket(fd);
|
||||
#else
|
||||
close(fd);
|
||||
#endif
|
||||
fd = -1;
|
||||
++_c;
|
||||
}
|
||||
|
@ -369,6 +465,8 @@ static int _xcb_open_unix(char *protocol, const char *file)
|
|||
{
|
||||
int fd;
|
||||
struct sockaddr_un addr;
|
||||
socklen_t len = sizeof(int);
|
||||
int val;
|
||||
|
||||
if (protocol && strcmp("unix",protocol))
|
||||
return -1;
|
||||
|
@ -381,6 +479,11 @@ static int _xcb_open_unix(char *protocol, const char *file)
|
|||
fd = _xcb_socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if(fd == -1)
|
||||
return -1;
|
||||
if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) == 0 && val < 64 * 1024)
|
||||
{
|
||||
val = 64 * 1024;
|
||||
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, sizeof(int));
|
||||
}
|
||||
if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
|
||||
close(fd);
|
||||
return -1;
|
||||
|
@ -430,21 +533,22 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
|
|||
xcb_connection_t *c;
|
||||
|
||||
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
|
||||
|
||||
|
||||
if(!parsed) {
|
||||
c = _xcb_conn_ret_error(XCB_CONN_CLOSED_PARSE_ERR);
|
||||
goto out;
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
|
||||
c = _xcb_conn_ret_error(XCB_CONN_ERROR);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
fd = _xcb_open(host, protocol, display);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
|
||||
c = _xcb_conn_ret_error(XCB_CONN_ERROR);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
fd = _xcb_open(host, protocol, display);
|
||||
|
||||
if(fd == -1) {
|
||||
c = _xcb_conn_ret_error(XCB_CONN_ERROR);
|
||||
#ifdef _WIN32
|
||||
|
@ -455,10 +559,8 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
|
|||
|
||||
if(auth) {
|
||||
c = xcb_connect_to_fd(fd, auth);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(_xcb_get_auth_info(fd, &ourauth, display))
|
||||
else if(_xcb_get_auth_info(fd, &ourauth, display))
|
||||
{
|
||||
c = xcb_connect_to_fd(fd, &ourauth);
|
||||
free(ourauth.name);
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
#include <windef.h>
|
||||
|
||||
struct iovec {
|
||||
void *iov_base; /* Pointer to data. */
|
||||
int iov_len; /* Length of data. */
|
||||
void *iov_base; /* Pointer to data. */
|
||||
int iov_len; /* Length of data. */
|
||||
};
|
||||
|
||||
typedef unsigned int in_addr_t;
|
||||
|
|
|
@ -55,7 +55,7 @@ uint32_t xcb_generate_id(xcb_connection_t *c)
|
|||
/* 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) {
|
||||
if (!xc_misc_reply || !xc_misc_reply->present) {
|
||||
pthread_mutex_unlock(&c->xid.lock);
|
||||
return -1;
|
||||
}
|
||||
|
|
233
src/xcbext.h
233
src/xcbext.h
|
@ -54,12 +54,147 @@ typedef struct {
|
|||
enum xcb_send_request_flags_t {
|
||||
XCB_REQUEST_CHECKED = 1 << 0,
|
||||
XCB_REQUEST_RAW = 1 << 1,
|
||||
XCB_REQUEST_DISCARD_REPLY = 1 << 2
|
||||
XCB_REQUEST_DISCARD_REPLY = 1 << 2,
|
||||
XCB_REQUEST_REPLY_FDS = 1 << 3
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Send a request to the server.
|
||||
* @param c The connection to the X server.
|
||||
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
|
||||
* @param vector Data to send; must have two iovecs before start for internal use.
|
||||
* @param request Information about the request to be sent.
|
||||
* @return The request's sequence number on success, 0 otherwise.
|
||||
*
|
||||
* This function sends a new request to the X server. The data of the request is
|
||||
* given as an array of @c iovecs in the @p vector argument. The length of that
|
||||
* array and the necessary management information are given in the @p request
|
||||
* argument.
|
||||
*
|
||||
* When this function returns, the request might or might not be sent already.
|
||||
* Use xcb_flush() to make sure that it really was sent.
|
||||
*
|
||||
* Please note that this function is not the preferred way for sending requests.
|
||||
* It's better to use the generated wrapper functions.
|
||||
*
|
||||
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
|
||||
* so they must be valid!
|
||||
*/
|
||||
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
|
||||
|
||||
/* xcb_take_socket allows external code to ask XCB for permission to
|
||||
/**
|
||||
* @brief Send a request to the server.
|
||||
* @param c The connection to the X server.
|
||||
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
|
||||
* @param vector Data to send; must have two iovecs before start for internal use.
|
||||
* @param request Information about the request to be sent.
|
||||
* @param num_fds Number of additional file descriptors to send to the server
|
||||
* @param fds Additional file descriptors that should be send to the server.
|
||||
* @return The request's sequence number on success, 0 otherwise.
|
||||
*
|
||||
* This function sends a new request to the X server. The data of the request is
|
||||
* given as an array of @c iovecs in the @p vector argument. The length of that
|
||||
* array and the necessary management information are given in the @p request
|
||||
* argument.
|
||||
*
|
||||
* If @p num_fds is non-zero, @p fds points to an array of file descriptors that
|
||||
* will be sent to the X server along with this request. After this function
|
||||
* returns, all file descriptors sent are owned by xcb and will be closed
|
||||
* eventually.
|
||||
*
|
||||
* When this function returns, the request might or might not be sent already.
|
||||
* Use xcb_flush() to make sure that it really was sent.
|
||||
*
|
||||
* Please note that this function is not the preferred way for sending requests.
|
||||
*
|
||||
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
|
||||
* so they must be valid!
|
||||
*/
|
||||
unsigned int xcb_send_request_with_fds(xcb_connection_t *c, int flags, struct iovec *vector,
|
||||
const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
|
||||
|
||||
/**
|
||||
* @brief Send a request to the server, with 64-bit sequence number returned.
|
||||
* @param c The connection to the X server.
|
||||
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
|
||||
* @param vector Data to send; must have two iovecs before start for internal use.
|
||||
* @param request Information about the request to be sent.
|
||||
* @return The request's sequence number on success, 0 otherwise.
|
||||
*
|
||||
* This function sends a new request to the X server. The data of the request is
|
||||
* given as an array of @c iovecs in the @p vector argument. The length of that
|
||||
* array and the necessary management information are given in the @p request
|
||||
* argument.
|
||||
*
|
||||
* When this function returns, the request might or might not be sent already.
|
||||
* Use xcb_flush() to make sure that it really was sent.
|
||||
*
|
||||
* Please note that this function is not the preferred way for sending requests.
|
||||
* It's better to use the generated wrapper functions.
|
||||
*
|
||||
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
|
||||
* so they must be valid!
|
||||
*/
|
||||
uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
|
||||
|
||||
/**
|
||||
* @brief Send a request to the server, with 64-bit sequence number returned.
|
||||
* @param c The connection to the X server.
|
||||
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
|
||||
* @param vector Data to send; must have two iovecs before start for internal use.
|
||||
* @param request Information about the request to be sent.
|
||||
* @param num_fds Number of additional file descriptors to send to the server
|
||||
* @param fds Additional file descriptors that should be send to the server.
|
||||
* @return The request's sequence number on success, 0 otherwise.
|
||||
*
|
||||
* This function sends a new request to the X server. The data of the request is
|
||||
* given as an array of @c iovecs in the @p vector argument. The length of that
|
||||
* array and the necessary management information are given in the @p request
|
||||
* argument.
|
||||
*
|
||||
* If @p num_fds is non-zero, @p fds points to an array of file descriptors that
|
||||
* will be sent to the X server along with this request. After this function
|
||||
* returns, all file descriptors sent are owned by xcb and will be closed
|
||||
* eventually.
|
||||
*
|
||||
* When this function returns, the request might or might not be sent already.
|
||||
* Use xcb_flush() to make sure that it really was sent.
|
||||
*
|
||||
* Please note that this function is not the preferred way for sending requests.
|
||||
* It's better to use the generated wrapper functions.
|
||||
*
|
||||
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
|
||||
* so they must be valid!
|
||||
*/
|
||||
uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
|
||||
const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
|
||||
|
||||
/**
|
||||
* @brief Send a file descriptor to the server in the next call to xcb_send_request.
|
||||
* @param c The connection to the X server.
|
||||
* @param fd The file descriptor to send.
|
||||
*
|
||||
* After this function returns, the file descriptor given is owned by xcb and
|
||||
* will be closed eventually.
|
||||
*
|
||||
* @deprecated This function cannot be used in a thread-safe way. Two threads
|
||||
* that run xcb_send_fd(); xcb_send_request(); could mix up their file
|
||||
* descriptors. Instead, xcb_send_request_with_fds() should be used.
|
||||
*/
|
||||
void xcb_send_fd(xcb_connection_t *c, int fd);
|
||||
|
||||
/**
|
||||
* @brief Take over the write side of the socket
|
||||
* @param c The connection to the X server.
|
||||
* @param return_socket Callback function that will be called when xcb wants
|
||||
* to use the socket again.
|
||||
* @param closure Argument to the callback function.
|
||||
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
|
||||
* @param sent Location to the sequence number of the last sequence request.
|
||||
* Must not be NULL.
|
||||
* @return 1 on success, else 0.
|
||||
*
|
||||
* xcb_take_socket allows external code to ask XCB for permission to
|
||||
* take over the write side of the socket and send raw data with
|
||||
* xcb_writev. xcb_take_socket provides the sequence number of the last
|
||||
* request XCB sent. The caller of xcb_take_socket must supply a
|
||||
|
@ -68,10 +203,24 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
|
|||
* external socket owner and flushes any output queues if appropriate.
|
||||
* If you are sending requests which won't cause a reply, please note the
|
||||
* comment for xcb_writev which explains some sequence number wrap issues.
|
||||
* */
|
||||
*
|
||||
* All replies that are generated while the socket is owned externally have
|
||||
* @p flags applied to them. For example, use XCB_REQUEST_CHECK if you don't
|
||||
* want errors to go to xcb's normal error handling, but instead having to be
|
||||
* picked up via xcb_wait_for_reply(), xcb_poll_for_reply() or
|
||||
* xcb_request_check().
|
||||
*/
|
||||
int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
|
||||
|
||||
/* You must own the write-side of the socket (you've called
|
||||
/**
|
||||
* @brief Send raw data to the X server.
|
||||
* @param c The connection to the X server.
|
||||
* @param vector Array of data to be sent.
|
||||
* @param count Number of entries in @p vector.
|
||||
* @param requests Number of requests that are being sent.
|
||||
* @return 1 on success, else 0.
|
||||
*
|
||||
* You must own the write-side of the socket (you've called
|
||||
* xcb_take_socket, and haven't returned from return_socket yet) to call
|
||||
* xcb_writev. Also, the iovec must have at least 1 byte of data in it.
|
||||
* You have to make sure that xcb can detect sequence number wraps correctly.
|
||||
|
@ -80,19 +229,93 @@ int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), v
|
|||
* requests without a reply, you have to insert a request which will cause a
|
||||
* reply. You can again use GetInputFocus for this. You do not have to wait for
|
||||
* any of the GetInputFocus replies, but can instead handle them via
|
||||
* xcb_discard_reply(). */
|
||||
* xcb_discard_reply().
|
||||
*/
|
||||
int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
|
||||
|
||||
|
||||
/* xcb_in.c */
|
||||
|
||||
/**
|
||||
* @brief Wait for the reply of a given request.
|
||||
* @param c The connection to the X server.
|
||||
* @param request Sequence number of the request as returned by xcb_send_request().
|
||||
* @param e Location to store errors in, or NULL. Ignored for unchecked requests.
|
||||
*
|
||||
* Returns the reply to the given request or returns null in the event of
|
||||
* errors. Blocks until the reply or error for the request arrives, or an I/O
|
||||
* error occurs.
|
||||
*/
|
||||
void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
|
||||
|
||||
/**
|
||||
* @brief Wait for the reply of a given request, with 64-bit sequence number
|
||||
* @param c The connection to the X server.
|
||||
* @param request 64-bit sequence number of the request as returned by xcb_send_request64().
|
||||
* @param e Location to store errors in, or NULL. Ignored for unchecked requests.
|
||||
*
|
||||
* Returns the reply to the given request or returns null in the event of
|
||||
* errors. Blocks until the reply or error for the request arrives, or an I/O
|
||||
* error occurs.
|
||||
*
|
||||
* Unlike its xcb_wait_for_reply() counterpart, the given sequence number is not
|
||||
* automatically "widened" to 64-bit.
|
||||
*/
|
||||
void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
|
||||
|
||||
/**
|
||||
* @brief Poll for the reply of a given request.
|
||||
* @param c The connection to the X server.
|
||||
* @param request Sequence number of the request as returned by xcb_send_request().
|
||||
* @param reply Location to store the reply in, must not be NULL.
|
||||
* @param error Location to store errors in, or NULL. Ignored for unchecked requests.
|
||||
* @return 1 when the reply to the request was returned, else 0.
|
||||
*
|
||||
* Checks if the reply to the given request already received. Does not block.
|
||||
*/
|
||||
int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
|
||||
|
||||
/**
|
||||
* @brief Poll for the reply of a given request, with 64-bit sequence number.
|
||||
* @param c The connection to the X server.
|
||||
* @param request 64-bit sequence number of the request as returned by xcb_send_request().
|
||||
* @param reply Location to store the reply in, must not be NULL.
|
||||
* @param error Location to store errors in, or NULL. Ignored for unchecked requests.
|
||||
* @return 1 when the reply to the request was returned, else 0.
|
||||
*
|
||||
* Checks if the reply to the given request already received. Does not block.
|
||||
*
|
||||
* Unlike its xcb_poll_for_reply() counterpart, the given sequence number is not
|
||||
* automatically "widened" to 64-bit.
|
||||
*/
|
||||
int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
|
||||
|
||||
/**
|
||||
* @brief Don't use this, only needed by the generated code.
|
||||
* @param c The connection to the X server.
|
||||
* @param reply A reply that was received from the server
|
||||
* @param replylen The size of the reply.
|
||||
* @return Pointer to the location where received file descriptors are stored.
|
||||
*/
|
||||
XCB_CONST_FUNCTION
|
||||
int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
|
||||
|
||||
|
||||
/* xcb_util.c */
|
||||
|
||||
/**
|
||||
* @param mask The mask to check
|
||||
* @return The number of set bits in the mask
|
||||
*/
|
||||
XCB_CONST_FUNCTION
|
||||
int xcb_popcount(uint32_t mask);
|
||||
|
||||
/**
|
||||
* @param list The base of an array
|
||||
* @param len The length of the array
|
||||
* @return The sum of all entries in the array.
|
||||
*/
|
||||
XCB_PURE_FUNCTION
|
||||
int xcb_sumof(uint8_t *list, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
39
src/xcbint.h
39
src/xcbint.h
|
@ -38,6 +38,16 @@
|
|||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with older compilers. */
|
||||
#endif
|
||||
|
||||
#if __has_attribute(fallthrough)
|
||||
# define XCB_ALLOW_FALLTHRU __attribute__ ((fallthrough));
|
||||
#else
|
||||
# define XCB_ALLOW_FALLTHRU /* FALLTHRU */
|
||||
#endif
|
||||
|
||||
enum workarounds {
|
||||
WORKAROUND_NONE,
|
||||
WORKAROUND_GLX_GET_FB_CONFIGS_BUG,
|
||||
|
@ -53,7 +63,7 @@ enum lazy_reply_tag
|
|||
|
||||
#define XCB_PAD(i) (-(i) & 3)
|
||||
|
||||
#define XCB_SEQUENCE_COMPARE(a,op,b) ((int64_t) ((a) - (b)) op 0)
|
||||
#define XCB_SEQUENCE_COMPARE(a,op,b) ((int64_t) ((a) - (b)) op 0)
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type,member) ((size_t) &((type *)0)->member)
|
||||
|
@ -73,12 +83,22 @@ typedef struct _xcb_map _xcb_map;
|
|||
|
||||
_xcb_map *_xcb_map_new(void);
|
||||
void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
|
||||
int _xcb_map_put(_xcb_map *q, unsigned int key, void *data);
|
||||
void *_xcb_map_remove(_xcb_map *q, unsigned int key);
|
||||
int _xcb_map_put(_xcb_map *q, uint64_t key, void *data);
|
||||
void *_xcb_map_remove(_xcb_map *q, uint64_t key);
|
||||
|
||||
|
||||
/* xcb_out.c */
|
||||
|
||||
#if HAVE_SENDMSG
|
||||
#define XCB_MAX_PASS_FD 16
|
||||
|
||||
typedef struct _xcb_fd {
|
||||
int fd[XCB_MAX_PASS_FD];
|
||||
int nfd;
|
||||
int ifd;
|
||||
} _xcb_fd;
|
||||
#endif
|
||||
|
||||
typedef struct _xcb_out {
|
||||
pthread_cond_t cond;
|
||||
int writing;
|
||||
|
@ -93,6 +113,8 @@ typedef struct _xcb_out {
|
|||
|
||||
uint64_t request;
|
||||
uint64_t request_written;
|
||||
uint64_t request_expected_written;
|
||||
uint64_t total_written;
|
||||
|
||||
pthread_mutex_t reqlenlock;
|
||||
enum lazy_reply_tag maximum_request_length_tag;
|
||||
|
@ -100,6 +122,9 @@ typedef struct _xcb_out {
|
|||
xcb_big_requests_enable_cookie_t cookie;
|
||||
uint32_t value;
|
||||
} maximum_request_length;
|
||||
#if HAVE_SENDMSG
|
||||
_xcb_fd out_fd;
|
||||
#endif
|
||||
} _xcb_out;
|
||||
|
||||
int _xcb_out_init(_xcb_out *out);
|
||||
|
@ -122,6 +147,7 @@ typedef struct _xcb_in {
|
|||
uint64_t request_expected;
|
||||
uint64_t request_read;
|
||||
uint64_t request_completed;
|
||||
uint64_t total_read;
|
||||
struct reply_list *current_reply;
|
||||
struct reply_list **current_reply_tail;
|
||||
|
||||
|
@ -129,9 +155,14 @@ typedef struct _xcb_in {
|
|||
struct event_list *events;
|
||||
struct event_list **events_tail;
|
||||
struct reader_list *readers;
|
||||
struct special_list *special_waiters;
|
||||
|
||||
struct pending_reply *pending_replies;
|
||||
struct pending_reply **pending_replies_tail;
|
||||
#if HAVE_SENDMSG
|
||||
_xcb_fd in_fd;
|
||||
#endif
|
||||
struct xcb_special_event *special_events;
|
||||
} _xcb_in;
|
||||
|
||||
int _xcb_in_init(_xcb_in *in);
|
||||
|
@ -175,6 +206,7 @@ void _xcb_ext_destroy(xcb_connection_t *c);
|
|||
/* xcb_conn.c */
|
||||
|
||||
struct xcb_connection_t {
|
||||
/* This must be the first field; see _xcb_conn_ret_error(). */
|
||||
int has_error;
|
||||
|
||||
/* constant data */
|
||||
|
@ -193,6 +225,7 @@ struct xcb_connection_t {
|
|||
|
||||
void _xcb_conn_shutdown(xcb_connection_t *c, int err);
|
||||
|
||||
XCB_CONST_FUNCTION
|
||||
xcb_connection_t *_xcb_conn_ret_error(int err);
|
||||
|
||||
int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
CheckLog.html
|
||||
CheckLog_xcb.xml
|
||||
check_all
|
||||
check_all.log
|
||||
check_all.trs
|
||||
test-suite.log
|
||||
|
|
|
@ -12,12 +12,9 @@ TESTS = check_all
|
|||
check_PROGRAMS = check_all
|
||||
check_all_SOURCES = check_all.c check_suites.h check_public.c
|
||||
|
||||
all-local::
|
||||
$(RM) CheckLog*.xml
|
||||
|
||||
check-local: check-TESTS
|
||||
$(RM) CheckLog.html
|
||||
if test x$(HTML_CHECK_RESULT) = xtrue; then \
|
||||
if test x$(HTML_CHECK_RESULT) = xyes; then \
|
||||
$(XSLTPROC) $(srcdir)/CheckLog.xsl CheckLog*.xml > CheckLog.html; \
|
||||
else \
|
||||
touch CheckLog.html; \
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
#include <stdlib.h>
|
||||
#include "check_suites.h"
|
||||
|
||||
#if CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13
|
||||
void suite_add_test(Suite *s, TFun tf, const char *name)
|
||||
#else
|
||||
void suite_add_test(Suite *s, const TTest *tt, const char *name)
|
||||
#endif
|
||||
{
|
||||
TCase *tc = tcase_create(name);
|
||||
|
||||
#if CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13
|
||||
tcase_add_test(tc, tf);
|
||||
#else
|
||||
tcase_add_test(tc, tt);
|
||||
#endif
|
||||
suite_add_tcase(s, tc);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include <check.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __unix__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "check_suites.h"
|
||||
#include "xcb.h"
|
||||
#include "xcbext.h"
|
||||
|
@ -12,6 +16,10 @@ typedef enum test_type_t {
|
|||
} test_type_t;
|
||||
static const char *const test_string[] = { "", "via $DISPLAY " };
|
||||
|
||||
/* putenv(3) takes a pointer to a writable string that it adds directly
|
||||
to the environment, so it must be in persistent memory, not on the stack */
|
||||
static char display_env[] = "DISPLAY=";
|
||||
|
||||
static void parse_display_pass(const char *name, const char *host, const int display, const int screen)
|
||||
{
|
||||
int success;
|
||||
|
@ -25,7 +33,7 @@ static void parse_display_pass(const char *name, const char *host, const int dis
|
|||
if(test_type == TEST_ARGUMENT)
|
||||
{
|
||||
argument = name;
|
||||
putenv("DISPLAY=");
|
||||
putenv(display_env);
|
||||
}
|
||||
else if(test_type == TEST_ENVIRONMENT)
|
||||
{
|
||||
|
@ -37,20 +45,20 @@ static void parse_display_pass(const char *name, const char *host, const int dis
|
|||
got_display = got_screen = -42;
|
||||
mark_point();
|
||||
success = xcb_parse_display(argument, &got_host, &got_display, &got_screen);
|
||||
fail_unless(success, "unexpected parse failure %sfor '%s'", test_string[test_type], name);
|
||||
fail_unless(strcmp(host, got_host) == 0, "parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
|
||||
fail_unless(display == got_display, "parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
|
||||
fail_unless(screen == got_screen, "parse %sproduced unexpected screen '%d' for '%s': expected '%d'", test_string[test_type], got_screen, name, screen);
|
||||
ck_assert_msg(success, "unexpected parse failure %sfor '%s'", test_string[test_type], name);
|
||||
ck_assert_msg(strcmp(host, got_host) == 0, "parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
|
||||
ck_assert_msg(display == got_display, "parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
|
||||
ck_assert_msg(screen == got_screen, "parse %sproduced unexpected screen '%d' for '%s': expected '%d'", test_string[test_type], got_screen, name, screen);
|
||||
|
||||
got_host = (char *) -1;
|
||||
got_display = got_screen = -42;
|
||||
mark_point();
|
||||
success = xcb_parse_display(argument, &got_host, &got_display, 0);
|
||||
fail_unless(success, "unexpected screenless parse failure %sfor '%s'", test_string[test_type], name);
|
||||
fail_unless(strcmp(host, got_host) == 0, "screenless parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
|
||||
fail_unless(display == got_display, "screenless parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
|
||||
ck_assert_msg(success, "unexpected screenless parse failure %sfor '%s'", test_string[test_type], name);
|
||||
ck_assert_msg(strcmp(host, got_host) == 0, "screenless parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
|
||||
ck_assert_msg(display == got_display, "screenless parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
|
||||
}
|
||||
putenv("DISPLAY=");
|
||||
putenv(display_env);
|
||||
}
|
||||
|
||||
static void parse_display_fail(const char *name)
|
||||
|
@ -66,7 +74,7 @@ static void parse_display_fail(const char *name)
|
|||
if(test_type == TEST_ARGUMENT)
|
||||
{
|
||||
argument = name;
|
||||
putenv("DISPLAY=");
|
||||
putenv(display_env);
|
||||
}
|
||||
else if(test_type == TEST_ENVIRONMENT)
|
||||
{
|
||||
|
@ -79,24 +87,55 @@ static void parse_display_fail(const char *name)
|
|||
got_display = got_screen = -42;
|
||||
mark_point();
|
||||
success = xcb_parse_display(argument, &got_host, &got_display, &got_screen);
|
||||
fail_unless(!success, "unexpected parse success %sfor '%s'", test_string[test_type], name);
|
||||
fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
|
||||
fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
|
||||
fail_unless(got_screen == -42, "screen changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_screen);
|
||||
ck_assert_msg(!success, "unexpected parse success %sfor '%s'", test_string[test_type], name);
|
||||
ck_assert_msg(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
|
||||
ck_assert_msg(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
|
||||
ck_assert_msg(got_screen == -42, "screen changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_screen);
|
||||
|
||||
got_host = (char *) -1;
|
||||
got_display = got_screen = -42;
|
||||
mark_point();
|
||||
success = xcb_parse_display(argument, &got_host, &got_display, 0);
|
||||
fail_unless(!success, "unexpected screenless parse success %sfor '%s'", test_string[test_type], name);
|
||||
fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
|
||||
fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
|
||||
ck_assert_msg(!success, "unexpected screenless parse success %sfor '%s'", test_string[test_type], name);
|
||||
ck_assert_msg(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
|
||||
ck_assert_msg(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
|
||||
}
|
||||
putenv("DISPLAY=");
|
||||
putenv(display_env);
|
||||
}
|
||||
|
||||
START_TEST(parse_display_unix)
|
||||
{
|
||||
#ifdef __unix__
|
||||
char buf[sizeof "/tmp/xcb-test.XXXXXXX"];
|
||||
char buf2[sizeof(buf) + 7];
|
||||
int r, v;
|
||||
memcpy(buf, "/tmp/xcb-test.XXXXXXX", sizeof buf);
|
||||
v = mkstemp(buf);
|
||||
ck_assert_msg(v >= 0, "cannot create temporary file");
|
||||
parse_display_pass(buf, buf, 0, 0);
|
||||
r = snprintf(buf2, sizeof buf2, "unix:%s", buf);
|
||||
if (r < 5 || r >= (int)sizeof buf2) {
|
||||
ck_assert_msg(0, "snprintf() failed (return value %d)", r);
|
||||
unlink(buf);
|
||||
return;
|
||||
}
|
||||
parse_display_pass(buf2, buf, 0, 0);
|
||||
r = snprintf(buf2, sizeof buf2, "unix:%s.1", buf);
|
||||
if (r < 7 || r >= (int)sizeof buf2) {
|
||||
ck_assert_msg(0, "snprintf() failed (return value %d)", r);
|
||||
unlink(buf);
|
||||
return;
|
||||
}
|
||||
parse_display_pass(buf2, buf, 0, 1);
|
||||
r = snprintf(buf2, sizeof buf2, "%s.1", buf);
|
||||
if (r < 2 || r >= (int)sizeof buf2) {
|
||||
ck_assert_msg(0, "snprintf() failed (return value %d)", r);
|
||||
unlink(buf);
|
||||
return;
|
||||
}
|
||||
parse_display_pass(buf2, buf, 0, 1);
|
||||
unlink(buf);
|
||||
#endif
|
||||
parse_display_pass(":0", "", 0, 0);
|
||||
parse_display_pass(":1", "", 1, 0);
|
||||
parse_display_pass(":0.1", "", 0, 1);
|
||||
|
@ -183,7 +222,7 @@ END_TEST
|
|||
|
||||
static void popcount_eq(uint32_t bits, int count)
|
||||
{
|
||||
fail_unless(xcb_popcount(bits) == count, "unexpected popcount(%08x) != %d", bits, count);
|
||||
ck_assert_msg(xcb_popcount(bits) == count, "unexpected popcount(%08x) != %d", bits, count);
|
||||
}
|
||||
|
||||
START_TEST(popcount)
|
||||
|
@ -206,7 +245,7 @@ END_TEST
|
|||
Suite *public_suite(void)
|
||||
{
|
||||
Suite *s = suite_create("Public API");
|
||||
putenv("DISPLAY=");
|
||||
putenv(display_env);
|
||||
suite_add_test(s, parse_display_unix, "xcb_parse_display unix");
|
||||
suite_add_test(s, parse_display_ip, "xcb_parse_display ip");
|
||||
suite_add_test(s, parse_display_ipv4, "xcb_parse_display ipv4");
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#include <check.h>
|
||||
|
||||
#if CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13
|
||||
void suite_add_test(Suite *s, TFun tf, const char *name);
|
||||
#else
|
||||
void suite_add_test(Suite *s, const TTest *tt, const char *name);
|
||||
#endif
|
||||
Suite *public_suite(void);
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Composite
|
||||
Description: XCB Composite Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb xcb-xfixes
|
||||
Requires.private: xcb xcb-xfixes
|
||||
Libs: -L${libdir} -lxcb-composite
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Damage
|
||||
Description: XCB Damage Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb xcb-xfixes
|
||||
Requires.private: xcb xcb-xfixes
|
||||
Libs: -L${libdir} -lxcb-damage
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: XCB Dbe
|
||||
Description: XCB Double Buffer Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-dbe
|
||||
Cflags: -I${includedir}
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB DPMS
|
||||
Description: XCB DPMS Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-dpms
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB DRI2
|
||||
Description: XCB DRI2 Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-dri2
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: XCB DRI3
|
||||
Description: XCB DRI3 Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-dri3
|
||||
Cflags: -I${includedir}
|
|
@ -0,0 +1,11 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: XCB GenericEvent
|
||||
Description: XCB GenericEvent Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-ge
|
||||
Cflags: -I${includedir}
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB GLX
|
||||
Description: XCB GLX Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-glx
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: XCB Present
|
||||
Description: XCB Present Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires.private: xcb xcb-randr xcb-xfixes xcb-sync xcb-dri3
|
||||
Libs: -L${libdir} -lxcb-present
|
||||
Cflags: -I${includedir}
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB RandR
|
||||
Description: XCB RandR Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb xcb-render
|
||||
Libs: -L${libdir} -lxcb-randr
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Record
|
||||
Description: XCB Record Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-record
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Render
|
||||
Description: XCB Render Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-render
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Res
|
||||
Description: XCB X-Resource Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-res
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Screensaver
|
||||
Description: XCB Screensaver Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-screensaver
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Shape
|
||||
Description: XCB Shape Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-shape
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Shm
|
||||
Description: XCB Shm Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-shm
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Sync
|
||||
Description: XCB Sync Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-sync
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Xevie
|
||||
Description: XCB Xevie Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-xevie
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB XFree86-DRI
|
||||
Description: XCB XFree86-DRI Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-xf86dri
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB XFixes
|
||||
Description: XCB XFixes Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb xcb-render xcb-shape
|
||||
Requires.private: xcb xcb-render xcb-shape
|
||||
Libs: -L${libdir} -lxcb-xfixes
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Xinerama
|
||||
Description: XCB Xinerama Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-xinerama
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB XInput
|
||||
Description: XCB XInput Extension (EXPERIMENTAL)
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb xcb-xfixes
|
||||
Libs: -L${libdir} -lxcb-xinput
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB XKB
|
||||
Description: XCB Keyboard Extension (EXPERIMENTAL)
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-xkb
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Xprint
|
||||
Description: XCB Xprint Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-xprint
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB SELinux
|
||||
Description: XCB SELinux Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-xselinux
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB XTEST
|
||||
Description: XCB XTEST Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb
|
||||
Requires.private: xcb
|
||||
Libs: -L${libdir} -lxcb-xtest
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB Xv
|
||||
Description: XCB Xv Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb xcb-shm
|
||||
Requires.private: xcb xcb-shm
|
||||
Libs: -L${libdir} -lxcb-xv
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: XCB XvMC
|
||||
Description: XCB XvMC Extension
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: xcb xcb-xv
|
||||
Requires.private: xcb xcb-xv
|
||||
Libs: -L${libdir} -lxcb-xvmc
|
||||
Cflags: -I${includedir}
|
||||
|
|
Loading…
Reference in New Issue