diff options
752 files changed, 6997 insertions, 9596 deletions
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..155c282bc --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,24 @@ +# This file contains revisions to be ignored by git blame. +# These revisions are expected to be formatting-only changes. +# +# Calling `git blame --ignore-revs-file .git-blame-ignore-revs` will +# tell git blame to ignore changes made by these revisions when assigning +# assigning blame, as if the change never happened. +# +# You can enable this as a default for your local repository by running +# `git config blame.ignoreRevsFile .git-blame-ignore-revs` +# Important: if you do this, then switch to a branch without this file, +# `git blame` will fail with an error. +# + +# Introduce a consistent coding style +9838b7032ea9792bec21af424c53c07078636d21 + +# Drop trailing whitespaces +732fd7e571b81d63aa44d6e4cf55883479e88f2f + +# glamor: Apply x-indent.sh. +d84d71029ae9e462559d64eff7259e2cc7732fac + +# indent fixes (OMG SO UGLY), and nuke old RCS keywords. +6d7083bd69724586338d79784655328f1fcd2ae5 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dd055e284..b20b527b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ # Please see the ci-templates documentation for details: # https://freedesktop.pages.freedesktop.org/ci-templates/ -.templates_sha: &template_sha c5626190ec14b475271288dda7a7dae8dbe0cd76 # see https://docs.gitlab.com/ee/ci/yaml/#includefile +.templates_sha: &template_sha ef5e4669b7500834a17ffe9277e15fbb6d977fff # see https://docs.gitlab.com/ee/ci/yaml/#includefile # FDO_DISTRIBUTION_TAG is the tag of the docker image used for the build jobs. # If the image doesn't exist yet, the docker-image stage generates it. @@ -16,19 +16,23 @@ # gcc/clang or other packages, which might break the build with older commits # using the same tag. variables: - FDO_UPSTREAM_REPO: xorg/xserver - FDO_DISTRIBUTION_VERSION: bullseye-slim - FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/debian-install.sh' - FDO_DISTRIBUTION_TAG: "2024-03-26-explicit-sync-2" - MESON_BUILDDIR: "build" + FDO_UPSTREAM_REPO: 'xorg/xserver' + MESON_BUILDDIR: 'build' + REPO_URL_XORGPROTO: 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' + XORG_DEBIAN_VERSION: 'bullseye-slim' + XORG_DEBIAN_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/debian-install.sh' + XORG_DEBIAN_TAG: '2025-02-26-xcb-deps' + XORG_FREEBSD_VERSION: '14.2' + XORG_FREEBSD_EXEC: '' + XORG_FREEBSD_TAG: '2025-02-18-vm-image' include: - project: 'freedesktop/ci-templates' ref: *template_sha - file: '/templates/debian.yml' - - project: 'freedesktop/ci-templates' - ref: *template_sha - file: '/templates/ci-fairy.yml' + file: + - '/templates/debian.yml' + - '/templates/freebsd.yml' + - '/templates/ci-fairy.yml' - template: Security/SAST.gitlab-ci.yml stages: @@ -94,17 +98,55 @@ stages: .all_ddx_paths: - hw/**/* +.debian: + variables: + FDO_DISTRIBUTION_VERSION: '$XORG_DEBIAN_VERSION' + FDO_DISTRIBUTION_EXEC: '$XORG_DEBIAN_EXEC' + FDO_DISTRIBUTION_TAG: '$XORG_DEBIAN_TAG' + +.freebsd: + tags: + - kvm + variables: + FDO_DISTRIBUTION_TAG: '$XORG_FREEBSD_TAG' + FDO_DISTRIBUTION_VERSION: '$XORG_FREEBSD_VERSION' + FDO_DISTRIBUTION_EXEC: '' + FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake libtool xorg-macros xorgproto bash meson ninja pixman xtrans libXau libXdmcp libXfont2 libxkbfile libxcvt libpciaccess font-util libepoll-shim' + FDO_IMAGE_SIZE: '30G' + debian-bullseye: extends: - .fdo.container-build@debian - .ci-run-policy + - .debian stage: docker-image variables: GIT_STRATEGY: none -.common-build-and-test: +freebsd-image: + extends: + - .fdo.qemu-build@freebsd@x86_64 + - .freebsd + stage: docker-image + variables: + GIT_STRATEGY: none + +.xorg-image@debian: extends: - .fdo.distribution-image@debian + - .debian + +.xorg-image@freebsd: + extends: + - .fdo.distribution-image@freebsd + - .freebsd + variables: + GIT_DEPTH: 1 + PKG_CONFIG_PATH: /usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/pkg/share/pkgconfig:/usr/pkg/lib/pkgconfig:/usr/local/libdata/pkgconfig + +.common-build-and-test: + extends: + - .xorg-image@debian - .ci-run-policy stage: build-and-test artifacts: @@ -113,7 +155,7 @@ debian-bullseye: - $MESON_BUILDDIR/meson-logs/ - $MESON_BUILDDIR/test/piglit-results/ variables: - MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=true -Dwerror=true + MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=true -Dwerror=true -Dxcsecurity=true CCACHE_COMPILERCHECK: content CCACHE_DIR: /cache/xserver/cache LC_ALL: C.UTF-8 @@ -130,29 +172,63 @@ meson: - .gitlab-ci/meson-build.sh --run-test - .gitlab-ci/check-piglit-results.sh - .gitlab-ci/manpages-check + - .gitlab-ci/check-ddx-build.sh variables: XTEST_DIR: /root/xts PIGLIT_DIR: /root/piglit LP_NUM_THREADS: 0 + MESON_DDX_BUILD_ARGS: > + -Dxwayland=${BUILD_XWAYLAND} -Dxorg=${BUILD_XORG} -Dxephyr=${BUILD_XEPHYR} -Dxvfb=${BUILD_XVFB} -Dxnest=${BUILD_XNEST} + BUILD_XEPHYR: true + BUILD_XNEST: true + BUILD_XORG: true + BUILD_XVFB: true + BUILD_XWAYLAND: true + MESON_EXTRA_ARGS: ${MESON_DDX_BUILD_ARGS} meson-noglamor: extends: meson variables: - MESON_EXTRA_ARGS: > - -Dglamor=false + MESON_EXTRA_ARGS: -Dglamor=false ${MESON_DDX_BUILD_ARGS} -meson-nolibdecor: +xwayland-nolibdecor: extends: meson variables: - MESON_EXTRA_ARGS: > - -Dlibdecor=false + BUILD_XEPHYR: false + BUILD_XNEST: false + BUILD_XORG: false + BUILD_XVFB: false + MESON_EXTRA_ARGS: -Dlibdecor=false ${MESON_DDX_BUILD_ARGS} mingw-cross-build: extends: .common-build-and-test script: - .gitlab-ci/meson-build.sh --run-install variables: - MESON_ARGS: --cross-file=.gitlab-ci/cross-i686-w64-mingw32.txt -Dglx=false -Dsecure-rpc=false -Dlisten_tcp=true + MESON_ARGS: --cross-file=.gitlab-ci/cross-i686-w64-mingw32.txt -Dglx=false -Dlisten_tcp=true + +freebsd: + stage: build-and-test + extends: + - .xorg-image@freebsd + variables: + MESON_ARGS: -Dglx=false -Dglamor=false -Dudev=false -Dudev_kms=false + script: + # running of of disk space without this + # needed until https://gitlab.freedesktop.org/freedesktop/ci-templates/-/issues/67 is fixed + - git gc + - git clone --depth=1 $REPO_URL_XORGPROTO dep.xorgproto + - /app/vmctl start + - set +e + - scp -r $PWD "vm:" + # need to install newer xorgproto + - /app/vmctl exec "cd $CI_PROJECT_NAME/dep.xorgproto && ./autogen.sh --prefix=/usr && make && make install" + - /app/vmctl exec "cd $CI_PROJECT_NAME && PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH\" MESON_ARGS=\"$MESON_ARGS\" MESON_BUILDDIR=\"$MESON_BUILDDIR\" .gitlab-ci/meson-build.sh --skip-test" && touch .success + # test not working yet, so skipped + # - scp -r vm:$CI_PROJECT_NAME/test-results.xml . + - /app/vmctl stop + - set -e + - test -e .success || exit 1 meson-dist: extends: .common-build-and-test @@ -161,6 +237,7 @@ meson-dist: paths: - $MESON_BUILDDIR/meson-logs/ - $MESON_BUILDDIR/xserver-*/$MESON_BUILDDIR/meson-logs/ + - xserver-tarball/install/ script: - .gitlab-ci/meson-build.sh --run-dist - mkdir xserver-tarball @@ -168,11 +245,11 @@ meson-dist: - .gitlab-ci/meson-build.sh -C xserver-tarball --skip-test --skip-dist --run-install variables: MESON_DIST_ARGS: --no-tests - DESTDIR: xserver-tarball/install/ + MESON_EXTRA_ARGS: -Dprefix=$CI_PROJECT_DIR/xserver-tarball/install/ xf86-driver-build-test: extends: - - .fdo.distribution-image@debian + - .xorg-image@debian - .ci-run-policy stage: drivers parallel: @@ -189,28 +266,33 @@ xf86-driver-build-test: SHA: xf86-video-amdgpu-23.0.0 - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-ati SHA: xf86-video-ati-22.0.0 + - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel + SHA: e6a4c4740c15ace9dd79dc7c18955f2eb413a6a5 # no release yet - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-qxl - SHA: xf86-video-qxl-0.1.6 + SHA: 989ff620220e8d0555cec38c1508b57dfbcfb0c6 # no release yet - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-vesa SHA: xf86-video-vesa-2.6.0 - REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-vmware SHA: xf86-video-vmware-13.4.0 script: - # Install the server first - - .gitlab-ci/meson-build.sh --skip-test --run-install + # built xserver is taken from meson-dist job + - export PKG_CONFIG_PATH=$(pwd)/xserver-tarball/install/lib/x86_64-linux-gnu/pkgconfig + - export ACLOCAL_PATH=$(pwd)/xserver-tarball/install/share/aclocal/ - unset MESON_EXTRA_ARGS - DRIVER=$(basename $REPO) - git clone "$REPO" "$DRIVER" - - GIT_DIR="$DRIVER/.git" git checkout -f "$SHA" + - git -C "$DRIVER" checkout "$SHA" - | - if [[ -e "$DRIVER/meson.build" ]]; then + if [[ -e "$DRIVER/meson.build" ]] && [[ "$DRIVER" != "xf86-video-intel" ]]; then .gitlab-ci/meson-build.sh -C "$DRIVER" --skip-test else pushd "$DRIVER" || exit 1 ./autogen.sh && make fi needs: - - "meson" + - meson-dist + dependencies: + - meson-dist variables: GIT_DEPTH: 1 MESON_ARGS: -Dprefix=/usr/ diff --git a/.gitlab-ci/check-ddx-build.sh b/.gitlab-ci/check-ddx-build.sh new file mode 100755 index 000000000..df6f0c029 --- /dev/null +++ b/.gitlab-ci/check-ddx-build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e +set -o xtrace + +check_executable () { + if [[ ! -x $MESON_BUILDDIR/$1 ]]; then + echo "$1 not found after build" + exit 1 + fi + return 0 +} + +if [[ -z "$MESON_BUILDDIR" ]]; then + echo "\$MESON_BUILDDIR not set" + exit 1 +fi + +[[ "$BUILD_XEPHYR" == true ]] && check_executable "hw/kdrive/ephyr/Xephyr" +[[ "$BUILD_XNEST" == true ]] && check_executable "hw/xnest/Xnest" +[[ "$BUILD_XORG" == true ]] && check_executable "hw/xfree86/Xorg" +[[ "$BUILD_XVFB" == true ]] && check_executable "hw/vfb/Xvfb" +[[ "$BUILD_XWAYLAND" == true ]] && check_executable "hw/xwayland/Xwayland" + +exit 0 diff --git a/.gitlab-ci/cross-prereqs-build.sh b/.gitlab-ci/cross-prereqs-build.sh index 916d95a3d..fb788895b 100755 --- a/.gitlab-ci/cross-prereqs-build.sh +++ b/.gitlab-ci/cross-prereqs-build.sh @@ -11,7 +11,7 @@ HOST=$1 cat >/usr/local/bin/${HOST}-pkg-config <<EOF #!/bin/sh -PKG_CONFIG_SYSROOT_DIR=/usr/${HOST} PKG_CONFIG_LIBDIR=/usr/${HOST}/lib/pkgconfig:/usr/share/pkgconfig pkg-config \$@ +PKG_CONFIG_SYSROOT_DIR=/usr/${HOST} PKG_CONFIG_LIBDIR=/usr/${HOST}/lib/pkgconfig:/usr/${HOST}/share/pkgconfig pkg-config \$@ EOF chmod +x /usr/local/bin/${HOST}-pkg-config @@ -68,9 +68,9 @@ build 'https://gitlab.freedesktop.org/xorg/lib/libfontenc.git' 'libfontenc-1.1.4 build 'https://gitlab.freedesktop.org/xorg/lib/libXfont.git' 'libXfont2-2.0.3' build 'https://gitlab.freedesktop.org/xorg/lib/libXdmcp.git' 'libXdmcp-1.1.3' build 'https://gitlab.freedesktop.org/xorg/lib/libXfixes.git' 'libXfixes-5.0.3' -build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-util.git' '0.4.0' -build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-image.git' '0.4.0' -build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-wm.git' '0.4.1' +build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-util.git' 'xcb-util-0.4.1-gitlab' +build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-image.git' 'xcb-util-image-0.4.1-gitlab' +build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-wm.git' 'xcb-util-wm-0.4.2' # workaround xcb_windefs.h leaking all Windows API types into X server build # (some of which clash which types defined by Xmd.h) XXX: This is a bit of a diff --git a/.gitlab-ci/debian-install.sh b/.gitlab-ci/debian-install.sh index 59bcea4b0..e4f1eb6e2 100644 --- a/.gitlab-ci/debian-install.sh +++ b/.gitlab-ci/debian-install.sh @@ -15,7 +15,7 @@ EPHEMERAL=" xvfb " -# Add bullseye-backports for the newer linux-libc-dev package +# Add bullseye-backports for the newer linux-libc-dev & meson packages echo 'deb http://deb.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list apt update @@ -65,6 +65,9 @@ apt-get install -y \ libx11-xcb-dev \ libxau-dev \ libxaw7-dev \ + libxcb-damage0-dev \ + libxcb-dri2-0-dev \ + libxcb-dri3-dev \ libxcb-glx0-dev \ libxcb-icccm4-dev \ libxcb-image0-dev \ @@ -74,11 +77,15 @@ apt-get install -y \ libxcb-render0-dev \ libxcb-shape0-dev \ libxcb-shm0-dev \ + libxcb-sync-dev \ libxcb-util0-dev \ libxcb-xf86dri0-dev \ + libxcb-xinput-dev \ libxcb-xkb-dev \ libxcb-xv0-dev \ libxcb1-dev \ + libxcursor-dev \ + libxdamage-dev \ libxdmcp-dev \ libxext-dev \ libxfixes-dev \ @@ -90,16 +97,20 @@ apt-get install -y \ libxmu-dev \ libxmuu-dev \ libxpm-dev \ + libxrandr-dev \ libxrender-dev \ libxres-dev \ libxshmfence-dev \ + libxss-dev \ libxt-dev \ libxtst-dev \ libxv-dev \ + libxvmc-dev \ + libxxf86vm-dev \ libz-mingw-w64-dev \ linux-libc-dev/bullseye-backports \ mesa-common-dev \ - meson \ + meson/bullseye-backports \ mingw-w64-tools \ nettle-dev \ pkg-config \ @@ -108,6 +119,7 @@ apt-get install -y \ python3-mako \ python3-numpy \ python3-six \ + valgrind \ weston \ x11-xkb-utils \ xfonts-utils \ @@ -151,8 +163,8 @@ ninja -C _build -j${FDO_CI_CONCURRENT:-4} install cd .. rm -rf wayland -# Xwayland requires wayland-protocols >= 1.34, but Debian bullseye has 1.20 only -git clone https://gitlab.freedesktop.org/wayland/wayland-protocols.git --depth 1 --branch=1.34 +# Xwayland requires wayland-protocols >= 1.38, but Debian bullseye has 1.20 only +git clone https://gitlab.freedesktop.org/wayland/wayland-protocols.git --depth 1 --branch=1.38 cd wayland-protocols meson _build ninja -C _build -j${FDO_CI_CONCURRENT:-4} install @@ -160,7 +172,7 @@ cd .. rm -rf wayland-protocols # Install libdecor for Xwayland -git clone https://gitlab.gnome.org/jadahl/libdecor.git --depth 1 --branch=0.1.0 +git clone https://gitlab.freedesktop.org/libdecor/libdecor.git --depth 1 --branch=0.1.1 cd libdecor meson _build -D{demo,install_demo}=false ninja -C _build -j${FDO_CI_CONCURRENT:-4} install @@ -182,10 +194,8 @@ cd .. git clone https://gitlab.freedesktop.org/xorg/test/xts cd xts -git checkout dbbfa96c036e596346147081cbceda136e7c86c1 -# Using -fcommon until we get a proper fix into xtst. -# See discussion at https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/913 -CFLAGS=-fcommon ./autogen.sh +git checkout 12a887c2c72c4258962b56ced7b0aec782f1ffed +./autogen.sh xvfb-run make -j${FDO_CI_CONCURRENT:-4} cd .. @@ -277,7 +277,8 @@ Paulo Zanoni <paulo.r.zanoni@intel.com> Paulo Ricardo Zanoni <pzanoni@mandriva.c Pekka Paalanen <pekka.paalanen@collabora.co.uk> <pekka.paalanen@collabora.com> -Peter Harris <pharris@opentext.com> <peter.harris@hummingbird.com> +Peter Harris <pharris2@rocketsoftware.com> <peter.harris@hummingbird.com> +Peter Harris <pharris2@rocketsoftware.com> <pharris@opentext.com> Peter Hutterer <peter.hutterer@who-t.net> <peter.hutterer@redhat.com> Peter Hutterer <peter.hutterer@who-t.net> <peter@cs.unisa.edu.au> diff --git a/Xext/bigreq.c b/Xext/bigreq.c index 0dc60c258..2a3012cf7 100644 --- a/Xext/bigreq.c +++ b/Xext/bigreq.c @@ -26,9 +26,7 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -49,9 +47,6 @@ ProcBigReqDispatch(ClientPtr client) REQUEST(xBigReqEnableReq); xBigReqEnableReply rep; - if (client->swapped) { - swaps(&stuff->length); - } if (stuff->brReqType != X_BigReqEnable) return BadRequest; REQUEST_SIZE_MATCH(xBigReqEnableReq); diff --git a/Xext/dpms.c b/Xext/dpms.c index 68759a48a..5031ba197 100644 --- a/Xext/dpms.c +++ b/Xext/dpms.c @@ -26,12 +26,14 @@ Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> + +#include "os/screensaver.h" +#include "Xext/geext.h" + #include "misc.h" #include "os.h" #include "dixstruct.h" @@ -492,8 +494,6 @@ static int _X_COLD SProcDPMSGetVersion(ClientPtr client) { REQUEST(xDPMSGetVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDPMSGetVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); @@ -501,33 +501,9 @@ SProcDPMSGetVersion(ClientPtr client) } static int _X_COLD -SProcDPMSCapable(ClientPtr client) -{ - REQUEST(xDPMSCapableReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xDPMSCapableReq); - - return ProcDPMSCapable(client); -} - -static int _X_COLD -SProcDPMSGetTimeouts(ClientPtr client) -{ - REQUEST(xDPMSGetTimeoutsReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq); - - return ProcDPMSGetTimeouts(client); -} - -static int _X_COLD SProcDPMSSetTimeouts(ClientPtr client) { REQUEST(xDPMSSetTimeoutsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq); swaps(&stuff->standby); @@ -537,33 +513,9 @@ SProcDPMSSetTimeouts(ClientPtr client) } static int _X_COLD -SProcDPMSEnable(ClientPtr client) -{ - REQUEST(xDPMSEnableReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xDPMSEnableReq); - - return ProcDPMSEnable(client); -} - -static int _X_COLD -SProcDPMSDisable(ClientPtr client) -{ - REQUEST(xDPMSDisableReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xDPMSDisableReq); - - return ProcDPMSDisable(client); -} - -static int _X_COLD SProcDPMSForceLevel(ClientPtr client) { REQUEST(xDPMSForceLevelReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDPMSForceLevelReq); swaps(&stuff->level); @@ -572,21 +524,9 @@ SProcDPMSForceLevel(ClientPtr client) } static int _X_COLD -SProcDPMSInfo(ClientPtr client) -{ - REQUEST(xDPMSInfoReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xDPMSInfoReq); - - return ProcDPMSInfo(client); -} - -static int _X_COLD SProcDPMSSelectInput(ClientPtr client) { REQUEST(xDPMSSelectInputReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDPMSSelectInputReq); swapl(&stuff->eventMask); return ProcDPMSSelectInput(client); @@ -602,19 +542,19 @@ SProcDPMSDispatch(ClientPtr client) case X_DPMSGetVersion: return SProcDPMSGetVersion(client); case X_DPMSCapable: - return SProcDPMSCapable(client); + return ProcDPMSCapable(client); case X_DPMSGetTimeouts: - return SProcDPMSGetTimeouts(client); + return ProcDPMSGetTimeouts(client); case X_DPMSSetTimeouts: return SProcDPMSSetTimeouts(client); case X_DPMSEnable: - return SProcDPMSEnable(client); + return ProcDPMSEnable(client); case X_DPMSDisable: - return SProcDPMSDisable(client); + return ProcDPMSDisable(client); case X_DPMSForceLevel: return SProcDPMSForceLevel(client); case X_DPMSInfo: - return SProcDPMSInfo(client); + return ProcDPMSInfo(client); case X_DPMSSelectInput: return SProcDPMSSelectInput(client); default: diff --git a/Xext/geext.c b/Xext/geext.c index ac21b7a53..a116e9d3c 100644 --- a/Xext/geext.c +++ b/Xext/geext.c @@ -23,26 +23,32 @@ * Author: Peter Hutterer, University of South Australia, NICTA */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "windowstr.h" #include <X11/extensions/ge.h> -#include "geint.h" #include "geext.h" #include "protocol-versions.h" #include "extinit_priv.h" DevPrivateKeyRec GEClientPrivateKeyRec; -GEExtension GEExtensions[MAXEXTENSIONS]; +#define GEClientPrivateKey (&GEClientPrivateKeyRec) -/* Major available requests */ -static const int version_requests[] = { - X_GEQueryVersion, /* before client sends QueryVersion */ - X_GEQueryVersion, /* must be set to last request in version 1 */ -}; +/** Struct to keep information about registered extensions */ +typedef struct _GEExtension { + /** Event swapping routine */ + void (*evswap) (xGenericEvent *from, xGenericEvent *to); +} GEExtension, *GEExtensionPtr; + +static GEExtension GEExtensions[MAXEXTENSIONS]; + +typedef struct _GEClientInfo { + CARD32 major_version; + CARD32 minor_version; +} GEClientInfoRec, *GEClientInfoPtr; + +#define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey))) /* Forward declarations */ static void SGEGenericEvent(xEvent *from, xEvent *to); @@ -89,11 +95,6 @@ ProcGEQueryVersion(ClientPtr client) return Success; } -static int (*ProcGEVector[GENumberRequests]) (ClientPtr) = { - /* Version 1.0 */ - ProcGEQueryVersion, -}; - /************************************************************/ /* swapped request handlers */ /************************************************************/ @@ -101,19 +102,12 @@ static int _X_COLD SProcGEQueryVersion(ClientPtr client) { REQUEST(xGEQueryVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGEQueryVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); - return (*ProcGEVector[stuff->ReqType]) (client); + return ProcGEQueryVersion(client); } -static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = { - /* Version 1.0 */ - SProcGEQueryVersion -}; - /************************************************************/ /* callbacks */ /************************************************************/ @@ -122,32 +116,29 @@ static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = { static int ProcGEDispatch(ClientPtr client) { - GEClientInfoPtr pGEClient = GEGetClient(client); - - REQUEST(xGEReq); + REQUEST(xReq); - if (pGEClient->major_version >= ARRAY_SIZE(version_requests)) + switch (stuff->data) { + case X_GEQueryVersion: + return ProcGEQueryVersion(client); + default: return BadRequest; - if (stuff->ReqType > version_requests[pGEClient->major_version]) - return BadRequest; - - return (ProcGEVector[stuff->ReqType]) (client); + } } /* dispatch swapped requests */ static int _X_COLD SProcGEDispatch(ClientPtr client) { - GEClientInfoPtr pGEClient = GEGetClient(client); - - REQUEST(xGEReq); + REQUEST(xReq); + swaps(&stuff->length); - if (pGEClient->major_version >= ARRAY_SIZE(version_requests)) - return BadRequest; - if (stuff->ReqType > version_requests[pGEClient->major_version]) + switch (stuff->data) { + case X_GEQueryVersion: + return SProcGEQueryVersion(client); + default: return BadRequest; - - return (*SProcGEVector[stuff->ReqType]) (client); + } } /* Reset extension. Called on server shutdown. */ @@ -186,24 +177,16 @@ SGEGenericEvent(xEvent *from, xEvent *to) void GEExtensionInit(void) { - ExtensionEntry *extEntry; - if (!dixRegisterPrivateKey (&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec))) FatalError("GEExtensionInit: GE private request failed.\n"); - if ((extEntry = AddExtension(GE_NAME, - 0, GENumberErrors, - ProcGEDispatch, SProcGEDispatch, - GEResetProc, StandardMinorOpcode)) != 0) { - memset(GEExtensions, 0, sizeof(GEExtensions)); - - EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent; - } - else { + if (!AddExtension(GE_NAME, 0, GENumberErrors, ProcGEDispatch, SProcGEDispatch, + GEResetProc, StandardMinorOpcode)) FatalError("GEInit: AddExtensions failed.\n"); - } + memset(GEExtensions, 0, sizeof(GEExtensions)); + EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent; } /************************************************************/ diff --git a/Xext/geext.h b/Xext/geext.h index f46897966..79984e659 100644 --- a/Xext/geext.h +++ b/Xext/geext.h @@ -25,49 +25,11 @@ other dealings in this Software without prior written authorization from the author. */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - #ifndef _GEEXT_H_ #define _GEEXT_H_ -#include <X11/extensions/geproto.h> - -/** Struct to keep information about registered extensions */ -typedef struct _GEExtension { - /** Event swapping routine */ - void (*evswap) (xGenericEvent *from, xGenericEvent *to); -} GEExtension, *GEExtensionPtr; - -/* All registered extensions and their handling functions. */ -extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS]; -/* Typecast to generic event */ -#define GEV(ev) ((xGenericEvent*)(ev)) -/* Returns the extension offset from the event */ -#define GEEXT(ev) (GEV(ev)->extension) - -/* Return zero-based extension offset (offset - 128). Only for use in arrays */ -#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F) -/* True if mask is set for extension on window */ -#define GEMaskIsSet(pWin, extension, mask) \ - ((pWin)->optional && \ - (pWin)->optional->geMasks && \ - ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask))) - -/* Returns first client */ -#define GECLIENT(pWin) \ - (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL) - -/* Returns the event_fill for the given event */ -#define GEEventFill(ev) \ - GEExtensions[GEEXTIDX(ev)].evfill - -#define GEIsType(ev, ext, ev_type) \ - ((GEV(ev)->type == GenericEvent) && \ - GEEXT(ev) == (ext) && \ - GEV(ev)->evtype == (ev_type)) +#include <X11/Xfuncproto.h> +#include <X11/extensions/geproto.h> /* Interface for other extensions */ extern _X_EXPORT void GERegisterExtension(int extension, diff --git a/Xext/geint.h b/Xext/geint.h deleted file mode 100644 index 0ee28e471..000000000 --- a/Xext/geint.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Author: Peter Hutterer, University of South Australia, NICTA - */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _GEINT_H_ -#define _GEINT_H_ - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "extnsionst.h" -#include <X11/extensions/geproto.h> - -extern DevPrivateKeyRec GEClientPrivateKeyRec; - -#define GEClientPrivateKey (&GEClientPrivateKeyRec) - -typedef struct _GEClientInfo { - CARD32 major_version; - CARD32 minor_version; -} GEClientInfoRec, *GEClientInfoPtr; - -#define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey))) - -#endif /* _GEINT_H_ */ diff --git a/Xext/hashtable.c b/Xext/hashtable.c index 3434c9948..13db19f9d 100644 --- a/Xext/hashtable.c +++ b/Xext/hashtable.c @@ -1,6 +1,4 @@ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> #include "misc.h" diff --git a/Xext/meson.build b/Xext/meson.build index 0600fe98b..457c7ef2c 100644 --- a/Xext/meson.build +++ b/Xext/meson.build @@ -10,7 +10,6 @@ srcs_xext = [ hdrs_xext = [ 'geext.h', - 'geint.h', 'syncsdk.h', ] @@ -37,7 +36,6 @@ endif if build_xace srcs_xext += 'xace.c' - hdrs_xext += ['xace.h', 'xacestr.h'] endif if build_xf86bigfont diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 732e983ba..f43ae2a95 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -23,9 +23,7 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h index c16b9a5e2..b1a03e35d 100644 --- a/Xext/panoramiX.h +++ b/Xext/panoramiX.h @@ -39,9 +39,8 @@ Equipment Corporation. #ifndef _PANORAMIX_H_ #define _PANORAMIX_H_ -#define _PANORAMIX_SERVER #include <X11/extensions/panoramiXproto.h> -#undef _PANORAMIX_SERVER + #include "gcstruct.h" #include "dixstruct.h" diff --git a/Xext/panoramiXSwap.c b/Xext/panoramiXSwap.c index 022defdc7..9546251b3 100644 --- a/Xext/panoramiXSwap.c +++ b/Xext/panoramiXSwap.c @@ -23,9 +23,7 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> @@ -48,21 +46,9 @@ Equipment Corporation. #include "panoramiXh.h" static int _X_COLD -SProcPanoramiXQueryVersion(ClientPtr client) -{ - REQUEST(xPanoramiXQueryVersionReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); - return ProcPanoramiXQueryVersion(client); -} - -static int _X_COLD SProcPanoramiXGetState(ClientPtr client) { REQUEST(xPanoramiXGetStateReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); swapl(&stuff->window); return ProcPanoramiXGetState(client); @@ -72,8 +58,6 @@ static int _X_COLD SProcPanoramiXGetScreenCount(ClientPtr client) { REQUEST(xPanoramiXGetScreenCountReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); swapl(&stuff->window); return ProcPanoramiXGetScreenCount(client); @@ -83,41 +67,19 @@ static int _X_COLD SProcPanoramiXGetScreenSize(ClientPtr client) { REQUEST(xPanoramiXGetScreenSizeReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); swapl(&stuff->window); swapl(&stuff->screen); return ProcPanoramiXGetScreenSize(client); } -static int _X_COLD -SProcXineramaIsActive(ClientPtr client) -{ - REQUEST(xXineramaIsActiveReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXineramaIsActiveReq); - return ProcXineramaIsActive(client); -} - -static int _X_COLD -SProcXineramaQueryScreens(ClientPtr client) -{ - REQUEST(xXineramaQueryScreensReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); - return ProcXineramaQueryScreens(client); -} - int _X_COLD SProcPanoramiXDispatch(ClientPtr client) { REQUEST(xReq); switch (stuff->data) { case X_PanoramiXQueryVersion: - return SProcPanoramiXQueryVersion(client); + return ProcPanoramiXQueryVersion(client); case X_PanoramiXGetState: return SProcPanoramiXGetState(client); case X_PanoramiXGetScreenCount: @@ -125,9 +87,9 @@ SProcPanoramiXDispatch(ClientPtr client) case X_PanoramiXGetScreenSize: return SProcPanoramiXGetScreenSize(client); case X_XineramaIsActive: - return SProcXineramaIsActive(client); + return ProcXineramaIsActive(client); case X_XineramaQueryScreens: - return SProcXineramaQueryScreens(client); + return ProcXineramaQueryScreens(client); } return BadRequest; } diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 3e3567590..57424135a 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -25,15 +25,14 @@ Equipment Corporation. /* Massively rewritten by Mark Vojkovich <markv@valinux.com> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> #include <X11/Xproto.h> #include "dix/dix_priv.h" +#include "os/osdep.h" #include "windowstr.h" #include "dixfontstr.h" diff --git a/Xext/saver.c b/Xext/saver.c index e6dddbb03..1f5f82c35 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -26,16 +26,18 @@ in this Software without prior written authorization from the X Consortium. * Author: Keith Packard, MIT X Consortium */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> #include <X11/Xproto.h> #include <X11/extensions/saverproto.h> +#include "dix/colormap_priv.h" +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "os/osdep.h" +#include "os/screensaver.h" #include "misc.h" #include "os.h" @@ -45,16 +47,15 @@ in this Software without prior written authorization from the X Consortium. #include "extnsionst.h" #include "dixstruct.h" #include "resource.h" -#include "opaque.h" #include "gcstruct.h" #include "cursorstr.h" #include "colormapst.h" #include "xace.h" #include "inputstr.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ #ifdef DPMSExtension #include <X11/extensions/dpmsconst.h> #include "dpmsproc.h" @@ -62,32 +63,19 @@ in this Software without prior written authorization from the X Consortium. #include "protocol-versions.h" #include "extinit_priv.h" -static int ScreenSaverEventBase = 0; - -static Bool ScreenSaverHandle(ScreenPtr /* pScreen */ , - int /* xstate */ , - Bool /* force */ - ); - -static Bool - CreateSaverWindow(ScreenPtr /* pScreen */ - ); - -static Bool - DestroySaverWindow(ScreenPtr /* pScreen */ - ); - -static void - UninstallSaverColormap(ScreenPtr /* pScreen */ - ); +// temporary workaround for win32/mingw32 name clash +// see: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355 +#undef CreateWindow -static void - CheckScreenPrivate(ScreenPtr /* pScreen */ - ); +static int ScreenSaverEventBase = 0; -static void SScreenSaverNotifyEvent(xScreenSaverNotifyEvent * /* from */ , - xScreenSaverNotifyEvent * /* to */ - ); +static Bool ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force); +static Bool CreateSaverWindow(ScreenPtr pScreen); +static Bool DestroySaverWindow(ScreenPtr pScreen); +static void UninstallSaverColormap(ScreenPtr pScreen); +static void CheckScreenPrivate(ScreenPtr pScreen); +static void SScreenSaverNotifyEvent(xScreenSaverNotifyEvent *from, + xScreenSaverNotifyEvent *to); static RESTYPE SuspendType; /* resource type for suspension records */ @@ -194,8 +182,6 @@ static DevPrivateKeyRec ScreenPrivateKeyRec; dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v); #define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL) -#define New(t) (malloc(sizeof (t))) - static void CheckScreenPrivate(ScreenPtr pScreen) { @@ -218,7 +204,7 @@ MakeScreenPrivate(ScreenPtr pScreen) if (pPriv) return pPriv; - pPriv = New(ScreenSaverScreenPrivateRec); + pPriv = calloc(1, sizeof(ScreenSaverScreenPrivateRec)); if (!pPriv) return 0; pPriv->events = 0; @@ -268,7 +254,7 @@ setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask) } else { if (!pEv) { - pEv = New(ScreenSaverEventRec); + pEv = calloc(1, sizeof(ScreenSaverEventRec)); if (!pEv) { CheckScreenPrivate(pScreen); return FALSE; @@ -602,9 +588,9 @@ ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force) ret = TRUE; } -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension || !pScreen->myNum) -#endif +#endif /* XINERAMA */ SendScreenSaverNotify(pScreen, state, force); return ret; } @@ -625,6 +611,8 @@ ProcScreenSaverQueryVersion(ClientPtr client) if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); + swaps(&rep.majorVersion); + swaps(&rep.minorVersion); } WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), &rep); return Success; @@ -646,8 +634,7 @@ ProcScreenSaverQueryInfo(ClientPtr client) DixGetAttrAccess); if (rc != Success) return rc; - rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen, - DixGetAttrAccess); + rc = XaceHookScreensaverAccess(client, pDraw->pScreen, DixGetAttrAccess); if (rc != Success) return rc; @@ -716,8 +703,7 @@ ProcScreenSaverSelectInput(ClientPtr client) if (rc != Success) return rc; - rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen, - DixSetAttrAccess); + rc = XaceHookScreensaverAccess(client, pDraw->pScreen, DixSetAttrAccess); if (rc != Success) return rc; @@ -727,9 +713,8 @@ ProcScreenSaverSelectInput(ClientPtr client) } static int -ScreenSaverSetAttributes(ClientPtr client) +ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff) { - REQUEST(xScreenSaverSetAttributesReq); DrawablePtr pDraw; WindowPtr pParent; ScreenPtr pScreen; @@ -752,7 +737,6 @@ ScreenSaverSetAttributes(ClientPtr client) Colormap cmap; ColormapPtr pCmap; - REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixGetAttrAccess); if (ret != Success) @@ -760,11 +744,11 @@ ScreenSaverSetAttributes(ClientPtr client) pScreen = pDraw->pScreen; pParent = pScreen->root; - ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess); + ret = XaceHookScreensaverAccess(client, pScreen, DixSetAttrAccess); if (ret != Success) return ret; - len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); + len = client->req_len - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); if (Ones(stuff->mask) != len) return BadLength; if (!stuff->width || !stuff->height) { @@ -849,7 +833,7 @@ ScreenSaverSetAttributes(ClientPtr client) if (!pPriv) return FALSE; } - pAttr = New(ScreenSaverAttrRec); + pAttr = calloc(1, sizeof(ScreenSaverAttrRec)); if (!pAttr) { ret = BadAlloc; goto bail; @@ -1069,16 +1053,13 @@ ScreenSaverSetAttributes(ClientPtr client) } static int -ScreenSaverUnsetAttributes(ClientPtr client) +ScreenSaverUnsetAttributes(ClientPtr client, Drawable drawable) { - REQUEST(xScreenSaverSetAttributesReq); DrawablePtr pDraw; ScreenSaverScreenPrivatePtr pPriv; int rc; - REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixGetAttrAccess); + rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixGetAttrAccess); if (rc != Success) return rc; pPriv = GetScreenPrivate(pDraw->pScreen); @@ -1094,9 +1075,11 @@ ScreenSaverUnsetAttributes(ClientPtr client) static int ProcScreenSaverSetAttributes(ClientPtr client) { -#ifdef PANORAMIX + REQUEST(xScreenSaverSetAttributesReq); + REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); + +#ifdef XINERAMA if (!noPanoramiXExtension) { - REQUEST(xScreenSaverSetAttributesReq); PanoramiXRes *draw; PanoramiXRes *backPix = NULL; PanoramiXRes *bordPix = NULL; @@ -1105,15 +1088,13 @@ ProcScreenSaverSetAttributes(ClientPtr client) int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; XID orig_visual, tmp; - REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); - status = dixLookupResourceByClass((void **) &draw, stuff->drawable, XRC_DRAWABLE, client, DixWriteAccess); if (status != Success) return (status == BadValue) ? BadDrawable : status; len = - stuff->length - + client->req_len - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); if (Ones(stuff->mask) != len) return BadLength; @@ -1168,26 +1149,27 @@ ProcScreenSaverSetAttributes(ClientPtr client) if (orig_visual != CopyFromParent) stuff->visualID = PanoramiXTranslateVisualID(i, orig_visual); - status = ScreenSaverSetAttributes(client); + status = ScreenSaverSetAttributes(client, stuff); } return status; } -#endif +#endif /* XINERAMA */ - return ScreenSaverSetAttributes(client); + return ScreenSaverSetAttributes(client, stuff); } static int ProcScreenSaverUnsetAttributes(ClientPtr client) { -#ifdef PANORAMIX + REQUEST(xScreenSaverUnsetAttributesReq); + REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); + +#ifdef XINERAMA if (!noPanoramiXExtension) { - REQUEST(xScreenSaverUnsetAttributesReq); PanoramiXRes *draw; int rc, i; - REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); rc = dixLookupResourceByClass((void **) &draw, stuff->drawable, XRC_DRAWABLE, client, DixWriteAccess); @@ -1195,15 +1177,14 @@ ProcScreenSaverUnsetAttributes(ClientPtr client) return (rc == BadValue) ? BadDrawable : rc; for (i = PanoramiXNumScreens - 1; i > 0; i--) { - stuff->drawable = draw->info[i].id; - ScreenSaverUnsetAttributes(client); + ScreenSaverUnsetAttributes(client, draw->info[i].id); } stuff->drawable = draw->info[0].id; } -#endif +#endif /* XINERAMA */ - return ScreenSaverUnsetAttributes(client); + return ScreenSaverUnsetAttributes(client, stuff->drawable); } static int @@ -1272,11 +1253,13 @@ ProcScreenSaverSuspend(ClientPtr client) } static int (*NormalVector[]) (ClientPtr /* client */ ) = { -ProcScreenSaverQueryVersion, + ProcScreenSaverQueryVersion, ProcScreenSaverQueryInfo, ProcScreenSaverSelectInput, ProcScreenSaverSetAttributes, - ProcScreenSaverUnsetAttributes, ProcScreenSaverSuspend,}; + ProcScreenSaverUnsetAttributes, + ProcScreenSaverSuspend, +}; static int ProcScreenSaverDispatch(ClientPtr client) @@ -1289,19 +1272,9 @@ ProcScreenSaverDispatch(ClientPtr client) } static int _X_COLD -SProcScreenSaverQueryVersion(ClientPtr client) -{ - REQUEST(xScreenSaverQueryVersionReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq); - return ProcScreenSaverQueryVersion(client); -} - -static int _X_COLD SProcScreenSaverQueryInfo(ClientPtr client) { REQUEST(xScreenSaverQueryInfoReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq); swapl(&stuff->drawable); return ProcScreenSaverQueryInfo(client); @@ -1311,7 +1284,6 @@ static int _X_COLD SProcScreenSaverSelectInput(ClientPtr client) { REQUEST(xScreenSaverSelectInputReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq); swapl(&stuff->drawable); swapl(&stuff->eventMask); @@ -1322,7 +1294,6 @@ static int _X_COLD SProcScreenSaverSetAttributes(ClientPtr client) { REQUEST(xScreenSaverSetAttributesReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); swapl(&stuff->drawable); swaps(&stuff->x); @@ -1340,7 +1311,6 @@ static int _X_COLD SProcScreenSaverUnsetAttributes(ClientPtr client) { REQUEST(xScreenSaverUnsetAttributesReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); swapl(&stuff->drawable); return ProcScreenSaverUnsetAttributes(client); @@ -1350,19 +1320,19 @@ static int _X_COLD SProcScreenSaverSuspend(ClientPtr client) { REQUEST(xScreenSaverSuspendReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverSuspendReq); swapl(&stuff->suspend); return ProcScreenSaverSuspend(client); } static int (*SwappedVector[]) (ClientPtr /* client */ ) = { -SProcScreenSaverQueryVersion, + ProcScreenSaverQueryVersion, SProcScreenSaverQueryInfo, SProcScreenSaverSelectInput, SProcScreenSaverSetAttributes, - SProcScreenSaverUnsetAttributes, SProcScreenSaverSuspend,}; + SProcScreenSaverUnsetAttributes, + SProcScreenSaverSuspend, +}; static int _X_COLD SProcScreenSaverDispatch(ClientPtr client) diff --git a/Xext/security.c b/Xext/security.c index cf5f4051a..a717d4881 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -24,14 +24,19 @@ in this Software without prior written authorization from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include <X11/Xmd.h> +#include <X11/extensions/securproto.h> +#include <X11/Xfuncproto.h> #include "dix/dix_priv.h" #include "dix/registry_priv.h" +#include "include/extinit_priv.h" #include "os/audit.h" #include "os/auth.h" +#include "os/client_priv.h" +#include "os/osdep.h" #include "scrnintstr.h" #include "inputstr.h" @@ -41,7 +46,6 @@ in this Software without prior written authorization from The Open Group. #include "privates.h" #include "xacestr.h" #include "securitysrv.h" -#include <X11/extensions/securproto.h> #include "extinit.h" #include "protocol-versions.h" @@ -609,8 +613,6 @@ static int _X_COLD SProcSecurityQueryVersion(ClientPtr client) { REQUEST(xSecurityQueryVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSecurityQueryVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); @@ -624,8 +626,6 @@ SProcSecurityGenerateAuthorization(ClientPtr client) CARD32 *values; unsigned long nvalues; int values_offset; - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq); swaps(&stuff->nbytesAuthProto); swaps(&stuff->nbytesAuthData); @@ -633,10 +633,10 @@ SProcSecurityGenerateAuthorization(ClientPtr client) values_offset = bytes_to_int32(stuff->nbytesAuthProto) + bytes_to_int32(stuff->nbytesAuthData); if (values_offset > - stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq)) + client->req_len - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq)) return BadLength; values = (CARD32 *) (&stuff[1]) + values_offset; - nvalues = (((CARD32 *) stuff) + stuff->length) - values; + nvalues = (((CARD32 *) stuff) + client->req_len) - values; SwapLongs(values, nvalues); return ProcSecurityGenerateAuthorization(client); } /* SProcSecurityGenerateAuthorization */ @@ -645,8 +645,6 @@ static int _X_COLD SProcSecurityRevokeAuthorization(ClientPtr client) { REQUEST(xSecurityRevokeAuthorizationReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); swapl(&stuff->authId); return ProcSecurityRevokeAuthorization(client); diff --git a/Xext/securitysrv.h b/Xext/securitysrv.h index 8904242d6..f000e732f 100644 --- a/Xext/securitysrv.h +++ b/Xext/securitysrv.h @@ -30,27 +30,8 @@ from The Open Group. #ifndef _SECURITY_SRV_H #define _SECURITY_SRV_H -/* Allow client side portions of <X11/extensions/security.h> to compile */ -#ifndef Status -#define Status int -#define NEED_UNDEF_Status -#endif -#ifndef Display -#define Display void -#define NEED_UNDEF_Display -#endif - #include <X11/extensions/secur.h> -#ifdef NEED_UNDEF_Status -#undef Status -#undef NEED_UNDEF_Status -#endif -#ifdef NEED_UNDEF_Display -#undef Display -#undef NEED_UNDEF_Display -#endif - #include "input.h" /* for DeviceIntPtr */ #include "property.h" /* for PropertyPtr */ #include "pixmap.h" /* for DrawablePtr */ diff --git a/Xext/shape.c b/Xext/shape.c index 213e7cc3f..65c55699f 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -24,9 +24,7 @@ in this Software without prior written authorization from The Open Group. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> #include <X11/X.h> @@ -67,10 +65,10 @@ static void SShapeNotifyEvent(xShapeNotifyEvent * /* from */ , * externally by the Xfixes extension and are now defined in window.h */ -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ static int ShapeEventBase = 0; static RESTYPE ClientType, ShapeEventType; /* resource types for event masks */ @@ -227,24 +225,16 @@ ProcShapeQueryVersion(ClientPtr client) return Success; } -/***************** - * ProcShapeRectangles - * - *****************/ - static int -ProcShapeRectangles(ClientPtr client) +ShapeRectangles(ClientPtr client, xShapeRectanglesReq *stuff) { WindowPtr pWin; - - REQUEST(xShapeRectanglesReq); xRectangle *prects; int nrects, ctype, rc; RegionPtr srcRgn; RegionPtr *destRgn; CreateDftPtr createDefault; - REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq); UpdateCurrentTime(); rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess); if (rc != Success) @@ -268,7 +258,7 @@ ProcShapeRectangles(ClientPtr client) client->errorValue = stuff->ordering; return BadValue; } - nrects = ((stuff->length << 2) - sizeof(xShapeRectanglesReq)); + nrects = ((client->req_len << 2) - sizeof(xShapeRectanglesReq)); if (nrects & 4) return BadLength; nrects >>= 3; @@ -299,16 +289,19 @@ ProcShapeRectangles(ClientPtr client) stuff->xOff, stuff->yOff, createDefault); } -#ifdef PANORAMIX static int -ProcPanoramiXShapeRectangles(ClientPtr client) +ProcShapeRectangles(ClientPtr client) { REQUEST(xShapeRectanglesReq); + REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq); + +#ifdef XINERAMA + if (noPanoramiXExtension) + return ShapeRectangles(client, stuff); + PanoramiXRes *win; int j, result; - REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq); - result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, client, DixWriteAccess); if (result != Success) @@ -316,32 +309,27 @@ ProcPanoramiXShapeRectangles(ClientPtr client) FOR_NSCREENS(j) { stuff->dest = win->info[j].id; - result = ProcShapeRectangles(client); + result = ShapeRectangles(client, stuff); if (result != Success) break; } return result; -} +#else + return ShapeRectangles(client); #endif - -/************** - * ProcShapeMask - **************/ +} static int -ProcShapeMask(ClientPtr client) +ShapeMask(ClientPtr client, xShapeMaskReq *stuff) { WindowPtr pWin; ScreenPtr pScreen; - - REQUEST(xShapeMaskReq); RegionPtr srcRgn; RegionPtr *destRgn; PixmapPtr pPixmap; CreateDftPtr createDefault; int rc; - REQUEST_SIZE_MATCH(xShapeMaskReq); UpdateCurrentTime(); rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess); if (rc != Success) @@ -397,16 +385,19 @@ ProcShapeMask(ClientPtr client) stuff->xOff, stuff->yOff, createDefault); } -#ifdef PANORAMIX static int -ProcPanoramiXShapeMask(ClientPtr client) +ProcShapeMask(ClientPtr client) { REQUEST(xShapeMaskReq); + REQUEST_SIZE_MATCH(xShapeMaskReq); + +#ifdef XINERAMA + if (noPanoramiXExtension) + return ShapeMask(client, stuff); + PanoramiXRes *win, *pmap; int j, result; - REQUEST_SIZE_MATCH(xShapeMaskReq); - result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, client, DixWriteAccess); if (result != Success) @@ -425,24 +416,20 @@ ProcPanoramiXShapeMask(ClientPtr client) stuff->dest = win->info[j].id; if (pmap) stuff->src = pmap->info[j].id; - result = ProcShapeMask(client); + result = ShapeMask(client, stuff); if (result != Success) break; } return result; -} +#else + return ShapeMask(client, stuff); #endif - -/************ - * ProcShapeCombine - ************/ +} static int -ProcShapeCombine(ClientPtr client) +ShapeCombine(ClientPtr client, xShapeCombineReq *stuff) { WindowPtr pSrcWin, pDestWin; - - REQUEST(xShapeCombineReq); RegionPtr srcRgn; RegionPtr *destRgn; CreateDftPtr createDefault; @@ -450,7 +437,6 @@ ProcShapeCombine(ClientPtr client) RegionPtr tmp; int rc; - REQUEST_SIZE_MATCH(xShapeCombineReq); UpdateCurrentTime(); rc = dixLookupWindow(&pDestWin, stuff->dest, client, DixSetAttrAccess); if (rc != Success) @@ -525,16 +511,19 @@ ProcShapeCombine(ClientPtr client) stuff->xOff, stuff->yOff, createDefault); } -#ifdef PANORAMIX static int -ProcPanoramiXShapeCombine(ClientPtr client) +ProcShapeCombine(ClientPtr client) { REQUEST(xShapeCombineReq); + REQUEST_AT_LEAST_SIZE(xShapeCombineReq); + +#ifdef XINERAMA + if (noPanoramiXExtension) + return ShapeCombine(client, stuff); + PanoramiXRes *win, *win2; int j, result; - REQUEST_AT_LEAST_SIZE(xShapeCombineReq); - result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, client, DixWriteAccess); if (result != Success) @@ -548,28 +537,23 @@ ProcPanoramiXShapeCombine(ClientPtr client) FOR_NSCREENS(j) { stuff->dest = win->info[j].id; stuff->src = win2->info[j].id; - result = ProcShapeCombine(client); + result = ShapeCombine(client, stuff); if (result != Success) break; } return result; -} +#else + return ShapeCombine(client, stuff); #endif - -/************* - * ProcShapeOffset - *************/ +} static int -ProcShapeOffset(ClientPtr client) +ShapeOffset(ClientPtr client, xShapeOffsetReq *stuff) { WindowPtr pWin; - - REQUEST(xShapeOffsetReq); RegionPtr srcRgn; int rc; - REQUEST_SIZE_MATCH(xShapeOffsetReq); UpdateCurrentTime(); rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess); if (rc != Success) @@ -596,15 +580,18 @@ ProcShapeOffset(ClientPtr client) return Success; } -#ifdef PANORAMIX static int -ProcPanoramiXShapeOffset(ClientPtr client) +ProcShapeOffset(ClientPtr client) { REQUEST(xShapeOffsetReq); + REQUEST_AT_LEAST_SIZE(xShapeOffsetReq); + +#ifdef XINERAMA PanoramiXRes *win; int j, result; - REQUEST_AT_LEAST_SIZE(xShapeOffsetReq); + if (noPanoramiXExtension) + return ShapeOffset(client, stuff); result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, client, DixWriteAccess); @@ -613,13 +600,15 @@ ProcPanoramiXShapeOffset(ClientPtr client) FOR_NSCREENS(j) { stuff->dest = win->info[j].id; - result = ProcShapeOffset(client); + result = ShapeOffset(client, stuff); if (result != Success) break; } return result; -} +#else + return ShapeOffset(client, stuff); #endif +} static int ProcShapeQueryExtents(ClientPtr client) @@ -1037,33 +1026,13 @@ ProcShapeDispatch(ClientPtr client) case X_ShapeQueryVersion: return ProcShapeQueryVersion(client); case X_ShapeRectangles: -#ifdef PANORAMIX - if (!noPanoramiXExtension) - return ProcPanoramiXShapeRectangles(client); - else -#endif - return ProcShapeRectangles(client); + return ProcShapeRectangles(client); case X_ShapeMask: -#ifdef PANORAMIX - if (!noPanoramiXExtension) - return ProcPanoramiXShapeMask(client); - else -#endif - return ProcShapeMask(client); + return ProcShapeMask(client); case X_ShapeCombine: -#ifdef PANORAMIX - if (!noPanoramiXExtension) - return ProcPanoramiXShapeCombine(client); - else -#endif - return ProcShapeCombine(client); + return ProcShapeCombine(client); case X_ShapeOffset: -#ifdef PANORAMIX - if (!noPanoramiXExtension) - return ProcPanoramiXShapeOffset(client); - else -#endif - return ProcShapeOffset(client); + return ProcShapeOffset(client); case X_ShapeQueryExtents: return ProcShapeQueryExtents(client); case X_ShapeSelectInput: @@ -1093,20 +1062,9 @@ SShapeNotifyEvent(xShapeNotifyEvent * from, xShapeNotifyEvent * to) } static int _X_COLD -SProcShapeQueryVersion(ClientPtr client) -{ - REQUEST(xShapeQueryVersionReq); - - swaps(&stuff->length); - return ProcShapeQueryVersion(client); -} - -static int _X_COLD SProcShapeRectangles(ClientPtr client) { REQUEST(xShapeRectanglesReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq); swapl(&stuff->dest); swaps(&stuff->xOff); @@ -1119,8 +1077,6 @@ static int _X_COLD SProcShapeMask(ClientPtr client) { REQUEST(xShapeMaskReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShapeMaskReq); swapl(&stuff->dest); swaps(&stuff->xOff); @@ -1133,8 +1089,6 @@ static int _X_COLD SProcShapeCombine(ClientPtr client) { REQUEST(xShapeCombineReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShapeCombineReq); swapl(&stuff->dest); swaps(&stuff->xOff); @@ -1147,8 +1101,6 @@ static int _X_COLD SProcShapeOffset(ClientPtr client) { REQUEST(xShapeOffsetReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShapeOffsetReq); swapl(&stuff->dest); swaps(&stuff->xOff); @@ -1160,8 +1112,6 @@ static int _X_COLD SProcShapeQueryExtents(ClientPtr client) { REQUEST(xShapeQueryExtentsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShapeQueryExtentsReq); swapl(&stuff->window); return ProcShapeQueryExtents(client); @@ -1171,8 +1121,6 @@ static int _X_COLD SProcShapeSelectInput(ClientPtr client) { REQUEST(xShapeSelectInputReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShapeSelectInputReq); swapl(&stuff->window); return ProcShapeSelectInput(client); @@ -1182,8 +1130,6 @@ static int _X_COLD SProcShapeInputSelected(ClientPtr client) { REQUEST(xShapeInputSelectedReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShapeInputSelectedReq); swapl(&stuff->window); return ProcShapeInputSelected(client); @@ -1193,7 +1139,6 @@ static int _X_COLD SProcShapeGetRectangles(ClientPtr client) { REQUEST(xShapeGetRectanglesReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShapeGetRectanglesReq); swapl(&stuff->window); return ProcShapeGetRectangles(client); @@ -1205,7 +1150,7 @@ SProcShapeDispatch(ClientPtr client) REQUEST(xReq); switch (stuff->data) { case X_ShapeQueryVersion: - return SProcShapeQueryVersion(client); + return ProcShapeQueryVersion(client); case X_ShapeRectangles: return SProcShapeRectangles(client); case X_ShapeMask: diff --git a/Xext/shm.c b/Xext/shm.c index 427cf1b4e..94ecaad84 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -28,9 +28,7 @@ in this Software without prior written authorization from The Open Group. #define SHM -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/types.h> #include <sys/ipc.h> @@ -47,6 +45,7 @@ in this Software without prior written authorization from The Open Group. #include "dix/dix_priv.h" #include "os/auth.h" #include "os/busfault.h" +#include "os/client_priv.h" #include "os/osdep.h" #include "misc.h" @@ -91,10 +90,10 @@ in this Software without prior written authorization from The Open Group. #define SHMPERM_MODE(p) p->mode #endif -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ typedef struct _ShmScrPrivateRec { CloseScreenProcPtr CloseScreen; @@ -252,13 +251,14 @@ ShmDestroyPixmap(PixmapPtr pPixmap) ScreenPtr pScreen = pPixmap->drawable.pScreen; ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); void *shmdesc = NULL; - Bool ret; + Bool ret = TRUE; if (pPixmap->refcnt == 1) shmdesc = dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey); pScreen->DestroyPixmap = screen_priv->destroyPixmap; - ret = (*pScreen->DestroyPixmap) (pPixmap); + if (pScreen->DestroyPixmap) + ret = pScreen->DestroyPixmap(pPixmap); screen_priv->destroyPixmap = pScreen->DestroyPixmap; pScreen->DestroyPixmap = ShmDestroyPixmap; @@ -482,8 +482,8 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC, PixmapBytePad(w, depth), data); if (!pPixmap) return; - pGC->ops->CopyArea((DrawablePtr) pPixmap, dst, pGC, sx, sy, sw, sh, dx, - dy); + (void) pGC->ops->CopyArea((DrawablePtr) pPixmap, dst, pGC, + sx, sy, sw, sh, dx, dy); FreeScratchPixmapHeader(pPixmap); } else { @@ -732,7 +732,7 @@ ProcShmGetImage(ClientPtr client) return Success; } -#ifdef PANORAMIX +#ifdef XINERAMA static int ProcPanoramiXShmPutImage(ClientPtr client) { @@ -997,7 +997,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client) stuff->offset); if (pMap) { - result = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, + result = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP, pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (result != Success) { pDraw->pScreen->DestroyPixmap(pMap); @@ -1028,7 +1028,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client) return result; } -#endif +#endif /* XINERAMA */ static PixmapPtr fbShmCreatePixmap(ScreenPtr pScreen, @@ -1112,7 +1112,7 @@ ProcShmCreatePixmap(ClientPtr client) shmdesc->addr + stuff->offset); if (pMap) { - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, X11_RESTYPE_PIXMAP, + rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP, pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) { pDraw->pScreen->DestroyPixmap(pMap); @@ -1348,22 +1348,22 @@ ProcShmDispatch(ClientPtr client) case X_ShmDetach: return ProcShmDetach(client); case X_ShmPutImage: -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return ProcPanoramiXShmPutImage(client); -#endif +#endif /* XINERAMA */ return ProcShmPutImage(client); case X_ShmGetImage: -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return ProcPanoramiXShmGetImage(client); -#endif +#endif /* XINERAMA */ return ProcShmGetImage(client); case X_ShmCreatePixmap: -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return ProcPanoramiXShmCreatePixmap(client); -#endif +#endif /* XINERAMA */ return ProcShmCreatePixmap(client); #ifdef SHM_FD_PASSING case X_ShmAttachFd: @@ -1389,19 +1389,9 @@ SShmCompletionEvent(xShmCompletionEvent * from, xShmCompletionEvent * to) } static int _X_COLD -SProcShmQueryVersion(ClientPtr client) -{ - REQUEST(xShmQueryVersionReq); - - swaps(&stuff->length); - return ProcShmQueryVersion(client); -} - -static int _X_COLD SProcShmAttach(ClientPtr client) { REQUEST(xShmAttachReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShmAttachReq); swapl(&stuff->shmseg); swapl(&stuff->shmid); @@ -1412,7 +1402,6 @@ static int _X_COLD SProcShmDetach(ClientPtr client) { REQUEST(xShmDetachReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShmDetachReq); swapl(&stuff->shmseg); return ProcShmDetach(client); @@ -1422,7 +1411,6 @@ static int _X_COLD SProcShmPutImage(ClientPtr client) { REQUEST(xShmPutImageReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShmPutImageReq); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -1443,7 +1431,6 @@ static int _X_COLD SProcShmGetImage(ClientPtr client) { REQUEST(xShmGetImageReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShmGetImageReq); swapl(&stuff->drawable); swaps(&stuff->x); @@ -1460,7 +1447,6 @@ static int _X_COLD SProcShmCreatePixmap(ClientPtr client) { REQUEST(xShmCreatePixmapReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShmCreatePixmapReq); swapl(&stuff->pid); swapl(&stuff->drawable); @@ -1477,7 +1463,6 @@ SProcShmAttachFd(ClientPtr client) { REQUEST(xShmAttachFdReq); SetReqFds(client, 1); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShmAttachFdReq); swapl(&stuff->shmseg); return ProcShmAttachFd(client); @@ -1487,7 +1472,6 @@ static int _X_COLD SProcShmCreateSegment(ClientPtr client) { REQUEST(xShmCreateSegmentReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xShmCreateSegmentReq); swapl(&stuff->shmseg); swapl(&stuff->size); @@ -1501,7 +1485,7 @@ SProcShmDispatch(ClientPtr client) REQUEST(xReq); if (stuff->data == X_ShmQueryVersion) - return SProcShmQueryVersion(client); + return ProcShmQueryVersion(client); if (!client->local) return BadRequest; diff --git a/Xext/sleepuntil.c b/Xext/sleepuntil.c index 3ff7a1d04..0fbfab10a 100644 --- a/Xext/sleepuntil.c +++ b/Xext/sleepuntil.c @@ -27,9 +27,7 @@ in this Software without prior written authorization from The Open Group. /* dixsleep.c - implement millisecond timeouts for X clients */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "sleepuntil.h" #include <X11/X.h> diff --git a/Xext/sync.c b/Xext/sync.c index a37444bb0..8eec01ebb 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -49,9 +49,7 @@ PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include <stdio.h> @@ -61,6 +59,7 @@ PERFORMANCE OF THIS SOFTWARE. #include <X11/extensions/syncproto.h> #include "dix/dix_priv.h" +#include "os/osdep.h" #include "scrnintstr.h" #include "os.h" @@ -68,7 +67,6 @@ PERFORMANCE OF THIS SOFTWARE. #include "dixstruct.h" #include "pixmapstr.h" #include "resource.h" -#include "opaque.h" #include "syncsrv.h" #include "syncsdk.h" #include "protocol-versions.h" @@ -202,8 +200,8 @@ SyncAddTriggerToSyncObject(SyncTrigger * pTrigger) return Success; } - if (!(pCur = malloc(sizeof(SyncTriggerList)))) - return BadAlloc; + /* Failure is not an option, it's succeed or burst! */ + pCur = XNFalloc(sizeof(SyncTriggerList)); pCur->pTrigger = pTrigger; pCur->next = pTrigger->pSync->pTriglist; @@ -332,11 +330,6 @@ SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject, client->errorValue = syncObject; return rc; } - if (pSync != pTrigger->pSync) { /* new counter for trigger */ - SyncDeleteTriggerFromSyncObject(pTrigger); - pTrigger->pSync = pSync; - newSyncObject = TRUE; - } } /* if system counter, ask it what the current value is */ @@ -358,6 +351,24 @@ SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject, } } + if (changes & (XSyncCAValueType | XSyncCAValue)) { + if (pTrigger->value_type == XSyncAbsolute) + pTrigger->test_value = pTrigger->wait_value; + else { /* relative */ + Bool overflow; + + if (pCounter == NULL) + return BadMatch; + + overflow = checked_int64_add(&pTrigger->test_value, + pCounter->value, pTrigger->wait_value); + if (overflow) { + client->errorValue = pTrigger->wait_value >> 32; + return BadValue; + } + } + } + if (changes & XSyncCATestType) { if (pSync && SYNC_FENCE == pSync->type) { @@ -386,21 +397,11 @@ SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject, } } - if (changes & (XSyncCAValueType | XSyncCAValue)) { - if (pTrigger->value_type == XSyncAbsolute) - pTrigger->test_value = pTrigger->wait_value; - else { /* relative */ - Bool overflow; - - if (pCounter == NULL) - return BadMatch; - - overflow = checked_int64_add(&pTrigger->test_value, - pCounter->value, pTrigger->wait_value); - if (overflow) { - client->errorValue = pTrigger->wait_value >> 32; - return BadValue; - } + if (changes & XSyncCACounter) { + if (pSync != pTrigger->pSync) { /* new counter for trigger */ + SyncDeleteTriggerFromSyncObject(pTrigger); + pTrigger->pSync = pSync; + newSyncObject = TRUE; } } @@ -408,8 +409,7 @@ SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject, * a new counter on a trigger */ if (newSyncObject) { - if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success) - return rc; + SyncAddTriggerToSyncObject(pTrigger); } else if (pCounter && IsSystemCounter(pCounter)) { SyncComputeBracketValues(pCounter); @@ -800,8 +800,14 @@ SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm * pAlarm, Mask mask, int status; XSyncCounter counter; Mask origmask = mask; + SyncTrigger trigger; + Bool select_events_changed = FALSE; + Bool select_events_value = FALSE; + int64_t delta; - counter = pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None; + trigger = pAlarm->trigger; + delta = pAlarm->delta; + counter = trigger.pSync ? trigger.pSync->id : None; while (mask) { int index2 = lowbit(mask); @@ -817,24 +823,24 @@ SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm * pAlarm, Mask mask, case XSyncCAValueType: mask &= ~XSyncCAValueType; /* sanity check in SyncInitTrigger */ - pAlarm->trigger.value_type = *values++; + trigger.value_type = *values++; break; case XSyncCAValue: mask &= ~XSyncCAValue; - pAlarm->trigger.wait_value = ((int64_t)values[0] << 32) | values[1]; + trigger.wait_value = ((int64_t)values[0] << 32) | values[1]; values += 2; break; case XSyncCATestType: mask &= ~XSyncCATestType; /* sanity check in SyncInitTrigger */ - pAlarm->trigger.test_type = *values++; + trigger.test_type = *values++; break; case XSyncCADelta: mask &= ~XSyncCADelta; - pAlarm->delta = ((int64_t)values[0] << 32) | values[1]; + delta = ((int64_t)values[0] << 32) | values[1]; values += 2; break; @@ -844,10 +850,8 @@ SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm * pAlarm, Mask mask, client->errorValue = *values; return BadValue; } - status = SyncEventSelectForAlarm(pAlarm, client, - (Bool) (*values++)); - if (status != Success) - return status; + select_events_value = (Bool) (*values++); + select_events_changed = TRUE; break; default: @@ -856,25 +860,33 @@ SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm * pAlarm, Mask mask, } } + if (select_events_changed) { + status = SyncEventSelectForAlarm(pAlarm, client, select_events_value); + if (status != Success) + return status; + } + /* "If the test-type is PositiveComparison or PositiveTransition * and delta is less than zero, or if the test-type is * NegativeComparison or NegativeTransition and delta is * greater than zero, a Match error is generated." */ if (origmask & (XSyncCADelta | XSyncCATestType)) { - if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) || - (pAlarm->trigger.test_type == XSyncPositiveTransition)) - && pAlarm->delta < 0) + if ((((trigger.test_type == XSyncPositiveComparison) || + (trigger.test_type == XSyncPositiveTransition)) + && delta < 0) || - (((pAlarm->trigger.test_type == XSyncNegativeComparison) || - (pAlarm->trigger.test_type == XSyncNegativeTransition)) - && pAlarm->delta > 0) + (((trigger.test_type == XSyncNegativeComparison) || + (trigger.test_type == XSyncNegativeTransition)) + && delta > 0) ) { return BadMatch; } } /* postpone this until now, when we're sure nothing else can go wrong */ + pAlarm->delta = delta; + pAlarm->trigger = trigger; if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter, origmask & XSyncCAAllTrigger)) != Success) return status; @@ -2154,30 +2166,9 @@ ProcSyncDispatch(ClientPtr client) */ static int _X_COLD -SProcSyncInitialize(ClientPtr client) -{ - REQUEST(xSyncInitializeReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xSyncInitializeReq); - - return ProcSyncInitialize(client); -} - -static int _X_COLD -SProcSyncListSystemCounters(ClientPtr client) -{ - REQUEST(xSyncListSystemCountersReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xSyncListSystemCountersReq); - - return ProcSyncListSystemCounters(client); -} - -static int _X_COLD SProcSyncCreateCounter(ClientPtr client) { REQUEST(xSyncCreateCounterReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncCreateCounterReq); swapl(&stuff->cid); swapl(&stuff->initial_value_lo); @@ -2190,7 +2181,6 @@ static int _X_COLD SProcSyncSetCounter(ClientPtr client) { REQUEST(xSyncSetCounterReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncSetCounterReq); swapl(&stuff->cid); swapl(&stuff->value_lo); @@ -2203,7 +2193,6 @@ static int _X_COLD SProcSyncChangeCounter(ClientPtr client) { REQUEST(xSyncChangeCounterReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncChangeCounterReq); swapl(&stuff->cid); swapl(&stuff->value_lo); @@ -2216,7 +2205,6 @@ static int _X_COLD SProcSyncQueryCounter(ClientPtr client) { REQUEST(xSyncQueryCounterReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncQueryCounterReq); swapl(&stuff->counter); @@ -2227,7 +2215,6 @@ static int _X_COLD SProcSyncDestroyCounter(ClientPtr client) { REQUEST(xSyncDestroyCounterReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); swapl(&stuff->counter); @@ -2238,7 +2225,6 @@ static int _X_COLD SProcSyncAwait(ClientPtr client) { REQUEST(xSyncAwaitReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); SwapRestL(stuff); @@ -2249,7 +2235,6 @@ static int _X_COLD SProcSyncCreateAlarm(ClientPtr client) { REQUEST(xSyncCreateAlarmReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); swapl(&stuff->id); swapl(&stuff->valueMask); @@ -2262,7 +2247,6 @@ static int _X_COLD SProcSyncChangeAlarm(ClientPtr client) { REQUEST(xSyncChangeAlarmReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); swapl(&stuff->alarm); swapl(&stuff->valueMask); @@ -2274,7 +2258,6 @@ static int _X_COLD SProcSyncQueryAlarm(ClientPtr client) { REQUEST(xSyncQueryAlarmReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); swapl(&stuff->alarm); @@ -2285,7 +2268,6 @@ static int _X_COLD SProcSyncDestroyAlarm(ClientPtr client) { REQUEST(xSyncDestroyAlarmReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); swapl(&stuff->alarm); @@ -2296,7 +2278,6 @@ static int _X_COLD SProcSyncSetPriority(ClientPtr client) { REQUEST(xSyncSetPriorityReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncSetPriorityReq); swapl(&stuff->id); swapl(&stuff->priority); @@ -2308,7 +2289,6 @@ static int _X_COLD SProcSyncGetPriority(ClientPtr client) { REQUEST(xSyncGetPriorityReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncGetPriorityReq); swapl(&stuff->id); @@ -2319,7 +2299,6 @@ static int _X_COLD SProcSyncCreateFence(ClientPtr client) { REQUEST(xSyncCreateFenceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncCreateFenceReq); swapl(&stuff->d); swapl(&stuff->fid); @@ -2331,7 +2310,6 @@ static int _X_COLD SProcSyncTriggerFence(ClientPtr client) { REQUEST(xSyncTriggerFenceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncTriggerFenceReq); swapl(&stuff->fid); @@ -2342,7 +2320,6 @@ static int _X_COLD SProcSyncResetFence(ClientPtr client) { REQUEST(xSyncResetFenceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncResetFenceReq); swapl(&stuff->fid); @@ -2353,7 +2330,6 @@ static int _X_COLD SProcSyncDestroyFence(ClientPtr client) { REQUEST(xSyncDestroyFenceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncDestroyFenceReq); swapl(&stuff->fid); @@ -2364,7 +2340,6 @@ static int _X_COLD SProcSyncQueryFence(ClientPtr client) { REQUEST(xSyncQueryFenceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSyncQueryFenceReq); swapl(&stuff->fid); @@ -2375,7 +2350,6 @@ static int _X_COLD SProcSyncAwaitFence(ClientPtr client) { REQUEST(xSyncAwaitFenceReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); SwapRestL(stuff); @@ -2389,9 +2363,9 @@ SProcSyncDispatch(ClientPtr client) switch (stuff->data) { case X_SyncInitialize: - return SProcSyncInitialize(client); + return ProcSyncInitialize(client); case X_SyncListSystemCounters: - return SProcSyncListSystemCounters(client); + return ProcSyncListSystemCounters(client); case X_SyncCreateCounter: return SProcSyncCreateCounter(client); case X_SyncSetCounter: diff --git a/Xext/vidmode.c b/Xext/vidmode.c index c7c61647e..06b710288 100644 --- a/Xext/vidmode.c +++ b/Xext/vidmode.c @@ -29,9 +29,7 @@ from Kaleb S. KEITHLEY */ /* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef XF86VIDMODE @@ -471,7 +469,7 @@ ProcVidModeAddModeLine(ClientPtr client) if (ver < 2) { /* convert from old format */ stuff = &newstuff; - stuff->length = oldstuff->length; + stuff->length = client->req_len; stuff->screen = oldstuff->screen; stuff->dotclock = oldstuff->dotclock; stuff->hdisplay = oldstuff->hdisplay; @@ -641,7 +639,7 @@ ProcVidModeDeleteModeLine(ClientPtr client) if (ver < 2) { /* convert from old format */ stuff = &newstuff; - stuff->length = oldstuff->length; + stuff->length = client->req_len; stuff->screen = oldstuff->screen; stuff->dotclock = oldstuff->dotclock; stuff->hdisplay = oldstuff->hdisplay; @@ -670,7 +668,7 @@ ProcVidModeDeleteModeLine(ClientPtr client) "len = %d, length = %d\n", (unsigned long) client->req_len, (int) sizeof(xXF86VidModeDeleteModeLineReq) >> 2, - (unsigned long) stuff->privsize, len, stuff->length); + (unsigned long) stuff->privsize, len, client->req_len); return BadLength; } @@ -765,7 +763,7 @@ ProcVidModeModModeLine(ClientPtr client) if (ver < 2) { /* convert from old format */ stuff = &newstuff; - stuff->length = oldstuff->length; + stuff->length = client->req_len; stuff->screen = oldstuff->screen; stuff->hdisplay = oldstuff->hdisplay; stuff->hsyncstart = oldstuff->hsyncstart; @@ -899,7 +897,7 @@ ProcVidModeValidateModeLine(ClientPtr client) if (ver < 2) { /* convert from old format */ stuff = &newstuff; - stuff->length = oldstuff->length; + stuff->length = client->req_len; stuff->screen = oldstuff->screen; stuff->dotclock = oldstuff->dotclock; stuff->hdisplay = oldstuff->hdisplay; @@ -1052,7 +1050,7 @@ ProcVidModeSwitchToMode(ClientPtr client) if (ver < 2) { /* convert from old format */ stuff = &newstuff; - stuff->length = oldstuff->length; + stuff->length = client->req_len; stuff->screen = oldstuff->screen; stuff->dotclock = oldstuff->dotclock; stuff->hdisplay = oldstuff->hdisplay; @@ -1704,18 +1702,9 @@ ProcVidModeDispatch(ClientPtr client) } static int _X_COLD -SProcVidModeQueryVersion(ClientPtr client) -{ - REQUEST(xXF86VidModeQueryVersionReq); - swaps(&stuff->length); - return ProcVidModeQueryVersion(client); -} - -static int _X_COLD SProcVidModeGetModeLine(ClientPtr client) { REQUEST(xXF86VidModeGetModeLineReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); swaps(&stuff->screen); return ProcVidModeGetModeLine(client); @@ -1725,7 +1714,6 @@ static int _X_COLD SProcVidModeGetAllModeLines(ClientPtr client) { REQUEST(xXF86VidModeGetAllModeLinesReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq); swaps(&stuff->screen); return ProcVidModeGetAllModeLines(client); @@ -1741,7 +1729,6 @@ SProcVidModeAddModeLine(ClientPtr client) REQUEST(xXF86VidModeAddModeLineReq); ver = ClientMajorVersion(client); if (ver < 2) { - swaps(&oldstuff->length); REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq); swapl(&oldstuff->screen); swaps(&oldstuff->hdisplay); @@ -1757,7 +1744,6 @@ SProcVidModeAddModeLine(ClientPtr client) SwapRestL(oldstuff); } else { - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); swapl(&stuff->screen); swaps(&stuff->hdisplay); @@ -1786,7 +1772,6 @@ SProcVidModeDeleteModeLine(ClientPtr client) REQUEST(xXF86VidModeDeleteModeLineReq); ver = ClientMajorVersion(client); if (ver < 2) { - swaps(&oldstuff->length); REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq); swapl(&oldstuff->screen); swaps(&oldstuff->hdisplay); @@ -1802,7 +1787,6 @@ SProcVidModeDeleteModeLine(ClientPtr client) SwapRestL(oldstuff); } else { - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); swapl(&stuff->screen); swaps(&stuff->hdisplay); @@ -1831,7 +1815,6 @@ SProcVidModeModModeLine(ClientPtr client) REQUEST(xXF86VidModeModModeLineReq); ver = ClientMajorVersion(client); if (ver < 2) { - swaps(&oldstuff->length); REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq); swapl(&oldstuff->screen); swaps(&oldstuff->hdisplay); @@ -1847,7 +1830,6 @@ SProcVidModeModModeLine(ClientPtr client) SwapRestL(oldstuff); } else { - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); swapl(&stuff->screen); swaps(&stuff->hdisplay); @@ -1876,7 +1858,6 @@ SProcVidModeValidateModeLine(ClientPtr client) REQUEST(xXF86VidModeValidateModeLineReq); ver = ClientMajorVersion(client); if (ver < 2) { - swaps(&oldstuff->length); REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq); swapl(&oldstuff->screen); swaps(&oldstuff->hdisplay); @@ -1892,7 +1873,6 @@ SProcVidModeValidateModeLine(ClientPtr client) SwapRestL(oldstuff); } else { - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); swapl(&stuff->screen); swaps(&stuff->hdisplay); @@ -1915,7 +1895,6 @@ static int _X_COLD SProcVidModeSwitchMode(ClientPtr client) { REQUEST(xXF86VidModeSwitchModeReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq); swaps(&stuff->screen); swaps(&stuff->zoom); @@ -1926,7 +1905,6 @@ static int _X_COLD SProcVidModeSwitchToMode(ClientPtr client) { REQUEST(xXF86VidModeSwitchToModeReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq); swapl(&stuff->screen); return ProcVidModeSwitchToMode(client); @@ -1936,7 +1914,6 @@ static int _X_COLD SProcVidModeLockModeSwitch(ClientPtr client) { REQUEST(xXF86VidModeLockModeSwitchReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq); swaps(&stuff->screen); swaps(&stuff->lock); @@ -1947,7 +1924,6 @@ static int _X_COLD SProcVidModeGetMonitor(ClientPtr client) { REQUEST(xXF86VidModeGetMonitorReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq); swaps(&stuff->screen); return ProcVidModeGetMonitor(client); @@ -1957,7 +1933,6 @@ static int _X_COLD SProcVidModeGetViewPort(ClientPtr client) { REQUEST(xXF86VidModeGetViewPortReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq); swaps(&stuff->screen); return ProcVidModeGetViewPort(client); @@ -1967,7 +1942,6 @@ static int _X_COLD SProcVidModeSetViewPort(ClientPtr client) { REQUEST(xXF86VidModeSetViewPortReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq); swaps(&stuff->screen); swapl(&stuff->x); @@ -1979,7 +1953,6 @@ static int _X_COLD SProcVidModeGetDotClocks(ClientPtr client) { REQUEST(xXF86VidModeGetDotClocksReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq); swaps(&stuff->screen); return ProcVidModeGetDotClocks(client); @@ -1989,7 +1962,6 @@ static int _X_COLD SProcVidModeSetClientVersion(ClientPtr client) { REQUEST(xXF86VidModeSetClientVersionReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); swaps(&stuff->major); swaps(&stuff->minor); @@ -2000,7 +1972,6 @@ static int _X_COLD SProcVidModeSetGamma(ClientPtr client) { REQUEST(xXF86VidModeSetGammaReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq); swaps(&stuff->screen); swapl(&stuff->red); @@ -2013,7 +1984,6 @@ static int _X_COLD SProcVidModeGetGamma(ClientPtr client) { REQUEST(xXF86VidModeGetGammaReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq); swaps(&stuff->screen); return ProcVidModeGetGamma(client); @@ -2025,7 +1995,6 @@ SProcVidModeSetGammaRamp(ClientPtr client) int length; REQUEST(xXF86VidModeSetGammaRampReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq); swaps(&stuff->size); swaps(&stuff->screen); @@ -2039,7 +2008,6 @@ static int _X_COLD SProcVidModeGetGammaRamp(ClientPtr client) { REQUEST(xXF86VidModeGetGammaRampReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq); swaps(&stuff->size); swaps(&stuff->screen); @@ -2050,7 +2018,6 @@ static int _X_COLD SProcVidModeGetGammaRampSize(ClientPtr client) { REQUEST(xXF86VidModeGetGammaRampSizeReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq); swaps(&stuff->screen); return ProcVidModeGetGammaRampSize(client); @@ -2060,7 +2027,6 @@ static int _X_COLD SProcVidModeGetPermissions(ClientPtr client) { REQUEST(xXF86VidModeGetPermissionsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq); swaps(&stuff->screen); return ProcVidModeGetPermissions(client); @@ -2072,7 +2038,7 @@ SProcVidModeDispatch(ClientPtr client) REQUEST(xReq); switch (stuff->data) { case X_XF86VidModeQueryVersion: - return SProcVidModeQueryVersion(client); + return ProcVidModeQueryVersion(client); case X_XF86VidModeGetModeLine: return SProcVidModeGetModeLine(client); case X_XF86VidModeGetMonitor: diff --git a/Xext/xace.c b/Xext/xace.c index 580566a5d..2ceea394d 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -17,11 +17,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdarg.h> + +#include "os/client_priv.h" + #include "scrnintstr.h" #include "extnsionst.h" #include "pixmapstr.h" @@ -33,9 +34,8 @@ CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = { 0 }; /* Special-cased hook functions. Called by Xserver. */ -#undef XaceHookDispatch int -XaceHookDispatch(ClientPtr client, int major) +XaceHookDispatch0(ClientPtr client, int major) { /* Call the extension dispatch hook */ ExtensionEntry *ext = GetExtensionEntry(major); @@ -63,130 +63,85 @@ XaceHookSelectionAccess(ClientPtr client, Selection ** ppSel, Mask access_mode) return rec.status; } -/* Entry point for hook functions. Called by Xserver. - */ -int -XaceHook(int hook, ...) +int XaceHookResourceAccess(ClientPtr client, XID id, RESTYPE rtype, void *res, + RESTYPE ptype, void *parent, Mask access_mode) { - union { - XaceResourceAccessRec res; - XaceDeviceAccessRec dev; - XaceSendAccessRec send; - XaceReceiveAccessRec recv; - XaceClientAccessRec client; - XaceExtAccessRec ext; - XaceServerAccessRec server; - XaceScreenAccessRec screen; - XaceAuthAvailRec auth; - XaceKeyAvailRec key; - } u; - int *prv = NULL; /* points to return value from callback */ - va_list ap; /* argument list */ - - if (!XaceHooks[hook]) - return Success; - - va_start(ap, hook); - - /* Marshal arguments for passing to callback. - * Each callback has its own case, which sets up a structure to hold - * the arguments and integer return parameter, or in some cases just - * sets calldata directly to a single argument (with no return result) - */ - switch (hook) { - case XACE_RESOURCE_ACCESS: - u.res.client = va_arg(ap, ClientPtr); - u.res.id = va_arg(ap, XID); - u.res.rtype = va_arg(ap, RESTYPE); - u.res.res = va_arg(ap, void *); - u.res.ptype = va_arg(ap, RESTYPE); - u.res.parent = va_arg(ap, void *); - u.res.access_mode = va_arg(ap, Mask); - - u.res.status = Success; /* default allow */ - prv = &u.res.status; - break; - case XACE_DEVICE_ACCESS: - u.dev.client = va_arg(ap, ClientPtr); - u.dev.dev = va_arg(ap, DeviceIntPtr); - u.dev.access_mode = va_arg(ap, Mask); - - u.dev.status = Success; /* default allow */ - prv = &u.dev.status; - break; - case XACE_SEND_ACCESS: - u.send.client = va_arg(ap, ClientPtr); - u.send.dev = va_arg(ap, DeviceIntPtr); - u.send.pWin = va_arg(ap, WindowPtr); - - u.send.events = va_arg(ap, xEventPtr); - u.send.count = va_arg(ap, int); - - u.send.status = Success; /* default allow */ - prv = &u.send.status; - break; - case XACE_RECEIVE_ACCESS: - u.recv.client = va_arg(ap, ClientPtr); - u.recv.pWin = va_arg(ap, WindowPtr); - - u.recv.events = va_arg(ap, xEventPtr); - u.recv.count = va_arg(ap, int); - - u.recv.status = Success; /* default allow */ - prv = &u.recv.status; - break; - case XACE_CLIENT_ACCESS: - u.client.client = va_arg(ap, ClientPtr); - u.client.target = va_arg(ap, ClientPtr); - u.client.access_mode = va_arg(ap, Mask); - - u.client.status = Success; /* default allow */ - prv = &u.client.status; - break; - case XACE_EXT_ACCESS: - u.ext.client = va_arg(ap, ClientPtr); - - u.ext.ext = va_arg(ap, ExtensionEntry *); - u.ext.access_mode = DixGetAttrAccess; - u.ext.status = Success; /* default allow */ - prv = &u.ext.status; - break; - case XACE_SERVER_ACCESS: - u.server.client = va_arg(ap, ClientPtr); - u.server.access_mode = va_arg(ap, Mask); - - u.server.status = Success; /* default allow */ - prv = &u.server.status; - break; - case XACE_SCREEN_ACCESS: - case XACE_SCREENSAVER_ACCESS: - u.screen.client = va_arg(ap, ClientPtr); - u.screen.screen = va_arg(ap, ScreenPtr); - u.screen.access_mode = va_arg(ap, Mask); - - u.screen.status = Success; /* default allow */ - prv = &u.screen.status; - break; - case XACE_AUTH_AVAIL: - u.auth.client = va_arg(ap, ClientPtr); - u.auth.authId = va_arg(ap, XID); - - break; - case XACE_KEY_AVAIL: - u.key.event = va_arg(ap, xEventPtr); - u.key.keybd = va_arg(ap, DeviceIntPtr); - u.key.count = va_arg(ap, int); - - break; - default: - va_end(ap); - return 0; /* unimplemented hook number */ - } - va_end(ap); + XaceResourceAccessRec rec = { client, id, rtype, res, ptype, parent, + access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_RESOURCE_ACCESS], &rec); + return rec.status; +} + +int XaceHookDeviceAccess(ClientPtr client, DeviceIntPtr dev, Mask access_mode) +{ + XaceDeviceAccessRec rec = { client, dev, access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_DEVICE_ACCESS], &rec); + return rec.status; +} - /* call callbacks and return result, if any. */ - CallCallbacks(&XaceHooks[hook], &u); - return prv ? *prv : Success; +int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win, + xEventPtr ev, int count) +{ + XaceSendAccessRec rec = { client, dev, win, ev, count, Success }; + CallCallbacks(&XaceHooks[XACE_SEND_ACCESS], &rec); + return rec.status; +} + +int XaceHookReceiveAccess(ClientPtr client, WindowPtr win, + xEventPtr ev, int count) +{ + XaceReceiveAccessRec rec = { client, win, ev, count, Success }; + CallCallbacks(&XaceHooks[XACE_RECEIVE_ACCESS], &rec); + return rec.status; +} + +int XaceHookClientAccess(ClientPtr client, ClientPtr target, Mask access_mode) +{ + XaceClientAccessRec rec = { client, target, access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_CLIENT_ACCESS], &rec); + return rec.status; +} + +int XaceHookExtAccess(ClientPtr client, ExtensionEntry *ext) +{ + XaceExtAccessRec rec = { client, ext, DixGetAttrAccess, Success }; + CallCallbacks(&XaceHooks[XACE_EXT_ACCESS], &rec); + return rec.status; +} + +int XaceHookServerAccess(ClientPtr client, Mask access_mode) +{ + XaceServerAccessRec rec = { client, access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_SERVER_ACCESS], &rec); + return rec.status; +} + +int XaceHookScreenAccess(ClientPtr client, ScreenPtr screen, Mask access_mode) +{ + XaceScreenAccessRec rec = { client, screen, access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_SCREEN_ACCESS], &rec); + return rec.status; +} + +int XaceHookScreensaverAccess(ClientPtr client, ScreenPtr screen, Mask access_mode) +{ + XaceScreenAccessRec rec = { client, screen, access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_SCREENSAVER_ACCESS], &rec); + return rec.status; +} + +int XaceHookAuthAvail(ClientPtr client, XID authId) +{ + XaceAuthAvailRec rec = { client, authId }; + CallCallbacks(&XaceHooks[XACE_AUTH_AVAIL], &rec); + return Success; +} + +int XaceHookKeyAvail(xEventPtr ev, DeviceIntPtr dev, int count) +{ + XaceKeyAvailRec rec = { ev, dev, count }; + CallCallbacks(&XaceHooks[XACE_KEY_AVAIL], &rec); + return Success; } /* XaceHookIsSet diff --git a/Xext/xace.h b/Xext/xace.h index 8c8723288..481110a1c 100644 --- a/Xext/xace.h +++ b/Xext/xace.h @@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define XACE_MAJOR_VERSION 2 #define XACE_MINOR_VERSION 0 +#include "extnsionst.h" #include "pixmap.h" #include "region.h" #include "window.h" @@ -54,31 +55,47 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define XACE_KEY_AVAIL 14 #define XACE_NUM_HOOKS 15 -extern _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; +extern CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; /* Entry point for hook functions. Called by Xserver. * Required by libdbe and libextmod */ -extern _X_EXPORT int XaceHook(int /*hook */ , - ... /*appropriate args for hook */ - ); +/* needs to be exported for in-tree modsetting driver, but not part + of public API for external modules */ +_X_EXPORT int XaceHook(int hook, ... /* appropriate args for hook */); /* determine whether any callbacks are present for the XACE hook */ -extern _X_EXPORT int XaceHookIsSet(int hook); +int XaceHookIsSet(int hook); /* Special-cased hook functions */ -extern _X_EXPORT int XaceHookDispatch(ClientPtr ptr, int major); +int XaceHookDispatch0(ClientPtr ptr, int major); #define XaceHookDispatch(c, m) \ ((XaceHooks[XACE_EXT_DISPATCH] && (m) >= EXTENSION_BASE) ? \ - XaceHookDispatch((c), (m)) : \ + XaceHookDispatch0((c), (m)) : \ Success) -extern _X_EXPORT int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin, - PropertyPtr *ppProp, - Mask access_mode); -extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr, Selection ** ppSel, - Mask access_mode); +int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin, PropertyPtr *ppProp, + Mask access_mode); +int XaceHookSelectionAccess(ClientPtr ptr, Selection ** ppSel, Mask access_mode); + +/* needs to be exported for in-tree modsetting, but not part of public API */ +_X_EXPORT int XaceHookResourceAccess(ClientPtr client, XID id, RESTYPE rtype, void *res, + RESTYPE ptype, void *parent, Mask access_mode); + +int XaceHookDeviceAccess(ClientPtr client, DeviceIntPtr dev, Mask access_mode); + +int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win, + xEventPtr ev, int count); +int XaceHookReceiveAccess(ClientPtr client, WindowPtr win, xEventPtr ev, int count); +int XaceHookClientAccess(ClientPtr client, ClientPtr target, Mask access_mode); +int XaceHookExtAccess(ClientPtr client, ExtensionEntry *ext); +int XaceHookServerAccess(ClientPtr client, Mask access_mode); +int XaceHookScreenAccess(ClientPtr client, ScreenPtr screen, Mask access_mode); +int XaceHookScreensaverAccess(ClientPtr client, ScreenPtr screen, Mask access_mode); +int XaceHookAuthAvail(ClientPtr client, XID authId); +int XaceHookKeyAvail(xEventPtr ev, DeviceIntPtr dev, int count); + /* Register a callback for a given hook. */ @@ -92,18 +109,18 @@ extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr, Selection ** ppSel, /* XTrans wrappers for use by security modules */ -extern _X_EXPORT int XaceGetConnectionNumber(ClientPtr ptr); -extern _X_EXPORT int XaceIsLocal(ClientPtr ptr); +int XaceGetConnectionNumber(ClientPtr ptr); +int XaceIsLocal(ClientPtr ptr); /* From the original Security extension... */ -extern _X_EXPORT void XaceCensorImage(ClientPtr client, - RegionPtr pVisibleRegion, - long widthBytesLine, - DrawablePtr pDraw, - int x, int y, int w, int h, - unsigned int format, char *pBuf); +void XaceCensorImage(ClientPtr client, + RegionPtr pVisibleRegion, + long widthBytesLine, + DrawablePtr pDraw, + int x, int y, int w, int h, + unsigned int format, char *pBuf); #else /* XACE */ @@ -113,14 +130,12 @@ extern _X_EXPORT void XaceCensorImage(ClientPtr client, /* Define calls away when XACE is not being built. */ #ifdef __GNUC__ -#define XaceHook(args...) Success #define XaceHookIsSet(args...) 0 #define XaceHookDispatch(args...) Success #define XaceHookPropertyAccess(args...) Success #define XaceHookSelectionAccess(args...) Success #define XaceCensorImage(args...) { ; } #else -#define XaceHook(...) Success #define XaceHookIsSet(...) 0 #define XaceHookDispatch(...) Success #define XaceHookPropertyAccess(...) Success diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c index 385e63383..dff21efb1 100644 --- a/Xext/xcmisc.c +++ b/Xext/xcmisc.c @@ -26,9 +26,7 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -146,8 +144,6 @@ static int _X_COLD SProcXCMiscGetVersion(ClientPtr client) { REQUEST(xXCMiscGetVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXCMiscGetVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); @@ -155,21 +151,11 @@ SProcXCMiscGetVersion(ClientPtr client) } static int _X_COLD -SProcXCMiscGetXIDRange(ClientPtr client) -{ - REQUEST(xReq); - - swaps(&stuff->length); - return ProcXCMiscGetXIDRange(client); -} - -static int _X_COLD SProcXCMiscGetXIDList(ClientPtr client) { REQUEST(xXCMiscGetXIDListReq); REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq); - swaps(&stuff->length); swapl(&stuff->count); return ProcXCMiscGetXIDList(client); } @@ -182,7 +168,7 @@ SProcXCMiscDispatch(ClientPtr client) case X_XCMiscGetVersion: return SProcXCMiscGetVersion(client); case X_XCMiscGetXIDRange: - return SProcXCMiscGetXIDRange(client); + return ProcXCMiscGetXIDRange(client); case X_XCMiscGetXIDList: return SProcXCMiscGetXIDList(client); default: diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 44a8e7dd8..e7cc99fd9 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -34,9 +34,7 @@ * XLoadQueryFont). */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/types.h> #ifdef MITSHM @@ -58,6 +56,8 @@ #include <X11/X.h> #include <X11/Xproto.h> +#include <X11/extensions/xf86bigfproto.h> + #include "misc.h" #include "os.h" #include "dixstruct.h" @@ -67,11 +67,9 @@ #include "extinit.h" #include "protocol-versions.h" -#include <X11/extensions/xf86bigfproto.h> #include "xf86bigfontsrv.h" -static void XF86BigfontResetProc(ExtensionEntry * /* extEntry */ - ); +static void XF86BigfontResetProc(ExtensionEntry *extEntry ); #ifdef MITSHM @@ -339,9 +337,7 @@ ProcXF86BigfontQueryFont(ClientPtr client) CARD16 *pUniqIndex2Index; CARD32 nUniqCharInfos; -#if 0 - REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq); -#else + /* protocol version is decided based on request packet size */ switch (client->req_len) { case 2: /* client with version 1.0 libX11 */ stuff_flags = (client->local && @@ -353,7 +349,7 @@ ProcXF86BigfontQueryFont(ClientPtr client) default: return BadLength; } -#endif + if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success) return BadFont; /* procotol spec says only error is BadFont */ @@ -534,60 +530,59 @@ ProcXF86BigfontQueryFont(ClientPtr client) { int nfontprops = pFont->info.nprops; - int rlength = sizeof(xXF86BigfontQueryFontReply) - + nfontprops * sizeof(xFontProp) + int rlength = nfontprops * sizeof(xFontProp) + (nCharInfos > 0 && shmid == -1 ? nUniqCharInfos * sizeof(xCharInfo) + (nCharInfos + 1) / 2 * 2 * sizeof(CARD16) : 0); - xXF86BigfontQueryFontReply *reply = calloc(1, rlength); - char *p; - if (!reply) { - if (nCharInfos > 0) { - if (shmid == -1) - free(pIndex2UniqIndex); - if (!pDesc) - free(pCI); - } - return BadAlloc; - } - reply->type = X_Reply; - reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); - reply->sequenceNumber = client->sequence; - reply->minBounds = pFont->info.ink_minbounds; - reply->maxBounds = pFont->info.ink_maxbounds; - reply->minCharOrByte2 = pFont->info.firstCol; - reply->maxCharOrByte2 = pFont->info.lastCol; - reply->defaultChar = pFont->info.defaultCh; - reply->nFontProps = pFont->info.nprops; - reply->drawDirection = pFont->info.drawDirection; - reply->minByte1 = pFont->info.firstRow; - reply->maxByte1 = pFont->info.lastRow; - reply->allCharsExist = pFont->info.allExist; - reply->fontAscent = pFont->info.fontAscent; - reply->fontDescent = pFont->info.fontDescent; - reply->nCharInfos = nCharInfos; - reply->nUniqCharInfos = nUniqCharInfos; - reply->shmid = shmid; - reply->shmsegoffset = 0; + xXF86BigfontQueryFontReply rep = { + .type = X_Reply; + .length = bytes_to_int32(buflength), + .sequenceNumber = client->sequence, + .minBounds = pFont->info.ink_minbounds, + .maxBounds = pFont->info.ink_maxbounds, + .minCharOrByte2 = pFont->info.firstCol, + .maxCharOrByte2 = pFont->info.lastCol, + .defaultChar = pFont->info.defaultCh, + .nFontProps = pFont->info.nprops, + .drawDirection = pFont->info.drawDirection, + .minByte1 = pFont->info.firstRow, + .maxByte1 = pFont->info.lastRow, + .allCharsExist = pFont->info.allExist, + .fontAscent = pFont->info.fontAscent, + .fontDescent = pFont->info.fontDescent, + .nCharInfos = nCharInfos, + .nUniqCharInfos = nUniqCharInfos, + .shmid = shmid, + }; + if (client->swapped) { - swaps(&reply->sequenceNumber); - swapl(&reply->length); - swapCharInfo(&reply->minBounds); - swapCharInfo(&reply->maxBounds); - swaps(&reply->minCharOrByte2); - swaps(&reply->maxCharOrByte2); - swaps(&reply->defaultChar); - swaps(&reply->nFontProps); - swaps(&reply->fontAscent); - swaps(&reply->fontDescent); - swapl(&reply->nCharInfos); - swapl(&reply->nUniqCharInfos); - swapl(&reply->shmid); - swapl(&reply->shmsegoffset); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapCharInfo(&rep.minBounds); + swapCharInfo(&rep.maxBounds); + swaps(&rep.minCharOrByte2); + swaps(&rep.maxCharOrByte2); + swaps(&rep.defaultChar); + swaps(&rep.nFontProps); + swaps(&rep.fontAscent); + swaps(&rep.fontDescent); + swapl(&rep.nCharInfos); + swapl(&rep.nUniqCharInfos); + swapl(&rep.shmid); + swapl(&rep.shmsegoffset); + } + + int rc = Success; + char *buf = calloc(1, rlength); + if (!buf) { + rc = BadAlloc; + goto out; } - p = (char *) &reply[1]; + + char *p = buf; + { FontPropPtr pFP; xFontProp *prFP; @@ -623,15 +618,18 @@ ProcXF86BigfontQueryFont(ClientPtr client) } } } - WriteToClient(client, rlength, reply); - free(reply); + + WriteToClient(client, sizeof(xXF86BigfontQueryFontReply), &rep); + WriteToClient(client, rlength, buf); + free(buf); +out: if (nCharInfos > 0) { if (shmid == -1) free(pIndex2UniqIndex); if (!pDesc) free(pCI); } - return Success; + return rc; } } @@ -654,8 +652,6 @@ static int _X_COLD SProcXF86BigfontQueryVersion(ClientPtr client) { REQUEST(xXF86BigfontQueryVersionReq); - - swaps(&stuff->length); return ProcXF86BigfontQueryVersion(client); } @@ -663,8 +659,6 @@ static int _X_COLD SProcXF86BigfontQueryFont(ClientPtr client) { REQUEST(xXF86BigfontQueryFontReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq); swapl(&stuff->id); return ProcXF86BigfontQueryFont(client); diff --git a/Xext/xres.c b/Xext/xres.c index 9d71402f1..403ab74bb 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -2,30 +2,28 @@ Copyright (c) 2002 XFree86 Inc */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include <assert.h> #include <stdio.h> #include <string.h> #include <X11/X.h> #include <X11/Xproto.h> -#include <assert.h> +#include <X11/extensions/XResproto.h> #include "dix/registry_priv.h" +#include "os/client_priv.h" #include "misc.h" #include "os.h" #include "dixstruct.h" #include "extnsionst.h" #include "swaprep.h" -#include <X11/extensions/XResproto.h> #include "pixmapstr.h" #include "windowstr.h" #include "gcstruct.h" #include "extinit_priv.h" #include "protocol-versions.h" -#include "client.h" #include "list.h" #include "misc.h" #include <string.h> @@ -1080,7 +1078,6 @@ static int _X_COLD SProcResDispatch (ClientPtr client) { REQUEST(xReq); - swaps(&stuff->length); switch (stuff->data) { case X_XResQueryVersion: diff --git a/Xext/xselinux_ext.c b/Xext/xselinux_ext.c index 5bfb9a84b..dd5ace348 100644 --- a/Xext/xselinux_ext.c +++ b/Xext/xselinux_ext.c @@ -17,11 +17,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" +#include "dix/property_priv.h" #include "selection.h" #include "inputstr.h" @@ -71,7 +70,6 @@ ProcSELinuxQueryVersion(ClientPtr client) SELinuxQueryVersionReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, - .length = 0, .server_major = SELINUX_MAJOR_VERSION, .server_minor = SELINUX_MINOR_VERSION }; @@ -88,7 +86,6 @@ ProcSELinuxQueryVersion(ClientPtr client) static int SELinuxSendContextReply(ClientPtr client, security_id_t sid) { - SELinuxGetContextReply rep; char *ctx = NULL; int len = 0; @@ -98,7 +95,7 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid) len = strlen(ctx) + 1; } - rep = (SELinuxGetContextReply) { + SELinuxGetContextReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .length = bytes_to_int32(len), @@ -345,13 +342,9 @@ static int SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items, int size, int count) { - int rc, k, pos = 0; - SELinuxListItemsReply rep; - CARD32 *buf; - - buf = calloc(size, sizeof(CARD32)); + int rc = BadAlloc, k, pos = 0; + CARD32 *buf = calloc(size, sizeof(CARD32)); if (size && !buf) { - rc = BadAlloc; goto out; } @@ -379,7 +372,7 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items, } /* Send reply to client */ - rep = (SELinuxListItemsReply) { + SELinuxListItemsReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .length = size, @@ -626,8 +619,6 @@ SProcSELinuxDispatch(ClientPtr client) { REQUEST(xReq); - swaps(&stuff->length); - switch (stuff->data) { case X_SELinuxQueryVersion: return SProcSELinuxQueryVersion(client); diff --git a/Xext/xselinux_hooks.c b/Xext/xselinux_hooks.c index 63fc18f93..4007958a9 100644 --- a/Xext/xselinux_hooks.c +++ b/Xext/xselinux_hooks.c @@ -22,9 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * All rights reserved. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <errno.h> #include <sys/socket.h> @@ -32,8 +30,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <stdarg.h> #include <libaudit.h> #include <X11/Xatom.h> +#include <X11/Xfuncproto.h> #include "dix/registry_priv.h" +#include "os/client_priv.h" #include "selection.h" #include "inputstr.h" @@ -42,7 +42,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "propertyst.h" #include "extnsionst.h" #include "xacestr.h" -#include "client.h" #define _XSELINUX_NEED_FLASK_MAP #include "xselinuxint.h" diff --git a/Xext/xselinux_label.c b/Xext/xselinux_label.c index 08159ff0b..4110f9074 100644 --- a/Xext/xselinux_label.c +++ b/Xext/xselinux_label.c @@ -17,9 +17,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <selinux/label.h> diff --git a/Xext/xtest.c b/Xext/xtest.c index b451e41cd..2798fe258 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -26,9 +26,7 @@ */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -37,8 +35,12 @@ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> +#include "dix/input_priv.h" #include "dix/dix_priv.h" #include "dix/exevents_priv.h" +#include "mi/mi_priv.h" +#include "mi/mipointer_priv.h" +#include "os/client_priv.h" #include "os/osdep.h" #include "misc.h" @@ -50,7 +52,6 @@ #include "scrnintstr.h" #include "dixevents.h" #include "sleepuntil.h" -#include "mi.h" #include "xkbsrv.h" #include "xkbstr.h" #include "exglobals.h" @@ -78,10 +79,10 @@ static InternalEvent *xtest_evlist; */ DeviceIntPtr xtestpointer, xtestkeyboard; -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ static int XTestSwapFakeInput(ClientPtr /* client */ , xReq * /* req */ @@ -197,7 +198,7 @@ ProcXTestFakeInput(ClientPtr client) int flags = 0; int need_ptr_update = 1; - nev = (stuff->length << 2) - sizeof(xReq); + nev = (client->req_len << 2) - sizeof(xReq); if ((nev % sizeof(xEvent)) || !nev) return BadLength; nev /= sizeof(xEvent); @@ -373,7 +374,6 @@ ProcXTestFakeInput(ClientPtr client) /* swap the request back so we can simply re-execute it */ if (client->swapped) { (void) XTestSwapFakeInput(client, (xReq *) stuff); - swaps(&stuff->length); } ResetCurrentRequest(client); client->sequence--; @@ -487,8 +487,6 @@ static int _X_COLD SProcXTestGetVersion(ClientPtr client) { REQUEST(xXTestGetVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXTestGetVersionReq); swaps(&stuff->minorVersion); return ProcXTestGetVersion(client); @@ -498,8 +496,6 @@ static int _X_COLD SProcXTestCompareCursor(ClientPtr client) { REQUEST(xXTestCompareCursorReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXTestCompareCursorReq); swapl(&stuff->window); swapl(&stuff->cursor); @@ -514,7 +510,7 @@ XTestSwapFakeInput(ClientPtr client, xReq * req) xEvent sev; EventSwapPtr proc; - nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent); + nev = ((client->req_len << 2) - sizeof(xReq)) / sizeof(xEvent); for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) { int evtype = ev->u.u.type & 0177; /* Swap event */ @@ -537,7 +533,6 @@ SProcXTestFakeInput(ClientPtr client) REQUEST(xReq); - swaps(&stuff->length); n = XTestSwapFakeInput(client, stuff); if (n != Success) return n; @@ -545,16 +540,6 @@ SProcXTestFakeInput(ClientPtr client) } static int _X_COLD -SProcXTestGrabControl(ClientPtr client) -{ - REQUEST(xXTestGrabControlReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXTestGrabControlReq); - return ProcXTestGrabControl(client); -} - -static int _X_COLD SProcXTestDispatch(ClientPtr client) { REQUEST(xReq); @@ -566,7 +551,7 @@ SProcXTestDispatch(ClientPtr client) case X_XTestFakeInput: return SProcXTestFakeInput(client); case X_XTestGrabControl: - return SProcXTestGrabControl(client); + return ProcXTestGrabControl(client); default: return BadRequest; } diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index eb80561b7..8a315b90a 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -21,9 +21,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> @@ -33,6 +31,7 @@ SOFTWARE. #include <X11/extensions/Xvproto.h> #include "dix/dix_priv.h" +#include "Xext/xvdix_priv.h" #include "misc.h" #include "scrnintstr.h" @@ -42,7 +41,6 @@ SOFTWARE. #include "dixstruct.h" #include "resource.h" #include "opaque.h" -#include "xvdix.h" #ifdef MITSHM #include <X11/extensions/shmproto.h> #include "shmint.h" @@ -50,12 +48,12 @@ SOFTWARE. #include "xvdisp.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" unsigned long XvXRTPort; -#endif +#endif /* XINERAMA */ static int SWriteQueryExtensionReply(ClientPtr client, xvQueryExtensionReply * rep) @@ -1118,20 +1116,10 @@ ProcXvDispatch(ClientPtr client) /* Swapped Procs */ static int _X_COLD -SProcXvQueryExtension(ClientPtr client) -{ - REQUEST(xvQueryExtensionReq); - REQUEST_SIZE_MATCH(xvQueryExtensionReq); - swaps(&stuff->length); - return XvProcVector[xv_QueryExtension] (client); -} - -static int _X_COLD SProcXvQueryAdaptors(ClientPtr client) { REQUEST(xvQueryAdaptorsReq); REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); - swaps(&stuff->length); swapl(&stuff->window); return XvProcVector[xv_QueryAdaptors] (client); } @@ -1141,7 +1129,6 @@ SProcXvQueryEncodings(ClientPtr client) { REQUEST(xvQueryEncodingsReq); REQUEST_SIZE_MATCH(xvQueryEncodingsReq); - swaps(&stuff->length); swapl(&stuff->port); return XvProcVector[xv_QueryEncodings] (client); } @@ -1151,7 +1138,6 @@ SProcXvGrabPort(ClientPtr client) { REQUEST(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->time); return XvProcVector[xv_GrabPort] (client); @@ -1162,7 +1148,6 @@ SProcXvUngrabPort(ClientPtr client) { REQUEST(xvUngrabPortReq); REQUEST_SIZE_MATCH(xvUngrabPortReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->time); return XvProcVector[xv_UngrabPort] (client); @@ -1173,7 +1158,6 @@ SProcXvPutVideo(ClientPtr client) { REQUEST(xvPutVideoReq); REQUEST_SIZE_MATCH(xvPutVideoReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -1193,7 +1177,6 @@ SProcXvPutStill(ClientPtr client) { REQUEST(xvPutStillReq); REQUEST_SIZE_MATCH(xvPutStillReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -1213,7 +1196,6 @@ SProcXvGetVideo(ClientPtr client) { REQUEST(xvGetVideoReq); REQUEST_SIZE_MATCH(xvGetVideoReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -1233,7 +1215,6 @@ SProcXvGetStill(ClientPtr client) { REQUEST(xvGetStillReq); REQUEST_SIZE_MATCH(xvGetStillReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -1253,7 +1234,6 @@ SProcXvPutImage(ClientPtr client) { REQUEST(xvPutImageReq); REQUEST_AT_LEAST_SIZE(xvPutImageReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -1277,7 +1257,6 @@ SProcXvShmPutImage(ClientPtr client) { REQUEST(xvShmPutImageReq); REQUEST_SIZE_MATCH(xvShmPutImageReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -1305,7 +1284,6 @@ SProcXvSelectVideoNotify(ClientPtr client) { REQUEST(xvSelectVideoNotifyReq); REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); - swaps(&stuff->length); swapl(&stuff->drawable); return XvProcVector[xv_SelectVideoNotify] (client); } @@ -1315,7 +1293,6 @@ SProcXvSelectPortNotify(ClientPtr client) { REQUEST(xvSelectPortNotifyReq); REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); - swaps(&stuff->length); swapl(&stuff->port); return XvProcVector[xv_SelectPortNotify] (client); } @@ -1325,7 +1302,6 @@ SProcXvStopVideo(ClientPtr client) { REQUEST(xvStopVideoReq); REQUEST_SIZE_MATCH(xvStopVideoReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->drawable); return XvProcVector[xv_StopVideo] (client); @@ -1336,7 +1312,6 @@ SProcXvSetPortAttribute(ClientPtr client) { REQUEST(xvSetPortAttributeReq); REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->attribute); swapl(&stuff->value); @@ -1348,7 +1323,6 @@ SProcXvGetPortAttribute(ClientPtr client) { REQUEST(xvGetPortAttributeReq); REQUEST_SIZE_MATCH(xvGetPortAttributeReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->attribute); return XvProcVector[xv_GetPortAttribute] (client); @@ -1359,7 +1333,6 @@ SProcXvQueryBestSize(ClientPtr client) { REQUEST(xvQueryBestSizeReq); REQUEST_SIZE_MATCH(xvQueryBestSizeReq); - swaps(&stuff->length); swapl(&stuff->port); swaps(&stuff->vid_w); swaps(&stuff->vid_h); @@ -1373,7 +1346,6 @@ SProcXvQueryPortAttributes(ClientPtr client) { REQUEST(xvQueryPortAttributesReq); REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); - swaps(&stuff->length); swapl(&stuff->port); return XvProcVector[xv_QueryPortAttributes] (client); } @@ -1383,7 +1355,6 @@ SProcXvQueryImageAttributes(ClientPtr client) { REQUEST(xvQueryImageAttributesReq); REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); - swaps(&stuff->length); swapl(&stuff->port); swapl(&stuff->id); swaps(&stuff->width); @@ -1396,13 +1367,12 @@ SProcXvListImageFormats(ClientPtr client) { REQUEST(xvListImageFormatsReq); REQUEST_SIZE_MATCH(xvListImageFormatsReq); - swaps(&stuff->length); swapl(&stuff->port); return XvProcVector[xv_ListImageFormats] (client); } static int (*SXvProcVector[xvNumRequests]) (ClientPtr) = { -SProcXvQueryExtension, + ProcXvQueryExtension, SProcXvQueryAdaptors, SProcXvQueryEncodings, SProcXvGrabPort, @@ -1435,7 +1405,7 @@ SProcXvDispatch(ClientPtr client) return SXvProcVector[stuff->data] (client); } -#ifdef PANORAMIX +#ifdef XINERAMA static int XineramaXvStopVideo(ClientPtr client) { @@ -1543,7 +1513,7 @@ XineramaXvShmPutImage(ClientPtr client) } #else #define XineramaXvShmPutImage ProcXvShmPutImage -#endif +#endif /* MITSHM */ static int XineramaXvPutImage(ClientPtr client) @@ -1798,17 +1768,17 @@ XineramifyXv(void) XvProcVector[xv_PutImage] = XineramaXvPutImage; XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage; } -#endif /* PANORAMIX */ +#endif /* XINERAMA */ void XvResetProcVector(void) { -#ifdef PANORAMIX +#ifdef XINERAMA XvProcVector[xv_PutVideo] = ProcXvPutVideo; XvProcVector[xv_PutStill] = ProcXvPutStill; XvProcVector[xv_StopVideo] = ProcXvStopVideo; XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute; XvProcVector[xv_PutImage] = ProcXvPutImage; XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage; -#endif +#endif /* XINERAMA */ } diff --git a/Xext/xvdix.h b/Xext/xvdix.h index 621a1e3a3..0ead1c80a 100644 --- a/Xext/xvdix.h +++ b/Xext/xvdix.h @@ -55,21 +55,6 @@ SOFTWARE. #include "scrnintstr.h" #include <X11/extensions/Xvproto.h> -extern _X_EXPORT unsigned long XvExtensionGeneration; -extern _X_EXPORT unsigned long XvScreenGeneration; -extern _X_EXPORT unsigned long XvResourceGeneration; - -extern _X_EXPORT int XvReqCode; -extern _X_EXPORT int XvEventBase; -extern _X_EXPORT int XvErrorBase; - -extern _X_EXPORT RESTYPE XvRTPort; -extern _X_EXPORT RESTYPE XvRTEncoding; -extern _X_EXPORT RESTYPE XvRTGrab; -extern _X_EXPORT RESTYPE XvRTVideoNotify; -extern _X_EXPORT RESTYPE XvRTVideoNotifyList; -extern _X_EXPORT RESTYPE XvRTPortNotify; - typedef struct { int numerator; int denominator; @@ -85,18 +70,7 @@ typedef struct { ClientPtr client; } XvGrabRec, *XvGrabPtr; -typedef struct _XvVideoNotifyRec { - struct _XvVideoNotifyRec *next; - ClientPtr client; - unsigned long id; - unsigned long mask; -} XvVideoNotifyRec, *XvVideoNotifyPtr; - -typedef struct _XvPortNotifyRec { - struct _XvPortNotifyRec *next; - ClientPtr client; - unsigned long id; -} XvPortNotifyRec, *XvPortNotifyPtr; +typedef struct _XvPortNotifyRec *XvPortNotifyPtr; typedef struct { int id; @@ -195,14 +169,6 @@ typedef struct _XvPortRec { DevUnion devPriv; } XvPortRec, *XvPortPtr; -#define VALIDATE_XV_PORT(portID, pPort, mode)\ - {\ - int rc = dixLookupResourceByType((void **)&(pPort), portID,\ - XvRTPort, client, mode);\ - if (rc != Success)\ - return rc;\ - } - typedef struct { int version, revision; int nAdaptors; @@ -212,51 +178,8 @@ typedef struct { CloseScreenProcPtr CloseScreen; } XvScreenRec, *XvScreenPtr; -#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \ - dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field) - -#define SCREEN_EPILOGUE(pScreen, field, wrapper)\ - ((pScreen)->field = wrapper) - -/* Errors */ - -#define _XvBadPort (XvBadPort+XvErrorBase) -#define _XvBadEncoding (XvBadEncoding+XvErrorBase) - -extern _X_EXPORT int ProcXvDispatch(ClientPtr); -extern _X_EXPORT int SProcXvDispatch(ClientPtr); - extern _X_EXPORT int XvScreenInit(ScreenPtr); extern _X_EXPORT DevPrivateKey XvGetScreenKey(void); extern _X_EXPORT unsigned long XvGetRTPort(void); -extern _X_EXPORT void XvFreeAdaptor(XvAdaptorPtr pAdaptor); -extern void _X_EXPORT XvFillColorKey(DrawablePtr pDraw, CARD32 key, - RegionPtr region); -extern _X_EXPORT int XvdiSendPortNotify(XvPortPtr, Atom, INT32); -extern _X_EXPORT int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -extern _X_EXPORT int XvdiPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -extern _X_EXPORT int XvdiGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -extern _X_EXPORT int XvdiGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16); -extern _X_EXPORT int XvdiPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, - INT16, INT16, CARD16, CARD16, - INT16, INT16, CARD16, CARD16, - XvImagePtr, unsigned char *, Bool, - CARD16, CARD16); -extern _X_EXPORT int XvdiSelectVideoNotify(ClientPtr, DrawablePtr, BOOL); -extern _X_EXPORT int XvdiSelectPortNotify(ClientPtr, XvPortPtr, BOOL); -extern _X_EXPORT int XvdiSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32); -extern _X_EXPORT int XvdiGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *); -extern _X_EXPORT int XvdiStopVideo(ClientPtr, XvPortPtr, DrawablePtr); -extern _X_EXPORT int XvdiMatchPort(XvPortPtr, DrawablePtr); -extern _X_EXPORT int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *); -extern _X_EXPORT int XvdiUngrabPort(ClientPtr, XvPortPtr, Time); #endif /* XVDIX_H */ diff --git a/Xext/xvdix_priv.h b/Xext/xvdix_priv.h new file mode 100644 index 000000000..d1ddb68f2 --- /dev/null +++ b/Xext/xvdix_priv.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XORG_XVDIX_PRIV_H + +#include <X11/Xdefs.h> + +#include "include/pixmap.h" +#include "include/regionstr.h" +#include "Xext/xvdix.h" + +#define VALIDATE_XV_PORT(portID, pPort, mode)\ + {\ + int rc = dixLookupResourceByType((void **)&(pPort), portID,\ + XvRTPort, client, mode);\ + if (rc != Success)\ + return rc;\ + } + +/* Errors */ + +#define _XvBadPort (XvBadPort+XvErrorBase) + +typedef struct _XvPortNotifyRec { + struct _XvPortNotifyRec *next; + ClientPtr client; + unsigned long id; +} XvPortNotifyRec, *XvPortNotifyPtr; + +extern int XvReqCode; +extern int XvErrorBase; + +extern RESTYPE XvRTPort; + +/* dispatch functions */ +int ProcXvDispatch(ClientPtr); +int SProcXvDispatch(ClientPtr); + +void XvFreeAdaptor(XvAdaptorPtr pAdaptor); + +void XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region); + +int XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff); +int XvdiSelectPortNotify(ClientPtr client, XvPortPtr pPort, BOOL onoff); + +int XvdiPutVideo(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, + GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w, + CARD16 wid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w, + CARD16 drw_h); +int XvdiPutStill(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, + GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w, + CARD16 vid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w, + CARD16 drw_h); +int XvdiPutImage(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, + GCPtr pGC, INT16 src_x, INT16 src_y, CARD16 src_w, + CARD16 src_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w, + CARD16 drw_h, XvImagePtr image, unsigned char *data, + Bool sync, CARD16 width, CARD16 height); + +int XvdiGetVideo(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, + GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w, + CARD16 vid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w, + CARD16 drw_h); +int XvdiGetStill(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, + GCPtr pGC, INT16 vid_x, INT16 vid_y, CARD16 vid_w, + CARD16 vid_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w, + CARD16 drw_h); + +int XvdiSetPortAttribute(ClientPtr client, XvPortPtr pPort, Atom attribute, + INT32 value); +int XvdiGetPortAttribute(ClientPtr client, XvPortPtr pPort, Atom attribute, + INT32 *p_value); + +int XvdiStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw); + +int XvdiMatchPort(XvPortPtr pPort, DrawablePtr pDraw); + +int XvdiGrabPort(ClientPtr client, XvPortPtr pPort, Time ctime, int *p_result); +int XvdiUngrabPort(ClientPtr client, XvPortPtr pPort, Time ctime); + +XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id); + +#endif /* _XORG_XVDIX_PRIV_H */ diff --git a/Xext/xvmain.c b/Xext/xvmain.c index 937f2893b..bc4a7489d 100644 --- a/Xext/xvmain.c +++ b/Xext/xvmain.c @@ -73,14 +73,16 @@ SOFTWARE. ** */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> - #include <X11/X.h> #include <X11/Xproto.h> +#include <X11/extensions/Xv.h> +#include <X11/extensions/Xvproto.h> + +#include "Xext/xvdix_priv.h" + #include "misc.h" #include "os.h" #include "scrnintstr.h" @@ -94,35 +96,44 @@ SOFTWARE. #include "opaque.h" #include "input.h" -#define GLOBAL - -#include <X11/extensions/Xv.h> -#include <X11/extensions/Xvproto.h> -#include "xvdix.h" - -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ #include "xvdisp.h" +#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field) + +#define SCREEN_EPILOGUE(pScreen, field, wrapper)\ + ((pScreen)->field = wrapper) + +typedef struct _XvVideoNotifyRec { + struct _XvVideoNotifyRec *next; + ClientPtr client; + unsigned long id; + unsigned long mask; +} XvVideoNotifyRec, *XvVideoNotifyPtr; + static DevPrivateKeyRec XvScreenKeyRec; +Bool noXvExtension = FALSE; + #define XvScreenKey (&XvScreenKeyRec) -unsigned long XvExtensionGeneration = 0; -unsigned long XvScreenGeneration = 0; -unsigned long XvResourceGeneration = 0; +static unsigned long XvExtensionGeneration = 0; +static unsigned long XvScreenGeneration = 0; +static unsigned long XvResourceGeneration = 0; int XvReqCode; -int XvEventBase; +static int XvEventBase; int XvErrorBase; RESTYPE XvRTPort; -RESTYPE XvRTEncoding; -RESTYPE XvRTGrab; -RESTYPE XvRTVideoNotify; -RESTYPE XvRTVideoNotifyList; -RESTYPE XvRTPortNotify; +static RESTYPE XvRTEncoding; +static RESTYPE XvRTGrab; +static RESTYPE XvRTVideoNotify; +static RESTYPE XvRTVideoNotifyList; +static RESTYPE XvRTPortNotify; /* EXTERNAL */ @@ -163,9 +174,9 @@ XvExtensionInit(void) ErrorF("XvExtensionInit: Unable to allocate resource types\n"); return; } -#ifdef PANORAMIX +#ifdef XINERAMA XineramaRegisterConnectionBlockCallback(XineramifyXv); -#endif +#endif /* XINERAMA */ XvScreenGeneration = serverGeneration; } @@ -256,9 +267,9 @@ XvScreenInit(ScreenPtr pScreen) ErrorF("XvScreenInit: Unable to allocate resource types\n"); return BadAlloc; } -#ifdef PANORAMIX +#ifdef XINERAMA XineramaRegisterConnectionBlockCallback(XineramifyXv); -#endif +#endif /* XINERAMA */ XvScreenGeneration = serverGeneration; } @@ -360,13 +371,14 @@ static Bool XvDestroyPixmap(PixmapPtr pPix) { ScreenPtr pScreen = pPix->drawable.pScreen; - Bool status; + Bool status = TRUE; if (pPix->refcnt == 1) XvStopAdaptors(&pPix->drawable); SCREEN_PROLOGUE(pScreen, DestroyPixmap); - status = (*pScreen->DestroyPixmap) (pPix); + if (pScreen->DestroyPixmap) + status = pScreen->DestroyPixmap(pPix); SCREEN_EPILOGUE(pScreen, DestroyPixmap, XvDestroyPixmap); return status; @@ -469,7 +481,7 @@ XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason) } -int +static int XvdiSendPortNotify(XvPortPtr pPort, Atom attribute, INT32 value) { XvPortNotifyPtr pn; diff --git a/Xext/xvmc.c b/Xext/xvmc.c index 04023772d..277da1d0e 100644 --- a/Xext/xvmc.c +++ b/Xext/xvmc.c @@ -1,12 +1,12 @@ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> - #include <X11/X.h> #include <X11/Xproto.h> + +#include "Xext/xvdix_priv.h" + #include "misc.h" #include "os.h" #include "dixstruct.h" @@ -16,7 +16,6 @@ #include "extinit_priv.h" #include "servermd.h" #include <X11/Xfuncproto.h> -#include "xvdix.h" #include <X11/extensions/XvMC.h> #include <X11/extensions/Xvproto.h> #include <X11/extensions/XvMCproto.h> @@ -44,8 +43,6 @@ static RESTYPE XvMCRTContext; static RESTYPE XvMCRTSurface; static RESTYPE XvMCRTSubpicture; -int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr) = NULL; - typedef struct { int num_adaptors; XvMCAdaptorPtr adaptors; diff --git a/Xext/xvmcext.h b/Xext/xvmcext.h index e8a6dae47..acfbee7d6 100644 --- a/Xext/xvmcext.h +++ b/Xext/xvmcext.h @@ -84,13 +84,9 @@ typedef struct { XvMCDestroySubpictureProcPtr DestroySubpicture; } XvMCAdaptorRec, *XvMCAdaptorPtr; -extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr); - extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr adapt); -extern _X_EXPORT XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id); - extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name, const char *busID, int major, int minor, int patchLevel); diff --git a/include/XIstubs.h b/Xi/XIstubs.h index b7ea4d1f4..25662f3a2 100644 --- a/include/XIstubs.h +++ b/Xi/XIstubs.h @@ -26,21 +26,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef XI_STUBS_H #define XI_STUBS_H 1 -extern _X_EXPORT int - SetDeviceMode(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - int /* mode */ ); - -extern _X_EXPORT int - SetDeviceValuators(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - int * /* valuators */ , - int /* first_valuator */ , - int /* num_valuators */ ); - -extern _X_EXPORT int - ChangeDeviceControl(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - xDeviceCtl * /* control */ ); +int SetDeviceMode(ClientPtr client, + DeviceIntPtr dev, + int mode); + +int SetDeviceValuators(ClientPtr client, + DeviceIntPtr dev, + int *valuators, + int first_valuator, + int num_valuators); + +int ChangeDeviceControl(ClientPtr client, + DeviceIntPtr dev, + xDeviceCtl *control); #endif /* XI_STUBS_H */ diff --git a/Xi/allowev.c b/Xi/allowev.c index fc4f33be8..0753a033c 100644 --- a/Xi/allowev.c +++ b/Xi/allowev.c @@ -50,15 +50,14 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "exglobals.h" #include "allowev.h" @@ -74,7 +73,6 @@ int _X_COLD SProcXAllowDeviceEvents(ClientPtr client) { REQUEST(xAllowDeviceEventsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAllowDeviceEventsReq); swapl(&stuff->time); return (ProcXAllowDeviceEvents(client)); @@ -103,22 +101,22 @@ ProcXAllowDeviceEvents(ClientPtr client) switch (stuff->mode) { case ReplayThisDevice: - AllowSome(client, time, thisdev, NOT_GRABBED); + AllowSome(client, time, thisdev, GRAB_STATE_NOT_GRABBED); break; case SyncThisDevice: - AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT); + AllowSome(client, time, thisdev, GRAB_STATE_FREEZE_NEXT_EVENT); break; case AsyncThisDevice: - AllowSome(client, time, thisdev, THAWED); + AllowSome(client, time, thisdev, GRAB_STATE_THAWED); break; case AsyncOtherDevices: - AllowSome(client, time, thisdev, THAW_OTHERS); + AllowSome(client, time, thisdev, GRAB_STATE_THAW_OTHERS); break; case SyncAll: - AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT); + AllowSome(client, time, thisdev, GRAB_STATE_FREEZE_BOTH_NEXT_EVENT); break; case AsyncAll: - AllowSome(client, time, thisdev, THAWED_BOTH); + AllowSome(client, time, thisdev, GRAB_STATE_THAWED_BOTH); break; default: client->errorValue = stuff->mode; diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c index a6325a1c6..7fdb5d5e0 100644 --- a/Xi/chgdctl.c +++ b/Xi/chgdctl.c @@ -50,14 +50,13 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> /* control constants */ #include "dix/exevents_priv.h" +#include "dix/input_priv.h" #include "inputstr.h" /* DeviceIntPtr */ #include "XIstubs.h" @@ -77,7 +76,6 @@ SProcXChangeDeviceControl(ClientPtr client) xDeviceCtl *ctl; REQUEST(xChangeDeviceControlReq); - swaps(&stuff->length); REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl)); swaps(&stuff->control); ctl = (xDeviceCtl *) &stuff[1]; @@ -117,7 +115,7 @@ ProcXChangeDeviceControl(ClientPtr client) REQUEST(xChangeDeviceControlReq); REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl)); - len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceControlReq)); + len = client->req_len - bytes_to_int32(sizeof(xChangeDeviceControlReq)); ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); if (ret != Success) goto out; diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c index 7a597e43d..e1295b5fa 100644 --- a/Xi/chgfctl.c +++ b/Xi/chgfctl.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -75,7 +73,6 @@ int _X_COLD SProcXChangeFeedbackControl(ClientPtr client) { REQUEST(xChangeFeedbackControlReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); swapl(&stuff->mask); return (ProcXChangeFeedbackControl(client)); @@ -438,7 +435,7 @@ ProcXChangeFeedbackControl(ClientPtr client) REQUEST(xChangeFeedbackControlReq); REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); - len = stuff->length - bytes_to_int32(sizeof(xChangeFeedbackControlReq)); + len = client->req_len - bytes_to_int32(sizeof(xChangeFeedbackControlReq)); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); if (rc != Success) return rc; diff --git a/Xi/chgkbd.c b/Xi/chgkbd.c index 4f5abd731..8e16c9dea 100644 --- a/Xi/chgkbd.c +++ b/Xi/chgkbd.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -71,23 +69,6 @@ SOFTWARE. * This procedure changes the keyboard device. * */ - -int _X_COLD -SProcXChangeKeyboardDevice(ClientPtr client) -{ - REQUEST(xChangeKeyboardDeviceReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq); - return (ProcXChangeKeyboardDevice(client)); -} - -/*********************************************************************** - * - * This procedure is invoked to swap the request bytes if the server and - * client have a different byte order. - * - */ - int ProcXChangeKeyboardDevice(ClientPtr client) { diff --git a/Xi/chgkbd.h b/Xi/chgkbd.h index ec567fe42..55ea3947a 100644 --- a/Xi/chgkbd.h +++ b/Xi/chgkbd.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef CHGKBD_H #define CHGKBD_H 1 -int SProcXChangeKeyboardDevice(ClientPtr /* client */ - ); - int ProcXChangeKeyboardDevice(ClientPtr /* client */ ); diff --git a/Xi/chgkmap.c b/Xi/chgkmap.c index 2940a2cb0..73cc8b4e2 100644 --- a/Xi/chgkmap.c +++ b/Xi/chgkmap.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -77,7 +75,6 @@ SProcXChangeDeviceKeyMapping(ClientPtr client) unsigned int count; REQUEST(xChangeDeviceKeyMappingReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq); count = stuff->keyCodes * stuff->keySymsPerKeyCode; REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32)); @@ -108,7 +105,7 @@ ProcXChangeDeviceKeyMapping(ClientPtr client) ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); if (ret != Success) return ret; - len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceKeyMappingReq)); + len = client->req_len - bytes_to_int32(sizeof(xChangeDeviceKeyMappingReq)); ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify, stuff->firstKeyCode, stuff->keyCodes, diff --git a/Xi/chgprop.c b/Xi/chgprop.c index a97fab18d..ab1a6b601 100644 --- a/Xi/chgprop.c +++ b/Xi/chgprop.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -77,7 +75,6 @@ int _X_COLD SProcXChangeDeviceDontPropagateList(ClientPtr client) { REQUEST(xChangeDeviceDontPropagateListReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq); swapl(&stuff->window); swaps(&stuff->count); @@ -104,7 +101,7 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client) REQUEST(xChangeDeviceDontPropagateListReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) + stuff->count) return BadLength; diff --git a/Xi/chgptr.c b/Xi/chgptr.c index 06047a62a..42d160bf3 100644 --- a/Xi/chgptr.c +++ b/Xi/chgptr.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -69,22 +67,6 @@ SOFTWARE. /*********************************************************************** * - * This procedure is invoked to swap the request bytes if the server and - * client have a different byte order. - * - */ - -int _X_COLD -SProcXChangePointerDevice(ClientPtr client) -{ - REQUEST(xChangePointerDeviceReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xChangePointerDeviceReq); - return (ProcXChangePointerDevice(client)); -} - -/*********************************************************************** - * * This procedure changes the device used as the X pointer. * */ diff --git a/Xi/chgptr.h b/Xi/chgptr.h index 275511ffc..3a85f0f03 100644 --- a/Xi/chgptr.h +++ b/Xi/chgptr.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef CHGPTR_H #define CHGPTR_H 1 -int SProcXChangePointerDevice(ClientPtr /* client */ - ); - int ProcXChangePointerDevice(ClientPtr /* client */ ); diff --git a/Xi/closedev.c b/Xi/closedev.c index af60d7e99..15099d054 100644 --- a/Xi/closedev.c +++ b/Xi/closedev.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ @@ -66,21 +64,6 @@ SOFTWARE. /*********************************************************************** * - * This procedure closes an input device. - * - */ - -int _X_COLD -SProcXCloseDevice(ClientPtr client) -{ - REQUEST(xCloseDeviceReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xCloseDeviceReq); - return (ProcXCloseDevice(client)); -} - -/*********************************************************************** - * * Clear out event selections and passive grabs from a window for the * specified device. * diff --git a/Xi/closedev.h b/Xi/closedev.h index 798c02379..201d14f0a 100644 --- a/Xi/closedev.h +++ b/Xi/closedev.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef CLOSEDEV_H #define CLOSEDEV_H 1 -int SProcXCloseDevice(ClientPtr /* client */ - ); - int ProcXCloseDevice(ClientPtr /* client */ ); diff --git a/Xi/devbell.c b/Xi/devbell.c index 2e2a348f9..76085c738 100644 --- a/Xi/devbell.c +++ b/Xi/devbell.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -63,21 +61,6 @@ SOFTWARE. /*********************************************************************** * - * This procedure is invoked to swap the request bytes if the server and - * client have a different byte order. - * - */ - -int _X_COLD -SProcXDeviceBell(ClientPtr client) -{ - REQUEST(xDeviceBellReq); - swaps(&stuff->length); - return (ProcXDeviceBell(client)); -} - -/*********************************************************************** - * * This procedure rings a bell on an extension device. * */ diff --git a/Xi/devbell.h b/Xi/devbell.h index 2d0b05aa3..c83a9d4b0 100644 --- a/Xi/devbell.h +++ b/Xi/devbell.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef DEVBELL_H #define DEVBELL_H 1 -int SProcXDeviceBell(ClientPtr /* client */ - ); - int ProcXDeviceBell(ClientPtr /* client */ ); diff --git a/Xi/exevents.c b/Xi/exevents.c index 61de1dfda..a9c2300cc 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -78,9 +78,9 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "dix/cursor_priv.h" #include <X11/X.h> #include <X11/Xproto.h> @@ -91,8 +91,11 @@ SOFTWARE. #include <X11/extensions/XKBproto.h> #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/eventconvert.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" #include "inputstr.h" #include "windowstr.h" @@ -102,14 +105,12 @@ SOFTWARE. #include "exglobals.h" #include "eventstr.h" #include "dixevents.h" /* DeliverFocusedEvent */ -#include "dixgrabs.h" /* CreateGrab() */ #include "scrnintstr.h" #include "listdev.h" /* for CopySwapXXXClass */ #include "xace.h" #include "xiquerydevice.h" /* For List*Info */ #include "eventstr.h" #include "inpututils.h" -#include "mi.h" #include "xkbsrv.h" #define WID(w) ((w) ? ((w)->drawable.id) : 0) @@ -615,7 +616,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) if (from->button->xkb_acts) { size_t maxbuttons = max(to->button->numButtons, from->button->numButtons); - to->button->xkb_acts = xnfreallocarray(to->button->xkb_acts, + to->button->xkb_acts = XNFreallocarray(to->button->xkb_acts, maxbuttons, sizeof(XkbAction)); memset(to->button->xkb_acts, 0, maxbuttons * sizeof(XkbAction)); @@ -1094,7 +1095,7 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti, FixUpEventFromWindow(&ti->sprite, xi2, win, child, FALSE); filter = GetEventFilter(dev, xi2); - if (XaceHook(XACE_RECEIVE_ACCESS, client, win, xi2, 1) != Success) + if (XaceHookReceiveAccess(client, win, xi2, 1) != Success) return FALSE; err = TryClientEvents(client, dev, xi2, 1, filter, filter, NullGrab); free(xi2); @@ -1880,7 +1881,7 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device) int count; if (EventToCore(ev, &core, &count) == Success && count > 0) { - XaceHook(XACE_KEY_AVAIL, core, device, 0); + XaceHookKeyAvail(core, device, 0); free(core); } } @@ -2240,7 +2241,7 @@ DeliverOneGestureEvent(ClientPtr client, DeviceIntPtr dev, GestureInfoPtr gi, FixUpEventFromWindow(&gi->sprite, xi2, win, child, FALSE); filter = GetEventFilter(dev, xi2); - if (XaceHook(XACE_RECEIVE_ACCESS, client, win, xi2, 1) != Success) + if (XaceHookReceiveAccess(client, win, xi2, 1) != Success) return FALSE; err = TryClientEvents(client, dev, xi2, 1, filter, filter, NullGrab); free(xi2); @@ -2514,7 +2515,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync) access_mode |= DixFreezeAccess; - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); + rc = XaceHookDeviceAccess(client, dev, access_mode); if (rc != Success) return rc; rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess); @@ -2570,7 +2571,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync) access_mode |= DixFreezeAccess; - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); + rc = XaceHookDeviceAccess(client, dev, access_mode); if (rc != Success) return rc; @@ -2613,7 +2614,7 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type, if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync) access_mode |= DixFreezeAccess; - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); + rc = XaceHookDeviceAccess(client, dev, access_mode); if (rc != Success) return rc; @@ -2644,7 +2645,7 @@ GrabTouchOrGesture(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev, rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess); if (rc != Success) return rc; - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGrabAccess); + rc = XaceHookDeviceAccess(client, dev, DixGrabAccess); if (rc != Success) return rc; @@ -2957,7 +2958,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, break; } } - else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, ev, count)) + else if (!XaceHookSendAccess(client, NULL, pWin, ev, count)) DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab); return Success; } diff --git a/Xi/extinit.c b/Xi/extinit.c index 6354ad059..f6f21f30d 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -51,9 +51,7 @@ SOFTWARE. */ #define NUMTYPES 15 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -254,19 +252,19 @@ static int (*ProcIVector[]) (ClientPtr) = { /* For swapped clients */ static int (*SProcIVector[]) (ClientPtr) = { - NULL, /* 0 */ + NULL, /* 0 */ SProcXGetExtensionVersion, /* 1 */ - SProcXListInputDevices, /* 2 */ - SProcXOpenDevice, /* 3 */ - SProcXCloseDevice, /* 4 */ - SProcXSetDeviceMode, /* 5 */ + ProcXListInputDevices, /* 2 */ + ProcXOpenDevice, /* 3 */ + ProcXCloseDevice, /* 4 */ + ProcXSetDeviceMode, /* 5 */ SProcXSelectExtensionEvent, /* 6 */ SProcXGetSelectedExtensionEvents, /* 7 */ SProcXChangeDeviceDontPropagateList, /* 8 */ SProcXGetDeviceDontPropagateList, /* 9 */ SProcXGetDeviceMotionEvents, /* 10 */ - SProcXChangeKeyboardDevice, /* 11 */ - SProcXChangePointerDevice, /* 12 */ + ProcXChangeKeyboardDevice, /* 11 */ + ProcXChangePointerDevice, /* 12 */ SProcXGrabDevice, /* 13 */ SProcXUngrabDevice, /* 14 */ SProcXGrabDeviceKey, /* 15 */ @@ -274,30 +272,30 @@ static int (*SProcIVector[]) (ClientPtr) = { SProcXGrabDeviceButton, /* 17 */ SProcXUngrabDeviceButton, /* 18 */ SProcXAllowDeviceEvents, /* 19 */ - SProcXGetDeviceFocus, /* 20 */ + ProcXGetDeviceFocus, /* 20 */ SProcXSetDeviceFocus, /* 21 */ - SProcXGetFeedbackControl, /* 22 */ + ProcXGetFeedbackControl, /* 22 */ SProcXChangeFeedbackControl, /* 23 */ - SProcXGetDeviceKeyMapping, /* 24 */ + ProcXGetDeviceKeyMapping, /* 24 */ SProcXChangeDeviceKeyMapping, /* 25 */ - SProcXGetDeviceModifierMapping, /* 26 */ - SProcXSetDeviceModifierMapping, /* 27 */ - SProcXGetDeviceButtonMapping, /* 28 */ - SProcXSetDeviceButtonMapping, /* 29 */ - SProcXQueryDeviceState, /* 30 */ + ProcXGetDeviceModifierMapping, /* 26 */ + ProcXSetDeviceModifierMapping, /* 27 */ + ProcXGetDeviceButtonMapping, /* 28 */ + ProcXSetDeviceButtonMapping, /* 29 */ + ProcXQueryDeviceState, /* 30 */ SProcXSendExtensionEvent, /* 31 */ - SProcXDeviceBell, /* 32 */ - SProcXSetDeviceValuators, /* 33 */ + ProcXDeviceBell, /* 32 */ + ProcXSetDeviceValuators, /* 33 */ SProcXGetDeviceControl, /* 34 */ SProcXChangeDeviceControl, /* 35 */ - SProcXListDeviceProperties, /* 36 */ + ProcXListDeviceProperties, /* 36 */ SProcXChangeDeviceProperty, /* 37 */ SProcXDeleteDeviceProperty, /* 38 */ SProcXGetDeviceProperty, /* 39 */ SProcXIQueryPointer, /* 40 */ SProcXIWarpPointer, /* 41 */ SProcXIChangeCursor, /* 42 */ - SProcXIChangeHierarchy, /* 43 */ + ProcXIChangeHierarchy, /* 43 */ SProcXISetClientPointer, /* 44 */ SProcXIGetClientPointer, /* 45 */ SProcXISelectEvents, /* 46 */ diff --git a/Xi/getbmap.c b/Xi/getbmap.c index ce3e9e60b..623978fd5 100644 --- a/Xi/getbmap.c +++ b/Xi/getbmap.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -67,20 +65,6 @@ SOFTWARE. * */ -int _X_COLD -SProcXGetDeviceButtonMapping(ClientPtr client) -{ - REQUEST(xGetDeviceButtonMappingReq); - swaps(&stuff->length); - return (ProcXGetDeviceButtonMapping(client)); -} - -/*********************************************************************** - * - * This procedure gets the button mapping for the specified device. - * - */ - int ProcXGetDeviceButtonMapping(ClientPtr client) { diff --git a/Xi/getbmap.h b/Xi/getbmap.h index 8b107d026..a320c7421 100644 --- a/Xi/getbmap.h +++ b/Xi/getbmap.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef GETBMAP_H #define GETBMAP_H 1 -int SProcXGetDeviceButtonMapping(ClientPtr /* client */ - ); - int ProcXGetDeviceButtonMapping(ClientPtr /* client */ ); diff --git a/Xi/getdctl.c b/Xi/getdctl.c index 149f5e14e..07b6bec7e 100644 --- a/Xi/getdctl.c +++ b/Xi/getdctl.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -72,7 +70,6 @@ int _X_COLD SProcXGetDeviceControl(ClientPtr client) { REQUEST(xGetDeviceControlReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetDeviceControlReq); swaps(&stuff->control); return (ProcXGetDeviceControl(client)); diff --git a/Xi/getfctl.c b/Xi/getfctl.c index eea0113c1..562cd5260 100644 --- a/Xi/getfctl.c +++ b/Xi/getfctl.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -63,21 +61,6 @@ SOFTWARE. /*********************************************************************** * - * This procedure gets the control attributes for an extension device, - * for clients on machines with a different byte ordering than the server. - * - */ - -int _X_COLD -SProcXGetFeedbackControl(ClientPtr client) -{ - REQUEST(xGetFeedbackControlReq); - swaps(&stuff->length); - return (ProcXGetFeedbackControl(client)); -} - -/*********************************************************************** - * * This procedure copies KbdFeedbackClass data, swapping if necessary. * */ diff --git a/Xi/getfctl.h b/Xi/getfctl.h index f0b240d4c..14944d28b 100644 --- a/Xi/getfctl.h +++ b/Xi/getfctl.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef GETFCTL_H #define GETFCTL_H 1 -int SProcXGetFeedbackControl(ClientPtr /* client */ - ); - int ProcXGetFeedbackControl(ClientPtr /* client */ ); diff --git a/Xi/getfocus.c b/Xi/getfocus.c index cf8e02449..731896b7d 100644 --- a/Xi/getfocus.c +++ b/Xi/getfocus.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "windowstr.h" /* focus struct */ #include "inputstr.h" /* DeviceIntPtr */ @@ -68,20 +66,6 @@ SOFTWARE. * */ -int _X_COLD -SProcXGetDeviceFocus(ClientPtr client) -{ - REQUEST(xGetDeviceFocusReq); - swaps(&stuff->length); - return (ProcXGetDeviceFocus(client)); -} - -/*********************************************************************** - * - * This procedure gets the focus for a device. - * - */ - int ProcXGetDeviceFocus(ClientPtr client) { diff --git a/Xi/getfocus.h b/Xi/getfocus.h index 6e90ae77b..daaedfcbd 100644 --- a/Xi/getfocus.h +++ b/Xi/getfocus.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef GETFOCUS_H #define GETFOCUS_H 1 -int SProcXGetDeviceFocus(ClientPtr /* client */ - ); - int ProcXGetDeviceFocus(ClientPtr /* client */ ); diff --git a/Xi/getkmap.c b/Xi/getkmap.c index c6db2cee2..5d9cba1d5 100644 --- a/Xi/getkmap.c +++ b/Xi/getkmap.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -66,21 +64,6 @@ SOFTWARE. /*********************************************************************** * - * This procedure gets the key mapping for an extension device, - * for clients on machines with a different byte ordering than the server. - * - */ - -int _X_COLD -SProcXGetDeviceKeyMapping(ClientPtr client) -{ - REQUEST(xGetDeviceKeyMappingReq); - swaps(&stuff->length); - return (ProcXGetDeviceKeyMapping(client)); -} - -/*********************************************************************** - * * Get the device key mapping. * */ diff --git a/Xi/getkmap.h b/Xi/getkmap.h index 8f0ff8eec..f51e0e96d 100644 --- a/Xi/getkmap.h +++ b/Xi/getkmap.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef GETKMAP_H #define GETKMAP_H 1 -int SProcXGetDeviceKeyMapping(ClientPtr /* client */ - ); - int ProcXGetDeviceKeyMapping(ClientPtr /* client */ ); diff --git a/Xi/getmmap.c b/Xi/getmmap.c index 19d8eb221..4ff03a3bd 100644 --- a/Xi/getmmap.c +++ b/Xi/getmmap.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -63,21 +61,6 @@ SOFTWARE. /*********************************************************************** * - * This procedure gets the modifier mapping for an extension device, - * for clients on machines with a different byte ordering than the server. - * - */ - -int _X_COLD -SProcXGetDeviceModifierMapping(ClientPtr client) -{ - REQUEST(xGetDeviceModifierMappingReq); - swaps(&stuff->length); - return (ProcXGetDeviceModifierMapping(client)); -} - -/*********************************************************************** - * * Get the device Modifier mapping. * */ diff --git a/Xi/getmmap.h b/Xi/getmmap.h index d0a76df43..7512188ec 100644 --- a/Xi/getmmap.h +++ b/Xi/getmmap.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef GETMMAP_H #define GETMMAP_H 1 -int SProcXGetDeviceModifierMapping(ClientPtr /* client */ - ); - int ProcXGetDeviceModifierMapping(ClientPtr /* client */ ); diff --git a/Xi/getprop.c b/Xi/getprop.c index 282831310..54b8131ec 100644 --- a/Xi/getprop.c +++ b/Xi/getprop.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -78,7 +76,6 @@ int _X_COLD SProcXGetDeviceDontPropagateList(ClientPtr client) { REQUEST(xGetDeviceDontPropagateListReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq); swapl(&stuff->window); return (ProcXGetDeviceDontPropagateList(client)); diff --git a/Xi/getselev.c b/Xi/getselev.c index b85eca3ff..0abf9faa9 100644 --- a/Xi/getselev.c +++ b/Xi/getselev.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -76,7 +74,6 @@ int _X_COLD SProcXGetSelectedExtensionEvents(ClientPtr client) { REQUEST(xGetSelectedExtensionEventsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq); swapl(&stuff->window); return (ProcXGetSelectedExtensionEvents(client)); diff --git a/Xi/getvers.c b/Xi/getvers.c index a56ff1684..0d90fc9a8 100644 --- a/Xi/getvers.c +++ b/Xi/getvers.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -74,7 +72,6 @@ int _X_COLD SProcXGetExtensionVersion(ClientPtr client) { REQUEST(xGetExtensionVersionReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq); swaps(&stuff->nbytes); return (ProcXGetExtensionVersion(client)); @@ -94,7 +91,7 @@ ProcXGetExtensionVersion(ClientPtr client) REQUEST(xGetExtensionVersionReq); REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq); - if (stuff->length != bytes_to_int32(sizeof(xGetExtensionVersionReq) + + if (client->req_len != bytes_to_int32(sizeof(xGetExtensionVersionReq) + stuff->nbytes)) return BadLength; diff --git a/Xi/grabdev.c b/Xi/grabdev.c index d26bea434..9bae237d1 100644 --- a/Xi/grabdev.c +++ b/Xi/grabdev.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -78,13 +76,13 @@ int _X_COLD SProcXGrabDevice(ClientPtr client) { REQUEST(xGrabDeviceReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xGrabDeviceReq); + swapl(&stuff->grabWindow); swapl(&stuff->time); swaps(&stuff->event_count); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count) return BadLength; @@ -111,7 +109,7 @@ ProcXGrabDevice(ClientPtr client) REQUEST(xGrabDeviceReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceReq); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count) return BadLength; diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c index 6b54dd425..9a2ef87ab 100644 --- a/Xi/grabdevb.c +++ b/Xi/grabdevb.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -76,7 +74,6 @@ int _X_COLD SProcXGrabDeviceButton(ClientPtr client) { REQUEST(xGrabDeviceButtonReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq); swapl(&stuff->grabWindow); swaps(&stuff->modifiers); @@ -108,7 +105,7 @@ ProcXGrabDeviceButton(ClientPtr client) REQUEST(xGrabDeviceButtonReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xGrabDeviceButtonReq)) + stuff->event_count) return BadLength; @@ -126,7 +123,7 @@ ProcXGrabDeviceButton(ClientPtr client) } else { mdev = PickKeyboard(client); - ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess); + ret = XaceHookDeviceAccess(client, mdev, DixUseAccess); if (ret != Success) return ret; } diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c index f63de62d3..7668735ea 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -76,7 +74,6 @@ int _X_COLD SProcXGrabDeviceKey(ClientPtr client) { REQUEST(xGrabDeviceKeyReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq); swapl(&stuff->grabWindow); swaps(&stuff->modifiers); @@ -106,7 +103,7 @@ ProcXGrabDeviceKey(ClientPtr client) REQUEST(xGrabDeviceKeyReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count) return BadLength; @@ -124,7 +121,7 @@ ProcXGrabDeviceKey(ClientPtr client) } else { mdev = PickKeyboard(client); - ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess); + ret = XaceHookDeviceAccess(client, mdev, DixUseAccess); if (ret != Success) return ret; } diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c index 57a25bb2e..41d68ec87 100644 --- a/Xi/gtmotion.c +++ b/Xi/gtmotion.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -73,7 +71,6 @@ int _X_COLD SProcXGetDeviceMotionEvents(ClientPtr client) { REQUEST(xGetDeviceMotionEventsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq); swapl(&stuff->start); swapl(&stuff->stop); diff --git a/Xi/listdev.c b/Xi/listdev.c index c15e61b37..bf2f439a4 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -50,40 +50,26 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> /* for inputstr.h */ #include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> + +#include "dix/input_priv.h" + +#include "inputstr.h" /* DeviceIntPtr */ #include "XIstubs.h" #include "extnsionst.h" #include "exevents.h" #include "xace.h" #include "xkbsrv.h" #include "xkbstr.h" - #include "listdev.h" /*********************************************************************** * - * This procedure lists the input devices available to the server. - * - */ - -int _X_COLD -SProcXListInputDevices(ClientPtr client) -{ - REQUEST(xListInputDevicesReq); - swaps(&stuff->length); - return (ProcXListInputDevices(client)); -} - -/*********************************************************************** - * * This procedure calculates the size of the information to be returned * for an input device. * @@ -309,7 +295,7 @@ ShouldSkipDevice(ClientPtr client, DeviceIntPtr d) { /* don't send master devices other than VCP/VCK */ if (!IsMaster(d) || d == inputInfo.pointer ||d == inputInfo.keyboard) { - int rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess); + int rc = XaceHookDeviceAccess(client, d, DixGetAttrAccess); if (rc == Success) return FALSE; @@ -350,7 +336,7 @@ ProcXListInputDevices(ClientPtr client) }; /* allocate space for saving skip value */ - skip = calloc(sizeof(Bool), inputInfo.numDevices); + skip = calloc(inputInfo.numDevices, sizeof(Bool)); if (!skip) return BadAlloc; diff --git a/Xi/listdev.h b/Xi/listdev.h index 39ea2389f..c8f91796d 100644 --- a/Xi/listdev.h +++ b/Xi/listdev.h @@ -32,9 +32,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define VPC 20 /* Max # valuators per chunk */ -int SProcXListInputDevices(ClientPtr /* client */ - ); - int ProcXListInputDevices(ClientPtr /* client */ ); diff --git a/Xi/opendev.c b/Xi/opendev.c index 3472c97dd..977a44115 100644 --- a/Xi/opendev.c +++ b/Xi/opendev.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> @@ -68,21 +66,6 @@ extern CARD8 event_base[]; /*********************************************************************** * - * This procedure swaps the request if the server and client have different - * byte orderings. - * - */ - -int _X_COLD -SProcXOpenDevice(ClientPtr client) -{ - REQUEST(xOpenDeviceReq); - swaps(&stuff->length); - return (ProcXOpenDevice(client)); -} - -/*********************************************************************** - * * This procedure causes the server to open an input device. * */ diff --git a/Xi/opendev.h b/Xi/opendev.h index e2d806197..641dd7862 100644 --- a/Xi/opendev.h +++ b/Xi/opendev.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef OPENDEV_H #define OPENDEV_H 1 -int SProcXOpenDevice(ClientPtr /* client */ - ); - int ProcXOpenDevice(ClientPtr /* client */ ); diff --git a/Xi/queryst.c b/Xi/queryst.c index 34bfa9031..ca386f5dc 100644 --- a/Xi/queryst.c +++ b/Xi/queryst.c @@ -32,14 +32,13 @@ from The Open Group. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "dix/exevents_priv.h" +#include "dix/input_priv.h" #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ @@ -50,20 +49,6 @@ from The Open Group. /*********************************************************************** * - * This procedure allows a client to query the state of a device. - * - */ - -int _X_COLD -SProcXQueryDeviceState(ClientPtr client) -{ - REQUEST(xQueryDeviceStateReq); - swaps(&stuff->length); - return (ProcXQueryDeviceState(client)); -} - -/*********************************************************************** - * * This procedure allows frozen events to be routed. * */ diff --git a/Xi/queryst.h b/Xi/queryst.h index 5619ca59d..a271edf71 100644 --- a/Xi/queryst.h +++ b/Xi/queryst.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef QUERYST_H #define QUERYST_H 1 -int SProcXQueryDeviceState(ClientPtr /* client */ - ); - int ProcXQueryDeviceState(ClientPtr /* client */ ); diff --git a/Xi/selectev.c b/Xi/selectev.c index 378403d3b..3f2a3178c 100644 --- a/Xi/selectev.c +++ b/Xi/selectev.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XI2.h> @@ -123,7 +121,6 @@ int _X_COLD SProcXSelectExtensionEvent(ClientPtr client) { REQUEST(xSelectExtensionEventReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq); swapl(&stuff->window); swaps(&stuff->count); @@ -150,7 +147,7 @@ ProcXSelectExtensionEvent(ClientPtr client) REQUEST(xSelectExtensionEventReq); REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xSelectExtensionEventReq)) + stuff->count) return BadLength; diff --git a/Xi/sendexev.c b/Xi/sendexev.c index 0f6b4e46a..79a93b6b7 100644 --- a/Xi/sendexev.c +++ b/Xi/sendexev.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -84,12 +82,11 @@ SProcXSendExtensionEvent(ClientPtr client) EventSwapPtr proc; REQUEST(xSendExtensionEventReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq); swapl(&stuff->destination); swaps(&stuff->count); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + bytes_to_int32(stuff->num_events * sizeof(xEvent))) return BadLength; @@ -135,7 +132,7 @@ ProcXSendExtensionEvent(ClientPtr client) REQUEST(xSendExtensionEventReq); REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + (stuff->num_events * bytes_to_int32(sizeof(xEvent)))) return BadLength; diff --git a/Xi/setbmap.c b/Xi/setbmap.c index f94db861d..4afa655fa 100644 --- a/Xi/setbmap.c +++ b/Xi/setbmap.c @@ -50,34 +50,20 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> + +#include "dix/input_priv.h" + +#include "inputstr.h" /* DeviceIntPtr */ #include "exevents.h" #include "exglobals.h" - #include "setbmap.h" /*********************************************************************** * - * This procedure changes the button mapping. - * - */ - -int _X_COLD -SProcXSetDeviceButtonMapping(ClientPtr client) -{ - REQUEST(xSetDeviceButtonMappingReq); - swaps(&stuff->length); - return (ProcXSetDeviceButtonMapping(client)); -} - -/*********************************************************************** - * * This procedure lists the input devices available to the server. * */ @@ -92,7 +78,7 @@ ProcXSetDeviceButtonMapping(ClientPtr client) REQUEST(xSetDeviceButtonMappingReq); REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq); - if (stuff->length != + if (client->req_len != bytes_to_int32(sizeof(xSetDeviceButtonMappingReq) + stuff->map_length)) return BadLength; diff --git a/Xi/setbmap.h b/Xi/setbmap.h index 8d73f23b4..b402692ce 100644 --- a/Xi/setbmap.h +++ b/Xi/setbmap.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef SETBMAP_H #define SETBMAP_H 1 -int SProcXSetDeviceButtonMapping(ClientPtr /* client */ - ); - int ProcXSetDeviceButtonMapping(ClientPtr /* client */ ); diff --git a/Xi/setdval.c b/Xi/setdval.c index e57cb259d..2127e6afe 100644 --- a/Xi/setdval.c +++ b/Xi/setdval.c @@ -50,34 +50,20 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> + +#include "dix/input_priv.h" + +#include "inputstr.h" /* DeviceIntPtr */ #include "XIstubs.h" #include "exglobals.h" - #include "setdval.h" /*********************************************************************** * - * Handle a request from a client with a different byte order. - * - */ - -int _X_COLD -SProcXSetDeviceValuators(ClientPtr client) -{ - REQUEST(xSetDeviceValuatorsReq); - swaps(&stuff->length); - return (ProcXSetDeviceValuators(client)); -} - -/*********************************************************************** - * * This procedure sets the value of valuators on an extension input device. * */ @@ -100,7 +86,7 @@ ProcXSetDeviceValuators(ClientPtr client) .status = Success }; - if (stuff->length != bytes_to_int32(sizeof(xSetDeviceValuatorsReq)) + + if (client->req_len != bytes_to_int32(sizeof(xSetDeviceValuatorsReq)) + stuff->num_valuators) return BadLength; diff --git a/Xi/setdval.h b/Xi/setdval.h index 05642743a..452be2897 100644 --- a/Xi/setdval.h +++ b/Xi/setdval.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef SETDVAL_H #define SETDVAL_H 1 -int SProcXSetDeviceValuators(ClientPtr /* client */ - ); - int ProcXSetDeviceValuators(ClientPtr /* client */ ); diff --git a/Xi/setfocus.c b/Xi/setfocus.c index f0c80accc..16f969436 100644 --- a/Xi/setfocus.c +++ b/Xi/setfocus.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -76,7 +74,6 @@ int _X_COLD SProcXSetDeviceFocus(ClientPtr client) { REQUEST(xSetDeviceFocusReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSetDeviceFocusReq); swapl(&stuff->focus); swapl(&stuff->time); diff --git a/Xi/setmmap.c b/Xi/setmmap.c index d60096a5a..1c8df53c2 100644 --- a/Xi/setmmap.c +++ b/Xi/setmmap.c @@ -50,36 +50,21 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2.h> #include <X11/extensions/XIproto.h> + +#include "dix/input_priv.h" + +#include "inputstr.h" /* DeviceIntPtr */ #include "exevents.h" #include "exglobals.h" - #include "setmmap.h" /*********************************************************************** * - * This procedure sets the modifier mapping for an extension device, - * for clients on machines with a different byte ordering than the server. - * - */ - -int _X_COLD -SProcXSetDeviceModifierMapping(ClientPtr client) -{ - REQUEST(xSetDeviceModifierMappingReq); - swaps(&stuff->length); - return (ProcXSetDeviceModifierMapping(client)); -} - -/*********************************************************************** - * * Set the device Modifier mapping. * */ @@ -94,7 +79,7 @@ ProcXSetDeviceModifierMapping(ClientPtr client) REQUEST(xSetDeviceModifierMappingReq); REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq); - if (stuff->length != bytes_to_int32(sizeof(xSetDeviceModifierMappingReq)) + + if (client->req_len != bytes_to_int32(sizeof(xSetDeviceModifierMappingReq)) + (stuff->numKeyPerModifier << 1)) return BadLength; diff --git a/Xi/setmmap.h b/Xi/setmmap.h index 9347b9679..f8b96a875 100644 --- a/Xi/setmmap.h +++ b/Xi/setmmap.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef SETMMAP_H #define SETMMAP_H 1 -int SProcXSetDeviceModifierMapping(ClientPtr /* client */ - ); - int ProcXSetDeviceModifierMapping(ClientPtr /* client */ ); diff --git a/Xi/setmode.c b/Xi/setmode.c index e7e12d4e0..9c9476134 100644 --- a/Xi/setmode.c +++ b/Xi/setmode.c @@ -50,34 +50,20 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> + +#include "dix/input_priv.h" + +#include "inputstr.h" /* DeviceIntPtr */ #include "XIstubs.h" #include "exglobals.h" - #include "setmode.h" /*********************************************************************** * - * Handle a request from a client with a different byte order. - * - */ - -int _X_COLD -SProcXSetDeviceMode(ClientPtr client) -{ - REQUEST(xSetDeviceModeReq); - swaps(&stuff->length); - return (ProcXSetDeviceMode(client)); -} - -/*********************************************************************** - * * This procedure sets the mode of a device. * */ diff --git a/Xi/setmode.h b/Xi/setmode.h index d01bfffd3..cc906c735 100644 --- a/Xi/setmode.h +++ b/Xi/setmode.h @@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef SETMODE_H #define SETMODE_H 1 -int SProcXSetDeviceMode(ClientPtr /* client */ - ); - int ProcXSetDeviceMode(ClientPtr /* client */ ); diff --git a/Xi/stubs.c b/Xi/stubs.c index 27848a2f6..ace15c006 100644 --- a/Xi/stubs.c +++ b/Xi/stubs.c @@ -54,9 +54,7 @@ SOFTWARE. * Xnest could do the same thing. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> diff --git a/Xi/ungrdev.c b/Xi/ungrdev.c index fd4fc0f45..e64d3b99c 100644 --- a/Xi/ungrdev.c +++ b/Xi/ungrdev.c @@ -50,9 +50,7 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ @@ -71,7 +69,6 @@ int _X_COLD SProcXUngrabDevice(ClientPtr client) { REQUEST(xUngrabDeviceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xUngrabDeviceReq); swapl(&stuff->time); return (ProcXUngrabDevice(client)); diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c index 0f5c7913c..1d6795fe8 100644 --- a/Xi/ungrdevb.c +++ b/Xi/ungrdevb.c @@ -50,19 +50,17 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ #include "exglobals.h" -#include "dixgrabs.h" #include "ungrdevb.h" #define AllModifiersMask ( \ @@ -79,7 +77,6 @@ int _X_COLD SProcXUngrabDeviceButton(ClientPtr client) { REQUEST(xUngrabDeviceButtonReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq); swapl(&stuff->grabWindow); swaps(&stuff->modifiers); diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c index 8aa797b4d..eee36cbd1 100644 --- a/Xi/ungrdevk.c +++ b/Xi/ungrdevk.c @@ -50,19 +50,17 @@ SOFTWARE. * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ #include "exglobals.h" -#include "dixgrabs.h" #include "xkbsrv.h" #include "xkbstr.h" #include "ungrdevk.h" @@ -81,7 +79,6 @@ int _X_COLD SProcXUngrabDeviceKey(ClientPtr client) { REQUEST(xUngrabDeviceKeyReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq); swapl(&stuff->grabWindow); swaps(&stuff->modifiers); diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c index 03ced79bb..b9979a824 100644 --- a/Xi/xiallowev.c +++ b/Xi/xiallowev.c @@ -29,15 +29,15 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> #include "dix/dix_priv.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "os/fmt.h" #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ @@ -52,10 +52,9 @@ SProcXIAllowEvents(ClientPtr client) REQUEST(xXIAllowEventsReq); REQUEST_AT_LEAST_SIZE(xXIAllowEventsReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->time); - if (stuff->length > 3) { + if (client->req_len > 3) { xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq *) stuff; REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq); @@ -96,25 +95,25 @@ ProcXIAllowEvents(ClientPtr client) switch (stuff->mode) { case XIReplayDevice: - AllowSome(client, time, dev, NOT_GRABBED); + AllowSome(client, time, dev, GRAB_STATE_NOT_GRABBED); break; case XISyncDevice: - AllowSome(client, time, dev, FREEZE_NEXT_EVENT); + AllowSome(client, time, dev, GRAB_STATE_FREEZE_NEXT_EVENT); break; case XIAsyncDevice: - AllowSome(client, time, dev, THAWED); + AllowSome(client, time, dev, GRAB_STATE_THAWED); break; case XIAsyncPairedDevice: if (IsMaster(dev)) - AllowSome(client, time, dev, THAW_OTHERS); + AllowSome(client, time, dev, GRAB_STATE_THAW_OTHERS); break; case XISyncPair: if (IsMaster(dev)) - AllowSome(client, time, dev, FREEZE_BOTH_NEXT_EVENT); + AllowSome(client, time, dev, GRAB_STATE_FREEZE_BOTH_NEXT_EVENT); break; case XIAsyncPair: if (IsMaster(dev)) - AllowSome(client, time, dev, THAWED_BOTH); + AllowSome(client, time, dev, GRAB_STATE_THAWED_BOTH); break; case XIRejectTouch: case XIAcceptTouch: diff --git a/Xi/xibarriers.c b/Xi/xibarriers.c index da6964453..28bc0a24f 100644 --- a/Xi/xibarriers.c +++ b/Xi/xibarriers.c @@ -41,11 +41,12 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" #include "xibarriers.h" #include "scrnintstr.h" @@ -59,7 +60,6 @@ #include "list.h" #include "exglobals.h" #include "eventstr.h" -#include "mi.h" RESTYPE PointerBarrierType; @@ -131,14 +131,15 @@ static void FreePointerBarrierClient(struct PointerBarrierClient *c) static struct PointerBarrierDevice *GetBarrierDevice(struct PointerBarrierClient *c, int deviceid) { - struct PointerBarrierDevice *pbd = NULL; + struct PointerBarrierDevice *p, *pbd = NULL; - xorg_list_for_each_entry(pbd, &c->per_device, entry) { - if (pbd->deviceid == deviceid) + xorg_list_for_each_entry(p, &c->per_device, entry) { + if (p->deviceid == deviceid) { + pbd = p; break; + } } - BUG_WARN(!pbd); return pbd; } @@ -339,6 +340,9 @@ barrier_find_nearest(BarrierScreenPtr cs, DeviceIntPtr dev, double distance; pbd = GetBarrierDevice(c, dev->id); + if (!pbd) + continue; + if (pbd->seen) continue; @@ -447,6 +451,9 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen, nearest = &c->barrier; pbd = GetBarrierDevice(c, master->id); + if (!pbd) + continue; + new_sequence = !pbd->hit; pbd->seen = TRUE; @@ -487,6 +494,9 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen, int flags = 0; pbd = GetBarrierDevice(c, master->id); + if (!pbd) + continue; + pbd->seen = FALSE; if (!pbd->hit) continue; @@ -681,6 +691,9 @@ BarrierFreeBarrier(void *data, XID id) continue; pbd = GetBarrierDevice(c, dev->id); + if (!pbd) + continue; + if (!pbd->hit) continue; @@ -740,6 +753,8 @@ static void remove_master_func(void *res, XID id, void *devid) barrier = container_of(b, struct PointerBarrierClient, barrier); pbd = GetBarrierDevice(barrier, *deviceid); + if (!pbd) + return; if (pbd->hit) { BarrierEvent ev = { @@ -842,7 +857,6 @@ SProcXIBarrierReleasePointer(ClientPtr client) REQUEST(xXIBarrierReleasePointerReq); int i; - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq); swapl(&stuff->num_barriers); @@ -905,6 +919,10 @@ ProcXIBarrierReleasePointer(ClientPtr client) barrier = container_of(b, struct PointerBarrierClient, barrier); pbd = GetBarrierDevice(barrier, dev->id); + if (!pbd) { + client->errorValue = dev->id; + return BadDevice; + } if (pbd->barrier_event_id == event_id) pbd->release_event_id = event_id; diff --git a/Xi/xichangecursor.c b/Xi/xichangecursor.c index 9f2a616d9..a0ed7adf7 100644 --- a/Xi/xichangecursor.c +++ b/Xi/xichangecursor.c @@ -29,15 +29,14 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> /* for inputstr.h */ #include <X11/Xproto.h> /* Request macro */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" #include "inputstr.h" /* DeviceIntPtr */ @@ -60,7 +59,6 @@ SProcXIChangeCursor(ClientPtr client) { REQUEST(xXIChangeCursorReq); REQUEST_SIZE_MATCH(xXIChangeCursorReq); - swaps(&stuff->length); swapl(&stuff->win); swapl(&stuff->cursor); swaps(&stuff->deviceid); diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c index eea917ff6..c49fb4cfc 100644 --- a/Xi/xichangehierarchy.c +++ b/Xi/xichangehierarchy.c @@ -30,9 +30,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> /* for inputstr.h */ #include <X11/Xproto.h> /* Request macro */ @@ -42,13 +40,14 @@ #include "dix/dix_priv.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ #include "scrnintstr.h" /* screen structure */ #include "extnsionst.h" #include "exglobals.h" -#include "geext.h" +#include "misc.h" #include "xace.h" #include "xiquerydevice.h" /* for GetDeviceUse */ #include "xkbsrv.h" @@ -128,14 +127,6 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) * */ -int _X_COLD -SProcXIChangeHierarchy(ClientPtr client) -{ - REQUEST(xXIChangeHierarchyReq); - swaps(&stuff->length); - return (ProcXIChangeHierarchy(client)); -} - static int add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES]) { @@ -216,46 +207,68 @@ disable_clientpointer(DeviceIntPtr dev) } } +static DeviceIntPtr +find_disabled_master(int type) +{ + DeviceIntPtr dev; + + /* Once a master device is disabled it loses the pairing, so returning the first + * match is good enough */ + for (dev = inputInfo.off_devices; dev; dev = dev->next) { + if (dev->type == type) + return dev; + } + + return NULL; +} + static int remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES]) { - DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; + DeviceIntPtr dev, ptr, keybd, XTestptr, XTestkeybd; int rc = Success; if (r->return_mode != XIAttachToMaster && r->return_mode != XIFloating) return BadValue; - rc = dixLookupDevice(&ptr, r->deviceid, client, DixDestroyAccess); + rc = dixLookupDevice(&dev, r->deviceid, client, DixDestroyAccess); if (rc != Success) goto unwind; - if (!IsMaster(ptr)) { + if (!IsMaster(dev)) { client->errorValue = r->deviceid; rc = BadDevice; goto unwind; } /* XXX: For now, don't allow removal of VCP, VCK */ - if (ptr == inputInfo.pointer ||ptr == inputInfo.keyboard) { + if (dev == inputInfo.pointer || dev == inputInfo.keyboard) { rc = BadDevice; goto unwind; } - ptr = GetMaster(ptr, MASTER_POINTER); + if ((ptr = GetMaster(dev, MASTER_POINTER)) == NULL) + ptr = find_disabled_master(MASTER_POINTER); + BUG_RETURN_VAL(ptr == NULL, BadDevice); rc = dixLookupDevice(&ptr, ptr->id, client, DixDestroyAccess); if (rc != Success) goto unwind; - keybd = GetMaster(ptr, MASTER_KEYBOARD); + + if ((keybd = GetMaster(dev, MASTER_KEYBOARD)) == NULL) + keybd = find_disabled_master(MASTER_KEYBOARD); + BUG_RETURN_VAL(keybd == NULL, BadDevice); rc = dixLookupDevice(&keybd, keybd->id, client, DixDestroyAccess); if (rc != Success) goto unwind; XTestptr = GetXTestDevice(ptr); + BUG_RETURN_VAL(XTestptr == NULL, BadDevice); rc = dixLookupDevice(&XTestptr, XTestptr->id, client, DixDestroyAccess); if (rc != Success) goto unwind; XTestkeybd = GetXTestDevice(keybd); + BUG_RETURN_VAL(XTestkeybd == NULL, BadDevice); rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client, DixDestroyAccess); if (rc != Success) goto unwind; diff --git a/Xi/xichangehierarchy.h b/Xi/xichangehierarchy.h index 649b654e5..8fa3a66e7 100644 --- a/Xi/xichangehierarchy.h +++ b/Xi/xichangehierarchy.h @@ -36,7 +36,6 @@ #ifndef CHDEVHIER_H #define CHDEVHIER_H 1 -int SProcXIChangeHierarchy(ClientPtr /* client */ ); int ProcXIChangeHierarchy(ClientPtr /* client */ ); void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]); diff --git a/Xi/xigetclientpointer.c b/Xi/xigetclientpointer.c index f63d6006e..95fb6f2d1 100644 --- a/Xi/xigetclientpointer.c +++ b/Xi/xigetclientpointer.c @@ -23,9 +23,7 @@ * Author: Peter Hutterer, University of South Australia, NICTA */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> /* for inputstr.h */ #include <X11/Xproto.h> /* Request macro */ @@ -54,7 +52,6 @@ SProcXIGetClientPointer(ClientPtr client) REQUEST(xXIGetClientPointerReq); REQUEST_SIZE_MATCH(xXIGetClientPointerReq); - swaps(&stuff->length); swapl(&stuff->win); return ProcXIGetClientPointer(client); } diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c index 604f8c926..f7fea9cf3 100644 --- a/Xi/xigrabdev.c +++ b/Xi/xigrabdev.c @@ -29,9 +29,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> @@ -55,7 +53,6 @@ SProcXIGrabDevice(ClientPtr client) */ REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->grab_window); swapl(&stuff->cursor); @@ -84,6 +81,9 @@ ProcXIGrabDevice(ClientPtr client) if (ret != Success) return ret; + if (!dev->enabled) + return AlreadyGrabbed; + if (!IsMaster(dev)) stuff->paired_device_mode = GrabModeAsync; @@ -140,7 +140,6 @@ SProcXIUngrabDevice(ClientPtr client) REQUEST(xXIUngrabDeviceReq); REQUEST_SIZE_MATCH(xXIUngrabDeviceReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->time); diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index 78147d8dd..2d6c51eb5 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -29,14 +29,13 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/exevents_priv.h" #include "inputstr.h" /* DeviceIntPtr */ @@ -44,7 +43,6 @@ #include "swaprep.h" #include "exglobals.h" /* BadDevice */ #include "xipassivegrab.h" -#include "dixgrabs.h" #include "misc.h" #include "inpututils.h" @@ -57,7 +55,6 @@ SProcXIPassiveGrabDevice(ClientPtr client) REQUEST(xXIPassiveGrabDeviceReq); REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->grab_window); swapl(&stuff->cursor); @@ -282,7 +279,6 @@ SProcXIPassiveUngrabDevice(ClientPtr client) REQUEST(xXIPassiveUngrabDeviceReq); REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq); - swaps(&stuff->length); swapl(&stuff->grab_window); swaps(&stuff->deviceid); swapl(&stuff->detail); diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c index aaafc629b..8db6b03d1 100644 --- a/Xi/xiproperty.c +++ b/Xi/xiproperty.c @@ -25,9 +25,7 @@ /* This code is a modified version of randr/rrproperty.c */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/Xatom.h> #include <X11/extensions/XI.h> @@ -35,6 +33,7 @@ #include <X11/extensions/XI2proto.h> #include "dix/exevents_priv.h" +#include "dix/input_priv.h" #include "dix.h" #include "inputstr.h" @@ -1015,22 +1014,11 @@ ProcXGetDeviceProperty(ClientPtr client) } int _X_COLD -SProcXListDeviceProperties(ClientPtr client) -{ - REQUEST(xListDevicePropertiesReq); - REQUEST_SIZE_MATCH(xListDevicePropertiesReq); - - swaps(&stuff->length); - return (ProcXListDeviceProperties(client)); -} - -int _X_COLD SProcXChangeDeviceProperty(ClientPtr client) { REQUEST(xChangeDevicePropertyReq); REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq); - swaps(&stuff->length); swapl(&stuff->property); swapl(&stuff->type); swapl(&stuff->nUnits); @@ -1043,7 +1031,6 @@ SProcXDeleteDeviceProperty(ClientPtr client) REQUEST(xDeleteDevicePropertyReq); REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq); - swaps(&stuff->length); swapl(&stuff->property); return (ProcXDeleteDeviceProperty(client)); } @@ -1054,7 +1041,6 @@ SProcXGetDeviceProperty(ClientPtr client) REQUEST(xGetDevicePropertyReq); REQUEST_SIZE_MATCH(xGetDevicePropertyReq); - swaps(&stuff->length); swapl(&stuff->property); swapl(&stuff->type); swapl(&stuff->longOffset); @@ -1262,7 +1248,6 @@ SProcXIListProperties(ClientPtr client) REQUEST(xXIListPropertiesReq); REQUEST_SIZE_MATCH(xXIListPropertiesReq); - swaps(&stuff->length); swaps(&stuff->deviceid); return (ProcXIListProperties(client)); } @@ -1273,7 +1258,6 @@ SProcXIChangeProperty(ClientPtr client) REQUEST(xXIChangePropertyReq); REQUEST_AT_LEAST_SIZE(xXIChangePropertyReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->property); swapl(&stuff->type); @@ -1287,7 +1271,6 @@ SProcXIDeleteProperty(ClientPtr client) REQUEST(xXIDeletePropertyReq); REQUEST_SIZE_MATCH(xXIDeletePropertyReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->property); return (ProcXIDeleteProperty(client)); @@ -1299,7 +1282,6 @@ SProcXIGetProperty(ClientPtr client) REQUEST(xXIGetPropertyReq); REQUEST_SIZE_MATCH(xXIGetPropertyReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->property); swapl(&stuff->type); diff --git a/Xi/xiproperty.h b/Xi/xiproperty.h index 482c834ed..561779f2e 100644 --- a/Xi/xiproperty.h +++ b/Xi/xiproperty.h @@ -36,7 +36,6 @@ int ProcXDeleteDeviceProperty(ClientPtr client); int ProcXGetDeviceProperty(ClientPtr client); /* request swapping */ -int SProcXListDeviceProperties(ClientPtr client); int SProcXChangeDeviceProperty(ClientPtr client); int SProcXDeleteDeviceProperty(ClientPtr client); int SProcXGetDeviceProperty(ClientPtr client); diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index c9a9864bc..2e974e3ab 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -28,15 +28,15 @@ * @file Protocol handling for the XIQueryDevice request/reply. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xatom.h> #include <X11/extensions/XI2proto.h> #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "os/fmt.h" #include "inputstr.h" #include "xkbstr.h" @@ -59,7 +59,6 @@ SProcXIQueryDevice(ClientPtr client) REQUEST(xXIQueryDeviceReq); REQUEST_SIZE_MATCH(xXIQueryDeviceReq); - swaps(&stuff->length); swaps(&stuff->deviceid); return ProcXIQueryDevice(client); @@ -88,7 +87,7 @@ ProcXIQueryDevice(ClientPtr client) len += SizeDeviceInfo(dev); } else { - skip = calloc(sizeof(Bool), inputInfo.numDevices); + skip = calloc(inputInfo.numDevices, sizeof(Bool)); if (!skip) return BadAlloc; @@ -178,7 +177,7 @@ ShouldSkipDevice(ClientPtr client, int deviceid, DeviceIntPtr dev) { /* if all devices are not being queried, only master devices are */ if (deviceid == XIAllDevices || IsMaster(dev)) { - int rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGetAttrAccess); + int rc = XaceHookDeviceAccess(client, dev, DixGetAttrAccess); if (rc == Success) return FALSE; @@ -575,7 +574,7 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev, int rc; /* Check if the current device state should be suppressed */ - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess); + rc = XaceHookDeviceAccess(client, dev, DixReadAccess); if (dev->button) { (*nclasses)++; diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c index 2ac3e73a0..19eb8cad1 100644 --- a/Xi/xiquerypointer.c +++ b/Xi/xiquerypointer.c @@ -29,9 +29,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> /* for inputstr.h */ #include <X11/Xproto.h> /* Request macro */ @@ -41,6 +39,8 @@ #include "dix/dix_priv.h" #include "dix/eventconvert.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "os/fmt.h" #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ @@ -49,9 +49,9 @@ #include "scrnintstr.h" #include "xkbsrv.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ #include "inpututils.h" #include "xiquerypointer.h" @@ -68,7 +68,6 @@ SProcXIQueryPointer(ClientPtr client) REQUEST(xXIQueryPointerReq); REQUEST_SIZE_MATCH(xXIQueryPointerReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->win); return (ProcXIQueryPointer(client)); @@ -185,7 +184,7 @@ ProcXIQueryPointer(ClientPtr client) rep.win_y = 0; } -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { rep.root_x += double_to_fp1616(screenInfo.screens[0]->x); rep.root_y += double_to_fp1616(screenInfo.screens[0]->y); @@ -194,7 +193,7 @@ ProcXIQueryPointer(ClientPtr client) rep.win_y += double_to_fp1616(screenInfo.screens[0]->y); } } -#endif +#endif /* XINERAMA */ WriteReplyToClient(client, sizeof(xXIQueryPointerReply), &rep); if (buttons) diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c index dc3860a21..b2055f010 100644 --- a/Xi/xiqueryversion.c +++ b/Xi/xiqueryversion.c @@ -29,18 +29,16 @@ * Protocol handling for the XIQueryVersion request/reply. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif - -#include "inputstr.h" #include <X11/Xmd.h> #include <X11/X.h> #include <X11/extensions/XI2proto.h> #include "dix/exevents_priv.h" +#include "os/fmt.h" +#include "inputstr.h" #include "exglobals.h" #include "xiqueryversion.h" #include "misc.h" @@ -135,7 +133,6 @@ int _X_COLD SProcXIQueryVersion(ClientPtr client) { REQUEST(xXIQueryVersionReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXIQueryVersionReq); swaps(&stuff->major_version); swaps(&stuff->minor_version); diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c index 6c6aff884..d341a12d5 100644 --- a/Xi/xiselectev.c +++ b/Xi/xiselectev.c @@ -23,9 +23,7 @@ * Author: Peter Hutterer */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI2proto.h> @@ -122,12 +120,11 @@ SProcXISelectEvents(ClientPtr client) xXIEventMask *evmask; REQUEST(xXISelectEventsReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXISelectEventsReq); swapl(&stuff->win); swaps(&stuff->num_masks); - len = stuff->length - bytes_to_int32(sizeof(xXISelectEventsReq)); + len = client->req_len - bytes_to_int32(sizeof(xXISelectEventsReq)); evmask = (xXIEventMask *) &stuff[1]; for (i = 0; i < stuff->num_masks; i++) { if (len < bytes_to_int32(sizeof(xXIEventMask))) @@ -174,7 +171,7 @@ ProcXISelectEvents(ClientPtr client) while (num_masks--) { len += sizeof(xXIEventMask) + evmask->mask_len * 4; - if (bytes_to_int32(len) > stuff->length) + if (bytes_to_int32(len) > client->req_len) return BadLength; if (evmask->deviceid != XIAllDevices && @@ -300,7 +297,7 @@ ProcXISelectEvents(ClientPtr client) evmask++; } - if (bytes_to_int32(len) != stuff->length) + if (bytes_to_int32(len) != client->req_len) return BadLength; /* Set masks on window */ @@ -333,7 +330,6 @@ int _X_COLD SProcXIGetSelectedEvents(ClientPtr client) { REQUEST(xXIGetSelectedEventsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXIGetSelectedEventsReq); swapl(&stuff->win); diff --git a/Xi/xisetclientpointer.c b/Xi/xisetclientpointer.c index a865c164c..b6c3ddfd8 100644 --- a/Xi/xisetclientpointer.c +++ b/Xi/xisetclientpointer.c @@ -30,9 +30,7 @@ * default value. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> /* for inputstr.h */ #include <X11/Xproto.h> /* Request macro */ @@ -55,7 +53,6 @@ SProcXISetClientPointer(ClientPtr client) REQUEST(xXISetClientPointerReq); REQUEST_SIZE_MATCH(xXISetClientPointerReq); - swaps(&stuff->length); swapl(&stuff->win); swaps(&stuff->deviceid); return (ProcXISetClientPointer(client)); diff --git a/Xi/xisetdevfocus.c b/Xi/xisetdevfocus.c index d09aa9d5e..bf2103fdc 100644 --- a/Xi/xisetdevfocus.c +++ b/Xi/xisetdevfocus.c @@ -28,9 +28,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> @@ -48,7 +46,6 @@ SProcXISetFocus(ClientPtr client) REQUEST(xXISetFocusReq); REQUEST_AT_LEAST_SIZE(xXISetFocusReq); - swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->focus); swapl(&stuff->time); @@ -62,7 +59,6 @@ SProcXIGetFocus(ClientPtr client) REQUEST(xXIGetFocusReq); REQUEST_AT_LEAST_SIZE(xXIGetFocusReq); - swaps(&stuff->length); swaps(&stuff->deviceid); return ProcXIGetFocus(client); diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c index 1d8926935..f4e08abdf 100644 --- a/Xi/xiwarppointer.c +++ b/Xi/xiwarppointer.c @@ -29,16 +29,16 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> /* for inputstr.h */ #include <X11/Xproto.h> /* Request macro */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "mi/mipointer_priv.h" #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ @@ -61,7 +61,6 @@ SProcXIWarpPointer(ClientPtr client) REQUEST(xXIWarpPointerReq); REQUEST_SIZE_MATCH(xXIWarpPointerReq); - swaps(&stuff->length); swapl(&stuff->src_win); swapl(&stuff->dst_win); swapl(&stuff->src_x); diff --git a/composite/compalloc.c b/composite/compalloc.c index f97b6c688..d1342799b 100644 --- a/composite/compalloc.c +++ b/composite/compalloc.c @@ -41,9 +41,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "compint.h" @@ -140,6 +138,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update) CompScreenPtr cs = GetCompScreen(pWin->drawable.pScreen); WindowPtr pLayerWin; Bool anyMarked = FALSE; + int status = Success; if (pWin == cs->pOverlayWin) { return Success; @@ -218,13 +217,13 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update) if (!compCheckRedirect(pWin)) { FreeResource(ccw->id, X11_RESTYPE_NONE); - return BadAlloc; + status = BadAlloc; } if (anyMarked) compHandleMarkedWindows(pWin, pLayerWin); - return Success; + return status; } void @@ -247,7 +246,7 @@ compRestoreWindow(WindowPtr pWin, PixmapPtr pPixmap) val.val = IncludeInferiors; ChangeGC(NullClient, pGC, GCSubwindowMode, &val); ValidateGC(&pWin->drawable, pGC); - (*pGC->ops->CopyArea) (&pPixmap->drawable, + (void) (*pGC->ops->CopyArea) (&pPixmap->drawable, &pWin->drawable, pGC, x, y, w, h, 0, 0); FreeScratchGC(pGC); } @@ -552,11 +551,12 @@ compNewPixmap(WindowPtr pWin, int x, int y, int w, int h) val.val = IncludeInferiors; ChangeGC(NullClient, pGC, GCSubwindowMode, &val); ValidateGC(&pPixmap->drawable, pGC); - (*pGC->ops->CopyArea) (&pParent->drawable, - &pPixmap->drawable, - pGC, - x - pParent->drawable.x, - y - pParent->drawable.y, w, h, 0, 0); + (void) (*pGC->ops->CopyArea) (&pParent->drawable, + &pPixmap->drawable, + pGC, + x - pParent->drawable.x, + y - pParent->drawable.y, + w, h, 0, 0); FreeScratchGC(pGC); } } @@ -605,9 +605,12 @@ compAllocPixmap(WindowPtr pWin) int h = pWin->drawable.height + (bw << 1); PixmapPtr pPixmap = compNewPixmap(pWin, x, y, w, h); CompWindowPtr cw = GetCompWindow(pWin); + Bool status; - if (!pPixmap) - return FALSE; + if (!pPixmap) { + status = FALSE; + goto out; + } if (cw->update == CompositeRedirectAutomatic) pWin->redirectDraw = RedirectDrawAutomatic; else @@ -621,14 +624,16 @@ compAllocPixmap(WindowPtr pWin) DamageRegister(&pWin->drawable, cw->damage); cw->damageRegistered = TRUE; } + status = TRUE; +out: /* Make sure our borderClip is up to date */ RegionUninit(&cw->borderClip); RegionCopy(&cw->borderClip, &pWin->borderClip); cw->borderClipX = pWin->drawable.x; cw->borderClipY = pWin->drawable.y; - return TRUE; + return status; } void diff --git a/composite/compext.c b/composite/compext.c index 62bce26e7..bb8f5946d 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -41,9 +41,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "compint.h" #include "xace.h" @@ -252,7 +250,7 @@ ProcCompositeNameWindowPixmap(ClientPtr client) return BadMatch; /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, X11_RESTYPE_PIXMAP, + rc = XaceHookResourceAccess(client, stuff->pixmap, X11_RESTYPE_PIXMAP, pPixmap, X11_RESTYPE_WINDOW, pWin, DixCreateAccess); if (rc != Success) return rc; @@ -306,7 +304,7 @@ ProcCompositeGetOverlayWindow(ClientPtr client) return BadAlloc; } - rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id, + rc = XaceHookResourceAccess(client, cs->pOverlayWin->drawable.id, X11_RESTYPE_WINDOW, cs->pOverlayWin, X11_RESTYPE_NONE, NULL, DixGetAttrAccess); if (rc != Success) { @@ -380,8 +378,6 @@ static int _X_COLD SProcCompositeQueryVersion(ClientPtr client) { REQUEST(xCompositeQueryVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeQueryVersionReq); swapl(&stuff->majorVersion); swapl(&stuff->minorVersion); @@ -392,8 +388,6 @@ static int _X_COLD SProcCompositeRedirectWindow(ClientPtr client) { REQUEST(xCompositeRedirectWindowReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); swapl(&stuff->window); return (*ProcCompositeVector[stuff->compositeReqType]) (client); @@ -403,8 +397,6 @@ static int _X_COLD SProcCompositeRedirectSubwindows(ClientPtr client) { REQUEST(xCompositeRedirectSubwindowsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); swapl(&stuff->window); return (*ProcCompositeVector[stuff->compositeReqType]) (client); @@ -414,8 +406,6 @@ static int _X_COLD SProcCompositeUnredirectWindow(ClientPtr client) { REQUEST(xCompositeUnredirectWindowReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); swapl(&stuff->window); return (*ProcCompositeVector[stuff->compositeReqType]) (client); @@ -425,8 +415,6 @@ static int _X_COLD SProcCompositeUnredirectSubwindows(ClientPtr client) { REQUEST(xCompositeUnredirectSubwindowsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); swapl(&stuff->window); return (*ProcCompositeVector[stuff->compositeReqType]) (client); @@ -436,8 +424,6 @@ static int _X_COLD SProcCompositeCreateRegionFromBorderClip(ClientPtr client) { REQUEST(xCompositeCreateRegionFromBorderClipReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); swapl(&stuff->region); swapl(&stuff->window); @@ -448,8 +434,6 @@ static int _X_COLD SProcCompositeNameWindowPixmap(ClientPtr client) { REQUEST(xCompositeNameWindowPixmapReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); swapl(&stuff->window); swapl(&stuff->pixmap); @@ -460,8 +444,6 @@ static int _X_COLD SProcCompositeGetOverlayWindow(ClientPtr client) { REQUEST(xCompositeGetOverlayWindowReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); swapl(&stuff->window); return (*ProcCompositeVector[stuff->compositeReqType]) (client); @@ -471,8 +453,6 @@ static int _X_COLD SProcCompositeReleaseOverlayWindow(ClientPtr client) { REQUEST(xCompositeReleaseOverlayWindowReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); swapl(&stuff->window); return (*ProcCompositeVector[stuff->compositeReqType]) (client); @@ -589,7 +569,7 @@ CompositeExtensionInit(void) noCompositeExtension = FALSE; } -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiXsrv.h" int (*PanoramiXSaveCompositeVector[CompositeNumberRequests]) (ClientPtr); @@ -828,7 +808,7 @@ PanoramiXCompositeGetOverlayWindow(ClientPtr client) return BadAlloc; } - rc = XaceHook(XACE_RESOURCE_ACCESS, client, + rc = XaceHookResourceAccess(client, cs->pOverlayWin->drawable.id, X11_RESTYPE_WINDOW, cs->pOverlayWin, X11_RESTYPE_NONE, NULL, DixGetAttrAccess); @@ -942,4 +922,4 @@ PanoramiXCompositeReset(void) ProcCompositeVector[i] = PanoramiXSaveCompositeVector[i]; } -#endif +#endif /* XINERAMA */ diff --git a/composite/compinit.c b/composite/compinit.c index 7e324afdc..88e69d37e 100644 --- a/composite/compinit.c +++ b/composite/compinit.c @@ -41,9 +41,10 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "dix/dix_priv.h" +#include "os/osdep.h" #include "compint.h" #include "compositeext.h" diff --git a/composite/compoverlay.c b/composite/compoverlay.c index 18538ed98..ffff34b7b 100644 --- a/composite/compoverlay.c +++ b/composite/compoverlay.c @@ -41,16 +41,14 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "compint.h" #include "xace.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ /* * Delete the given overlay client list element from its screen list. @@ -135,14 +133,14 @@ compCreateOverlayWindow(ScreenPtr pScreen) int h = pScreen->height; int x = 0, y = 0; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { x = -pScreen->x; y = -pScreen->y; w = PanoramiXPixWidth; h = PanoramiXPixHeight; } -#endif +#endif /* XINERAMA */ pWin = cs->pOverlayWin = CreateWindow(cs->overlayWid, pRoot, x, y, w, h, 0, diff --git a/composite/compwindow.c b/composite/compwindow.c index 3d62358b9..1970860c3 100644 --- a/composite/compwindow.c +++ b/composite/compwindow.c @@ -41,9 +41,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" #include "os/osdep.h" @@ -51,9 +49,9 @@ #include "compint.h" #include "compositeext_priv.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ #ifdef COMPOSITE_DEBUG static int @@ -203,12 +201,12 @@ updateOverlayWindow(ScreenPtr pScreen) int w = pScreen->width; int h = pScreen->height; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { w = PanoramiXPixWidth; h = PanoramiXPixHeight; } -#endif +#endif /* XINERAMA */ cs = GetCompScreen(pScreen); if ((pWin = cs->pOverlayWin) != NULL) { diff --git a/config/config.c b/config/config.c index fb60295ae..d75f1f453 100644 --- a/config/config.c +++ b/config/config.c @@ -23,14 +23,14 @@ * Author: Daniel Stone <daniel@fooishbar.org> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <unistd.h> + +#include "config/hotplug_priv.h" + #include "os.h" #include "inputstr.h" -#include "hotplug.h" #include "config-backends.h" #include "systemd-logind.h" @@ -133,7 +133,7 @@ struct OdevAttributes * config_odev_allocate_attributes(void) { struct OdevAttributes *attribs = - xnfcalloc(1, sizeof (struct OdevAttributes)); + XNFcallocarray(1, sizeof (struct OdevAttributes)); attribs->fd = -1; return attribs; } diff --git a/config/dbus-core.c b/config/dbus-core.c index 180ca9364..30495f07b 100644 --- a/config/dbus-core.c +++ b/config/dbus-core.c @@ -23,9 +23,7 @@ * Author: Daniel Stone <daniel@fooishbar.org> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <dbus/dbus.h> #include <sys/select.h> diff --git a/config/hal.c b/config/hal.c index 7e0e88498..e9fda38e8 100644 --- a/config/hal.c +++ b/config/hal.c @@ -24,20 +24,19 @@ * Author: Daniel Stone <daniel@fooishbar.org> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include <dbus/dbus.h> -#include <hal/libhal.h> #include <string.h> #include <sys/select.h> +#include <dbus/dbus.h> +#include <hal/libhal.h> + +#include "config/hotplug_priv.h" #include "config/dbus-core.h" #include "input.h" #include "inputstr.h" -#include "hotplug.h" #include "config-backends.h" #include "os.h" @@ -102,7 +101,7 @@ get_prop_string_array(LibHalContext * hal_ctx, const char *udi, for (i = 0; props[i]; i++) len += strlen(props[i]); - ret = calloc(sizeof(char), len + i); /* i - 1 commas, 1 NULL */ + ret = calloc(len + i, sizeof(char)); /* i - 1 commas, 1 NULL */ if (!ret) { libhal_free_string_array(props); return NULL; diff --git a/config/hotplug_priv.h b/config/hotplug_priv.h new file mode 100644 index 000000000..6377c2f60 --- /dev/null +++ b/config/hotplug_priv.h @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +/* + * Copyright © 2006-2007 Daniel Stone + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Daniel Stone <daniel@fooishbar.org> + */ +#ifndef _XSERVER_HOTPLUG_PRIV_H +#define _XSERVER_HOTPLUG_PRIV_H + +#include <X11/Xfuncproto.h> + +#include "hotplug.h" +#include "list.h" + +/* Bump this each time you add something to the struct + * so that drivers can easily tell what is available + */ +#define ODEV_ATTRIBUTES_VERSION 1 + +struct OdevAttributes { + /* path to kernel device node - Linux e.g. /dev/dri/card0 */ + char *path; + + /* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ + char *syspath; + + /* DRI-style bus id */ + char *busid; + + /* Server managed FD */ + int fd; + + /* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ + int major; + + /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ + int minor; + + /* kernel driver name */ + char *driver; +}; + +/* Note starting with xserver 1.16 this function never fails */ +struct OdevAttributes * +config_odev_allocate_attributes(void); + +void +config_odev_free_attributes(struct OdevAttributes *attribs); + +typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs); +void config_odev_probe(config_odev_probe_proc_ptr probe_callback); + +#ifdef CONFIG_UDEV_KMS +void NewGPUDeviceRequest(struct OdevAttributes *attribs); +void DeleteGPUDeviceRequest(struct OdevAttributes *attribs); +#endif + +#define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0")) + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor); + +void config_pre_init(void); + +#endif /* _XSERVER_HOTPLUG_PRIV_H */ diff --git a/config/udev.c b/config/udev.c index 836fc2afa..be317ee99 100644 --- a/config/udev.c +++ b/config/udev.c @@ -23,17 +23,16 @@ * Author: Julien Cristau <jcristau@debian.org> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <libudev.h> #include <ctype.h> #include <unistd.h> +#include "config/hotplug_priv.h" + #include "input.h" #include "inputstr.h" -#include "hotplug.h" #include "config-backends.h" #include "os.h" #include "globals.h" @@ -552,6 +551,9 @@ config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path attribs->busid = XNFstrdup(value); attribs->busid[3] = ':'; + } else if (value && (str = strrstr(value, "platform-"))) { + value = str + 9; + attribs->busid = XNFstrdup(value); } if (!value) diff --git a/config/wscons.c b/config/wscons.c index a7beb85a4..eb44e1b25 100644 --- a/config/wscons.c +++ b/config/wscons.c @@ -21,9 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/time.h> #include <dev/wscons/wsconsio.h> diff --git a/damageext/damageext.c b/damageext/damageext.c index 6a46291fd..c9b14b2ee 100644 --- a/damageext/damageext.c +++ b/damageext/damageext.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" @@ -33,7 +31,7 @@ #include "extinit_priv.h" #include "dixstruct_priv.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" @@ -45,7 +43,7 @@ typedef struct { static RESTYPE XRT_DAMAGE; static int (*PanoramiXSaveDamageCreate) (ClientPtr); -#endif +#endif /* XINERAMA */ static unsigned char DamageReqCode; static int DamageEventBase; @@ -70,7 +68,7 @@ DamageNoteCritical(ClientPtr pClient) static void damageGetGeometry(DrawablePtr draw, int *x, int *y, int *w, int *h) { -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && draw->type == DRAWABLE_WINDOW) { WindowPtr win = (WindowPtr)draw; @@ -82,7 +80,7 @@ damageGetGeometry(DrawablePtr draw, int *x, int *y, int *w, int *h) return; } } -#endif +#endif /* XINERAMA */ *x = draw->x; *y = draw->y; @@ -321,7 +319,7 @@ ProcDamageDestroy(ClientPtr client) return Success; } -#ifdef PANORAMIX +#ifdef XINERAMA static RegionPtr DamageExtSubtractWindowClip(DamageExtPtr pDamageExt) { @@ -369,7 +367,7 @@ DamageExtFreeWindowClip(RegionPtr reg) if (reg != &PanoramiXScreenRegion) RegionDestroy(reg); } -#endif +#endif /* XINERAMA */ /* * DamageSubtract intersects with borderClip, so we must reconstruct the @@ -380,7 +378,7 @@ DamageExtSubtract(DamageExtPtr pDamageExt, const RegionPtr pRegion) { DamagePtr pDamage = pDamageExt->pDamage; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { RegionPtr damage = DamageRegion(pDamage); RegionSubtract(damage, damage, pRegion); @@ -398,7 +396,7 @@ DamageExtSubtract(DamageExtPtr pDamageExt, const RegionPtr pRegion) return RegionNotEmpty(damage); } -#endif +#endif /* XINERAMA */ return DamageSubtract(pDamage, pRegion); } @@ -494,8 +492,6 @@ static int _X_COLD SProcDamageQueryVersion(ClientPtr client) { REQUEST(xDamageQueryVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageQueryVersionReq); swapl(&stuff->majorVersion); swapl(&stuff->minorVersion); @@ -506,8 +502,6 @@ static int _X_COLD SProcDamageCreate(ClientPtr client) { REQUEST(xDamageCreateReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageCreateReq); swapl(&stuff->damage); swapl(&stuff->drawable); @@ -518,8 +512,6 @@ static int _X_COLD SProcDamageDestroy(ClientPtr client) { REQUEST(xDamageDestroyReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageDestroyReq); swapl(&stuff->damage); return (*ProcDamageVector[stuff->damageReqType]) (client); @@ -529,8 +521,6 @@ static int _X_COLD SProcDamageSubtract(ClientPtr client) { REQUEST(xDamageSubtractReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageSubtractReq); swapl(&stuff->damage); swapl(&stuff->repair); @@ -542,8 +532,6 @@ static int _X_COLD SProcDamageAdd(ClientPtr client) { REQUEST(xDamageAddReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDamageSubtractReq); swapl(&stuff->drawable); swapl(&stuff->region); @@ -606,7 +594,7 @@ SDamageNotifyEvent(xDamageNotifyEvent * from, xDamageNotifyEvent * to) cpswaps(from->geometry.height, to->geometry.height); } -#ifdef PANORAMIX +#ifdef XINERAMA static void PanoramiXDamageReport(DamagePtr pDamage, RegionPtr pRegion, void *closure) @@ -725,7 +713,7 @@ PanoramiXDamageReset(void) ProcDamageVector[X_DamageCreate] = PanoramiXSaveDamageCreate; } -#endif /* PANORAMIX */ +#endif /* XINERAMA */ void DamageExtensionInit(void) @@ -754,10 +742,10 @@ DamageExtensionInit(void) (EventSwapPtr) SDamageNotifyEvent; SetResourceTypeErrorValue(DamageExtType, extEntry->errorBase + BadDamage); -#ifdef PANORAMIX +#ifdef XINERAMA if (XRT_DAMAGE) SetResourceTypeErrorValue(XRT_DAMAGE, extEntry->errorBase + BadDamage); -#endif +#endif /* XINERAMA */ } } diff --git a/damageext/damageext.h b/damageext/damageext.h deleted file mode 100644 index bd9963509..000000000 --- a/damageext/damageext.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2002 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _DAMAGEEXT_H_ -#define _DAMAGEEXT_H_ - -void - DamageExtensionInit(void); - -#endif /* _DAMAGEEXT_H_ */ @@ -32,9 +32,7 @@ /* INCLUDES */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include <stdint.h> @@ -614,7 +612,7 @@ ProcDbeGetVisualInfo(ClientPtr client) pDrawables[i]->pScreen; pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen); - rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess); + rc = XaceHookScreenAccess(client, pScreen, DixGetAttrAccess); if (rc != Success) goto freeScrVisInfo; @@ -799,33 +797,7 @@ ProcDbeDispatch(ClientPtr client) } } /* ProcDbeDispatch() */ - -/****************************************************************************** - * - * DBE DIX Procedure: SProcDbeGetVersion - * - * Description: - * - * This function is for processing a DbeGetVersion request on a swapped - * server. This request returns the major and minor version numbers of - * this extension. - * - * Return Values: - * - * Success - * - *****************************************************************************/ - -static int _X_COLD -SProcDbeGetVersion(ClientPtr client) -{ - REQUEST(xDbeGetVersionReq); - - swaps(&stuff->length); - return (ProcDbeGetVersion(client)); -} /* SProcDbeGetVersion() */ - /****************************************************************************** * * DBE DIX Procedure: SProcDbeAllocateBackBufferName @@ -853,8 +825,6 @@ static int _X_COLD SProcDbeAllocateBackBufferName(ClientPtr client) { REQUEST(xDbeAllocateBackBufferNameReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq); swapl(&stuff->window); @@ -886,8 +856,6 @@ static int _X_COLD SProcDbeDeallocateBackBufferName(ClientPtr client) { REQUEST(xDbeDeallocateBackBufferNameReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq); swapl(&stuff->buffer); @@ -924,7 +892,6 @@ SProcDbeSwapBuffers(ClientPtr client) unsigned int i; xDbeSwapInfo *pSwapInfo; - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq); swapl(&stuff->n); @@ -939,7 +906,7 @@ SProcDbeSwapBuffers(ClientPtr client) * followed by a 1 byte swap action and then 3 pad bytes. We only need * to swap the window information. */ - for (i = 0; i < stuff->n; i++) { + for (i = 0; i < stuff->n; i++, pSwapInfo++) { swapl(&pSwapInfo->window); } } @@ -969,8 +936,6 @@ static int _X_COLD SProcDbeGetVisualInfo(ClientPtr client) { REQUEST(xDbeGetVisualInfoReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq); swapl(&stuff->n); @@ -1000,8 +965,6 @@ static int _X_COLD SProcDbeGetBackBufferAttributes(ClientPtr client) { REQUEST(xDbeGetBackBufferAttributesReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq); swapl(&stuff->buffer); @@ -1027,7 +990,7 @@ SProcDbeDispatch(ClientPtr client) switch (stuff->data) { case X_DbeGetVersion: - return (SProcDbeGetVersion(client)); + return ProcDbeGetVersion(client); case X_DbeAllocateBackBufferName: return (SProcDbeAllocateBackBufferName(client)); @@ -1369,10 +1332,10 @@ DbeExtensionInit(void) int nStubbedScreens = 0; Bool ddxInitSuccess; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return; -#endif +#endif /* XINERAMA */ /* Create the resource types. */ dbeDrawableResType = diff --git a/dbe/midbe.c b/dbe/midbe.c index eb6057748..379b7a024 100644 --- a/dbe/midbe.c +++ b/dbe/midbe.c @@ -32,9 +32,7 @@ /* INCLUDES */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -169,9 +167,9 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) } /* Security creation/labeling check. */ - rc = XaceHook(XACE_RESOURCE_ACCESS, serverClient, bufId, - dbeDrawableResType, pDbeWindowPriv->pBackBuffer, - X11_RESTYPE_WINDOW, pWin, DixCreateAccess); + rc = XaceHookResourceAccess(serverClient, bufId, dbeDrawableResType, + pDbeWindowPriv->pBackBuffer, X11_RESTYPE_WINDOW, + pWin, DixCreateAccess); /* Make the back pixmap a DBE drawable resource. */ if (rc != Success || !AddResource(bufId, dbeDrawableResType, @@ -275,10 +273,10 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) case XdbeUntouched: ValidateGC((DrawablePtr) pDbeWindowPriv->pFrontBuffer, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr) pWin, - (DrawablePtr) pDbeWindowPriv->pFrontBuffer, - pGC, 0, 0, pWin->drawable.width, - pWin->drawable.height, 0, 0); + (void) (*pGC->ops->CopyArea) ((DrawablePtr) pWin, + (DrawablePtr) pDbeWindowPriv->pFrontBuffer, + pGC, 0, 0, pWin->drawable.width, + pWin->drawable.height, 0, 0); break; case XdbeCopied: @@ -293,9 +291,10 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) */ ValidateGC((DrawablePtr) pWin, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer, - (DrawablePtr) pWin, pGC, 0, 0, - pWin->drawable.width, pWin->drawable.height, 0, 0); + (void) (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer, + (DrawablePtr) pWin, pGC, 0, 0, + pWin->drawable.width, + pWin->drawable.height, 0, 0); /* ********************************************************************** @@ -620,10 +619,10 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) } /* Copy the contents of the old front pixmap to the new one. */ if (pWin->bitGravity != ForgetGravity) { - (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pFrontBuffer, - (DrawablePtr) pFrontBuffer, pGC, - sourcex, sourcey, savewidth, saveheight, - destx, desty); + (void) (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pFrontBuffer, + (DrawablePtr) pFrontBuffer, pGC, + sourcex, sourcey, savewidth, saveheight, + destx, desty); } ValidateGC(&pBackBuffer->drawable, pGC); @@ -633,10 +632,10 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) } /* Copy the contents of the old back pixmap to the new one. */ if (pWin->bitGravity != ForgetGravity) { - (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer, - (DrawablePtr) pBackBuffer, pGC, - sourcex, sourcey, savewidth, saveheight, - destx, desty); + (void) (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer, + (DrawablePtr) pBackBuffer, pGC, + sourcex, sourcey, savewidth, saveheight, + destx, desty); } /* Destroy the old pixmaps, and point the DBE window priv to the new diff --git a/dix/atom.c b/dix/atom.c index da0adfe78..194b2baec 100644 --- a/dix/atom.c +++ b/dix/atom.c @@ -44,14 +44,15 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include <X11/X.h> -#include <X11/Xatom.h> #include <stdio.h> #include <string.h> +#include <X11/X.h> +#include <X11/Xatom.h> + +#include "dix/dix_priv.h" + #include "misc.h" #include "resource.h" #include "dix.h" diff --git a/dix/buildatoms b/dix/buildatoms deleted file mode 100644 index dfbbca8a9..000000000 --- a/dix/buildatoms +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -hfile=../../../include/Xatom.h -cfile=initatoms.c -rm -f $hfile $cfile -umask 222 -awk ' -BEGIN { - hfile = "'$hfile'"; - cfile = "'$cfile'"; - hformat = "#define XA_%s ((Atom) %d)\n"; - printf("#ifndef XATOM_H\n") > hfile; - printf("#define XATOM_H 1\n\n") > hfile; - printf("/* THIS IS A GENERATED FILE\n") > hfile; - printf(" *\n") > hfile; - printf(" * Do not change! Changing this file implies a protocol change!\n") > hfile; - printf(" */\n\n") > hfile; - - printf("/* THIS IS A GENERATED FILE\n") > cfile; - printf(" *\n") > cfile; - printf(" * Do not change! Changing this file implies a protocol change!\n") > cfile; - printf(" */\n\n") > cfile; - printf("#include \"X.h\"\n") > cfile; - printf("#include \"Xatom.h\"\n") > cfile; - printf("#include \"misc.h\"\n") > cfile; - printf("#include \"dix.h\"\n") > cfile; - printf("void MakePredeclaredAtoms()\n") > cfile; - printf("{\n") > cfile; - - } - -NF == 2 && $2 == "@" { - printf(hformat, $1, ++atomno) > hfile ; - printf(" if (MakeAtom(\"%s\", %d, 1) != XA_%s) AtomError();\n", $1, length($1), $1) > cfile ; - } - -END { - printf("\n") > hfile; - printf(hformat, "LAST_PREDEFINED", atomno) > hfile ; - printf("#endif /* XATOM_H */\n") > hfile; - printf("}\n") > cfile ; - } -' BuiltInAtoms -exit 0 diff --git a/dix/callback_priv.h b/dix/callback_priv.h index d0240bfd7..828b74cf2 100644 --- a/dix/callback_priv.h +++ b/dix/callback_priv.h @@ -7,8 +7,6 @@ #include "callback.h" -typedef struct _CallbackList *CallbackListPtr; - void InitCallbackManager(void); void DeleteCallbackManager(void); diff --git a/dix/color.c b/dix/color.c index 8252e2e88..ead707383 100644 --- a/dix/color.c +++ b/dix/color.c @@ -44,9 +44,7 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/keysym.h> diff --git a/dix/colormap.c b/dix/colormap.c index ec787349f..9a8be28e2 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -44,9 +44,7 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -55,6 +53,7 @@ SOFTWARE. #include <strings.h> #include "dix/colormap_priv.h" +#include "os/osdep.h" #include "misc.h" #include "dix.h" @@ -67,6 +66,14 @@ SOFTWARE. #include "privates.h" #include "xace.h" +#define REDMAP 0 +#define GREENMAP 1 +#define BLUEMAP 2 +#define PSEUDOMAP 3 + +#define AllocPrivate (-1) +#define AllocTemporary (-2) + typedef int (*ColorCompareProcPtr) (EntryPtr /*pent */ , xrgb * /*prgb */ ); @@ -107,8 +114,7 @@ static void FreeCell(ColormapPtr /*pmap */ , int /*channel */ ); -static void UpdateColors(ColormapPtr /*pmap */ - ); +static void doUpdateColors(ColormapPtr pmap); static int AllocDirect(int /*client */ , ColormapPtr /*pmap */ , @@ -284,7 +290,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->mid = mid; pmap->flags = 0; /* start out with all flags clear */ if (mid == pScreen->defColormap) - pmap->flags |= IsDefault; + pmap->flags |= CM_IsDefault; pmap->pScreen = pScreen; pmap->pVisual = pVisual; pmap->class = class; @@ -298,7 +304,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, *pptr = (Pixel *) NULL; if (alloc == AllocAll) { if (class & DynamicClass) - pmap->flags |= AllAllocated; + pmap->flags |= CM_AllAllocated; for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--) pent->refcnt = AllocPrivate; pmap->freeRed = 0; @@ -371,7 +377,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->numPixelsBlue[client] = size; } } - pmap->flags |= BeingCreated; + pmap->flags |= CM_BeingCreated; if (!AddResource(mid, X11_RESTYPE_COLORMAP, (void *) pmap)) return BadAlloc; @@ -379,7 +385,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, /* * Security creation/labeling check */ - i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, X11_RESTYPE_COLORMAP, + i = XaceHookResourceAccess(clients[client], mid, X11_RESTYPE_COLORMAP, pmap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (i != Success) { FreeResource(mid, X11_RESTYPE_NONE); @@ -393,7 +399,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, FreeResource(mid, X11_RESTYPE_NONE); return BadAlloc; } - pmap->flags &= ~BeingCreated; + pmap->flags &= ~CM_BeingCreated; *ppcmap = pmap; return Success; } @@ -443,7 +449,7 @@ FreeColormap(void *value, XID mid) } } - if (pmap->flags & IsDefault) { + if (pmap->flags & CM_IsDefault) { dixFreePrivates(pmap->devPrivates, PRIVATE_COLORMAP); free(pmap); } @@ -465,9 +471,9 @@ TellNoMap(WindowPtr pwin, Colormap * pmid) .u.colormap.state = ColormapUninstalled }; xE.u.u.type = ColormapNotify; -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension || !pwin->drawable.pScreen->myNum) -#endif +#endif /* XINERAMA */ DeliverEvents(pwin, &xE, 1, (WindowPtr) NULL); if (pwin->optional) { pwin->optional->colormap = None; @@ -484,10 +490,10 @@ TellLostMap(WindowPtr pwin, void *value) { Colormap *pmid = (Colormap *) value; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && pwin->drawable.pScreen->myNum) return WT_STOPWALKING; -#endif +#endif /* XINERAMA */ if (wColormap(pwin) == *pmid) { /* This should be call to DeliverEvent */ xEvent xE = { @@ -509,10 +515,10 @@ TellGainedMap(WindowPtr pwin, void *value) { Colormap *pmid = (Colormap *) value; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && pwin->drawable.pScreen->myNum) return WT_STOPWALKING; -#endif +#endif /* XINERAMA */ if (wColormap(pwin) == *pmid) { /* This should be call to DeliverEvent */ xEvent xE = { @@ -540,7 +546,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client) pScreen = pSrc->pScreen; pVisual = pSrc->pVisual; midSrc = pSrc->mid; - alloc = ((pSrc->flags & AllAllocated) && CLIENT_ID(midSrc) == client) ? + alloc = ((pSrc->flags & CM_AllAllocated) && CLIENT_ID(midSrc) == client) ? AllocAll : AllocNone; size = pVisual->ColormapEntries; @@ -556,9 +562,9 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client) memmove((char *) pmap->blue, (char *) pSrc->blue, size * sizeof(Entry)); } - pSrc->flags &= ~AllAllocated; + pSrc->flags &= ~CM_AllAllocated; FreePixels(pSrc, client); - UpdateColors(pmap); + doUpdateColors(pmap); return Success; } @@ -568,7 +574,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client) CopyFree(BLUEMAP, client, pSrc, pmap); } if (pmap->class & DynamicClass) - UpdateColors(pmap); + doUpdateColors(pmap); /* XXX should worry about removing any X11_RESTYPE_CMAPENTRY resource */ return Success; } @@ -698,7 +704,7 @@ FreeCell(ColormapPtr pmap, Pixel i, int channel) } static void -UpdateColors(ColormapPtr pmap) +doUpdateColors(ColormapPtr pmap) { xColorItem *defs; xColorItem *pdef; @@ -802,7 +808,7 @@ FindColor(ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb * prgb, /* If we're initializing the colormap, then we are looking for * the first free cell we can find, not to minimize the number * of entries we use. So don't look any further. */ - if (pmap->flags & BeingCreated) + if (pmap->flags & CM_BeingCreated) break; } pixel++; @@ -875,7 +881,7 @@ FindColor(ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb * prgb, *pPixel = def.pixel; gotit: - if (pmap->flags & BeingCreated || client == -1) + if (pmap->flags & CM_BeingCreated || client == -1) return Success; /* Now remember the pixel, for freeing later */ switch (channel) { @@ -949,7 +955,7 @@ AllocColor(ColormapPtr pmap, * the colormap, even if it's a static type. Otherwise, we'd never be * able to initialize static colormaps */ - if (pmap->flags & BeingCreated) + if (pmap->flags & CM_BeingCreated) class |= DynamicClass; /* If this is one of the static storage classes, and we're not initializing @@ -1080,7 +1086,7 @@ AllocColor(ColormapPtr pmap, * resource manager that the client has pixels in this colormap which * should be freed when the client dies */ if ((pmap->numPixelsRed[client] == 1) && - (CLIENT_ID(pmap->mid) != client) && !(pmap->flags & BeingCreated)) { + (CLIENT_ID(pmap->mid) != client) && !(pmap->flags & CM_BeingCreated)) { colorResource *pcr; pcr = malloc(sizeof(colorResource)); @@ -1253,6 +1259,7 @@ FindBestPixel(EntryPtr pentFirst, int size, xrgb * prgb, int channel) case PSEUDOMAP: dg = (long) pent->co.local.green - prgb->green; db = (long) pent->co.local.blue - prgb->blue; + /* fallthrough */ case REDMAP: dr = (long) pent->co.local.red - prgb->red; break; @@ -2070,7 +2077,7 @@ FreeColors(ColormapPtr pmap, int client, int count, Pixel * pixels, Pixel mask) Pixel rmask; class = pmap->class; - if (pmap->flags & AllAllocated) + if (pmap->flags & CM_AllAllocated) return BadAccess; if ((class | DynamicClass) == DirectColor) { rmask = mask & RGBMASK(pmap->pVisual); @@ -2252,7 +2259,7 @@ StoreColors(ColormapPtr pmap, int count, xColorItem * defs, ClientPtr client) int ok; class = pmap->class; - if (!(class & DynamicClass) && !(pmap->flags & BeingCreated)) { + if (!(class & DynamicClass) && !(pmap->flags & CM_BeingCreated)) { return BadAccess; } pVisual = pmap->pVisual; diff --git a/dix/colormap_priv.h b/dix/colormap_priv.h index dbdffb8d0..266e44793 100644 --- a/dix/colormap_priv.h +++ b/dix/colormap_priv.h @@ -5,6 +5,55 @@ #ifndef _XSERVER_DIX_COLORMAP_PRIV_H #define _XSERVER_DIX_COLORMAP_PRIV_H +#include <X11/Xdefs.h> +#include <X11/Xproto.h> + +#include "dix/screenint_priv.h" +#include "include/colormap.h" +#include "include/dix.h" +#include "include/window.h" + +/* Values for the flags field of a colormap. These should have 1 bit set + * and not overlap */ +#define CM_IsDefault 1 +#define CM_AllAllocated 2 +#define CM_BeingCreated 4 + typedef struct _CMEntry *EntryPtr; +int CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, + ColormapPtr *ppcmap, int alloc, int client); + +/* should only be called via resource type's destructor */ +int FreeColormap(void *pmap, XID mid); + +int TellLostMap(WindowPtr pwin, void *value); + +int TellGainedMap(WindowPtr pwin, void *value); + +int CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client); + +void FakeAllocColor(ColormapPtr pmap, xColorItem *item); + +void FakeFreeColor(ColormapPtr pmap, Pixel pixel); + +int QueryColors(ColormapPtr pmap, int count, Pixel *ppixIn, + xrgb *prgbList, ClientPtr client); + +/* should only be called via resource type's destructor */ +int FreeClientPixels(void *pcr, XID fakeid); + +int AllocColorCells(int client, ColormapPtr pmap, int colors, int planes, + Bool contig, Pixel *ppix, Pixel *masks); + +int AllocColorPlanes(int client, ColormapPtr pmap, int colors, int r, int g, + int b, Bool contig, Pixel *pixels, Pixel *prmask, + Pixel *pgmask, Pixel *pbmask); + +int FreeColors(ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask); + +int StoreColors(ColormapPtr pmap, int count, xColorItem * defs, ClientPtr client); + +int IsMapInstalled(Colormap map, WindowPtr pWin); + #endif /* _XSERVER_DIX_COLORMAP_PRIV_H */ diff --git a/dix/cursor.c b/dix/cursor.c index 14b855196..e3774f7be 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -44,13 +44,12 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" #include "servermd.h" @@ -145,7 +144,7 @@ UnrefCursor(CursorPtr cursor) } int -CursorRefCount(const CursorPtr cursor) +CursorRefCount(ConstCursorPtr cursor) { return cursor ? cursor->refcnt : 0; } @@ -279,7 +278,7 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, pCurs->id = cid; /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, X11_RESTYPE_CURSOR, + rc = XaceHookResourceAccess(client, cid, X11_RESTYPE_CURSOR, pCurs, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) goto error; @@ -459,7 +458,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, pCurs->id = cid; /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, X11_RESTYPE_CURSOR, + rc = XaceHookResourceAccess(client, cid, X11_RESTYPE_CURSOR, pCurs, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) goto error; @@ -489,7 +488,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, *************************************************************/ CursorPtr -CreateRootCursor(char *unused1, unsigned int unused2) +CreateRootCursor(void) { CursorPtr curs; FontPtr cursorfont; diff --git a/dix/cursor_priv.h b/dix/cursor_priv.h new file mode 100644 index 000000000..58048aea9 --- /dev/null +++ b/dix/cursor_priv.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_DIX_CURSOR_PRIV_H +#define _XSERVER_DIX_CURSOR_PRIV_H + +#include <X11/fonts/font.h> +#include <X11/X.h> +#include <X11/Xdefs.h> +#include <X11/Xmd.h> + +#include "dix/screenint_priv.h" +#include "include/cursor.h" +#include "include/dix.h" +#include "include/input.h" +#include "include/window.h" + +extern CursorPtr rootCursor; + +/* reference counting */ +CursorPtr RefCursor(CursorPtr cursor); +CursorPtr UnrefCursor(CursorPtr cursor); +int CursorRefCount(ConstCursorPtr cursor); + +int AllocARGBCursor(unsigned char *psrcbits, + unsigned char *pmaskbits, + CARD32 *argb, + CursorMetricPtr cm, + unsigned foreRed, + unsigned foreGreen, + unsigned foreBlue, + unsigned backRed, + unsigned backGreen, + unsigned backBlue, + CursorPtr *ppCurs, + ClientPtr client, + XID cid); + +int AllocGlyphCursor(Font source, + unsigned int sourceChar, + Font mask, + unsigned int maskChar, + unsigned foreRed, + unsigned foreGreen, + unsigned foreBlue, + unsigned backRed, + unsigned backGreen, + unsigned backBlue, + CursorPtr *ppCurs, + ClientPtr client, + XID cid); + +CursorPtr CreateRootCursor(void); + +int ServerBitsFromGlyph(FontPtr pfont, + unsigned int ch, + CursorMetricPtr cm, + unsigned char **ppbits); + +Bool CursorMetricsFromGlyph(FontPtr pfont, + unsigned ch, + CursorMetricPtr cm); + +void CheckCursorConfinement(WindowPtr pWin); + +void NewCurrentScreen(DeviceIntPtr pDev, + ScreenPtr newScreen, + int x, + int y); + +Bool PointerConfinedToScreen(DeviceIntPtr pDev); + +void GetSpritePosition(DeviceIntPtr pDev, int *px, int *py); + +#endif /* _XSERVER_DIX_CURSOR_PRIV_H */ diff --git a/dix/devices.c b/dix/devices.c index 73402e091..740390207 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -44,9 +44,7 @@ SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <math.h> #include <pixman.h> @@ -58,8 +56,12 @@ SOFTWARE. #include <X11/extensions/XIproto.h> #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" #include "dix/ptrveloc_priv.h" +#include "mi/mi_priv.h" +#include "os/osdep.h" #include "xkb/xkbsrv_priv.h" #include "misc.h" @@ -72,13 +74,11 @@ SOFTWARE. #include "ptrveloc.h" #include "privates.h" #include "xace.h" -#include "mi.h" #include "dispatch.h" #include "swaprep.h" #include "dixevents.h" #include "mipointer.h" #include "eventstr.h" -#include "dixgrabs.h" #include "exglobals.h" #include "xiquerydevice.h" /* for SizeDeviceClasses */ #include "xiproperty.h" @@ -296,7 +296,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) /* security creation/labeling check */ - if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixCreateAccess)) { + if (XaceHookDeviceAccess(client, dev, DixCreateAccess)) { dixFreePrivates(dev->devPrivates, PRIVATE_DEVICE); free(dev); return NULL; @@ -980,6 +980,23 @@ FreeAllDeviceClasses(ClassesPtr classes) } +static void +FreePendingFrozenDeviceEvents(DeviceIntPtr dev) +{ + QdEventPtr qe, tmp; + + if (!dev->deviceGrab.sync.frozen) + return; + + /* Dequeue any frozen pending events */ + xorg_list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next) { + if (qe->device == dev) { + xorg_list_del(&qe->next); + free(qe); + } + } +} + /** * Close down a device and free all resources. * Once closed down, the driver will probably not expect you that you'll ever @@ -1035,8 +1052,7 @@ CloseDevice(DeviceIntPtr dev) } } - if (dev->deviceGrab.grab) - FreeGrab(dev->deviceGrab.grab); + FreeGrab(dev->deviceGrab.grab); free(dev->deviceGrab.sync.event); free(dev->config_info); /* Allocated in xf86ActivateDevice. */ free(dev->last.scroll); @@ -1044,6 +1060,7 @@ CloseDevice(DeviceIntPtr dev) valuator_mask_free(&dev->last.touches[j].valuators); free(dev->last.touches); dev->config_info = NULL; + FreePendingFrozenDeviceEvents(dev); dixFreePrivates(dev->devPrivates, PRIVATE_DEVICE); free(dev); } @@ -1264,7 +1281,7 @@ dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode) return BadDevice; found: - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); + rc = XaceHookDeviceAccess(client, dev, access_mode); if (rc == Success) *pDev = dev; return rc; @@ -1844,7 +1861,7 @@ ProcChangeKeyboardMapping(ClientPtr client) keysyms.mapWidth = stuff->keySymsPerKeyCode; keysyms.map = (KeySym *) &stuff[1]; - rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + rc = XaceHookDeviceAccess(client, pDev, DixManageAccess); if (rc != Success) return rc; @@ -1857,7 +1874,7 @@ ProcChangeKeyboardMapping(ClientPtr client) if (!tmp->key) continue; - rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + rc = XaceHookDeviceAccess(client, pDev, DixManageAccess); if (rc != Success) continue; @@ -1938,7 +1955,7 @@ ProcGetKeyboardMapping(ClientPtr client) REQUEST(xGetKeyboardMappingReq); REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); - rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); + rc = XaceHookDeviceAccess(client, kbd, DixGetAttrAccess); if (rc != Success) return rc; @@ -1991,7 +2008,7 @@ ProcGetPointerMapping(ClientPtr client) REQUEST_SIZE_MATCH(xReq); - rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); + rc = XaceHookDeviceAccess(client, ptr, DixGetAttrAccess); if (rc != Success) return rc; @@ -2019,16 +2036,6 @@ NoteLedState(DeviceIntPtr keybd, int led, Bool on) ctrl->leds &= ~((Leds) 1 << (led - 1)); } -int -Ones(unsigned long mask) -{ /* HACKMEM 169 */ - unsigned long y; - - y = (mask >> 1) & 033333333333; - y = mask - y - ((y >> 1) & 033333333333); - return (((y + (y >> 3)) & 030707070707) % 077); -} - static int DoChangeKeyboardControl(ClientPtr client, DeviceIntPtr keybd, XID *vlist, BITS32 vmask) @@ -2217,7 +2224,7 @@ ProcChangeKeyboardControl(ClientPtr client) if ((pDev == keyboard || (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { - ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + ret = XaceHookDeviceAccess(client, pDev, DixManageAccess); if (ret != Success) return ret; } @@ -2246,7 +2253,7 @@ ProcGetKeyboardControl(ClientPtr client) REQUEST_SIZE_MATCH(xReq); - rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); + rc = XaceHookDeviceAccess(client, kbd, DixGetAttrAccess); if (rc != Success) return rc; @@ -2294,7 +2301,7 @@ ProcBell(ClientPtr client) (!IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == keybd)) && ((dev->kbdfeed && dev->kbdfeed->BellProc) || dev->xkb_interest)) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess); + rc = XaceHookDeviceAccess(client, dev, DixBellAccess); if (rc != Success) return rc; XkbHandleBell(FALSE, FALSE, dev, newpercent, @@ -2367,7 +2374,7 @@ ProcChangePointerControl(ClientPtr client) if ((dev == mouse || (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && dev->ptrfeed) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); + rc = XaceHookDeviceAccess(client, dev, DixManageAccess); if (rc != Success) return rc; } @@ -2399,7 +2406,7 @@ ProcGetPointerControl(ClientPtr client) REQUEST_SIZE_MATCH(xReq); - rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); + rc = XaceHookDeviceAccess(client, ptr, DixGetAttrAccess); if (rc != Success) return rc; @@ -2448,7 +2455,7 @@ ProcGetMotionEvents(ClientPtr client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) return rc; - rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess); + rc = XaceHookDeviceAccess(client, mouse, DixReadAccess); if (rc != Success) return rc; @@ -2512,7 +2519,7 @@ ProcQueryKeymap(ClientPtr client) .length = 2 }; - rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess); + rc = XaceHookDeviceAccess(client, keybd, DixReadAccess); /* If rc is Success, we're allowed to copy out the keymap. * If it's BadAccess, we leave it empty & lie to the client. */ @@ -2569,7 +2576,7 @@ RecalculateMasterButtons(DeviceIntPtr slave) master->button->numButtons = maxbuttons; if (last_num_buttons < maxbuttons) { - master->button->xkb_acts = xnfreallocarray(master->button->xkb_acts, + master->button->xkb_acts = XNFreallocarray(master->button->xkb_acts, maxbuttons, sizeof(XkbAction)); memset(&master->button->xkb_acts[last_num_buttons], @@ -2698,11 +2705,14 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) dev->spriteInfo->paired = dev; } else { + DeviceIntPtr keyboard = GetMaster(dev, MASTER_KEYBOARD); + dev->spriteInfo->sprite = master->spriteInfo->sprite; dev->spriteInfo->paired = master; dev->spriteInfo->spriteOwner = FALSE; - XkbPushLockedStateToSlaves(GetMaster(dev, MASTER_KEYBOARD), 0, 0); + if (keyboard) + XkbPushLockedStateToSlaves(keyboard, 0, 0); RecalculateMasterButtons(master); } @@ -2727,7 +2737,7 @@ GetPairedDevice(DeviceIntPtr dev) if (!IsMaster(dev) && !IsFloating(dev)) dev = GetMaster(dev, MASTER_ATTACHED); - return dev->spriteInfo? dev->spriteInfo->paired: NULL; + return (dev && dev->spriteInfo) ? dev->spriteInfo->paired: NULL; } /** diff --git a/dix/dispatch.c b/dix/dispatch.c index fee0f171c..efb6818df 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -96,22 +96,26 @@ Equipment Corporation. * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #include <version-config.h> -#endif #include <stddef.h> #include <X11/fonts/fontstruct.h> #include <X11/fonts/libxfont2.h> +#include "dix/colormap_priv.h" +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "dix/gc_priv.h" #include "dix/registry_priv.h" #include "dix/screenint_priv.h" +#include "include/resource.h" #include "os/auth.h" +#include "os/client_priv.h" #include "os/ddx_priv.h" #include "os/osdep.h" +#include "os/screensaver.h" #include "windowstr.h" #include "dixfontstr.h" @@ -120,7 +124,6 @@ Equipment Corporation. #include "colormapst.h" #include "cursorstr.h" #include "scrnintstr.h" -#include "input.h" #include "servermd.h" #include "extnsionst.h" #include "dixfont.h" @@ -131,7 +134,6 @@ Equipment Corporation. #include "xace.h" #include "inputstr.h" #include "xkbsrv.h" -#include "client.h" #include "xfixesint.h" #include "dixstruct_priv.h" @@ -525,9 +527,10 @@ Dispatch(void) /* now, finally, deal with client requests */ result = ReadRequestFromClient(client); - if (result <= 0) { - if (result < 0) - CloseDownClient(client); + if (result == 0) + break; + else if (result == -1) { + CloseDownClient(client); break; } @@ -548,7 +551,7 @@ Dispatch(void) client->index, client->requestBuffer); #endif - if (result > (maxBigRequestSize << 2)) + if (result < 0 || result > (maxBigRequestSize << 2)) result = BadLength; else { result = XaceHookDispatch(client, client->majorOp); @@ -1460,8 +1463,9 @@ int dixDestroyPixmap(void *value, XID pid) { PixmapPtr pPixmap = (PixmapPtr) value; - - return (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap); + if (pPixmap && pPixmap->drawable.pScreen && pPixmap->drawable.pScreen->DestroyPixmap) + return pPixmap->drawable.pScreen->DestroyPixmap(pPixmap); + return TRUE; } int @@ -1518,7 +1522,7 @@ ProcCreatePixmap(ClientPtr client) pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, X11_RESTYPE_PIXMAP, + rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP, pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) { (*pDraw->pScreen->DestroyPixmap) (pMap); @@ -2478,7 +2482,7 @@ ProcFreeColormap(ClientPtr client) client, DixDestroyAccess); if (rc == Success) { /* Freeing a default colormap is a no-op */ - if (!(pmap->flags & IsDefault)) + if (!(pmap->flags & CM_IsDefault)) FreeResource(stuff->id, X11_RESTYPE_NONE); return Success; } @@ -2523,7 +2527,7 @@ ProcInstallColormap(ClientPtr client) if (rc != Success) goto out; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); + rc = XaceHookScreenAccess(client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) { if (rc == BadValue) rc = BadColor; @@ -2552,7 +2556,7 @@ ProcUninstallColormap(ClientPtr client) if (rc != Success) goto out; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); + rc = XaceHookScreenAccess(client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) { if (rc == BadValue) rc = BadColor; @@ -2582,8 +2586,7 @@ ProcListInstalledColormaps(ClientPtr client) if (rc != Success) return rc; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, - DixGetAttrAccess); + rc = XaceHookScreenAccess(client, pWin->drawable.pScreen, DixGetAttrAccess); if (rc != Success) return rc; @@ -2630,9 +2633,9 @@ ProcAllocColor(ClientPtr client) if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue, &acr.pixel, client->index))) return rc; -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension || !pmap->pScreen->myNum) -#endif +#endif /* XINERAMA */ WriteReplyToClient(client, sizeof(xAllocColorReply), &acr); return Success; @@ -2671,9 +2674,9 @@ ProcAllocNamedColor(ClientPtr client) &ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue, &ancr.pixel, client->index))) return rc; -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension || !pcmp->pScreen->myNum) -#endif +#endif /* XINERAMA */ WriteReplyToClient(client, sizeof(xAllocNamedColorReply), &ancr); return Success; @@ -2725,9 +2728,9 @@ ProcAllocColorCells(ClientPtr client) free(ppixels); return rc; } -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension || !pcmp->pScreen->myNum) -#endif +#endif /* XINERAMA */ { xAllocColorCellsReply accr = { .type = X_Reply, @@ -2794,9 +2797,9 @@ ProcAllocColorPlanes(ClientPtr client) return rc; } acpr.length = bytes_to_int32(length); -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension || !pcmp->pScreen->myNum) -#endif +#endif /* XINERAMA */ { WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; @@ -2825,7 +2828,7 @@ ProcFreeColors(ClientPtr client) if (rc == Success) { int count; - if (pcmp->flags & AllAllocated) + if (pcmp->flags & CM_AllAllocated) return BadAccess; count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq)); return FreeColors(pcmp, client->index, count, @@ -3121,6 +3124,10 @@ ProcFreeCursor(ClientPtr client) rc = dixLookupResourceByType((void **) &pCursor, stuff->id, X11_RESTYPE_CURSOR, client, DixDestroyAccess); if (rc == Success) { + if (pCursor == rootCursor) { + client->errorValue = stuff->id; + return BadCursor; + } FreeResource(stuff->id, X11_RESTYPE_NONE); return Success; } @@ -3154,7 +3161,7 @@ ProcQueryBestSize(ClientPtr client) if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return BadMatch; pScreen = pDraw->pScreen; - rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess); + rc = XaceHookScreenAccess(client, pScreen, DixGetAttrAccess); if (rc != Success) return rc; (*pScreen->QueryBestSize) (stuff->class, &stuff->width, @@ -3179,7 +3186,7 @@ ProcSetScreenSaver(ClientPtr client) REQUEST_SIZE_MATCH(xSetScreenSaverReq); for (i = 0; i < screenInfo.numScreens; i++) { - rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], + rc = XaceHookScreensaverAccess(client, screenInfo.screens[i], DixSetAttrAccess); if (rc != Success) return rc; @@ -3239,7 +3246,7 @@ ProcGetScreenSaver(ClientPtr client) REQUEST_SIZE_MATCH(xReq); for (i = 0; i < screenInfo.numScreens; i++) { - rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], + rc = XaceHookScreensaverAccess(client, screenInfo.screens[i], DixGetAttrAccess); if (rc != Success) return rc; @@ -3288,7 +3295,7 @@ ProcListHosts(ClientPtr client) REQUEST_SIZE_MATCH(xListHostsReq); /* untrusted clients can't list hosts */ - result = XaceHook(XACE_SERVER_ACCESS, client, DixReadAccess); + result = XaceHookServerAccess(client, DixReadAccess); if (result != Success) return result; @@ -3436,7 +3443,7 @@ ProcChangeCloseDownMode(ClientPtr client) REQUEST(xSetCloseDownModeReq); REQUEST_SIZE_MATCH(xSetCloseDownModeReq); - rc = XaceHook(XACE_CLIENT_ACCESS, client, client, DixManageAccess); + rc = XaceHookClientAccess(client, client, DixManageAccess); if (rc != Success) return rc; @@ -3736,12 +3743,12 @@ SendConnSetup(ClientPtr client, const char *reason) #endif /* fill in the "currentInputMask" */ root = (xWindowRoot *) (lConnectionInfo + connBlockScreenStart); -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension) numScreens = screenInfo.numScreens; else numScreens = ((xConnSetup *) ConnectionInfo)->numRoots; -#endif +#endif /* XINERAMA */ for (i = 0; i < numScreens; i++) { unsigned int j; diff --git a/dix/dispatch.h b/dix/dispatch.h index 939a6b936..9d68a0727 100644 --- a/dix/dispatch.h +++ b/dix/dispatch.h @@ -29,9 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * extension.c, property.c. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifndef DISPATCH_H #define DISPATCH_H 1 diff --git a/dix/display.c b/dix/display.c new file mode 100644 index 000000000..5e8cf7bc5 --- /dev/null +++ b/dix/display.c @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#include <dix-config.h> + +#include "dix/dix_priv.h" +#include "include/dix.h" +#include "include/screenint.h" + +const char *display = "0"; +int displayfd = -1; + +const char *dixGetDisplayName(ScreenPtr *pScreen) +{ + // pScreen currently is ignored as the value is global, + // but this might perhaps change in the future. + return display; +} diff --git a/dix/dix_priv.h b/dix/dix_priv.h index e02a6ea0a..47c18817f 100644 --- a/dix/dix_priv.h +++ b/dix/dix_priv.h @@ -24,7 +24,6 @@ #include "include/gc.h" #include "include/input.h" #include "include/window.h" -#include "Xext/geext.h" /* server setting: maximum size for big requests */ #define MAX_BIG_REQUEST_SIZE 4194303 @@ -36,6 +35,9 @@ extern Bool touchEmulatePointer; extern HWEventQueuePtr checkForInput[2]; + /* -retro mode */ +extern Bool party_like_its_1989; + static inline _X_NOTSAN Bool InputCheckPending(void) { @@ -228,4 +230,29 @@ int CorePointerProc(DeviceIntPtr dev, int what); int CoreKeyboardProc(DeviceIntPtr dev, int what); +extern Bool whiteRoot; + +extern volatile char isItTimeToYield; + +/* bit values for dispatchException */ +#define DE_RESET 1 +#define DE_TERMINATE 2 +#define DE_PRIORITYCHANGE 4 /* set when a client's priority changes */ + +extern volatile char dispatchException; + +extern int ScreenSaverBlanking; +extern int ScreenSaverAllowExposures; +extern int defaultScreenSaverBlanking; +extern int defaultScreenSaverAllowExposures; +extern const char *display; +extern int displayfd; +extern Bool explicit_display; + +extern Bool disableBackingStore; +extern Bool enableBackingStore; + +/* in generated BuiltInAtoms.c */ +void MakePredeclaredAtoms(void); + #endif /* _XSERVER_DIX_PRIV_H */ diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 914ceb7a3..e67ad0f8d 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -48,9 +48,7 @@ Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> #include <X11/X.h> @@ -812,7 +810,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + i = XaceHookServerAccess(client, DixGetAttrAccess); if (i != Success) return i; @@ -1058,7 +1056,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + i = XaceHookServerAccess(client, DixGetAttrAccess); if (i != Success) return i; @@ -1335,9 +1333,9 @@ doPolyText(ClientPtr client, PTclosurePtr c) if (c->err != Success) err = c->err; if (err != Success && c->client != serverClient) { -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension || !c->pGC->pScreen->myNum) -#endif +#endif /* XINERAMA */ SendErrorToClient(c->client, c->reqType, 0, 0, err); } if (ClientIsAsleep(client)) { @@ -1359,18 +1357,18 @@ int PolyText(ClientPtr client, DrawablePtr pDraw, GC * pGC, unsigned char *pElt, unsigned char *endReq, int xorg, int yorg, int reqType, XID did) { - PTclosureRec local_closure; - - local_closure.pElt = pElt; - local_closure.endReq = endReq; - local_closure.client = client; - local_closure.pDraw = pDraw; - local_closure.xorg = xorg; - local_closure.yorg = yorg; - local_closure.reqType = reqType; - local_closure.pGC = pGC; - local_closure.did = did; - local_closure.err = Success; + PTclosureRec local_closure = { + .client = client, + .pDraw = pDraw, + .pGC = pGC, + .pElt = pElt, + .endReq = endReq, + .xorg = xorg, + .yorg = yorg, + .reqType = reqType, + .did = did, + .err = Success + }; (void) doPolyText(client, &local_closure); return Success; @@ -1681,7 +1679,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) int SetFontPath(ClientPtr client, int npaths, unsigned char *paths) { - int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + int err = XaceHookServerAccess(client, DixManageAccess); if (err != Success) return err; @@ -1694,7 +1692,8 @@ SetFontPath(ClientPtr client, int npaths, unsigned char *paths) int bad; err = SetFontPathElements(npaths, paths, &bad, FALSE); - client->errorValue = bad; + if (err != Success) + client->errorValue = bad; } return err; } @@ -1769,7 +1768,7 @@ GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result) int len; FontPathElementPtr fpe; - i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + i = XaceHookServerAccess(client, DixGetAttrAccess); if (i != Success) return i; diff --git a/dix/dixgrabs_priv.h b/dix/dixgrabs_priv.h new file mode 100644 index 000000000..12e8824d2 --- /dev/null +++ b/dix/dixgrabs_priv.h @@ -0,0 +1,171 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_DIXGRABS_PRIV_H_ +#define _XSERVER_DIXGRABS_PRIV_H_ + +#include <X11/extensions/XIproto.h> + +#include "misc.h" +#include "window.h" +#include "input.h" +#include "cursor.h" + +struct _GrabParameters; + +/** + * @brief Print current device grab information for specific device + * + * Walks through all active grabs and dumps them into the Xserver's error log. + * This is usually for debugging and troubleshooting. Will also be called by + * UngrabAllDevices(). + * + * @param dev the device to act on + */ +void PrintDeviceGrabInfo(DeviceIntPtr dev); + +/** + * @brief Forcefully remove _all_ device grabs + * + * Forcefully remove all device grabs on all devices. Optionally kill the + * clients holding a grab + * + * @param kill_client TRUE if clients holding a grab should be killed + */ +void UngrabAllDevices(Bool kill_client); + +/** + * @brief Allocate new grab, optionally copy from existing + * + * Allocate a new grab structure. If src is non-null, copy parameters from + * the existing grab. + * + * Returns NULL in case of OOM or when src grab is given, but copy failed. + * + * @param src optional grab to copy from (NULL = don't copy) + * @return pointer to new grab. Must be freed via ::FreeGrab(). + */ +GrabPtr AllocGrab(const GrabPtr src); + +/** + * @brief Free a grab + * + * Free a grab (that had been allocated by ::AllocGrab()). If the grab has + * a cursor, this will also be unref'ed / free'd. + * + * @param grab pointer to the grab to be freed. Tolerates NULL. + */ +void FreeGrab(GrabPtr grab); + +/** + * @brief create a new grab for given client + * + * Create a new grab for given client, with given parameters. + * Returns NULL on OOM. + * + * @param client _Index_ of the client who will hold the grab + * @param device Device that's being grabbed + * @param modDevice Device whose modifiers are used (NULL = use core keyboard) + * @param window the window getting the events + * @param grabtype type of grab (see ::"enum InputLevel") + * @param mask mask for fields used from param + * @param param pointer to struct holding additional parameters + * @param eventType type of event to grab on (eg. DeviceButtonPress) + * @param keyCode KeyCode of key or button to grab + * @param confineTo window to restrict device into (may be NULL) + * @param cursor cursor to be used while grabbed (may be NULL) + * @return newly created grab. Must be freed by ::FreeGrab() + */ +GrabPtr CreateGrab(int client, + DeviceIntPtr device, + DeviceIntPtr modDevice, + WindowPtr window, + enum InputLevel grabtype, + GrabMask *mask, + struct _GrabParameters *param, + int eventType, + KeyCode keycode, + WindowPtr confineTo, + CursorPtr cursor); + +/** + * @brief check whether it is a pointer grab + * + * @param grab pointer to the grab structure to check + * @return TRUE if grabbed a pointer + */ +Bool GrabIsPointerGrab(GrabPtr grab); + +/** + * @brief check whether it is a keyboard grab + * + * @param grab pointer to the grab structure to check + * @return TRUE if grabbed a keyboard + */ +Bool GrabIsKeyboardGrab(GrabPtr grab); + +/** + * @brief check whether it is a gesture grab + * + * @param grab pointer to the grab structure to check + * @return TRUE if grabbed a gesture + */ +Bool GrabIsGestureGrab(GrabPtr grab); + +/** + * @brief destructor for X11_RESTYPE_PASSIVEGRAB resource type + * + * Destructor for the X11_RESTYPE_PASSIVEGRAB resource type. + * Should not be used anywhere else + * + * @param value pointer to the resource data object + * @param XID the X11 ID of the resource object + * @return result code (always Success) + */ +int DeletePassiveGrab(void *value, XID id); + +/* + * @brief compare to grabs + * + * Check whether two grabs match each other: grabbing the same events + * and (optional) grabbing on the same device. + * + * @param pFirstGrab first grab to compare + * @param pSecondGrab second grab to compare + * @param ignoreDevice TRUE if devices don't need to match + * @return TRUE if both grabs are having the same claims + */ +Bool GrabMatchesSecond(GrabPtr pFirstGrab, + GrabPtr pSecondGrab, + Bool ignoreDevice); + +/** + * @brief add passive grab to a client + * + * Prepend a grab to the clients's list of passive grabs. + * Previously existing matching ones are deleted. + * On conflict with another client's grabs, return BadAccess. + * + * @param client pointer to the client the new grab is added to + * @param pGrab pointer to the grab to be added. + * @return X11 error code: BadAccess on conflict, otherwise Success + */ +int AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab); + +/** + * @brief delete grab claims from a window's passive grabs list + * + * Delete the items affected by given grab from the currently existing + * passive grabs on a window. This walk through list of passive grabs + * of the associated window and delete the claims matching this one's. + * + * The grab structure passed in here is just used as a vehicle for + * specifying which claims should be deleted (on which window). + * + * @param pMinuedGrab GrabRec structure specifying which claims to delete + * @return TRUE if succeeded (FALSE usually indicated allocation failure) + */ +Bool DeletePassiveGrabFromList(GrabPtr pMinuendGrab); + +#endif /* _XSERVER_DIXGRABS_PRIV_H_ */ diff --git a/dix/dixutils.c b/dix/dixutils.c index 440b4d08c..3b98ced0e 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -80,9 +80,7 @@ Author: Adobe Systems Incorporated */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> @@ -232,7 +230,7 @@ dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access) if (rc != Success) goto bad; - rc = XaceHook(XACE_CLIENT_ACCESS, client, clients[clientIndex], access); + rc = XaceHookClientAccess(client, clients[clientIndex], access); if (rc != Success) goto bad; @@ -800,7 +798,7 @@ CreateCallbackList(CallbackListPtr *pcbl) } } - listsToCleanup = (CallbackListPtr **) xnfrealloc(listsToCleanup, + listsToCleanup = (CallbackListPtr **) XNFrealloc(listsToCleanup, sizeof(CallbackListPtr *) * (numCallbackListsToCleanup + 1)); diff --git a/dix/enterleave.c b/dix/enterleave.c index 57a3d9967..b954c8e21 100644 --- a/dix/enterleave.c +++ b/dix/enterleave.c @@ -24,9 +24,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/extensions/XI2.h> @@ -35,6 +33,7 @@ #include "dix/dix_priv.h" #include "dix/eventconvert.h" +#include "dix/input_priv.h" #include "inputstr.h" #include "windowstr.h" @@ -623,14 +622,19 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v, switch (ev->num_valuators) { case 6: ev->valuator5 = v->axisVal[first + 5]; + /* fallthrough */ case 5: ev->valuator4 = v->axisVal[first + 4]; + /* fallthrough */ case 4: ev->valuator3 = v->axisVal[first + 3]; + /* fallthrough */ case 3: ev->valuator2 = v->axisVal[first + 2]; + /* fallthrough */ case 2: ev->valuator1 = v->axisVal[first + 1]; + /* fallthrough */ case 1: ev->valuator0 = v->axisVal[first]; break; @@ -669,8 +673,10 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k, switch (ev->num_valuators) { case 3: ev->valuator2 = v->axisVal[first + 2]; + /* fallthrough */ case 2: ev->valuator1 = v->axisVal[first + 1]; + /* fallthrough */ case 1: ev->valuator0 = v->axisVal[first]; break; @@ -725,7 +731,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win) evcount += ((nval - 3) + 6)/6; } - BUG_RETURN(evcount <= ARRAY_SIZE(sev)); + BUG_RETURN(evcount > ARRAY_SIZE(sev)); FixDeviceStateNotify(dev, ev, k, b, v, first); @@ -734,7 +740,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win) (ev - 1)->deviceid |= MORE_EVENTS; bev->type = DeviceButtonStateNotify; bev->deviceid = dev->id; - memcpy((char *) &bev->buttons[4], (char *) &b->down[4], + memcpy((char *) &bev->buttons[0], (char *) &b->down[4], DOWN_LENGTH - 4); } @@ -1245,10 +1251,10 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev, int i; int nscreens = screenInfo.numScreens; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) nscreens = 1; -#endif +#endif /* XINERAMA */ for (i = 0; i < nscreens; i++) { root = screenInfo.screens[i]->root; @@ -1289,10 +1295,10 @@ CoreFocusToPointerRootOrNone(DeviceIntPtr dev, WindowPtr A, int i; int nscreens = screenInfo.numScreens; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) nscreens = 1; -#endif +#endif /* XINERAMA */ if (!HasFocus(A)) { WindowPtr child = FirstFocusChild(A); @@ -1336,10 +1342,10 @@ CoreFocusFromPointerRootOrNone(DeviceIntPtr dev, int i; int nscreens = screenInfo.numScreens; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) nscreens = 1; -#endif +#endif /* XINERAMA */ for (i = 0; i < nscreens; i++) { root = screenInfo.screens[i]->root; @@ -1426,10 +1432,10 @@ DeviceFocusEvents(DeviceIntPtr dev, WindowPtr from, WindowPtr to, int mode) in = (to == NoneWin) ? NotifyDetailNone : NotifyPointerRoot; /* wrong values if neither, but then not referenced */ -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) nscreens = 1; -#endif +#endif /* XINERAMA */ if ((to == NullWindow) || (to == PointerRootWin)) { if ((from == NullWindow) || (from == PointerRootWin)) { diff --git a/dix/enterleave.h b/dix/enterleave.h index e8af924c6..b6341ff68 100644 --- a/dix/enterleave.h +++ b/dix/enterleave.h @@ -24,9 +24,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifndef ENTERLEAVE_H #define ENTERLEAVE_H diff --git a/dix/eventconvert.c b/dix/eventconvert.c index a7f43efe6..d805018f8 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -28,9 +28,7 @@ * matching protocol events. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include <X11/X.h> @@ -685,6 +683,8 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) len += vallen * 4; /* valuators mask */ *xi = calloc(1, len); + if (*xi == NULL) + return BadAlloc; xde = (xXIDeviceEvent *) * xi; xde->type = GenericEvent; xde->extension = IReqCode; @@ -735,7 +735,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) ptr += xde->buttons_len * 4; axisval = (FP3232 *) (ptr + xde->valuators_len * 4); - for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++) { + for (i = 0; i < MAX_VALUATORS; i++) { if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); *axisval = double_to_fp3232(ev->valuators.data[i]); @@ -753,6 +753,8 @@ eventToTouchOwnershipEvent(TouchOwnershipEvent *ev, xEvent **xi) xXITouchOwnershipEvent *xtoe; *xi = calloc(1, len); + if (*xi == NULL) + return BadAlloc; xtoe = (xXITouchOwnershipEvent *) * xi; xtoe->type = GenericEvent; xtoe->extension = IReqCode; @@ -783,6 +785,8 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) len += vallen * 4; /* valuators mask */ *xi = calloc(1, len); + if (*xi == NULL) + return BadAlloc; raw = (xXIRawEvent *) * xi; raw->type = GenericEvent; raw->extension = IReqCode; @@ -798,7 +802,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) ptr = (char *) &raw[1]; axisval = (FP3232 *) (ptr + raw->valuators_len * 4); axisval_raw = axisval + nvals; - for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++) { + for (i = 0; i < MAX_VALUATORS; i++) { if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); *axisval = double_to_fp3232(ev->valuators.data[i]); @@ -818,6 +822,8 @@ eventToBarrierEvent(BarrierEvent *ev, xEvent **xi) int len = sizeof(xXIBarrierEvent); *xi = calloc(1, len); + if (*xi == NULL) + return BadAlloc; barrier = (xXIBarrierEvent*) *xi; barrier->type = GenericEvent; barrier->extension = IReqCode; @@ -847,6 +853,8 @@ eventToGesturePinchEvent(GestureEvent *ev, xEvent **xi) xXIGesturePinchEvent *xpe; *xi = calloc(1, len); + if (*xi == NULL) + return BadAlloc; xpe = (xXIGesturePinchEvent *) * xi; xpe->type = GenericEvent; xpe->extension = IReqCode; @@ -889,6 +897,8 @@ eventToGestureSwipeEvent(GestureEvent *ev, xEvent **xi) xXIGestureSwipeEvent *xde; *xi = calloc(1, len); + if (*xi == NULL) + return BadAlloc; xde = (xXIGestureSwipeEvent *) * xi; xde->type = GenericEvent; xde->extension = IReqCode; diff --git a/dix/events.c b/dix/events.c index 361a1c298..2c99cd29e 100644 --- a/dix/events.c +++ b/dix/events.c @@ -101,11 +101,15 @@ Equipment Corporation. * handling (the parts for input devices). */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> +#include <X11/extensions/ge.h> +#include <X11/extensions/XKBproto.h> +#include <X11/extensions/XIproto.h> +#include <X11/extensions/XI2proto.h> +#include <X11/extensions/XI.h> +#include <X11/extensions/XI2.h> #include <X11/Xproto.h> #include <X11/extensions/ge.h> #include <X11/extensions/XI.h> @@ -114,9 +118,13 @@ Equipment Corporation. #include <X11/extensions/XIproto.h> #include <X11/extensions/XI2proto.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" +#include "dix/input_priv.h" #include "dix/eventconvert.h" #include "dix/exevents_priv.h" +#include "os/fmt.h" #include "xkb/xkbsrv_priv.h" #include "misc.h" @@ -127,25 +135,25 @@ Equipment Corporation. #include "scrnintstr.h" #include "cursorstr.h" #include "dixstruct.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ #include "globals.h" #include "xace.h" #include "probes.h" #include "exglobals.h" #include "extnsionst.h" #include "dixevents.h" -#include "dixgrabs.h" #include "dispatch.h" -#include "geext.h" -#include "geint.h" #include "dixstruct_priv.h" #include "eventstr.h" #include "enterleave.h" #include "mi.h" +#define _XkbWantsDetectableAutoRepeat(c) \ + ((c)->xkbClientFlags&XkbPCF_DetectableAutoRepeatMask) + /* Extension events type numbering starts at EXTENSION_EVENT_BASE. */ #define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */ #define StructureAndSubMask ( StructureNotifyMask | SubstructureNotifyMask ) @@ -503,17 +511,17 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) { int screenno = 0; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) screenno = dev->spriteInfo->sprite->screen->myNum; -#endif +#endif /* XINERAMA */ PostSyntheticMotion(dev, x, y, screenno, (syncEvents.playingEvents) ? syncEvents.time. milliseconds : currentTime.milliseconds); } -#ifdef PANORAMIX +#ifdef XINERAMA static void PostNewCursor(DeviceIntPtr pDev); static Bool @@ -648,7 +656,7 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev, CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL); } -#endif /* PANORAMIX */ +#endif /* XINERAMA */ /** * Modifies the filter for the given protocol event type to the given masks. @@ -724,12 +732,12 @@ CheckPhysLimits(DeviceIntPtr pDev, CursorPtr cursor, Bool generateEvents, if (!cursor) return; new = pSprite->hotPhys; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) /* I don't care what the DDX has to say about it */ pSprite->physLimits = pSprite->hotLimits; else -#endif +#endif /* XINERAMA */ { if (pScreen) new.pScreen = pScreen; @@ -753,16 +761,16 @@ CheckPhysLimits(DeviceIntPtr pDev, CursorPtr cursor, Bool generateEvents, if (pSprite->hotShape) ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y); if (( -#ifdef PANORAMIX +#ifdef XINERAMA noPanoramiXExtension && -#endif +#endif /* XINERAMA */ (pScreen != pSprite->hotPhys.pScreen)) || (new.x != pSprite->hotPhys.x) || (new.y != pSprite->hotPhys.y)) { -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) XineramaSetCursorPosition(pDev, new.x, new.y, generateEvents); else -#endif +#endif /* XINERAMA */ { if (pScreen != pSprite->hotPhys.pScreen) pSprite->hotPhys = new; @@ -773,11 +781,11 @@ CheckPhysLimits(DeviceIntPtr pDev, CursorPtr cursor, Bool generateEvents, SyntheticMotion(pDev, new.x, new.y); } -#ifdef PANORAMIX +#ifdef XINERAMA /* Tell DDX what the limits are */ if (!noPanoramiXExtension) XineramaConstrainCursor(pDev); -#endif +#endif /* XINERAMA */ } static void @@ -811,7 +819,7 @@ CheckVirtualMotion(DeviceIntPtr pDev, QdEventPtr qe, WindowPtr pWin) if (pWin) { BoxRec lims; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { int x, y, off_x, off_y, i; @@ -839,7 +847,7 @@ CheckVirtualMotion(DeviceIntPtr pDev, QdEventPtr qe, WindowPtr pWin) } } else -#endif +#endif /* XINERAMA */ { if (pSprite->hot.pScreen != pWin->drawable.pScreen) { pSprite->hot.pScreen = pWin->drawable.pScreen; @@ -857,14 +865,14 @@ CheckVirtualMotion(DeviceIntPtr pDev, QdEventPtr qe, WindowPtr pWin) else if (pSprite->hot.y >= lims.y2) pSprite->hot.y = lims.y2 - 1; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { if (RegionNumRects(&pSprite->Reg2) > 1) reg = &pSprite->Reg2; } else -#endif +#endif /* XINERAMA */ { if (wBoundingShape(pWin)) reg = &pWin->borderSize; @@ -879,9 +887,9 @@ CheckVirtualMotion(DeviceIntPtr pDev, QdEventPtr qe, WindowPtr pWin) ev->root_y = pSprite->hot.y; } } -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */ -#endif +#endif /* XINERAMA */ RootWindow(pDev->spriteInfo->sprite) = pSprite->hot.pScreen->root; } @@ -898,12 +906,12 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, else { ScreenPtr pScreen = pWin->drawable.pScreen; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { XineramaConfineCursorToWindow(pDev, pWin, generateEvents); return; } -#endif +#endif /* XINERAMA */ pSprite->hotLimits = *RegionExtents(&pWin->borderSize); pSprite->hotShape = wBoundingShape(pWin) ? &pWin->borderSize : NullRegion; @@ -939,12 +947,12 @@ ChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor) (pSprite->current->bits->yhot != cursor->bits->yhot)) CheckPhysLimits(pDev, cursor, FALSE, pSprite->confined, (ScreenPtr) NULL); -#ifdef PANORAMIX +#ifdef XINERAMA /* XXX: is this really necessary?? (whot) */ if (!noPanoramiXExtension) pScreen = pSprite->screen; else -#endif +#endif /* XINERAMA */ pScreen = pSprite->hotPhys.pScreen; (*pScreen->DisplayCursor) (pDev, pScreen, cursor); @@ -1045,19 +1053,6 @@ GetSpritePosition(DeviceIntPtr pDev, int *px, int *py) *py = pSprite->hotPhys.y; } -#ifdef PANORAMIX -int -XineramaGetCursorScreen(DeviceIntPtr pDev) -{ - if (!noPanoramiXExtension) { - return pDev->spriteInfo->sprite->screen->myNum; - } - else { - return 0; - } -} -#endif /* PANORAMIX */ - #define TIMESLOP (5 * 60 * 1000) /* 5 minutes */ static void @@ -1180,12 +1175,12 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device) } if (event->type == ET_Motion) { -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { event->root_x += pSprite->screen->x - screenInfo.screens[0]->x; event->root_y += pSprite->screen->y - screenInfo.screens[0]->y; } -#endif +#endif /* XINERAMA */ pSprite->hotPhys.x = event->root_x; pSprite->hotPhys.y = event->root_y; /* do motion compression, but not if from different devices */ @@ -1243,7 +1238,7 @@ PlayReleasedEvents(void) CheckVirtualMotion(pDev, qe, NullWindow); syncEvents.time.months = qe->months; syncEvents.time.milliseconds = qe->event->any.time; -#ifdef PANORAMIX +#ifdef XINERAMA /* Translate back to the sprite screen since processInputProc will translate from sprite screen to screen 0 upon reentry to the DIX layer */ @@ -1271,7 +1266,7 @@ PlayReleasedEvents(void) } } -#endif +#endif /* XINERAMA */ (*qe->device->public.processInputProc) (qe->event, qe->device); free(qe); for (dev = inputInfo.devices; dev && dev->deviceGrab.sync.frozen; @@ -1321,7 +1316,7 @@ ComputeFreezes(void) for (dev = inputInfo.devices; dev; dev = dev->next) FreezeThaw(dev, dev->deviceGrab.sync.other || - (dev->deviceGrab.sync.state >= FROZEN)); + (dev->deviceGrab.sync.state >= GRAB_STATE_FROZEN)); if (syncEvents.playingEvents || (!replayDev && xorg_list_is_empty(&syncEvents.pending))) return; @@ -1423,9 +1418,9 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) DeviceIntPtr dev; if (thisMode == GrabModeSync) - thisDev->deviceGrab.sync.state = FROZEN_NO_EVENT; + thisDev->deviceGrab.sync.state = GRAB_STATE_FROZEN_NO_EVENT; else { /* free both if same client owns both */ - thisDev->deviceGrab.sync.state = THAWED; + thisDev->deviceGrab.sync.state = GRAB_STATE_THAWED; if (thisDev->deviceGrab.sync.other && (CLIENT_BITS(thisDev->deviceGrab.sync.other->resource) == CLIENT_BITS(grab->resource))) @@ -1483,6 +1478,30 @@ ReattachToOldMaster(DeviceIntPtr dev) } /** + * Return the current master keyboard or, if we're temporarily detached, the one + * we've been attached to previously. + */ +static DeviceIntPtr +CurrentOrOldMasterKeyboard(DeviceIntPtr dev) +{ + DeviceIntPtr kbd = GetMaster(dev, MASTER_KEYBOARD); + + if (kbd) + return kbd; + + if (dev->saved_master_id) { + dixLookupDevice(&kbd, dev->saved_master_id, serverClient, DixUseAccess); + if (!kbd) + return NULL; + /* if dev is a pointer the saved master is a master pointer, + * we want the keybard */ + return GetMaster(kbd, MASTER_KEYBOARD); + } + + return NULL; +} + +/** * Update touch records when an explicit grab is activated. Any touches owned by * the grabbing client are updated so the listener state reflects the new grab. */ @@ -1520,8 +1539,7 @@ UpdateTouchesForGrab(DeviceIntPtr mouse) listener->window = grab->window; listener->state = TOUCH_LISTENER_IS_OWNER; - if (listener->grab) - FreeGrab(listener->grab); + FreeGrab(listener->grab); listener->grab = AllocGrab(grab); } } @@ -1561,8 +1579,7 @@ UpdateGesturesForGrab(DeviceIntPtr mouse) listener->listener = grab->resource; listener->window = grab->window; - if (listener->grab) - FreeGrab(listener->grab); + FreeGrab(listener->grab); listener->grab = AllocGrab(grab); } } @@ -1620,8 +1637,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, UpdateGesturesForGrab(mouse); CheckGrabForSyncs(mouse, (Bool) grab->pointerMode, (Bool) grab->keyboardMode); - if (oldgrab) - FreeGrab(oldgrab); + FreeGrab(oldgrab); } /** @@ -1666,7 +1682,7 @@ DeactivatePointerGrab(DeviceIntPtr mouse) mouse->valuator->motionHintWindow = NullWindow; mouse->deviceGrab.grab = NullGrab; - mouse->deviceGrab.sync.state = NOT_GRABBED; + mouse->deviceGrab.sync.state = GRAB_STATE_NOT_GRABBED; mouse->deviceGrab.fromPassiveGrab = FALSE; for (dev = inputInfo.devices; dev; dev = dev->next) { @@ -1709,6 +1725,10 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, GrabInfoPtr grabinfo = &keybd->deviceGrab; GrabPtr oldgrab = grabinfo->grab; WindowPtr oldWin; + DeviceIntPtr master_keyboard = CurrentOrOldMasterKeyboard(keybd); + + if (!master_keyboard) + master_keyboard = inputInfo.keyboard; /* slave devices need to float for the duration of the grab. */ if (grab->grabtype == XI2 && keybd->enabled && @@ -1724,7 +1744,7 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, else oldWin = keybd->spriteInfo->sprite->win; if (oldWin == FollowKeyboardWin) - oldWin = keybd->focus->win; + oldWin = master_keyboard->focus->win; if (keybd->valuator) keybd->valuator->motionHintWindow = NullWindow; if (oldWin && @@ -1740,8 +1760,7 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, grabinfo->implicitGrab = passive & ImplicitGrabMask; CheckGrabForSyncs(keybd, (Bool) grab->keyboardMode, (Bool) grab->pointerMode); - if (oldgrab) - FreeGrab(oldgrab); + FreeGrab(oldgrab); } /** @@ -1755,11 +1774,15 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd) WindowPtr focusWin; Bool wasImplicit = (keybd->deviceGrab.fromPassiveGrab && keybd->deviceGrab.implicitGrab); + DeviceIntPtr master_keyboard = CurrentOrOldMasterKeyboard(keybd); + + if (!master_keyboard) + master_keyboard = inputInfo.keyboard; if (keybd->valuator) keybd->valuator->motionHintWindow = NullWindow; keybd->deviceGrab.grab = NullGrab; - keybd->deviceGrab.sync.state = NOT_GRABBED; + keybd->deviceGrab.sync.state = GRAB_STATE_NOT_GRABBED; keybd->deviceGrab.fromPassiveGrab = FALSE; for (dev = inputInfo.devices; dev; dev = dev->next) { @@ -1775,7 +1798,7 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd) focusWin = NullWindow; if (focusWin == FollowKeyboardWin) - focusWin = inputInfo.keyboard->focus->win; + focusWin = master_keyboard->focus->win; DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab); @@ -1812,37 +1835,37 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) otherGrabbed = TRUE; if (grabinfo->sync.other == devgrabinfo->grab) thisSynced = TRUE; - if (devgrabinfo->sync.state >= FROZEN) + if (devgrabinfo->sync.state >= GRAB_STATE_FROZEN) othersFrozen = TRUE; } } - if (!((thisGrabbed && grabinfo->sync.state >= FROZEN) || thisSynced)) + if (!((thisGrabbed && grabinfo->sync.state >= GRAB_STATE_FROZEN) || thisSynced)) return; if ((CompareTimeStamps(time, currentTime) == LATER) || (CompareTimeStamps(time, grabTime) == EARLIER)) return; switch (newState) { - case THAWED: /* Async */ + case GRAB_STATE_THAWED: /* Async */ if (thisGrabbed) - grabinfo->sync.state = THAWED; + grabinfo->sync.state = GRAB_STATE_THAWED; if (thisSynced) grabinfo->sync.other = NullGrab; ComputeFreezes(); break; - case FREEZE_NEXT_EVENT: /* Sync */ + case GRAB_STATE_FREEZE_NEXT_EVENT: /* Sync */ if (thisGrabbed) { - grabinfo->sync.state = FREEZE_NEXT_EVENT; + grabinfo->sync.state = GRAB_STATE_FREEZE_NEXT_EVENT; if (thisSynced) grabinfo->sync.other = NullGrab; ComputeFreezes(); } break; - case THAWED_BOTH: /* AsyncBoth */ + case GRAB_STATE_THAWED_BOTH: /* AsyncBoth */ if (othersFrozen) { for (dev = inputInfo.devices; dev; dev = dev->next) { devgrabinfo = &dev->deviceGrab; if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) - devgrabinfo->sync.state = THAWED; + devgrabinfo->sync.state = GRAB_STATE_THAWED; if (devgrabinfo->sync.other && SameClient(devgrabinfo->sync.other, client)) devgrabinfo->sync.other = NullGrab; @@ -1850,12 +1873,12 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) ComputeFreezes(); } break; - case FREEZE_BOTH_NEXT_EVENT: /* SyncBoth */ + case GRAB_STATE_FREEZE_BOTH_NEXT_EVENT: /* SyncBoth */ if (othersFrozen) { for (dev = inputInfo.devices; dev; dev = dev->next) { devgrabinfo = &dev->deviceGrab; if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) - devgrabinfo->sync.state = FREEZE_BOTH_NEXT_EVENT; + devgrabinfo->sync.state = GRAB_STATE_FREEZE_BOTH_NEXT_EVENT; if (devgrabinfo->sync.other && SameClient(devgrabinfo->sync.other, client)) devgrabinfo->sync.other = NullGrab; @@ -1863,8 +1886,8 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) ComputeFreezes(); } break; - case NOT_GRABBED: /* Replay */ - if (thisGrabbed && grabinfo->sync.state == FROZEN_WITH_EVENT) { + case GRAB_STATE_NOT_GRABBED: /* Replay */ + if (thisGrabbed && grabinfo->sync.state == GRAB_STATE_FROZEN_WITH_EVENT) { if (thisSynced) grabinfo->sync.other = NullGrab; syncEvents.replayDev = thisDev; @@ -1873,14 +1896,14 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) syncEvents.replayDev = (DeviceIntPtr) NULL; } break; - case THAW_OTHERS: /* AsyncOthers */ + case GRAB_STATE_THAW_OTHERS: /* AsyncOthers */ if (othersFrozen) { for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev == thisDev) continue; devgrabinfo = &dev->deviceGrab; if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) - devgrabinfo->sync.state = THAWED; + devgrabinfo->sync.state = GRAB_STATE_THAWED; if (devgrabinfo->sync.other && SameClient(devgrabinfo->sync.other, client)) devgrabinfo->sync.other = NullGrab; @@ -1895,7 +1918,7 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) * we've handled in ComputeFreezes() (during DeactivateGrab) above, * anything else is accept. */ - if (newState != NOT_GRABBED /* Replay */ && + if (newState != GRAB_STATE_NOT_GRABBED /* Replay */ && IsTouchEvent(grabinfo->sync.event)) { TouchAcceptAndEnd(thisDev, grabinfo->sync.event->device_event.touchid); } @@ -1924,28 +1947,28 @@ ProcAllowEvents(ClientPtr client) switch (stuff->mode) { case ReplayPointer: - AllowSome(client, time, mouse, NOT_GRABBED); + AllowSome(client, time, mouse, GRAB_STATE_NOT_GRABBED); break; case SyncPointer: - AllowSome(client, time, mouse, FREEZE_NEXT_EVENT); + AllowSome(client, time, mouse, GRAB_STATE_FREEZE_NEXT_EVENT); break; case AsyncPointer: - AllowSome(client, time, mouse, THAWED); + AllowSome(client, time, mouse, GRAB_STATE_THAWED); break; case ReplayKeyboard: - AllowSome(client, time, keybd, NOT_GRABBED); + AllowSome(client, time, keybd, GRAB_STATE_NOT_GRABBED); break; case SyncKeyboard: - AllowSome(client, time, keybd, FREEZE_NEXT_EVENT); + AllowSome(client, time, keybd, GRAB_STATE_FREEZE_NEXT_EVENT); break; case AsyncKeyboard: - AllowSome(client, time, keybd, THAWED); + AllowSome(client, time, keybd, GRAB_STATE_THAWED); break; case SyncBoth: - AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT); + AllowSome(client, time, keybd, GRAB_STATE_FREEZE_BOTH_NEXT_EVENT); break; case AsyncBoth: - AllowSome(client, time, keybd, THAWED_BOTH); + AllowSome(client, time, keybd, GRAB_STATE_THAWED_BOTH); break; default: client->errorValue = stuff->mode; @@ -2176,7 +2199,7 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win, if (IsInterferingGrab(wClient(win), dev, events)) return EVENT_SKIP; - if (!XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count)) { + if (!XaceHookReceiveAccess(wClient(win), win, events, count)) { int attempt = TryClientEvents(wClient(win), dev, events, count, win->eventMask, filter, grab); @@ -2254,7 +2277,7 @@ DeliverEventToInputClients(DeviceIntPtr dev, InputClients * inputclients, mask = GetEventMask(dev, events, inputclients); - if (XaceHook(XACE_RECEIVE_ACCESS, client, win, events, count)) + if (XaceHookReceiveAccess(client, win, events, count)) /* do nothing */ ; else if ((attempt = TryClientEvents(client, dev, events, count, @@ -2494,7 +2517,7 @@ DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) Only works for core events. */ -#ifdef PANORAMIX +#ifdef XINERAMA static int XineramaTryClientEventsResult(ClientPtr client, GrabPtr grab, Mask mask, Mask filter) @@ -2508,7 +2531,7 @@ XineramaTryClientEventsResult(ClientPtr client, } return 0; } -#endif +#endif /* XINERAMA */ /** * Try to deliver events to the interested parties. @@ -2528,12 +2551,12 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents, if (pWin->eventMask & filter) { if (wClient(pWin) == dontClient) return 0; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return XineramaTryClientEventsResult(wClient(pWin), NullGrab, pWin->eventMask, filter); -#endif - if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count)) +#endif /* XINERAMA */ + if (XaceHookReceiveAccess(wClient(pWin), pWin, pEvents, count)) return 1; /* don't send, but pretend we did */ return TryClientEvents(wClient(pWin), NULL, pEvents, count, pWin->eventMask, filter, NullGrab); @@ -2542,12 +2565,12 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents, if (other->mask & filter) { if (SameClient(other, dontClient)) return 0; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return XineramaTryClientEventsResult(rClient(other), NullGrab, other->mask, filter); -#endif - if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin, pEvents, +#endif /* XINERAMA */ + if (XaceHookReceiveAccess(rClient(other), pWin, pEvents, count)) return 1; /* don't send, but pretend we did */ return TryClientEvents(rClient(other), NULL, pEvents, count, @@ -2786,7 +2809,7 @@ DeliverEvent(DeviceIntPtr dev, xEvent *xE, int count, Mask filter; int deliveries = 0; - if (XaceHook(XACE_SEND_ACCESS, NULL, dev, win, xE, count) == Success) { + if (XaceHookSendAccess(NULL, dev, win, xE, count) == Success) { filter = GetEventFilter(dev, xE); FixUpEventFromWindow(pSprite, xE, win, child, FALSE); deliveries = DeliverEventsToWindow(dev, win, xE, count, filter, grab); @@ -2919,10 +2942,10 @@ DeliverEvents(WindowPtr pWin, xEvent *xE, int count, WindowPtr otherParent) DeviceIntRec dummy; int deliveries; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return count; -#endif +#endif /* XINERAMA */ if (!count) return 0; @@ -2987,7 +3010,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y) if (RegionContainsPoint(&pWin->borderSize, x, y, &box)) return TRUE; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && XineramaSetWindowPntrs(inputInfo.pointer, pWin)) { SpritePtr pSprite = inputInfo.pointer->spriteInfo->sprite; @@ -3002,7 +3025,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y) return TRUE; } } -#endif +#endif /* XINERAMA */ return FALSE; } @@ -3142,7 +3165,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) return FALSE; } -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { /* Motion events entering DIX get translated to Screen 0 coordinates. Replayed events have already been @@ -3151,7 +3174,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) ev->root_y += pSprite->screen->y - screenInfo.screens[0]->y; } else -#endif +#endif /* XINERAMA */ { if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen) { pSprite->hot.pScreen = pSprite->hotPhys.pScreen; @@ -3177,13 +3200,13 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) if ((pSprite->hotPhys.x != ev->root_x) || (pSprite->hotPhys.y != ev->root_y)) { -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { XineramaSetCursorPosition(pDev, pSprite->hotPhys.x, pSprite->hotPhys.y, FALSE); } else -#endif +#endif /* XINERAMA */ { (*pSprite->hotPhys.pScreen->SetCursorPosition) (pDev, pSprite-> @@ -3340,7 +3363,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) pSprite->hot.y, FALSE); (*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current); } -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { pSprite->hotLimits.x1 = -screenInfo.screens[0]->x; pSprite->hotLimits.y1 = -screenInfo.screens[0]->y; @@ -3354,7 +3377,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) RegionNull(&pSprite->Reg1); RegionNull(&pSprite->Reg2); } -#endif +#endif /* XINERAMA */ } void FreeSprite(DeviceIntPtr dev) @@ -3420,7 +3443,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen) (*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits); (*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current); -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { pSprite->hotLimits.x1 = -screenInfo.screens[0]->x; pSprite->hotLimits.y1 = -screenInfo.screens[0]->y; @@ -3429,7 +3452,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen) pSprite->physLimits = pSprite->hotLimits; pSprite->screen = pScreen; } -#endif +#endif /* XINERAMA */ } /* @@ -3462,7 +3485,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) pSprite->hotPhys.x = x; pSprite->hotPhys.y = y; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { pSprite->hotPhys.x += newScreen->x - screenInfo.screens[0]->x; pSprite->hotPhys.y += newScreen->y - screenInfo.screens[0]->y; @@ -3489,12 +3512,12 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) } } else -#endif +#endif /* XINERAMA */ if (newScreen != pSprite->hotPhys.pScreen) ConfineCursorToWindow(ptr, newScreen->root, TRUE, FALSE); } -#ifdef PANORAMIX +#ifdef XINERAMA static Bool XineramaPointInWindowIsVisible(WindowPtr pWin, int x, int y) @@ -3601,7 +3624,7 @@ XineramaWarpPointer(ClientPtr client) return Success; } -#endif +#endif /* XINERAMA */ /** * Server-side protocol handling for WarpPointer request. @@ -3623,7 +3646,7 @@ ProcWarpPointer(ClientPtr client) for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { if (GetMaster(tmp, MASTER_ATTACHED) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess); + rc = XaceHookDeviceAccess(client, dev, DixWriteAccess); if (rc != Success) return rc; } @@ -3633,10 +3656,10 @@ ProcWarpPointer(ClientPtr client) dev = dev->lastSlave; pSprite = dev->spriteInfo->sprite; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return XineramaWarpPointer(client); -#endif +#endif /* XINERAMA */ if (stuff->dstWid != None) { rc = dixLookupWindow(&dest, stuff->dstWid, client, DixGetAttrAccess); @@ -3715,7 +3738,7 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin) if (RegionNotEmpty(&pWin->borderSize)) return TRUE; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && XineramaSetWindowPntrs(pDev, pWin)) { int i; @@ -3725,7 +3748,7 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin) return TRUE; } } -#endif +#endif /* XINERAMA */ return FALSE; } @@ -3826,8 +3849,8 @@ void ActivateGrabNoDelivery(DeviceIntPtr dev, GrabPtr grab, (*grabinfo->ActivateGrab) (dev, grab, ClientTimeToServerTime(event->any.time), TRUE); - if (grabinfo->sync.state == FROZEN_NO_EVENT) - grabinfo->sync.state = FROZEN_WITH_EVENT; + if (grabinfo->sync.state == GRAB_STATE_FROZEN_NO_EVENT) + grabinfo->sync.state = GRAB_STATE_FROZEN_WITH_EVENT; CopyPartialInternalEvent(grabinfo->sync.event, real_event); } @@ -4210,7 +4233,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window) rc = EventToXI(event, &xE, &count); if (rc == Success && - XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, xE, count) == Success) { + XaceHookSendAccess(NULL, keybd, focus, xE, count) == Success) { FixUpEventFromWindow(ptr->spriteInfo->sprite, xE, focus, None, FALSE); deliveries = DeliverEventsToWindow(keybd, focus, xE, count, GetEventFilter(keybd, xE), NullGrab); @@ -4226,7 +4249,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window) if (sendCore) { rc = EventToCore(event, &core, &count); if (rc == Success) { - if (XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, core, count) == + if (XaceHookSendAccess(NULL, keybd, focus, core, count) == Success) { FixUpEventFromWindow(keybd->spriteInfo->sprite, core, focus, None, FALSE); @@ -4299,10 +4322,8 @@ DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev, if (rc == Success) { FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE); - if (XaceHook(XACE_SEND_ACCESS, 0, dev, - grab->window, xE, count) || - XaceHook(XACE_RECEIVE_ACCESS, rClient(grab), - grab->window, xE, count)) + if (XaceHookSendAccess(0, dev, grab->window, xE, count) || + XaceHookReceiveAccess(rClient(grab), grab->window, xE, count)) deliveries = 1; /* don't send, but pretend we did */ else if (level != CORE || !IsInterferingGrab(rClient(grab), dev, xE)) { deliveries = TryClientEvents(rClient(grab), dev, @@ -4395,20 +4416,20 @@ FreezeThisEventIfNeededForSyncGrab(DeviceIntPtr thisDev, InternalEvent *event) DeviceIntPtr dev; switch (grabinfo->sync.state) { - case FREEZE_BOTH_NEXT_EVENT: + case GRAB_STATE_FREEZE_BOTH_NEXT_EVENT: dev = GetPairedDevice(thisDev); if (dev) { FreezeThaw(dev, TRUE); - if ((dev->deviceGrab.sync.state == FREEZE_BOTH_NEXT_EVENT) && + if ((dev->deviceGrab.sync.state == GRAB_STATE_FREEZE_BOTH_NEXT_EVENT) && (CLIENT_BITS(grab->resource) == CLIENT_BITS(dev->deviceGrab.grab->resource))) - dev->deviceGrab.sync.state = FROZEN_NO_EVENT; + dev->deviceGrab.sync.state = GRAB_STATE_FROZEN_NO_EVENT; else dev->deviceGrab.sync.other = grab; } /* fall through */ - case FREEZE_NEXT_EVENT: - grabinfo->sync.state = FROZEN_WITH_EVENT; + case GRAB_STATE_FREEZE_NEXT_EVENT: + grabinfo->sync.state = GRAB_STATE_FROZEN_WITH_EVENT; FreezeThaw(thisDev, TRUE); CopyPartialInternalEvent(grabinfo->sync.event, event); break; @@ -4528,7 +4549,7 @@ EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask) } check = (mask & ManagerMask); if (check) { - rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, + rc = XaceHookResourceAccess(client, pWin->drawable.id, X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_NONE, NULL, DixManageAccess); if (rc != Success) return rc; @@ -4702,7 +4723,7 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse, ClientPtr client = grab ? rClient(grab) : wClient(pWin); int rc; - rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess); + rc = XaceHookDeviceAccess(client, keybd, DixReadAccess); if (rc == Success) memcpy((char *) &ke.map[0], (char *) &keybd->key->down[1], 31); @@ -4813,7 +4834,7 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin) ClientPtr client = wClient(pWin); int rc; - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess); + rc = XaceHookDeviceAccess(client, dev, DixReadAccess); if (rc == Success) memcpy((char *) &ke.map[0], (char *) &dev->key->down[1], 31); @@ -4876,7 +4897,7 @@ SetInputFocus(ClientPtr client, if (!focusWin->realized) return BadMatch; } - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixSetFocusAccess); + rc = XaceHookDeviceAccess(client, dev, DixSetFocusAccess); if (rc != Success) return Success; @@ -4954,7 +4975,7 @@ ProcGetInputFocus(ClientPtr client) /* REQUEST(xReq); */ REQUEST_SIZE_MATCH(xReq); - rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetFocusAccess); + rc = XaceHookDeviceAccess(client, kbd, DixGetFocusAccess); if (rc != Success) return rc; @@ -5188,7 +5209,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev, if (keyboard_mode == GrabModeSync || pointer_mode == GrabModeSync) access_mode |= DixFreezeAccess; - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); + rc = XaceHookDeviceAccess(client, dev, access_mode); if (rc != Success) return rc; @@ -5327,7 +5348,7 @@ ProcQueryPointer(ClientPtr client) rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); if (rc != Success) return rc; - rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess); + rc = XaceHookDeviceAccess(client, mouse, DixReadAccess); if (rc != Success && rc != BadAccess) return rc; @@ -5362,7 +5383,7 @@ ProcQueryPointer(ClientPtr client) rep.winY = 0; } -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { rep.rootX += screenInfo.screens[0]->x; rep.rootY += screenInfo.screens[0]->y; @@ -5371,7 +5392,7 @@ ProcQueryPointer(ClientPtr client) rep.winY += screenInfo.screens[0]->y; } } -#endif +#endif /* XINERAMA */ if (rc == BadAccess) { rep.mask = 0; @@ -5529,8 +5550,7 @@ ProcSendEvent(ClientPtr client) stuff->event.u.u.type |= SEND_EVENT_BIT; if (stuff->propagate) { for (; pWin; pWin = pWin->parent) { - if (XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, - &stuff->event, 1)) + if (XaceHookSendAccess(client, NULL, pWin, &stuff->event, 1)) return Success; if (DeliverEventsToWindow(dev, pWin, &stuff->event, 1, stuff->eventMask, @@ -5543,7 +5563,7 @@ ProcSendEvent(ClientPtr client) break; } } - else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, &stuff->event, 1)) + else if (!XaceHookSendAccess(client, NULL, pWin, &stuff->event, 1)) DeliverEventsToWindow(dev, pWin, &stuff->event, 1, stuff->eventMask, NullGrab); return Success; @@ -5727,7 +5747,7 @@ ProcGrabButton(ClientPtr client) if (stuff->pointerMode == GrabModeSync || stuff->keyboardMode == GrabModeSync) access_mode |= DixFreezeAccess; - rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, access_mode); + rc = XaceHookDeviceAccess(client, ptr, access_mode); if (rc != Success) return rc; @@ -5921,10 +5941,10 @@ CheckCursorConfinement(WindowPtr pWin) WindowPtr confineTo; DeviceIntPtr pDev; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return; -#endif +#endif /* XINERMA */ for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if (DevHasCursor(pDev)) { @@ -5985,11 +6005,11 @@ ProcRecolorCursor(ClientPtr client) for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) displayed = (pscr == pSprite->screen); else -#endif +#endif /* XINERAMA */ displayed = (pscr == pSprite->hotPhys.pScreen); (*pscr->RecolorCursor) (PickPointer(client), pscr, pCursor, (pCursor == pSprite->current) && displayed); @@ -6014,9 +6034,9 @@ ProcRecolorCursor(ClientPtr client) void WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) { -#ifdef PANORAMIX +#ifdef XINERAMA xEvent eventCopy; -#endif +#endif /* XINERAMA */ xEvent *eventTo, *eventFrom; int i, eventlength = sizeof(xEvent); @@ -6030,7 +6050,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) /* Let XKB rewrite the state, as it depends on client preferences. */ XkbFilterEvents(pClient, count, events); -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && (screenInfo.screens[0]->x || screenInfo.screens[0]->y)) { switch (events->u.u.type) { @@ -6061,7 +6081,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) break; } } -#endif +#endif /* XINERAMA */ if (EventCallback) { EventInfoRec eventinfo; @@ -6133,7 +6153,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) int SetClientPointer(ClientPtr client, DeviceIntPtr device) { - int rc = XaceHook(XACE_DEVICE_ACCESS, client, device, DixUseAccess); + int rc = XaceHookDeviceAccess(client, device, DixUseAccess); if (rc != Success) return rc; diff --git a/dix/extension.c b/dix/extension.c index dbe6c0a97..fd1439957 100644 --- a/dix/extension.c +++ b/dix/extension.c @@ -44,9 +44,7 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -89,7 +87,7 @@ AddExtension(const char *name, int NumEvents, int NumErrors, return ((ExtensionEntry *) NULL); } - ext = calloc(sizeof(ExtensionEntry), 1); + ext = calloc(1, sizeof(ExtensionEntry)); if (!ext) return NULL; if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) { @@ -215,7 +213,7 @@ CloseDownExtensions(void) static Bool ExtensionAvailable(ClientPtr client, ExtensionEntry *ext) { - if (XaceHook(XACE_EXT_ACCESS, client, ext) != Success) + if (XaceHookExtAccess(client, ext) != Success) return FALSE; if (!ext->base) return FALSE; @@ -44,9 +44,7 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <assert.h> #include <X11/X.h> @@ -54,6 +52,7 @@ SOFTWARE. #include <X11/Xproto.h> #include "dix/gc_priv.h" +#include "os/osdep.h" #include "misc.h" #include "resource.h" @@ -549,7 +548,7 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus, } /* security creation/labeling check */ - *pStatus = XaceHook(XACE_RESOURCE_ACCESS, client, gcid, X11_RESTYPE_GC, pGC, + *pStatus = XaceHookResourceAccess(client, gcid, X11_RESTYPE_GC, pGC, X11_RESTYPE_NONE, NULL, DixCreateAccess | DixSetAttrAccess); if (*pStatus != Success) goto out; @@ -815,7 +814,8 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth) FreeGC(pGC, (XID) 0); pGC = (GCPtr) NULL; } - pGC->graphicsExposures = FALSE; + else + pGC->graphicsExposures = FALSE; return pGC; } diff --git a/dix/generate-atoms b/dix/generate-atoms new file mode 100755 index 000000000..780548919 --- /dev/null +++ b/dix/generate-atoms @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT OR X11 +# +# Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + +INPUT="$1" +OUTPUT="$2" + +do_line() { + local name="$1" + [ "$2" != "@" ] && return 0 + echo " if (MakeAtom(\"$name\", ${#name}, 1) != XA_$name)" + echo " AtomError();" +} + +cat > "$OUTPUT" << __END__ +/* THIS IS A GENERATED FILE + * + * Do not change! Changing this file implies a protocol change! + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xatom.h> + +#include "dix/dix_priv.h" + +#include "misc.h" +#include "dix.h" +void +MakePredeclaredAtoms(void) +{ +__END__ + +( grep '@' < "$INPUT" ) | ( while read l ; do do_line $l ; done ) >> "$OUTPUT" + +echo "}" >> "$OUTPUT" diff --git a/dix/gestures.c b/dix/gestures.c index 2c47abb09..6b0f24728 100644 --- a/dix/gestures.c +++ b/dix/gestures.c @@ -23,22 +23,21 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/eventconvert.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" #include "inputstr.h" #include "scrnintstr.h" -#include "dixgrabs.h" #include "eventstr.h" #include "exevents.h" #include "exglobals.h" #include "inpututils.h" #include "windowstr.h" -#include "mi.h" #define GESTURE_HISTORY_SIZE 100 @@ -115,10 +114,8 @@ void GestureEndGesture(GestureInfoPtr gi) { if (gi->has_listener) { - if (gi->listener.grab) { - FreeGrab(gi->listener.grab); - gi->listener.grab = NULL; - } + FreeGrab(gi->listener.grab); + gi->listener.grab = NULL; gi->listener.listener = 0; gi->has_listener = FALSE; } diff --git a/dix/getevents.c b/dix/getevents.c index c39ef3371..4cdd2b711 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -27,15 +27,21 @@ * Peter Hutterer <peter.hutterer@who-t.net> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include <math.h> +#include <limits.h> +#include <pixman.h> #include <X11/X.h> #include <X11/keysym.h> #include <X11/Xproto.h> -#include <math.h> -#include <limits.h> +#include <X11/extensions/XI.h> +#include <X11/extensions/XI2.h> +#include <X11/extensions/XIproto.h> +#include <X11/extensions/XKBproto.h> + +#include "dix/input_priv.h" +#include "mi/mi_priv.h" #include "misc.h" #include "resource.h" @@ -49,21 +55,15 @@ #include "eventstr.h" #include "eventconvert.h" #include "inpututils.h" -#include "mi.h" #include "windowstr.h" -#include <X11/extensions/XKBproto.h> #include "xkbsrv.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ -#include <X11/extensions/XI.h> -#include <X11/extensions/XI2.h> -#include <X11/extensions/XIproto.h> -#include <pixman.h> #include "exglobals.h" #include "exevents.h" #include "extnsionst.h" @@ -2139,7 +2139,7 @@ PostSyntheticMotion(DeviceIntPtr pDev, { DeviceEvent ev; -#ifdef PANORAMIX +#ifdef XINERAMA /* Translate back to the sprite screen since processInputProc will translate from sprite screen to screen 0 upon reentry to the DIX layer. */ @@ -2147,7 +2147,7 @@ PostSyntheticMotion(DeviceIntPtr pDev, x += screenInfo.screens[0]->x - screenInfo.screens[screen]->x; y += screenInfo.screens[0]->y - screenInfo.screens[screen]->y; } -#endif +#endif /* XINERAMA */ memset(&ev, 0, sizeof(DeviceEvent)); init_device_event(&ev, pDev, time, EVENT_SOURCE_NORMAL); diff --git a/dix/globals.c b/dix/globals.c index 65edfc11f..f0ce065df 100644 --- a/dix/globals.c +++ b/dix/globals.c @@ -44,13 +44,12 @@ SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" #include "misc.h" @@ -117,7 +116,5 @@ TimeStamp currentTime; int defaultColorVisualClass = -1; int monitorResolution = 0; -const char *display; -int displayfd = -1; Bool explicit_display = FALSE; char *ConnectionInfo; diff --git a/dix/glyphcurs.c b/dix/glyphcurs.c index 3ff6ae83e..012af910e 100644 --- a/dix/glyphcurs.c +++ b/dix/glyphcurs.c @@ -44,9 +44,9 @@ SOFTWARE. ************************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "dix/cursor_priv.h" #include "misc.h" #include <X11/fonts/fontstruct.h> diff --git a/dix/grabs.c b/dix/grabs.c index d6017bef2..8409a0bf8 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -45,27 +45,26 @@ SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> #include <X11/extensions/XI2.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/exevents_priv.h" #include "os/auth.h" +#include "os/client_priv.h" #include "misc.h" #include "windowstr.h" #include "inputstr.h" #include "cursorstr.h" -#include "dixgrabs.h" #include "xace.h" #include "exglobals.h" #include "inpututils.h" -#include "client.h" #define BITMASK(i) (((Mask)1) << ((i) & 31)) #define MASKIDX(i) ((i) >> 5) @@ -192,6 +191,8 @@ UngrabAllDevices(Bool kill_client) ErrorF("End list of ungrabbed devices\n"); } +static Bool CopyGrab(GrabPtr dst, const GrabPtr src); + GrabPtr AllocGrab(const GrabPtr src) { @@ -216,7 +217,7 @@ AllocGrab(const GrabPtr src) GrabPtr CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, WindowPtr window, enum InputLevel grabtype, GrabMask *mask, - GrabParameters *param, int type, + GrabParameters *param, int eventType, KeyCode keybut, /* key or button */ WindowPtr confineTo, CursorPtr cursor) { @@ -239,7 +240,7 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, grab->modifiersDetail.exact = param->modifiers; grab->modifiersDetail.pMask = NULL; grab->modifierDevice = modDevice; - grab->type = type; + grab->type = eventType; grab->grabtype = grabtype; grab->detail.exact = keybut; grab->detail.pMask = NULL; @@ -250,13 +251,13 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, if (grabtype == XI2) xi2mask_merge(grab->xi2mask, mask->xi2mask); return grab; - } void FreeGrab(GrabPtr pGrab) { - BUG_RETURN(!pGrab); + if (!pGrab) + return; free(pGrab->modifiersDetail.pMask); free(pGrab->detail.pMask); @@ -268,7 +269,7 @@ FreeGrab(GrabPtr pGrab) free(pGrab); } -Bool +static Bool CopyGrab(GrabPtr dst, const GrabPtr src) { Mask *mdetails_mask = NULL; @@ -548,7 +549,7 @@ AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab) if (pGrab->keyboardMode == GrabModeSync || pGrab->pointerMode == GrabModeSync) access_mode |= DixFreezeAccess; - rc = XaceHook(XACE_DEVICE_ACCESS, client, pGrab->device, access_mode); + rc = XaceHookDeviceAccess(client, pGrab->device, access_mode); if (rc != Success) return rc; diff --git a/dix/initatoms.c b/dix/initatoms.c deleted file mode 100644 index bcc38a0f1..000000000 --- a/dix/initatoms.c +++ /dev/null @@ -1,153 +0,0 @@ -/* THIS IS A GENERATED FILE - * - * Do not change! Changing this file implies a protocol change! - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xatom.h> -#include "misc.h" -#include "dix.h" -void -MakePredeclaredAtoms(void) -{ - if (MakeAtom("PRIMARY", 7, 1) != XA_PRIMARY) - AtomError(); - if (MakeAtom("SECONDARY", 9, 1) != XA_SECONDARY) - AtomError(); - if (MakeAtom("ARC", 3, 1) != XA_ARC) - AtomError(); - if (MakeAtom("ATOM", 4, 1) != XA_ATOM) - AtomError(); - if (MakeAtom("BITMAP", 6, 1) != XA_BITMAP) - AtomError(); - if (MakeAtom("CARDINAL", 8, 1) != XA_CARDINAL) - AtomError(); - if (MakeAtom("COLORMAP", 8, 1) != XA_COLORMAP) - AtomError(); - if (MakeAtom("CURSOR", 6, 1) != XA_CURSOR) - AtomError(); - if (MakeAtom("CUT_BUFFER0", 11, 1) != XA_CUT_BUFFER0) - AtomError(); - if (MakeAtom("CUT_BUFFER1", 11, 1) != XA_CUT_BUFFER1) - AtomError(); - if (MakeAtom("CUT_BUFFER2", 11, 1) != XA_CUT_BUFFER2) - AtomError(); - if (MakeAtom("CUT_BUFFER3", 11, 1) != XA_CUT_BUFFER3) - AtomError(); - if (MakeAtom("CUT_BUFFER4", 11, 1) != XA_CUT_BUFFER4) - AtomError(); - if (MakeAtom("CUT_BUFFER5", 11, 1) != XA_CUT_BUFFER5) - AtomError(); - if (MakeAtom("CUT_BUFFER6", 11, 1) != XA_CUT_BUFFER6) - AtomError(); - if (MakeAtom("CUT_BUFFER7", 11, 1) != XA_CUT_BUFFER7) - AtomError(); - if (MakeAtom("DRAWABLE", 8, 1) != XA_DRAWABLE) - AtomError(); - if (MakeAtom("FONT", 4, 1) != XA_FONT) - AtomError(); - if (MakeAtom("INTEGER", 7, 1) != XA_INTEGER) - AtomError(); - if (MakeAtom("PIXMAP", 6, 1) != XA_PIXMAP) - AtomError(); - if (MakeAtom("POINT", 5, 1) != XA_POINT) - AtomError(); - if (MakeAtom("RECTANGLE", 9, 1) != XA_RECTANGLE) - AtomError(); - if (MakeAtom("RESOURCE_MANAGER", 16, 1) != XA_RESOURCE_MANAGER) - AtomError(); - if (MakeAtom("RGB_COLOR_MAP", 13, 1) != XA_RGB_COLOR_MAP) - AtomError(); - if (MakeAtom("RGB_BEST_MAP", 12, 1) != XA_RGB_BEST_MAP) - AtomError(); - if (MakeAtom("RGB_BLUE_MAP", 12, 1) != XA_RGB_BLUE_MAP) - AtomError(); - if (MakeAtom("RGB_DEFAULT_MAP", 15, 1) != XA_RGB_DEFAULT_MAP) - AtomError(); - if (MakeAtom("RGB_GRAY_MAP", 12, 1) != XA_RGB_GRAY_MAP) - AtomError(); - if (MakeAtom("RGB_GREEN_MAP", 13, 1) != XA_RGB_GREEN_MAP) - AtomError(); - if (MakeAtom("RGB_RED_MAP", 11, 1) != XA_RGB_RED_MAP) - AtomError(); - if (MakeAtom("STRING", 6, 1) != XA_STRING) - AtomError(); - if (MakeAtom("VISUALID", 8, 1) != XA_VISUALID) - AtomError(); - if (MakeAtom("WINDOW", 6, 1) != XA_WINDOW) - AtomError(); - if (MakeAtom("WM_COMMAND", 10, 1) != XA_WM_COMMAND) - AtomError(); - if (MakeAtom("WM_HINTS", 8, 1) != XA_WM_HINTS) - AtomError(); - if (MakeAtom("WM_CLIENT_MACHINE", 17, 1) != XA_WM_CLIENT_MACHINE) - AtomError(); - if (MakeAtom("WM_ICON_NAME", 12, 1) != XA_WM_ICON_NAME) - AtomError(); - if (MakeAtom("WM_ICON_SIZE", 12, 1) != XA_WM_ICON_SIZE) - AtomError(); - if (MakeAtom("WM_NAME", 7, 1) != XA_WM_NAME) - AtomError(); - if (MakeAtom("WM_NORMAL_HINTS", 15, 1) != XA_WM_NORMAL_HINTS) - AtomError(); - if (MakeAtom("WM_SIZE_HINTS", 13, 1) != XA_WM_SIZE_HINTS) - AtomError(); - if (MakeAtom("WM_ZOOM_HINTS", 13, 1) != XA_WM_ZOOM_HINTS) - AtomError(); - if (MakeAtom("MIN_SPACE", 9, 1) != XA_MIN_SPACE) - AtomError(); - if (MakeAtom("NORM_SPACE", 10, 1) != XA_NORM_SPACE) - AtomError(); - if (MakeAtom("MAX_SPACE", 9, 1) != XA_MAX_SPACE) - AtomError(); - if (MakeAtom("END_SPACE", 9, 1) != XA_END_SPACE) - AtomError(); - if (MakeAtom("SUPERSCRIPT_X", 13, 1) != XA_SUPERSCRIPT_X) - AtomError(); - if (MakeAtom("SUPERSCRIPT_Y", 13, 1) != XA_SUPERSCRIPT_Y) - AtomError(); - if (MakeAtom("SUBSCRIPT_X", 11, 1) != XA_SUBSCRIPT_X) - AtomError(); - if (MakeAtom("SUBSCRIPT_Y", 11, 1) != XA_SUBSCRIPT_Y) - AtomError(); - if (MakeAtom("UNDERLINE_POSITION", 18, 1) != XA_UNDERLINE_POSITION) - AtomError(); - if (MakeAtom("UNDERLINE_THICKNESS", 19, 1) != XA_UNDERLINE_THICKNESS) - AtomError(); - if (MakeAtom("STRIKEOUT_ASCENT", 16, 1) != XA_STRIKEOUT_ASCENT) - AtomError(); - if (MakeAtom("STRIKEOUT_DESCENT", 17, 1) != XA_STRIKEOUT_DESCENT) - AtomError(); - if (MakeAtom("ITALIC_ANGLE", 12, 1) != XA_ITALIC_ANGLE) - AtomError(); - if (MakeAtom("X_HEIGHT", 8, 1) != XA_X_HEIGHT) - AtomError(); - if (MakeAtom("QUAD_WIDTH", 10, 1) != XA_QUAD_WIDTH) - AtomError(); - if (MakeAtom("WEIGHT", 6, 1) != XA_WEIGHT) - AtomError(); - if (MakeAtom("POINT_SIZE", 10, 1) != XA_POINT_SIZE) - AtomError(); - if (MakeAtom("RESOLUTION", 10, 1) != XA_RESOLUTION) - AtomError(); - if (MakeAtom("COPYRIGHT", 9, 1) != XA_COPYRIGHT) - AtomError(); - if (MakeAtom("NOTICE", 6, 1) != XA_NOTICE) - AtomError(); - if (MakeAtom("FONT_NAME", 9, 1) != XA_FONT_NAME) - AtomError(); - if (MakeAtom("FAMILY_NAME", 11, 1) != XA_FAMILY_NAME) - AtomError(); - if (MakeAtom("FULL_NAME", 9, 1) != XA_FULL_NAME) - AtomError(); - if (MakeAtom("CAP_HEIGHT", 10, 1) != XA_CAP_HEIGHT) - AtomError(); - if (MakeAtom("WM_CLASS", 8, 1) != XA_WM_CLASS) - AtomError(); - if (MakeAtom("WM_TRANSIENT_FOR", 16, 1) != XA_WM_TRANSIENT_FOR) - AtomError(); -} diff --git a/dix/input_priv.h b/dix/input_priv.h new file mode 100644 index 000000000..69802e077 --- /dev/null +++ b/dix/input_priv.h @@ -0,0 +1,364 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + + Copyright © 1987, 1998 The Open Group + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +/************************************************************ + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +********************************************************/ +#ifndef _XSERVER_INPUT_PRIV_H +#define _XSERVER_INPUT_PRIV_H + +#include "input.h" + +void InitCoreDevices(void); +void InitXTestDevices(void); + +void DisableAllDevices(void); +int InitAndStartDevices(void); + +void CloseDownDevices(void); +void AbortDevices(void); + +void UndisplayDevices(void); + +ValuatorClassPtr AllocValuatorClass(ValuatorClassPtr src, int numAxes); +void FreeDeviceClass(int type, void **class); + +int ApplyPointerMapping(DeviceIntPtr pDev, + CARD8 *map, + int len, + ClientPtr client); + +Bool BadDeviceMap(BYTE *buff, + int length, + unsigned low, + unsigned high, + XID *errval); + +void NoteLedState(DeviceIntPtr keybd, int led, Bool on); + +void MaybeStopHint(DeviceIntPtr device, ClientPtr client ); + +void ProcessPointerEvent(InternalEvent *ev, DeviceIntPtr mouse); + +void ProcessKeyboardEvent(InternalEvent *ev, DeviceIntPtr keybd); + +void CreateClassesChangedEvent(InternalEvent *event, + DeviceIntPtr master, + DeviceIntPtr slave, + int flags); + +InternalEvent *UpdateFromMaster(InternalEvent *events, + DeviceIntPtr pDev, + int type, + int *num_events); + +void PostSyntheticMotion(DeviceIntPtr pDev, + int x, + int y, + int screen, + unsigned long time); + +void ReleaseButtonsAndKeys(DeviceIntPtr dev); + +int AttachDevice(ClientPtr client, DeviceIntPtr slave, DeviceIntPtr master); + +void DeepCopyDeviceClasses(DeviceIntPtr from, + DeviceIntPtr to, + DeviceChangedEvent *dce); + +int change_modmap(ClientPtr client, + DeviceIntPtr dev, + KeyCode *map, + int max_keys_per_mod); + +int AllocXTestDevice(ClientPtr client, + const char *name, + DeviceIntPtr *ptr, + DeviceIntPtr *keybd, + DeviceIntPtr master_ptr, + DeviceIntPtr master_keybd); +BOOL IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master); +DeviceIntPtr GetXTestDevice(DeviceIntPtr master); + +void SendDevicePresenceEvent(int deviceid, int type); +void DeliverDeviceClassesChangedEvent(int sourceid, Time time); + +/* touch support */ +int GetTouchEvents(InternalEvent *events, + DeviceIntPtr pDev, + uint32_t ddx_touchid, + uint16_t type, + uint32_t flags, + const ValuatorMask *mask); +void QueueTouchEvents(DeviceIntPtr device, + int type, + uint32_t ddx_touchid, + int flags, const ValuatorMask *mask); +int GetTouchOwnershipEvents(InternalEvent *events, + DeviceIntPtr pDev, + TouchPointInfoPtr ti, + uint8_t mode, + XID resource, + uint32_t flags); +void GetDixTouchEnd(InternalEvent *ievent, + DeviceIntPtr dev, + TouchPointInfoPtr ti, + uint32_t flags); +void TouchInitDDXTouchPoint(DeviceIntPtr dev, DDXTouchPointInfoPtr ddxtouch); +DDXTouchPointInfoPtr TouchBeginDDXTouch(DeviceIntPtr dev, uint32_t ddx_id); +void TouchEndDDXTouch(DeviceIntPtr dev, DDXTouchPointInfoPtr ti); +DDXTouchPointInfoPtr TouchFindByDDXID(DeviceIntPtr dev, + uint32_t ddx_id, + Bool create); +Bool TouchInitTouchPoint(TouchClassPtr touch, ValuatorClassPtr v, int index); +void TouchFreeTouchPoint(DeviceIntPtr dev, int index); +TouchPointInfoPtr TouchBeginTouch(DeviceIntPtr dev, + int sourceid, + uint32_t touchid, + Bool emulate_pointer); +TouchPointInfoPtr TouchFindByClientID(DeviceIntPtr dev, uint32_t client_id); +void TouchEndTouch(DeviceIntPtr dev, TouchPointInfoPtr ti); +Bool TouchEventHistoryAllocate(TouchPointInfoPtr ti); +void TouchEventHistoryFree(TouchPointInfoPtr ti); +void TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev); +void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource); +Bool TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource); +void TouchAddListener(TouchPointInfoPtr ti, + XID resource, + int resource_type, + enum InputLevel level, + enum TouchListenerType type, + enum TouchListenerState state, + WindowPtr window, + GrabPtr grab); +Bool TouchRemoveListener(TouchPointInfoPtr ti, XID resource); +void TouchSetupListeners(DeviceIntPtr dev, + TouchPointInfoPtr ti, + InternalEvent *ev); +Bool TouchBuildSprite(DeviceIntPtr sourcedev, + TouchPointInfoPtr ti, + InternalEvent *ev); +Bool TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite); +int TouchConvertToPointerEvent(const InternalEvent *ev, + InternalEvent *motion, + InternalEvent *button); +int TouchGetPointerEventType(const InternalEvent *ev); +void TouchRemovePointerGrab(DeviceIntPtr dev); +void TouchListenerGone(XID resource); +int TouchListenerAcceptReject(DeviceIntPtr dev, + TouchPointInfoPtr ti, + int listener, + int mode); +int TouchAcceptReject(ClientPtr client, + DeviceIntPtr dev, + int mode, + uint32_t touchid, + Window grab_window, + XID *error); +void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev); +void TouchEmitTouchEnd(DeviceIntPtr dev, + TouchPointInfoPtr ti, + int flags, + XID resource); +void TouchAcceptAndEnd(DeviceIntPtr dev, int touchid); + +/* Gesture support */ +void InitGestureEvent(InternalEvent *ievent, + DeviceIntPtr dev, + CARD32 ms, + int type, + uint16_t num_touches, + uint32_t flags, + double delta_x, + double delta_y, + double delta_unaccel_x, + double delta_unaccel_y, + double scale, + double delta_angle); +int GetGestureEvents(InternalEvent *events, + DeviceIntPtr dev, + uint16_t type, + uint16_t num_touches, + uint32_t flags, + double delta_x, + double delta_y, + double delta_unaccel_x, + double delta_unaccel_y, + double scale, + double delta_angle); +void QueueGesturePinchEvents(DeviceIntPtr dev, + uint16_t type, + uint16_t num_touches, + uint32_t flags, + double delta_x, + double delta_y, + double delta_unaccel_x, + double delta_unaccel_y, + double scale, + double delta_angle); +void QueueGestureSwipeEvents(DeviceIntPtr dev, + uint16_t type, + uint16_t num_touches, + uint32_t flags, + double delta_x, + double delta_y, + double delta_unaccel_x, + double delta_unaccel_y); +Bool GestureInitGestureInfo(GestureInfoPtr gesture); +void GestureFreeGestureInfo(GestureInfoPtr gesture); +GestureInfoPtr GestureBeginGesture(DeviceIntPtr dev, InternalEvent *ev); +GestureInfoPtr GestureFindActiveByEventType(DeviceIntPtr dev, int type); +void GestureEndGesture(GestureInfoPtr gi); +Bool GestureResourceIsOwner(GestureInfoPtr gi, XID resource); +void GestureAddListener(GestureInfoPtr gi, + XID resource, + int resource_type, + enum GestureListenerType type, + WindowPtr window, + GrabPtr grab); +void GestureSetupListener(DeviceIntPtr dev, GestureInfoPtr gi, InternalEvent *ev); +Bool GestureBuildSprite(DeviceIntPtr sourcedev, GestureInfoPtr gi); +void GestureListenerGone(XID resource); +void GestureEndActiveGestures(DeviceIntPtr dev); +void GestureEmitGestureEndToOwner(DeviceIntPtr dev, GestureInfoPtr gi); +void ProcessGestureEvent(InternalEvent *ev, DeviceIntPtr dev); + +/* misc event helpers */ +void CopyPartialInternalEvent(InternalEvent* dst_event, + const InternalEvent* src_event); +Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients); +Mask GetEventFilter(DeviceIntPtr dev, xEvent *event); +Bool WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent *ev); +int GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type); +void FixUpEventFromWindow(SpritePtr pSprite, + xEvent *xE, + WindowPtr pWin, + Window child, + Bool calcChild); +Bool PointInBorderSize(WindowPtr pWin, int x, int y); +WindowPtr XYToWindow(SpritePtr pSprite, int x, int y); +int EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win); +Bool ActivatePassiveGrab(DeviceIntPtr dev, + GrabPtr grab, + InternalEvent *ev, + InternalEvent *real_event); +void ActivateGrabNoDelivery(DeviceIntPtr dev, + GrabPtr grab, + InternalEvent *event, + InternalEvent *real_event); + +/* states for device grabs */ + +#define GRAB_STATE_NOT_GRABBED 0 +#define GRAB_STATE_THAWED 1 +#define GRAB_STATE_THAWED_BOTH 2 /* not a real state */ +#define GRAB_STATE_FREEZE_NEXT_EVENT 3 +#define GRAB_STATE_FREEZE_BOTH_NEXT_EVENT 4 +#define GRAB_STATE_FROZEN 5 /* any state >= has device frozen */ +#define GRAB_STATE_FROZEN_NO_EVENT 5 +#define GRAB_STATE_FROZEN_WITH_EVENT 6 +#define GRAB_STATE_THAW_OTHERS 7 + +/** + * Masks specifying the type of event to deliver for an InternalEvent; used + * by EventIsDeliverable. + * @defgroup EventIsDeliverable return flags + * @{ + */ +#define EVENT_XI1_MASK (1 << 0) /**< XI1.x event */ +#define EVENT_CORE_MASK (1 << 1) /**< Core event */ +#define EVENT_DONT_PROPAGATE_MASK (1 << 2) /**< DontPropagate mask set */ +#define EVENT_XI2_MASK (1 << 3) /**< XI2 mask set on window */ +/* @} */ + +enum EventDeliveryState { + EVENT_DELIVERED, /**< Event has been delivered to a client */ + EVENT_NOT_DELIVERED, /**< Event was not delivered to any client */ + EVENT_SKIP, /**< Event can be discarded by the caller */ + EVENT_REJECTED, /**< Event was rejected for delivery to the client */ +}; + +#define VALUATOR_MODE_ALL_AXES -1 +int valuator_get_mode(DeviceIntPtr dev, int axis); +void valuator_set_mode(DeviceIntPtr dev, int axis, int mode); + +/* Set to TRUE by default - os/utils.c sets it to FALSE on user request, + xfixes/cursor.c uses it to determine if the cursor is enabled */ +extern Bool EnableCursor; + +/* Set to FALSE by default - ChangeWindowAttributes sets it to TRUE on + * CWCursor, xfixes/cursor.c uses it to determine if the cursor is enabled + */ +extern Bool CursorVisible; + +void valuator_mask_drop_unaccelerated(ValuatorMask *mask); + +Bool point_on_screen(ScreenPtr pScreen, int x, int y); +void update_desktop_dimensions(void); + +void input_constrain_cursor(DeviceIntPtr pDev, + ScreenPtr screen, + int current_x, + int current_y, + int dest_x, + int dest_y, + int *out_x, + int *out_y, + int *nevents, + InternalEvent* events); + +void InputThreadPreInit(void); +void InputThreadInit(void); +void InputThreadFini(void); + +int InputThreadRegisterDev(int fd, + NotifyFdProcPtr readInputProc, + void *readInputArgs); + +int InputThreadUnregisterDev(int fd); + +#endif /* _XSERVER_INPUT_PRIV_H */ diff --git a/dix/inpututils.c b/dix/inpututils.c index 240d0ff8a..f6b383ebc 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -23,15 +23,13 @@ * Author: Daniel Stone <daniel@fooishbar.org> */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include "dix/exevents_priv.h" +#include "dix/input_priv.h" #include "exglobals.h" #include "misc.h" -#include "input.h" #include "inputstr.h" #include "xace.h" #include "xkbsrv.h" @@ -54,7 +52,7 @@ check_butmap_change(DeviceIntPtr dev, CARD8 *map, int len, CARD32 *errval_out, return BadDevice; } - ret = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); + ret = XaceHookDeviceAccess(client, dev, DixManageAccess); if (ret != Success) { client->errorValue = dev->id; return ret; @@ -135,7 +133,7 @@ check_modmap_change(ClientPtr client, DeviceIntPtr dev, KeyCode *modmap) int ret, i; XkbDescPtr xkb; - ret = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); + ret = XaceHookDeviceAccess(client, dev, DixManageAccess); if (ret != Success) return ret; @@ -293,7 +291,7 @@ generate_modkeymap(ClientPtr client, DeviceIntPtr dev, KeyCode *modkeymap = NULL; int i, j, ret; - ret = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGetAttrAccess); + ret = XaceHookDeviceAccess(client, dev, DixGetAttrAccess); if (ret != Success) return ret; diff --git a/dix/main.c b/dix/main.c index 263bce602..0c57ba605 100644 --- a/dix/main.c +++ b/dix/main.c @@ -73,25 +73,31 @@ Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #include <version-config.h> -#endif +#include <pixman.h> #include <X11/X.h> #include <X11/Xos.h> /* for unistd.h */ #include <X11/Xproto.h> -#include <pixman.h> +#include <X11/fonts/font.h> +#include <X11/fonts/fontstruct.h> +#include <X11/fonts/libxfont2.h> +#include "config/hotplug_priv.h" #include "dix/callback_priv.h" +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "dix/gc_priv.h" #include "dix/registry_priv.h" #include "os/audit.h" #include "os/auth.h" +#include "os/client_priv.h" #include "os/cmdline.h" #include "os/ddx_priv.h" #include "os/osdep.h" +#include "os/screensaver.h" #include "scrnintstr.h" #include "misc.h" @@ -105,22 +111,16 @@ Equipment Corporation. #include "colormapst.h" #include "cursorstr.h" #include "selection.h" -#include <X11/fonts/font.h> -#include <X11/fonts/fontstruct.h> -#include <X11/fonts/libxfont2.h> -#include "opaque.h" #include "servermd.h" -#include "hotplug.h" #include "dixfont.h" #include "extnsionst.h" #include "privates.h" -#include "client.h" #include "exevents.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiXsrv.h" #else #include "dixevents.h" /* InitEvents() */ -#endif +#endif /* XINERAMA */ #ifdef DPMSExtension #include <X11/extensions/dpmsconst.h> @@ -163,7 +163,7 @@ dix_main(int argc, char *argv[], char *envp[]) CreateWellKnownSockets(); for (i = 1; i < LimitClients; i++) clients[i] = NullClient; - serverClient = calloc(sizeof(ClientRec), 1); + serverClient = calloc(1, sizeof(ClientRec)); if (!serverClient) FatalError("couldn't create server client"); InitClient(serverClient, 0, (void *) NULL); @@ -237,17 +237,19 @@ dix_main(int argc, char *argv[], char *envp[]) FatalError("could not open default font"); } - if (!(rootCursor = CreateRootCursor(NULL, 0))) { + if (!(rootCursor = CreateRootCursor())) { FatalError("could not open default cursor font"); } -#ifdef PANORAMIX + rootCursor = RefCursor(rootCursor); + +#ifdef XINERAMA /* * Consolidate window and colourmap information for each screen */ if (!noPanoramiXExtension) PanoramiXConsolidate(); -#endif +#endif /* XINERAMA */ for (i = 0; i < screenInfo.numScreens; i++) InitRootWindow(screenInfo.screens[i]->root); @@ -261,14 +263,14 @@ dix_main(int argc, char *argv[], char *envp[]) dixCloseRegistry(); -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { if (!PanoramiXCreateConnectionBlock()) { FatalError("could not create connection block info"); } } else -#endif +#endif /* XINERAMA */ { if (!CreateConnectionBlock()) { FatalError("could not create connection block info"); @@ -281,6 +283,8 @@ dix_main(int argc, char *argv[], char *envp[]) Dispatch(); + UnrefCursor(rootCursor); + UndisplayDevices(); DisableAllDevices(); @@ -290,7 +294,7 @@ dix_main(int argc, char *argv[], char *envp[]) FreeScreenSaverTimer(); CloseDownExtensions(); -#ifdef PANORAMIX +#ifdef XINERAMA { Bool remember_it = noPanoramiXExtension; @@ -300,7 +304,7 @@ dix_main(int argc, char *argv[], char *envp[]) } #else FreeAllResources(); -#endif +#endif /* XINERAMA */ CloseInput(); diff --git a/dix/meson.build b/dix/meson.build index 0b5cfbf8f..78f3b1f9e 100644 --- a/dix/meson.build +++ b/dix/meson.build @@ -5,6 +5,7 @@ srcs_dix = [ 'cursor.c', 'devices.c', 'dispatch.c', + 'display.c', 'dixfonts.c', 'main.c', 'dixutils.c', @@ -18,7 +19,6 @@ srcs_dix = [ 'globals.c', 'glyphcurs.c', 'grabs.c', - 'initatoms.c', 'inpututils.c', 'pixmap.c', 'privates.c', @@ -35,6 +35,13 @@ srcs_dix = [ 'window.c', ] +atom_generator = generator( + find_program('generate-atoms'), + output: '@BASENAME@.c', + arguments : ['@INPUT@', '@OUTPUT@']) + +builtinatoms_src = atom_generator.process('BuiltInAtoms') + dtrace_src = [] if with_dtrace dtrace_object = generator(dtrace, @@ -48,7 +55,7 @@ endif dtrace_dep = declare_dependency(sources: [dtrace_src, dtrace_hdr]) libxserver_dix = static_library('libxserver_dix', - srcs_dix, + [ srcs_dix, builtinatoms_src ], include_directories: inc, dependencies: [ dtrace_dep, common_dep, ] ) diff --git a/dix/pixmap.c b/dix/pixmap.c index a58795c78..020ceb83a 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -26,13 +26,14 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> +#include <X11/extensions/render.h> + +#include "mi/mi_priv.h" + #include "scrnintstr.h" -#include "mi.h" #include "misc.h" #include "os.h" #include "windowstr.h" @@ -40,7 +41,6 @@ from The Open Group. #include "dixstruct.h" #include "gcstruct.h" #include "servermd.h" -#include "X11/extensions/render.h" #include "picturestr.h" #include "randrstr.h" /* @@ -278,9 +278,15 @@ PixmapDirtyCopyArea(PixmapPtr dst, DrawablePtr src, w = dst_box.x2 - dst_box.x1; h = dst_box.y2 - dst_box.y1; - pGC->ops->CopyArea(src, &dst->drawable, pGC, - x + dst_box.x1, y + dst_box.y1, w, h, - dst_x + dst_box.x1, dst_y + dst_box.y1); + (void) pGC->ops->CopyArea(src, + &dst->drawable, + pGC, + x + dst_box.x1, + y + dst_box.y1, + w, + h, + dst_x + dst_box.x1, + dst_y + dst_box.y1); b++; } FreeScratchGC(pGC); diff --git a/dix/privates.c b/dix/privates.c index 01686637c..62309d769 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -48,9 +48,7 @@ from The Open Group. * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> #include "windowstr.h" @@ -413,7 +411,7 @@ dixRegisterScreenPrivateKey(DevScreenPrivateKey screenKey, ScreenPtr pScreen, assert(key->type == type); return TRUE; } - key = calloc(sizeof(DevPrivateKeyRec), 1); + key = calloc(1, sizeof(DevPrivateKeyRec)); if (!key) return FALSE; if (!dixRegisterPrivateKey(key, type, size)) { diff --git a/dix/property.c b/dix/property.c index 22f4d1603..e5e579f95 100644 --- a/dix/property.c +++ b/dix/property.c @@ -44,14 +44,13 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> #include "dix/dix_priv.h" +#include "dix/property_priv.h" #include "windowstr.h" #include "propertyst.h" @@ -279,11 +278,13 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, if (!pProp) return BadAlloc; data = malloc(totalSize); - if (!data && len) { - dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); - return BadAlloc; + if (totalSize) { + if (!data) { + dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); + return BadAlloc; + } + memcpy(data, value, totalSize); } - memcpy(data, value, totalSize); pProp->propertyName = property; pProp->type = type; pProp->format = format; @@ -316,9 +317,11 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, if (mode == PropModeReplace) { data = malloc(totalSize); - if (!data && len) - return BadAlloc; - memcpy(data, value, totalSize); + if (totalSize) { + if (!data) + return BadAlloc; + memcpy(data, value, totalSize); + } pProp->data = data; pProp->size = len; pProp->type = type; @@ -588,17 +591,20 @@ ProcListProperties(ClientPtr client) for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) numProps++; - if (numProps && !(pAtoms = xallocarray(numProps, sizeof(Atom)))) - return BadAlloc; - - numProps = 0; - temppAtoms = pAtoms; - for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) { - realProp = pProp; - rc = XaceHookPropertyAccess(client, pWin, &realProp, DixGetAttrAccess); - if (rc == Success && realProp == pProp) { - *temppAtoms++ = pProp->propertyName; - numProps++; + if (numProps) { + pAtoms = xallocarray(numProps, sizeof(Atom)); + if (!pAtoms) + return BadAlloc; + + numProps = 0; + temppAtoms = pAtoms; + for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) { + realProp = pProp; + rc = XaceHookPropertyAccess(client, pWin, &realProp, DixGetAttrAccess); + if (rc == Success && realProp == pProp) { + *temppAtoms++ = pProp->propertyName; + numProps++; + } } } @@ -612,8 +618,8 @@ ProcListProperties(ClientPtr client) if (numProps) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); + free(pAtoms); } - free(pAtoms); return Success; } diff --git a/mi/mifillrct.c b/dix/property_priv.h index eb98a779e..38ad2da4b 100644 --- a/mi/mifillrct.c +++ b/dix/property_priv.h @@ -1,3 +1,8 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 1987, 1998 The Open Group + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -43,90 +48,26 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif +#ifndef _XSERVER_PROPERTY_PRIV_H +#define _XSERVER_PROPERTY_PRIV_H #include <X11/X.h> -#include <X11/Xprotostr.h> -#include "gcstruct.h" -#include "windowstr.h" -#include "pixmap.h" -#include "mi.h" -#include "misc.h" - -/* mi rectangles - written by newman, with debts to all and sundry -*/ - -/* MIPOLYFILLRECT -- public entry for PolyFillRect request - * very straight forward: translate rectangles if necessary - * then call FillSpans to fill each rectangle. We let FillSpans worry about - * clipping to the destination - */ -_X_COLD void -miPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, /* number of rectangles to fill */ - xRectangle *prectInit /* Pointer to first rectangle to fill */ - ) -{ - int i; - int height; - int width; - xRectangle *prect; - int xorg; - int yorg; - int maxheight; - DDXPointPtr pptFirst; - DDXPointPtr ppt; - int *pwFirst; - int *pw; - - if (pGC->miTranslate) { - xorg = pDrawable->x; - yorg = pDrawable->y; - prect = prectInit; - maxheight = 0; - for (i = 0; i < nrectFill; i++, prect++) { - prect->x += xorg; - prect->y += yorg; - maxheight = max(maxheight, prect->height); - } - } - else { - prect = prectInit; - maxheight = 0; - for (i = 0; i < nrectFill; i++, prect++) - maxheight = max(maxheight, prect->height); - } - - pptFirst = xallocarray(maxheight, sizeof(DDXPointRec)); - pwFirst = xallocarray(maxheight, sizeof(int)); - if (!pptFirst || !pwFirst) { - free(pwFirst); - free(pptFirst); - return; - } - - prect = prectInit; - while (nrectFill--) { - ppt = pptFirst; - pw = pwFirst; - height = prect->height; - width = prect->width; - xorg = prect->x; - yorg = prect->y; - while (height--) { - *pw++ = width; - ppt->x = xorg; - ppt->y = yorg; - ppt++; - yorg++; - } - (*pGC->ops->FillSpans) (pDrawable, pGC, - prect->height, pptFirst, pwFirst, 1); - prect++; - } - free(pwFirst); - free(pptFirst); -} + +#include "dix.h" +#include "window.h" +#include "property.h" + +typedef struct _PropertyStateRec { + WindowPtr win; + PropertyPtr prop; + int state; +} PropertyStateRec; + +extern CallbackListPtr PropertyStateCallback; + +int dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom proprty, + ClientPtr pClient, Mask access_mode); + +void DeleteAllWindowProperties(WindowPtr pWin); + +#endif /* _XSERVER_PROPERTY_PRIV_H */ diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 5166288e8..192c0f5bb 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -22,9 +22,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <math.h> @@ -146,6 +144,7 @@ InitPredictableAccelerationScheme(DeviceIntPtr dev, schemeData->vel = vel; scheme.accelData = schemeData; if (!InitializePredictableAccelerationProperties(dev, vel, schemeData)) { + FreeVelocityData(vel); free(vel); free(schemeData); return FALSE; diff --git a/dix/ptrveloc_priv.h b/dix/ptrveloc_priv.h index a96401b90..da834e955 100644 --- a/dix/ptrveloc_priv.h +++ b/dix/ptrveloc_priv.h @@ -14,23 +14,15 @@ struct _DeviceVelocityRec; /** - * profile - * returns actual acceleration depending on velocity, acceleration control,... - */ -typedef double (*PointerAccelerationProfileFunc) - (DeviceIntPtr dev, struct _DeviceVelocityRec * vel, - double velocity, double threshold, double accelCoeff); - -/** * a motion history, with just enough information to * calc mean velocity and decide which motion was along * a more or less straight line */ -typedef struct _MotionTracker { +struct _MotionTracker { double dx, dy; /* accumulated delta for each axis */ int time; /* time of creation */ int dir; /* initial direction bitfield */ -} MotionTracker, *MotionTrackerPtr; +}; /** * contains the run-time data for the predictable scheme, that is, a diff --git a/dix/region.c b/dix/region.c index 5c83f8a04..00c804ea2 100644 --- a/dix/region.c +++ b/dix/region.c @@ -75,9 +75,7 @@ Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "regionstr.h" #include <X11/Xprotostr.h> diff --git a/dix/registry.c b/dix/registry.c index e04a26727..c37dbce5d 100644 --- a/dix/registry.c +++ b/dix/registry.c @@ -17,9 +17,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> #include <string.h> diff --git a/dix/resource.c b/dix/resource.c index f6fa42247..7542f0c42 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -117,14 +117,15 @@ Equipment Corporation. * resource "owned" by the client. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> +#include "dix/colormap_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/gc_priv.h" #include "dix/registry_priv.h" +#include "os/osdep.h" #include "misc.h" #include "os.h" @@ -135,13 +136,11 @@ Equipment Corporation. #include "dixfont.h" #include "colormap.h" #include "inputstr.h" -#include "dixevents.h" -#include "dixgrabs.h" #include "cursor.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ #include "xace.h" #include <assert.h> #include "gcstruct.h" @@ -686,7 +685,7 @@ HashResourceID(XID id, unsigned int numBits) id &= mask; if (numBits < 9) return (id ^ (id >> numBits) ^ (id >> (numBits<<1))) & ~((~0U) << numBits); - return (id ^ (id >> numBits)) & ~((~0) << numBits); + return (id ^ (id >> numBits)) & ~((~0U) << numBits); } static XID @@ -1179,7 +1178,7 @@ LegalNewID(XID id, ClientPtr client) void *val; int rc; -#ifdef PANORAMIX +#ifdef XINERAMA XID minid, maxid; if (!noPanoramiXExtension) { @@ -1189,7 +1188,7 @@ LegalNewID(XID id, ClientPtr client) if ((id >= minid) && (id <= maxid)) return TRUE; } -#endif /* PANORAMIX */ +#endif /* XINERAMA */ if (client->clientAsMask == (id & ~RESOURCE_ID_MASK)) { rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient, DixGetAttrAccess); @@ -1223,7 +1222,7 @@ dixLookupResourceByType(void **result, XID id, RESTYPE rtype, return resourceTypes[rtype & TypeMask].errorValue; if (client) { - cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, + cid = XaceHookResourceAccess(client, id, res->type, res->value, X11_RESTYPE_NONE, NULL, mode); if (cid == BadValue) return resourceTypes[rtype & TypeMask].errorValue; @@ -1258,7 +1257,7 @@ dixLookupResourceByClass(void **result, XID id, RESTYPE rclass, return BadValue; if (client) { - cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, + cid = XaceHookResourceAccess(client, id, res->type, res->value, X11_RESTYPE_NONE, NULL, mode); if (cid != Success) return cid; diff --git a/dix/screenint_priv.h b/dix/screenint_priv.h index 2d98d9ba9..616cfbfb6 100644 --- a/dix/screenint_priv.h +++ b/dix/screenint_priv.h @@ -8,7 +8,7 @@ #include <X11/Xdefs.h> -typedef struct _Screen *ScreenPtr; +#include "screenint.h" typedef Bool (*ScreenInitProcPtr)(ScreenPtr pScreen, int argc, char **argv); @@ -20,9 +20,6 @@ void RemoveGPUScreen(ScreenPtr pScreen); void AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr newScreen); void DetachUnboundGPU(ScreenPtr unbound); -void AttachOutputGPU(ScreenPtr pScreen, ScreenPtr newScreen); -void DetachOutputGPU(ScreenPtr output); - void AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr newScreen); void DetachOffloadGPU(ScreenPtr slave); diff --git a/dix/selection.c b/dix/selection.c index a107eb6cf..ec9b4e85b 100644 --- a/dix/selection.c +++ b/dix/selection.c @@ -44,9 +44,7 @@ SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" @@ -82,8 +80,21 @@ dixLookupSelection(Selection ** result, Atom selectionName, if (pSel->selection == selectionName) break; - if (pSel) - rc = XaceHookSelectionAccess(client, &pSel, access_mode); + if (!pSel) { + pSel = dixAllocateObjectWithPrivates(Selection, PRIVATE_SELECTION); + if (!pSel) + return BadAlloc; + pSel->selection = selectionName; + pSel->next = CurrentSelections; + CurrentSelections = pSel; + } + + /* security creation/labeling check */ + rc = XaceHookSelectionAccess(client, &pSel, access_mode | DixCreateAccess); + if (rc != Success) { + return rc; + } + *result = pSel; return rc; } @@ -175,46 +186,24 @@ ProcSetSelectionOwner(ClientPtr client) */ rc = dixLookupSelection(&pSel, stuff->selection, client, DixSetAttrAccess); - if (rc == Success) { - /* If the timestamp in client's request is in the past relative - to the time stamp indicating the last time the owner of the - selection was set, do not set the selection, just return - success. */ - if (CompareTimeStamps(time, pSel->lastTimeChanged) == EARLIER) - return Success; - if (pSel->client && (!pWin || (pSel->client != client))) { - xEvent event = { - .u.selectionClear.time = time.milliseconds, - .u.selectionClear.window = pSel->window, - .u.selectionClear.atom = pSel->selection - }; - event.u.u.type = SelectionClear; - WriteEventsToClient(pSel->client, 1, &event); - } - } - else if (rc == BadMatch) { - /* - * It doesn't exist, so add it... - */ - pSel = dixAllocateObjectWithPrivates(Selection, PRIVATE_SELECTION); - if (!pSel) - return BadAlloc; - - pSel->selection = stuff->selection; - - /* security creation/labeling check */ - rc = XaceHookSelectionAccess(client, &pSel, - DixCreateAccess | DixSetAttrAccess); - if (rc != Success) { - free(pSel); - return rc; - } + if (rc != Success) + return rc; - pSel->next = CurrentSelections; - CurrentSelections = pSel; + /* If the timestamp in client's request is in the past relative + to the time stamp indicating the last time the owner of the + selection was set, do not set the selection, just return + success. */ + if (CompareTimeStamps(time, pSel->lastTimeChanged) == EARLIER) + return Success; + if (pSel->client && (!pWin || (pSel->client != client))) { + xEvent event = { + .u.selectionClear.time = time.milliseconds, + .u.selectionClear.window = pSel->window, + .u.selectionClear.atom = pSel->selection + }; + event.u.u.type = SelectionClear; + WriteEventsToClient(pSel->client, 1, &event); } - else - return rc; pSel->lastTimeChanged = time; pSel->window = stuff->window; diff --git a/dix/swaprep.c b/dix/swaprep.c index d785b2e5e..b9afa14a2 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -44,9 +44,7 @@ SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> diff --git a/dix/swapreq.c b/dix/swapreq.c index 67850593b..9031f083d 100644 --- a/dix/swapreq.c +++ b/dix/swapreq.c @@ -44,9 +44,7 @@ SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -120,7 +118,6 @@ int _X_COLD SProcSimpleReq(ClientPtr client) { REQUEST(xReq); - swaps(&stuff->length); return (*ProcVector[stuff->reqType]) (client); } @@ -131,7 +128,6 @@ int _X_COLD SProcResourceReq(ClientPtr client) { REQUEST(xResourceReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */ swapl(&stuff->id); return (*ProcVector[stuff->reqType]) (client); @@ -141,7 +137,6 @@ int _X_COLD SProcCreateWindow(ClientPtr client) { REQUEST(xCreateWindowReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xCreateWindowReq); swapl(&stuff->wid); swapl(&stuff->parent); @@ -161,7 +156,6 @@ int _X_COLD SProcChangeWindowAttributes(ClientPtr client) { REQUEST(xChangeWindowAttributesReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); swapl(&stuff->window); swapl(&stuff->valueMask); @@ -173,7 +167,6 @@ int _X_COLD SProcReparentWindow(ClientPtr client) { REQUEST(xReparentWindowReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xReparentWindowReq); swapl(&stuff->window); swapl(&stuff->parent); @@ -186,7 +179,6 @@ int _X_COLD SProcConfigureWindow(ClientPtr client) { REQUEST(xConfigureWindowReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); swapl(&stuff->window); swaps(&stuff->mask); @@ -199,7 +191,6 @@ int _X_COLD SProcInternAtom(ClientPtr client) { REQUEST(xInternAtomReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xInternAtomReq); swaps(&stuff->nbytes); return ((*ProcVector[X_InternAtom]) (client)); @@ -209,7 +200,6 @@ int _X_COLD SProcChangeProperty(ClientPtr client) { REQUEST(xChangePropertyReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangePropertyReq); swapl(&stuff->window); swapl(&stuff->property); @@ -232,19 +222,16 @@ int _X_COLD SProcDeleteProperty(ClientPtr client) { REQUEST(xDeletePropertyReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xDeletePropertyReq); swapl(&stuff->window); swapl(&stuff->property); return ((*ProcVector[X_DeleteProperty]) (client)); - } int _X_COLD SProcGetProperty(ClientPtr client) { REQUEST(xGetPropertyReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetPropertyReq); swapl(&stuff->window); swapl(&stuff->property); @@ -258,7 +245,6 @@ int _X_COLD SProcSetSelectionOwner(ClientPtr client) { REQUEST(xSetSelectionOwnerReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); swapl(&stuff->window); swapl(&stuff->selection); @@ -270,7 +256,6 @@ int _X_COLD SProcConvertSelection(ClientPtr client) { REQUEST(xConvertSelectionReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xConvertSelectionReq); swapl(&stuff->requestor); swapl(&stuff->selection); @@ -287,7 +272,6 @@ SProcSendEvent(ClientPtr client) EventSwapPtr proc; REQUEST(xSendEventReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSendEventReq); swapl(&stuff->destination); swapl(&stuff->eventMask); @@ -313,7 +297,6 @@ int _X_COLD SProcGrabPointer(ClientPtr client) { REQUEST(xGrabPointerReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabPointerReq); swapl(&stuff->grabWindow); swaps(&stuff->eventMask); @@ -327,7 +310,6 @@ int _X_COLD SProcGrabButton(ClientPtr client) { REQUEST(xGrabButtonReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabButtonReq); swapl(&stuff->grabWindow); swaps(&stuff->eventMask); @@ -341,7 +323,6 @@ int _X_COLD SProcUngrabButton(ClientPtr client) { REQUEST(xUngrabButtonReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xUngrabButtonReq); swapl(&stuff->grabWindow); swaps(&stuff->modifiers); @@ -352,7 +333,6 @@ int _X_COLD SProcChangeActivePointerGrab(ClientPtr client) { REQUEST(xChangeActivePointerGrabReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq); swapl(&stuff->cursor); swapl(&stuff->time); @@ -364,7 +344,6 @@ int _X_COLD SProcGrabKeyboard(ClientPtr client) { REQUEST(xGrabKeyboardReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabKeyboardReq); swapl(&stuff->grabWindow); swapl(&stuff->time); @@ -375,7 +354,6 @@ int _X_COLD SProcGrabKey(ClientPtr client) { REQUEST(xGrabKeyReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabKeyReq); swapl(&stuff->grabWindow); swaps(&stuff->modifiers); @@ -386,7 +364,6 @@ int _X_COLD SProcUngrabKey(ClientPtr client) { REQUEST(xUngrabKeyReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xUngrabKeyReq); swapl(&stuff->grabWindow); swaps(&stuff->modifiers); @@ -397,7 +374,6 @@ int _X_COLD SProcGetMotionEvents(ClientPtr client) { REQUEST(xGetMotionEventsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetMotionEventsReq); swapl(&stuff->window); swapl(&stuff->start); @@ -409,7 +385,6 @@ int _X_COLD SProcTranslateCoords(ClientPtr client) { REQUEST(xTranslateCoordsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xTranslateCoordsReq); swapl(&stuff->srcWid); swapl(&stuff->dstWid); @@ -422,7 +397,6 @@ int _X_COLD SProcWarpPointer(ClientPtr client) { REQUEST(xWarpPointerReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xWarpPointerReq); swapl(&stuff->srcWid); swapl(&stuff->dstWid); @@ -439,7 +413,6 @@ int _X_COLD SProcSetInputFocus(ClientPtr client) { REQUEST(xSetInputFocusReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSetInputFocusReq); swapl(&stuff->focus); swapl(&stuff->time); @@ -450,7 +423,6 @@ int _X_COLD SProcOpenFont(ClientPtr client) { REQUEST(xOpenFontReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xOpenFontReq); swapl(&stuff->fid); swaps(&stuff->nbytes); @@ -461,7 +433,6 @@ int _X_COLD SProcListFonts(ClientPtr client) { REQUEST(xListFontsReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xListFontsReq); swaps(&stuff->maxNames); swaps(&stuff->nbytes); @@ -472,7 +443,6 @@ int _X_COLD SProcListFontsWithInfo(ClientPtr client) { REQUEST(xListFontsWithInfoReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq); swaps(&stuff->maxNames); swaps(&stuff->nbytes); @@ -483,7 +453,6 @@ int _X_COLD SProcSetFontPath(ClientPtr client) { REQUEST(xSetFontPathReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSetFontPathReq); swaps(&stuff->nFonts); return ((*ProcVector[X_SetFontPath]) (client)); @@ -493,8 +462,6 @@ int _X_COLD SProcCreatePixmap(ClientPtr client) { REQUEST(xCreatePixmapReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreatePixmapReq); swapl(&stuff->pid); swapl(&stuff->drawable); @@ -507,7 +474,6 @@ int _X_COLD SProcCreateGC(ClientPtr client) { REQUEST(xCreateGCReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xCreateGCReq); swapl(&stuff->gc); swapl(&stuff->drawable); @@ -520,7 +486,6 @@ int _X_COLD SProcChangeGC(ClientPtr client) { REQUEST(xChangeGCReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeGCReq); swapl(&stuff->gc); swapl(&stuff->mask); @@ -532,7 +497,6 @@ int _X_COLD SProcCopyGC(ClientPtr client) { REQUEST(xCopyGCReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyGCReq); swapl(&stuff->srcGC); swapl(&stuff->dstGC); @@ -544,20 +508,17 @@ int _X_COLD SProcSetDashes(ClientPtr client) { REQUEST(xSetDashesReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSetDashesReq); swapl(&stuff->gc); swaps(&stuff->dashOffset); swaps(&stuff->nDashes); return ((*ProcVector[X_SetDashes]) (client)); - } int _X_COLD SProcSetClipRectangles(ClientPtr client) { REQUEST(xSetClipRectanglesReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); swapl(&stuff->gc); swaps(&stuff->xOrigin); @@ -570,7 +531,6 @@ int _X_COLD SProcClearToBackground(ClientPtr client) { REQUEST(xClearAreaReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xClearAreaReq); swapl(&stuff->window); swaps(&stuff->x); @@ -584,7 +544,6 @@ int _X_COLD SProcCopyArea(ClientPtr client) { REQUEST(xCopyAreaReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyAreaReq); swapl(&stuff->srcDrawable); swapl(&stuff->dstDrawable); @@ -602,7 +561,6 @@ int _X_COLD SProcCopyPlane(ClientPtr client) { REQUEST(xCopyPlaneReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyPlaneReq); swapl(&stuff->srcDrawable); swapl(&stuff->dstDrawable); @@ -623,7 +581,6 @@ int _X_COLD SProcPoly(ClientPtr client) { REQUEST(xPolyPointReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xPolyPointReq); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -638,7 +595,6 @@ int _X_COLD SProcFillPoly(ClientPtr client) { REQUEST(xFillPolyReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xFillPolyReq); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -650,7 +606,6 @@ int _X_COLD SProcPutImage(ClientPtr client) { REQUEST(xPutImageReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xPutImageReq); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -660,14 +615,12 @@ SProcPutImage(ClientPtr client) swaps(&stuff->dstY); /* Image should already be swapped */ return ((*ProcVector[X_PutImage]) (client)); - } int _X_COLD SProcGetImage(ClientPtr client) { REQUEST(xGetImageReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetImageReq); swapl(&stuff->drawable); swaps(&stuff->x); @@ -684,7 +637,6 @@ int _X_COLD SProcPolyText(ClientPtr client) { REQUEST(xPolyTextReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xPolyTextReq); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -699,7 +651,6 @@ int _X_COLD SProcImageText(ClientPtr client) { REQUEST(xImageTextReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xImageTextReq); swapl(&stuff->drawable); swapl(&stuff->gc); @@ -712,7 +663,6 @@ int _X_COLD SProcCreateColormap(ClientPtr client) { REQUEST(xCreateColormapReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreateColormapReq); swapl(&stuff->mid); swapl(&stuff->window); @@ -724,19 +674,16 @@ int _X_COLD SProcCopyColormapAndFree(ClientPtr client) { REQUEST(xCopyColormapAndFreeReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); swapl(&stuff->mid); swapl(&stuff->srcCmap); return ((*ProcVector[X_CopyColormapAndFree]) (client)); - } int _X_COLD SProcAllocColor(ClientPtr client) { REQUEST(xAllocColorReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAllocColorReq); swapl(&stuff->cmap); swaps(&stuff->red); @@ -749,7 +696,6 @@ int _X_COLD SProcAllocNamedColor(ClientPtr client) { REQUEST(xAllocNamedColorReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq); swapl(&stuff->cmap); swaps(&stuff->nbytes); @@ -760,7 +706,6 @@ int _X_COLD SProcAllocColorCells(ClientPtr client) { REQUEST(xAllocColorCellsReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAllocColorCellsReq); swapl(&stuff->cmap); swaps(&stuff->colors); @@ -772,7 +717,6 @@ int _X_COLD SProcAllocColorPlanes(ClientPtr client) { REQUEST(xAllocColorPlanesReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAllocColorPlanesReq); swapl(&stuff->cmap); swaps(&stuff->colors); @@ -786,13 +730,11 @@ int _X_COLD SProcFreeColors(ClientPtr client) { REQUEST(xFreeColorsReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); swapl(&stuff->cmap); swapl(&stuff->planeMask); SwapRestL(stuff); return ((*ProcVector[X_FreeColors]) (client)); - } void _X_COLD @@ -811,7 +753,6 @@ SProcStoreColors(ClientPtr client) xColorItem *pItem; REQUEST(xStoreColorsReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); swapl(&stuff->cmap); pItem = (xColorItem *) &stuff[1]; @@ -824,7 +765,6 @@ int _X_COLD SProcStoreNamedColor(ClientPtr client) { REQUEST(xStoreNamedColorReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq); swapl(&stuff->cmap); swapl(&stuff->pixel); @@ -836,7 +776,6 @@ int _X_COLD SProcQueryColors(ClientPtr client) { REQUEST(xQueryColorsReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xQueryColorsReq); swapl(&stuff->cmap); SwapRestL(stuff); @@ -847,7 +786,6 @@ int _X_COLD SProcLookupColor(ClientPtr client) { REQUEST(xLookupColorReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xLookupColorReq); swapl(&stuff->cmap); swaps(&stuff->nbytes); @@ -858,7 +796,6 @@ int _X_COLD SProcCreateCursor(ClientPtr client) { REQUEST(xCreateCursorReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreateCursorReq); swapl(&stuff->cid); swapl(&stuff->source); @@ -878,7 +815,6 @@ int _X_COLD SProcCreateGlyphCursor(ClientPtr client) { REQUEST(xCreateGlyphCursorReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); swapl(&stuff->cid); swapl(&stuff->source); @@ -898,7 +834,6 @@ int _X_COLD SProcRecolorCursor(ClientPtr client) { REQUEST(xRecolorCursorReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xRecolorCursorReq); swapl(&stuff->cursor); swaps(&stuff->foreRed); @@ -914,20 +849,17 @@ int _X_COLD SProcQueryBestSize(ClientPtr client) { REQUEST(xQueryBestSizeReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xQueryBestSizeReq); swapl(&stuff->drawable); swaps(&stuff->width); swaps(&stuff->height); return ((*ProcVector[X_QueryBestSize]) (client)); - } int _X_COLD SProcQueryExtension(ClientPtr client) { REQUEST(xQueryExtensionReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xQueryExtensionReq); swaps(&stuff->nbytes); return ((*ProcVector[X_QueryExtension]) (client)); @@ -937,7 +869,6 @@ int _X_COLD SProcChangeKeyboardMapping(ClientPtr client) { REQUEST(xChangeKeyboardMappingReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); SwapRestL(stuff); return ((*ProcVector[X_ChangeKeyboardMapping]) (client)); @@ -947,7 +878,6 @@ int _X_COLD SProcChangeKeyboardControl(ClientPtr client) { REQUEST(xChangeKeyboardControlReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); swapl(&stuff->mask); SwapRestL(stuff); @@ -958,7 +888,6 @@ int _X_COLD SProcChangePointerControl(ClientPtr client) { REQUEST(xChangePointerControlReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xChangePointerControlReq); swaps(&stuff->accelNum); swaps(&stuff->accelDenum); @@ -970,7 +899,6 @@ int _X_COLD SProcSetScreenSaver(ClientPtr client) { REQUEST(xSetScreenSaverReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xSetScreenSaverReq); swaps(&stuff->timeout); swaps(&stuff->interval); @@ -981,18 +909,15 @@ int _X_COLD SProcChangeHosts(ClientPtr client) { REQUEST(xChangeHostsReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeHostsReq); swaps(&stuff->hostLength); return ((*ProcVector[X_ChangeHosts]) (client)); - } int _X_COLD SProcRotateProperties(ClientPtr client) { REQUEST(xRotatePropertiesReq); - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq); swapl(&stuff->window); swaps(&stuff->nAtoms); @@ -1001,14 +926,6 @@ SProcRotateProperties(ClientPtr client) return ((*ProcVector[X_RotateProperties]) (client)); } -int _X_COLD -SProcNoOperation(ClientPtr client) -{ - REQUEST(xReq); - swaps(&stuff->length); - return ((*ProcVector[X_NoOperation]) (client)); -} - void _X_COLD SwapConnClientPrefix(xConnClientPrefix * pCCP) { diff --git a/dix/tables.c b/dix/tables.c index 88b372eb7..22b44c408 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -44,15 +44,14 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> #include "windowstr.h" #include "extnsionst.h" #include "dixstruct.h" +#include "dixstruct_priv.h" #include "dixevents.h" #include "dispatch.h" #include "swaprep.h" @@ -451,7 +450,7 @@ int (*SwappedProcVector[256]) (ClientPtr /* client */) = { ProcBadRequest, ProcBadRequest, /* 125 */ ProcBadRequest, - SProcNoOperation, + ProcNoOperation, ProcBadRequest, ProcBadRequest, ProcBadRequest, diff --git a/dix/touch.c b/dix/touch.c index ef5dd4ae3..7c509fb26 100644 --- a/dix/touch.c +++ b/dix/touch.c @@ -24,22 +24,21 @@ * Author: Daniel Stone <daniel@fooishbar.org> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/eventconvert.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" #include "inputstr.h" #include "scrnintstr.h" -#include "dixgrabs.h" #include "eventstr.h" #include "exglobals.h" #include "inpututils.h" #include "windowstr.h" -#include "mi.h" #define TOUCH_HISTORY_SIZE 100 diff --git a/dix/window.c b/dix/window.c index 3534ff19b..6b7fc808e 100644 --- a/dix/window.c +++ b/dix/window.c @@ -96,13 +96,18 @@ Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include "dix/colormap_priv.h" +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "dix/property_priv.h" +#include "mi/mi_priv.h" /* miPaintWindow */ #include "os/auth.h" +#include "os/client_priv.h" +#include "os/screensaver.h" #include "misc.h" #include "scrnintstr.h" @@ -111,7 +116,6 @@ Equipment Corporation. #include "validate.h" #include "windowstr.h" #include "propertyst.h" -#include "input.h" #include "inputstr.h" #include "resource.h" #include "colormapst.h" @@ -120,13 +124,12 @@ Equipment Corporation. #include "gcstruct.h" #include "servermd.h" #include "mivalidate.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ #include "dixevents.h" #include "globals.h" -#include "mi.h" /* miPaintWindow */ #ifdef COMPOSITE #include "compint.h" #endif @@ -638,7 +641,7 @@ CreateRootWindow(ScreenPtr pScreen) /* security creation/labeling check */ - if (XaceHook(XACE_RESOURCE_ACCESS, serverClient, pWin->drawable.id, + if (XaceHookResourceAccess(serverClient, pWin->drawable.id, X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_NONE, NULL, DixCreateAccess)) return FALSE; @@ -867,7 +870,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, /* security creation/labeling check */ - *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, X11_RESTYPE_WINDOW, pWin, + *error = XaceHookResourceAccess(client, wid, X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_WINDOW, pWin->parent, DixCreateAccess | DixSetAttrAccess); if (*error != Success) { @@ -1115,7 +1118,7 @@ DestroySubwindows(WindowPtr pWin, ClientPtr client) */ UnmapSubwindows(pWin); while (pWin->lastChild) { - int rc = XaceHook(XACE_RESOURCE_ACCESS, client, + int rc = XaceHookResourceAccess(client, pWin->lastChild->drawable.id, X11_RESTYPE_WINDOW, pWin->lastChild, X11_RESTYPE_NONE, NULL, DixDestroyAccess); @@ -1397,7 +1400,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) goto PatchUp; } if (val == xTrue) { - rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, + rc = XaceHookResourceAccess(client, pWin->drawable.id, X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_NONE, NULL, DixGrabAccess); if (rc != Success) { error = rc; @@ -2300,12 +2303,12 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) }; event.u.u.type = ConfigureRequest; event.u.u.detail = (mask & CWStackMode) ? smode : Above; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && (!pParent || !pParent->parent)) { event.u.configureRequest.x += screenInfo.screens[0]->x; event.u.configureRequest.y += screenInfo.screens[0]->y; } -#endif +#endif /* XINERAMA */ if (MaybeDeliverEventsToClient(pParent, &event, 1, SubstructureRedirectMask, client) == 1) return Success; @@ -2383,12 +2386,12 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client) .u.configureNotify.override = pWin->overrideRedirect }; event.u.u.type = ConfigureNotify; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && (!pParent || !pParent->parent)) { event.u.configureNotify.x += screenInfo.screens[0]->x; event.u.configureNotify.y += screenInfo.screens[0]->y; } -#endif +#endif /* XINERAMA */ DeliverEvents(pWin, &event, 1, NullWindow); } if (mask & CWBorderWidth) { @@ -2528,12 +2531,12 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent, .u.reparent.override = pWin->overrideRedirect }; event.u.u.type = ReparentNotify; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && !pParent->parent) { event.u.reparent.x += screenInfo.screens[0]->x; event.u.reparent.y += screenInfo.screens[0]->y; } -#endif +#endif /* XINERAMA */ DeliverEvents(pWin, &event, 1, pParent); /* take out of sibling chain */ @@ -2664,7 +2667,7 @@ MapWindow(WindowPtr pWin, ClientPtr client) return Success; /* general check for permission to map window */ - if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, X11_RESTYPE_WINDOW, + if (XaceHookResourceAccess(client, pWin->drawable.id, X11_RESTYPE_WINDOW, pWin, X11_RESTYPE_NONE, NULL, DixShowAccess) != Success) return Success; @@ -2792,7 +2795,7 @@ UnrealizeTree(WindowPtr pWin, Bool fromConfigure) if (pChild->realized) { pChild->realized = FALSE; pChild->visibility = VisibilityNotViewable; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) { PanoramiXRes *win; int rc = dixLookupResourceByType((void **) &win, @@ -2803,7 +2806,7 @@ UnrealizeTree(WindowPtr pWin, Bool fromConfigure) if (rc == Success) win->u.win.visibility = VisibilityNotViewable; } -#endif +#endif /* XINERAMA */ (*Unrealize) (pChild); DeleteWindowFromAnyEvents(pChild, FALSE); if (pChild->viewable) { @@ -3020,7 +3023,7 @@ SendVisibilityNotify(WindowPtr pWin) xEvent event; unsigned int visibility = pWin->visibility; -#ifdef PANORAMIX +#ifdef XINERAMA /* This is not quite correct yet, but it's close */ if (!noPanoramiXExtension) { PanoramiXRes *win; @@ -3081,7 +3084,7 @@ SendVisibilityNotify(WindowPtr pWin) win->u.win.visibility = visibility; } -#endif +#endif /* XINERAMA */ event = (xEvent) { .u.visibility.window = pWin->drawable.id, @@ -3113,7 +3116,7 @@ dixSaveScreens(ClientPtr client, int on, int mode) } for (i = 0; i < screenInfo.numScreens; i++) { - rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], + rc = XaceHookScreensaverAccess(client, screenInfo.screens[i], DixShowAccess | DixHideAccess); if (rc != Success) return rc; diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml index 8c3c0fce4..a4450dbdb 100644 --- a/doc/Xserver-spec.xml +++ b/doc/Xserver-spec.xml @@ -2736,7 +2736,7 @@ If the colormap is static, which you can tell by looking at the class field, you will want to fill in each color cell to match the hardwares notion of the color for that pixel. If the colormap is the default for the screen, which you can tell by looking -at the IsDefault bit in the flags field, you should allocate BlackPixel +at the CM_IsDefault bit in the flags field, you should allocate BlackPixel and WhitePixel to match the values you set in the pScreen structure. (Of course, you picked those values to begin with.)</para> <para> @@ -3277,9 +3277,8 @@ need to be done when these happen, such as allocating or deallocating structures that are only needed for visible windows. RealizeWindow does NOT draw the window border, background or contents; UnrealizeWindow does NOT erase the window or generate exposure events -for underlying windows; this is taken care of by DIX. DIX does, -however, call PaintWindowBackground() and PaintWindowBorder() to -perform some of these.</para> +for underlying windows; this is taken care of by DIX. +</para> <para> <blockquote><programlisting> @@ -3383,7 +3382,7 @@ and all of its child windows.</para> If generateExposures is false, the client is trying to simply erase part of the window to the background fill style. ClearToBackground should write the background color or tile to the -rectangle in question (probably using PaintWindowBackground). +rectangle in question. If w or h is zero, it clears all the way to the right or lower edge of the window.</para> <para> The sample server implementation is in Xserver/mi/miwindow.c.</para> @@ -4044,7 +4043,7 @@ returned instead). Furthermore, the invalid bits of the source are not copied to the destination and (when the destination is a window) are filled with the background tile. The sample routine miHandleExposures generates the appropriate return value and fills the -invalid area using pScreen->PaintWindowBackground.</para> +invalid area.</para> <para> For instance, imagine a window that is partially obscured by other windows in front of it. As text is scrolled on your window, the pixels @@ -4257,7 +4256,6 @@ bit in that plane equal to 0. If format is XYPixmap, planemask is guaranteed to have a single bit set; the bits should be written in Bitmap format, which is the format for a single plane of an XYPixmap.</para> <para> -An example implementation is miGetImage() in Xserver/mi/mibitblt.c. <blockquote><programlisting> void pGC->ops->ImageText8(pDraw, pGC, x, y, count, chars) @@ -4924,10 +4922,8 @@ mi and fb implementations.</para> <row><entry><function>ClipNotify</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>CloseScreen</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row> <row><entry><function>ConstrainCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row> -<row><entry><function>CopyArea</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row> <row><entry><function>CopyGCDest</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row> <row><entry><function>CopyGCSource</function></entry><entry><literal>none</literal></entry><entry><para>GC func</para></entry></row> -<row><entry><function>CopyPlane</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row> <row><entry><function>CopyWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Window</para></entry></row> <row><entry><function>CreateGC</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>CreateCallbackList</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row> @@ -4952,7 +4948,6 @@ mi and fb implementations.</para> <row><entry><function>FlushAllOutput</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row> <row><entry><function>FlushIfCriticalOutputPending</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row> <row><entry><function>FreeScratchPixmapHeader</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row> -<row><entry><function>GetImage</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>GetMotionEvents</function></entry><entry><literal>hd</literal></entry><entry><para>Device</para></entry></row> <row><entry><function>GetScratchPixmapHeader</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row> <row><entry><function>GetSpans</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row> @@ -4990,8 +4985,6 @@ mi and fb implementations.</para> <row><entry><function>ModifyPixmapHeader</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>NextAvailableClient</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row> <row><entry><function>OsInit</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row> -<row><entry><function>PaintWindowBackground</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row> -<row><entry><function>PaintWindowBorder</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row> <row><entry><function>PointerNonInterestBox</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>PointInRegion</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>PolyArc</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row> @@ -5007,7 +5000,6 @@ mi and fb implementations.</para> <row><entry><function>PositionWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>ProcessInputEvents</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row> <row><entry><function>PushPixels</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row> -<row><entry><function>PutImage</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row> <row><entry><function>QueryBestSize</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row> <row><entry><function>ReadRequestFromClient</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row> <row><entry><function>RealizeCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row> diff --git a/dri3/dri3.c b/dri3/dri3.c index 0ea01bb2f..2675b44ff 100644 --- a/dri3/dri3.c +++ b/dri3/dri3.c @@ -85,10 +85,10 @@ dri3_extension_init(void) if (dri3_screen_generation != serverGeneration) return; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return; -#endif +#endif /* XINERAMA */ extension = AddExtension(DRI3_NAME, DRI3NumberEvents, DRI3NumberErrors, proc_dri3_dispatch, sproc_dri3_dispatch, diff --git a/dri3/dri3_request.c b/dri3/dri3_request.c index b6128659c..cdb5a1f1e 100644 --- a/dri3/dri3_request.c +++ b/dri3/dri3_request.c @@ -24,6 +24,7 @@ #include <unistd.h> #include "dix/dix_priv.h" +#include "os/client_priv.h" #include "dri3_priv.h" #include <syncsrv.h> @@ -239,7 +240,7 @@ proc_dri3_pixmap_from_buffer(ClientPtr client) pixmap->drawable.id = stuff->pixmap; /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, X11_RESTYPE_PIXMAP, + rc = XaceHookResourceAccess(client, stuff->pixmap, X11_RESTYPE_PIXMAP, pixmap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) { @@ -503,7 +504,7 @@ proc_dri3_pixmap_from_buffers(ClientPtr client) pixmap->drawable.id = stuff->pixmap; /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pixmap, X11_RESTYPE_PIXMAP, + rc = XaceHookResourceAccess(client, stuff->pixmap, X11_RESTYPE_PIXMAP, pixmap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) { @@ -676,8 +677,6 @@ sproc_dri3_query_version(ClientPtr client) { REQUEST(xDRI3QueryVersionReq); REQUEST_SIZE_MATCH(xDRI3QueryVersionReq); - - swaps(&stuff->length); swapl(&stuff->majorVersion); swapl(&stuff->minorVersion); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); @@ -688,8 +687,6 @@ sproc_dri3_open(ClientPtr client) { REQUEST(xDRI3OpenReq); REQUEST_SIZE_MATCH(xDRI3OpenReq); - - swaps(&stuff->length); swapl(&stuff->drawable); swapl(&stuff->provider); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); @@ -700,8 +697,6 @@ sproc_dri3_pixmap_from_buffer(ClientPtr client) { REQUEST(xDRI3PixmapFromBufferReq); REQUEST_SIZE_MATCH(xDRI3PixmapFromBufferReq); - - swaps(&stuff->length); swapl(&stuff->pixmap); swapl(&stuff->drawable); swapl(&stuff->size); @@ -716,8 +711,6 @@ sproc_dri3_buffer_from_pixmap(ClientPtr client) { REQUEST(xDRI3BufferFromPixmapReq); REQUEST_SIZE_MATCH(xDRI3BufferFromPixmapReq); - - swaps(&stuff->length); swapl(&stuff->pixmap); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); } @@ -727,8 +720,6 @@ sproc_dri3_fence_from_fd(ClientPtr client) { REQUEST(xDRI3FenceFromFDReq); REQUEST_SIZE_MATCH(xDRI3FenceFromFDReq); - - swaps(&stuff->length); swapl(&stuff->drawable); swapl(&stuff->fence); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); @@ -739,8 +730,6 @@ sproc_dri3_fd_from_fence(ClientPtr client) { REQUEST(xDRI3FDFromFenceReq); REQUEST_SIZE_MATCH(xDRI3FDFromFenceReq); - - swaps(&stuff->length); swapl(&stuff->drawable); swapl(&stuff->fence); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); @@ -751,8 +740,6 @@ sproc_dri3_get_supported_modifiers(ClientPtr client) { REQUEST(xDRI3GetSupportedModifiersReq); REQUEST_SIZE_MATCH(xDRI3GetSupportedModifiersReq); - - swaps(&stuff->length); swapl(&stuff->window); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); } @@ -762,8 +749,6 @@ sproc_dri3_pixmap_from_buffers(ClientPtr client) { REQUEST(xDRI3PixmapFromBuffersReq); REQUEST_SIZE_MATCH(xDRI3PixmapFromBuffersReq); - - swaps(&stuff->length); swapl(&stuff->pixmap); swapl(&stuff->window); swaps(&stuff->width); @@ -785,8 +770,6 @@ sproc_dri3_buffers_from_pixmap(ClientPtr client) { REQUEST(xDRI3BuffersFromPixmapReq); REQUEST_SIZE_MATCH(xDRI3BuffersFromPixmapReq); - - swaps(&stuff->length); swapl(&stuff->pixmap); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); } @@ -807,8 +790,6 @@ sproc_dri3_import_syncobj(ClientPtr client) { REQUEST(xDRI3ImportSyncobjReq); REQUEST_SIZE_MATCH(xDRI3ImportSyncobjReq); - - swaps(&stuff->length); swapl(&stuff->syncobj); swapl(&stuff->drawable); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); @@ -819,8 +800,6 @@ sproc_dri3_free_syncobj(ClientPtr client) { REQUEST(xDRI3FreeSyncobjReq); REQUEST_SIZE_MATCH(xDRI3FreeSyncobjReq); - - swaps(&stuff->length); swapl(&stuff->syncobj); return (*proc_dri3_vector[stuff->dri3ReqType]) (client); } diff --git a/dri3/dri3_screen.c b/dri3/dri3_screen.c index 2430505fb..ec8d025c4 100644 --- a/dri3/dri3_screen.c +++ b/dri3/dri3_screen.c @@ -255,7 +255,7 @@ dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable, } /* copy the screen mods so we can return an owned allocation */ - screen_mods = xnfalloc(screen_format->num_modifiers * sizeof(CARD64)); + screen_mods = XNFalloc(screen_format->num_modifiers * sizeof(CARD64)); memcpy(screen_mods, screen_format->modifiers, screen_format->num_modifiers * sizeof(CARD64)); @@ -28,9 +28,7 @@ * memory management. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> @@ -883,7 +881,7 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) return FALSE; } - pExaScr = calloc(sizeof(ExaScreenPrivRec), 1); + pExaScr = calloc(1, sizeof(ExaScreenPrivRec)); if (!pExaScr) { LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n", pScreen->myNum); diff --git a/exa/exa_accel.c b/exa/exa_accel.c index 2a31bd3c7..92211964f 100644 --- a/exa/exa_accel.c +++ b/exa/exa_accel.c @@ -27,9 +27,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "exa_priv.h" #include <X11/fonts/fontstruct.h> #include "dixfontstr.h" diff --git a/exa/exa_classic.c b/exa/exa_classic.c index a9460f999..7f93f1e3d 100644 --- a/exa/exa_classic.c +++ b/exa/exa_classic.c @@ -22,9 +22,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> @@ -99,7 +97,8 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth, if (pExaPixmap->fb_pitch > 131071) { swap(pExaScr, pScreen, DestroyPixmap); - pScreen->DestroyPixmap(pPixmap); + if (pScreen->DestroyPixmap) + pScreen->DestroyPixmap(pPixmap); swap(pExaScr, pScreen, DestroyPixmap); return NULL; } @@ -111,7 +110,8 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth, if (pExaPixmap->pDamage == NULL) { swap(pExaScr, pScreen, DestroyPixmap); - pScreen->DestroyPixmap(pPixmap); + if (pScreen->DestroyPixmap) + pScreen->DestroyPixmap(pPixmap); swap(pExaScr, pScreen, DestroyPixmap); return NULL; } @@ -214,7 +214,7 @@ exaDestroyPixmap_classic(PixmapPtr pPixmap) ScreenPtr pScreen = pPixmap->drawable.pScreen; ExaScreenPriv(pScreen); - Bool ret; + Bool ret = TRUE; if (pPixmap->refcnt == 1) { ExaPixmapPriv(pPixmap); @@ -236,7 +236,8 @@ exaDestroyPixmap_classic(PixmapPtr pPixmap) } swap(pExaScr, pScreen, DestroyPixmap); - ret = pScreen->DestroyPixmap(pPixmap); + if (pScreen->DestroyPixmap) + ret = pScreen->DestroyPixmap(pPixmap); swap(pExaScr, pScreen, DestroyPixmap); return ret; diff --git a/exa/exa_driver.c b/exa/exa_driver.c index 7a74c4500..17106fcb9 100644 --- a/exa/exa_driver.c +++ b/exa/exa_driver.c @@ -22,9 +22,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> @@ -101,7 +99,8 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth, if (!pExaPixmap->driverPriv) { swap(pExaScr, pScreen, DestroyPixmap); - pScreen->DestroyPixmap(pPixmap); + if (pScreen->DestroyPixmap) + pScreen->DestroyPixmap(pPixmap); swap(pExaScr, pScreen, DestroyPixmap); return NULL; } @@ -193,7 +192,7 @@ exaDestroyPixmap_driver(PixmapPtr pPixmap) ScreenPtr pScreen = pPixmap->drawable.pScreen; ExaScreenPriv(pScreen); - Bool ret; + Bool ret = TRUE; if (pPixmap->refcnt == 1) { ExaPixmapPriv(pPixmap); @@ -206,7 +205,8 @@ exaDestroyPixmap_driver(PixmapPtr pPixmap) } swap(pExaScr, pScreen, DestroyPixmap); - ret = pScreen->DestroyPixmap(pPixmap); + if (pScreen->DestroyPixmap) + ret = pScreen->DestroyPixmap(pPixmap); swap(pExaScr, pScreen, DestroyPixmap); return ret; diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c index 6b97a83b1..371301888 100644 --- a/exa/exa_glyphs.c +++ b/exa/exa_glyphs.c @@ -40,9 +40,7 @@ * Based on code by: Keith Packard */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/exa/exa_migration_classic.c b/exa/exa_migration_classic.c index f712e1914..825789578 100644 --- a/exa/exa_migration_classic.c +++ b/exa/exa_migration_classic.c @@ -26,9 +26,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> diff --git a/exa/exa_migration_mixed.c b/exa/exa_migration_mixed.c index 7d3fca7c0..52623e3ca 100644 --- a/exa/exa_migration_mixed.c +++ b/exa/exa_migration_mixed.c @@ -22,9 +22,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c index 4c7714657..7138f9b30 100644 --- a/exa/exa_mixed.c +++ b/exa/exa_mixed.c @@ -22,9 +22,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> @@ -247,7 +245,7 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap) ScreenPtr pScreen = pPixmap->drawable.pScreen; ExaScreenPriv(pScreen); - Bool ret; + Bool ret = TRUE; if (pPixmap->refcnt == 1) { ExaPixmapPriv(pPixmap); @@ -269,7 +267,8 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap) } swap(pExaScr, pScreen, DestroyPixmap); - ret = pScreen->DestroyPixmap(pPixmap); + if (pScreen->DestroyPixmap) + ret = pScreen->DestroyPixmap(pPixmap); swap(pExaScr, pScreen, DestroyPixmap); return ret; diff --git a/exa/exa_render.c b/exa/exa_render.c index 9fbfdfca2..da74f64d7 100644 --- a/exa/exa_render.c +++ b/exa/exa_render.c @@ -22,9 +22,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> @@ -1030,6 +1030,7 @@ extern _X_EXPORT Bool int dpiy, int width, /* pixel width of frame buffer */ int bpp); /* bits per pixel of frame buffer */ +#ifdef FB_ACCESS_WRAPPER extern _X_EXPORT Bool wfbFinishScreenInit(ScreenPtr pScreen, void *pbits, @@ -1051,6 +1052,7 @@ wfbScreenInit(ScreenPtr pScreen, int width, int bpp, SetupWrapProcPtr setupWrap, FinishWrapProcPtr finishWrap); +#endif extern _X_EXPORT Bool fbFinishScreenInit(ScreenPtr pScreen, diff --git a/fb/fballpriv.c b/fb/fballpriv.c index 187d0b068..e5f9f80ac 100644 --- a/fb/fballpriv.c +++ b/fb/fballpriv.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbarc.c b/fb/fbarc.c index fe14aed61..98d4281a7 100644 --- a/fb/fbarc.c +++ b/fb/fbarc.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" #include "mizerarc.h" diff --git a/fb/fbbits.c b/fb/fbbits.c index 7435ad56a..682eff647 100644 --- a/fb/fbbits.c +++ b/fb/fbbits.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" #include "miline.h" diff --git a/fb/fbblt.c b/fb/fbblt.c index c1730ab6a..b0ac72b82 100644 --- a/fb/fbblt.c +++ b/fb/fbblt.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include "fb.h" diff --git a/fb/fbbltone.c b/fb/fbbltone.c index 7eac85b08..732a89a9c 100644 --- a/fb/fbbltone.c +++ b/fb/fbbltone.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbcmap_mi.c b/fb/fbcmap_mi.c index a71828a11..df0fe98b5 100644 --- a/fb/fbcmap_mi.c +++ b/fb/fbcmap_mi.c @@ -27,9 +27,7 @@ * XFree86Server being defined. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include "fb.h" diff --git a/fb/fbcopy.c b/fb/fbcopy.c index 3af128ada..8a834ac3e 100644 --- a/fb/fbcopy.c +++ b/fb/fbcopy.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/fb/fbfill.c b/fb/fbfill.c index ad09671fa..5d08e2257 100644 --- a/fb/fbfill.c +++ b/fb/fbfill.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbfillrect.c b/fb/fbfillrect.c index 0075b2cdb..78feba691 100644 --- a/fb/fbfillrect.c +++ b/fb/fbfillrect.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbfillsp.c b/fb/fbfillsp.c index 4debe1ebd..3fe85b45a 100644 --- a/fb/fbfillsp.c +++ b/fb/fbfillsp.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/fb/fbgetsp.c b/fb/fbgetsp.c index 445a4e385..2bccb5dd8 100644 --- a/fb/fbgetsp.c +++ b/fb/fbgetsp.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbglyph.c b/fb/fbglyph.c index 1bdc2d4fd..5a1282ba9 100644 --- a/fb/fbglyph.c +++ b/fb/fbglyph.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" #include <X11/fonts/fontstruct.h> diff --git a/fb/fbimage.c b/fb/fbimage.c index bd24728fd..3e459885d 100644 --- a/fb/fbimage.c +++ b/fb/fbimage.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> diff --git a/fb/fbline.c b/fb/fbline.c index 38c3c6c16..0a3d45452 100644 --- a/fb/fbline.c +++ b/fb/fbline.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fboverlay.c b/fb/fboverlay.c index d47a7c67b..7ea8e660b 100644 --- a/fb/fboverlay.c +++ b/fb/fboverlay.c @@ -22,12 +22,12 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> +#include "mi/mi_priv.h" + #include "fb.h" #include "fboverlay.h" #include "shmint.h" diff --git a/fb/fbpict.c b/fb/fbpict.c index f985198fb..76b7aaf00 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -23,9 +23,7 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c index 89e3370a6..3ed2b5680 100644 --- a/fb/fbpixmap.c +++ b/fb/fbpixmap.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/fb/fbpoint.c b/fb/fbpoint.c index d4c95eea7..0b804e557 100644 --- a/fb/fbpoint.c +++ b/fb/fbpoint.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbpush.c b/fb/fbpush.c index 1d1bcfd08..fd9641154 100644 --- a/fb/fbpush.c +++ b/fb/fbpush.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbscreen.c b/fb/fbscreen.c index 42efaa911..220a99511 100644 --- a/fb/fbscreen.c +++ b/fb/fbscreen.c @@ -20,9 +20,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "os/osdep.h" #include "fb.h" diff --git a/fb/fbseg.c b/fb/fbseg.c index 6c3d69363..4992973c0 100644 --- a/fb/fbseg.c +++ b/fb/fbseg.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/fb/fbsetsp.c b/fb/fbsetsp.c index fe94e283c..0fdc17380 100644 --- a/fb/fbsetsp.c +++ b/fb/fbsetsp.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbsolid.c b/fb/fbsolid.c index 1ee165950..1ad4ab2ab 100644 --- a/fb/fbsolid.c +++ b/fb/fbsolid.c @@ -22,9 +22,7 @@ #define FbSelectPart(xor,o,t) xor -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbtile.c b/fb/fbtile.c index 785c5f0e4..a7d938667 100644 --- a/fb/fbtile.c +++ b/fb/fbtile.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbtrap.c b/fb/fbtrap.c index bf82f8f2c..0893d168f 100644 --- a/fb/fbtrap.c +++ b/fb/fbtrap.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbutil.c b/fb/fbutil.c index c1d5923c4..920d70197 100644 --- a/fb/fbutil.c +++ b/fb/fbutil.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "fb.h" diff --git a/fb/fbwindow.c b/fb/fbwindow.c index df33af948..96e749a20 100644 --- a/fb/fbwindow.c +++ b/fb/fbwindow.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/glamor/glamor.c b/glamor/glamor.c index 70a34d81b..914c414a1 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -954,7 +954,7 @@ glamor_set_glvnd_vendor(ScreenPtr screen, const char *vendor_name) if (glamor_priv->glvnd_vendor) free(glamor_priv->glvnd_vendor); - glamor_priv->glvnd_vendor = xnfstrdup(vendor_name); + glamor_priv->glvnd_vendor = XNFstrdup(vendor_name); } const char * diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c index 428303091..13af727ff 100644 --- a/glamor/glamor_composite_glyphs.c +++ b/glamor/glamor_composite_glyphs.c @@ -178,6 +178,24 @@ glamor_glyph_add(struct glamor_glyph_atlas *atlas, DrawablePtr glyph_draw) return TRUE; } +static const glamor_facet glamor_facet_composite_glyphs_es300 = { + .name = "composite_glyphs", + .version = 130, + .fs_extensions = ("#extension GL_EXT_blend_func_extended : enable\n"), + .vs_vars = ("in vec4 primitive;\n" + "in vec2 source;\n" + "out vec2 glyph_pos;\n"), + .vs_exec = (" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n" + GLAMOR_POS(gl_Position, (primitive.xy + pos)) + " glyph_pos = (source + pos) * ATLAS_DIM_INV;\n"), + .fs_vars = ("in vec2 glyph_pos;\n" + "out vec4 color0;\n" + "out vec4 color1;\n"), + .fs_exec = (" vec4 mask = texture(atlas, glyph_pos);\n"), + .source_name = "source", + .locations = glamor_program_location_atlas, +}; + static const glamor_facet glamor_facet_composite_glyphs_130 = { .name = "composite_glyphs", .version = 130, @@ -454,7 +472,9 @@ glamor_composite_glyphs(CARD8 op, if (glamor_glsl_has_ints(glamor_priv)) prog = glamor_setup_program_render(op, src, glyph_pict, dst, glyphs_program, - &glamor_facet_composite_glyphs_130, + glamor_priv->is_gles ? + &glamor_facet_composite_glyphs_es300 : + &glamor_facet_composite_glyphs_130, glamor_priv->glyph_defines); else prog = glamor_setup_program_render(op, src, glyph_pict, dst, diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 844dbbe71..668eddc86 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -354,7 +354,7 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok) scratch_gc = GetScratchGC(pixmap->drawable.depth, screen); ValidateGC(&pixmap->drawable, scratch_gc); - scratch_gc->ops->CopyArea(&pixmap->drawable, &exported->drawable, + (void) scratch_gc->ops->CopyArea(&pixmap->drawable, &exported->drawable, scratch_gc, 0, 0, width, height, 0, 0); FreeScratchGC(scratch_gc); @@ -520,6 +520,31 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen, return fd; } +static bool +gbm_format_for_depth(CARD8 depth, uint32_t *format) +{ + switch (depth) { + case 15: + *format = GBM_FORMAT_ARGB1555; + return true; + case 16: + *format = GBM_FORMAT_RGB565; + return true; + case 24: + *format = GBM_FORMAT_XRGB8888; + return true; + case 30: + *format = GBM_FORMAT_ARGB2101010; + return true; + case 32: + *format = GBM_FORMAT_ARGB8888; + return true; + default: + ErrorF("unexpected depth: %d\n", depth); + return false; + } +} + Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap, int fd, @@ -536,17 +561,14 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap, glamor_egl = glamor_egl_get_screen_private(scrn); - if (bpp != 32 || !(depth == 24 || depth == 32 || depth == 30) || width == 0 || height == 0) + if (!gbm_format_for_depth(depth, &import_data.format) || + width == 0 || height == 0) return FALSE; import_data.fd = fd; import_data.width = width; import_data.height = height; import_data.stride = stride; - if (depth == 30) - import_data.format = GBM_FORMAT_ARGB2101010; - else - import_data.format = GBM_FORMAT_ARGB8888; bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD, &import_data, 0); if (!bo) return FALSE; @@ -558,25 +580,6 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap, return ret; } -static uint32_t -gbm_format_for_depth(CARD8 depth) -{ - switch (depth) { - case 15: - return GBM_FORMAT_ARGB1555; - case 16: - return GBM_FORMAT_RGB565; - case 24: - return GBM_FORMAT_XRGB8888; - case 30: - return GBM_FORMAT_ARGB2101010; - default: - ErrorF("unexpected depth: %d\n", depth); - case 32: - return GBM_FORMAT_ARGB8888; - } -} - PixmapPtr glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds, @@ -599,6 +602,10 @@ glamor_pixmap_from_fds(ScreenPtr screen, struct gbm_import_fd_modifier_data import_data = { 0 }; struct gbm_bo *bo; + if (!gbm_format_for_depth(depth, &import_data.format) || + width == 0 || height == 0) + goto error; + import_data.width = width; import_data.height = height; import_data.num_fds = num_fds; @@ -608,7 +615,6 @@ glamor_pixmap_from_fds(ScreenPtr screen, import_data.strides[i] = strides[i]; import_data.offsets[i] = offsets[i]; } - import_data.format = gbm_format_for_depth(depth); bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD_MODIFIER, &import_data, 0); if (bo) { screen->ModifyPixmapHeader(pixmap, width, height, 0, 0, strides[0], NULL); @@ -624,6 +630,7 @@ glamor_pixmap_from_fds(ScreenPtr screen, } } +error: if (ret == FALSE) { screen->DestroyPixmap(pixmap); return NULL; @@ -757,7 +764,7 @@ glamor_egl_destroy_pixmap(PixmapPtr pixmap) ScrnInfoPtr scrn = xf86ScreenToScrn(screen); struct glamor_egl_screen_private *glamor_egl = glamor_egl_get_screen_private(scrn); - Bool ret; + Bool ret = TRUE; if (pixmap->refcnt == 1) { struct glamor_pixmap_private *pixmap_priv = @@ -768,7 +775,8 @@ glamor_egl_destroy_pixmap(PixmapPtr pixmap) } screen->DestroyPixmap = glamor_egl->saved_destroy_pixmap; - ret = screen->DestroyPixmap(pixmap); + if (screen->DestroyPixmap) + ret = screen->DestroyPixmap(pixmap); glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap; screen->DestroyPixmap = glamor_egl_destroy_pixmap; @@ -1089,13 +1097,13 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd) Bool force_es = FALSE; const char *glvnd_vendor = NULL; - glamor_egl = calloc(sizeof(*glamor_egl), 1); + glamor_egl = calloc(1, sizeof(*glamor_egl)); if (glamor_egl == NULL) return FALSE; if (xf86GlamorEGLPrivateIndex == -1) xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); - options = xnfalloc(sizeof(GlamorEGLOptions)); + options = XNFalloc(sizeof(GlamorEGLOptions)); memcpy(options, GlamorEGLOptions, sizeof(GlamorEGLOptions)); xf86ProcessOptions(scrn->scrnIndex, scrn->options, options); glvnd_vendor = xf86GetOptValString(options, GLAMOREGLOPT_VENDOR_LIBRARY); diff --git a/glamor/glamor_eglmodule.c b/glamor/glamor_eglmodule.c index 326af3aa6..8ba9ba037 100644 --- a/glamor/glamor_eglmodule.c +++ b/glamor/glamor_eglmodule.c @@ -35,16 +35,18 @@ #include "glamor.h" static XF86ModuleVersionInfo VersRec = { - GLAMOR_EGL_MODULE_NAME, - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 1, 0, 1, /* version */ - ABI_CLASS_ANSIC, /* Only need the ansic layer */ - ABI_ANSIC_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} /* signature, to be patched into the file by a tool */ + .modname = GLAMOR_EGL_MODULE_NAME, + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 1, + .minorversion = 0, + .patchlevel = 1, + .abiclass = ABI_CLASS_ANSIC, + .abiversion = ABI_ANSIC_VERSION, }; -_X_EXPORT XF86ModuleData glamoreglModuleData = { &VersRec, NULL, NULL }; +_X_EXPORT XF86ModuleData glamoreglModuleData = { + .vers = &VersRec +}; diff --git a/glamor/glamor_font.c b/glamor/glamor_font.c index c60fa787b..9b26180e9 100644 --- a/glamor/glamor_font.c +++ b/glamor/glamor_font.c @@ -20,6 +20,12 @@ * OF THIS SOFTWARE. */ +#include <dix-config.h> + +#include <stddef.h> +#include <X11/fonts/fontstruct.h> // libxfont2.h missed to include that +#include <X11/fonts/libxfont2.h> + #include "glamor_priv.h" #include "glamor_font.h" #include <dixfontstr.h> diff --git a/glamor/glamor_glx_provider.c b/glamor/glamor_glx_provider.c index 77ccc3c8b..c27141c7c 100644 --- a/glamor/glamor_glx_provider.c +++ b/glamor/glamor_glx_provider.c @@ -140,12 +140,14 @@ egl_create_glx_drawable(ClientPtr client, __GLXscreen *screen, * - drawable type masks is suspicious */ static struct egl_config * -translate_eglconfig(struct egl_screen *screen, EGLConfig hc, +translate_eglconfig(ScreenPtr pScreen, struct egl_screen *screen, EGLConfig hc, struct egl_config *chain, Bool direct_color, Bool double_buffer, Bool duplicate_for_composite, Bool srgb_only) { EGLint value; + bool valid_depth; + int i; struct egl_config *c = calloc(1, sizeof *c); if (!c) @@ -218,6 +220,19 @@ translate_eglconfig(struct egl_screen *screen, EGLConfig hc, } #undef GET + /* Only expose this config if rgbBits matches a supported + * depth value. + */ + valid_depth = false; + for (i = 0; i < pScreen->numDepths && !valid_depth; i++) { + if (pScreen->allowedDepths[i].depth == c->base.rgbBits) + valid_depth = true; + } + if (!valid_depth) { + free(c); + return chain; + } + /* derived state: config caveats */ eglGetConfigAttrib(screen->display, hc, EGL_CONFIG_CAVEAT, &value); if (value == EGL_NONE) @@ -340,13 +355,13 @@ egl_mirror_configs(ScreenPtr pScreen, struct egl_screen *screen) for (j = 0; j < 3; j++) /* direct_color */ for (k = 0; k < 2; k++) /* double_buffer */ { if (can_srgb) - c = translate_eglconfig(screen, host_configs[i], c, + c = translate_eglconfig(pScreen, screen, host_configs[i], c, /* direct_color */ j == 1, /* double_buffer */ k > 0, /* duplicate_for_composite */ j == 0, /* srgb_only */ true); - c = translate_eglconfig(screen, host_configs[i], c, + c = translate_eglconfig(pScreen, screen, host_configs[i], c, /* direct_color */ j == 1, /* double_buffer */ k > 0, /* duplicate_for_composite */ j == 0, diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c index 558e14311..7c22ccdb2 100644 --- a/glamor/glamor_gradient.c +++ b/glamor/glamor_gradient.c @@ -1110,10 +1110,8 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen, } if (stops_count > RADIAL_SMALL_STOPS) { - if (n_stops) - free(n_stops); - if (stop_colors) - free(stop_colors); + free(n_stops); + free(stop_colors); } glDisableVertexAttribArray(GLAMOR_VERTEX_POS); @@ -1454,10 +1452,8 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen, } if (stops_count > LINEAR_SMALL_STOPS) { - if (n_stops) - free(n_stops); - if (stop_colors) - free(stop_colors); + free(n_stops); + free(stop_colors); } glDisableVertexAttribArray(GLAMOR_VERTEX_POS); diff --git a/glamor/glamor_lines.c b/glamor/glamor_lines.c index c9b776bb5..8d6db3e4c 100644 --- a/glamor/glamor_lines.c +++ b/glamor/glamor_lines.c @@ -115,6 +115,7 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc, box->y2 - box->y1); box++; glDrawArrays(GL_LINE_STRIP, 0, n + add_last); + glDrawArrays(GL_POINTS, 0, n + add_last); } } diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 5a0dc2e2d..f80aab74b 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -29,6 +29,8 @@ #include "dix-config.h" +#include <X11/Xfuncproto.h> + #include "glamor.h" #include "xvdix.h" diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c index 21f8987d9..a02584fad 100644 --- a/glamor/glamor_program.c +++ b/glamor/glamor_program.c @@ -359,8 +359,6 @@ glamor_build_program(ScreenPtr screen, vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_prog_string); fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_prog_string); - free(vs_prog_string); - free(fs_prog_string); glAttachShader(prog->prog, vs_prog); glDeleteShader(vs_prog); glAttachShader(prog->prog, fs_prog); @@ -394,6 +392,8 @@ glamor_build_program(ScreenPtr screen, prog->atlas_uniform = glamor_get_uniform(prog, glamor_program_location_atlas, "atlas"); free(version_string); + free(vs_prog_string); + free(fs_prog_string); free(fs_vars); free(vs_vars); return TRUE; diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c index 9404e899c..9efb505f0 100644 --- a/glamor/glamor_transfer.c +++ b/glamor/glamor_transfer.c @@ -37,12 +37,12 @@ glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox, PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); int box_index; - int bytes_per_pixel = drawable->bitsPerPixel >> 3; const struct glamor_format *f = glamor_format_for_pixmap(pixmap); + int bytes_per_pixel = PICT_FORMAT_BPP(f->render_format) >> 3; char *tmp_bits = NULL; if (glamor_drawable_effective_depth(drawable) == 24 && pixmap->drawable.depth == 32) - tmp_bits = xnfalloc(byte_stride * pixmap->drawable.height); + tmp_bits = XNFalloc(byte_stride * pixmap->drawable.height); glamor_make_current(glamor_priv); @@ -145,8 +145,8 @@ glamor_download_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox, PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); int box_index; - int bytes_per_pixel = drawable->bitsPerPixel >> 3; const struct glamor_format *f = glamor_format_for_pixmap(pixmap); + int bytes_per_pixel = PICT_FORMAT_BPP(f->render_format) >> 3; glamor_make_current(glamor_priv); diff --git a/glamor/glamor_vbo.c b/glamor/glamor_vbo.c index 000c3e827..3b91bd8b5 100644 --- a/glamor/glamor_vbo.c +++ b/glamor/glamor_vbo.c @@ -128,7 +128,7 @@ glamor_get_vbo_space(ScreenPtr screen, unsigned size, char **vbo_offset) if (glamor_priv->vbo_size < size) { glamor_priv->vbo_size = MAX(GLAMOR_VBO_SIZE, size); free(glamor_priv->vb); - glamor_priv->vb = xnfalloc(glamor_priv->vbo_size); + glamor_priv->vb = XNFalloc(glamor_priv->vbo_size); } *vbo_offset = NULL; /* We point to the start of glamor_priv->vb every time, and diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c index 40b9ca4ea..a5b4b6802 100644 --- a/glamor/glamor_xv.c +++ b/glamor/glamor_xv.c @@ -32,9 +32,7 @@ * Xv acceleration implementation */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glamor_priv.h" #include "glamor_transform.h" @@ -141,24 +139,22 @@ static const glamor_facet glamor_facet_xv_uyvy = { "in vec2 tcs;\n" ), .fs_exec = ( - " vec3 uyv;\n" - " vec4 frameOut = texture2D(sampler, tcs.st);\n" - "\n" - " vec4 prevPixel = texture2D(sampler, vec2(tcs.s - texelSize.x, tcs.t));\n" - " vec4 nextPixel = texture2D(sampler, vec2(tcs.s + texelSize.x, tcs.t));\n" - "\n" - " float delta = 0.50;\n" - "\n" - " int even = int(mod(tcs.x / texelSize.x, 2.0));\n" - "\n" - " uyv.rgb = float(even)*vec3(frameOut.rg, nextPixel.r) + (1.0-float(even))*vec3(prevPixel.r, frameOut.gr);\n" - "\n" - " frameOut.r = uyv.g + 1.403*(uyv.r - delta);\n" - " frameOut.g = uyv.g - 0.714*(uyv.r - delta) - 0.344*(uyv.b - delta);\n" - " frameOut.b = uyv.g + 1.773*(uyv.b - delta);\n" - " frameOut.a = 1.0;\n" - " frag_color = frameOut;\n" - ), + " vec4 temp1;\n" + " vec2 xy = texture(sampler, tcs.st).xy;\n" + " vec2 prev_xy = texture(sampler, vec2(tcs.s - texelSize.x, tcs.t)).xy;\n" + " vec2 next_xy = texture(sampler, vec2(tcs.s + texelSize.x, tcs.t)).xy;\n" + "\n" + " vec3 sample_yuv;\n" + " int odd = int(mod(tcs.x / texelSize.x, 2.0));\n" + " int even = 1 - odd;\n" + " sample_yuv.yxz = float(even)*vec3(xy, next_xy.x) + float(odd)*vec3(prev_xy.x, xy.yx);\n" + "\n" + " temp1.xyz = offsetyco.www * vec3(sample_yuv.x) + offsetyco.xyz;\n" + " temp1.xyz = ucogamma.xyz * vec3(sample_yuv.y) + temp1.xyz;\n" + " temp1.xyz = clamp(vco.xyz * vec3(sample_yuv.z) + temp1.xyz, 0.0, 1.0);\n" + " temp1.w = 1.0;\n" + " frag_color = temp1;\n" + ), }; static const glamor_facet glamor_facet_xv_rgb_raw = { @@ -379,9 +375,16 @@ glamor_xv_query_image_attributes(int id, offsets[0] = 0; size *= *h; break; - case FOURCC_RGB565: case FOURCC_UYVY: /* UYVU is single-plane really, all tranformation is processed inside a shader */ + size = ALIGN(*w, 2) * 2; + if (pitches) + pitches[0] = size; + if (offsets) + offsets[0] = 0; + size *= *h; + break; + case FOURCC_RGB565: size = *w * 2; if (pitches) pitches[0] = size; @@ -787,6 +790,15 @@ glamor_xv_put_image(glamor_port_private *port_priv, buf + s2offset, srcPitch); break; case FOURCC_UYVY: + srcPitch = ALIGN(width, 2) * 2; + full_box.x1 = 0; + full_box.y1 = 0; + full_box.x2 = width; + full_box.y2 = height; + glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1, + 0, 0, 0, 0, + buf, srcPitch); + break; case FOURCC_RGB565: srcPitch = width * 2; full_box.x1 = 0; diff --git a/glx/clientinfo.c b/glx/clientinfo.c index 74ad91991..899f5d2c0 100644 --- a/glx/clientinfo.c +++ b/glx/clientinfo.c @@ -20,13 +20,11 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include "misc.h" #include "glxserver.h" #include "indirect_dispatch.h" -#include "glxbyteorder.h" #include "unpack.h" static int @@ -43,7 +41,7 @@ set_client_info(__GLXclientState * cl, xGLXSetClientInfoARBReq * req, /* Verify that the size of the packet matches the size inferred from the * sizes specified for the various fields. */ - size = sz_xGLXSetClientInfoARBReq; + size = sizeof(xGLXSetClientInfoARBReq); size = safe_add(size, safe_mul(req->numVersions, bytes_per_version)); size = safe_add(size, safe_pad(req->numGLExtensionBytes)); size = safe_add(size, safe_pad(req->numGLXExtensionBytes)); diff --git a/glx/createcontext.c b/glx/createcontext.c index 37d14fe99..59ecf3eaf 100644 --- a/glx/createcontext.c +++ b/glx/createcontext.c @@ -20,9 +20,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <GL/glxtokens.h> #include "glxserver.h" @@ -116,7 +114,7 @@ __glXDisp_CreateContextAttribsARB(__GLXclientState * cl, GLbyte * pc) /* Verify that the size of the packet matches the size inferred from the * sizes specified for the various fields. */ - const unsigned expected_size = (sz_xGLXCreateContextAttribsARBReq + const unsigned expected_size = (sizeof(xGLXCreateContextAttribsARBReq) + (req->numAttribs * 8)) / 4; if (req->length != expected_size) diff --git a/glx/glxbyteorder.h b/glx/glxbyteorder.h deleted file mode 100644 index 8f0cd8a4b..000000000 --- a/glx/glxbyteorder.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2006, 2007 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, THE AUTHORS, AND/OR THEIR SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glxbyteorder.h - * Platform glue for handling byte-ordering issues in GLX protocol. - * - * \author Ian Romanick <idr@us.ibm.com> - */ -#if !defined(__GLXBYTEORDER_H__) -#define __GLXBYTEORDER_H__ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "misc.h" - -#endif /* !defined(__GLXBYTEORDER_H__) */ diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 651e8d39b..90154b404 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include <assert.h> @@ -704,14 +702,13 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc) { ClientPtr client = cl->client; xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc; - xGLXIsDirectReply reply; __GLXcontext *glxc; int err; if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err)) return err; - reply = (xGLXIsDirectReply) { + xGLXIsDirectReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, @@ -723,7 +720,7 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc) __GLX_SWAP_SHORT(&reply.sequenceNumber); __GLX_SWAP_INT(&reply.length); } - WriteToClient(client, sz_xGLXIsDirectReply, &reply); + WriteToClient(client, sizeof(xGLXIsDirectReply), &reply); return Success; } @@ -733,13 +730,11 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc) { ClientPtr client = cl->client; xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; - xGLXQueryVersionReply reply; - GLuint major, minor; REQUEST_SIZE_MATCH(xGLXQueryVersionReq); - major = req->majorVersion; - minor = req->minorVersion; + GLuint major = req->majorVersion; + GLuint minor = req->minorVersion; (void) major; (void) minor; @@ -748,7 +743,7 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc) ** client if it wants to work with older clients; however, in this ** implementation the server just returns its version number. */ - reply = (xGLXQueryVersionReply) { + xGLXQueryVersionReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, @@ -764,7 +759,7 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc) __GLX_SWAP_INT(&reply.minorVersion); } - WriteToClient(client, sz_xGLXQueryVersionReply, &reply); + WriteToClient(client, sizeof(xGLXQueryVersionReply), &reply); return Success; } @@ -908,7 +903,6 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc) { xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; ClientPtr client = cl->client; - xGLXGetVisualConfigsReply reply; __GLXscreen *pGlxScreen; __GLXconfig *modes; CARD32 buf[GLX_VIS_CONFIG_TOTAL]; @@ -920,7 +914,7 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc) if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; - reply = (xGLXGetVisualConfigsReply) { + xGLXGetVisualConfigsReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = (pGlxScreen->numVisuals * @@ -936,7 +930,7 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc) __GLX_SWAP_INT(&reply.numProps); } - WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply); + WriteToClient(client, sizeof(xGLXGetVisualConfigsReply), &reply); for (i = 0; i < pGlxScreen->numVisuals; i++) { modes = pGlxScreen->visuals[i]; @@ -1023,7 +1017,6 @@ static int DoGetFBConfigs(__GLXclientState * cl, unsigned screen) { ClientPtr client = cl->client; - xGLXGetFBConfigsReply reply; __GLXscreen *pGlxScreen; CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH]; int p, err; @@ -1035,7 +1028,7 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen) if (!validGlxScreen(cl->client, screen, &pGlxScreen, &err)) return err; - reply = (xGLXGetFBConfigsReply) { + xGLXGetFBConfigsReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs, @@ -1050,7 +1043,7 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen) __GLX_SWAP_INT(&reply.numAttribs); } - WriteToClient(client, sz_xGLXGetFBConfigsReply, &reply); + WriteToClient(client, sizeof(xGLXGetFBConfigsReply), &reply); for (modes = pGlxScreen->fbconfigs; modes != NULL; modes = modes->next) { p = 0; @@ -1395,7 +1388,7 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId, if (!pPixmap) return BadAlloc; - err = XaceHook(XACE_RESOURCE_ACCESS, client, glxDrawableId, X11_RESTYPE_PIXMAP, + err = XaceHookResourceAccess(client, glxDrawableId, X11_RESTYPE_PIXMAP, pPixmap, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (err != Success) { (*pGlxScreen->pScreen->DestroyPixmap) (pPixmap); @@ -1659,28 +1652,26 @@ __glXDisp_SwapBuffers(__GLXclientState * cl, GLbyte * pc) return Success; } +#define GLX_QUERY_NPROPS 5 + static int DoQueryContext(__GLXclientState * cl, GLXContextID gcId) { ClientPtr client = cl->client; __GLXcontext *ctx; - xGLXQueryContextInfoEXTReply reply; - int nProps = 5; - int sendBuf[nProps * 2]; - int nReplyBytes; + CARD32 sendBuf[GLX_QUERY_NPROPS * 2]; int err; if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err)) return err; - reply = (xGLXQueryContextInfoEXTReply) { + xGLXQueryContextInfoEXTReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, - .length = nProps << 1, - .n = nProps + .length = bytes_to_int32(sizeof(sendBuf)), + .n = GLX_QUERY_NPROPS, }; - nReplyBytes = reply.length << 2; sendBuf[0] = GLX_SHARE_CONTEXT_EXT; sendBuf[1] = (int) (ctx->share_id); sendBuf[2] = GLX_VISUAL_ID_EXT; @@ -1693,25 +1684,20 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId) sendBuf[9] = (int) (ctx->renderType); if (client->swapped) { - int length = reply.length; - - __GLX_DECLARE_SWAP_VARIABLES; - __GLX_DECLARE_SWAP_ARRAY_VARIABLES; - __GLX_SWAP_SHORT(&reply.sequenceNumber); - __GLX_SWAP_INT(&reply.length); - __GLX_SWAP_INT(&reply.n); - WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply); - __GLX_SWAP_INT_ARRAY((int *) sendBuf, length); - WriteToClient(client, length << 2, sendBuf); - } - else { - WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply); - WriteToClient(client, nReplyBytes, sendBuf); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swapl(&reply.n); + SwapLongs(sendBuf, sizeof(sendBuf) / 4); } + WriteToClient(client, sizeof(xGLXQueryContextInfoEXTReply), &reply); + WriteToClient(client, sizeof(sendBuf), sendBuf); + return Success; } +#undef GLX_QUERY_NPROPS + int __glXDisp_QueryContextInfoEXT(__GLXclientState * cl, GLbyte * pc) { @@ -1879,7 +1865,6 @@ static int DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) { ClientPtr client = cl->client; - xGLXGetDrawableAttributesReply reply; __GLXdrawable *pGlxDraw = NULL; DrawablePtr pDraw; CARD32 attributes[20]; @@ -1929,7 +1914,7 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) ATTRIB(GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT); #undef ATTRIB - reply = (xGLXGetDrawableAttributesReply) { + xGLXGetDrawableAttributesReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = num << 1, @@ -1944,12 +1929,12 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId) __GLX_SWAP_SHORT(&reply.sequenceNumber); __GLX_SWAP_INT(&reply.length); __GLX_SWAP_INT(&reply.numAttribs); - WriteToClient(client, sz_xGLXGetDrawableAttributesReply, &reply); + WriteToClient(client, sizeof(xGLXGetDrawableAttributesReply), &reply); __GLX_SWAP_INT_ARRAY((int *) attributes, length); WriteToClient(client, length << 2, attributes); } else { - WriteToClient(client, sz_xGLXGetDrawableAttributesReply, &reply); + WriteToClient(client, sizeof(xGLXGetDrawableAttributesReply), &reply); WriteToClient(client, reply.length * sizeof(CARD32), attributes); } @@ -2029,8 +2014,8 @@ __glXDisp_Render(__GLXclientState * cl, GLbyte * pc) } commandsDone = 0; - pc += sz_xGLXRenderReq; - left = (req->length << 2) - sz_xGLXRenderReq; + pc += sizeof(xGLXRenderReq); + left = (req->length << 2) - sizeof(xGLXRenderReq); while (left > 0) { __GLXrenderSizeData entry; int extra = 0; @@ -2139,18 +2124,18 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc) /* ** Check the request length. */ - if ((req->length << 2) != safe_pad(dataBytes) + sz_xGLXRenderLargeReq) { + if ((req->length << 2) != safe_pad(dataBytes) + sizeof(xGLXRenderLargeReq)) { client->errorValue = req->length; /* Reset in case this isn't 1st request. */ ResetLargeCommandStatus(glxc); return BadLength; } - pc += sz_xGLXRenderLargeReq; + pc += sizeof(xGLXRenderLargeReq); if (glxc->largeCmdRequestsSoFar == 0) { __GLXrenderSizeData entry; int extra = 0; - int left = (req->length << 2) - sz_xGLXRenderLargeReq; + int left = (req->length << 2) - sizeof(xGLXRenderLargeReq); int cmdlen; int err; @@ -2375,7 +2360,6 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) { ClientPtr client = cl->client; xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc; - xGLXQueryExtensionsStringReply reply; __GLXscreen *pGlxScreen; size_t n, length; char *buf; @@ -2386,7 +2370,8 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) n = strlen(pGlxScreen->GLXextensions) + 1; length = __GLX_PAD(n) >> 2; - reply = (xGLXQueryExtensionsStringReply) { + + xGLXQueryExtensionsStringReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = length, @@ -2405,12 +2390,12 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) __GLX_SWAP_SHORT(&reply.sequenceNumber); __GLX_SWAP_INT(&reply.length); __GLX_SWAP_INT(&reply.n); - WriteToClient(client, sz_xGLXQueryExtensionsStringReply, &reply); + WriteToClient(client, sizeof(xGLXQueryExtensionsStringReply), &reply); __GLX_SWAP_INT_ARRAY((int *) buf, length); WriteToClient(client, length << 2, buf); } else { - WriteToClient(client, sz_xGLXQueryExtensionsStringReply, &reply); + WriteToClient(client, sizeof(xGLXQueryExtensionsStringReply), &reply); WriteToClient(client, (int) (length << 2), buf); } @@ -2427,7 +2412,6 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) { ClientPtr client = cl->client; xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc; - xGLXQueryServerStringReply reply; size_t n, length; const char *ptr; char *buf; @@ -2459,7 +2443,8 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) n = strlen(ptr) + 1; length = __GLX_PAD(n) >> 2; - reply = (xGLXQueryServerStringReply) { + + xGLXQueryServerStringReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = length, @@ -2477,13 +2462,13 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) __GLX_SWAP_SHORT(&reply.sequenceNumber); __GLX_SWAP_INT(&reply.length); __GLX_SWAP_INT(&reply.n); - WriteToClient(client, sz_xGLXQueryServerStringReply, &reply); + WriteToClient(client, sizeof(xGLXQueryServerStringReply), &reply); /** no swap is needed for an array of chars **/ /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */ WriteToClient(client, length << 2, buf); } else { - WriteToClient(client, sz_xGLXQueryServerStringReply, &reply); + WriteToClient(client, sizeof(xGLXQueryServerStringReply), &reply); WriteToClient(client, (int) (length << 2), buf); } diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index 7d6674470..59ce663b7 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include "glxserver.h" diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 822515a86..c4e02b7b7 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -21,9 +21,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include <stdio.h> @@ -977,12 +975,12 @@ __glXDRIscreenProbe(ScreenPtr pScreen) screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs); - options = xnfalloc(sizeof(GLXOptions)); + options = XNFalloc(sizeof(GLXOptions)); memcpy(options, GLXOptions, sizeof(GLXOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); glvnd = xf86GetOptValString(options, GLXOPT_VENDOR_LIBRARY); if (glvnd) - screen->base.glvnd = xnfstrdup(glvnd); + screen->base.glvnd = XNFstrdup(glvnd); free(options); if (!screen->base.glvnd) diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c index 35a539629..0d83fa714 100644 --- a/glx/glxdricommon.c +++ b/glx/glxdricommon.c @@ -23,9 +23,7 @@ * SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <ctype.h> #include <stdint.h> diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c index c57d80db7..ac657d6f8 100644 --- a/glx/glxdriswrast.c +++ b/glx/glxdriswrast.c @@ -24,9 +24,7 @@ * SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include <stdio.h> diff --git a/glx/glxext.c b/glx/glxext.c index 585f64eda..216dea98d 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -28,11 +28,12 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> + +#include "os/client_priv.h" + #include "glxserver.h" #include <windowstr.h> #include <propertyst.h> diff --git a/glx/glxscreens.c b/glx/glxscreens.c index 5cd9fcfd4..ef969fcd6 100644 --- a/glx/glxscreens.c +++ b/glx/glxscreens.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <GL/glxtokens.h> #include <string.h> @@ -427,7 +425,7 @@ __glXScreenInit(__GLXscreen * pGlxScreen, ScreenPtr pScreen) i = __glXGetExtensionString(pGlxScreen->glx_enable_bits, NULL); if (i > 0) { - pGlxScreen->GLXextensions = xnfalloc(i); + pGlxScreen->GLXextensions = XNFalloc(i); (void) __glXGetExtensionString(pGlxScreen->glx_enable_bits, pGlxScreen->GLXextensions); } diff --git a/glx/indirect_dispatch.c b/glx/indirect_dispatch.c index 24784e693..6459dbf26 100644 --- a/glx/indirect_dispatch.c +++ b/glx/indirect_dispatch.c @@ -1,5 +1,3 @@ -/* DO NOT EDIT - This file generated automatically by glX_proto_recv.py (from Mesa) script */ - /* * (C) Copyright IBM Corporation 2005 * All Rights Reserved. @@ -24,14 +22,16 @@ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include <dix-config.h> #include <inttypes.h> + #include "glxserver.h" #include "indirect_size.h" #include "indirect_size_get.h" #include "indirect_dispatch.h" -#include "glxbyteorder.h" #include "indirect_util.h" +#include "misc.h" #include "singlesize.h" #define __GLX_PAD(x) (((x) + 3) & ~3) diff --git a/glx/indirect_dispatch_swap.c b/glx/indirect_dispatch_swap.c index 3eeed00f3..aa31ebded 100644 --- a/glx/indirect_dispatch_swap.c +++ b/glx/indirect_dispatch_swap.c @@ -1,5 +1,3 @@ -/* DO NOT EDIT - This file generated automatically by glX_proto_recv.py (from Mesa) script */ - /* * (C) Copyright IBM Corporation 2005 * All Rights Reserved. @@ -24,14 +22,16 @@ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include <dix-config.h> #include <inttypes.h> + #include "glxserver.h" #include "indirect_size.h" #include "indirect_size_get.h" #include "indirect_dispatch.h" -#include "glxbyteorder.h" #include "indirect_util.h" +#include "misc.h" #include "singlesize.h" #define __GLX_PAD(x) (((x) + 3) & ~3) diff --git a/glx/indirect_program.c b/glx/indirect_program.c index c7bfa03ca..1f10c41a7 100644 --- a/glx/indirect_program.c +++ b/glx/indirect_program.c @@ -28,14 +28,11 @@ * * \author Ian Romanick <idr@us.ibm.com> */ - -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" -#include "glxbyteorder.h" #include "glxext.h" +#include "misc.h" #include "singlesize.h" #include "unpack.h" #include "indirect_size_get.h" diff --git a/glx/indirect_reqsize.c b/glx/indirect_reqsize.c index 020aae2fe..18dcfee2a 100644 --- a/glx/indirect_reqsize.c +++ b/glx/indirect_reqsize.c @@ -24,12 +24,14 @@ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include <dix-config.h> #include <GL/gl.h> + #include "glxserver.h" -#include "glxbyteorder.h" #include "indirect_size.h" #include "indirect_reqsize.h" +#include "misc.h" #if defined(__CYGWIN__) || defined(__MINGW32__) #undef HAVE_ALIAS diff --git a/glx/indirect_texture_compression.c b/glx/indirect_texture_compression.c index 6d25bcd04..d45b0a910 100644 --- a/glx/indirect_texture_compression.c +++ b/glx/indirect_texture_compression.c @@ -22,14 +22,11 @@ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" -#include "glxbyteorder.h" #include "glxext.h" +#include "misc.h" #include "singlesize.h" #include "unpack.h" #include "indirect_size_get.h" diff --git a/glx/indirect_util.c b/glx/indirect_util.c index ba180b0cc..83579c529 100644 --- a/glx/indirect_util.c +++ b/glx/indirect_util.c @@ -22,26 +22,23 @@ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include <inttypes.h> #include <string.h> - -#include <X11/Xmd.h> +#include <X11/Xmd.h> // needs to be before glxproto.h #include <GL/gl.h> #include <GL/glxproto.h> -#include <inttypes.h> + #include "indirect_size.h" #include "indirect_size_get.h" #include "indirect_dispatch.h" #include "glxserver.h" -#include "glxbyteorder.h" #include "singlesize.h" #include "glxext.h" #include "indirect_table.h" #include "indirect_util.h" +#include "misc.h" #define __GLX_PAD(a) (((a)+3)&~3) @@ -115,7 +112,6 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements, size_t element_size, GLboolean always_array, CARD32 retval) { size_t reply_ints = 0; - xGLXSingleReply reply = { 0, }; if (__glXErrorOccured()) { elements = 0; @@ -124,11 +120,13 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements, reply_ints = bytes_to_int32(elements * element_size); } - reply.length = reply_ints; - reply.type = X_Reply; - reply.sequenceNumber = client->sequence; - reply.size = elements; - reply.retval = retval; + xGLXSingleReply reply = { + .length = reply_ints, + .type = X_Reply, + .sequenceNumber = client->sequence, + .size = elements, + .retval = retval, + }; /* It is faster on almost always every architecture to just copy the 8 * bytes, even when not necessary, than check to see of the value of @@ -137,7 +135,7 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements, */ (void) memcpy(&reply.pad3, data, 8); - WriteToClient(client, sz_xGLXSingleReply, &reply); + WriteToClient(client, sizeof(xGLXSingleReply), &reply); if (reply_ints != 0) { WriteToClient(client, reply_ints * 4, data); @@ -162,7 +160,6 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements, size_t element_size, GLboolean always_array, CARD32 retval) { size_t reply_ints = 0; - xGLXSingleReply reply = { 0, }; if (__glXErrorOccured()) { elements = 0; @@ -171,11 +168,13 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements, reply_ints = bytes_to_int32(elements * element_size); } - reply.length = bswap_32(reply_ints); - reply.type = X_Reply; - reply.sequenceNumber = bswap_16(client->sequence); - reply.size = bswap_32(elements); - reply.retval = bswap_32(retval); + xGLXSingleReply reply = { + .length = bswap_32(reply_ints), + .type = X_Reply, + .sequenceNumber = bswap_16(client->sequence), + .size = bswap_32(elements), + .retval = bswap_32(retval), + }; /* It is faster on almost always every architecture to just copy the 8 * bytes, even when not necessary, than check to see of the value of @@ -184,7 +183,7 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements, */ (void) memcpy(&reply.pad3, data, 8); - WriteToClient(client, sz_xGLXSingleReply, &reply); + WriteToClient(client, sizeof(xGLXSingleReply), &reply); if (reply_ints != 0) { WriteToClient(client, reply_ints * 4, data); diff --git a/glx/render2.c b/glx/render2.c index 8d9b5f4d2..5d126eeca 100644 --- a/glx/render2.c +++ b/glx/render2.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <glxserver.h> #include "unpack.h" diff --git a/glx/render2swap.c b/glx/render2swap.c index 6ed364f75..243dd0fed 100644 --- a/glx/render2swap.c +++ b/glx/render2swap.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" #include "unpack.h" diff --git a/glx/renderpix.c b/glx/renderpix.c index 91ba91187..958f699c1 100644 --- a/glx/renderpix.c +++ b/glx/renderpix.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" #include "unpack.h" diff --git a/glx/renderpixswap.c b/glx/renderpixswap.c index a4cb246bb..322dc7e86 100644 --- a/glx/renderpixswap.c +++ b/glx/renderpixswap.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" #include "unpack.h" diff --git a/glx/rensize.c b/glx/rensize.c index 55ad4a2af..821c6b3fb 100644 --- a/glx/rensize.c +++ b/glx/rensize.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <GL/gl.h> #include "glxserver.h" diff --git a/glx/single2.c b/glx/single2.c index 36a01f0cb..18fd2c1bc 100644 --- a/glx/single2.c +++ b/glx/single2.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include <stdio.h> @@ -108,7 +106,6 @@ int __glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc) { ClientPtr client = cl->client; - xGLXRenderModeReply reply; __GLXcontext *cx; GLint nitems = 0, retBytes = 0, retval, newModeCheck; GLubyte *retBuffer = NULL; @@ -193,7 +190,7 @@ __glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc) ** selection array, as per the API for glRenderMode itself. */ noChangeAllowed:; - reply = (xGLXRenderModeReply) { + xGLXRenderModeReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = nitems, @@ -201,7 +198,7 @@ __glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc) .size = nitems, .newMode = newMode }; - WriteToClient(client, sz_xGLXRenderModeReply, &reply); + WriteToClient(client, sizeof(xGLXRenderModeReply), &reply); if (retBytes) { WriteToClient(client, retBytes, retBuffer); } @@ -232,7 +229,6 @@ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc) ClientPtr client = cl->client; __GLXcontext *cx; int error; - xGLXSingleReply reply = { 0, }; REQUEST_SIZE_MATCH(xGLXSingleReq); @@ -246,6 +242,8 @@ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc) /* Send empty reply packet to indicate finish is finished */ client = cl->client; + + xGLXSingleReply reply = { 0 }; __GLX_BEGIN_REPLY(0); __GLX_SEND_HEADER(); return Success; @@ -329,7 +327,6 @@ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap) __GLXcontext *cx; GLenum name; const char *string; - xGLXSingleReply reply = { 0, }; __GLX_DECLARE_SWAP_VARIABLES; int error; @@ -383,6 +380,7 @@ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap) length = strlen((const char *) string) + 1; } + xGLXSingleReply reply = { 0 }; __GLX_BEGIN_REPLY(length); __GLX_PUT_SIZE(length); diff --git a/glx/single2swap.c b/glx/single2swap.c index b140946ba..4bafd0dd5 100644 --- a/glx/single2swap.c +++ b/glx/single2swap.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" #include "glxutil.h" @@ -114,7 +112,6 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc) { ClientPtr client = cl->client; __GLXcontext *cx; - xGLXRenderModeReply reply; GLint nitems = 0, retBytes = 0, retval, newModeCheck; GLubyte *retBuffer = NULL; GLenum newMode; @@ -205,7 +202,7 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc) ** selection array, as per the API for glRenderMode itself. */ noChangeAllowed:; - reply = (xGLXRenderModeReply) { + xGLXRenderModeReply reply = { .type = X_Reply, .sequenceNumber = client->sequence, .length = nitems, @@ -218,7 +215,7 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc) __GLX_SWAP_INT(&reply.retval); __GLX_SWAP_INT(&reply.size); __GLX_SWAP_INT(&reply.newMode); - WriteToClient(client, sz_xGLXRenderModeReply, &reply); + WriteToClient(client, sizeof(xGLXRenderModeReply), &reply); if (retBytes) { WriteToClient(client, retBytes, retBuffer); } @@ -252,7 +249,6 @@ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc) ClientPtr client = cl->client; __GLXcontext *cx; int error; - xGLXSingleReply reply = { 0, }; __GLX_DECLARE_SWAP_VARIABLES; @@ -268,6 +264,7 @@ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc) glFinish(); /* Send empty reply packet to indicate finish is finished */ + xGLXSingleReply reply = { 0 }; __GLX_BEGIN_REPLY(0); __GLX_PUT_RETVAL(0); __GLX_SWAP_REPLY_HEADER(); diff --git a/glx/singlepix.c b/glx/singlepix.c index e1bed19aa..95dbf51e7 100644 --- a/glx/singlepix.c +++ b/glx/singlepix.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" #include "glxext.h" diff --git a/glx/singlepixswap.c b/glx/singlepixswap.c index 8e4d9bddf..0e2779145 100644 --- a/glx/singlepixswap.c +++ b/glx/singlepixswap.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" #include "glxext.h" diff --git a/glx/singlesize.c b/glx/singlesize.c index 4c60b6920..344ffef7f 100644 --- a/glx/singlesize.c +++ b/glx/singlesize.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <GL/gl.h> #include "glxserver.h" diff --git a/glx/swap_interval.c b/glx/swap_interval.c index 232055080..0af258e09 100644 --- a/glx/swap_interval.c +++ b/glx/swap_interval.c @@ -22,18 +22,16 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "glxserver.h" #include "glxutil.h" #include "glxext.h" +#include "misc.h" #include "singlesize.h" #include "unpack.h" #include "indirect_size_get.h" #include "indirect_dispatch.h" -#include "glxbyteorder.h" static int DoSwapInterval(__GLXclientState * cl, GLbyte * pc, int do_swap); diff --git a/glx/unpack.h b/glx/unpack.h index 9676e64c4..256073470 100644 --- a/glx/unpack.h +++ b/glx/unpack.h @@ -59,7 +59,7 @@ reply.sequenceNumber = client->sequence; #define __GLX_SEND_HEADER() \ - WriteToClient (client, sz_xGLXSingleReply, &reply); + WriteToClient (client, sizeof(xGLXSingleReply), &reply); #define __GLX_PUT_RETVAL(a) \ reply.retval = (a); diff --git a/glx/vndcmds.c b/glx/vndcmds.c index cb3732d2a..4ffa5f19f 100644 --- a/glx/vndcmds.c +++ b/glx/vndcmds.c @@ -110,7 +110,7 @@ static int dispatch_GLXQueryVersion(ClientPtr client) reply.majorVersion = GlxCheckSwap(client, 1); reply.minorVersion = GlxCheckSwap(client, 4); - WriteToClient(client, sz_xGLXQueryVersionReply, &reply); + WriteToClient(client, sizeof(xGLXQueryVersionReply), &reply); return Success; } @@ -272,7 +272,7 @@ static int CommonMakeCurrent(ClientPtr client, } reply.contextTag = GlxCheckSwap(client, reply.contextTag); - WriteToClient(client, sz_xGLXMakeCurrentReply, &reply); + WriteToClient(client, sizeof(xGLXMakeCurrentReply), &reply); return Success; } diff --git a/glx/vndext.c b/glx/vndext.c index 92b3001a3..a0519ff65 100644 --- a/glx/vndext.c +++ b/glx/vndext.c @@ -40,6 +40,8 @@ #include <GL/glxproto.h> #include "vndservervendor.h" +#include "dix/dix_priv.h" + ExtensionEntry *GlxExtensionEntry; int GlxErrorBase = 0; static CallbackListRec vndInitCallbackList; diff --git a/glx/xfont.c b/glx/xfont.c index bd090cb15..3e84369e8 100644 --- a/glx/xfont.c +++ b/glx/xfont.c @@ -28,9 +28,7 @@ * Silicon Graphics, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" diff --git a/hw/kdrive/Xkdrive.man b/hw/kdrive/Xkdrive.man index 4a5ee21c4..2111e2b86 100644 --- a/hw/kdrive/Xkdrive.man +++ b/hw/kdrive/Xkdrive.man @@ -10,13 +10,14 @@ Xkdrive \- tiny X server .SH DESCRIPTION .B Xkdrive is a family of X servers designed to be particularly small. This -manual page describes the common functionality of the +manual page describes the common functionality of the .B Xkdrive servers; for information on a specific X server, please refer to the relevant manual page. .SH OPTIONS In addition to the standard options accepted by all X servers (see -Xserver(1)), all the +.BR Xserver (1)), +all the .B Xkdrive servers accept the following options: .TP 8 @@ -44,7 +45,12 @@ enable emulation of a middle mouse button by chording. .B -3button disable emulation of a middle mouse button by chording. .SH SEE ALSO -X(@miscmansuffix@), Xserver(1), xdm(1), xinit(1), Xvesa(1), Xfbdev(1). +.BR X (@miscmansuffix@), +.BR Xserver (1), +.BR xdm (1), +.BR xinit (1), +.BR Xvesa (1), +.BR Xfbdev (1). .SH AUTHORS The Xkdrive common core was written by Keith Packard, and is based on the Sample Implementation of X. diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 3d0dd872b..069270219 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -23,13 +23,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <xcb/xcb_keysyms.h> #include <X11/keysym.h> +#include "mi/mipointer_priv.h" +#include "os/client_priv.h" #include "os/osdep.h" #include "ephyr.h" @@ -1265,7 +1265,7 @@ static Status MouseInit(KdPointerInfo * pi) { pi->driverPrivate = (EphyrPointerPrivate *) - calloc(sizeof(EphyrPointerPrivate), 1); + calloc(1, sizeof(EphyrPointerPrivate)); ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE; pi->nAxes = 3; pi->nButtons = 32; @@ -1326,7 +1326,7 @@ EphyrKeyboardInit(KdKeyboardInfo * ki) XkbControlsRec controls; ki->driverPrivate = (EphyrKbdPrivate *) - calloc(sizeof(EphyrKbdPrivate), 1); + calloc(1, sizeof(EphyrKbdPrivate)); if (hostx_load_keymap(&keySyms, modmap, &controls)) { XkbApplyMappingChange(ki->dixdev, &keySyms, diff --git a/hw/kdrive/ephyr/ephyr_draw.c b/hw/kdrive/ephyr/ephyr_draw.c index 64e07a7d1..ea9f0cb1a 100644 --- a/hw/kdrive/ephyr/ephyr_draw.c +++ b/hw/kdrive/ephyr/ephyr_draw.c @@ -25,9 +25,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "ephyr.h" #include "exa_priv.h" diff --git a/hw/kdrive/ephyr/ephyr_glamor_xv.c b/hw/kdrive/ephyr/ephyr_glamor_xv.c index b5eae48c8..a93afa17b 100644 --- a/hw/kdrive/ephyr/ephyr_glamor_xv.c +++ b/hw/kdrive/ephyr/ephyr_glamor_xv.c @@ -21,9 +21,7 @@ * IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "kdrive.h" #include "kxv.h" @@ -123,7 +121,7 @@ ephyr_glamor_xv_init(ScreenPtr screen) glamor_xv_core_init(screen); - adaptor = xnfcalloc(1, sizeof(*adaptor)); + adaptor = XNFcallocarray(1, sizeof(*adaptor)); adaptor->name = "glamor textured video"; adaptor->type = XvWindowMask | XvInputMask | XvImageMask; @@ -135,9 +133,9 @@ ephyr_glamor_xv_init(ScreenPtr screen) adaptor->nFormats = NUM_FORMATS; adaptor->nPorts = 16; /* Some absurd number */ - port_privates = xnfcalloc(adaptor->nPorts, + port_privates = XNFcallocarray(adaptor->nPorts, sizeof(glamor_port_private)); - adaptor->pPortPrivates = xnfcalloc(adaptor->nPorts, + adaptor->pPortPrivates = XNFcallocarray(adaptor->nPorts, sizeof(glamor_port_private *)); for (i = 0; i < adaptor->nPorts; i++) { adaptor->pPortPrivates[i].ptr = &port_privates[i]; diff --git a/hw/kdrive/ephyr/ephyrcursor.c b/hw/kdrive/ephyr/ephyrcursor.c index 3f192d034..ac7a245f2 100644 --- a/hw/kdrive/ephyr/ephyrcursor.c +++ b/hw/kdrive/ephyr/ephyrcursor.c @@ -24,15 +24,17 @@ * Adam Jackson <ajax@redhat.com> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include <xcb/render.h> +#include <xcb/xcb_renderutil.h> + +#include "mi/mipointer_priv.h" + #include "ephyr.h" #include "ephyrlog.h" #include "hostx.h" #include "cursorstr.h" -#include <xcb/render.h> -#include <xcb/xcb_renderutil.h> static DevPrivateKeyRec ephyrCursorPrivateKey; diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 25c078bfb..9306f3367 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -23,9 +23,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" #include "os/cmdline.h" diff --git a/hw/kdrive/ephyr/ephyrvideo.c b/hw/kdrive/ephyr/ephyrvideo.c index 2dbddfb8d..cdf21304e 100644 --- a/hw/kdrive/ephyr/ephyrvideo.c +++ b/hw/kdrive/ephyr/ephyrvideo.c @@ -26,9 +26,7 @@ * Dodji Seketeli <dodji@openedhand.com> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include <X11/extensions/Xv.h> #include <xcb/xcb.h> diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index be894bd36..b7ac56d50 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -23,12 +23,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif - -#include "hostx.h" -#include "input.h" #include <stdlib.h> #include <stdio.h> @@ -37,12 +32,15 @@ #include <errno.h> #include <time.h> #include <err.h> - #include <sys/ipc.h> #include <sys/shm.h> #include <sys/time.h> #include <sys/mman.h> +#include "dix/input_priv.h" + +#include "hostx.h" + #define X_INCLUDE_STRING_H #include <X11/Xos_r.h> #include <X11/keysym.h> @@ -1580,7 +1578,7 @@ __glXQueryServerString(CARD32 name) /* The spec doesn't mention this, but the Xorg server replies with * a string already terminated with '\0'. */ len = xcb_glx_query_server_string_string_length(reply); - buf = xnfalloc(len); + buf = XNFalloc(len); memcpy(buf, str, len); free(reply); diff --git a/hw/kdrive/ephyr/man/Xephyr.man b/hw/kdrive/ephyr/man/Xephyr.man index cc8a80f21..765e43f2d 100644 --- a/hw/kdrive/ephyr/man/Xephyr.man +++ b/hw/kdrive/ephyr/man/Xephyr.man @@ -39,35 +39,36 @@ uses the host X server window as "framebuffer" via fast SHM XImages. It also has support for "visually" debugging what the server is painting. .SH OPTIONS -The server accepts all the standard options of Xserver(@appmansuffix@) +The server accepts all the standard options of +.BR Xserver (@appmansuffix@) and the following additional options: .TP 8 -.BI -screen " width" x height +.BI \-screen " width" x height sets the screen size. .TP 8 -.BI -parent " id" +.BI \-parent " id" uses existing window .I id . If a -.BI -screen +.B \-screen argument follows a -.BI -parent +.B \-parent argument, this screen is embedded into the given window. .TP 8 -.B -host-cursor +.B \-host\-cursor set 'cursor acceleration': The host's cursor is reused. This is only really there to aid debugging by avoiding server paints for the cursor. Performance improvement is negligible. .TP 8 -.B -resizeable +.B \-resizeable Allow the Xephyr window to be resized, even if not embedded into a parent window. By default, the Xephyr window has a fixed size. .TP 8 -.B -no-host-grab +.B \-no\-host\-grab Disable grabbing the keyboard and mouse. .SH "SIGNALS" -Send a SIGUSR1 to the server (e.g. pkill -USR1 Xephyr) to +Send a SIGUSR1 to the server (e.g. pkill \-USR1 Xephyr) to toggle the debugging mode. In this mode red rectangles are painted to screen areas getting painted before painting the actual content. @@ -75,15 +76,14 @@ The delay between this can be altered by setting a XEPHYR_PAUSE env var to a value in micro seconds. .SH CAVEATS -.PP .IP \(bu 2 Rotated displays are currently updated via full blits. This is slower than a normal orientated display. Debug mode will therefore not be of much use rotated. .IP \(bu 2 -The '-host-cursor' cursor is static in its appearance. +The '\-host\-cursor' cursor is static in its appearance. .IP \(bu 2 -The build gets a warning about 'nanosleep'. I think the various '-D' +The build gets a warning about 'nanosleep'. I think the various '\-D' build flags are causing this. I haven't figured as yet how to work round it. It doesn't appear to break anything however. .IP \(bu 2 @@ -91,6 +91,7 @@ Keyboard handling is basic but works. .IP \(bu 2 Mouse button 5 probably won't work. .SH "SEE ALSO" -X(@miscmansuffix@), Xserver(@appmansuffix@) +.BR X (@miscmansuffix@), +.BR Xserver (@appmansuffix@) .SH AUTHOR -Matthew Allum <mallum@o-hand.com> 2004 +Matthew Allum <mallum@o\-hand.com> 2004 diff --git a/hw/kdrive/src/kcmap.c b/hw/kdrive/src/kcmap.c index 2e65bdde4..b19b90b08 100644 --- a/hw/kdrive/src/kcmap.c +++ b/hw/kdrive/src/kcmap.c @@ -20,11 +20,11 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "kdrive.h" +#include "dix/colormap_priv.h" + /* * Put the entire colormap into the DAC */ diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index aeefa01fb..e2eb847d7 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -20,10 +20,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include "config/hotplug_priv.h" #include "dix/screenint_priv.h" #include "os/cmdline.h" #include "os/ddx_priv.h" @@ -52,10 +51,6 @@ #include <execinfo.h> #endif -#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) -#include <hotplug.h> -#endif - /* This stub can be safely removed once we can * split input and GPU parts in hotplug.h et al. */ #include <systemd-logind.h> diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c index 4abb082b0..9a1585413 100644 --- a/hw/kdrive/src/kinfo.c +++ b/hw/kdrive/src/kinfo.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "kdrive.h" KdCardInfo *kdCardInfo; diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 5b33eeec0..ad5d4b047 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -21,10 +21,8 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #include <xkb-config.h> -#endif #include "kdrive.h" #include "inputstr.h" @@ -34,14 +32,18 @@ #include <X11/XF86keysym.h> #endif #include <stdio.h> -#ifdef __sun #include <sys/file.h> /* needed for FNONBLOCK & FASYNC */ -#endif - -#include "xkbsrv.h" #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> + +#include "config/hotplug_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" +#include "mi/mipointer_priv.h" +#include "os/cmdline.h" + +#include "xkbsrv.h" #include "XIstubs.h" /* even though we don't use stubs. cute, no? */ #include "exevents.h" #include "extinit.h" @@ -51,12 +53,6 @@ #include "inpututils.h" #include "optionstr.h" -#include "os/cmdline.h" - -#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) -#include <hotplug.h> -#endif - #define AtomFromName(x) MakeAtom(x, strlen(x), 1) struct KdConfigDevice { @@ -679,7 +675,7 @@ KdRemoveKeyboardDriver(KdKeyboardDriver * driver) KdKeyboardInfo * KdNewKeyboard(void) { - KdKeyboardInfo *ki = calloc(sizeof(KdKeyboardInfo), 1); + KdKeyboardInfo *ki = calloc(1, sizeof(KdKeyboardInfo)); if (!ki) return NULL; @@ -710,7 +706,7 @@ KdAddConfigKeyboard(char *keyboard) if (!keyboard) return Success; - new = (struct KdConfigDevice *) calloc(sizeof(struct KdConfigDevice), 1); + new = (struct KdConfigDevice *) calloc(1, sizeof(struct KdConfigDevice)); if (!new) return BadAlloc; @@ -774,7 +770,7 @@ KdAddConfigPointer(char *pointer) if (!pointer) return Success; - new = (struct KdConfigDevice *) calloc(sizeof(struct KdConfigDevice), 1); + new = (struct KdConfigDevice *) calloc(1, sizeof(struct KdConfigDevice)); if (!new) return BadAlloc; diff --git a/hw/kdrive/src/kshadow.c b/hw/kdrive/src/kshadow.c index 0cc8a1309..292a03321 100644 --- a/hw/kdrive/src/kshadow.c +++ b/hw/kdrive/src/kshadow.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "kdrive.h" Bool diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c index cb04f48cc..3077009a6 100644 --- a/hw/kdrive/src/kxv.c +++ b/hw/kdrive/src/kxv.c @@ -35,11 +35,14 @@ of the copyright holder. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include "kdrive.h" +#include <X11/extensions/Xv.h> +#include <X11/extensions/Xvproto.h> + +#include "Xext/xvdix_priv.h" + +#include "kdrive.h" #include "scrnintstr.h" #include "regionstr.h" #include "windowstr.h" @@ -49,10 +52,6 @@ of the copyright holder. #include "resource.h" #include "gcstruct.h" #include "dixstruct.h" - -#include <X11/extensions/Xv.h> -#include <X11/extensions/Xvproto.h> - #include "kxv.h" #include "fourcc.h" diff --git a/hw/meson.build b/hw/meson.build index 0f43ab6e2..f9605a5b7 100644 --- a/hw/meson.build +++ b/hw/meson.build @@ -1,8 +1,8 @@ -if get_option('xephyr') +if build_xephyr subdir('kdrive') endif -if get_option('xvfb') +if build_xvfb subdir('vfb') endif diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c index 21387dee4..447f23931 100644 --- a/hw/vfb/InitInput.c +++ b/hw/vfb/InitInput.c @@ -26,19 +26,19 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> -#include "mi.h" #include <X11/Xproto.h> +#include <X11/Xos.h> +#include <X11/keysym.h> + +#include "mi/mi_priv.h" + #include "scrnintstr.h" #include "inputstr.h" -#include <X11/Xos.h> #include "mipointer.h" #include "xkbsrv.h" -#include <X11/keysym.h> #include "xserver-properties.h" #include "exevents.h" #include "extinit.h" diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index b052e52fe..71ea78e2f 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -26,9 +26,7 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #if defined(WIN32) #include <X11/Xwinsock.h> @@ -38,7 +36,10 @@ from The Open Group. #include <X11/Xproto.h> #include <X11/Xos.h> +#include "dix/colormap_priv.h" +#include "dix/dix_priv.h" #include "dix/screenint_priv.h" +#include "mi/mipointer_priv.h" #include "os/cmdline.h" #include "os/ddx_priv.h" #include "os/osdep.h" @@ -80,10 +81,19 @@ from The Open Group. #define VFB_DEFAULT_WHITEPIXEL 1 #define VFB_DEFAULT_BLACKPIXEL 0 #define VFB_DEFAULT_LINEBIAS 0 +#define VFB_DEFAULT_NUM_CRTCS 1 #define XWD_WINDOW_NAME_LEN 60 typedef struct { int width; + int height; + int x; + int y; + int numOutputs; +} vfbCrtcInfo, *vfbCrtcInfoPtr; + +typedef struct { + int width; int paddedBytesWidth; int paddedWidth; int height; @@ -91,6 +101,8 @@ typedef struct { int bitsPerPixel; int sizeInBytes; int ncolors; + int numCrtcs; + vfbCrtcInfoPtr crtcs; char *pfbMemory; XWDColor *pXWDCmap; XWDFileHeader *pXWDHeader; @@ -140,6 +152,43 @@ static Bool Render = TRUE; else _dst = _src; static void +vfbAddCrtcInfo(vfbScreenInfoPtr screen, int numCrtcs) +{ + int i; + int count = numCrtcs - screen->numCrtcs; + + if (count > 0) { + vfbCrtcInfoPtr crtcs = + reallocarray(screen->crtcs, numCrtcs, sizeof(*crtcs)); + if (!crtcs) + FatalError("Not enough memory for %d CRTCs", numCrtcs); + + memset(crtcs + screen->numCrtcs, 0, count * sizeof(*crtcs)); + + for (i = screen->numCrtcs; i < numCrtcs; ++i) { + crtcs[i].width = screen->width; + crtcs[i].height = screen->height; + } + + screen->crtcs = crtcs; + screen->numCrtcs = numCrtcs; + } +} + +static vfbScreenInfoPtr +vfbInitializeScreenInfo(vfbScreenInfoPtr screen) +{ + *screen = defaultScreenInfo; + vfbAddCrtcInfo(screen, VFB_DEFAULT_NUM_CRTCS); + + /* First CRTC initializes with one output */ + if (screen->numCrtcs > 0) + screen->crtcs[0].numOutputs = 1; + + return screen; +} + +static void vfbInitializePixmapDepths(void) { int i; @@ -195,6 +244,8 @@ freeScreenInfo(vfbScreenInfoPtr pvfb) free(pvfb->pXWDHeader); break; } + + free(pvfb->crtcs); } void @@ -261,6 +312,9 @@ ddxUseMsg(void) #ifdef MITSHM ErrorF("-shmem put framebuffers in shared memory\n"); #endif + + ErrorF("-crtcs n number of CRTCs per screen (default: %d)\n", + VFB_DEFAULT_NUM_CRTCS); } int @@ -276,7 +330,7 @@ ddxProcessArgument(int argc, char *argv[], int i) } if (lastScreen == -1) - currentScreen = &defaultScreenInfo; + currentScreen = vfbInitializeScreenInfo(&defaultScreenInfo); else currentScreen = &vfbScreens[lastScreen]; @@ -300,7 +354,7 @@ ddxProcessArgument(int argc, char *argv[], int i) if (!vfbScreens) FatalError("Not enough memory for screen %d\n", screenNum); for (; vfbNumScreens <= screenNum; ++vfbNumScreens) - vfbScreens[vfbNumScreens] = defaultScreenInfo; + vfbInitializeScreenInfo(&vfbScreens[vfbNumScreens]); } if (3 != sscanf(argv[i + 2], "%dx%dx%d", @@ -381,6 +435,24 @@ ddxProcessArgument(int argc, char *argv[], int i) } #endif + if (strcmp(argv[i], "-crtcs") == 0) { /* -crtcs n */ + int numCrtcs; + + CHECK_FOR_REQUIRED_ARGUMENTS(1); + numCrtcs = atoi(argv[i + 1]); + + if (numCrtcs < 1) { + ErrorF("Invalid number of CRTCs %d\n", numCrtcs); + UseMsg(); + FatalError("Invalid number of CRTCs (%d) passed to -crtcs\n", + numCrtcs); + + } + + vfbAddCrtcInfo(currentScreen, numCrtcs); + return 2; + } + return 0; } @@ -785,10 +857,22 @@ vfbRRCrtcSet(ScreenPtr pScreen, int x, int y, Rotation rotation, - int numOutput, + int numOutputs, RROutputPtr *outputs) { - return RRCrtcNotify(crtc, mode, x, y, rotation, NULL, numOutput, outputs); + vfbCrtcInfoPtr pvci = crtc->devPrivate; + + if (pvci) { + if (mode) { + pvci->width = mode->mode.width; + pvci->height = mode->mode.height; + } + + pvci->x = x; + pvci->y = y; + pvci->numOutputs = numOutputs; + } + return RRCrtcNotify(crtc, mode, x, y, rotation, NULL, numOutputs, outputs); } static Bool @@ -804,17 +888,20 @@ static Bool vfbRandRInit(ScreenPtr pScreen) { rrScrPrivPtr pScrPriv; + #if RANDR_12_INTERFACE - RRModePtr mode; - RRCrtcPtr crtc; - RROutputPtr output; + RRModePtr mode; + RRCrtcPtr crtc; + RROutputPtr output; xRRModeInfo modeInfo; - char name[64]; + char name[64]; + int i; + vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; #endif int mmWidth, mmHeight; - if (!RRScreenInit (pScreen)) - return FALSE; + if (!RRScreenInit(pScreen)) + return FALSE; pScrPriv = rrGetScrPriv(pScreen); pScrPriv->rrGetInfo = vfbRRGetInfo; #if RANDR_12_INTERFACE @@ -827,44 +914,53 @@ vfbRandRInit(ScreenPtr pScreen) pScrPriv->rrOutputValidateMode = vfbRROutputValidateMode; pScrPriv->rrModeDestroy = NULL; - mmWidth = pScreen->width * 25.4 / monitorResolution; - mmHeight = pScreen->height * 25.4 / monitorResolution; - - RRScreenSetSizeRange (pScreen, - 1, 1, - pScreen->width, pScreen->height); - - sprintf (name, "%dx%d", pScreen->width, pScreen->height); - memset (&modeInfo, '\0', sizeof (modeInfo)); - modeInfo.width = pScreen->width; - modeInfo.height = pScreen->height; - modeInfo.nameLength = strlen (name); - - mode = RRModeGet (&modeInfo, name); - if (!mode) - return FALSE; - - crtc = RRCrtcCreate (pScreen, NULL); - if (!crtc) - return FALSE; - - /* This is to avoid xrandr to complain about the gamma missing */ - RRCrtcGammaSetSize (crtc, 256); - - output = RROutputCreate (pScreen, "screen", 6, NULL); - if (!output) - return FALSE; - if (!RROutputSetClones (output, NULL, 0)) - return FALSE; - if (!RROutputSetModes (output, &mode, 1, 0)) - return FALSE; - if (!RROutputSetCrtcs (output, &crtc, 1)) - return FALSE; - if (!RROutputSetConnection (output, RR_Connected)) - return FALSE; - if (!RROutputSetPhysicalSize (output, mmWidth, mmHeight)) - return FALSE; - RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, NULL, 1, &output); + RRScreenSetSizeRange(pScreen, 1, 1, pScreen->width, pScreen->height); + + for (i = 0; i < pvfb->numCrtcs; i++) { + vfbCrtcInfoPtr pvci = &pvfb->crtcs[i]; + + mmWidth = pvci->width * 25.4 / monitorResolution; + mmHeight = pvci->height * 25.4 / monitorResolution; + + crtc = RRCrtcCreate(pScreen, pvci); + if (!crtc) + return FALSE; + + /* Set gamma to avoid xrandr complaints */ + RRCrtcGammaSetSize(crtc, 256); + + /* Setup an Output for each CRTC: 'screen' for the first, then 'screen_N' */ + snprintf(name, sizeof(name), i == 0 ? "screen" : "screen_%d", i); + output = RROutputCreate(pScreen, name, strlen(name), NULL); + if (!output) + return FALSE; + if (!RROutputSetClones(output, NULL, 0)) + return FALSE; + if (!RROutputSetCrtcs(output, &crtc, 1)) + return FALSE; + if (!RROutputSetConnection(output, RR_Connected)) + return FALSE; + if (!RROutputSetPhysicalSize(output, mmWidth, mmHeight)) + return FALSE; + + /* Setup a Mode and notify only for CRTCs with Outputs */ + if (pvci->numOutputs > 0) { + snprintf(name, sizeof(name), "%dx%d", pvci->width, pvci->height); + memset(&modeInfo, '\0', sizeof(modeInfo)); + modeInfo.width = pvci->width; + modeInfo.height = pvci->height; + modeInfo.nameLength = strlen(name); + + mode = RRModeGet(&modeInfo, name); + if (!mode) + return FALSE; + if (!RROutputSetModes(output, &mode, 1, 0)) + return FALSE; + if (!RRCrtcNotify(crtc, mode, pvci->x, pvci->y, RR_Rotate_0, NULL, + 1, &output)) + return FALSE; + } + } #endif return TRUE; } diff --git a/hw/vfb/man/Xvfb.man b/hw/vfb/man/Xvfb.man index d7959b879..8d040a4c7 100644 --- a/hw/vfb/man/Xvfb.man +++ b/hw/vfb/man/Xvfb.man @@ -48,8 +48,8 @@ rendering engine, load testing, as an aid to porting the X server to a new platform, and providing an unobtrusive way to run applications that don't really need an X server but insist on having one anyway. .SH OPTIONS -.PP -In addition to the normal server options described in the \fIXserver(1)\fP +In addition to the normal server options described in the +.BR Xserver (1) manual page, \fIXvfb\fP accepts the following command line switches: .TP 4 .B "\-screen \fIscreennum\fP \fIWxHxD\fP" @@ -118,7 +118,10 @@ and will use memory mapped files in /var/tmp for the framebuffer. xwud -in /var/tmp/Xvfb_screen0 Displays screen 0 of the server started by the preceding example. .SH "SEE ALSO" -.PP -X(@miscmansuffix@), Xserver(1), xwd(1), xwud(1), XWDFile.h +.BR X (@miscmansuffix@), +.BR Xserver (1), +.BR xwd (1), +.BR xwud (1), +.B XWDFile.h .SH AUTHORS David P. Wiggins, The Open Group, Inc. diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h index af2f1490c..af9ac044d 100644 --- a/hw/xfree86/common/compiler.h +++ b/hw/xfree86/common/compiler.h @@ -51,20 +51,6 @@ #define _COMPILER_H -/* Map Sun compiler platform defines to gcc-style used in the code */ -#if defined(__amd64) && !defined(__amd64__) -#define __amd64__ -#endif -#if defined(__i386) && !defined(__i386__) -#define __i386__ -#endif -#if defined(__sparc) && !defined(__sparc__) -#define __sparc__ -#endif -#if defined(__sparcv9) && !defined(__sparc64__) -#define __sparc64__ -#endif - #ifndef _X_EXPORT #include <X11/Xfuncproto.h> #endif diff --git a/hw/xfree86/common/meson.build b/hw/xfree86/common/meson.build index 7dc19c6f9..5cdb832e8 100644 --- a/hw/xfree86/common/meson.build +++ b/hw/xfree86/common/meson.build @@ -42,7 +42,6 @@ xorg_sdk_headers = [ 'xf86VGAarbiter.h', 'xf86Optionstr.h', 'xf86platformBus.h', - 'xf86MatchDrivers.h', 'xaarop.h', ] diff --git a/hw/xfree86/common/modeline2c.awk b/hw/xfree86/common/modeline2c.awk index 3c9f602d1..4900d5a44 100644 --- a/hw/xfree86/common/modeline2c.awk +++ b/hw/xfree86/common/modeline2c.awk @@ -89,5 +89,5 @@ BEGIN { END { print "};" - printf "const int xf86NumDefaultModes = ARRAY_SIZE(xf86DefaultModes);" + print "const int xf86NumDefaultModes = ARRAY_SIZE(xf86DefaultModes);" } diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c index 6eb3705c2..d49f59085 100644 --- a/hw/xfree86/common/xf86AutoConfig.c +++ b/hw/xfree86/common/xf86AutoConfig.c @@ -104,11 +104,11 @@ AppendToList(const char *s, const char ***list, int *lines) { char *str, *newstr, *p; - str = xnfstrdup(s); + str = XNFstrdup(s); for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) { (*lines)++; - *list = xnfreallocarray(*list, *lines + 1, sizeof(**list)); - newstr = xnfalloc(strlen(p) + 2); + *list = XNFreallocarray(*list, *lines + 1, sizeof(**list)); + newstr = XNFalloc(strlen(p) + 2); strcpy(newstr, p); strcat(newstr, "\n"); (*list)[*lines - 1] = newstr; @@ -156,7 +156,7 @@ xf86AddMatchedDriver(XF86MatchedDrivers *md, const char *driver) } if (nmatches < MATCH_DRIVERS_LIMIT) { - md->matches[nmatches] = xnfstrdup(driver); + md->matches[nmatches] = XNFstrdup(driver); md->nmatches++; } else { @@ -272,7 +272,7 @@ listPossibleVideoDrivers(XF86MatchedDrivers *md) /* find end of all uppercase vendor section */ } if ((cp != visid.name) && (*cp != '\0')) { - char *vendorName = xnfstrdup(visid.name); + char *vendorName = XNFstrdup(visid.name); vendorName[cp - visid.name] = '\0'; @@ -403,7 +403,7 @@ autoConfigDevice(GDevPtr preconf_device) * minus one for the already existing first one * plus one for the terminating NULL */ for (; slp[num_screens].screen; num_screens++); - xf86ConfigLayout.screens = xnfcalloc(num_screens + md.nmatches, + xf86ConfigLayout.screens = XNFcallocarray(num_screens + md.nmatches, sizeof(screenLayoutRec)); xf86ConfigLayout.screens[0] = slp[0]; diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 6c5c730a1..af1a8d715 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -37,6 +37,9 @@ #include <stdlib.h> #include <unistd.h> #include <X11/X.h> + +#include "config/hotplug_priv.h" + #include "os.h" #include "xf86.h" #include "xf86Priv.h" @@ -266,13 +269,13 @@ StringToBusType(const char *busID, const char **retID) BusType ret = BUS_NONE; /* If no type field, Default to PCI */ - if (isdigit(busID[0])) { + if (isdigit((unsigned char)busID[0])) { if (retID) *retID = busID; return BUS_PCI; } - s = xstrdup(busID); + s = Xstrdup(busID); p = strtok(s, ":"); if (p == NULL || *p == 0) { free(s); @@ -297,11 +300,11 @@ int xf86AllocateEntity(void) { xf86NumEntities++; - xf86Entities = xnfreallocarray(xf86Entities, + xf86Entities = XNFreallocarray(xf86Entities, xf86NumEntities, sizeof(EntityPtr)); - xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec)); + xf86Entities[xf86NumEntities - 1] = XNFcallocarray(1, sizeof(EntityRec)); xf86Entities[xf86NumEntities - 1]->entityPrivates = - xnfcalloc(xf86EntityPrivateCount, sizeof(DevUnion)); + XNFcallocarray(xf86EntityPrivateCount, sizeof(DevUnion)); return xf86NumEntities - 1; } @@ -355,11 +358,11 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex) } pScrn->numEntities++; - pScrn->entityList = xnfreallocarray(pScrn->entityList, + pScrn->entityList = XNFreallocarray(pScrn->entityList, pScrn->numEntities, sizeof(int)); pScrn->entityList[pScrn->numEntities - 1] = entityIndex; xf86Entities[entityIndex]->inUse = TRUE; - pScrn->entityInstanceList = xnfreallocarray(pScrn->entityInstanceList, + pScrn->entityInstanceList = XNFreallocarray(pScrn->entityInstanceList, pScrn->numEntities, sizeof(int)); pScrn->entityInstanceList[pScrn->numEntities - 1] = 0; @@ -457,7 +460,7 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev) pEnt = xf86Entities[entityIndex]; pEnt->numInstances++; - pEnt->devices = xnfreallocarray(pEnt->devices, + pEnt->devices = XNFreallocarray(pEnt->devices, pEnt->numInstances, sizeof(GDevPtr)); pEnt->devices[pEnt->numInstances - 1] = dev; dev->claimed = TRUE; @@ -500,7 +503,7 @@ xf86GetEntityInfo(int entityIndex) if (entityIndex >= xf86NumEntities) return NULL; - pEnt = xnfcalloc(1, sizeof(EntityInfoRec)); + pEnt = XNFcallocarray(1, sizeof(EntityInfoRec)); pEnt->index = entityIndex; pEnt->location = xf86Entities[entityIndex]->bus; pEnt->active = xf86Entities[entityIndex]->active; @@ -651,7 +654,7 @@ xf86AllocateEntityPrivateIndex(void) idx = xf86EntityPrivateCount++; for (i = 0; i < xf86NumEntities; i++) { pEnt = xf86Entities[i]; - nprivs = xnfreallocarray(pEnt->entityPrivates, + nprivs = XNFreallocarray(pEnt->entityPrivates, xf86EntityPrivateCount, sizeof(DevUnion)); /* Zero the new private */ memset(&nprivs[idx], 0, sizeof(DevUnion)); diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index c3d87fbe2..7bb067073 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -50,6 +50,8 @@ #include <sys/types.h> #include <grp.h> +#include "os/osdep.h" + #include "xf86.h" #include "xf86Modes.h" #include "xf86Parser.h" @@ -182,7 +184,7 @@ xf86ValidateFontPath(char *path) while (next != NULL) { path_elem = xf86GetPathElem(&next); if (*path_elem == '/') { - dir_elem = xnfcalloc(1, strlen(path_elem) + 1); + dir_elem = XNFcallocarray(1, strlen(path_elem) + 1); if ((p1 = strchr(path_elem, ':')) != 0) dirlen = p1 - path_elem; else @@ -332,7 +334,7 @@ xf86ModulelistFromConfig(void ***optlist) } } else { - xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec)); + xf86configptr->conf_modules = XNFcallocarray(1, sizeof(XF86ConfModuleRec)); for (i = 0; ModuleDefaults[i].name != NULL; i++) { if (ModuleDefaults[i].toLoad == TRUE) { XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules; @@ -362,8 +364,8 @@ xf86ModulelistFromConfig(void ***optlist) /* * allocate the memory and walk the list again to fill in the pointers */ - modulearray = xnfallocarray(count + 1, sizeof(char *)); - optarray = xnfallocarray(count + 1, sizeof(void *)); + modulearray = XNFreallocarray(NULL, count + 1, sizeof(char *)); + optarray = XNFreallocarray(NULL, count + 1, sizeof(void *)); count = 0; if (xf86configptr->conf_modules) { modp = xf86configptr->conf_modules->mod_load_lst; @@ -430,7 +432,7 @@ xf86DriverlistFromConfig(void) /* * allocate the memory and walk the list again to fill in the pointers */ - modulearray = xnfallocarray(count + 1, sizeof(char *)); + modulearray = XNFreallocarray(NULL, count + 1, sizeof(char *)); count = 0; slp = xf86ConfigLayout.screens; while (slp->screen) { @@ -498,7 +500,7 @@ xf86InputDriverlistFromConfig(void) /* * allocate the memory and walk the list again to fill in the pointers */ - modulearray = xnfallocarray(count + 1, sizeof(char *)); + modulearray = XNFreallocarray(NULL, count + 1, sizeof(char *)); count = 0; idp = xf86ConfigLayout.inputs; while (idp && *idp) { @@ -554,7 +556,7 @@ configFiles(XF86ConfFilesPtr fileconf) temp_path = defaultFontPath ? (char *) defaultFontPath : (char *) ""; /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */ - temp_path = must_copy ? xnfstrdup(defaultFontPath) : (char *) defaultFontPath; + temp_path = must_copy ? XNFstrdup(defaultFontPath) : (char *) defaultFontPath; defaultFontPath = xf86ValidateFontPath(temp_path); free(temp_path); @@ -566,7 +568,7 @@ configFiles(XF86ConfFilesPtr fileconf) temp_path++; } - log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1); + log_buf = XNFalloc(strlen(defaultFontPath) + (2 * countDirs) + 1); temp_path = log_buf; start = (char *) defaultFontPath; while ((end = index(start, ',')) != NULL) { @@ -893,7 +895,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) rules = "base"; /* Xkb default options. */ - XkbInitRules(&set, rules, "pc105", "us", NULL, NULL); + XkbInitRules(&set, rules, XKB_DFLT_MODEL, XKB_DFLT_LAYOUT, NULL, NULL); XkbSetRulesDflts(&set); XkbFreeRMLVOSet(&set, FALSE); @@ -937,7 +939,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) i, MAX_TIME_IN_MIN); #endif -#ifdef PANORAMIX +#ifdef XINERAMA from = X_DEFAULT; if (!noPanoramiXExtension) from = X_CMDLINE; @@ -947,7 +949,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) } if (!noPanoramiXExtension) xf86Msg(from, "Xinerama: enabled\n"); -#endif +#endif /* XINERAMA */ #ifdef DRI2 xf86Info.dri2 = FALSE; @@ -1012,7 +1014,7 @@ addDevice(InputInfoPtr * list, InputInfoPtr pInfo) for (devs = list; devs && *devs; devs++) count++; - list = xnfreallocarray(list, count + 1, sizeof(InputInfoPtr)); + list = XNFreallocarray(list, count + 1, sizeof(InputInfoPtr)); list[count] = NULL; list[count - 1] = pInfo; @@ -1344,7 +1346,7 @@ configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp) } DebugF("Found %d input devices in the layout section %s\n", count, layout->lay_identifier); - indp = xnfcalloc((count + 1), sizeof(InputInfoPtr)); + indp = XNFcallocarray((count + 1), sizeof(InputInfoPtr)); indp[count] = NULL; irp = layout->lay_input_lst; count = 0; @@ -1428,7 +1430,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, if (!count) /* alloc enough storage even if no screen is specified */ count = 1; - slp = xnfcalloc((count + 1), sizeof(screenLayoutRec)); + slp = XNFcallocarray((count + 1), sizeof(screenLayoutRec)); slp[count].screen = NULL; /* * now that we have storage, loop over the list again and fill in our @@ -1438,7 +1440,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, adjp = conf_layout->lay_adjacency_lst; count = 0; while (adjp) { - slp[count].screen = xnfcalloc(1, sizeof(confScreenRec)); + slp[count].screen = XNFcallocarray(1, sizeof(confScreenRec)); if (adjp->adj_scrnum < 0) scrnum = count; else @@ -1492,7 +1494,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, XF86ConfScreenPtr screen; FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen); - slp[0].screen = xnfcalloc(1, sizeof(confScreenRec)); + slp[0].screen = XNFcallocarray(1, sizeof(confScreenRec)); if (!configScreen(slp[0].screen, screen, 0, X_CONFIG, TRUE)) { free(slp[0].screen); @@ -1552,7 +1554,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, } DebugF("Found %d inactive devices in the layout section %s\n", count, conf_layout->lay_identifier); - gdp = xnfallocarray(count + 1, sizeof(GDevRec)); + gdp = XNFreallocarray(NULL, count + 1, sizeof(GDevRec)); gdp[count].identifier = NULL; idp = conf_layout->lay_inactive_lst; count = 0; @@ -1620,8 +1622,8 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen, /* We have exactly one screen */ - slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec)); - slp[0].screen = xnfcalloc(1, sizeof(confScreenRec)); + slp = XNFcallocarray(1, 2 * sizeof(screenLayoutRec)); + slp[0].screen = XNFcallocarray(1, sizeof(confScreenRec)); slp[1].screen = NULL; if (!configScreen(slp[0].screen, conf_screen, 0, from, TRUE)) { free(slp); @@ -1629,7 +1631,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen, } servlayoutp->id = "(implicit)"; servlayoutp->screens = slp; - servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec)); + servlayoutp->inactives = XNFcallocarray(1, sizeof(GDevRec)); servlayoutp->options = NULL; memset(&layout, 0, sizeof(layout)); @@ -1641,7 +1643,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen, } else { /* Set up an empty input device list, then look for some core devices. */ - indp = xnfalloc(sizeof(InputInfoPtr)); + indp = XNFalloc(sizeof(InputInfoPtr)); *indp = NULL; servlayoutp->inputs = indp; } @@ -1672,7 +1674,7 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor) count++; conf_port = (XF86ConfVideoPortPtr) conf_port->list.next; } - adaptor->ports = xnfallocarray(count, sizeof(confXvPortRec)); + adaptor->ports = XNFreallocarray(NULL, count, sizeof(confXvPortRec)); adaptor->numports = count; count = 0; conf_port = conf_adaptor->va_port_lst; @@ -1714,7 +1716,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, screenp->defaultdepth = conf_screen->scrn_defaultdepth; screenp->defaultbpp = conf_screen->scrn_defaultbpp; screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp; - screenp->monitor = xnfcalloc(1, sizeof(MonRec)); + screenp->monitor = XNFcallocarray(1, sizeof(MonRec)); /* If no monitor is specified, create a default one. */ if (!conf_screen->scrn_monitor) { XF86ConfMonitorRec defMon; @@ -1732,7 +1734,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, /* Configure the device. If there isn't one configured, attach to the * first inactive one that we can configure. If there's none that work, * set it to NULL so that the section can be autoconfigured later */ - screenp->device = xnfcalloc(1, sizeof(GDevRec)); + screenp->device = XNFcallocarray(1, sizeof(GDevRec)); if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) { FIND_SUITABLE (XF86ConfDevicePtr, xf86configptr->conf_device_lst, conf_screen->scrn_device); xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n" @@ -1775,7 +1777,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, continue; } - screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec)); + screenp->gpu_devices[i] = XNFcallocarray(1, sizeof(GDevRec)); if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) { screenp->gpu_devices[i]->myScreenSection = screenp; } @@ -1785,7 +1787,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, } else { for (i = 0; i < conf_screen->num_gpu_devices; i++) { - screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec)); + screenp->gpu_devices[i] = XNFcallocarray(1, sizeof(GDevRec)); if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) { screenp->gpu_devices[i]->myScreenSection = screenp; } @@ -1803,7 +1805,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, count++; dispptr = (XF86ConfDisplayPtr) dispptr->list.next; } - screenp->displays = xnfallocarray(count, sizeof(DispPtr)); + screenp->displays = XNFreallocarray(NULL, count, sizeof(DispPtr)); screenp->numdisplays = count; for (count = 0, dispptr = conf_screen->scrn_display_lst; @@ -1811,7 +1813,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, dispptr = (XF86ConfDisplayPtr) dispptr->list.next, count++) { /* Allocate individual Display records */ - screenp->displays[count] = xnfcalloc(1, sizeof(DispRec)); + screenp->displays[count] = XNFcallocarray(1, sizeof(DispRec)); /* Fill in the default Virtual size, if any */ if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) { @@ -1832,7 +1834,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, count++; conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next; } - screenp->xvadaptors = xnfallocarray(count, sizeof(confXvAdaptorRec)); + screenp->xvadaptors = XNFreallocarray(NULL, count, sizeof(confXvAdaptorRec)); screenp->numxvadaptors = 0; conf_adaptor = conf_screen->scrn_adaptor_lst; while (conf_adaptor) { @@ -1934,7 +1936,7 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor) */ cmodep = conf_monitor->mon_modeline_lst; while (cmodep) { - mode = xnfcalloc(1, sizeof(DisplayModeRec)); + mode = XNFcallocarray(1, sizeof(DisplayModeRec)); mode->type = 0; mode->Clock = cmodep->ml_clock; mode->HDisplay = cmodep->ml_hdisplay; @@ -1948,7 +1950,7 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor) mode->Flags = cmodep->ml_flags; mode->HSkew = cmodep->ml_hskew; mode->VScan = cmodep->ml_vscan; - mode->name = xnfstrdup(cmodep->ml_identifier); + mode->name = XNFstrdup(cmodep->ml_identifier); if (last) { mode->prev = last; last->next = mode; @@ -2071,7 +2073,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display) count++; modep = (XF86ModePtr) modep->list.next; } - displayp->modes = xnfallocarray(count + 1, sizeof(char *)); + displayp->modes = XNFreallocarray(NULL, count + 1, sizeof(char *)); modep = conf_display->disp_mode_lst; count = 0; while (modep) { @@ -2345,7 +2347,7 @@ xf86HandleConfigFile(Bool autoconfig) filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT); if (filename) { xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename); - xf86ConfigFile = xnfstrdup(filename); + xf86ConfigFile = XNFstrdup(filename); } else { if (xf86ConfigFile) @@ -2355,7 +2357,7 @@ xf86HandleConfigFile(Bool autoconfig) if (dirname) { xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n", dirname); - xf86ConfigDir = xnfstrdup(dirname); + xf86ConfigDir = XNFstrdup(dirname); } else { if (xf86ConfigDir) diff --git a/hw/xfree86/common/xf86Config.h b/hw/xfree86/common/xf86Config.h index bbcb252ed..fea8da62d 100644 --- a/hw/xfree86/common/xf86Config.h +++ b/hw/xfree86/common/xf86Config.h @@ -68,4 +68,7 @@ ConfigStatus xf86HandleConfigFile(Bool); Bool xf86AutoConfig(void); GDevPtr autoConfigDevice(GDevPtr preconf_device); +void xf86SetVerbosity(int verb); +void xf86SetLogVerbosity(int verb); + #endif /* _xf86_config_h */ diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index afa1328a0..377766740 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -115,7 +115,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, /* Allocate new structure occurrence */ i = nDevToConfig++; DevToConfig = - xnfreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec)); + XNFreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec)); memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); DevToConfig[i].GDev.chipID = @@ -124,8 +124,8 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, DevToConfig[i].iDriver = CurrentDriver; /* Fill in what we know, converting the driver name to lower case */ - lower_driver = xnfalloc(strlen(driver) + 1); - for (j = 0; (lower_driver[j] = tolower(driver[j])); j++); + lower_driver = XNFalloc(strlen(driver) + 1); + for (j = 0; (lower_driver[j] = tolower((unsigned char)driver[j])); j++); DevToConfig[i].GDev.driver = lower_driver; switch (bus) { @@ -165,8 +165,8 @@ configureInputSection(void) parsePrologue(XF86ConfInputPtr, XF86ConfInputRec); - ptr->inp_identifier = xnfstrdup("Keyboard0"); - ptr->inp_driver = xnfstrdup("kbd"); + ptr->inp_identifier = XNFstrdup("Keyboard0"); + ptr->inp_driver = XNFstrdup("kbd"); ptr->list.next = NULL; /* Crude mechanism to auto-detect mouse (os dependent) */ @@ -181,17 +181,17 @@ configureInputSection(void) } mouse = calloc(1, sizeof(XF86ConfInputRec)); - mouse->inp_identifier = xnfstrdup("Mouse0"); - mouse->inp_driver = xnfstrdup("mouse"); + mouse->inp_identifier = XNFstrdup("Mouse0"); + mouse->inp_driver = XNFstrdup("mouse"); mouse->inp_option_lst = - xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Protocol"), - xnfstrdup(DFLT_MOUSE_PROTO)); + xf86addNewOption(mouse->inp_option_lst, XNFstrdup("Protocol"), + XNFstrdup(DFLT_MOUSE_PROTO)); mouse->inp_option_lst = - xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Device"), - xnfstrdup(DFLT_MOUSE_DEV)); + xf86addNewOption(mouse->inp_option_lst, XNFstrdup("Device"), + XNFstrdup(DFLT_MOUSE_DEV)); mouse->inp_option_lst = - xf86addNewOption(mouse->inp_option_lst, xnfstrdup("ZAxisMapping"), - xnfstrdup("4 5 6 7")); + xf86addNewOption(mouse->inp_option_lst, XNFstrdup("ZAxisMapping"), + XNFstrdup("4 5 6 7")); ptr = (XF86ConfInputPtr) xf86addListItem((glp) ptr, (glp) mouse); return ptr; } @@ -294,7 +294,7 @@ configureDeviceSection(int screennum) " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n" " ### <percent>: \"<f>%\"\n" " ### [arg]: arg optional\n"; - ptr->dev_comment = xnfstrdup(descrip); + ptr->dev_comment = XNFstrdup(descrip); if (ptr->dev_comment) { for (p = DevToConfig[screennum].GDev.options; p->name != NULL; p++) { char *p_e; @@ -313,8 +313,10 @@ configureDeviceSection(int screennum) len += strlen(opttype); ptr->dev_comment = realloc(ptr->dev_comment, len); - if (!ptr->dev_comment) + if (!ptr->dev_comment) { + free(optname); break; + } p_e = ptr->dev_comment + strlen(ptr->dev_comment); sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle, opttype, suffix); @@ -341,9 +343,9 @@ configureLayoutSection(void) iptr = malloc(sizeof(XF86ConfInputrefRec)); iptr->list.next = NULL; iptr->iref_option_lst = NULL; - iptr->iref_inputdev_str = xnfstrdup("Mouse0"); + iptr->iref_inputdev_str = XNFstrdup("Mouse0"); iptr->iref_option_lst = - xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CorePointer"), + xf86addNewOption(iptr->iref_option_lst, XNFstrdup("CorePointer"), NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr); @@ -355,9 +357,9 @@ configureLayoutSection(void) iptr = malloc(sizeof(XF86ConfInputrefRec)); iptr->list.next = NULL; iptr->iref_option_lst = NULL; - iptr->iref_inputdev_str = xnfstrdup("Keyboard0"); + iptr->iref_inputdev_str = XNFstrdup("Keyboard0"); iptr->iref_option_lst = - xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CoreKeyboard"), + xf86addNewOption(iptr->iref_option_lst, XNFstrdup("CoreKeyboard"), NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr); @@ -429,9 +431,9 @@ configureFilesSection(void) parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec); if (xf86ModulePath) - ptr->file_modulepath = xnfstrdup(xf86ModulePath); + ptr->file_modulepath = XNFstrdup(xf86ModulePath); if (defaultFontPath) - ptr->file_fontpath = xnfstrdup(defaultFontPath); + ptr->file_fontpath = XNFstrdup(defaultFontPath); return ptr; } @@ -444,8 +446,8 @@ configureMonitorSection(int screennum) XNFasprintf(&tmp, "Monitor%d", screennum); ptr->mon_identifier = tmp; - ptr->mon_vendor = xnfstrdup("Monitor Vendor"); - ptr->mon_modelname = xnfstrdup("Monitor Model"); + ptr->mon_vendor = XNFstrdup("Monitor Vendor"); + ptr->mon_modelname = XNFstrdup("Monitor Model"); return ptr; } @@ -489,7 +491,7 @@ configureDDCMonitorSection(int screennum) XNFasprintf(&tmp, "Monitor%d", screennum); ptr->mon_identifier = tmp; - ptr->mon_vendor = xnfstrdup(ConfiguredMonitor->vendor.name); + ptr->mon_vendor = XNFstrdup(ConfiguredMonitor->vendor.name); XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id); /* features in centimetres, we want millimetres */ @@ -527,7 +529,7 @@ configureDDCMonitorSection(int screennum) if (ConfiguredMonitor->features.dpms) { ptr->mon_option_lst = - xf86addNewOption(ptr->mon_option_lst, xnfstrdup("DPMS"), NULL); + xf86addNewOption(ptr->mon_option_lst, XNFstrdup("DPMS"), NULL); } return ptr; @@ -707,10 +709,10 @@ DoConfigure(void) xf86DoConfigurePass1 = FALSE; - dev2screen = xnfcalloc(nDevToConfig, sizeof(int)); + dev2screen = XNFcallocarray(nDevToConfig, sizeof(int)); { - Bool *driverProbed = xnfcalloc(xf86NumDrivers, sizeof(Bool)); + Bool *driverProbed = XNFcallocarray(xf86NumDrivers, sizeof(Bool)); for (screennum = 0; screennum < nDevToConfig; screennum++) { int k, l, n, oldNumScreens; @@ -845,7 +847,7 @@ DoShowOptions(void) int i = 0; const char **vlist = NULL; char *pSymbol = 0; - XF86ModuleData *initData = 0; + XF86ModuleData *initData = NULL; if (!(vlist = GenerateDriverList())) { ErrorF("Missing output drivers\n"); diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c index 37ae26c9a..8a3b5c778 100644 --- a/hw/xfree86/common/xf86Cursor.c +++ b/hw/xfree86/common/xf86Cursor.c @@ -31,7 +31,11 @@ #include <X11/X.h> #include <X11/Xmd.h> -#include "input.h" +#include <X11/extensions/XIproto.h> + +#include "dix/input_priv.h" +#include "mi/mipointer_priv.h" + #include "cursor.h" #include "mipointer.h" #include "scrnintstr.h" @@ -41,7 +45,6 @@ #include "xf86Priv.h" #include "xf86_OSproc.h" -#include <X11/extensions/XIproto.h> #include "xf86Xinput.h" #ifdef XFreeXDGA diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 614c35ae4..41b58d9e3 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -46,9 +46,11 @@ #include <X11/Xproto.h> #include <X11/extensions/xf86dgaproto.h> +#include "dix/colormap_priv.h" #include "dix/dix_priv.h" #include "dix/eventconvert.h" #include "dix/exevents_priv.h" +#include "mi/mi_priv.h" #include "xf86.h" #include "xf86str.h" @@ -66,7 +68,6 @@ #include "exglobals.h" #include "eventstr.h" #include "xf86Extensions.h" -#include "mi.h" #include "misc.h" #include "dixstruct.h" #include "dixevents.h" @@ -175,11 +176,11 @@ DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, int num) for (i = 0; i < num; i++) modes[i].num = i + 1; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) for (i = 0; i < num; i++) modes[i].flags &= ~DGA_PIXMAP_AVAILABLE; -#endif +#endif /* XINERAMA */ return TRUE; } @@ -224,11 +225,11 @@ DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num) for (i = 0; i < num; i++) modes[i].num = i + 1; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) for (i = 0; i < num; i++) modes[i].flags &= ~DGA_PIXMAP_AVAILABLE; -#endif +#endif /* XINERAMA */ return TRUE; } diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 23c492915..2a595b6e3 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -57,27 +57,28 @@ #include <X11/X.h> #include <X11/Xproto.h> #include <X11/Xatom.h> +#include <X11/extensions/XI.h> +#include <X11/extensions/XIproto.h> +#include <X11/keysym.h> + +#include "dix/dix_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" #include "misc.h" #include "xf86.h" #include "xf86Priv.h" #include "xf86_os_support.h" #include "xf86_OSlib.h" -#include <X11/keysym.h> #ifdef XFreeXDGA #include "dgaproc.h" #include "dgaproc_priv.h" #endif -#include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> #include "inputstr.h" #include "xf86Xinput.h" - -#include "mi.h" #include "mipointer.h" - #include "xkbsrv.h" #include "xkbstr.h" @@ -542,7 +543,7 @@ addInputHandler(int fd, InputHandlerProc proc, void *data) if (fd < 0 || !proc) return NULL; - ih = calloc(sizeof(*ih), 1); + ih = calloc(1, sizeof(*ih)); if (!ih) return NULL; diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index 85bd3bb33..430482c38 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -41,7 +41,10 @@ #include <sys/stat.h> #include <X11/X.h> -#include "mi.h" +#include "dix/dix_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" + #include "os.h" #include "servermd.h" #include "pixmapstr.h" @@ -56,6 +59,7 @@ #include "xf86DDC.h" #include "xf86Xinput.h" #include "xf86InPriv.h" +#include "xf86Config.h" #include "mivalidate.h" /* For xf86GetClocks */ @@ -79,9 +83,9 @@ xf86AddDriver(DriverPtr driver, void *module, int flags) xf86NumDrivers = 0; xf86NumDrivers++; - xf86DriverList = xnfreallocarray(xf86DriverList, + xf86DriverList = XNFreallocarray(xf86DriverList, xf86NumDrivers, sizeof(DriverPtr)); - xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec)); + xf86DriverList[xf86NumDrivers - 1] = XNFalloc(sizeof(DriverRec)); *xf86DriverList[xf86NumDrivers - 1] = *driver; xf86DriverList[xf86NumDrivers - 1]->module = module; xf86DriverList[xf86NumDrivers - 1]->refCount = 0; @@ -112,11 +116,11 @@ xf86AddInputDriver(InputDriverPtr driver, void *module, int flags) xf86NumInputDrivers = 0; xf86NumInputDrivers++; - xf86InputDriverList = xnfreallocarray(xf86InputDriverList, + xf86InputDriverList = XNFreallocarray(xf86InputDriverList, xf86NumInputDrivers, sizeof(InputDriverPtr)); xf86InputDriverList[xf86NumInputDrivers - 1] = - xnfalloc(sizeof(InputDriverRec)); + XNFalloc(sizeof(InputDriverRec)); *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver; xf86InputDriverList[xf86NumInputDrivers - 1]->module = module; } @@ -168,9 +172,9 @@ xf86AllocateScreen(DriverPtr drv, int flags) if (xf86GPUScreens == NULL) xf86NumGPUScreens = 0; i = xf86NumGPUScreens++; - xf86GPUScreens = xnfreallocarray(xf86GPUScreens, xf86NumGPUScreens, + xf86GPUScreens = XNFreallocarray(xf86GPUScreens, xf86NumGPUScreens, sizeof(ScrnInfoPtr)); - xf86GPUScreens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); + xf86GPUScreens[i] = XNFcallocarray(1, sizeof(ScrnInfoRec)); pScrn = xf86GPUScreens[i]; pScrn->scrnIndex = i + GPU_SCREEN_OFFSET; /* Changes when a screen is removed */ pScrn->is_gpu = TRUE; @@ -179,16 +183,16 @@ xf86AllocateScreen(DriverPtr drv, int flags) xf86NumScreens = 0; i = xf86NumScreens++; - xf86Screens = xnfreallocarray(xf86Screens, xf86NumScreens, + xf86Screens = XNFreallocarray(xf86Screens, xf86NumScreens, sizeof(ScrnInfoPtr)); - xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); + xf86Screens[i] = XNFcallocarray(1, sizeof(ScrnInfoRec)); pScrn = xf86Screens[i]; pScrn->scrnIndex = i; /* Changes when a screen is removed */ } pScrn->origIndex = pScrn->scrnIndex; /* This never changes */ - pScrn->privates = xnfcalloc(sizeof(DevUnion), xf86ScrnInfoPrivateCount); + pScrn->privates = XNFcallocarray(xf86ScrnInfoPrivateCount, sizeof(DevUnion)); /* * EnableDisableFBAccess now gets initialized in InitOutput() * pScrn->EnableDisableFBAccess = xf86EnableDisableFBAccess; @@ -290,7 +294,7 @@ xf86AllocateScrnInfoPrivateIndex(void) idx = xf86ScrnInfoPrivateCount++; for (i = 0; i < xf86NumScreens; i++) { pScr = xf86Screens[i]; - nprivs = xnfreallocarray(pScr->privates, + nprivs = XNFreallocarray(pScr->privates, xf86ScrnInfoPrivateCount, sizeof(DevUnion)); /* Zero the new private */ memset(&nprivs[idx], 0, sizeof(DevUnion)); @@ -298,7 +302,7 @@ xf86AllocateScrnInfoPrivateIndex(void) } for (i = 0; i < xf86NumGPUScreens; i++) { pScr = xf86GPUScreens[i]; - nprivs = xnfreallocarray(pScr->privates, + nprivs = XNFreallocarray(pScr->privates, xf86ScrnInfoPrivateCount, sizeof(DevUnion)); /* Zero the new private */ memset(&nprivs[idx], 0, sizeof(DevUnion)); @@ -558,13 +562,13 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp, if (i == scrp->confScreen->numdisplays) { scrp->confScreen->numdisplays++; scrp->confScreen->displays = - xnfreallocarray(scrp->confScreen->displays, + XNFreallocarray(scrp->confScreen->displays, scrp->confScreen->numdisplays, sizeof(DispPtr)); xf86DrvMsg(scrp->scrnIndex, X_INFO, "Creating default Display subsection in Screen section\n" "\t\"%s\" for depth/fbbpp %d/%d\n", scrp->confScreen->id, scrp->depth, scrp->bitsPerPixel); - scrp->confScreen->displays[i] = xnfcalloc(1, sizeof(DispRec)); + scrp->confScreen->displays[i] = XNFcallocarray(1, sizeof(DispRec)); memset(scrp->confScreen->displays[i], 0, sizeof(DispRec)); scrp->confScreen->displays[i]->blackColour.red = -1; scrp->confScreen->displays[i]->blackColour.green = -1; @@ -573,7 +577,7 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp, scrp->confScreen->displays[i]->whiteColour.green = -1; scrp->confScreen->displays[i]->whiteColour.blue = -1; scrp->confScreen->displays[i]->defaultVisual = -1; - scrp->confScreen->displays[i]->modes = xnfalloc(sizeof(char *)); + scrp->confScreen->displays[i]->modes = XNFalloc(sizeof(char *)); scrp->confScreen->displays[i]->modes[0] = NULL; scrp->confScreen->displays[i]->depth = depth; scrp->confScreen->displays[i]->fbbpp = fbbpp; @@ -1120,7 +1124,7 @@ xf86ErrorFVerb(int verb, const char *format, ...) va_start(ap, format); if (xf86Verbose >= verb || xf86LogVerbose >= verb) - LogVWrite(verb, format, ap); + LogVMessageVerb(X_NONE, verb, format, ap); va_end(ap); } @@ -1132,7 +1136,7 @@ xf86ErrorF(const char *format, ...) va_start(ap, format); if (xf86Verbose >= 1 || xf86LogVerbose >= 1) - LogVWrite(1, format, ap); + LogVMessageVerb(X_NONE, 1, format, ap); va_end(ap); } @@ -1321,13 +1325,14 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist) */ for (j = 0; xf86ConfigLayout.screens[j].screen != NULL; j++) { screensecptr = xf86ConfigLayout.screens[j].screen; - if ((screensecptr->device->driver != NULL) + if ((screensecptr->device != NULL) + && (screensecptr->device->driver != NULL) && (xf86NameCmp(screensecptr->device->driver, drivername) == 0) && (!screensecptr->device->claimed)) { /* * we have a matching driver that wasn't claimed, yet */ - pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr)); + pgdp = XNFreallocarray(pgdp, i + 2, sizeof(GDevPtr)); pgdp[i++] = screensecptr->device; } for (k = 0; k < screensecptr->num_gpu_devices; k++) { @@ -1337,7 +1342,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist) /* * we have a matching driver that wasn't claimed, yet */ - pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp = XNFrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); pgdp[i++] = screensecptr->gpu_devices[k]; } } @@ -1350,7 +1355,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist) if (gdp->driver && !gdp->claimed && !xf86NameCmp(gdp->driver, drivername)) { /* we have a matching driver that wasn't claimed yet */ - pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr)); + pgdp = XNFreallocarray(pgdp, i + 2, sizeof(GDevPtr)); pgdp[i++] = gdp; } j++; @@ -1548,7 +1553,7 @@ xf86SetBackingStore(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); OptionInfoPtr options; - options = xnfalloc(sizeof(BSOptions)); + options = XNFalloc(sizeof(BSOptions)); (void) memcpy(options, BSOptions, sizeof(BSOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); @@ -1594,7 +1599,7 @@ xf86SetSilkenMouse(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); OptionInfoPtr options; - options = xnfalloc(sizeof(SMOptions)); + options = XNFalloc(sizeof(SMOptions)); (void) memcpy(options, SMOptions, sizeof(SMOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 71e0a0a96..bcfaf8d1d 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -48,18 +48,21 @@ #include <X11/Xmd.h> #include <X11/Xproto.h> #include <X11/Xatom.h> +#include <X11/extensions/XI.h> +#include <X11/extensions/XIproto.h> #include "config/dbus-core.h" +#include "config/hotplug_priv.h" +#include "dix/input_priv.h" #include "dix/screenint_priv.h" +#include "mi/mi_priv.h" #include "os/cmdline.h" #include "os/ddx_priv.h" #include "os/osdep.h" -#include "input.h" #include "servermd.h" #include "windowstr.h" #include "scrnintstr.h" -#include "mi.h" #include "systemd-logind.h" #include "loaderProcs.h" @@ -71,8 +74,6 @@ #include "xf86cmap.h" #include "xorgVersion.h" #include "mipointer.h" -#include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> #include "xf86Extensions.h" #include "xf86DDC.h" #include "xf86Xinput.h" @@ -96,7 +97,6 @@ #include <linux/major.h> #include <sys/sysmacros.h> #endif -#include <hotplug.h> void (*xf86OSPMClose) (void) = NULL; static Bool xorgHWOpenConsole = FALSE; @@ -798,7 +798,7 @@ OsVendorInit(void) /* * ddxGiveUp -- * Device dependent cleanup. Called by by dix before normal server death. - * For SYSV386 we must switch the terminal back to normal mode. No error- + * On some OSes we must switch the terminal back to normal mode. No error- * checking here, since there should be restored as much as possible. */ @@ -856,37 +856,26 @@ ddxGiveUp(enum ExitCode error) void OsVendorFatalError(const char *f, va_list args) { -#ifdef VENDORSUPPORT - ErrorFSigSafe("\nPlease refer to your Operating System Vendor support " - "pages\nat %s for support on this crash.\n", VENDORSUPPORT); -#else ErrorFSigSafe("\nPlease consult the " XVENDORNAME " support \n\t at " __VENDORDWEBSUPPORT__ "\n for help. \n"); -#endif if (xf86LogFile && xf86LogFileWasOpened) ErrorFSigSafe("Please also check the log file at \"%s\" for additional " "information.\n", xf86LogFile); ErrorFSigSafe("\n"); } -int +void xf86SetVerbosity(int verb) { - int save = xf86Verbose; - xf86Verbose = verb; LogSetParameter(XLOG_VERBOSITY, verb); - return save; } -int +void xf86SetLogVerbosity(int verb) { - int save = xf86LogVerbose; - xf86LogVerbose = verb; LogSetParameter(XLOG_FILE_VERBOSITY, verb); - return save; } static void diff --git a/hw/xfree86/common/xf86MatchDrivers.h b/hw/xfree86/common/xf86MatchDrivers.h index 4663af478..484863814 100644 --- a/hw/xfree86/common/xf86MatchDrivers.h +++ b/hw/xfree86/common/xf86MatchDrivers.h @@ -36,5 +36,7 @@ typedef struct _XF86MatchedDrivers { */ void xf86AddMatchedDriver(XF86MatchedDrivers *, const char *); +void xf86PlatformMatchDriver(XF86MatchedDrivers *); + #endif /* _xf86_match_drivers_h */ diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c index a28973ead..ae007ccd7 100644 --- a/hw/xfree86/common/xf86Mode.c +++ b/hw/xfree86/common/xf86Mode.c @@ -1457,7 +1457,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, * Store the clockRanges for later use by the VidMode extension. */ nt_list_for_each_entry(cp, clockRanges, next) { - ClockRangePtr newCR = xnfalloc(sizeof(ClockRange)); + ClockRangePtr newCR = XNFalloc(sizeof(ClockRange)); memcpy(newCR, cp, sizeof(ClockRange)); newCR->next = NULL; if (scrp->clockRanges == NULL) @@ -1574,7 +1574,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, } if (status == MODE_OK) { - new = xnfalloc(sizeof(DisplayModeRec)); + new = XNFalloc(sizeof(DisplayModeRec)); *new = *p; new->next = NULL; if (!q) { @@ -1585,7 +1585,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, } new->prev = NULL; q = new; - q->name = xnfstrdup(p->name); + q->name = XNFstrdup(p->name); q->status = MODE_OK; } else { @@ -1615,10 +1615,10 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, if (modeNames != NULL) { for (i = 0; modeNames[i] != NULL; i++) { userModes = TRUE; - new = xnfcalloc(1, sizeof(DisplayModeRec)); + new = XNFcallocarray(1, sizeof(DisplayModeRec)); new->prev = last; new->type = M_T_USERDEF; - new->name = xnfstrdup(modeNames[i]); + new->name = XNFstrdup(modeNames[i]); if (new->prev) new->prev->next = new; *endp = last = new; @@ -1627,10 +1627,10 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, } /* Lookup each mode */ -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension) validateAllDefaultModes = TRUE; -#endif +#endif /* XINERAMA */ for (p = scrp->modes;; p = p->next) { Bool repeat; @@ -1683,9 +1683,9 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, if (r == NULL) break; - p = xnfcalloc(1, sizeof(DisplayModeRec)); + p = XNFcallocarray(1, sizeof(DisplayModeRec)); p->prev = last; - p->name = xnfstrdup(r->name); + p->name = XNFstrdup(r->name); if (!userModes) p->type = M_T_USERDEF; if (p->prev) diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index b6eb80622..96dfa8e56 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -75,7 +75,7 @@ */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) #define ABI_VIDEODRV_VERSION SET_ABI_VERSION(27, 0) -#define ABI_XINPUT_VERSION SET_ABI_VERSION(24, 4) +#define ABI_XINPUT_VERSION SET_ABI_VERSION(25, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(10, 0) #define MODINFOSTRING1 0xef23fdc5 @@ -147,8 +147,6 @@ typedef struct { #define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF) #define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF) -#define INITARGS void - /* Prototypes for Loader functions that are exported to modules */ extern _X_EXPORT void *LoadSubModule(void *, const char *, const char **, const char **, void *, diff --git a/hw/xfree86/common/xf86Opt.h b/hw/xfree86/common/xf86Opt.h index 3046fbd41..e939692cd 100644 --- a/hw/xfree86/common/xf86Opt.h +++ b/hw/xfree86/common/xf86Opt.h @@ -1,4 +1,3 @@ - /* * Copyright (c) 1998-2003 by The XFree86 Project, Inc. * @@ -30,6 +29,9 @@ #ifndef _XF86_OPT_H_ #define _XF86_OPT_H_ + +#include <X11/Xdefs.h> + #include "xf86Optionstr.h" typedef struct { diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index ca538cc57..b8bab3617 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -912,8 +912,8 @@ xf86NormalizeName(const char *s) case '\t': continue; default: - if (isupper(*p)) - *q++ = tolower(*p); + if (isupper((unsigned char)*p)) + *q++ = tolower((unsigned char)*p); else *q++ = *p; } diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h index f6c70fa17..4f3add769 100644 --- a/hw/xfree86/common/xf86Priv.h +++ b/hw/xfree86/common/xf86Priv.h @@ -151,10 +151,7 @@ xf86CloseLog(enum ExitCode error); /* xf86Init.c */ extern _X_EXPORT Bool xf86LoadModules(const char **list, void **optlist); -extern _X_EXPORT int -xf86SetVerbosity(int verb); -extern _X_EXPORT int -xf86SetLogVerbosity(int verb); + extern _X_EXPORT Bool xf86CallDriverProbe(struct _DriverRec *drv, Bool detect_only); extern _X_EXPORT Bool diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c index 08f656b30..1bd5f8ea7 100644 --- a/hw/xfree86/common/xf86RandR.c +++ b/hw/xfree86/common/xf86RandR.c @@ -26,6 +26,9 @@ #endif #include <X11/X.h> + +#include "dix/input_priv.h" + #include "os.h" #include "globals.h" #include "xf86.h" @@ -406,11 +409,11 @@ xf86RandRInit(ScreenPtr pScreen) XF86RandRInfoPtr randrp; ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen); -#ifdef PANORAMIX +#ifdef XINERAMA /* XXX disable RandR when using Xinerama */ if (!noPanoramiXExtension) return TRUE; -#endif +#endif /* XINERAMA */ xf86RandRKey = &xf86RandRKeyRec; diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 081a3dc11..2d310cc58 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -59,11 +59,13 @@ #include "dix/dix_priv.h" #include "dix/ptrveloc_priv.h" +#include "dix/input_priv.h" #include "xf86.h" #include "xf86Priv.h" #include "xf86Config.h" #include "xf86Xinput.h" +#include "XIstubs.h" #include "xf86Optrec.h" #include "mipointer.h" #include "extinit.h" @@ -720,7 +722,7 @@ MergeInputClasses(const InputInfoPtr idev, const InputAttributes * attrs) classopts = xf86optionListDup(cl->option_lst); if (cl->driver) { free((void *) idev->driver); - idev->driver = xstrdup(cl->driver); + idev->driver = Xstrdup(cl->driver); if (!idev->driver) { xf86Msg(X_ERROR, "Failed to allocate memory while merging " "InputClass configuration"); @@ -769,7 +771,7 @@ xf86AllocateInput(void) { InputInfoPtr pInfo; - pInfo = calloc(sizeof(*pInfo), 1); + pInfo = calloc(1, sizeof(*pInfo)); if (!pInfo) return NULL; @@ -950,7 +952,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable) if (fd != -1) { if (paused) { /* Put on new_input_devices list for delayed probe */ - PausedInputDevicePtr new_device = xnfalloc(sizeof *new_device); + PausedInputDevicePtr new_device = XNFalloc(sizeof *new_device); new_device->pInfo = pInfo; xorg_list_append(&new_device->node, &new_input_devices_list); @@ -1047,7 +1049,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, rval = BadRequest; goto unwind; } - pInfo->driver = xstrdup(value); + pInfo->driver = Xstrdup(value); if (!pInfo->driver) { rval = BadAlloc; goto unwind; @@ -1059,7 +1061,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, rval = BadRequest; goto unwind; } - pInfo->name = xstrdup(value); + pInfo->name = Xstrdup(value); if (!pInfo->name) { rval = BadAlloc; goto unwind; diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h index e73aff269..839a3b969 100644 --- a/hw/xfree86/common/xf86Xinput.h +++ b/hw/xfree86/common/xf86Xinput.h @@ -51,12 +51,13 @@ #ifndef _xf86Xinput_h #define _xf86Xinput_h +#include <X11/Xfuncproto.h> + #include "xf86.h" #include "xf86str.h" #include "inputstr.h" #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> -#include "XIstubs.h" /* Input device flags */ #define XI86_ALWAYS_CORE 0x04 /* device always controls the pointer */ diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c index bb639c4f8..84f6a495d 100644 --- a/hw/xfree86/common/xf86cmap.c +++ b/hw/xfree86/common/xf86cmap.c @@ -29,22 +29,18 @@ #include <xorg-config.h> #endif -#if defined(_XOPEN_SOURCE) || defined(__sun) && defined(__SVR4) #include <math.h> -#else -#define _XOPEN_SOURCE /* to get prototype for pow on some systems */ -#include <math.h> -#undef _XOPEN_SOURCE -#endif - #include <X11/X.h> -#include "misc.h" #include <X11/Xproto.h> +#include "misc.h" + #include "dix/colormap_priv.h" +#include "mi/mi_priv.h" + +#include "misc.h" #include "colormapst.h" #include "scrnintstr.h" - #include "resource.h" #include "xf86.h" diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 68e3f35fc..3a9ace9ab 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -102,7 +102,7 @@ xf86PciProbe(void) while ((info = pci_device_next(iter)) != NULL) { if (PCIINFOCLASSES(info->device_class)) { num++; - xf86PciVideoInfo = xnfreallocarray(xf86PciVideoInfo, + xf86PciVideoInfo = XNFreallocarray(xf86PciVideoInfo, num + 1, sizeof(struct pci_device *)); xf86PciVideoInfo[num] = NULL; @@ -272,7 +272,7 @@ xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func) if (StringToBusType(busID, &id) != BUS_PCI) return FALSE; - s = xstrdup(id); + s = Xstrdup(id); p = strtok(s, ":"); if (p == NULL || *p == 0) { free(s); @@ -282,14 +282,14 @@ xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func) if (d != NULL) { *(d++) = 0; for (i = 0; d[i] != 0; i++) { - if (!isdigit(d[i])) { + if (!isdigit((unsigned char)d[i])) { free(s); return FALSE; } } } for (i = 0; p[i] != 0; i++) { - if (!isdigit(p[i])) { + if (!isdigit((unsigned char)p[i])) { free(s); return FALSE; } @@ -303,7 +303,7 @@ xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func) return FALSE; } for (i = 0; p[i] != 0; i++) { - if (!isdigit(p[i])) { + if (!isdigit((unsigned char)p[i])) { free(s); return FALSE; } @@ -316,7 +316,7 @@ xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func) return TRUE; } for (i = 0; p[i] != 0; i++) { - if (!isdigit(p[i])) { + if (!isdigit((unsigned char)p[i])) { free(s); return FALSE; } @@ -682,7 +682,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID, } pci_iterator_destroy(iter); - instances = xnfallocarray(max_entries, sizeof(struct Inst)); + instances = XNFreallocarray(NULL, max_entries, sizeof(struct Inst)); } iter = pci_slot_match_iterator_create(NULL); @@ -979,7 +979,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID, /* Allocate an entry in the lists to be returned */ numFound++; - retEntities = xnfreallocarray(retEntities, numFound, sizeof(int)); + retEntities = XNFreallocarray(retEntities, numFound, sizeof(int)); retEntities[numFound - 1] = xf86ClaimPciSlot(pPci, drvp, instances[i].chip, instances[i].dev, diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index eeeff2b88..2962c8b21 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -37,10 +37,10 @@ #include <fcntl.h> #include <unistd.h> +#include "config/hotplug_priv.h" #include "dix/screenint_priv.h" #include "os.h" -#include "hotplug.h" #include "systemd-logind.h" #include "loaderProcs.h" @@ -65,7 +65,7 @@ struct xf86_platform_device *xf86_platform_devices; int xf86_add_platform_device(struct OdevAttributes *attribs, Bool unowned) { - xf86_platform_devices = xnfreallocarray(xf86_platform_devices, + xf86_platform_devices = XNFreallocarray(xf86_platform_devices, xf86_num_platform_devices + 1, sizeof(struct xf86_platform_device)); @@ -821,4 +821,39 @@ void xf86platformPrimary(void) } } } -#endif + +char * +_xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]) +{ + switch (attrib) { + case ODEV_ATTRIB_PATH: + return xf86_platform_device_odev_attributes(device)->path; + case ODEV_ATTRIB_SYSPATH: + return xf86_platform_device_odev_attributes(device)->syspath; + case ODEV_ATTRIB_BUSID: + return xf86_platform_device_odev_attributes(device)->busid; + case ODEV_ATTRIB_DRIVER: + return xf86_platform_device_odev_attributes(device)->driver; + default: + assert(FALSE); + return NULL; + } +} + +int +_xf86_get_platform_device_int_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]) +{ + switch (attrib) { + case ODEV_ATTRIB_FD: + return xf86_platform_device_odev_attributes(device)->fd; + case ODEV_ATTRIB_MAJOR: + return xf86_platform_device_odev_attributes(device)->major; + case ODEV_ATTRIB_MINOR: + return xf86_platform_device_odev_attributes(device)->minor; + default: + assert(FALSE); + return 0; + } +} + +#endif /* XSERVER_PLATFORM_BUS */ diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h index 9979106a1..7d4852ee8 100644 --- a/hw/xfree86/common/xf86platformBus.h +++ b/hw/xfree86/common/xf86platformBus.h @@ -24,9 +24,6 @@ #ifndef XF86_PLATFORM_BUS_H #define XF86_PLATFORM_BUS_H -#include "hotplug.h" -#include "xf86MatchDrivers.h" - struct xf86_platform_device { struct OdevAttributes *attribs; /* for PCI devices */ @@ -76,7 +73,6 @@ xf86_platform_odev_attributes(int index) return device->attribs; } -#ifndef _XORG_CONFIG_H_ /* * Define the legacy API only for external builds */ @@ -96,6 +92,14 @@ xf86_platform_odev_attributes(int index) /* kernel driver name */ #define ODEV_ATTRIB_DRIVER 7 +_X_EXPORT char * +_xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]); + +_X_EXPORT int +_xf86_get_platform_device_int_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]); + +#ifndef _XORG_CONFIG_H_ + /* Protect against a mismatch attribute type by generating a compiler * error using a negative array size when an incorrect attribute is * passed @@ -108,24 +112,6 @@ xf86_platform_odev_attributes(int index) #define _ODEV_ATTRIB_STRING_CHECK(x) ((int (*)[_ODEV_ATTRIB_IS_STRING(x)-1]) 0) -static inline char * -_xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]) -{ - switch (attrib) { - case ODEV_ATTRIB_PATH: - return xf86_platform_device_odev_attributes(device)->path; - case ODEV_ATTRIB_SYSPATH: - return xf86_platform_device_odev_attributes(device)->syspath; - case ODEV_ATTRIB_BUSID: - return xf86_platform_device_odev_attributes(device)->busid; - case ODEV_ATTRIB_DRIVER: - return xf86_platform_device_odev_attributes(device)->driver; - default: - assert(FALSE); - return NULL; - } -} - #define xf86_get_platform_device_attrib(device, attrib) _xf86_get_platform_device_attrib(device,attrib,_ODEV_ATTRIB_STRING_CHECK(attrib)) #define _ODEV_ATTRIB_IS_INT(x) ((x) == ODEV_ATTRIB_FD || (x) == ODEV_ATTRIB_MAJOR || (x) == ODEV_ATTRIB_MINOR) @@ -133,22 +119,6 @@ _xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib #define _ODEV_ATTRIB_DEFAULT_CHECK(x,def) (_ODEV_ATTRIB_INT_DEFAULT(x) == (def)) #define _ODEV_ATTRIB_INT_CHECK(x,def) ((int (*)[_ODEV_ATTRIB_IS_INT(x)*_ODEV_ATTRIB_DEFAULT_CHECK(x,def)-1]) 0) -static inline int -_xf86_get_platform_device_int_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]) -{ - switch (attrib) { - case ODEV_ATTRIB_FD: - return xf86_platform_device_odev_attributes(device)->fd; - case ODEV_ATTRIB_MAJOR: - return xf86_platform_device_odev_attributes(device)->major; - case ODEV_ATTRIB_MINOR: - return xf86_platform_device_odev_attributes(device)->minor; - default: - assert(FALSE); - return 0; - } -} - #define xf86_get_platform_device_int_attrib(device, attrib, def) _xf86_get_platform_device_int_attrib(device,attrib,_ODEV_ATTRIB_INT_CHECK(attrib,def)) #endif @@ -156,9 +126,6 @@ _xf86_get_platform_device_int_attrib(struct xf86_platform_device *device, int at extern _X_EXPORT Bool xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *busid); -extern _X_EXPORT void -xf86PlatformMatchDriver(XF86MatchedDrivers *); - extern void xf86platformVTProbe(void); extern void xf86platformPrimary(void); diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c index 119211dc5..e94b8f1c6 100644 --- a/hw/xfree86/common/xf86sbusBus.c +++ b/hw/xfree86/common/xf86sbusBus.c @@ -68,12 +68,12 @@ CheckSbusDevice(const char *device, int fbNum) if (!sbusDeviceTable[i].devId) return; xf86SbusInfo = - xnfreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp)); + XNFreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp)); xf86SbusInfo[xf86nSbusInfo] = NULL; - xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof(sbusDevice), 1); + xf86SbusInfo[xf86nSbusInfo - 1] = psdp = XNFcallocarray(1, sizeof(sbusDevice)); psdp->devId = sbusDeviceTable[i].devId; psdp->fbNum = fbNum; - psdp->device = xnfstrdup(device); + psdp->device = XNFstrdup(device); psdp->width = fbattr.fbtype.fb_width; psdp->height = fbattr.fbtype.fb_height; psdp->fd = -1; @@ -244,7 +244,7 @@ xf86SbusProbe(void) * in the correct format for a SBUS bus id. */ -Bool +static Bool xf86ParseSbusBusString(const char *busID, int *fbNum) { /* @@ -316,7 +316,7 @@ xf86ParseSbusBusString(const char *busID, int *fbNum) * Compare a BUS ID string with a SBUS bus id. Return TRUE if they match. */ -Bool +static Bool xf86CompareSbusBusString(const char *busID, int fbNum) { int iFbNum; @@ -333,7 +333,7 @@ xf86CompareSbusBusString(const char *busID, int fbNum) * Check if the slot requested is free. If it is already in use, return FALSE. */ -Bool +static Bool xf86CheckSbusSlot(int fbNum) { int i; @@ -354,7 +354,7 @@ xf86CheckSbusSlot(int fbNum) * Otherwise, claim the slot for the screen requesting it. */ -int +static int xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp, GDevPtr dev, Bool active) { EntityPtr p = NULL; @@ -406,7 +406,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId, if (psdp->fd == -2) continue; ++allocatedInstances; - instances = xnfreallocarray(instances, + instances = XNFreallocarray(instances, allocatedInstances, sizeof(struct Inst)); instances[allocatedInstances - 1].sbus = psdp; instances[allocatedInstances - 1].dev = NULL; @@ -532,7 +532,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId, /* Allocate an entry in the lists to be returned */ numFound++; - retEntities = xnfreallocarray(retEntities, numFound, sizeof(int)); + retEntities = XNFreallocarray(retEntities, numFound, sizeof(int)); retEntities[numFound - 1] = xf86ClaimSbusSlot(psdp, drvp, instances[i].dev, instances[i].dev->active ? TRUE : FALSE); @@ -589,7 +589,7 @@ xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp) { DisplayModePtr mode; - mode = xnfcalloc(sizeof(DisplayModeRec), 1); + mode = XNFcallocarray(sizeof(DisplayModeRec), 1); mode->name = "current"; mode->next = mode; mode->prev = mode; @@ -698,7 +698,7 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp) if (!dixRegisterPrivateKey(sbusPaletteKey, PRIVATE_SCREEN, 0)) FatalError("Cannot register sbus private key"); - cmap = xnfcalloc(1, sizeof(sbusCmapRec)); + cmap = XNFcallocarray(1, sizeof(sbusCmapRec)); dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap); cmap->psdp = psdp; fbcmap.index = 0; @@ -740,6 +740,7 @@ void xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec * GDev) { char *promPath = NULL; + char *tmp; sBus = (sbusDevicePtr) busData; GDev->identifier = sBus->descr; @@ -748,10 +749,11 @@ xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec * GDev) sparcPromClose(); } if (promPath) { - XNFasprintf(&GDev->busID, "SBUS:%s", promPath); + XNFasprintf(&tmp, "SBUS:%s", promPath); free(promPath); } else { - XNFasprintf(&GDev->busID, "SBUS:fb%d", sBus->fbNum); + XNFasprintf(&tmp, "SBUS:fb%d", sBus->fbNum); } + GDev->busID = tmp; } diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 8a8c5939d..35eab722c 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -32,12 +32,16 @@ #include <xorg-config.h> #endif +#include <X11/X.h> +#include <X11/Xproto.h> +#include <X11/extensions/Xv.h> +#include <X11/extensions/Xvproto.h> + +#include "Xext/xvdix_priv.h" + #include "misc.h" #include "xf86.h" #include "xf86_OSproc.h" - -#include <X11/X.h> -#include <X11/Xproto.h> #include "scrnintstr.h" #include "regionstr.h" #include "windowstr.h" @@ -47,11 +51,7 @@ #include "resource.h" #include "gcstruct.h" #include "dixstruct.h" - -#include <X11/extensions/Xv.h> -#include <X11/extensions/Xvproto.h> #include "xvdix.h" - #include "xf86xvpriv.h" /* XvAdaptorRec fields */ diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c index 621ef5336..effeff6fc 100644 --- a/hw/xfree86/ddc/ddc.c +++ b/hw/xfree86/ddc/ddc.c @@ -271,7 +271,7 @@ xf86DoEDID_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDC1SetSpeed, Bool noddc = FALSE, noddc1 = FALSE; OptionInfoPtr options; - options = xnfalloc(sizeof(DDCOptions)); + options = XNFalloc(sizeof(DDCOptions)); (void) memcpy(options, DDCOptions, sizeof(DDCOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c index 7259d2192..0ded3ff71 100644 --- a/hw/xfree86/ddc/interpret_edid.c +++ b/hw/xfree86/ddc/interpret_edid.c @@ -171,7 +171,7 @@ xf86InterpretEDID(int scrnIndex, Uchar * block) if (!block) return NULL; - if (!(m = xnfcalloc(sizeof(xf86Monitor), 1))) + if (!(m = XNFcallocarray(1, sizeof(xf86Monitor)))) return NULL; m->scrnIndex = scrnIndex; m->rawData = block; diff --git a/hw/xfree86/dixmods/fbmodule.c b/hw/xfree86/dixmods/fbmodule.c index 5895ba296..b3d98fb2d 100644 --- a/hw/xfree86/dixmods/fbmodule.c +++ b/hw/xfree86/dixmods/fbmodule.c @@ -33,20 +33,21 @@ static XF86ModuleVersionInfo VersRec = { #ifdef FB_ACCESS_WRAPPER - "wfb", + .modname = "wfb", #else - "fb", + .modname = "fb", #endif - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 1, 0, 0, - ABI_CLASS_ANSIC, /* Only need the ansic layer */ - ABI_ANSIC_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} /* signature, to be patched into the file by a tool */ + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 1, + .minorversion = 0, + .patchlevel = 0, + .abiclass = ABI_CLASS_ANSIC, + .abiversion = ABI_ANSIC_VERSION, }; _X_EXPORT XF86ModuleData FBPREFIX(ModuleData) = { -&VersRec, NULL, NULL}; + .vers = &VersRec +}; diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c index 2215c8867..b90e941d9 100644 --- a/hw/xfree86/dixmods/glxmodule.c +++ b/hw/xfree86/dixmods/glxmodule.c @@ -48,19 +48,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static MODULESETUPPROTO(glxSetup); static XF86ModuleVersionInfo VersRec = { - "glx", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 1, 0, 0, - ABI_CLASS_EXTENSION, - ABI_EXTENSION_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} + .modname = "glx", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 1, + .minorversion = 0, + .patchlevel = 0, + .abiclass = ABI_CLASS_EXTENSION, + .abiversion = ABI_EXTENSION_VERSION, }; -_X_EXPORT XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL }; +_X_EXPORT XF86ModuleData glxModuleData = { + .vers = &VersRec, + .setup = glxSetup +}; static void * glxSetup(void *module, void *opts, int *errmaj, int *errmin) diff --git a/hw/xfree86/dixmods/shmodule.c b/hw/xfree86/dixmods/shmodule.c index 0cbb9df71..655b7826e 100644 --- a/hw/xfree86/dixmods/shmodule.c +++ b/hw/xfree86/dixmods/shmodule.c @@ -38,16 +38,18 @@ #include "shadow.h" static XF86ModuleVersionInfo VersRec = { - "shadow", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 1, 1, 0, - ABI_CLASS_ANSIC, /* Only need the ansic layer */ - ABI_ANSIC_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} /* signature, to be patched into the file by a tool */ + .modname = "shadow", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 1, + .minorversion = 1, + .patchlevel = 0, + .abiclass = ABI_CLASS_ANSIC, + .abiversion = ABI_ANSIC_VERSION, }; -_X_EXPORT XF86ModuleData shadowModuleData = { &VersRec, NULL, NULL }; +_X_EXPORT XF86ModuleData shadowModuleData = { + .vers = &VersRec +}; diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml index b7da50de3..e17bb941e 100644 --- a/hw/xfree86/doc/ddxDesign.xml +++ b/hw/xfree86/doc/ddxDesign.xml @@ -6776,30 +6776,6 @@ programming the standard VGA registers, and for handling VGA colourmaps. <blockquote><para> <programlisting> - Bool vgaHWSetRegCounts(ScrnInfoPtr pScrn, int numCRTC, - int numSequencer, int numGraphics, int numAttribute); - </programlisting> - <blockquote><para> - This function allows the number of CRTC, Sequencer, Graphics and - Attribute registers to be changed. This makes it possible for - extended registers to be saved and restored with - <function>vgaHWSave()</function> and <function>vgaHWRestore()</function>. - This function should be called after a <structname>vgaHWRec</structname> - has been allocated with <function>vgaHWGetHWRec()</function>. The - default values are defined in <filename>vgaHW.h</filename> as follows: - - <programlisting> -#define VGA_NUM_CRTC 25 -#define VGA_NUM_SEQ 5 -#define VGA_NUM_GFX 9 -#define VGA_NUM_ATTR 21 - </programlisting> - </para> - - </blockquote></para></blockquote> - - <blockquote><para> - <programlisting> Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src); </programlisting> <blockquote><para> @@ -6947,17 +6923,6 @@ programming the standard VGA registers, and for handling VGA colourmaps. <blockquote><para> <programlisting> - void vgaHWDisable(vgaHWPtr hwp); - </programlisting> - <blockquote><para> - This function disables the VGA subsystem. (Note, this function is - present in XFree86 4.1.0 and later.). - </para> - - </blockquote></para></blockquote> - - <blockquote><para> - <programlisting> void vgaHWSave(ScrnInfoPtr pScrn, vgaRegPtr save, int flags); </programlisting> <blockquote><para> @@ -7021,11 +6986,6 @@ programming the standard VGA registers, and for handling VGA colourmaps. </literallayout> </para> - <para> - The number of registers actually saved may be modified by a prior call - to <function>vgaHWSetRegCounts()</function>. - </para> - </blockquote></para></blockquote> <blockquote><para> @@ -7105,11 +7065,6 @@ programming the standard VGA registers, and for handling VGA colourmaps. </literallayout> </para> - <para> - The number of registers actually restored may be modified by a prior call - to <function>vgaHWSetRegCounts()</function>. - </para> - </blockquote></para></blockquote> <blockquote><para> @@ -7777,7 +7732,7 @@ static const OptionInfoRec ZZZOptions[] = { <programlisting> static MODULESETUPPROTO(zzzSetup); -XF86ModuleData zzzModuleData = { &zzzVersRec, zzzSetup, NULL }; +XF86ModuleData zzzModuleData = { .vers = &zzzVersRec, .setup = zzzSetup, .teardown = NULL }; static pointer zzzSetup(pointer module, pointer opts, int *errmaj, int *errmin) @@ -7818,7 +7773,7 @@ zzzSetup(pointer module, pointer opts, int *errmaj, int *errmin) The <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> is initialised to <constant>NULL</constant>, so it is easy to check if the initialisation has already been done. After allocating it, initialise - the fields. By using <function>xnfcalloc()</function> to do the allocation + the fields. By using <function>XNFcallocarray()</function> to do the allocation it is zeroed, and if the allocation fails the server exits. </para> @@ -7837,7 +7792,7 @@ ZZZGetRec(ScrnInfoPtr pScrn) { if (pScrn->driverPrivate != NULL) return TRUE; - pScrn->driverPrivate = xnfcalloc(sizeof(ZZZRec), 1); + pScrn->driverPrivate = XNFcallocarray(1, sizeof(ZZZRec)); /* Initialise as required */ ... return TRUE; diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index ea2ac7d21..e9c5a24bb 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -44,6 +44,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <sys/time.h> #include <unistd.h> #include <X11/X.h> +#include <X11/Xfuncproto.h> #include <X11/Xproto.h> #include "dix/dix_priv.h" @@ -258,7 +259,7 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn, tmp.resOwner = NULL; if (!pDRIEntPriv) - pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1); + pDRIEntPriv = XNFcallocarray(1, sizeof(*pDRIEntPriv)); if (!pDRIEntPriv) { DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for " @@ -381,7 +382,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) return FALSE; } -#ifdef PANORAMIX +#ifdef XINERAMA /* * If Xinerama is on, don't allow DRI to initialise. It won't be usable * anyway. @@ -391,7 +392,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) "Direct rendering is not supported when Xinerama is enabled\n"); return FALSE; } -#endif +#endif /* XINERAMA */ if (drm_server_inited == FALSE) { drmSetServerInfo(&DRIDRMServerInfo); drm_server_inited = TRUE; @@ -633,6 +634,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) return TRUE; } +static Bool DRIDestroyWindow(WindowPtr pWin); + Bool DRIFinishScreenInit(ScreenPtr pScreen) { @@ -1209,7 +1212,7 @@ DRIDriverClipNotify(ScreenPtr pScreen) DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv->pDriverInfo->ClipNotify) { - WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows); + WindowPtr *pDRIWindows = calloc(pDRIPriv->nrWindows, sizeof(WindowPtr)); DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; if (pDRIPriv->nrWindows > 0) { @@ -1919,7 +1922,7 @@ DRITreeTraversal(WindowPtr pWin, void *data) return WT_WALKCHILDREN; } -Bool +static Bool DRIDestroyWindow(WindowPtr pWin) { ScreenPtr pScreen = pWin->drawable.pScreen; diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h index 2ec1c76ea..6e09048f4 100644 --- a/hw/xfree86/dri/dri.h +++ b/hw/xfree86/dri/dri.h @@ -277,8 +277,6 @@ extern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context); extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn); -extern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin); - extern _X_EXPORT void DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index b74544cad..0efaab2b2 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -425,28 +425,25 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) /* Clip cliprects to screen dimensions (redirected windows) */ pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t)); - if (pClippedRects) { - ScreenPtr pScreen = screenInfo.screens[stuff->screen]; - int i, j; - - for (i = 0, j = 0; i < rep.numClipRects; i++) { - pClippedRects[j].x1 = max(pClipRects[i].x1, 0); - pClippedRects[j].y1 = max(pClipRects[i].y1, 0); - pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width); - pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height); - - if (pClippedRects[j].x1 < pClippedRects[j].x2 && - pClippedRects[j].y1 < pClippedRects[j].y2) { - j++; - } - } + if (!pClippedRects) + return BadAlloc; - rep.numClipRects = j; - } - else { - rep.numClipRects = 0; + ScreenPtr pScreen = screenInfo.screens[stuff->screen]; + int i, j; + + for (i = 0, j = 0; i < rep.numClipRects; i++) { + pClippedRects[j].x1 = max(pClipRects[i].x1, 0); + pClippedRects[j].y1 = max(pClipRects[i].y1, 0); + pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width); + pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height); + + if (pClippedRects[j].x1 < pClippedRects[j].x2 && + pClippedRects[j].y1 < pClippedRects[j].y2) { + j++; + } } + rep.numClipRects = j; rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects; } @@ -560,19 +557,10 @@ ProcXF86DRIDispatch(register ClientPtr client) } static int _X_COLD -SProcXF86DRIQueryVersion(register ClientPtr client) -{ - REQUEST(xXF86DRIQueryVersionReq); - swaps(&stuff->length); - return ProcXF86DRIQueryVersion(client); -} - -static int _X_COLD SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) { REQUEST(xXF86DRIQueryDirectRenderingCapableReq); REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq); - swaps(&stuff->length); swapl(&stuff->screen); return ProcXF86DRIQueryDirectRenderingCapable(client); } @@ -588,7 +576,7 @@ SProcXF86DRIDispatch(register ClientPtr client) */ switch (stuff->data) { case X_XF86DRIQueryVersion: - return SProcXF86DRIQueryVersion(client); + return ProcXF86DRIQueryVersion(client); case X_XF86DRIQueryDirectRenderingCapable: return SProcXF86DRIQueryDirectRenderingCapable(client); default: diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 3397bb50c..953e736e4 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -35,6 +35,9 @@ #endif #include <errno.h> + +#include "os/client_priv.h" + #ifdef WITH_LIBDRM #include <xf86drm.h> #endif @@ -356,10 +359,15 @@ DRI2CreateDrawable2(ClientPtr client, DrawablePtr pDraw, XID id, XID *dri2_id_out) { DRI2DrawablePtr pPriv; - DRI2ClientPtr dri2_client = dri2ClientPrivate(client); + DRI2ClientPtr dri2_client; XID dri2_id; int rc; + if (!dixPrivateKeyRegistered(dri2ScreenPrivateKey)) + return BadValue; + + dri2_client = dri2ClientPrivate(client); + pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) pPriv = DRI2AllocateDrawable(pDraw); @@ -1362,9 +1370,14 @@ Bool DRI2Authenticate(ClientPtr client, ScreenPtr pScreen, uint32_t magic) { DRI2ScreenPtr ds; - DRI2ClientPtr dri2_client = dri2ClientPrivate(client); + DRI2ClientPtr dri2_client; ScreenPtr primescreen; + if (!dixPrivateKeyRegistered(dri2ScreenPrivateKey)) + return FALSE; + + dri2_client = dri2ClientPrivate(client); + ds = DRI2GetScreenPrime(pScreen, dri2_client->prime_id); if (ds == NULL) return FALSE; diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index c43ce95ca..b1d604a9e 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -75,7 +75,6 @@ validDrawable(ClientPtr client, XID drawable, Mask access_mode, static int ProcDRI2QueryVersion(ClientPtr client) { - REQUEST(xDRI2QueryVersionReq); xDRI2QueryVersionReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, @@ -84,9 +83,6 @@ ProcDRI2QueryVersion(ClientPtr client) .minorVersion = dri2_minor }; - if (client->swapped) - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xDRI2QueryVersionReq); if (client->swapped) { @@ -651,7 +647,6 @@ SProcDRI2Connect(ClientPtr client) /* If the client is swapped, it's not local. Talk to the hand. */ - swaps(&stuff->length); if (sizeof(*stuff) / 4 != client->req_len) return BadLength; @@ -686,10 +681,10 @@ DRI2ExtensionInit(void) { ExtensionEntry *dri2Extension; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return; -#endif +#endif /* XINERAMA */ dri2Extension = AddExtension(DRI2_NAME, DRI2NumberEvents, diff --git a/hw/xfree86/drivers/inputtest/inputtestdrv.man b/hw/xfree86/drivers/inputtest/inputtestdrv.man index b0aa76dd3..0fd3431d9 100644 --- a/hw/xfree86/drivers/inputtest/inputtestdrv.man +++ b/hw/xfree86/drivers/inputtest/inputtestdrv.man @@ -15,57 +15,67 @@ inputtest \- An X.Org input driver for testing .SH DESCRIPTION .B inputtest -is an Xorg input driver that passes events received over a socket on to the -server as input events. It supports the full set of the xf86 driver APIs -exposed by Xorg. The primary use cases of this input driver are various -integration tests that need to interface with the input subsystem. +is an Xorg input driver +that passes events received over a socket on to the server as input events. +It supports the full set of the xf86 driver APIs exposed by Xorg. +The primary use cases of this input driver are various integration tests +that need to interface with the input subsystem. .SH CONFIGURATION DETAILS -Please refer to @xconfigfile@(@filemansuffix@) for general configuration -details and for options that can be used with all input drivers. This -section only covers configuration details specific to this driver. +Please refer to +.BR @xconfigfile@ (@filemansuffix@) +for general configuration details +and for options +that can be used with all input drivers. +This section only covers configuration details specific to this driver. .PP -External process can communicate with the input driver via a named socket that -is created after the driver is initialized. The paths to the socket is passed -via input driver options. +External process can communicate with the input driver via a named socket +that is created after the driver is initialized. +The paths to the socket is passed via input driver options. .PP The following driver .B Options are supported: .TP 7 .BI "Option \*qSocketPath\*q \*q" string \*q -Sets the path where the driver will create a named socket. Any existing file -at that location will be removed. +Sets the path where the driver will create a named socket. +Any existing file at that location will be removed. .TP 7 .BI "Option \*qDeviceType\*q \*q" string \*q Sets the type of the device to be emulated. .IP -.BI Keyboard +.B Keyboard Initializes a keyboard device. .IP -.BI Pointer -Initializes a relative-mode pointer device. It will have four valuators - -a "Rel X" valuator at axis 0 and a "Rel Y" valuator at axis 1. +.B Pointer +Initializes a relative-mode pointer device. +It will have four valuators \(en +a "Rel X" valuator at axis 0 +and a "Rel Y" valuator at axis 1. A horizontal scroll valuator will be set up at axis 2. A vertical scroll valuator will be set up at axis 3. .IP -.BI PointerAbsolute -Initializes an absolute-mode pointer device. It will have four valuators - -an "Abs X" valuator at axis 0 and an "Abs Y" valuator at axis 1. +.B PointerAbsolute +Initializes an absolute-mode pointer device. +It will have four valuators \(en +an "Abs X" valuator at axis 0 +and an "Abs Y" valuator at axis 1. A horizontal scroll valuator will be set up at axis 2. A vertical scroll valuator will be set up at axis 3. .IP -.BI PointerAbsoluteProximity +.B PointerAbsoluteProximity Initializes an absolute-mode pointer device with proximity support. -The valuators are initialized in the same way as for \fBPointerAbsolute\fR type. +The valuators are initialized in the same way +as for \fBPointerAbsolute\fR type. .IP -.BI Touch +.B Touch Initializes a touch device. -It will have 5 valuators: an "Abs MT Position X" at axis 0, +It will have 5 valuators: +an "Abs MT Position X" at axis 0, an "Abs MT Position Y" valuator at axis 1, a horizontal scroll valuator on axis 2, -a vertical scroll valuator on axis 3 and an "Abs MT Pressure" valuator -at axis 4. +a vertical scroll valuator on axis 3 +and an "Abs MT Pressure" valuator at axis 4. .TP 7 .BI "Option \*qTouchCount\*q \*q" int \*q Sets the maximum number of simultaneous touches for touch devices. @@ -80,33 +90,47 @@ Selects whether "Abs Pressure" is available at the axis 4 in pointer devices. The communication with the driver is a binary protocol defined in include/xf86-input-inputtest-protocol.h .PP -At the beginning, the client process that communicates with the driver must -connect to the socket that is created by the driver at SocketPath. -Once the connection is established, it must write a xf86ITEventClientVersion -event and read a xf86ITResponseServerVersion response where the driver -specifies the protocol version supported by it. If this version is lower than -requested by the client, then the driver will disconnect. +At the beginning, +the client process +that communicates with the driver must connect to the socket +that is created by the driver at SocketPath. +Once the connection is established, +it must write a xf86ITEventClientVersion event +and read a xf86ITResponseServerVersion response +where the driver specifies the protocol version supported by it. +If this version is lower than requested by the client, +then the driver will disconnect. .PP After receiving xf86ITResponseServerVersion message the client may send events -to the driver. Each event is an instance of one of the -.BI xf86ITEvent* -structs. The length field defines the full length of the struct in bytes and -the event field defines the type of the struct. +to the driver. +Each event is an instance of one of the +.BI xf86ITEvent * +structs. +The length field defines the full length of the struct in bytes +and the event field defines the type of the struct. .PP -The responses from the server follow the same structure. Each response is an -instance of one of the -.BI xf86ITResponse* -structs. The length field defines the full length of the struct in bytes and -the event field defines the type of the struct. +The responses from the server follow the same structure. +Each response is an instance of one of the +.BI xf86ITResponse * +structs. +The length field defines the full length of the struct in bytes +and the event field defines the type of the struct. .PP The synchronization with Xorg is performed via -.BI xf86ITEventWaitForSync -event. After sending such event, the client must read of a -.BI xf86ITResponseSyncFinished event from the socket without sending additional -events. The completion of the read operation indicates that Xorg has fully -processed all input events sent to it so far. +.B xf86ITEventWaitForSync +event. +After sending such event, +the client must read a +.B xf86ITResponseSyncFinished +event from the socket +without sending additional events. +The completion of the read operation indicates +that Xorg has fully processed all input events sent to it so far. .SH AUTHORS Povilas Kanapickas <povilas@radix.lt> -.SH "SEE ALSO" -@xservername@(@appmansuffix@), @xconfigfile@(@filemansuffix@), Xserver(@appmansuffix@), X(@miscmansuffix@) +.SH SEE ALSO +.BR @xservername@ (@appmansuffix@), +.BR @xconfigfile@ (@filemansuffix@), +.BR Xserver (@appmansuffix@), +.BR X (@miscmansuffix@) diff --git a/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c b/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c index dd19f47a9..294e35747 100644 --- a/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c +++ b/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c @@ -940,7 +940,7 @@ get_type_name(InputInfoPtr pInfo, xf86ITDevicePtr driver_data) static xf86ITDevicePtr device_alloc(void) { - xf86ITDevicePtr driver_data = calloc(sizeof(xf86ITDevice), 1); + xf86ITDevicePtr driver_data = calloc(1, sizeof(xf86ITDevice)); if (!driver_data) return NULL; @@ -1107,18 +1107,17 @@ InputDriverRec driver = { }; static XF86ModuleVersionInfo version_info = { - "inputtest", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - XORG_VERSION_MAJOR, - XORG_VERSION_MINOR, - XORG_VERSION_PATCH, - ABI_CLASS_XINPUT, - ABI_XINPUT_VERSION, - MOD_CLASS_XINPUT, - {0, 0, 0, 0} + .modname = "inputtest", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = XORG_VERSION_MAJOR, + .minorversion = XORG_VERSION_MINOR, + .patchlevel = XORG_VERSION_PATCH, + .abiclass = ABI_CLASS_XINPUT, + .abiversion = ABI_XINPUT_VERSION, + .moduleclass = MOD_CLASS_XINPUT, }; static void* @@ -1131,5 +1130,4 @@ setup_proc(void *module, void *options, int *errmaj, int *errmin) _X_EXPORT XF86ModuleData inputtestModuleData = { .vers = &version_info, .setup = &setup_proc, - .teardown = NULL }; diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c index 8be3810bf..af7db7ddc 100644 --- a/hw/xfree86/drivers/modesetting/dri2.c +++ b/hw/xfree86/drivers/modesetting/dri2.c @@ -32,9 +32,7 @@ * This doesn't implement pageflipping yet. */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include <errno.h> #include <time.h> @@ -320,7 +318,7 @@ ms_dri2_copy_region2(ScreenPtr screen, DrawablePtr drawable, RegionPtr pRegion, * callback chain so we know that will happen before the client * tries to render again. */ - gc->ops->CopyArea(src, dst, gc, + (void) gc->ops->CopyArea(src, dst, gc, 0, 0, drawable->width, drawable->height, off_x, off_y); @@ -550,10 +548,8 @@ can_exchange(ScrnInfoPtr scrn, DrawablePtr draw, drmmode_crtc_private_ptr drmmode_crtc = config->crtc[i]->driver_private; /* Don't do pageflipping if CRTCs are rotated. */ -#ifdef GLAMOR_HAS_GBM if (drmmode_crtc->rotate_bo.gbm) return FALSE; -#endif if (xf86_crtc_on(config->crtc[i])) num_crtcs_on++; diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index f3400a1cd..fe78111e8 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -32,9 +32,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include <errno.h> #include <unistd.h> @@ -42,6 +40,7 @@ #include <X11/extensions/randr.h> #include <X11/extensions/Xv.h> +#include "config/hotplug_priv.h" #include "dix/dix_priv.h" #include "xf86.h" @@ -158,21 +157,23 @@ int ms_entity_index = -1; static MODULESETUPPROTO(Setup); static XF86ModuleVersionInfo VersRec = { - "modesetting", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - XORG_VERSION_MAJOR, - XORG_VERSION_MINOR, - XORG_VERSION_PATCH, - ABI_CLASS_VIDEODRV, - ABI_VIDEODRV_VERSION, - MOD_CLASS_VIDEODRV, - {0, 0, 0, 0} + .modname = "modesetting", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = XORG_VERSION_MAJOR, + .minorversion = XORG_VERSION_MINOR, + .patchlevel = XORG_VERSION_PATCH, + .abiclass = ABI_CLASS_VIDEODRV, + .abiversion = ABI_VIDEODRV_VERSION, + .moduleclass = MOD_CLASS_VIDEODRV, }; -_X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL }; +_X_EXPORT XF86ModuleData modesettingModuleData = { + .vers = &VersRec, + .setup = Setup +}; static void * Setup(void *module, void *opts, int *errmaj, int *errmin) @@ -396,7 +397,7 @@ ms_setup_entity(ScrnInfoPtr scrn, int entity_num) xf86SetEntityInstanceForScreen(scrn, entity_num, xf86GetNumEntityInstances(entity_num) - 1); if (!pPriv->ptr) - pPriv->ptr = xnfcalloc(sizeof(modesettingEntRec), 1); + pPriv->ptr = XNFcallocarray(1, sizeof(modesettingEntRec)); } #ifdef XSERVER_LIBPCIACCESS @@ -515,7 +516,7 @@ GetRec(ScrnInfoPtr pScrn) if (pScrn->driverPrivate) return TRUE; - pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1); + pScrn->driverPrivate = XNFcallocarray(1, sizeof(modesettingRec)); return TRUE; } @@ -1025,7 +1026,7 @@ ms_unwrap_property_requests(ScrnInfoPtr scrn) } static void -FreeRec(ScrnInfoPtr pScrn) +FreeScreen(ScrnInfoPtr pScrn) { modesettingPtr ms; @@ -2217,12 +2218,6 @@ AdjustFrame(ScrnInfoPtr pScrn, int x, int y) } static void -FreeScreen(ScrnInfoPtr pScrn) -{ - FreeRec(pScrn); -} - -static void LeaveVT(ScrnInfoPtr pScrn) { modesettingPtr ms = modesettingPTR(pScrn); diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 6942126c0..6769d3dbf 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -27,9 +27,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include <errno.h> #include <sys/ioctl.h> @@ -536,7 +534,7 @@ drm_mode_ensure_blob(xf86CrtcPtr crtc, const drmModeModeInfo* mode_info) drmmode_CompareKModes(&drmmode_crtc->current_mode->mode_info, mode_info) == 0) return 0; - mode = calloc(sizeof(drmmode_mode_rec), 1); + mode = calloc(1, sizeof(drmmode_mode_rec)); if (!mode) return -1; @@ -904,7 +902,7 @@ drmmode_crtc_set_mode(xf86CrtcPtr crtc, Bool test_only) return ret; } - output_ids = calloc(sizeof(uint32_t), xf86_config->num_output); + output_ids = calloc(xf86_config->num_output, sizeof(uint32_t)); if (!output_ids) return -1; @@ -1565,7 +1563,7 @@ drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) gc = GetScratchGC(pScrn->depth, pScreen); ValidateGC(&dst->drawable, gc); - (*gc->ops->CopyArea)(&src->drawable, &dst->drawable, gc, 0, 0, + (void) (*gc->ops->CopyArea)(&src->drawable, &dst->drawable, gc, 0, 0, pScrn->virtualX, pScrn->virtualY, 0, 0); FreeScratchGC(gc); @@ -1913,8 +1911,9 @@ drmmode_set_gamma_lut(drmmode_crtc_private_ptr drmmode_crtc, drmmode_prop_info_ptr gamma_lut_info = &drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT]; const uint32_t crtc_id = drmmode_crtc->mode_crtc->crtc_id; - uint32_t blob_id; - struct drm_color_lut lut[size]; + struct drm_color_lut *lut = calloc(size, sizeof(struct drm_color_lut)); + if (!lut) + return; assert(gamma_lut_info->prop_id != 0); @@ -1925,13 +1924,17 @@ drmmode_set_gamma_lut(drmmode_crtc_private_ptr drmmode_crtc, lut[i].reserved = 0; } - if (drmModeCreatePropertyBlob(drmmode->fd, lut, sizeof(lut), &blob_id)) + uint32_t blob_id; + if (drmModeCreatePropertyBlob(drmmode->fd, lut, sizeof(lut), &blob_id)) { + free(lut); return; + } drmModeObjectSetProperty(drmmode->fd, crtc_id, DRM_MODE_OBJECT_CRTC, gamma_lut_info->prop_id, blob_id); drmModeDestroyPropertyBlob(drmmode->fd, blob_id); + free(lut); } static void @@ -2495,8 +2498,8 @@ drmmode_crtc_create_planes(xf86CrtcPtr crtc, int num) drmmode_crtc->plane_id = best_plane; if (best_kplane) { drmmode_crtc->num_formats = best_kplane->count_formats; - drmmode_crtc->formats = calloc(sizeof(drmmode_format_rec), - best_kplane->count_formats); + drmmode_crtc->formats = calloc(best_kplane->count_formats, + sizeof(drmmode_format_rec)); if (!populate_format_modifiers(crtc, best_kplane, blob_id)) { for (i = 0; i < best_kplane->count_formats; i++) drmmode_crtc->formats[i].format = best_kplane->formats[i]; @@ -2573,7 +2576,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs); if (crtc == NULL) return 0; - drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1); + drmmode_crtc = XNFcallocarray(1, sizeof(drmmode_crtc_private_rec)); crtc->driver_private = drmmode_crtc; drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd, mode_res->crtcs[num]); @@ -2924,7 +2927,7 @@ drmmode_output_get_modes(xf86OutputPtr output) /* modes should already be available */ for (i = 0; i < koutput->count_modes; i++) { - Mode = xnfalloc(sizeof(DisplayModeRec)); + Mode = XNFalloc(sizeof(DisplayModeRec)); drmmode_ConvertFromKMode(output->scrn, &koutput->modes[i], Mode); Modes = xf86ModesAdd(Modes, Mode); @@ -3442,7 +3445,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r } } - kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders); + kencoders = calloc(koutput->count_encoders, sizeof(drmModeEncoderPtr)); if (!kencoders) { goto out_free_encoders; } @@ -3471,7 +3474,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r goto out_free_encoders; } - drmmode_output = calloc(sizeof(drmmode_output_private_rec), 1); + drmmode_output = calloc(1, sizeof(drmmode_output_private_rec)); if (!drmmode_output) { xf86OutputDestroy(output); goto out_free_encoders; @@ -4377,6 +4380,9 @@ static void drmmode_probe_cursor_size(xf86CrtcPtr crtc) drmmode_ptr drmmode = drmmode_crtc->drmmode; int width, height, size; + ms->min_cursor_width = ms->max_cursor_width; + ms->min_cursor_height = ms->max_cursor_height; + /* probe square min first */ for (size = 1; size <= ms->max_cursor_width && size <= ms->max_cursor_height; size *= 2) { diff --git a/hw/xfree86/drivers/modesetting/dumb_bo.c b/hw/xfree86/drivers/modesetting/dumb_bo.c index cf13f0a9c..cdff166ce 100644 --- a/hw/xfree86/drivers/modesetting/dumb_bo.c +++ b/hw/xfree86/drivers/modesetting/dumb_bo.c @@ -25,9 +25,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include "dumb_bo.h" diff --git a/hw/xfree86/drivers/modesetting/meson.build b/hw/xfree86/drivers/modesetting/meson.build index acb37b48d..6f35ff773 100644 --- a/hw/xfree86/drivers/modesetting/meson.build +++ b/hw/xfree86/drivers/modesetting/meson.build @@ -31,6 +31,7 @@ xorg_build_root = join_paths(meson.project_build_root(), 'hw', 'xfree86') symbol_test_args = [] symbol_test_args += join_paths(xorg_build_root, 'libxorgserver.so') symbol_test_args += join_paths(xorg_build_root, 'dixmods', 'libshadow.so') +symbol_test_args += join_paths(xorg_build_root, 'dixmods', 'libglx.so') if gbm_dep.found() symbol_test_args += join_paths(xorg_build_root, 'glamor_egl', 'libglamoregl.so') endif diff --git a/hw/xfree86/drivers/modesetting/modesetting.man b/hw/xfree86/drivers/modesetting/modesetting.man index 4a8af97c8..26212725c 100644 --- a/hw/xfree86/drivers/modesetting/modesetting.man +++ b/hw/xfree86/drivers/modesetting/modesetting.man @@ -22,16 +22,17 @@ If glamor is not enabled, a shadow framebuffer is configured based on the KMS drivers' preference (unless the framebuffer is 24 bits per pixel, in which case the shadow framebuffer is always used). .SH SUPPORTED HARDWARE -The +The .B modesetting driver supports all hardware where a KMS driver is available. modesetting uses the Linux DRM KMS ioctls and dumb object create/map. .SH CONFIGURATION DETAILS -Please refer to @xconfigfile@(@filemansuffix@) for general configuration -details. This section only covers configuration details specific to -this driver. +Please refer to +.BR @xconfigfile@ (@filemansuffix@) +for general configuration details. +This section only covers configuration details specific to this driver. .PP -For this driver it is not required to specify modes in the screen +For this driver it is not required to specify modes in the screen section of the config file. The .B modesetting driver can pick up the currently used video mode from the kernel @@ -40,7 +41,7 @@ driver and will use it if there are no video modes configured. For PCI boards you might have to add a BusID line to the Device section. See above for a sample line. .PP -The following driver +The following driver .B Options are supported: .TP @@ -125,7 +126,9 @@ Enable atomic modesetting when supported. The default is .B off. .TP .SH "SEE ALSO" -@xservername@(@appmansuffix@), @xconfigfile@(@filemansuffix@), Xserver(@appmansuffix@), -X(@miscmansuffix@) +.BR @xservername@ (@appmansuffix@), +.BR @xconfigfile@ (@filemansuffix@), +.BR Xserver (@appmansuffix@), +.BR X (@miscmansuffix@) .SH AUTHORS Authors include: Dave Airlie diff --git a/hw/xfree86/drivers/modesetting/pageflip.c b/hw/xfree86/drivers/modesetting/pageflip.c index f0b8d5919..785c0d2d1 100644 --- a/hw/xfree86/drivers/modesetting/pageflip.c +++ b/hw/xfree86/drivers/modesetting/pageflip.c @@ -20,13 +20,12 @@ * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include <errno.h> -#include <xserver_poll.h> +#include "os/xserver_poll.h" + #include <xf86drm.h> #include "driver.h" diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c index 788b500d6..421d70016 100644 --- a/hw/xfree86/drivers/modesetting/present.c +++ b/hw/xfree86/drivers/modesetting/present.c @@ -20,9 +20,7 @@ * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include <assert.h> #include <errno.h> @@ -127,7 +125,7 @@ ms_present_queue_vblank(RRCrtcPtr crtc, struct ms_present_vblank_event *event; uint32_t seq; - event = calloc(sizeof(struct ms_present_vblank_event), 1); + event = calloc(1, sizeof(struct ms_present_vblank_event)); if (!event) return BadAlloc; event->event_id = event_id; @@ -426,22 +424,24 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id) PixmapPtr pixmap = screen->GetScreenPixmap(screen); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); int i; - struct ms_present_vblank_event *event; ms_present_set_screen_vrr(scrn, FALSE); - event = calloc(1, sizeof(struct ms_present_vblank_event)); - if (!event) - return; + if (ms_present_check_unflip(NULL, screen->root, pixmap, TRUE, NULL)) { + struct ms_present_vblank_event *event; - event->event_id = event_id; - event->unflip = TRUE; + event = calloc(1, sizeof(struct ms_present_vblank_event)); + if (!event) + return; - if (ms_present_check_unflip(NULL, screen->root, pixmap, TRUE, NULL) && - ms_do_pageflip(screen, pixmap, event, NULL, FALSE, - ms_present_flip_handler, ms_present_flip_abort, - "Present-unflip")) { - return; + event->event_id = event_id; + event->unflip = TRUE; + + if (ms_do_pageflip(screen, pixmap, event, NULL, FALSE, + ms_present_flip_handler, ms_present_flip_abort, + "Present-unflip")) { + return; + } } for (i = 0; i < config->num_crtc; i++) { diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c index c89aa3f17..a406279c2 100644 --- a/hw/xfree86/drivers/modesetting/vblank.c +++ b/hw/xfree86/drivers/modesetting/vblank.c @@ -25,9 +25,7 @@ * Support for tracking the DRM's vblank events. */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include <errno.h> #include <unistd.h> diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c index 0bbd93e34..0b0bf8118 100644 --- a/hw/xfree86/exa/examodule.c +++ b/hw/xfree86/exa/examodule.c @@ -121,7 +121,7 @@ exaDDXDriverInit(ScreenPtr pScreen) if (pScreenPriv == NULL) return; - pScreenPriv->options = xnfalloc(sizeof(EXAOptions)); + pScreenPriv->options = XNFalloc(sizeof(EXAOptions)); memcpy(pScreenPriv->options, EXAOptions, sizeof(EXAOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pScreenPriv->options); @@ -182,16 +182,18 @@ exaDDXDriverInit(ScreenPtr pScreen) } static XF86ModuleVersionInfo exaVersRec = { - "exa", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - EXA_VERSION_MAJOR, EXA_VERSION_MINOR, EXA_VERSION_RELEASE, - ABI_CLASS_VIDEODRV, /* requires the video driver ABI */ - ABI_VIDEODRV_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} + .modname = "exa", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = EXA_VERSION_MAJOR, + .minorversion = EXA_VERSION_MINOR, + .patchlevel = EXA_VERSION_RELEASE, + .abiclass = ABI_CLASS_VIDEODRV, + .abiversion = ABI_VIDEODRV_VERSION, }; -_X_EXPORT XF86ModuleData exaModuleData = { &exaVersRec, NULL, NULL }; +_X_EXPORT XF86ModuleData exaModuleData = { + .vers = &exaVersRec +}; diff --git a/hw/xfree86/exa/man/exa.man b/hw/xfree86/exa/man/exa.man index c051b998b..5db7475bf 100644 --- a/hw/xfree86/exa/man/exa.man +++ b/hw/xfree86/exa/man/exa.man @@ -5,24 +5,30 @@ exa \- new 2D acceleration architecture for X.Org .SH DESCRIPTION .B EXA -provides a simple API for video drivers to implement for 2D acceleration. It -is a module loaded by drivers, and is not intended to be loaded on its own. +provides a simple API for video drivers to implement for 2D acceleration. +It is a module loaded by drivers, +and is not intended to be loaded on its own. See your driver's manual page for how to enable .BR EXA . .PP The .B EXA -architecture is designed to make accelerating the Render extension simple and -efficient, and results in various performance tradeoffs compared to XAA. Some -xorg.conf options are available for debugging performance issues or -driver rendering problems. They are not intended for general use. +architecture is designed to make accelerating the Render extension simple +and efficient, +and results in various performance tradeoffs compared to XAA. +Some xorg.conf options are available for debugging performance issues +or driver rendering problems. +They are not intended for general use. .TP .BI "Option \*qEXANoComposite\*q \*q" boolean \*q -Disables acceleration of the Composite operation, which is at the heart of -the Render extension. Not related to the Composite extension. Default: No. +Disables acceleration of the Composite operation, +which is at the heart of the Render extension. +Not related to the Composite extension. +Default: No. .TP .BI "Option \*qEXANoUploadToScreen\*q \*q" boolean \*q -Disables acceleration of uploading pixmap data to the framebuffer. Default: No. +Disables acceleration of uploading pixmap data to the framebuffer. +Default: No. .TP .BI "Option \*qEXANoDownloadFromScreen\*q \*q" boolean \*q Disables acceleration of downloading of pixmap data from the framebuffer. @@ -31,12 +37,16 @@ Not usable with drivers which rely on DownloadFromScreen succeeding. Default: No. .TP .BI "Option \*qMigrationHeuristic\*q \*q" anystr \*q -Chooses an alternate pixmap migration heuristic, for debugging purposes. The -default is intended to be the best performing one for general use, though others -may help with specific use cases. Available options include \*qalways\*q, -\*qgreedy\*q, and \*qsmart\*q. Default: always. -.SH "SEE ALSO" +Chooses an alternate pixmap migration heuristic, +for debugging purposes. +The default is intended to be the best performing one for general use, +though others may help with specific use cases. +Available options include \*qalways\*q, +\*qgreedy\*q, +and \*qsmart\*q. +Default: always. +.SH SEE ALSO .BR Xorg (@appmansuffix@), -.BR xorg.conf(@filemansuffix@). +.BR xorg.conf (@filemansuffix@). .SH AUTHORS Authors include: Keith Packard, Eric Anholt, Zack Rusin, and Michel D\(:anzer diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 76bc4809f..74336087a 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -23,22 +23,20 @@ #define PAGE_MASK (~(getpagesize() - 1)) static XF86ModuleVersionInfo fbdevHWVersRec = { - "fbdevhw", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 0, 0, 2, - ABI_CLASS_VIDEODRV, - ABI_VIDEODRV_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} + .modname = "fbdevhw", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 0, + .minorversion = 0, + .patchlevel = 2, + .abiclass = ABI_CLASS_VIDEODRV, + .abiversion = ABI_VIDEODRV_VERSION, }; _X_EXPORT XF86ModuleData fbdevhwModuleData = { - &fbdevHWVersRec, - NULL, - NULL + .vers = &fbdevHWVersRec }; #include <fcntl.h> @@ -94,7 +92,7 @@ fbdevHWGetRec(ScrnInfoPtr pScrn) if (FBDEVHWPTR(pScrn) != NULL) return TRUE; - FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(fbdevHWRec), 1); + FBDEVHWPTRLVAL(pScrn) = XNFcallocarray(1, sizeof(fbdevHWRec)); return TRUE; } @@ -287,7 +285,7 @@ fbdev_open_pci(struct pci_device *pPci, char **namep) if (fd != -1) { if (ioctl(fd, FBIOGET_FSCREENINFO, (void *) &fix) != -1) { if (namep) { - *namep = xnfalloc(16); + *namep = XNFalloc(16); strncpy(*namep, fix.id, 16); } @@ -378,9 +376,9 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) node++; } - if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 || + if (asprintf(&sysfs_path, "/sys/class/graphics/%s/device/subsystem", node) < 0 || readlink(sysfs_path, buf, sizeof(buf) - 1) < 0 || - strstr(buf, "devices/pci")) { + strstr(buf, "bus/pci")) { free(sysfs_path); close(fd); return -1; @@ -396,7 +394,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) return -1; } else { - *namep = xnfalloc(16); + *namep = XNFalloc(16); strncpy(*namep, fix.id, 16); } } diff --git a/hw/xfree86/fbdevhw/man/fbdevhw.man b/hw/xfree86/fbdevhw/man/fbdevhw.man index f9e8aaf41..f72b3cd1d 100644 --- a/hw/xfree86/fbdevhw/man/fbdevhw.man +++ b/hw/xfree86/fbdevhw/man/fbdevhw.man @@ -10,13 +10,17 @@ A .B fbdevhw module is currently available for linux framebuffer devices. .PP -fbdev(@drivermansuffix@) is a non-accelerated driver which runs on top of the +.BR fbdev (@drivermansuffix@) +is a non-accelerated driver which runs on top of the fbdevhw module. fbdevhw can be used by other drivers too, this is usually activated with `Option "UseFBDev"' in the device section. .SH "SEE ALSO" -Xorg(@appmansuffix@), xorg.conf(@filemansuffix@), -xorgconfig(@appmansuffix@), Xserver(@appmansuffix@), X(@miscmansuffix@), -fbdev(@drivermansuffix@) +.BR Xorg (@appmansuffix@), +.BR xorg.conf (@filemansuffix@), +.BR xorgconfig (@appmansuffix@), +.BR Xserver (@appmansuffix@), +.BR X (@miscmansuffix@), +.BR fbdev (@drivermansuffix@) .SH AUTHORS Authors include: Gerd Knorr, based on the XF68_FBDev Server code (Martin Schaller, Geert Uytterhoeven). diff --git a/hw/xfree86/glamor_egl/glamor_xf86_xv.c b/hw/xfree86/glamor_egl/glamor_xf86_xv.c index 5f8bb8f15..5e0eb0afd 100644 --- a/hw/xfree86/glamor_egl/glamor_xf86_xv.c +++ b/hw/xfree86/glamor_egl/glamor_xf86_xv.c @@ -34,9 +34,7 @@ * device-dependent XV interfaces. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #define GLAMOR_FOR_XORG #include "glamor_priv.h" diff --git a/hw/xfree86/i2c/xf86i2c.c b/hw/xfree86/i2c/xf86i2c.c index 59733b032..3c295b6dd 100644 --- a/hw/xfree86/i2c/xf86i2c.c +++ b/hw/xfree86/i2c/xf86i2c.c @@ -872,7 +872,7 @@ xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr ** pppI2CBus) if (!pppI2CBus) continue; - *pppI2CBus = xnfreallocarray(*pppI2CBus, n, sizeof(I2CBusPtr)); + *pppI2CBus = XNFreallocarray(*pppI2CBus, n, sizeof(I2CBusPtr)); (*pppI2CBus)[n - 1] = pI2CBus; } diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c index 9e52305d9..4d8dfb4de 100644 --- a/hw/xfree86/int10/generic.c +++ b/hw/xfree86/int10/generic.c @@ -133,15 +133,15 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) return NULL; } - pInt = (xf86Int10InfoPtr) xnfcalloc(1, sizeof(xf86Int10InfoRec)); + pInt = (xf86Int10InfoPtr) XNFcallocarray(1, sizeof(xf86Int10InfoRec)); pInt->entityIndex = entityIndex; if (!xf86Int10ExecSetup(pInt)) goto error0; pInt->mem = &genericMem; - pInt->private = (void *) xnfcalloc(1, sizeof(genericInt10Priv)); - INTPriv(pInt)->alloc = (void *) xnfcalloc(1, ALLOC_ENTRIES(getpagesize())); + pInt->private = (void *) XNFcallocarray(1, sizeof(genericInt10Priv)); + INTPriv(pInt)->alloc = (void *) XNFcallocarray(1, ALLOC_ENTRIES(getpagesize())); pInt->pScrn = pScrn; - base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS); + base = INTPriv(pInt)->base = XNFalloc(SYS_BIOS); /* FIXME: Shouldn't this be a failure case? Leaving dev as NULL seems like * FIXME: an error @@ -217,7 +217,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) } #else if (!sysMem) { - sysMem = xnfalloc(BIOS_SIZE); + sysMem = XNFalloc(BIOS_SIZE); setup_system_bios(sysMem); } INTPriv(pInt)->sysMem = sysMem; diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c index c7c8478e6..ccfecf15d 100644 --- a/hw/xfree86/int10/helper_exec.c +++ b/hw/xfree86/int10/helper_exec.c @@ -744,7 +744,7 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save) base += BIOS_SCRATCH_OFF; if (save) { - if ((pInt->BIOSScratch = xnfalloc(BIOS_SCRATCH_LEN))) + if ((pInt->BIOSScratch = XNFalloc(BIOS_SCRATCH_LEN))) for (i = 0; i < BIOS_SCRATCH_LEN; i++) *(((char *) pInt->BIOSScratch + i)) = *(base + i); } diff --git a/hw/xfree86/int10/vbe.c b/hw/xfree86/int10/vbe.c index 26efdd76e..a4f3af58c 100644 --- a/hw/xfree86/int10/vbe.c +++ b/hw/xfree86/int10/vbe.c @@ -143,7 +143,7 @@ VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags) L_ADD(vbe-> OemProductRevPtr))); } - vip = (vbeInfoPtr) xnfalloc(sizeof(vbeInfoRec)); + vip = (vbeInfoPtr) XNFalloc(sizeof(vbeInfoRec)); vip->version = B_O16(vbe->VbeVersion); vip->pInt10 = pInt; vip->ddc = DDC_UNCHECKED; @@ -270,7 +270,7 @@ vbeReadEDID(vbeInfoPtr pVbe) if (!page) return NULL; - options = xnfalloc(sizeof(VBEOptions)); + options = XNFalloc(sizeof(VBEOptions)); (void) memcpy(options, VBEOptions, sizeof(VBEOptions)); xf86ProcessOptions(screen, pScrn->options, options); xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe); @@ -302,7 +302,7 @@ vbeReadEDID(vbeInfoPtr pVbe) switch (pVbe->pInt10->ax & 0xff00) { case 0x0: xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read successfully\n"); - tmp = (unsigned char *) xnfalloc(128); + tmp = (unsigned char *) XNFalloc(128); memcpy(tmp, page, 128); break; case 0x100: @@ -374,7 +374,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) if (R16(pVbe->pInt10->ax) != 0x4f) return NULL; - block = calloc(sizeof(VbeInfoBlock), 1); + block = calloc(1, sizeof(VbeInfoBlock)); block->VESASignature[0] = ((char *) pVbe->memory)[0]; block->VESASignature[1] = ((char *) pVbe->memory)[1]; block->VESASignature[2] = ((char *) pVbe->memory)[2]; @@ -886,7 +886,7 @@ VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock * vbe) bpp = mode->BitsPerPixel; - m = xnfcalloc(sizeof(vbeModeInfoRec), 1); + m = XNFcallocarray(1, sizeof(vbeModeInfoRec)); m->width = mode->XResolution; m->height = mode->YResolution; m->bpp = bpp; @@ -1078,7 +1078,7 @@ VBEReadPanelID(vbeInfoPtr pVbe) case 0x0: xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID read successfully\n"); - tmp = xnfalloc(32); + tmp = XNFalloc(32); memcpy(tmp, page, 32); break; case 0x100: diff --git a/hw/xfree86/int10/vbeModes.c b/hw/xfree86/int10/vbeModes.c index 980e40b9c..7c5d882fc 100644 --- a/hw/xfree86/int10/vbeModes.c +++ b/hw/xfree86/int10/vbeModes.c @@ -240,7 +240,7 @@ CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, int id, VBEFreeModeInfo(mode); return NULL; } - pMode = xnfcalloc(sizeof(DisplayModeRec), 1); + pMode = XNFcallocarray(1, sizeof(DisplayModeRec)); pMode->status = MODE_OK; pMode->type = M_T_BUILTIN; @@ -249,7 +249,7 @@ CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, int id, pMode->HDisplay = mode->XResolution; pMode->VDisplay = mode->YResolution; - data = xnfcalloc(sizeof(VbeModeInfoData), 1); + data = XNFcallocarray(1, sizeof(VbeModeInfoData)); data->mode = id; data->data = mode; pMode->PrivSize = sizeof(VbeModeInfoData); @@ -404,7 +404,7 @@ VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Attempting to use %dHz refresh for mode \"%s\" (%x)\n", (int) pMode->VRefresh, pMode->name, data->mode); - data->block = calloc(sizeof(VbeCRTCInfoBlock), 1); + data->block = calloc(1, sizeof(VbeCRTCInfoBlock)); data->block->HorizontalTotal = best->HTotal; data->block->HorizontalSyncStart = best->HSyncStart; data->block->HorizontalSyncEnd = best->HSyncEnd; diff --git a/hw/xfree86/int10/xf86int10module.c b/hw/xfree86/int10/xf86int10module.c index 1eb5a0783..00e4ce34a 100644 --- a/hw/xfree86/int10/xf86int10module.c +++ b/hw/xfree86/int10/xf86int10module.c @@ -7,26 +7,21 @@ #include <xorg-config.h> #endif -#include "xf86.h" -#include "xf86str.h" -#include "xf86Pci.h" -#include "xf86int10.h" +#include "xf86Module.h" -#ifndef MOD_NAME -#define MOD_NAME int10 -#endif - -#define stringify(x) #x -#define STRING(x) stringify(x) -#define concat(x,y) x ## y -#define combine(a,b) concat(a,b) -#define NAME(x) combine(MOD_NAME,x) - -static XF86ModuleVersionInfo NAME(VersRec) = { - STRING(NAME()), MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_VIDEODRV, /* needs the video driver ABI */ - ABI_VIDEODRV_VERSION, MOD_CLASS_NONE, { - 0, 0, 0, 0} +static XF86ModuleVersionInfo VersRec = { + .modname = "int10", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 1, + .minorversion = 0, + .patchlevel = 0, + .abiclass = ABI_CLASS_VIDEODRV, + .abiversion = ABI_VIDEODRV_VERSION, }; -_X_EXPORT XF86ModuleData NAME(ModuleData) = { -&NAME(VersRec), NULL, NULL}; +_X_EXPORT XF86ModuleData int10ModuleData = { + .vers = &VersRec +}; diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index 2580e93d9..4696b639d 100644 --- a/hw/xfree86/loader/loader.c +++ b/hw/xfree86/loader/loader.c @@ -75,19 +75,18 @@ LoaderInit(void) LogMessageVerb(X_INFO, 2, "Loader magic: %p\n", (void *) xorg_symbols); #endif LogMessageVerb(X_INFO, 2, "Module ABI versions:\n"); - LogWrite(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC, - GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion), - GET_ABI_MINOR(LoaderVersionInfo.ansicVersion)); - LogWrite(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV, - GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion), - GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion)); - LogWrite(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT, - GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion), - GET_ABI_MINOR(LoaderVersionInfo.xinputVersion)); - LogWrite(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION, - GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion), - GET_ABI_MINOR(LoaderVersionInfo.extensionVersion)); - + LogMessageVerb(X_NONE, 2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC, + GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion), + GET_ABI_MINOR(LoaderVersionInfo.ansicVersion)); + LogMessageVerb(X_NONE, 2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV, + GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion), + GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion)); + LogMessageVerb(X_NONE, 2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT, + GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion), + GET_ABI_MINOR(LoaderVersionInfo.xinputVersion)); + LogMessageVerb(X_NONE, 2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION, + GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion), + GET_ABI_MINOR(LoaderVersionInfo.extensionVersion)); } /* Public Interface to the loader. */ diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index f8a44827f..cca11028c 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -438,14 +438,14 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data, vercode[1] = (ver / 100000) % 100; vercode[2] = (ver / 1000) % 100; vercode[3] = ver % 1000; - LogWrite(1, "\tcompiled for %d.%d.%d", vercode[0], vercode[1], vercode[2]); + LogMessageVerb(X_NONE, 1, "\tcompiled for %d.%d.%d", vercode[0], vercode[1], vercode[2]); if (vercode[3] != 0) - LogWrite(1, ".%d", vercode[3]); - LogWrite(1, ", module version = %d.%d.%d\n", data->majorversion, - data->minorversion, data->patchlevel); + LogMessageVerb(X_NONE, 1, ".%d", vercode[3]); + LogMessageVerb(X_NONE, 1, ", module version = %d.%d.%d\n", data->majorversion, + data->minorversion, data->patchlevel); if (data->moduleclass) - LogWrite(2, "\tModule class: %s\n", data->moduleclass); + LogMessageVerb(X_NONE, 2, "\tModule class: %s\n", data->moduleclass); ver = -1; if (data->abiclass) { @@ -463,8 +463,8 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data, abimaj = GET_ABI_MAJOR(data->abiversion); abimin = GET_ABI_MINOR(data->abiversion); - LogWrite(2, "\tABI class: %s, version %d.%d\n", - data->abiclass, abimaj, abimin); + LogMessageVerb(X_NONE, 2, "\tABI class: %s, version %d.%d\n", + data->abiclass, abimaj, abimin); if (ver != -1) { vermaj = GET_ABI_MAJOR(ver); vermin = GET_ABI_MINOR(ver); @@ -686,14 +686,14 @@ LoadModule(const char *module, void *options, const XF86ModReqInfo *modreq, name = LoaderGetCanonicalName(module, patterns); noncanonical = (name && strcmp(module, name) != 0); if (noncanonical) { - LogWrite(3, " (%s)\n", name); + LogMessageVerb(X_NONE, 3, " (%s)\n", name); LogMessageVerb(X_WARNING, 1, "LoadModule: given non-canonical module name \"%s\"\n", module); m = name; } else { - LogWrite(3, "\n"); + LogMessageVerb(X_NONE, 3, "\n"); m = (char *) module; } @@ -733,7 +733,7 @@ LoadModule(const char *module, void *options, const XF86ModReqInfo *modreq, * check the elements in the path */ if (PathIsAbsolute(module)) - found = xstrdup(module); + found = Xstrdup(module); path_elem = pathlist; while (!found && *path_elem != NULL) { found = FindModule(m, *path_elem, patterns); diff --git a/hw/xfree86/man/Xorg.man b/hw/xfree86/man/Xorg.man index 2084653f8..a77b4ffaa 100644 --- a/hw/xfree86/man/Xorg.man +++ b/hw/xfree86/man/Xorg.man @@ -23,7 +23,6 @@ The XFree86 release was originally derived from by Thomas Roell which was contributed to X11R5 by Snitily Graphics Consulting Service. .SH PLATFORMS -.PP .B Xorg operates under a wide range of operating systems and hardware platforms. The Intel x86 (IA32) architecture is the most widely supported hardware @@ -33,9 +32,10 @@ free/OpenSource UNIX-like systems such as Linux, FreeBSD, NetBSD, OpenBSD, and Solaris. Commercial UNIX operating systems such as UnixWare are also supported. Other supported operating systems include GNU Hurd. Mac OS X is supported with the -Xquartz(@appmansuffix@) X server. Win32/Cygwin is supported with the -XWin(@appmansuffix@) X server. -.PP +.BR Xquartz (@appmansuffix@) +X server. Win32/Cygwin is supported with the +.BR XWin (@appmansuffix@) +X server. .SH "NETWORK CONNECTIONS" .B Xorg supports connections made using the following reliable @@ -44,8 +44,10 @@ byte-streams: .I "Local" On most platforms, the "Local" connection type is a UNIX-domain socket. On some System V platforms, the "local" connection types also include -STREAMS pipes, named pipes, and some other mechanisms. See the -"LOCAL CONNECTIONS" section of X(@miscmansuffix@) for details. +STREAMS pipes, named pipes, and some other mechanisms. +See the "LOCAL CONNECTIONS" section of +.BR X (@miscmansuffix@) +for details. .TP 4 .I TCP/IP .B Xorg @@ -56,25 +58,31 @@ where is the display number. This connection type is usually disabled by default, but may be enabled with the .B \-listen -option (see the Xserver(1) man page for details). +option (see the +.BR Xserver (1) +man page for details). .SH OPTIONS .B Xorg supports several mechanisms for supplying/obtaining configuration and run-time parameters: command line options, environment variables, the -xorg.conf(@filemansuffix@) configuration files, auto-detection, and +.BR xorg.conf (@filemansuffix@) +configuration files, auto-detection, and fallback defaults. When the same information is supplied in more than one way, the highest precedence mechanism is used. The list of mechanisms is ordered from highest precedence to lowest. Note that not all parameters can be supplied via all methods. The available command line options -and environment variables (and some defaults) are described here and in -the Xserver(@appmansuffix@) manual page. Most configuration file +and environment variables (and some defaults) are described here and in the +.BR Xserver (@appmansuffix@) +manual page. Most configuration file parameters, with their defaults, are described in the -xorg.conf(@filemansuffix@) manual page. Driver and module specific +.BR xorg.conf (@filemansuffix@) +manual page. Driver and module specific configuration parameters are described in the relevant driver or module manual page. .PP In addition to the normal server options described in the -Xserver(@appmansuffix@) manual page, +.BR Xserver (@appmansuffix@) +manual page, .B Xorg accepts the following command line switches: .TP 8 @@ -92,15 +100,17 @@ as Linux, BSD, OpenSolaris, SVR3, and SVR4. Allow the server to start up even if the mouse device can't be opened or initialised. This is equivalent to the .B AllowMouseOpenFail -xorg.conf(@filemansuffix@) file option. +.BR xorg.conf (@filemansuffix@) +file option. .TP 8 .B \-allowNonLocalXvidtune Make the VidMode extension available to remote clients. This allows the xvidtune client to connect from another host. This is equivalent to the .B AllowNonLocalXvidtune -xorg.conf(@filemansuffix@) file option. By default non-local -connections are not allowed. +.BR xorg.conf (@filemansuffix@) +file option. +By default non-local connections are not allowed. .TP 8 .BI \-bgamma " value" Set the blue gamma correction. @@ -139,10 +149,12 @@ config directory search path for all other users. When this option is specified, the .B Xorg server loads all video driver modules, probes for available hardware, -and writes out an initial xorg.conf(@filemansuffix@) file based on -what was detected. This option currently has some problems on some -platforms, but in most cases it is a good way to bootstrap the -configuration process. This option is only available when the server +and writes out an initial +.BR xorg.conf (@filemansuffix@) +file based on what was detected. +This option currently has some problems on some platforms, +but in most cases it is a good way to bootstrap the configuration process. +This option is only available when the server is run as root (i.e, with real-uid 0). .TP 8 .BI "\-crt /dev/tty" XX @@ -159,7 +171,8 @@ Disable the parts of the VidMode extension (used by the xvidtune client) that can be used to change the video modes. This is equivalent to the .B DisableVidModeExtension -xorg.conf(@filemansuffix@) file option. +.BR xorg.conf (@filemansuffix@) +file option. .TP 8 .B \-fbbpp \fIn\fP Sets the number of framebuffer bits per pixel. You should only set this @@ -226,7 +239,9 @@ want to use systemd-logind integration you must specify this option. Not all platforms support (or can use) this option. .TP 8 .BI \-keyboard " keyboard-name" -Use the xorg.conf(@filemansuffix@) file +Use the +.BR xorg.conf (@filemansuffix@) +file .B InputDevice section called .I keyboard-name @@ -238,7 +253,9 @@ section and this option, the first relevant section is used for the core keyboard. .TP 8 .BI \-layout " layout-name" -Use the xorg.conf(@filemansuffix@) file +Use the +.BR xorg.conf (@filemansuffix@) +file .B Layout section called .IR layout-name . @@ -287,7 +304,8 @@ as root (i.e, with real-uid 0). Disable automatically setting secondary GPUs up as output sinks and offload sources. This is equivalent to setting the .B AutoBindGPU -xorg.conf(__filemansuffix__) file option. To +.BR xorg.conf (@filemansuffix@) +file option. To .B false. .TP 8 .B \-nosilk @@ -298,7 +316,9 @@ Disable the automatic switching on X server reset and shutdown to the VT that was active when the server started, if supported by the OS. .TP 8 .BI \-pointer " pointer-name" -Use the xorg.conf(@filemansuffix@) file +Use the +.BR xorg.conf (@filemansuffix@) +file .B InputDevice section called .I pointer-name @@ -328,7 +348,9 @@ options. Share virtual terminals with another X server, if supported by the OS. .TP 8 .BI \-screen " screen-name" -Use the xorg.conf(@filemansuffix@) file +Use the +.BR xorg.conf (@filemansuffix@) +file .B Screen section called .IR screen-name . @@ -376,7 +398,6 @@ Print out the server version, patchlevel, release date, the operating system/platform it was built on, and whether it includes module loader support. .SH "KEYBOARD" -.PP The .B Xorg server is normally configured to recognize various special combinations @@ -392,7 +413,8 @@ keymap. Immediately kills the server -- no questions asked. It can be disabled by setting the .B DontZap -xorg.conf(@filemansuffix@) file option to a TRUE value. +.BR xorg.conf (@filemansuffix@) +file option to a TRUE value. .PP .RS 8 It should be noted that zapping is triggered by the @@ -406,20 +428,23 @@ but can be enabled with the XKB option Change video mode to next one specified in the configuration file. This can be disabled with the .B DontZoom -xorg.conf(@filemansuffix@) file option. +.BR xorg.conf (@filemansuffix@) +file option. .TP 8 .B Ctrl+Alt+Keypad-Minus Change video mode to previous one specified in the configuration file. This can be disabled with the .B DontZoom -xorg.conf(@filemansuffix@) file option. +.BR xorg.conf (@filemansuffix@) +file option. .TP 8 .B Ctrl+Alt+F1...F12 For systems with virtual terminal support, these keystroke combinations are used to switch to virtual terminals 1 through 12, respectively. This can be disabled with the .B DontVTSwitch -xorg.conf(@filemansuffix@) file option. +.BR xorg.conf (@filemansuffix@) +file option. .SH CONFIGURATION .B Xorg typically uses a configuration file called @@ -429,8 +454,9 @@ and configuration files with the suffix in a directory called .B @xconfigdir@ for its initial setup. -Refer to the xorg.conf(@filemansuffix@) manual page for information -about the format of this file. +Refer to the +.BR xorg.conf (@filemansuffix@) +manual page for information about the format of this file. .PP .B Xorg has a mechanism for automatically generating a built-in configuration @@ -460,9 +486,11 @@ supported by Xorg. Enhancements are planned for future releases. .SH FILES The .B Xorg -server config files can be found in a range of locations. These are -documented fully in the xorg.conf(@filemansuffix@) manual page. The -most commonly used locations are shown here. +server config files can be found in a range of locations. +These are documented fully in the +.BR xorg.conf (@filemansuffix@) +manual page. +The most commonly used locations are shown here. .TP 30 .B /etc/X11/xorg.conf Server configuration file. @@ -523,45 +551,49 @@ Manual pages. Initial access control list for display .IR n . .SH "SEE ALSO" -X(@miscmansuffix@), Xserver(@appmansuffix@), xdm(@appmansuffix@), xinit(@appmansuffix@), -xorg.conf(@filemansuffix@), xvidtune(@appmansuffix@), -xkeyboard-config (@miscmansuffix@), -apm(@drivermansuffix@), -ati(@drivermansuffix@), -chips(@drivermansuffix@), -cirrus(@drivermansuffix@), -cyrix(@drivermansuffix@), -fbdev(@drivermansuffix@), -glide(@drivermansuffix@), -glint(@drivermansuffix@), -i128(@drivermansuffix@), -i740(@drivermansuffix@), -imstt(@drivermansuffix@), -intel(@drivermansuffix@), -mga(@drivermansuffix@), -neomagic(@drivermansuffix@), -nsc(@drivermansuffix@), -nv(@drivermansuffix@), -openchrome (@drivermansuffix@), -r128(@drivermansuffix@), -rendition(@drivermansuffix@), -s3virge(@drivermansuffix@), -siliconmotion(@drivermansuffix@), -sis(@drivermansuffix@), -sunbw2(@drivermansuffix@), -suncg14(@drivermansuffix@), -suncg3(@drivermansuffix@), -suncg6(@drivermansuffix@), -sunffb(@drivermansuffix@), -sunleo(@drivermansuffix@), -suntcx(@drivermansuffix@), -tdfx(@drivermansuffix@), -tga(@drivermansuffix@), -trident(@drivermansuffix@), -tseng(@drivermansuffix@), -v4l(@drivermansuffix@), -vesa(@drivermansuffix@), -vmware(@drivermansuffix@), +.BR X (@miscmansuffix@), +.BR Xserver (@appmansuffix@), +.BR xdm (@appmansuffix@), +.BR xinit (@appmansuffix@), +.BR xorg.conf (@filemansuffix@), +.BR xvidtune (@appmansuffix@), +.BR xkeyboard-config (@miscmansuffix@), +.BR apm (@drivermansuffix@), +.BR ati (@drivermansuffix@), +.BR chips (@drivermansuffix@), +.BR cirrus (@drivermansuffix@), +.BR cyrix (@drivermansuffix@), +.BR fbdev (@drivermansuffix@), +.BR glide (@drivermansuffix@), +.BR glint (@drivermansuffix@), +.BR i128 (@drivermansuffix@), +.BR i740 (@drivermansuffix@), +.BR imstt (@drivermansuffix@), +.BR intel (@drivermansuffix@), +.BR mga (@drivermansuffix@), +.BR neomagic (@drivermansuffix@), +.BR nsc (@drivermansuffix@), +.BR nv (@drivermansuffix@), +.BR openchrome (@drivermansuffix@), +.BR r128 (@drivermansuffix@), +.BR rendition (@drivermansuffix@), +.BR s3virge (@drivermansuffix@), +.BR siliconmotion (@drivermansuffix@), +.BR sis (@drivermansuffix@), +.BR sunbw2 (@drivermansuffix@), +.BR suncg14 (@drivermansuffix@), +.BR suncg3 (@drivermansuffix@), +.BR suncg6 (@drivermansuffix@), +.BR sunffb (@drivermansuffix@), +.BR sunleo (@drivermansuffix@), +.BR suntcx (@drivermansuffix@), +.BR tdfx (@drivermansuffix@), +.BR tga (@drivermansuffix@), +.BR trident (@drivermansuffix@), +.BR tseng (@drivermansuffix@), +.BR v4l (@drivermansuffix@), +.BR vesa (@drivermansuffix@), +.BR vmware (@drivermansuffix@), .br Web site .IR <https://www.x.org> . @@ -622,7 +654,6 @@ information can be found from the X.Org web site \fI<https://www.x.org/>\fP. .SH LEGAL -.PP .B Xorg is copyright software, provided under licenses that permit modification and redistribution in source and binary form without fee. diff --git a/hw/xfree86/man/Xorg.wrap.man b/hw/xfree86/man/Xorg.wrap.man index a8ee5eae8..0bf394fa9 100644 --- a/hw/xfree86/man/Xorg.wrap.man +++ b/hw/xfree86/man/Xorg.wrap.man @@ -64,4 +64,5 @@ graphics cards and some are not kms capable auto-detection may fail, in this case manual configuration should be used. .SH "SEE ALSO" -Xorg X server information: \fIXorg\fP(1) +Xorg X server information: +.BR Xorg (1) diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man index ac214591e..b677f5d4a 100644 --- a/hw/xfree86/man/xorg.conf.man +++ b/hw/xfree86/man/xorg.conf.man @@ -14,8 +14,11 @@ than one way, the highest precedence mechanism is used. The list of mechanisms is ordered from highest precedence to lowest. Note that not all parameters can be supplied via all methods. The available command line options and environment variables (and some defaults) are -described in the Xserver(@appmansuffix@) and -Xorg(@appmansuffix@) manual pages. Most configuration file +described in the +.BR Xserver (@appmansuffix@) +and +.BR Xorg (@appmansuffix@) +manual pages. Most configuration file parameters, with their defaults, are described below. Driver and module specific configuration parameters are described in the relevant driver or module manual page. @@ -50,11 +53,11 @@ server is started as a normal user: .PP where .I <cmdline> -is a relative path (with no \(lq..\(rq components) specified with the +is a relative path (with no \(lq..\&\(rq components) specified with the .B \-config command line option, .B $XORGCONFIG -is the relative path (with no \(lq..\(rq components) specified by that +is the relative path (with no \(lq..\&\(rq components) specified by that environment variable, and .I <hostname> is the machine's hostname as reported by @@ -109,7 +112,7 @@ directories when the server is started as a normal user: .PP where .I <cmdline> -is a relative path (with no \(lq..\(rq components) specified with the +is a relative path (with no \(lq..\&\(rq components) specified with the .B \-configdir command line option. .PP @@ -156,7 +159,7 @@ Each section has the form: .nf .BI "Section \*q" SectionName \*q .RI " " SectionEntry - ... + \&... .B EndSection .fi .RE @@ -379,7 +382,6 @@ is a number used to order the fontfile FPEs. Examples: .I gscript:pri=60 -> /usr/share/fonts/default/ghostscript .I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc .fi -.PP .RE .RE .RE @@ -551,9 +553,14 @@ extension) to connect from another host. Default: off. .TP 7 .BI "Option \*qAllowMouseOpenFail\*q \*q" boolean \*q -This tells the mousedrv(@drivermansuffix@) and vmmouse(@drivermansuffix@) +This tells the +.BR mousedrv (@drivermansuffix@) +and +.BR vmmouse (@drivermansuffix@) drivers to not report failure if the mouse device can't be opened/initialised. -It has no effect on the evdev(@drivermansuffix@) or other drivers. +It has no effect on the +.BR evdev (@drivermansuffix@) +or other drivers. Default: false. .TP 7 .BI "Option \*qBlankTime\*q \*q" time \*q @@ -565,7 +572,7 @@ is in minutes. This is equivalent to the Xorg server's .B \-s flag, and the value can be changed at run\-time with -.BR xset(@appmansuffix@). +.BR xset (@appmansuffix@). Default: 10 minutes. .TP 7 .BI "Option \*qStandbyTime\*q \*q" time \*q @@ -574,7 +581,7 @@ sets the inactivity timeout for the phase of DPMS mode. .I time is in minutes, and the value can be changed at run\-time with -.BR xset(@appmansuffix@). +.BR xset (@appmansuffix@). Default: 10 minutes. This is only suitable for VESA DPMS compatible monitors, and may not be supported by all video drivers. @@ -588,7 +595,7 @@ sets the inactivity timeout for the phase of DPMS mode. .I time is in minutes, and the value can be changed at run\-time with -.BR xset(@appmansuffix@). +.BR xset (@appmansuffix@). Default: 10 minutes. This is only suitable for VESA DPMS compatible monitors, and may not be supported by all video drivers. @@ -602,7 +609,7 @@ sets the inactivity timeout for the phase of DPMS mode. .I time is in minutes, and the value can be changed at run\-time with -.BR xset(@appmansuffix@). +.BR xset (@appmansuffix@). Default: 10 minutes. This is only suitable for VESA DPMS compatible monitors, and may not be supported by all video drivers. @@ -635,9 +642,9 @@ The default value is .BR "typical" , which will setup up a typical subset of the GLXFBConfigs provided by the driver as GLX visuals. Other options are -.BR "minimal" , +.BR minimal , which will set up the minimal set allowed by the GLX specification and -.BR "all" +.B all which will setup GLX visuals for all GLXFBConfigs. .TP 7 .BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q @@ -730,7 +737,7 @@ instruction, the standard name is case-sensitive, and does not include the "lib" prefix, or the ".a", ".o", or ".so" suffixes. .PP The second form of entry is a -.BR SubSection, +.BR SubSection , with the subsection name being the module name, and the contents of the .B SubSection being @@ -785,7 +792,7 @@ it. Entries in this section are listed as Option statements with the name of the extension as the first argument, and a boolean value as the second. The extension name is case\-sensitive, and matches the form shown in the output -of \*qXorg -extension ?\*q. +of \*qXorg \-extension ?\*q. .PP .RS 7 Example: the MIT-SHM extension can be disabled with the following entry: @@ -794,7 +801,7 @@ Example: the MIT-SHM extension can be disabled with the following entry: .nf .B "Section \*qExtensions\*q" .B " Option \*qMIT-SHM\*q \*qDisable\*q" -.B "EndSection" +.B EndSection .fi .RE .RE @@ -806,7 +813,7 @@ Recent X servers employ HAL or udev backends for input device enumeration and input hotplugging. It is usually not necessary to provide .B InputDevice -sections in the xorg.conf if hotplugging is in use (i.e. AutoAddDevices is +sections in the xorg.conf if hotplugging is in use (i.e., AutoAddDevices is enabled). If hotplugging is enabled, .B InputDevice sections using the @@ -843,7 +850,7 @@ sections have the following format: .BI " Driver \*q" inputdriver \*q .I " options" .I " ..." -.B "EndSection" +.B EndSection .fi .RE .PP @@ -885,7 +892,6 @@ and .BR mousedrv (@drivermansuffix@) on other platforms. .PP -.PP .B InputDevice sections recognise some driver\-independent .BR Options , @@ -898,11 +904,11 @@ Always add the device to the ServerLayout section used by this instance of the server. This affects implied layouts as well as explicit layouts specified in the configuration and/or on the command line. .TP 7 -.BI "Option \*qCorePointer\*q" +.B "Option \*qCorePointer\*q" Deprecated, see .B Floating .TP 7 -.BI "Option \*qCoreKeyboard\*q" +.B "Option \*qCoreKeyboard\*q" Deprecated, see .B Floating .TP 7 @@ -928,7 +934,7 @@ and .B SendCoreEvents, are the inverse of option .B Floating -(i.e. +(i.e., .B SendCoreEvents \*qon\*q is equivalent to .B Floating \*qoff\*q @@ -950,8 +956,10 @@ respectively. The identity matrix is "1 0 0 0 1 0 0 0 1". .SS POINTER ACCELERATION For pointing devices, the following options control how the pointer is accelerated or decelerated with respect to physical device motion. Most of -these can be adjusted at runtime, see the xinput(1) man page for details. Only -the most important acceleration options are discussed here. +these can be adjusted at runtime, see the +.BR xinput (1) +man page for details. +Only the most important acceleration options are discussed here. .TP 7 .BI "Option \*qAccelerationProfile\*q \*q" integer \*q Select the profile. In layman's terms, the profile constitutes the "feeling" of @@ -962,7 +970,7 @@ is constructed. This is mainly a matter of personal preference. .RS 6 .nf .B " 0 classic (mostly compatible)" -.B "-1 none (only constant deceleration is applied)" +.B "\-1 none (only constant deceleration is applied)" .B " 1 device-dependent" .B " 2 polynomial (polynomial function)" .B " 3 smooth linear (soft knee, then linear)" @@ -1004,7 +1012,7 @@ profiles to suit the users needs. The .B simple and .B limited -profiles use it directly (i.e. they accelerate by the factor), for other +profiles use it directly (i.e., they accelerate by the factor), for other profiles it should hold that a higher acceleration factor leads to a faster pointer. Typically, 1 is unaccelerated and values up to 5 are sensible. .TP 7 @@ -1035,7 +1043,7 @@ sections have the following format: .I " ..." .I " options" .I " ..." -.B "EndSection" +.B EndSection .fi .RE .PP @@ -1079,13 +1087,13 @@ attribute. For example: .nf .B "Section \*qInputClass\*q" .B " Identifier \*qMy Class\*q" -.B " # product string must contain example and -.B " # either gizmo or gadget -.B " MatchProduct \*qexample\*q -.B " MatchProduct \*qgizmo|gadget\*q -.B " NoMatchDriver \*qdrivername\*q -.I " ..." -.B "EndSection" +.B " # product string must contain example and" +.B " # either gizmo or gadget" +.B " MatchProduct \*qexample\*q" +.B " MatchProduct \*qgizmo\^|\^gadget\*q" +.B " NoMatchDriver \*qdrivername\*q" +.I " \&.\|.\|.\&" +.B EndSection .fi .RE .TP 7 @@ -1224,7 +1232,7 @@ sections have the following format: .BI " Identifier \*q" name \*q .I " entries" .I " ..." -.B "EndSection" +.B EndSection .fi .RE .PP @@ -1268,10 +1276,10 @@ For example: .nf .B "Section \*qOutputClass\*q" .B " Identifier \*qMy Class\*q" -.B " # kernel driver must be either foo or bar -.B " MatchDriver \*qfoo|bar\*q -.I " ..." -.B "EndSection" +.B " # kernel driver must be either foo or bar" +.B " MatchDriver \*qfoo\^|\^bar\*q" +.I " \&.\|.\|.\&" +.B EndSection .fi .RE .TP 7 @@ -1344,7 +1352,7 @@ sections have the following format: .BI " Driver \*q" driver \*q .I " entries" .I " ..." -.B "EndSection" +.B EndSection .fi .RE .PP @@ -1417,7 +1425,7 @@ section is required for each head, and this parameter determines which head each of the .B Device sections applies to. -The legal values of +The valid values of .I number range from 0 to one less than the total number of heads per entity. Most drivers require that the primary screen (0) be present. @@ -1477,7 +1485,7 @@ For details, see the appropriate driver manual page. .BI "VideoRam " "mem" This optional entry specifies the amount of video ram that is installed on the graphics board. -This is measured in kBytes. +This is measured in kilobytes. In most cases this is not required because the Xorg server probes the graphics board to determine this quantity. The driver-specific documentation should indicate when it might be needed. @@ -1508,7 +1516,7 @@ when the driver-specific documentation recommends it. Only apply this .B Device section if X server was started with -.B -seat +.B \-seat .I seat\-id option. .TP 7 @@ -1548,7 +1556,7 @@ section, and they may also be included here. .SH "VIDEOADAPTOR SECTION" Nobody wants to say how this works. -Maybe nobody knows ... +Maybe nobody knows \&... .SH "MONITOR SECTION" The config file may have multiple @@ -1566,7 +1574,7 @@ sections have the following format: .BI " Identifier \*q" name \*q .I " entries" .I " ..." -.B "EndSection" +.B EndSection .fi .RE .PP @@ -1643,7 +1651,7 @@ is added to the end of the line. The data given here is used by the Xorg server to determine if video modes are within the specifications of the monitor. This information should be available in the monitor's handbook. -If this entry is omitted, a default range of 28\-33kHz is used. +If this entry is omitted, a default range of 28\(en33\ kHz is used. .TP 7 .BI "VertRefresh " "vertrefresh\-range" gives the range(s) of vertical refresh frequencies supported by the @@ -1662,7 +1670,7 @@ is added to the end of the line. The data given here is used by the Xorg server to determine if video modes are within the specifications of the monitor. This information should be available in the monitor's handbook. -If this entry is omitted, a default range of 43\-72Hz is used. +If this entry is omitted, a default range of 43\(en72\ Hz is used. .TP 7 .BI "DisplaySize " "width height" This optional entry gives the width and height, in millimetres, of the @@ -1683,7 +1691,7 @@ Not all drivers are capable of using this information. Include the set of modes listed in the .B Modes section called -.IR modesection\-id. +.IR modesection\-id . This makes all of the modes defined in that section available for use by this monitor. .TP 7 @@ -1877,6 +1885,12 @@ at startup. By default, the server will attempt to enable all connected monitors. (RandR 1.2-supporting drivers only) .TP 7 +.BI "Option \*qDisable\*q \*q" bool \*q +This optional entry specifies whether the monitor should be turned off +at startup. By default, the server will attempt to enable all connected +monitors. +(RandR 1.2-supporting drivers only) +.TP 7 .BI "Option \*qDefaultModes\*q \*q" bool \*q This optional entry specifies whether the server should add supported default modes to the list of modes offered on this monitor. By default, the server @@ -1932,7 +1946,7 @@ sections have the following format: .BI " Identifier \*q" name \*q .I " entries" .I " ..." -.B "EndSection" +.B EndSection .fi .RE .PP @@ -1981,12 +1995,12 @@ sections have the following format: .BI " Monitor \*q" monid \*q .I " entries" .I " ..." -.BI " SubSection \*qDisplay\*q" +.B " SubSection \*qDisplay\*q" .I " entries" -.I " ... +.I " \&.\|.\|.\&" .B " EndSubSection" -.I " ..." -.B "EndSection" +.I " \&.\|.\|.\&" +.B EndSection .fi .RE .PP @@ -2024,14 +2038,17 @@ section in the config file. .BI "GPUDevice \*q" device\-id \*q This entry specifies the .B Device -section to be used as a secondary GPU device for this screen. When multiple graphics cards are -present, this is what ties a specific secondary card to a screen. The +section to be used as a secondary GPU device for this screen. +When multiple graphics cards are present, this is what ties a specific +secondary card to a screen. +The .I device\-id must match the .B Identifier of a .B Device -section in the config file. This can be specified up to 4 times for a single screen. +section in the config file. +This can be specified up to 4 times for a single screen. .TP 7 .BI "Monitor \*q" monitor\-id \*q specifies which monitor description is to be used for this screen. @@ -2067,7 +2084,7 @@ sparse 32 bit framebuffer layout. Only apply this .B Screen section if X server was started with -.B -seat +.B \-seat .I seat\-id option. .TP 7 @@ -2081,7 +2098,7 @@ Some are driver\-specific and are described in the driver documentation. Others are driver\-independent, and will eventually be described here. .\" XXX These should really be in an xaa man page. .TP 7 -.BI "Option \*qAccel\*q" +.B "Option \*qAccel\*q" Enables 2D hardware acceleration. This option is on by default, but it may be necessary to turn it off if there are bugs in the driver. @@ -2099,7 +2116,7 @@ Default: mesa. .TP 7 .BI "Option \*RenderingAPI\*q \*q" string \*q This option specifies an rendering API for use in conjunction with Glamor -accel method. You can specify OpenGL with a value "gl" and OpenGL ES with a +accel method. You can specify OpenGL with a value "gl" and OpenGL ES with a value "es", and the default is both, when Glamor fallbacks to GLES if GL 2.1 is not available. This may be useful for embedded and old cards, where GL ES feature set works faster than GL feature set. @@ -2187,7 +2204,7 @@ This entry specifies the framebuffer format this .B Display subsection is to be used for. This entry is only needed when providing depth 24 configurations that allow -a choice between a 24 bpp packed framebuffer format and a 32bpp sparse +a choice between a 24\ bpp packed framebuffer format and a 32\ bpp sparse framebuffer format. In most cases this entry should not be used. .TP 7 @@ -2198,7 +2215,7 @@ formats. This may also be specified from the command line with the .B \-weight option (see -.BR Xorg(@appmansuffix@)). +.BR Xorg (@appmansuffix@)). .TP 7 .BI "Virtual " "xdim ydim" This optional entry specifies the virtual screen resolution to be used. @@ -2249,7 +2266,7 @@ built-in VESA standard modes. .BI "Visual \*q" visual\-name \*q This optional entry sets the default root visual type. This may also be specified from the command line (see the -.BR Xserver(@appmansuffix@) +.BR Xserver (@appmansuffix@) man page). The visual types available for depth 8 are (default is .BR PseudoColor ): @@ -2356,7 +2373,7 @@ sections have the following format: .I " ..." .I " options" .I " ..." -.B "EndSection" +.B EndSection .fi .RE .PP @@ -2478,7 +2495,7 @@ and core keyboard devices respectively. Only apply this .B ServerLayout section if X server was started with -.B -seat +.B \-seat .I seat\-id option. .TP 7 @@ -2525,7 +2542,7 @@ section for a dual headed configuration with two mice: .B " InputDevice \*qMouse 1\*q \*qCorePointer\*q" .B " InputDevice \*qMouse 2\*q \*qSendCoreEvents\*q" .B " Option \*qBlankTime\*q \*q5\*q" -.B "EndSection" +.B EndSection .fi .RE .SH "DRI SECTION" @@ -2545,7 +2562,6 @@ entry and multiple .B Option flags. The data therein is not used in this release. -.PP .SH "SEE ALSO" General: .BR X (@miscmansuffix@), diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index c6e89e66f..902a39104 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -59,7 +59,7 @@ xf86CrtcConfigInit(ScrnInfoPtr scrn, const xf86CrtcConfigFuncsRec * funcs) if (xf86CrtcConfigPrivateIndex == -1) xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); - config = xnfcalloc(1, sizeof(xf86CrtcConfigRec)); + config = XNFcallocarray(1, sizeof(xf86CrtcConfigRec)); config->funcs = funcs; config->compat_output = -1; @@ -88,7 +88,7 @@ xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CrtcPtr crtc, *crtcs; - crtc = calloc(sizeof(xf86CrtcRec), 1); + crtc = calloc(1, sizeof(xf86CrtcRec)); if (!crtc) return NULL; crtc->version = XF86_CRTC_VERSION; @@ -521,7 +521,7 @@ xf86OutputSetMonitor(xf86OutputPtr output) free(output->options); - output->options = xnfalloc(sizeof(xf86OutputOptions)); + output->options = XNFalloc(sizeof(xf86OutputOptions)); memcpy(output->options, xf86OutputOptions, sizeof(xf86OutputOptions)); XNFasprintf(&option_name, "monitor-%s", output->name); @@ -640,7 +640,7 @@ xf86OutputCreate(ScrnInfoPtr scrn, else len = 0; - output = calloc(sizeof(xf86OutputRec) + len, 1); + output = calloc(1, sizeof(xf86OutputRec) + len); if (!output) return NULL; output->scrn = scrn; @@ -2284,8 +2284,8 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, DisplayModePtr *preferred, *preferred_match; Bool ret = FALSE; - preferred = xnfcalloc(config->num_output, sizeof(DisplayModePtr)); - preferred_match = xnfcalloc(config->num_output, sizeof(DisplayModePtr)); + preferred = XNFcallocarray(config->num_output, sizeof(DisplayModePtr)); + preferred_match = XNFcallocarray(config->num_output, sizeof(DisplayModePtr)); /* Check if the preferred mode is available on all outputs */ for (p = -1; nextEnabledOutput(config, enabled, &p);) { @@ -2394,7 +2394,7 @@ xf86TargetAspect(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, Bool ret = FALSE; DisplayModePtr guess = NULL, aspect_guess = NULL, base_guess = NULL; - aspects = xnfcalloc(config->num_output, sizeof(float)); + aspects = XNFcallocarray(config->num_output, sizeof(float)); /* collect the aspect ratios */ for (o = -1; nextEnabledOutput(config, enabled, &o);) { @@ -2551,7 +2551,7 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) Bool success = FALSE; /* Set up the device options */ - config->options = xnfalloc(sizeof(xf86DeviceOptions)); + config->options = XNFalloc(sizeof(xf86DeviceOptions)); memcpy(config->options, xf86DeviceOptions, sizeof(xf86DeviceOptions)); xf86ProcessOptions(scrn->scrnIndex, scrn->options, config->options); config->debug_modes = xf86ReturnOptValBool(config->options, @@ -2571,9 +2571,9 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow) xf86ProbeOutputModes(scrn, width, height); - crtcs = xnfcalloc(config->num_output, sizeof(xf86CrtcPtr)); - modes = xnfcalloc(config->num_output, sizeof(DisplayModePtr)); - enabled = xnfcalloc(config->num_output, sizeof(Bool)); + crtcs = XNFcallocarray(config->num_output, sizeof(xf86CrtcPtr)); + modes = XNFcallocarray(config->num_output, sizeof(DisplayModePtr)); + enabled = XNFcallocarray(config->num_output, sizeof(Bool)); ret = xf86CollectEnabledOutputs(scrn, config, enabled); if (ret == FALSE && canGrow) { diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c index 1ac573867..b0f93e2b7 100644 --- a/hw/xfree86/modes/xf86EdidModes.c +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -596,7 +596,7 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, " sync.\n", __func__, timing->h_active, timing->v_active); } - Mode = xnfcalloc(1, sizeof(DisplayModeRec)); + Mode = XNFcallocarray(1, sizeof(DisplayModeRec)); Mode->type = M_T_DRIVER; if (preferred) diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index 00586c457..091ce6333 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -212,7 +212,7 @@ xf86DuplicateMode(const DisplayModeRec * pMode) { DisplayModePtr pNew; - pNew = xnfalloc(sizeof(DisplayModeRec)); + pNew = XNFalloc(sizeof(DisplayModeRec)); *pNew = *pMode; pNew->next = NULL; pNew->prev = NULL; @@ -220,7 +220,7 @@ xf86DuplicateMode(const DisplayModeRec * pMode) if (pMode->name == NULL) xf86SetModeDefaultName(pNew); else - pNew->name = xnfstrdup(pMode->name); + pNew->name = XNFstrdup(pMode->name); return pNew; } @@ -288,7 +288,7 @@ xf86ModesEqual(const DisplayModeRec * pMode1, const DisplayModeRec * pMode2) static void add(char **p, const char *new) { - *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2); + *p = XNFrealloc(*p, strlen(*p) + strlen(new) + 2); strcat(*p, " "); strcat(*p, new); } @@ -322,7 +322,7 @@ void xf86PrintModeline(int scrnIndex, DisplayModePtr mode) { char tmp[256]; - char *flags = xnfcalloc(1, 1); + char *flags = XNFcallocarray(1, 1); #define TBITS 6 const char tchar[TBITS + 1] = "UezdPb"; @@ -681,7 +681,7 @@ xf86GetConfigModes(XF86ConfModeLinePtr conf_mode) mode = calloc(1, sizeof(DisplayModeRec)); if (!mode) continue; - mode->name = xstrdup(conf_mode->ml_identifier); + mode->name = Xstrdup(conf_mode->ml_identifier); if (!mode->name) { free(mode); continue; @@ -802,7 +802,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, Bool Interlaced) { struct libxcvt_mode_info *libxcvt_mode_info; - DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec)); + DisplayModeRec *Mode = XNFcallocarray(1, sizeof(DisplayModeRec)); char *tmp; libxcvt_mode_info = diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 7943c02b8..cdc4d0c7f 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -24,6 +24,9 @@ #include <xorg-config.h> #endif +#include <X11/extensions/render.h> + +#include "dix/input_priv.h" #include "dix/screenint_priv.h" #include "xf86.h" @@ -36,7 +39,6 @@ #include "windowstr.h" #include "inputstr.h" #include "randrstr_priv.h" -#include <X11/extensions/render.h> #include "xf86cmap.h" #include "xf86Crtc.h" @@ -757,11 +759,11 @@ xf86RandR12CreateScreenResources(ScreenPtr pScreen) int width, height; int mmWidth, mmHeight; -#ifdef PANORAMIX +#ifdef XINERAMA /* XXX disable RandR when using Xinerama */ if (!noPanoramiXExtension) return TRUE; -#endif +#endif /* XINERAMA */ config = XF86_CRTC_CONFIG_PTR(pScrn); randrp = XF86RANDRINFO(pScreen); @@ -847,7 +849,7 @@ xf86RandR12Init(ScreenPtr pScreen) rrScrPrivPtr rp; XF86RandRInfoPtr randrp; -#ifdef PANORAMIX +#ifdef XINERAMA /* XXX disable RandR when using Xinerama */ if (!noPanoramiXExtension) { if (xf86NumScreens == 1) @@ -855,7 +857,7 @@ xf86RandR12Init(ScreenPtr pScreen) else return TRUE; } -#endif +#endif /* XINERAMA */ if (xf86RandR12Generation != serverGeneration) xf86RandR12Generation = serverGeneration; @@ -2144,7 +2146,8 @@ xf86RandR14ProviderSetProperty(ScreenPtr pScreen, /* If we don't have any property handler, then we don't care what the * user is setting properties to. */ - if (config->provider_funcs->set_property == NULL) + if (config->provider_funcs == NULL || + config->provider_funcs->set_property == NULL) return TRUE; /* @@ -2162,7 +2165,8 @@ xf86RandR14ProviderGetProperty(ScreenPtr pScreen, ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - if (config->provider_funcs->get_property == NULL) + if (config->provider_funcs == NULL || + config->provider_funcs->get_property == NULL) return TRUE; /* Should be safe even w/o vtSema */ diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index d94c77cdf..da0aa7635 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -33,8 +33,8 @@ #include <X11/extensions/dpmsconst.h> #include "dix/dix_priv.h" +#include "mi/mi_priv.h" -#include "mi.h" #include "xf86.h" #include "xf86DDC.h" #include "windowstr.h" diff --git a/hw/xfree86/modes/xf86gtf.c b/hw/xfree86/modes/xf86gtf.c index c6a738422..b67233f90 100644 --- a/hw/xfree86/modes/xf86gtf.c +++ b/hw/xfree86/modes/xf86gtf.c @@ -100,7 +100,7 @@ DisplayModePtr xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins) { - DisplayModeRec *mode = xnfcalloc(1, sizeof(DisplayModeRec)); + DisplayModeRec *mode = XNFcallocarray(1, sizeof(DisplayModeRec)); float h_pixels_rnd; float v_lines_rnd; diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c index 279391e42..4d61eeac2 100644 --- a/hw/xfree86/os-support/bsd/alpha_video.c +++ b/hw/xfree86/os-support/bsd/alpha_video.c @@ -42,11 +42,7 @@ #include "xf86_os_support.h" #include "xf86_OSlib.h" -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif +#include "xf86_bsd_priv.h" #ifndef __NetBSD__ extern unsigned long dense_base(void); @@ -91,10 +87,6 @@ dense_base(void) static int devMemFd = -1; -#ifdef HAS_APERTURE_DRV -#define DEV_APERTURE "/dev/xf86" -#endif - /* * Check if /dev/mem can be mmap'd. If it can't print a warning when * "warn" is TRUE. diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c index 15b12a86f..ac34c9ad6 100644 --- a/hw/xfree86/os-support/bsd/arm_video.c +++ b/hw/xfree86/os-support/bsd/arm_video.c @@ -70,11 +70,7 @@ #include "xf86_OSlib.h" #include "compiler.h" -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif +#include "xf86_bsd_priv.h" #define BUS_BASE 0L #define BUS_BASE_BWX 0L diff --git a/hw/xfree86/os-support/bsd/bsd_VTsw.c b/hw/xfree86/os-support/bsd/bsd_VTsw.c index ed06d944a..3016d691b 100644 --- a/hw/xfree86/os-support/bsd/bsd_VTsw.c +++ b/hw/xfree86/os-support/bsd/bsd_VTsw.c @@ -28,14 +28,15 @@ #endif #include <X11/X.h> + #include "xf86.h" #include "xf86Priv.h" #include "xf86_os_support.h" #include "xf86_OSlib.h" +#include "xf86_OSproc.h" /* - * Handle the VT-switching interface for OSs that use USL-style ioctl()s - * (the bsd, sysv, sco, and linux subdirs). + * Handle the VT-switching interface for BSD OSs that use USL-style ioctl()s. */ /* diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index ae6f28b58..5c1323e1a 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -36,6 +36,7 @@ #include "xf86Priv.h" #include "xf86_os_support.h" #include "xf86_OSlib.h" +#include "xf86_OSproc.h" #include <sys/utsname.h> #include <sys/ioctl.h> @@ -44,6 +45,14 @@ #include "os/osdep.h" +#ifndef CONSOLE_X_MODE_ON +#define CONSOLE_X_MODE_ON _IO('t',121) +#endif + +#ifndef CONSOLE_X_MODE_OFF +#define CONSOLE_X_MODE_OFF _IO('t',122) +#endif + static Bool KeepTty = FALSE; #ifdef PCCONS_SUPPORT diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index 403aa08cc..6374b5f80 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -36,10 +36,18 @@ #include "xf86Priv.h" #include "xf86_OSlib.h" -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL) +#include <machine/sysarch.h> +#endif + +#include "xf86_bsd_priv.h" + +#ifndef CONSOLE_X_TV_ON +#define CONSOLE_X_TV_ON _IOW('t',155,int) +#endif + +#ifndef CONSOLE_X_TV_OFF +#define CONSOLE_X_TV_OFF _IO('t',156) #endif #ifdef __OpenBSD__ @@ -59,10 +67,6 @@ static Bool useDevMem = FALSE; static int devMemFd = -1; -#ifdef HAS_APERTURE_DRV -#define DEV_APERTURE "/dev/xf86" -#endif - /* * Check if /dev/mem can be mmap'd. If it can't print a warning when * "warn" is TRUE. diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c index 7a64f4b83..493f886ee 100644 --- a/hw/xfree86/os-support/bsd/ppc_video.c +++ b/hw/xfree86/os-support/bsd/ppc_video.c @@ -37,6 +37,8 @@ #include "bus/Pci.h" +#include "xf86_bsd_priv.h" + /***************************************************************************/ /* Video Memory Mapping section */ /***************************************************************************/ diff --git a/hw/xfree86/os-support/bsd/xf86_bsd_priv.h b/hw/xfree86/os-support/bsd/xf86_bsd_priv.h new file mode 100644 index 000000000..477f2d054 --- /dev/null +++ b/hw/xfree86/os-support/bsd/xf86_bsd_priv.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_XFREE86_OS_SUPPORT_BSD_PRIV_H +#define _XSERVER_XFREE86_OS_SUPPORT_BSD_PRIV_H + +#ifdef __OpenBSD__ +#define DEV_MEM "/dev/xf86" +#else +#define DEV_MEM "/dev/mem" +#endif + +#if defined(__NetBSD__) && !defined(MAP_FILE) +#define MAP_FLAGS MAP_SHARED +#else +#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#endif + +#define DEV_APERTURE "/dev/xf86" + +#endif /* _XSERVER_XFREE86_OS_SUPPORT_BSD_PRIV_H */ diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index 52d142fbf..0fd66a8d1 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -125,6 +125,7 @@ #endif #include "Pci.h" +#include "../xf86_os_support.h" Bool xf86scanpci(void) @@ -134,7 +135,9 @@ xf86scanpci(void) success = (pci_system_init() == 0); /* choose correct platform/OS specific PCI init routine */ - osPciInit(); +#if !defined(__linux__) + xf86InitVidMem(); +#endif return success; } diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index 1921e0282..5e11cf3df 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -106,6 +106,8 @@ #ifndef _PCI_H #define _PCI_H 1 +#include <X11/Xdefs.h> + #include "xf86Pci.h" /* @@ -135,14 +137,6 @@ #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u) -#if defined(__linux__) -#define osPciInit(x) do {} while (0) -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || \ - defined(__DragonFly__) || defined(__sun) || defined(__GNU__) -extern void osPciInit(void); -#else -#error No PCI support available for this architecture/OS combination -#endif +Bool xf86scanpci(void); #endif /* _PCI_H */ diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c index cb14368f8..e27a13dfa 100644 --- a/hw/xfree86/os-support/bus/Sbus.c +++ b/hw/xfree86/os-support/bus/Sbus.c @@ -427,7 +427,7 @@ sparcPromAssignNodes(void) xf86ErrorF("Inconsistent /proc/fb with FBIOGATTR\n"); } else if (!devicePtrs[fbNum]) { - devicePtrs[fbNum] = psdp = xnfcalloc(sizeof(sbusDevice), 1); + devicePtrs[fbNum] = psdp = XNFcallocarray(1, sizeof(sbusDevice)); psdp->devId = devId; psdp->fbNum = fbNum; psdp->fd = -2; @@ -440,7 +440,7 @@ sparcPromAssignNodes(void) for (i = 0, j = 0; i < 32; i++) if (devicePtrs[i] && devicePtrs[i]->fbNum == -1) j++; - xf86SbusInfo = xnfreallocarray(xf86SbusInfo, n + j + 1, sizeof(psdp)); + xf86SbusInfo = XNFreallocarray(xf86SbusInfo, n + j + 1, sizeof(psdp)); for (i = 0, psdpp = xf86SbusInfo; i < 32; i++) if (devicePtrs[i]) { if (devicePtrs[i]->fbNum == -1) { diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c deleted file mode 100644 index 91b80aab9..000000000 --- a/hw/xfree86/os-support/bus/bsd_pci.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2007 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - * Authors: - * Eric Anholt <eric@anholt.net> - * - */ - -/** - * @file bsd_pci.c - * - * This is a trivial implementation of the remaining PCI support hooks in the - * X Server that is unaware of domains. - * - * Most of even this should go away once drivers are converted and the - * old interfaces are confirmed to all be obsolete. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> - -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_os_support.h" -#include "xf86_OSlib.h" -#include "Pci.h" - -#include "pciaccess.h" - -void -osPciInit(void) -{ - xf86InitVidMem(); -} diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h index 4dbe08bd7..88cebcf1c 100644 --- a/hw/xfree86/os-support/bus/xf86Pci.h +++ b/hw/xfree86/os-support/bus/xf86Pci.h @@ -228,12 +228,7 @@ #define PCI_REG_USERCONFIG 0x40 #define PCI_OPTION_REG 0x40 -/* - * Typedefs, etc... - */ - /* Public PCI access functions */ -extern _X_EXPORT Bool xf86scanpci(void); extern _X_EXPORT char *DRICreatePCIBusID(const struct pci_device *dev); #endif /* _XF86PCI_H */ diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c index 42f872dd2..62fdaa434 100644 --- a/hw/xfree86/os-support/linux/int10/linux.c +++ b/hw/xfree86/os-support/linux/int10/linux.c @@ -135,7 +135,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) } } - pInt = (xf86Int10InfoPtr) xnfcalloc(1, sizeof(xf86Int10InfoRec)); + pInt = (xf86Int10InfoPtr) XNFcallocarray(1, sizeof(xf86Int10InfoRec)); pInt->pScrn = pScrn; pInt->entityIndex = entityIndex; pInt->dev = xf86GetPciInfoForEntity(entityIndex); @@ -144,9 +144,9 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) goto error0; pInt->mem = &linuxMem; pagesize = getpagesize(); - pInt->private = (void *) xnfcalloc(1, sizeof(linuxInt10Priv)); + pInt->private = (void *) XNFcallocarray(1, sizeof(linuxInt10Priv)); ((linuxInt10Priv *) pInt->private)->alloc = - (void *) xnfcalloc(1, ALLOC_ENTRIES(pagesize)); + (void *) XNFcallocarray(1, ALLOC_ENTRIES(pagesize)); if (!xf86IsEntityPrimary(entityIndex)) { DebugF("Mapping high memory area\n"); diff --git a/hw/xfree86/os-support/linux/lnx_agp.c b/hw/xfree86/os-support/linux/lnx_agp.c index c1bc6fac7..fd2a07f1b 100644 --- a/hw/xfree86/os-support/linux/lnx_agp.c +++ b/hw/xfree86/os-support/linux/lnx_agp.c @@ -133,7 +133,7 @@ xf86GetAGPInfo(int screenNum) if (!GARTInit(screenNum)) return NULL; - if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) { + if ((info = calloc(1, sizeof(AgpInfo))) == NULL) { xf86DrvMsg(screenNum, X_ERROR, "xf86GetAGPInfo: Failed to allocate AgpInfo\n"); return NULL; diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index c6a24fc7b..689cb1b21 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -33,6 +33,7 @@ #include <unistd.h> #include "config/dbus-core.h" +#include "config/hotplug_priv.h" #include "os.h" #include "linux.h" @@ -397,6 +398,11 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data) dbus_error_free(&error); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } + + /* + * fd will be received via DBus if and only if pause == 0, so it + * only needs to be closed in that code path + */ } else return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -431,6 +437,7 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data) info->active = TRUE; if (pdev) { + close(fd); pdev->flags &= ~XF86_PDEV_PAUSED; } else systemd_logind_set_input_fd_for_all_devs(major, minor, fd, diff --git a/hw/xfree86/os-support/meson.build b/hw/xfree86/os-support/meson.build index bcedf97dc..c312162f3 100644 --- a/hw/xfree86/os-support/meson.build +++ b/hw/xfree86/os-support/meson.build @@ -16,9 +16,6 @@ os_c_args = [] if get_option('pciaccess') srcs_xorg_os_support += 'bus/Pci.c' - if host_machine.system() != 'linux' - srcs_xorg_os_support += 'bus/bsd_pci.c' - endif if host_machine.cpu() == 'sparc' or host_machine.cpu() == 'sparc64' srcs_xorg_os_support += 'bus/Sbus.c' install_data('bus/xf86Sbus.h', install_dir: xorgsdkdir) @@ -39,8 +36,12 @@ if host_machine.system() == 'linux' 'linux/lnx_video.c', 'misc/SlowBcopy.c', 'shared/VTsw_usl.c', - 'shared/drm_platform.c', ] + if libdrm_dep.found() + srcs_xorg_os_support += 'shared/drm_platform.c' + else + srcs_xorg_os_support += 'shared/platform_noop.c' + endif if build_agp srcs_xorg_os_support += 'linux/lnx_agp.c' else diff --git a/hw/xfree86/os-support/shared/VTsw_usl.c b/hw/xfree86/os-support/shared/VTsw_usl.c index a905cce24..ca083fcfd 100644 --- a/hw/xfree86/os-support/shared/VTsw_usl.c +++ b/hw/xfree86/os-support/shared/VTsw_usl.c @@ -36,7 +36,8 @@ /* * Handle the VT-switching interface for OSs that use USL-style ioctl()s - * (the sysv, sco, and linux subdirs). + * (this used to include the sysv, sco, and linux subdirs, but only linux + * remains now). */ /* diff --git a/hw/xfree86/os-support/shared/drm_platform.c b/hw/xfree86/os-support/shared/drm_platform.c index a404aadcc..f6291e44d 100644 --- a/hw/xfree86/os-support/shared/drm_platform.c +++ b/hw/xfree86/os-support/shared/drm_platform.c @@ -10,6 +10,8 @@ #include <errno.h> #include <string.h> +#include "config/hotplug_priv.h" + /* Linux platform device support */ #include "xf86_OSproc.h" @@ -18,7 +20,6 @@ #include "xf86platformBus.h" #include "xf86Bus.h" -#include "hotplug.h" #include "systemd-logind.h" static Bool diff --git a/hw/xfree86/os-support/shared/platform_noop.c b/hw/xfree86/os-support/shared/platform_noop.c index 2ff1deafa..ed0ff93ed 100644 --- a/hw/xfree86/os-support/shared/platform_noop.c +++ b/hw/xfree86/os-support/shared/platform_noop.c @@ -3,6 +3,8 @@ #include <xorg-config.h> #endif +#include "config/hotplug_priv.h" + #ifdef XSERVER_PLATFORM_BUS /* noop platform device support */ #include "xf86_OSproc.h" @@ -19,6 +21,18 @@ xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *bu void xf86PlatformDeviceProbe(struct OdevAttributes *attribs) { +} + +void xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs) +{ +} + +void DeleteGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} +void NewGPUDeviceRequest(struct OdevAttributes *attribs) +{ } + #endif diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c index ee2b2154a..b5a9c87fd 100644 --- a/hw/xfree86/os-support/shared/posix_tty.c +++ b/hw/xfree86/os-support/shared/posix_tty.c @@ -59,7 +59,8 @@ #include <errno.h> #include <X11/X.h> -#include <xserver_poll.h> +#include "os/xserver_poll.h" + #include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c index 40677ad7a..760a39b32 100644 --- a/hw/xfree86/os-support/shared/sigio.c +++ b/hw/xfree86/os-support/shared/sigio.c @@ -61,8 +61,8 @@ #include <X11/X.h> #include "os/osdep.h" +#include "os/xserver_poll.h" -#include <xserver_poll.h> #include "xf86.h" #include "xf86Priv.h" #include "xf86_os_support.h" diff --git a/hw/xfree86/os-support/solaris/sun_agp.c b/hw/xfree86/os-support/solaris/sun_agp.c index 0e5bdb1c5..8dd099b86 100644 --- a/hw/xfree86/os-support/solaris/sun_agp.c +++ b/hw/xfree86/os-support/solaris/sun_agp.c @@ -126,7 +126,7 @@ xf86GetAGPInfo(int screenNum) return NULL; } - if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) { + if ((info = calloc(1, sizeof(AgpInfo))) == NULL) { xf86DrvMsg(screenNum, X_ERROR, "xf86GetAGPInfo: Failed to allocate AgpInfo\n"); return NULL; diff --git a/hw/xfree86/os-support/solaris/sun_apm.c b/hw/xfree86/os-support/solaris/sun_apm.c index 24a743f17..cddc6b3cb 100644 --- a/hw/xfree86/os-support/solaris/sun_apm.c +++ b/hw/xfree86/os-support/solaris/sun_apm.c @@ -54,6 +54,7 @@ #endif #include <errno.h> +#include <sys/srn.h> #include <X11/X.h> #include "os.h" @@ -63,34 +64,11 @@ #include "xf86_OSproc.h" #include "xf86_OSlib.h" -#ifndef PLEASE_FIX_THIS -#define APM_STANDBY_REQ 0xa01 -#define APM_SUSPEND_REQ 0xa02 -#define APM_NORMAL_RESUME 0xa03 -#define APM_CRIT_RESUME 0xa04 -#define APM_BATTERY_LOW 0xa05 -#define APM_POWER_CHANGE 0xa06 -#define APM_UPDATE_TIME 0xa07 -#define APM_CRIT_SUSPEND_REQ 0xa08 -#define APM_USER_STANDBY_REQ 0xa09 -#define APM_USER_SUSPEND_REQ 0xa0a -#define APM_SYS_STANDBY_RESUME 0xa0b -#define APM_IOC_NEXTEVENT 0xa0c -#define APM_IOC_RESUME 0xa0d -#define APM_IOC_SUSPEND 0xa0e -#define APM_IOC_STANDBY 0xa0f -#endif - typedef struct apm_event_info { int type; } apm_event_info; -/* - This may be replaced with a better device name - very soon... -*/ #define APM_DEVICE "/dev/srn" -#define APM_DEVICE1 "/dev/apm" static void *APMihPtr = NULL; static void sunCloseAPM(void); @@ -99,20 +77,17 @@ static struct { u_int apmBsd; pmEvent xf86; } sunToXF86Array[] = { - {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, - {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, - {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, - {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, - {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, - {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, - {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, - {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, - {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, - {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, - {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, -#ifdef APM_CAPABILITY_CHANGE - {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, -#endif + {SRN_STANDBY_REQ, XF86_APM_SYS_STANDBY}, + {SRN_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, + {SRN_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, + {SRN_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, + {SRN_BATTERY_LOW, XF86_APM_LOW_BATTERY}, + {SRN_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, + {SRN_UPDATE_TIME, XF86_APM_UPDATE_TIME}, + {SRN_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, + {SRN_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, + {SRN_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, + {SRN_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, }; static pmEvent @@ -139,9 +114,9 @@ sunPMGetEventFromOS(int fd, pmEvent * events, int num) for (i = 0; i < num; i++) { - if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) { + if (ioctl(fd, SRN_IOC_NEXTEVENT, &sunEvent) < 0) { if (errno != EAGAIN) { - xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT" + xf86Msg(X_WARNING, "sunPMGetEventFromOS: SRN_IOC_NEXTEVENT" " %s\n", strerror(errno)); } break; @@ -159,7 +134,7 @@ sunPMConfirmEventToOs(int fd, pmEvent event) /* XXX: NOT CURRENTLY RETURNED FROM OS */ case XF86_APM_SYS_STANDBY: case XF86_APM_USER_STANDBY: - if (ioctl(fd, APM_IOC_STANDBY, NULL) == 0) + if (ioctl(fd, SRN_IOC_STANDBY, NULL) == 0) return PM_WAIT; /* should we stop the Xserver in standby, too? */ else return PM_NONE; @@ -167,10 +142,10 @@ sunPMConfirmEventToOs(int fd, pmEvent event) case XF86_APM_CRITICAL_SUSPEND: case XF86_APM_USER_SUSPEND: xf86Msg(X_WARNING, "Got SUSPENDED\n"); - if (ioctl(fd, APM_IOC_SUSPEND, NULL) == 0) + if (ioctl(fd, SRN_IOC_SUSPEND, NULL) == 0) return PM_CONTINUE; else { - xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND" + xf86Msg(X_WARNING, "sunPMConfirmEventToOs: SRN_IOC_SUSPEND" " %s\n", strerror(errno)); return PM_FAILED; } @@ -180,10 +155,10 @@ sunPMConfirmEventToOs(int fd, pmEvent event) case XF86_APM_STANDBY_FAILED: case XF86_APM_SUSPEND_FAILED: xf86Msg(X_WARNING, "Got RESUME\n"); - if (ioctl(fd, APM_IOC_RESUME, NULL) == 0) + if (ioctl(fd, SRN_IOC_RESUME, NULL) == 0) return PM_CONTINUE; else { - xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME" + xf86Msg(X_WARNING, "sunPMConfirmEventToOs: SRN_IOC_RESUME" " %s\n", strerror(errno)); return PM_FAILED; } @@ -202,9 +177,7 @@ xf86OSPMOpen(void) } if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { - if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) { - return NULL; - } + return NULL; } xf86PMGetEventFromOs = sunPMGetEventFromOS; xf86PMConfirmEventToOs = sunPMConfirmEventToOs; diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c index d08474516..e374ed826 100644 --- a/hw/xfree86/os-support/solaris/sun_bell.c +++ b/hw/xfree86/os-support/solaris/sun_bell.c @@ -29,7 +29,8 @@ #include <sys/uio.h> #include <limits.h> #include <math.h> -#include <xserver_poll.h> + +#include "os/xserver_poll.h" #include "xf86.h" #include "xf86Priv.h" diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index 7bdacb9e9..582d5a9d8 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -81,10 +81,9 @@ #include <stddef.h> /**************************************************************************/ -/* SYSV386 (SVR3, SVR4), including Solaris */ +/* Solaris or illumos-based system */ /**************************************************************************/ -#if (defined(SYSV) || defined(SVR4)) && \ - (defined(__sun) || defined(__i386__)) +#if defined(__SVR4) && defined(__sun) #include <sys/ioctl.h> #include <signal.h> #include <termio.h> @@ -92,43 +91,17 @@ #include <errno.h> -#if !defined(__sun) || defined(HAVE_SYS_VT_H) +#ifdef HAVE_SYS_VT_H #define HAS_USL_VTS #endif -#if !defined(__sun) -#include <sys/emap.h> -#endif -#if defined(HAS_USL_VTS) -#if !defined(__sun) -#include <sys/at_ansi.h> -#endif +#ifdef HAS_USL_VTS #include <sys/kd.h> #include <sys/vt.h> #endif -#if defined(__sun) -#include <sys/kbd.h> -#include <sys/kbio.h> - -/* undefine symbols from <sys/kbd.h> we don't need that conflict with enum - definitions in parser/xf86tokens.h */ -#undef STRING -#undef LEFTALT -#undef RIGHTALT -#endif /* __sun */ - -#if !defined(VT_ACKACQ) -#define VT_ACKACQ 2 -#endif /* !VT_ACKACQ */ - -#if defined(SVR4) -#if !(defined(__sun) && defined (SVR4)) -#define DEV_MEM "/dev/pmem" -#endif #define CLEARDTR_SUPPORT -#endif /* SVR4 */ -#endif /* (SYSV || SVR4) */ +#endif /* SVR4 && __sun */ /**************************************************************************/ /* Linux or Glibc-based system */ @@ -224,38 +197,9 @@ struct pcvtid { #include <sys/mouse.h> #endif /* Include these definitions in case ioctl_pc.h didn't get included */ -#ifndef CONSOLE_X_MODE_ON -#define CONSOLE_X_MODE_ON _IO('t',121) -#endif -#ifndef CONSOLE_X_MODE_OFF -#define CONSOLE_X_MODE_OFF _IO('t',122) -#endif #ifndef CONSOLE_X_BELL #define CONSOLE_X_BELL _IOW('t',123,int[2]) #endif -#ifndef CONSOLE_X_TV_ON -#define CONSOLE_X_TV_ON _IOW('t',155,int) -#define XMODE_RGB 0 -#define XMODE_NTSC 1 -#define XMODE_PAL 2 -#define XMODE_SECAM 3 -#endif -#ifndef CONSOLE_X_TV_OFF -#define CONSOLE_X_TV_OFF _IO('t',156) -#endif -#ifndef CONSOLE_GET_LINEAR_INFO -#define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info) -#endif -#ifndef CONSOLE_GET_IO_INFO -#define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info) -#endif -#ifndef CONSOLE_GET_MEM_INFO -#define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info) -#endif - -#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL) -#include <machine/sysarch.h> -#endif #define CLEARDTR_SUPPORT @@ -286,10 +230,6 @@ struct pcvtid { #include <limits.h> -#ifndef DEV_MEM -#define DEV_MEM "/dev/mem" -#endif - #ifndef MAP_FAILED #define MAP_FAILED ((void *)-1) #endif diff --git a/hw/xfree86/os-support/xf86_os_support.h b/hw/xfree86/os-support/xf86_os_support.h index a45716cf4..b9aebb0a2 100644 --- a/hw/xfree86/os-support/xf86_os_support.h +++ b/hw/xfree86/os-support/xf86_os_support.h @@ -11,6 +11,7 @@ #include <X11/Xdefs.h> #include "os.h" +#include "dix/dix_priv.h" /* * This is to prevent re-entrancy to FatalError() when aborting. @@ -52,6 +53,9 @@ void xf86OSInitVidMem(VidMemInfoPtr); #ifdef XSERVER_PLATFORM_BUS #include "hotplug.h" + +struct OdevAttributes; + void xf86PlatformDeviceProbe(struct OdevAttributes *attribs); diff --git a/hw/xfree86/parser/DRI.c b/hw/xfree86/parser/DRI.c index 31f447d05..933e69f30 100644 --- a/hw/xfree86/parser/DRI.c +++ b/hw/xfree86/parser/DRI.c @@ -77,6 +77,8 @@ xf86parseDRISection(void) break; case COMMENT: ptr->dri_comment = xf86addComment(ptr->dri_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; default: Error(INVALID_KEYWORD_MSG, xf86tokenString()); diff --git a/hw/xfree86/parser/Device.c b/hw/xfree86/parser/Device.c index 34b7f6557..ebc7178fb 100644 --- a/hw/xfree86/parser/Device.c +++ b/hw/xfree86/parser/Device.c @@ -75,7 +75,7 @@ static const xf86ConfigSymTabRec DeviceTab[] = { {VIDEORAM, "videoram"}, {BIOSBASE, "biosbase"}, {MEMBASE, "membase"}, - {IOBASE, "iobase"}, + {XF86_TOKEN_IOBASE, "iobase"}, {CLOCKCHIP, "clockchip"}, {CHIPID, "chipid"}, {CHIPREV, "chiprev"}, @@ -106,6 +106,8 @@ xf86parseDeviceSection(void) switch (token) { case COMMENT: ptr->dev_comment = xf86addComment(ptr->dev_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->dev_comment)) != STRING) @@ -179,7 +181,7 @@ xf86parseDeviceSection(void) Error(NUMBER_MSG, "MemBase"); ptr->dev_mem_base = xf86_lex_val.num; break; - case IOBASE: + case XF86_TOKEN_IOBASE: if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER) Error(NUMBER_MSG, "IOBase"); ptr->dev_io_base = xf86_lex_val.num; diff --git a/hw/xfree86/parser/Extensions.c b/hw/xfree86/parser/Extensions.c index 3a2195901..206c512ef 100644 --- a/hw/xfree86/parser/Extensions.c +++ b/hw/xfree86/parser/Extensions.c @@ -67,6 +67,8 @@ xf86parseExtensionsSection(void) case COMMENT: ptr->extensions_comment = xf86addComment(ptr->extensions_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; default: Error(INVALID_KEYWORD_MSG, xf86tokenString()); diff --git a/hw/xfree86/parser/Files.c b/hw/xfree86/parser/Files.c index c86ac7af2..fba99a864 100644 --- a/hw/xfree86/parser/Files.c +++ b/hw/xfree86/parser/Files.c @@ -89,6 +89,8 @@ xf86parseFilesSection(void) switch (token) { case COMMENT: ptr->file_comment = xf86addComment(ptr->file_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case FONTPATH: if (xf86getSubToken(&(ptr->file_comment)) != STRING) diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c index d677cf1db..7d35bb7ea 100644 --- a/hw/xfree86/parser/Flags.c +++ b/hw/xfree86/parser/Flags.c @@ -98,6 +98,8 @@ xf86parseFlagsSection(void) switch (token) { case COMMENT: ptr->flg_comment = xf86addComment(ptr->flg_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; /* * these old keywords are turned into standard generic options. @@ -436,18 +438,24 @@ xf86parseOption(XF86OptionPtr head) if ((token = xf86getSubToken(&comment)) == STRING) { option = xf86newOption(name, xf86_lex_val.str); option->opt_comment = comment; - if ((token = xf86getToken(NULL)) == COMMENT) + if ((token = xf86getToken(NULL)) == COMMENT) { option->opt_comment = xf86addComment(option->opt_comment, xf86_lex_val.str); - else + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; + } else { xf86unGetToken(token); + } } else { option = xf86newOption(name, NULL); option->opt_comment = comment; - if (token == COMMENT) + if (token == COMMENT) { option->opt_comment = xf86addComment(option->opt_comment, xf86_lex_val.str); - else + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; + } else { xf86unGetToken(token); + } } old = NULL; diff --git a/hw/xfree86/parser/Input.c b/hw/xfree86/parser/Input.c index 88d19b6b5..6b286ec74 100644 --- a/hw/xfree86/parser/Input.c +++ b/hw/xfree86/parser/Input.c @@ -84,6 +84,8 @@ xf86parseInputSection(void) switch (token) { case COMMENT: ptr->inp_comment = xf86addComment(ptr->inp_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->inp_comment)) != STRING) diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c index 7281659e0..8b9510c0b 100644 --- a/hw/xfree86/parser/InputClass.c +++ b/hw/xfree86/parser/InputClass.c @@ -191,6 +191,8 @@ xf86parseInputClassSection(void) switch (token) { case COMMENT: ptr->comment = xf86addComment(ptr->comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->comment)) != STRING) diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c index 2c829f4ee..532f318f3 100644 --- a/hw/xfree86/parser/Layout.c +++ b/hw/xfree86/parser/Layout.c @@ -101,6 +101,8 @@ xf86parseLayoutSection(void) switch (token) { case COMMENT: ptr->lay_comment = xf86addComment(ptr->lay_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->lay_comment)) != STRING) diff --git a/hw/xfree86/parser/Module.c b/hw/xfree86/parser/Module.c index 38bf777ed..9a166aff2 100644 --- a/hw/xfree86/parser/Module.c +++ b/hw/xfree86/parser/Module.c @@ -95,6 +95,8 @@ xf86parseModuleSubSection(XF86LoadPtr head, char *name) switch (token) { case COMMENT: ptr->load_comment = xf86addComment(ptr->load_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case OPTION: ptr->load_opt = xf86parseOption(ptr->load_opt); @@ -126,6 +128,8 @@ xf86parseModuleSection(void) switch (token) { case COMMENT: ptr->mod_comment = xf86addComment(ptr->mod_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case LOAD: if (xf86getSubToken(&(ptr->mod_comment)) != STRING) @@ -230,10 +234,13 @@ xf86addNewLoadDirective(XF86LoadPtr head, const char *name, int type, new->ignore = 0; new->list.next = NULL; - if ((token = xf86getToken(NULL)) == COMMENT) + if ((token = xf86getToken(NULL)) == COMMENT) { new->load_comment = xf86addComment(new->load_comment, xf86_lex_val.str); - else + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; + } else { xf86unGetToken(token); + } return ((XF86LoadPtr) xf86addListItem((glp) head, (glp) new)); } diff --git a/hw/xfree86/parser/Monitor.c b/hw/xfree86/parser/Monitor.c index 1d63a441c..056b9f4c0 100644 --- a/hw/xfree86/parser/Monitor.c +++ b/hw/xfree86/parser/Monitor.c @@ -269,6 +269,8 @@ xf86parseVerboseMode(void) switch (token) { case COMMENT: ptr->ml_comment = xf86addComment(ptr->ml_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case DOTCLOCK: if ((token = xf86getSubToken(&(ptr->ml_comment))) != NUMBER) @@ -413,6 +415,8 @@ xf86parseMonitorSection(void) switch (token) { case COMMENT: ptr->mon_comment = xf86addComment(ptr->mon_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->mon_comment)) != STRING) @@ -599,6 +603,8 @@ xf86parseModesSection(void) switch (token) { case COMMENT: ptr->modes_comment = xf86addComment(ptr->modes_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->modes_comment)) != STRING) diff --git a/hw/xfree86/parser/OutputClass.c b/hw/xfree86/parser/OutputClass.c index 01b348fdd..4c5340a03 100644 --- a/hw/xfree86/parser/OutputClass.c +++ b/hw/xfree86/parser/OutputClass.c @@ -102,6 +102,8 @@ xf86parseOutputClassSection(void) switch (token) { case COMMENT: ptr->comment = xf86addComment(ptr->comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->comment)) != STRING) diff --git a/hw/xfree86/parser/Pointer.c b/hw/xfree86/parser/Pointer.c index ff63deb31..85f7b46d5 100644 --- a/hw/xfree86/parser/Pointer.c +++ b/hw/xfree86/parser/Pointer.c @@ -104,6 +104,8 @@ xf86parsePointerSection(void) switch (token) { case COMMENT: ptr->inp_comment = xf86addComment(ptr->inp_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case PROTOCOL: if (xf86getSubToken(&(ptr->inp_comment)) != STRING) diff --git a/hw/xfree86/parser/Screen.c b/hw/xfree86/parser/Screen.c index a831c30cd..28cd03b68 100644 --- a/hw/xfree86/parser/Screen.c +++ b/hw/xfree86/parser/Screen.c @@ -119,6 +119,8 @@ xf86parseDisplaySubSection(void) switch (token) { case COMMENT: ptr->disp_comment = xf86addComment(ptr->disp_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case VIEWPORT: if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER) @@ -256,6 +258,8 @@ xf86parseScreenSection(void) switch (token) { case COMMENT: ptr->scrn_comment = xf86addComment(ptr->scrn_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->scrn_comment)) != STRING) diff --git a/hw/xfree86/parser/Vendor.c b/hw/xfree86/parser/Vendor.c index 50ea68956..456ce8fd0 100644 --- a/hw/xfree86/parser/Vendor.c +++ b/hw/xfree86/parser/Vendor.c @@ -98,6 +98,8 @@ xf86parseVendorSubSection(void) switch (token) { case COMMENT: ptr->vs_comment = xf86addComment(ptr->vs_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->vs_comment))) @@ -151,6 +153,8 @@ xf86parseVendorSection(void) switch (token) { case COMMENT: ptr->vnd_comment = xf86addComment(ptr->vnd_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->vnd_comment)) != STRING) diff --git a/hw/xfree86/parser/Video.c b/hw/xfree86/parser/Video.c index 4e8526f3f..108c8f3ad 100644 --- a/hw/xfree86/parser/Video.c +++ b/hw/xfree86/parser/Video.c @@ -97,6 +97,8 @@ xf86parseVideoPortSubSection(void) switch (token) { case COMMENT: ptr->vp_comment = xf86addComment(ptr->vp_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->vp_comment)) != STRING) @@ -154,6 +156,8 @@ xf86parseVideoAdaptorSection(void) switch (token) { case COMMENT: ptr->va_comment = xf86addComment(ptr->va_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case IDENTIFIER: if (xf86getSubToken(&(ptr->va_comment)) != STRING) diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h index 7a46e0160..39399b7bc 100644 --- a/hw/xfree86/parser/configProcs.h +++ b/hw/xfree86/parser/configProcs.h @@ -29,6 +29,8 @@ /* exported functions are/were used by the X Server */ +#include <X11/Xfuncproto.h> + /* Device.c */ XF86ConfDevicePtr xf86parseDeviceSection(void); void xf86printDeviceSection(FILE * cf, XF86ConfDevicePtr ptr); diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c index d7e731217..a4600bc06 100644 --- a/hw/xfree86/parser/read.c +++ b/hw/xfree86/parser/read.c @@ -100,6 +100,8 @@ xf86readConfigFile(void) switch (token) { case COMMENT: ptr->conf_comment = xf86addComment(ptr->conf_comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; break; case SECTION: if (xf86getSubToken(&(ptr->conf_comment)) != STRING) { diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c index 1eb35ed73..bf5a8d13b 100644 --- a/hw/xfree86/parser/scan.c +++ b/hw/xfree86/parser/scan.c @@ -332,18 +332,18 @@ xf86getToken(const xf86ConfigSymTabRec * tab) } while ((c != '\n') && (c != '\r') && (c != '\0')); configRBuf[i] = '\0'; - /* XXX no private copy. + /* XXX private copy. * Use xf86addComment when setting a comment. */ - xf86_lex_val.str = configRBuf; + xf86_lex_val.str = strdup(configRBuf); return COMMENT; } /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */ - else if ((c == ',') && !isalpha(configBuf[configPos])) { + else if ((c == ',') && !isalpha((unsigned char)configBuf[configPos])) { return COMMA; } - else if ((c == '-') && !isalpha(configBuf[configPos])) { + else if ((c == '-') && !isalpha((unsigned char)configBuf[configPos])) { return DASH; } @@ -448,8 +448,11 @@ xf86getSubToken(char **comment) for (;;) { token = xf86getToken(NULL); if (token == COMMENT) { - if (comment) + if (comment) { *comment = xf86addComment(*comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; + } } else return token; @@ -464,8 +467,11 @@ xf86getSubTokenWithTab(char **comment, const xf86ConfigSymTabRec * tab) for (;;) { token = xf86getToken(tab); if (token == COMMENT) { - if (comment) + if (comment) { *comment = xf86addComment(*comment, xf86_lex_val.str); + free(xf86_lex_val.str); + xf86_lex_val.str = NULL; + } } else return token; @@ -1028,8 +1034,8 @@ xf86nameCompare(const char *s1, const char *s2) s1++; while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') s2++; - c1 = (isupper(*s1) ? tolower(*s1) : *s1); - c2 = (isupper(*s2) ? tolower(*s2) : *s2); + c1 = (isupper((unsigned char)*s1) ? tolower((unsigned char)*s1) : *s1); + c2 = (isupper((unsigned char)*s2) ? tolower((unsigned char)*s2) : *s2); while (c1 == c2) { if (c1 == '\0') return 0; @@ -1039,8 +1045,8 @@ xf86nameCompare(const char *s1, const char *s2) s1++; while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') s2++; - c1 = (isupper(*s1) ? tolower(*s1) : *s1); - c2 = (isupper(*s2) ? tolower(*s2) : *s2); + c1 = (isupper((unsigned char)*s1) ? tolower((unsigned char)*s1) : *s1); + c2 = (isupper((unsigned char)*s2) ? tolower((unsigned char)*s2) : *s2); } return c1 - c2; } diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h index 4abff0d79..75b9e1f8f 100644 --- a/hw/xfree86/parser/xf86tokens.h +++ b/hw/xfree86/parser/xf86tokens.h @@ -59,9 +59,6 @@ #ifndef _xf86_tokens_h #define _xf86_tokens_h -/* Undefine symbols that some OSs might define */ -#undef IOBASE - /* * Each token should have a unique value regardless of the section * it is used in. @@ -91,11 +88,6 @@ typedef enum { OPTION, COMMENT, - /* Frequency units */ - HRZ, - KHZ, - MHZ, - /* File tokens */ FONTPATH, MODULEPATH, @@ -126,9 +118,6 @@ typedef enum { GAMMA, USEMODES, - /* Modes tokens */ - /* no new ones */ - /* Mode tokens */ DOTCLOCK, HTIMINGS, @@ -177,7 +166,7 @@ typedef enum { CLOCKS, VIDEORAM, BOARD, - IOBASE, + XF86_TOKEN_IOBASE, RAMDAC, DACSPEED, BIOSBASE, @@ -189,37 +178,6 @@ typedef enum { BUSID, IRQ, - /* Keyboard tokens */ - AUTOREPEAT, - XLEDS, - KPROTOCOL, - XKBKEYMAP, - XKBCOMPAT, - XKBTYPES, - XKBKEYCODES, - XKBGEOMETRY, - XKBSYMBOLS, - XKBDISABLE, - PANIX106, - XKBRULES, - XKBMODEL, - XKBLAYOUT, - XKBVARIANT, - XKBOPTIONS, - /* Obsolete keyboard tokens */ - SERVERNUM, - LEFTALT, - RIGHTALT, - SCROLLLOCK_TOK, - RIGHTCTL, - /* arguments for the above obsolete tokens */ - CONF_KM_META, - CONF_KM_COMPOSE, - CONF_KM_MODESHIFT, - CONF_KM_MODELOCK, - CONF_KM_SCROLLLOCK, - CONF_KM_CONTROL, - /* Pointer tokens */ EMULATE3, BAUDRATE, diff --git a/hw/xfree86/ramdac/xf86CursorRD.c b/hw/xfree86/ramdac/xf86CursorRD.c index d423ad204..f6d883f3b 100644 --- a/hw/xfree86/ramdac/xf86CursorRD.c +++ b/hw/xfree86/ramdac/xf86CursorRD.c @@ -3,6 +3,9 @@ #include <xorg-config.h> #endif +#include "dix/cursor_priv.h" +#include "mi/mipointer_priv.h" + #include "xf86.h" #include "xf86CursorPriv.h" #include "colormapst.h" diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c index eba503d51..4ccd55eaa 100644 --- a/hw/xfree86/ramdac/xf86HWCurs.c +++ b/hw/xfree86/ramdac/xf86HWCurs.c @@ -4,12 +4,13 @@ #endif #include <string.h> +#include <X11/X.h> + +#include "dix/colormap_priv.h" #include "misc.h" #include "xf86.h" #include "xf86_OSproc.h" - -#include <X11/X.h> #include "scrnintstr.h" #include "pixmapstr.h" #include "windowstr.h" @@ -19,7 +20,6 @@ #include "mipointer.h" #include "randrstr.h" #include "xf86CursorPriv.h" - #include "servermd.h" static void diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh index c3ed36401..4747846f5 100755 --- a/hw/xfree86/sdksyms.sh +++ b/hw/xfree86/sdksyms.sh @@ -222,7 +222,6 @@ cat > sdksyms.c << EOF /* include/Makefile.am */ -#include "XIstubs.h" #include "Xprintf.h" #include "closure.h" #include "colormap.h" @@ -237,7 +236,6 @@ cat > sdksyms.c << EOF #define _FONTPROTO_H #include "dixfont.h" #include "dixfontstr.h" -#include "dixgrabs.h" #include "dixstruct.h" #include "exevents.h" #include "extension.h" @@ -273,7 +271,6 @@ cat > sdksyms.c << EOF #include "window.h" #include "windowstr.h" #include "xace.h" -#include "xkbfile.h" #include "xkbsrv.h" #include "xkbstr.h" #include "xkbrules.h" diff --git a/hw/xfree86/shadowfb/sfbmodule.c b/hw/xfree86/shadowfb/sfbmodule.c index c20efc071..4c770a7fd 100644 --- a/hw/xfree86/shadowfb/sfbmodule.c +++ b/hw/xfree86/shadowfb/sfbmodule.c @@ -5,16 +5,18 @@ #include "xf86Module.h" static XF86ModuleVersionInfo VersRec = { - "shadowfb", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 1, 0, 0, - ABI_CLASS_ANSIC, /* Only need the ansic layer */ - ABI_ANSIC_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} /* signature, to be patched into the file by a tool */ + .modname = "shadowfb", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 1, + .minorversion = 0, + .patchlevel = 0, + .abiclass = ABI_CLASS_ANSIC, + .abiversion = ABI_ANSIC_VERSION, }; -_X_EXPORT XF86ModuleData shadowfbModuleData = { &VersRec, NULL, NULL }; +_X_EXPORT XF86ModuleData shadowfbModuleData = { + .vers = &VersRec +}; diff --git a/hw/xfree86/utils/man/gtf.man b/hw/xfree86/utils/man/gtf.man index 95bddbbcf..336dfac08 100644 --- a/hw/xfree86/utils/man/gtf.man +++ b/hw/xfree86/utils/man/gtf.man @@ -15,9 +15,9 @@ is a utility for calculating VESA GTF modes. Given the desired horizontal and vertical resolutions and refresh rate (in Hz), the parameters for a matching VESA GTF mode are printed out. Two output formats are supported: mode lines suitable for the Xorg -.B xorg.conf(@filemansuffix@) +.BR xorg.conf (@filemansuffix@) file, and mode parameters suitable for the Linux -.B fbset(8) +.BR fbset (8) utility. .SH OPTIONS @@ -32,9 +32,10 @@ default format. .TP 8 .BR \-f | \-\-fbset Print the mode parameters in a format suitable for -.BR fbset(8) . +.BR fbset (8). .SH "SEE ALSO" -xorg.conf(@filemansuffix@), cvt(@appmansuffix@) +.BR xorg.conf (@filemansuffix@), +.BR cvt (@appmansuffix@) .SH AUTHOR Andy Ritger. .PP diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c index 00e30e8c9..215bc93f9 100644 --- a/hw/xfree86/vgahw/vgaHW.c +++ b/hw/xfree86/vgahw/vgaHW.c @@ -600,12 +600,6 @@ vgaHWProtect(ScrnInfoPtr pScrn, Bool on) } } -vgaHWProtectProc * -vgaHWProtectWeak(void) -{ - return vgaHWProtect; -} - /* * vgaHWBlankScreen -- blank the screen. */ @@ -630,12 +624,6 @@ vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on) vgaHWSeqReset(hwp, FALSE); } -vgaHWBlankScreenProc * -vgaHWBlankScreenWeak(void) -{ - return vgaHWBlankScreen; -} - /* * vgaHWSaveScreen -- blank the screen. */ @@ -837,7 +825,7 @@ vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore) #endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */ } -void +static void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore) { vgaHWPtr hwp = VGAHWPTR(scrninfp); @@ -868,7 +856,7 @@ vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore) hwp->disablePalette(hwp); } -void +static void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore) { vgaHWPtr hwp = VGAHWPTR(scrninfp); @@ -1008,7 +996,7 @@ vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save) #endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */ } -void +static void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save) { vgaHWPtr hwp = VGAHWPTR(scrninfp); @@ -1043,7 +1031,7 @@ vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save) } } -void +static void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save) { vgaHWPtr hwp = VGAHWPTR(scrninfp); @@ -1524,75 +1512,6 @@ vgaHWAllocDefaultRegs(vgaRegPtr regp) } Bool -vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer, - int numGraphics, int numAttribute) -{ -#define VGAHWMINNUM(regtype) \ - ((newMode.num##regtype < regp->num##regtype) ? \ - (newMode.num##regtype) : (regp->num##regtype)) -#define VGAHWCOPYREGSET(regtype) \ - memcpy (newMode.regtype, regp->regtype, VGAHWMINNUM(regtype)) - - vgaRegRec newMode, newSaved; - vgaRegPtr regp; - - regp = &VGAHWPTR(scrp)->ModeReg; - memcpy(&newMode, regp, sizeof(vgaRegRec)); - - /* allocate space for new registers */ - - regp = &newMode; - regp->numCRTC = numCRTC; - regp->numSequencer = numSequencer; - regp->numGraphics = numGraphics; - regp->numAttribute = numAttribute; - if (!vgaHWAllocRegs(regp)) - return FALSE; - - regp = &VGAHWPTR(scrp)->SavedReg; - memcpy(&newSaved, regp, sizeof(vgaRegRec)); - - regp = &newSaved; - regp->numCRTC = numCRTC; - regp->numSequencer = numSequencer; - regp->numGraphics = numGraphics; - regp->numAttribute = numAttribute; - if (!vgaHWAllocRegs(regp)) { - vgaHWFreeRegs(&newMode); - return FALSE; - } - - /* allocations succeeded, copy register data into new space */ - - regp = &VGAHWPTR(scrp)->ModeReg; - VGAHWCOPYREGSET(CRTC); - VGAHWCOPYREGSET(Sequencer); - VGAHWCOPYREGSET(Graphics); - VGAHWCOPYREGSET(Attribute); - - regp = &VGAHWPTR(scrp)->SavedReg; - VGAHWCOPYREGSET(CRTC); - VGAHWCOPYREGSET(Sequencer); - VGAHWCOPYREGSET(Graphics); - VGAHWCOPYREGSET(Attribute); - - /* free old register arrays */ - - regp = &VGAHWPTR(scrp)->ModeReg; - vgaHWFreeRegs(regp); - memcpy(regp, &newMode, sizeof(vgaRegRec)); - - regp = &VGAHWPTR(scrp)->SavedReg; - vgaHWFreeRegs(regp); - memcpy(regp, &newSaved, sizeof(vgaRegRec)); - - return TRUE; - -#undef VGAHWMINNUM -#undef VGAHWCOPYREGSET -} - -Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src) { vgaHWFreeRegs(dst); @@ -1627,7 +1546,7 @@ vgaHWGetHWRec(ScrnInfoPtr scrp) */ if (VGAHWPTR(scrp)) return TRUE; - hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1); + hwp = VGAHWPTRLVAL(scrp) = XNFcallocarray(1, sizeof(vgaHWRec)); regp = &VGAHWPTR(scrp)->ModeReg; if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) || @@ -1809,12 +1728,6 @@ vgaHWEnable(vgaHWPtr hwp) hwp->writeEnable(hwp, hwp->readEnable(hwp) | 0x01); } -void -vgaHWDisable(vgaHWPtr hwp) -{ - hwp->writeEnable(hwp, hwp->readEnable(hwp) & ~0x01); -} - static void vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO * colors, VisualPtr pVisual) @@ -1921,7 +1834,7 @@ vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed) if (hwp->ddc != NULL) break; - hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave), 1); + hwp->ddc = XNFcallocarray(1, sizeof(struct _vgaDdcSave)); save = (struct _vgaDdcSave *) hwp->ddc; /* Lightpen register disable - allow access to cr10 & 11; just in case */ save->cr03 = hwp->readCrtc(hwp, 0x03); @@ -1977,12 +1890,6 @@ vgaHWddc1SetSpeedWeak(void) return vgaHWddc1SetSpeed; } -SaveScreenProcPtr -vgaHWSaveScreenWeak(void) -{ - return vgaHWSaveScreen; -} - /* * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ... */ diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h index 0fa80da45..a7d7a500a 100644 --- a/hw/xfree86/vgahw/vgaHW.h +++ b/hw/xfree86/vgahw/vgaHW.h @@ -177,34 +177,20 @@ typedef struct _vgaHWRec { /* Function Prototypes */ /* vgaHW.c */ - -typedef void vgaHWProtectProc(ScrnInfoPtr, Bool); -typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool); - extern _X_EXPORT void vgaHWSetStdFuncs(vgaHWPtr hwp); extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset); extern _X_EXPORT void vgaHWProtect(ScrnInfoPtr pScrn, Bool on); -extern _X_EXPORT vgaHWProtectProc *vgaHWProtectWeak(void); extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode); extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on); -extern _X_EXPORT vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void); extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start); extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore); -extern _X_EXPORT void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore); -extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, - vgaRegPtr restore); extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags); extern _X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save); -extern _X_EXPORT void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save); -extern _X_EXPORT void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save); extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags); extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode); -extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, - int numSequencer, int numGraphics, - int numAttribute); extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src); extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp); extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp); @@ -214,7 +200,6 @@ extern _X_EXPORT void vgaHWGetIOBase(vgaHWPtr hwp); extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp); extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp); extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp); -extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp); extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen); @@ -226,7 +211,6 @@ extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp); extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void); -extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void); extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc) (ScrnInfoPtr, int), void (*ProtectRegs) (ScrnInfoPtr, Bool), diff --git a/hw/xfree86/vgahw/vgaHWmodule.c b/hw/xfree86/vgahw/vgaHWmodule.c index 0c5a43aa6..5559e3741 100644 --- a/hw/xfree86/vgahw/vgaHWmodule.c +++ b/hw/xfree86/vgahw/vgaHWmodule.c @@ -9,16 +9,18 @@ #include "xf86Module.h" static XF86ModuleVersionInfo VersRec = { - "vgahw", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 0, 1, 0, - ABI_CLASS_VIDEODRV, - ABI_VIDEODRV_VERSION, - MOD_CLASS_NONE, - {0, 0, 0, 0} + .modname = "vgahw", + .vendor = MODULEVENDORSTRING, + ._modinfo1_ = MODINFOSTRING1, + ._modinfo2_ = MODINFOSTRING2, + .xf86version = XORG_VERSION_CURRENT, + .majorversion = 0, + .minorversion = 1, + .patchlevel = 0, + .abiclass = ABI_CLASS_VIDEODRV, + .abiversion = ABI_VIDEODRV_VERSION, }; -_X_EXPORT XF86ModuleData vgahwModuleData = { &VersRec, NULL, NULL }; +_X_EXPORT XF86ModuleData vgahwModuleData = { + .vers = &VersRec +}; diff --git a/hw/xfree86/x86emu/decode.c b/hw/xfree86/x86emu/decode.c index 261d67b21..6e4013ecc 100644 --- a/hw/xfree86/x86emu/decode.c +++ b/hw/xfree86/x86emu/decode.c @@ -39,15 +39,6 @@ #include <stdlib.h> -#if defined(__sun) && defined(CS) /* avoid conflicts with Solaris sys/regset.h */ -# undef CS -# undef DS -# undef SS -# undef ES -# undef FS -# undef GS -#endif - #include "x86emu/x86emui.h" /*----------------------------- Implementation ----------------------------*/ diff --git a/hw/xfree86/x86emu/x86emu/regs.h b/hw/xfree86/x86emu/x86emu/regs.h index edf9be324..7c649755e 100644 --- a/hw/xfree86/x86emu/x86emu/regs.h +++ b/hw/xfree86/x86emu/x86emu/regs.h @@ -114,17 +114,8 @@ struct i386_special_regs { * CS, DS, ES, SS. */ -#if defined(__sun) && defined(CS) /* avoid conflicts with Solaris sys/regset.h */ -# undef CS -# undef DS -# undef SS -# undef ES -# undef FS -# undef GS -#endif - struct i386_segment_regs { - u16 CS, DS, SS, ES, FS, GS; + u16 reg_cs, reg_ds, reg_ss, reg_es, reg_fs, reg_gs; }; /* 8 bit registers */ @@ -166,12 +157,12 @@ struct i386_segment_regs { #define R_EFLG spc.FLAGS /* segment registers */ -#define R_CS seg.CS -#define R_DS seg.DS -#define R_SS seg.SS -#define R_ES seg.ES -#define R_FS seg.FS -#define R_GS seg.GS +#define R_CS seg.reg_cs +#define R_DS seg.reg_ds +#define R_SS seg.reg_ss +#define R_ES seg.reg_es +#define R_FS seg.reg_fs +#define R_GS seg.reg_gs /* flag conditions */ #define FB_CF 0x0001 /* CARRY flag */ diff --git a/hw/xfree86/x86emu/x86emu/x86emui.h b/hw/xfree86/x86emu/x86emu/x86emui.h index aa2074a87..1d1decc4c 100644 --- a/hw/xfree86/x86emu/x86emu/x86emui.h +++ b/hw/xfree86/x86emu/x86emu/x86emui.h @@ -73,15 +73,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -/* avoid conflicts with Solaris sys/regset.h */ -# if defined(__sun) && defined(CS) -# undef CS -# undef DS -# undef SS -# undef ES -# undef FS -# undef GS -# endif #endif /* NO_SYS_HEADERS */ /*--------------------------- Inline Functions ----------------------------*/ diff --git a/hw/xfree86/xkb/xkbKillSrv.c b/hw/xfree86/xkb/xkbKillSrv.c index 79cf08198..d03674a94 100644 --- a/hw/xfree86/xkb/xkbKillSrv.c +++ b/hw/xfree86/xkb/xkbKillSrv.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef HAVE_XORG_CONFIG_H #include <xorg-config.h> diff --git a/hw/xfree86/xkb/xkbPrivate.c b/hw/xfree86/xkb/xkbPrivate.c index 506b60bb0..779fda187 100644 --- a/hw/xfree86/xkb/xkbPrivate.c +++ b/hw/xfree86/xkb/xkbPrivate.c @@ -1,7 +1,5 @@ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef HAVE_XORG_CONFIG_H #include <xorg-config.h> @@ -12,7 +10,6 @@ #include "windowstr.h" #include <xkbsrv.h> -#include "dixgrabs.h" #include "os.h" #include "xf86.h" diff --git a/hw/xfree86/xkb/xkbVT.c b/hw/xfree86/xkb/xkbVT.c index 984096122..463ff2362 100644 --- a/hw/xfree86/xkb/xkbVT.c +++ b/hw/xfree86/xkb/xkbVT.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef HAVE_XORG_CONFIG_H #include <xorg-config.h> diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c index adea553d6..aa87558f3 100644 --- a/hw/xnest/Args.c +++ b/hw/xnest/Args.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> @@ -27,6 +24,7 @@ is" without express or implied warranty. #include "misc.h" #include "scrnintstr.h" #include "servermd.h" +#include "extinit.h" #include "Xnest.h" @@ -34,28 +32,41 @@ is" without express or implied warranty. #include "Args.h" char *xnestDisplayName = NULL; -Bool xnestSynchronize = False; -Bool xnestFullGeneration = False; +Bool xnestSynchronize = FALSE; +Bool xnestFullGeneration = FALSE; int xnestDefaultClass; -Bool xnestUserDefaultClass = False; +Bool xnestUserDefaultClass = FALSE; int xnestDefaultDepth; -Bool xnestUserDefaultDepth = False; -Bool xnestSoftwareScreenSaver = False; +Bool xnestUserDefaultDepth = FALSE; +Bool xnestSoftwareScreenSaver = FALSE; int xnestX; int xnestY; unsigned int xnestWidth; unsigned int xnestHeight; int xnestUserGeometry = 0; int xnestBorderWidth; -Bool xnestUserBorderWidth = False; +Bool xnestUserBorderWidth = FALSE; char *xnestWindowName = NULL; int xnestNumScreens = 0; -Bool xnestDoDirectColormaps = False; +Bool xnestDoDirectColormaps = FALSE; Window xnestParentWindow = 0; int ddxProcessArgument(int argc, char *argv[], int i) { + /* disable some extensions we currently don't support yet */ +#ifdef MITSHM + noMITShmExtension = TRUE; +#endif + +#ifdef COMPOSITE + noCompositeExtension = TRUE; +#endif + +#ifdef DPMSExtension + noDPMSExtension = TRUE; +#endif + if (!strcmp(argv[i], "-display")) { if (++i < argc) { xnestDisplayName = argv[i]; @@ -64,43 +75,43 @@ ddxProcessArgument(int argc, char *argv[], int i) return 0; } if (!strcmp(argv[i], "-sync")) { - xnestSynchronize = True; + xnestSynchronize = TRUE; return 1; } if (!strcmp(argv[i], "-full")) { - xnestFullGeneration = True; + xnestFullGeneration = TRUE; return 1; } if (!strcmp(argv[i], "-class")) { if (++i < argc) { if (!strcmp(argv[i], "StaticGray")) { xnestDefaultClass = StaticGray; - xnestUserDefaultClass = True; + xnestUserDefaultClass = TRUE; return 2; } else if (!strcmp(argv[i], "GrayScale")) { xnestDefaultClass = GrayScale; - xnestUserDefaultClass = True; + xnestUserDefaultClass = TRUE; return 2; } else if (!strcmp(argv[i], "StaticColor")) { xnestDefaultClass = StaticColor; - xnestUserDefaultClass = True; + xnestUserDefaultClass = TRUE; return 2; } else if (!strcmp(argv[i], "PseudoColor")) { xnestDefaultClass = PseudoColor; - xnestUserDefaultClass = True; + xnestUserDefaultClass = TRUE; return 2; } else if (!strcmp(argv[i], "TrueColor")) { xnestDefaultClass = TrueColor; - xnestUserDefaultClass = True; + xnestUserDefaultClass = TRUE; return 2; } else if (!strcmp(argv[i], "DirectColor")) { xnestDefaultClass = DirectColor; - xnestUserDefaultClass = True; + xnestUserDefaultClass = TRUE; return 2; } } @@ -109,7 +120,7 @@ ddxProcessArgument(int argc, char *argv[], int i) if (!strcmp(argv[i], "-cc")) { if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) { if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) { - xnestUserDefaultClass = True; + xnestUserDefaultClass = TRUE; /* lex the OS layer process it as well, so return 0 */ } } @@ -118,14 +129,14 @@ ddxProcessArgument(int argc, char *argv[], int i) if (!strcmp(argv[i], "-depth")) { if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) { if (xnestDefaultDepth > 0) { - xnestUserDefaultDepth = True; + xnestUserDefaultDepth = TRUE; return 2; } } return 0; } if (!strcmp(argv[i], "-sss")) { - xnestSoftwareScreenSaver = True; + xnestSoftwareScreenSaver = TRUE; return 1; } if (!strcmp(argv[i], "-geometry")) { @@ -141,7 +152,7 @@ ddxProcessArgument(int argc, char *argv[], int i) if (!strcmp(argv[i], "-bw")) { if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) { if (xnestBorderWidth >= 0) { - xnestUserBorderWidth = True; + xnestUserBorderWidth = TRUE; return 2; } } @@ -167,7 +178,7 @@ ddxProcessArgument(int argc, char *argv[], int i) return 0; } if (!strcmp(argv[i], "-install")) { - xnestDoDirectColormaps = True; + xnestDoDirectColormaps = TRUE; return 1; } if (!strcmp(argv[i], "-parent")) { diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c index bb829847e..b8460b974 100644 --- a/hw/xnest/Color.c +++ b/hw/xnest/Color.c @@ -11,15 +11,14 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> #include <X11/Xproto.h> +#include "dix/colormap_priv.h" + #include "scrnintstr.h" #include "window.h" #include "windowstr.h" @@ -126,7 +125,7 @@ xnestCreateColormap(ColormapPtr pCmap) break; } - return True; + return TRUE; } void @@ -175,19 +174,19 @@ static Bool xnestSameInstalledColormapWindows(Window *windows, int numWindows) { if (xnestNumOldInstalledColormapWindows != numWindows) - return False; + return FALSE; if (xnestOldInstalledColormapWindows == windows) - return True; + return TRUE; if (xnestOldInstalledColormapWindows == NULL || windows == NULL) - return False; + return FALSE; if (memcmp(xnestOldInstalledColormapWindows, windows, numWindows * sizeof(Window))) - return False; + return FALSE; - return True; + return TRUE; } void @@ -372,7 +371,7 @@ xnestUninstallColormap(ColormapPtr pCmap) } } -static Bool xnestInstalledDefaultColormap = False; +static Bool xnestInstalledDefaultColormap = FALSE; int xnestListInstalledColormaps(ScreenPtr pScreen, Colormap * pCmapIDs) @@ -474,7 +473,7 @@ xnestCreateDefaultColormap(ScreenPtr pScreen) (pVisual->class & DynamicClass) ? AllocNone : AllocAll, 0) != Success) - return False; + return FALSE; wp = pScreen->whitePixel; bp = pScreen->blackPixel; @@ -486,7 +485,7 @@ xnestCreateDefaultColormap(ScreenPtr pScreen) pScreen->blackPixel = bp; (*pScreen->InstallColormap) (pCmap); - xnestInstalledDefaultColormap = True; + xnestInstalledDefaultColormap = TRUE; - return True; + return TRUE; } diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index fea5a959b..89f508709 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> @@ -99,7 +96,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) bg_color.green = pCursor->backGreen; bg_color.blue = pCursor->backBlue; - xnestSetCursorPriv(pCursor, pScreen, malloc(sizeof(xnestPrivCursor))); + xnestSetCursorPriv(pCursor, pScreen, calloc(1, sizeof(xnestPrivCursor))); xnestCursor(pCursor, pScreen) = XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color, pCursor->bits->xhot, pCursor->bits->yhot); @@ -107,7 +104,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) XFreePixmap(xnestDisplay, source); XFreePixmap(xnestDisplay, mask); - return True; + return TRUE; } Bool @@ -115,7 +112,7 @@ xnestUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen)); free(xnestGetCursorPriv(pCursor, pScreen)); - return True; + return TRUE; } void diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index 0735de772..297d9b9c8 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <string.h> #include <errno.h> @@ -22,6 +19,7 @@ is" without express or implied warranty. #include <X11/X.h> #include <X11/Xproto.h> +#include "os/client_priv.h" #include "os/osdep.h" #include "screenint.h" @@ -86,7 +84,7 @@ xnestOpenDisplay(int argc, char *argv[]) XDisplayName(xnestDisplayName)); if (xnestSynchronize) - XSynchronize(xnestDisplay, True); + XSynchronize(xnestDisplay, TRUE); mask = VisualScreenMask; vi.screen = DefaultScreen(xnestDisplay); diff --git a/hw/xnest/Display.h b/hw/xnest/Display.h index 4e9dbf463..c1fbaebe5 100644 --- a/hw/xnest/Display.h +++ b/hw/xnest/Display.h @@ -15,6 +15,8 @@ is" without express or implied warranty. #ifndef XNESTCOMMON_H #define XNESTCOMMON_H +#include "colormap.h" + #define UNDEFINED -1 #define MAXDEPTH 32 diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index 88db0d18f..0cc0d225d 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -11,15 +11,15 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> #include <X11/Xproto.h> +#include "dix/cursor_priv.h" +#include "mi/mi_priv.h" + #include "screenint.h" #include "input.h" #include "misc.h" @@ -29,8 +29,6 @@ is" without express or implied warranty. #include "inputstr.h" #include "inpututils.h" -#include "mi.h" - #include "Xnest.h" #include "Args.h" @@ -96,7 +94,7 @@ xnestCollectExposures(void) RegionInit(&Rgn, &Box, 1); - miSendExposures(pWin, &Rgn, Box.x2, Box.y2); + miSendExposures(pWin, &Rgn, Box.x1, Box.y1); } } } @@ -108,43 +106,50 @@ xnestQueueKeyEvent(int type, unsigned int keycode) QueueKeyboardEvents(xnestKeyboardDevice, type, keycode); } -void -xnestCollectEvents(void) +static void +xnest_handle_event(XEvent X) { - XEvent X; - int valuators[2]; - ValuatorMask mask; - ScreenPtr pScreen; - - while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) { - switch (X.type) { + switch (X.type) { case KeyPress: + { xnestUpdateModifierState(X.xkey.state); xnestQueueKeyEvent(KeyPress, X.xkey.keycode); break; + } case KeyRelease: + { xnestUpdateModifierState(X.xkey.state); xnestQueueKeyEvent(KeyRelease, X.xkey.keycode); break; + } case ButtonPress: + { + ValuatorMask mask; valuator_mask_set_range(&mask, 0, 0, NULL); xnestUpdateModifierState(X.xkey.state); lastEventTime = GetTimeInMillis(); QueuePointerEvents(xnestPointerDevice, ButtonPress, X.xbutton.button, POINTER_RELATIVE, &mask); break; + } case ButtonRelease: + { + ValuatorMask mask; valuator_mask_set_range(&mask, 0, 0, NULL); xnestUpdateModifierState(X.xkey.state); lastEventTime = GetTimeInMillis(); QueuePointerEvents(xnestPointerDevice, ButtonRelease, X.xbutton.button, POINTER_RELATIVE, &mask); break; + } case MotionNotify: + { + ValuatorMask mask; + int valuators[2]; valuators[0] = X.xmotion.x; valuators[1] = X.xmotion.y; valuator_mask_set_range(&mask, 0, 2, valuators); @@ -152,30 +157,38 @@ xnestCollectEvents(void) QueuePointerEvents(xnestPointerDevice, MotionNotify, 0, POINTER_ABSOLUTE, &mask); break; + } case FocusIn: + { if (X.xfocus.detail != NotifyInferior) { - pScreen = xnestScreen(X.xfocus.window); + ScreenPtr pScreen = xnestScreen(X.xfocus.window); if (pScreen) xnestDirectInstallColormaps(pScreen); } break; + } case FocusOut: + { if (X.xfocus.detail != NotifyInferior) { - pScreen = xnestScreen(X.xfocus.window); + ScreenPtr pScreen = xnestScreen(X.xfocus.window); if (pScreen) xnestDirectUninstallColormaps(pScreen); } break; + } case KeymapNotify: break; case EnterNotify: + { if (X.xcrossing.detail != NotifyInferior) { - pScreen = xnestScreen(X.xcrossing.window); + ScreenPtr pScreen = xnestScreen(X.xcrossing.window); if (pScreen) { + ValuatorMask mask; + int valuators[2]; NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x, X.xcrossing.y); valuators[0] = X.xcrossing.x; @@ -188,21 +201,26 @@ xnestCollectEvents(void) } } break; + } case LeaveNotify: + { if (X.xcrossing.detail != NotifyInferior) { - pScreen = xnestScreen(X.xcrossing.window); + ScreenPtr pScreen = xnestScreen(X.xcrossing.window); if (pScreen) { xnestDirectUninstallColormaps(pScreen); } } break; + } case DestroyNotify: + { if (xnestParentWindow != (Window) 0 && X.xdestroywindow.window == xnestParentWindow) exit(0); break; + } case CirculateNotify: case ConfigureNotify: @@ -216,6 +234,15 @@ xnestCollectEvents(void) default: ErrorF("xnest warning: unhandled event: %d\n", X.type); break; - } + } +} + +void +xnestCollectEvents(void) +{ + XEvent X; + + while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) { + xnest_handle_event(X); } } diff --git a/hw/xnest/Font.c b/hw/xnest/Font.c index 4a8f7d328..eff88f5d9 100644 --- a/hw/xnest/Font.c +++ b/hw/xnest/Font.c @@ -11,17 +11,16 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ +#include <dix-config.h> -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif - +#include <stddef.h> #include <X11/X.h> #include <X11/Xatom.h> #include <X11/Xdefs.h> #include <X11/Xproto.h> #include <X11/fonts/font.h> #include <X11/fonts/fontstruct.h> +#include <X11/fonts/libxfont2.h> #include "misc.h" #include "regionstr.h" @@ -47,7 +46,7 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont) xfont2_font_set_private(pFont, xnestFontPrivateIndex, NULL); - name_atom = MakeAtom("FONT", 4, True); + name_atom = MakeAtom("FONT", 4, TRUE); value_atom = 0L; nprops = pFont->info.nprops; @@ -60,12 +59,12 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont) } if (!value_atom) - return False; + return FALSE; name = NameForAtom(value_atom); if (!name) - return False; + return FALSE; priv = (void *) malloc(sizeof(xnestPrivFont)); xfont2_font_set_private(pFont, xnestFontPrivateIndex, priv); @@ -73,9 +72,9 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont) xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name); if (!xnestFontStruct(pFont)) - return False; + return FALSE; - return True; + return TRUE; } Bool @@ -87,5 +86,5 @@ xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont) free(xnestFontPriv(pFont)); xfont2_font_set_private(pFont, xnestFontPrivateIndex, NULL); } - return True; + return TRUE; } diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c index df12aee7d..a50803ea5 100644 --- a/hw/xnest/GC.c +++ b/hw/xnest/GC.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> @@ -84,7 +81,7 @@ xnestCreateGC(GCPtr pGC) xnestDefaultDrawables[pGC->depth], 0L, NULL); - return True; + return TRUE; } void diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c index 9c35d7410..42db50c10 100644 --- a/hw/xnest/GCOps.c +++ b/hw/xnest/GCOps.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> @@ -100,7 +97,7 @@ static int xnestIgnoreErrorHandler (Display *dpy, XErrorEvent *event) { - return False; /* return value is ignored */ + return FALSE; /* return value is ignored */ } void @@ -112,7 +109,7 @@ xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, int (*old_handler)(Display*, XErrorEvent*); /* we may get BadMatch error when xnest window is minimized */ - XSync(xnestDisplay, False); + XSync(xnestDisplay, FALSE); old_handler = XSetErrorHandler (xnestIgnoreErrorHandler); ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable), @@ -150,13 +147,13 @@ xnestBitBlitHelper(GCPtr pGC) if (!pReg || !pTmpReg) return NullRegion; - pending = True; + pending = TRUE; while (pending) { XIfEvent(xnestDisplay, &event, xnestBitBlitPredicate, NULL); switch (event.type) { case NoExpose: - pending = False; + pending = FALSE; break; case GraphicsExpose: diff --git a/hw/xnest/Handlers.c b/hw/xnest/Handlers.c index 27ea30a83..1484beec4 100644 --- a/hw/xnest/Handlers.c +++ b/hw/xnest/Handlers.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xproto.h> diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c index cd555edbb..fb30d7686 100644 --- a/hw/xnest/Init.c +++ b/hw/xnest/Init.c @@ -11,17 +11,17 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ +#include <dix-config.h> -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif - +#include <stddef.h> #include <X11/X.h> #include <X11/Xdefs.h> #include <X11/Xproto.h> #include <X11/fonts/fontstruct.h> +#include <X11/fonts/libxfont2.h> #include "dix/screenint_priv.h" +#include "mi/mi_priv.h" #include "os/ddx_priv.h" #include "os/osdep.h" @@ -31,7 +31,6 @@ is" without express or implied warranty. #include "scrnintstr.h" #include "windowstr.h" #include "servermd.h" -#include "mi.h" #include "dixfontstr.h" #include "extinit_priv.h" #include "Xnest.h" @@ -51,7 +50,7 @@ is" without express or implied warranty. #include "dpmsproc.h" #endif -Bool xnestDoFullGeneration = True; +Bool xnestDoFullGeneration = TRUE; #ifdef GLXEXT void @@ -135,7 +134,7 @@ CloseInput(void) void ddxGiveUp(enum ExitCode error) { - xnestDoFullGeneration = True; + xnestDoFullGeneration = TRUE; xnestCloseDisplay(); } diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index 7735b9310..92fedfb74 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #ifdef WIN32 #include <X11/Xwindows.h> @@ -39,28 +36,11 @@ is" without express or implied warranty. #include "Args.h" #include "Events.h" +// must come after Xnest.h, because of trickery to avoid name clash +#include <X11/XKBlib.h> #include <X11/extensions/XKB.h> + #include "xkbsrv.h" -#include <X11/extensions/XKBconfig.h> - -extern Bool - XkbQueryExtension(Display * /* dpy */ , - int * /* opcodeReturn */ , - int * /* eventBaseReturn */ , - int * /* errorBaseReturn */ , - int * /* majorRtrn */ , - int * /* minorRtrn */ - ); - -extern XkbDescPtr XkbGetKeyboard(Display * /* dpy */ , - unsigned int /* which */ , - unsigned int /* deviceSpec */ - ); - -extern Status XkbGetControls(Display * /* dpy */ , - unsigned long /* which */ , - XkbDescPtr /* desc */ - ); DeviceIntPtr xnestKeyboardDevice = NULL; @@ -191,7 +171,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) modmap, serverClient); XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); - XkbFreeKeyboard(xkb, 0, False); + XkbFreeKeyboard(xkb, 0, FALSE); free(keymap); break; case DEVICE_ON: diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c index 804e8a3a3..3910db3c7 100644 --- a/hw/xnest/Pixmap.c +++ b/hw/xnest/Pixmap.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> diff --git a/hw/xnest/Pointer.c b/hw/xnest/Pointer.c index a2ee90064..0eced5741 100644 --- a/hw/xnest/Pointer.c +++ b/hw/xnest/Pointer.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xproto.h> @@ -41,7 +38,7 @@ DeviceIntPtr xnestPointerDevice = NULL; void xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl * ctrl) { - XChangePointerControl(xnestDisplay, True, True, + XChangePointerControl(xnestDisplay, TRUE, TRUE, ctrl->num, ctrl->den, ctrl->threshold); } diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 6eb767233..bab6096b1 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -11,20 +11,17 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> #include <X11/Xproto.h> #include "mi/mi_priv.h" +#include "mi/mipointer_priv.h" #include "scrnintstr.h" #include "dix.h" -#include "mi.h" #include "micmap.h" #include "colormapst.h" #include "resource.h" @@ -78,7 +75,7 @@ static Bool xnestSaveScreen(ScreenPtr pScreen, int what) { if (xnestSoftwareScreenSaver) - return False; + return FALSE; else { switch (what) { case SCREEN_SAVER_ON: @@ -102,7 +99,7 @@ xnestSaveScreen(ScreenPtr pScreen, int what) xnestSetInstalledColormapWindows(pScreen); break; } - return True; + return TRUE; } } @@ -406,9 +403,9 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) } if (!xnestCreateDefaultColormap(pScreen)) - return False; + return FALSE; - return True; + return TRUE; } Bool @@ -427,5 +424,5 @@ xnestCloseScreen(ScreenPtr pScreen) the display connection. There is no need to generate extra protocol. */ - return True; + return TRUE; } diff --git a/hw/xnest/Visual.c b/hw/xnest/Visual.c index 11673c44a..37a6ac6cf 100644 --- a/hw/xnest/Visual.c +++ b/hw/xnest/Visual.c @@ -11,10 +11,7 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xproto.h> diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index 932db760c..d8a203a03 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -11,15 +11,14 @@ the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ - -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> -#endif +#include <dix-config.h> #include <X11/X.h> #include <X11/Xdefs.h> #include <X11/Xproto.h> +#include "mi/mi_priv.h" + #include "gcstruct.h" #include "window.h" #include "windowstr.h" @@ -145,7 +144,7 @@ xnestCreateWindow(WindowPtr pWin) if (!pWin->parent) /* only the root window will have the right colormap */ xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - return True; + return TRUE; } Bool @@ -162,7 +161,7 @@ xnestDestroyWindow(WindowPtr pWin) if (pWin->optional && pWin->optional->colormap && pWin->parent) xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - return True; + return TRUE; } Bool @@ -172,7 +171,7 @@ xnestPositionWindow(WindowPtr pWin, int x, int y) CWParent | CWX | CWY | CWWidth | CWHeight | CWBorderWidth); - return True; + return TRUE; } void @@ -348,7 +347,7 @@ xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask) XChangeWindowAttributes(xnestDisplay, xnestWindow(pWin), mask, &attributes); - return True; + return TRUE; } Bool @@ -358,7 +357,7 @@ xnestRealizeWindow(WindowPtr pWin) xnestShapeWindow(pWin); XMapWindow(xnestDisplay, xnestWindow(pWin)); - return True; + return TRUE; } Bool @@ -366,7 +365,7 @@ xnestUnrealizeWindow(WindowPtr pWin) { XUnmapWindow(xnestDisplay, xnestWindow(pWin)); - return True; + return TRUE; } void @@ -394,7 +393,7 @@ xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn) Window window; BoxRec Box; - XSync(xnestDisplay, False); + XSync(xnestDisplay, FALSE); window = xnestWindow(pWin); @@ -429,10 +428,10 @@ xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2) unsigned int n1, n2; if (pReg1 == pReg2) - return True; + return TRUE; if (pReg1 == NullRegion || pReg2 == NullRegion) - return False; + return FALSE; pBox1 = RegionRects(pReg1); n1 = RegionNumRects(pReg1); @@ -441,15 +440,15 @@ xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2) n2 = RegionNumRects(pReg2); if (n1 != n2) - return False; + return FALSE; if (pBox1 == pBox2) - return True; + return TRUE; if (memcmp(pBox1, pBox2, n1 * sizeof(BoxRec))) - return False; + return FALSE; - return True; + return TRUE; } void diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h index 6a222d073..a695f7a3b 100644 --- a/hw/xnest/XNGC.h +++ b/hw/xnest/XNGC.h @@ -17,6 +17,9 @@ is" without express or implied warranty. #include <X11/Xdefs.h> +#include "include/gcstruct.h" +#include "include/privates.h" + /* This file uses the GC definition form Xlib.h as XlibGC. */ typedef struct { diff --git a/hw/xnest/Xnest.h b/hw/xnest/Xnest.h index 37ea6e532..fafb2c876 100644 --- a/hw/xnest/Xnest.h +++ b/hw/xnest/Xnest.h @@ -27,6 +27,8 @@ other dealings in this Software without prior written authorization from the X Consortium. */ +#ifndef _XORG_XNEST_H +#define _XORG_XNEST_H /* ** Machines with a 64 bit library interface and a 32 bit server require @@ -88,3 +90,5 @@ typedef XID KeySym64; #undef GContext #undef KeySym #endif /*_XSERVER64_tmp*/ + +#endif /* _XORG_XNEST_H */ diff --git a/hw/xnest/meson.build b/hw/xnest/meson.build index 37ac5a691..1a981b906 100644 --- a/hw/xnest/meson.build +++ b/hw/xnest/meson.build @@ -33,7 +33,7 @@ executable( libxserver_xi_stubs, libxserver_xkb_stubs, ], - c_args: '-DHAVE_XNEST_CONFIG_H', + c_args: [ '-DHAVE_XNEST_CONFIG_H', '-DDISABLE_EXT_COMPOSITE', '-DDISABLE_EXT_DPMS', '-DISABLE_EXT_MITSHM' ], install: true, ) diff --git a/hw/xnest/xnest-config.h b/hw/xnest/xnest-config.h deleted file mode 100644 index ef48c580f..000000000 --- a/hw/xnest/xnest-config.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2005 Red Hat Inc., Raleigh, North Carolina. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation on the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef XNEST_CONFIG_H -#define XNEST_CONFIG_H - -#include <dix-config.h> -#include <xkb-config.h> - -#undef MITSHM - -#endif /* XNEST_CONFIG_H */ diff --git a/hw/xquartz/GL/capabilities.c b/hw/xquartz/GL/capabilities.c index 1744f1203..cc116b14b 100644 --- a/hw/xquartz/GL/capabilities.c +++ b/hw/xquartz/GL/capabilities.c @@ -20,9 +20,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <stdlib.h> diff --git a/hw/xquartz/GL/glcontextmodes.c b/hw/xquartz/GL/glcontextmodes.c index 64a1ac7c4..6e7f49af4 100644 --- a/hw/xquartz/GL/glcontextmodes.c +++ b/hw/xquartz/GL/glcontextmodes.c @@ -34,9 +34,7 @@ #if defined(IN_MINI_GLX) #include <GL/gl.h> #else -#if defined(HAVE_DIX_CONFIG_H) #include <dix-config.h> -#endif #include <X11/X.h> #include <GL/glx.h> #include "GL/glxint.h" diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c index a8ccfc8ee..993264bb7 100644 --- a/hw/xquartz/GL/indirect.c +++ b/hw/xquartz/GL/indirect.c @@ -31,9 +31,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <dlfcn.h> @@ -343,33 +341,6 @@ attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) return FALSE; } -#if 0 // unused -static void -unattach(__GLXAquaContext *context) -{ - x_list *lst; - GLAQUA_DEBUG_MSG("unattach\n"); - if (context == NULL) { - ErrorF("Tried to unattach a null context\n"); - return; - } - if (context->isAttached) { - GLAQUA_DEBUG_MSG("unattaching\n"); - - if (surface_hash != NULL) { - lst = x_hash_table_lookup(surface_hash, (void *)context->sid, - NULL); - lst = x_list_remove(lst, context); - x_hash_table_insert(surface_hash, (void *)context->sid, lst); - } - - CGLClearDrawable(context->ctx); - context->isAttached = FALSE; - context->sid = 0; - } -} -#endif - static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) { @@ -543,15 +514,6 @@ __glXAquaScreenProbe(ScreenPtr pScreen) return &screen->base; } -#if 0 // unused -static void -__glXAquaDrawableCopySubBuffer(__GLXdrawable *drawable, - int x, int y, int w, int h) -{ - /*TODO finish me*/ -} -#endif - static void __glXAquaDrawableDestroy(__GLXdrawable *base) { diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c index d810e2dfe..4f327cdd8 100644 --- a/hw/xquartz/GL/visualConfigs.c +++ b/hw/xquartz/GL/visualConfigs.c @@ -28,9 +28,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dri.h" @@ -117,7 +115,7 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) * __glXScreenDestroy now walks all the fbconfigs and frees them one at a time. * See 4b0a3cbab131eb453e2b3fc0337121969258a7be. */ - visualConfigs = calloc(sizeof(*visualConfigs), 1); + visualConfigs = calloc(1, sizeof(*visualConfigs)); l = NULL; c = visualConfigs; /* current buffer */ @@ -136,7 +134,7 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) // Global c->visualID = -1; c->visualType = GLX_TRUE_COLOR; - c->next = calloc(sizeof(*visualConfigs), 1); + c->next = calloc(1, sizeof(*visualConfigs)); assert(c->next); c->level = 0; diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index dd96e89f7..b2e2d6540 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -30,9 +30,7 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #import "X11Application.h" #import "NSUserDefaults+XQuartzDefaults.h" @@ -1103,7 +1101,7 @@ handle_mouse: else DarwinSendTabletEvents(darwinTabletCurrent, ProximityOut, 0, location.x, location.y, pressure, - tilt.x, tilt.y); + tilt.x, -tilt.y); return; } @@ -1117,7 +1115,7 @@ handle_mouse: if (needsProximityIn) { DarwinSendTabletEvents(darwinTabletCurrent, ProximityIn, 0, location.x, location.y, pressure, - tilt.x, tilt.y); + tilt.x, -tilt.y); needsProximityIn = NO; } @@ -1159,7 +1157,7 @@ handle_mouse: } else { DarwinSendTabletEvents(pDev, ev_type, ev_button, location.x, location.y, pressure, - tilt.x, tilt.y); + tilt.x, -tilt.y); } break; @@ -1186,7 +1184,7 @@ handle_mouse: else DarwinSendTabletEvents(darwinTabletCurrent, ProximityOut, 0, location.x, location.y, pressure, - tilt.x, tilt.y); + tilt.x, -tilt.y); break; case NSScrollWheel: diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m index e21aed0d3..7e7306895 100644 --- a/hw/xquartz/X11Controller.m +++ b/hw/xquartz/X11Controller.m @@ -30,9 +30,7 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #import "X11Controller.h" #import "X11Application.h" @@ -54,6 +52,8 @@ #include <asl.h> #include <stdlib.h> +#include "dix_priv.h" + extern aslclient aslc; extern char *bundle_id_prefix; diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index e0c7c505d..684999749 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -30,12 +30,12 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <errno.h> +#include "dix/property_priv.h" + #include "quartz.h" #include "misc.h" @@ -387,7 +387,7 @@ ProcAppleWMSetWindowMenu(register ClientPtr client) return BadAlloc; } - max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq); + max_len = (client->req_len << 2) - sizeof(xAppleWMSetWindowMenuReq); bytes = (char *)&stuff[1]; for (i = j = 0; i < max_len && j < nitems;) { @@ -601,7 +601,7 @@ ProcAppleWMFrameDraw(register ClientPtr client) or = make_box(stuff->ox, stuff->oy, stuff->ow, stuff->oh); title_length = stuff->title_length; - title_max = (stuff->length << 2) - sizeof(xAppleWMFrameDrawReq); + title_max = (client->req_len << 2) - sizeof(xAppleWMFrameDrawReq); if (title_max < title_length) return BadValue; @@ -692,7 +692,6 @@ static int SProcAppleWMQueryVersion(register ClientPtr client) { REQUEST(xAppleWMQueryVersionReq); - swaps(&stuff->length); return ProcAppleWMQueryVersion(client); } diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c index 1ec244b03..fcfcd554a 100644 --- a/hw/xquartz/darwin.c +++ b/hw/xquartz/darwin.c @@ -28,9 +28,7 @@ * use or other dealings in this Software without prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/stat.h> #include <X11/X.h> @@ -72,6 +70,9 @@ #define NO_CFPLUGIN #include <IOKit/hidsystem/IOHIDLib.h> +#include "input_priv.h" +#include "screenint_priv.h" + #ifdef MITSHM #include "shmint.h" #endif diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h index 3cae50b2a..c434d4838 100644 --- a/hw/xquartz/darwin.h +++ b/hw/xquartz/darwin.h @@ -29,6 +29,8 @@ #define _DARWIN_H #include <IOKit/IOTypes.h> +#include <X11/Xfuncproto.h> + #include "inputstr.h" #include "scrnintstr.h" #include <X11/extensions/XKB.h> diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index fd87e968b..5aa16ffab 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -40,20 +40,21 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> #include <X11/Xproto.h> + +#include "mi/mi_priv.h" +#include "os/client_priv.h" + #include "misc.h" #include "windowstr.h" #include "pixmapstr.h" #include "inputstr.h" #include "inpututils.h" #include "eventstr.h" -#include "mi.h" #include "scrnintstr.h" #include "mipointer.h" #include "os.h" diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c index fea7e921e..b9d475d63 100644 --- a/hw/xquartz/darwinXinput.c +++ b/hw/xquartz/darwinXinput.c @@ -51,9 +51,7 @@ ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c index 5c5bc70ac..f8598534f 100644 --- a/hw/xquartz/mach-startup/bundle-main.c +++ b/hw/xquartz/mach-startup/bundle-main.c @@ -30,12 +30,12 @@ #include <CoreFoundation/CoreFoundation.h> -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <errno.h> #include <X11/Xlib.h> +#include <X11/Xfuncproto.h> + #include <assert.h> #include <unistd.h> #include <stdio.h> diff --git a/hw/xquartz/mach-startup/launchd_fd.c b/hw/xquartz/mach-startup/launchd_fd.c index 15866cc42..90e59cbfd 100644 --- a/hw/xquartz/mach-startup/launchd_fd.c +++ b/hw/xquartz/mach-startup/launchd_fd.c @@ -26,9 +26,7 @@ * prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <launch.h> #include <asl.h> diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c index 83252e805..5ab09d9a7 100644 --- a/hw/xquartz/mach-startup/stub.c +++ b/hw/xquartz/mach-startup/stub.c @@ -28,9 +28,7 @@ #include <CoreServices/CoreServices.h> -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> #include <unistd.h> diff --git a/hw/xquartz/man/Xquartz.man b/hw/xquartz/man/Xquartz.man index 9b01bbaf3..43d5969dd 100644 --- a/hw/xquartz/man/Xquartz.man +++ b/hw/xquartz/man/Xquartz.man @@ -14,7 +14,9 @@ X11 display is the size of the screen and contains all the other windows. The X11 root window is not displayed in rootless mode as Mac OS X handles the desktop background. .SH CUSTOMIZATION -\fIXquartz\fP can be customized using the defaults(1) command. The available options are: +\fIXquartz\fP can be customized using the +.BR defaults (1) +command. The available options are: .TP 8 .B defaults write @bundle_id_prefix@.X11 enable_fake_buttons -boolean true Emulates a 3 button mouse using modifier keys. By default, the Command modifier @@ -43,11 +45,13 @@ Disables the alert dialog displayed when attempting to quit X11. .TP 8 .B defaults write @bundle_id_prefix@.X11 no_auth -boolean true Stops the X server requiring that clients authenticate themselves when -connecting. See Xsecurity(@miscmansuffix@). +connecting. See +.BR Xsecurity (@miscmansuffix@). .TP 8 .B defaults write @bundle_id_prefix@.X11 nolisten_tcp -boolean false -This will tell the server to listen and accept TCP connections. Doing this without enabling -xauth is a possible security concern. See Xsecurity(@miscmansuffix@). +This will tell the server to listen and accept TCP connections. +Doing this without enabling xauth is a possible security concern. See +.BR Xsecurity (@miscmansuffix@). .TP 8 .B defaults write @bundle_id_prefix@.X11 enable_system_beep -boolean false Don't use the standard system beep effect for X11 alerts. @@ -87,8 +91,8 @@ This option defaults to false and is only accessible through the command line. .B defaults write @bundle_id_prefix@.X11 scroll_in_device_direction -boolean true This option defaults to false. Enable this option to ensure that X11 scroll events are always in the direction of the device. This overrides the related option in the Mouse/Trackpad section of System Preferences. .SH OPTIONS -.PP -In addition to the normal server options described in the \fIXserver(1)\fP +In addition to the normal server options described in the +.BR Xserver (1) manual page, \fIXquartz\fP accepts the following command line switches: .TP 8 .B \-fakebuttons @@ -110,9 +114,14 @@ XQuartz stores a server log at ~/Library/Logs/X11.@bundle_id_prefix@.log which is analogous to /var/log/Xorg.#.log on systems that use the XFree86 DDX such as Linux, BSD, and Solaris. .PP -In addition to this server log, XQuartz sends messages to syslogd(8) using -asl(3). These logs are sent to the @bundle_id_prefix@ facility, and you can -watch these logs using the following syslog(1) command: +In addition to this server log, XQuartz sends messages to +.BR syslogd (8) +using +.BR asl (3). +These logs are sent to the @bundle_id_prefix@ facility, and you can +watch these logs using the following +.BR syslog (1) +command: .TP 8 .B $ syslog -w -k Facility eq @bundle_id_prefix@ .PP @@ -123,7 +132,9 @@ or you can include extra information such as the file, line, and function where By default, XQuartz sets an ASL mask which prevents it from logging messages below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly to the file referenced above). To force XQuartz to send all log messages to -syslogd(8), you can adjust this mask using the following syslog(1) command: +.BR syslogd (8), you can adjust this mask using the following +.BR syslog (1) +command: .TP 8 .B $ syslog -c X11.bin -d .PP @@ -133,11 +144,14 @@ and ASL_LEVEL_NOTICE respectively. In order to see these messages in syslog, you will need to adjust XQuartz's asl mask as above but using -i or -n instead of -d. .SH "SEE ALSO" -.PP -X(@miscmansuffix@), Xserver(1), xdm(1), xinit(1), syslog(1), syslogd(8) +.BR X (@miscmansuffix@), +.BR Xserver (1), +.BR xdm (1), +.BR xinit (1), +.BR syslog (1), +.BR syslogd (8) .PP https://www.xquartz.org/ -.PP .SH AUTHORS / HISTORY X11 was originally ported to Mac OS X Server by John Carmack. Dave Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0. diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h index 482f95ea6..ae3a8d34e 100644 --- a/hw/xquartz/pbproxy/pbproxy.h +++ b/hw/xquartz/pbproxy/pbproxy.h @@ -37,6 +37,7 @@ #define Cursor X_Cursor #undef _SHAPE_H_ +#include <X11/Xfuncproto.h> #include <X11/Xlib.h> #include <X11/extensions/shape.h> #undef Cursor diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c index 4bbe56b93..9c3f59461 100644 --- a/hw/xquartz/quartz.c +++ b/hw/xquartz/quartz.c @@ -31,9 +31,7 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "quartzRandR.h" #include "inputstr.h" @@ -117,7 +115,7 @@ QuartzAddScreen(int index, // The clang static analyzer thinks we leak displayInfo here #ifndef __clang_analyzer__ // allocate space for private per screen Quartz specific storage - QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1); + QuartzScreenPtr displayInfo = calloc(1, sizeof(QuartzScreenRec)); // QUARTZ_PRIV(pScreen) = displayInfo; dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo); diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c index c35a2d15d..82b8d45b4 100644 --- a/hw/xquartz/quartzKeyboard.c +++ b/hw/xquartz/quartzKeyboard.c @@ -33,9 +33,7 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #define HACK_MISSING 1 #define HACK_KEYPAD 1 diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c index 3ecc0e771..48a8be82d 100644 --- a/hw/xquartz/quartzRandR.c +++ b/hw/xquartz/quartzRandR.c @@ -31,9 +31,7 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "quartzRandR.h" #include "quartz.h" diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c index 77ff84506..4c346433b 100644 --- a/hw/xquartz/quartzStartup.c +++ b/hw/xquartz/quartzStartup.c @@ -29,9 +29,7 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <fcntl.h> #include <unistd.h> diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 40422b61a..d04d6213b 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -36,9 +36,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -399,7 +397,6 @@ static int SProcAppleDRIQueryVersion(register ClientPtr client) { REQUEST(xAppleDRIQueryVersionReq); - swaps(&stuff->length); return ProcAppleDRIQueryVersion(client); } @@ -407,7 +404,6 @@ static int SProcAppleDRIQueryDirectRenderingCapable(register ClientPtr client) { REQUEST(xAppleDRIQueryDirectRenderingCapableReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAppleDRIQueryDirectRenderingCapableReq); swapl(&stuff->screen); return ProcAppleDRIQueryDirectRenderingCapable(client); @@ -417,7 +413,6 @@ static int SProcAppleDRIAuthConnection(register ClientPtr client) { REQUEST(xAppleDRIAuthConnectionReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAppleDRIAuthConnectionReq); swapl(&stuff->screen); swapl(&stuff->magic); @@ -428,7 +423,6 @@ static int SProcAppleDRICreateSurface(register ClientPtr client) { REQUEST(xAppleDRICreateSurfaceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq); swapl(&stuff->screen); swapl(&stuff->drawable); @@ -440,7 +434,6 @@ static int SProcAppleDRIDestroySurface(register ClientPtr client) { REQUEST(xAppleDRIDestroySurfaceReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq); swapl(&stuff->screen); swapl(&stuff->drawable); @@ -451,7 +444,6 @@ static int SProcAppleDRICreatePixmap(register ClientPtr client) { REQUEST(xAppleDRICreatePixmapReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAppleDRICreatePixmapReq); swapl(&stuff->screen); swapl(&stuff->drawable); @@ -462,7 +454,6 @@ static int SProcAppleDRIDestroyPixmap(register ClientPtr client) { REQUEST(xAppleDRIDestroyPixmapReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq); swapl(&stuff->drawable); return ProcAppleDRIDestroyPixmap(client); diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c index 091418e19..952c85812 100644 --- a/hw/xquartz/xpr/dri.c +++ b/hw/xquartz/xpr/dri.c @@ -34,9 +34,7 @@ * Jeremy Huddleston <jeremyhu@apple.com> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/time.h> #include <unistd.h> diff --git a/hw/xquartz/xpr/driWrap.c b/hw/xquartz/xpr/driWrap.c index f588a834d..cf63eb9fc 100644 --- a/hw/xquartz/xpr/driWrap.c +++ b/hw/xquartz/xpr/driWrap.c @@ -27,9 +27,7 @@ * prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> #include "mi.h" diff --git a/hw/xquartz/xpr/x-hash.c b/hw/xquartz/xpr/x-hash.c index 087656d9b..2108fe6ae 100644 --- a/hw/xquartz/xpr/x-hash.c +++ b/hw/xquartz/xpr/x-hash.c @@ -28,9 +28,7 @@ * prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "x-hash.h" #include "x-list.h" diff --git a/hw/xquartz/xpr/x-hook.c b/hw/xquartz/xpr/x-hook.c index 3922bb86c..7ea0d01fd 100644 --- a/hw/xquartz/xpr/x-hook.c +++ b/hw/xquartz/xpr/x-hook.c @@ -28,9 +28,7 @@ * prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "x-hook.h" #include <stdlib.h> diff --git a/hw/xquartz/xpr/x-list.c b/hw/xquartz/xpr/x-list.c index 171657686..0250ac549 100644 --- a/hw/xquartz/xpr/x-list.c +++ b/hw/xquartz/xpr/x-list.c @@ -28,9 +28,7 @@ * prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "x-list.h" #include <stdlib.h> diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c index 126661766..ed031d228 100644 --- a/hw/xquartz/xpr/xprAppleWM.c +++ b/hw/xquartz/xpr/xprAppleWM.c @@ -27,9 +27,7 @@ * use or other dealings in this Software without prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "xpr.h" diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c index ff6cf4dd0..5b0ad8a33 100644 --- a/hw/xquartz/xpr/xprCursor.c +++ b/hw/xquartz/xpr/xprCursor.c @@ -31,15 +31,15 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "quartz.h" #include "xpr.h" #include "darwinEvents.h" #include <Xplugin.h> +#include "mi/mipointer_priv.h" + #include "mi.h" #include "scrnintstr.h" #include "cursorstr.h" diff --git a/hw/xquartz/xpr/xprEvent.c b/hw/xquartz/xpr/xprEvent.c index eb321a52f..7490da649 100644 --- a/hw/xquartz/xpr/xprEvent.c +++ b/hw/xquartz/xpr/xprEvent.c @@ -26,9 +26,7 @@ * prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "xpr.h" diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c index 57d16d42f..9d88abbb6 100644 --- a/hw/xquartz/xpr/xprFrame.c +++ b/hw/xquartz/xpr/xprFrame.c @@ -27,9 +27,7 @@ * use or other dealings in this Software without prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "xpr.h" #include "rootlessCommon.h" diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c index 81de33769..f595748ef 100644 --- a/hw/xquartz/xpr/xprScreen.c +++ b/hw/xquartz/xpr/xprScreen.c @@ -29,9 +29,7 @@ #include "sanitizedCarbon.h" -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "inputstr.h" #include "quartz.h" diff --git a/hw/xwayland/man/Xwayland.man b/hw/xwayland/man/Xwayland.man index e30799e9a..ea6d78eed 100644 --- a/hw/xwayland/man/Xwayland.man +++ b/hw/xwayland/man/Xwayland.man @@ -43,7 +43,9 @@ of the Wayland desktop. It is however possible for a user to launch Xwayland non-rootless, mainly for testing purposes. .PP Like all of the X servers, \fIXwayland\fP accepts the command line options -described in the \fIXserver\fP(@miscmansuffix@) manual page. +described in the +.BR Xserver (@miscmansuffix@) +manual page. The following additional arguments are supported as well. .TP 8 .B \-decorate @@ -146,7 +148,7 @@ Run \fIXwayland\fP rootless, so that X clients integrate seamlessly with Wayland clients in a Wayland desktop. That requires the Wayland server to be an X window manager as well. .TP 8 -.BI \-shm +.B \-shm Force the shared memory backend instead of glamor (if available) for passing buffers to the Wayland server. @@ -161,7 +163,7 @@ verbosity level. When the value is supplied, the verbosity level is set to that value. The default verbosity level is 0. .TP 8 -.BI \-version +.B \-version Show the server version and exit. .TP 8 .B \-wm \fIfd\fP @@ -176,4 +178,6 @@ the name of the display of the Wayland server. .B XWAYLAND_NO_GLAMOR disable glamor and DRI3 support in \fIXwayland\fP, for testing purposes. .SH "SEE ALSO" -General information: \fIX\fP(@miscmansuffix@), \fIwayland-info\fP(@miscmansuffix@) +General information: +.BR X (@miscmansuffix@), +.BR wayland-info (@miscmansuffix@) diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build index 458f3c09e..bee2eb324 100644 --- a/hw/xwayland/meson.build +++ b/hw/xwayland/meson.build @@ -51,6 +51,7 @@ xwayland_shell_xml = join_paths(protodir, 'staging', 'xwayland-shell', 'xwayland tearing_xml = join_paths(protodir, 'staging', 'tearing-control', 'tearing-control-v1.xml') fractional_scale_xml = join_paths(protodir, 'staging', 'fractional-scale', 'fractional-scale-v1.xml') syncobj_xml = join_paths(protodir, 'staging', 'linux-drm-syncobj', 'linux-drm-syncobj-v1.xml') +system_bell_xml = join_paths(protodir, 'staging', 'xdg-system-bell', 'xdg-system-bell-v1.xml') proto_xml = [ relative_xml, @@ -68,6 +69,7 @@ proto_xml = [ tearing_xml, fractional_scale_xml, syncobj_xml, + system_bell_xml, ] client_header = generator(scanner, @@ -139,6 +141,7 @@ xwayland_server = executable( include_directories: wayland_inc, dependencies: [ common_dep, + epoll_dep, xwayland_dep, xwaylandproto_dep, ], @@ -182,10 +185,12 @@ pkgconfig.generate( filebase: 'xwayland', name: 'Xwayland', description: 'X Server for Wayland', + dataonly: true, variables: [ 'exec_prefix=${prefix}', 'xwayland=' + xwayland_path / xwayland_server.name(), ] + xwayland_vars, + url: 'https://gitlab.freedesktop.org/xorg/xserver/', ) xwayland_manpage = configure_file( diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c index 9ee427063..be78f97e3 100644 --- a/hw/xwayland/xwayland-cursor.c +++ b/hw/xwayland/xwayland-cursor.c @@ -26,6 +26,8 @@ #include <xwayland-config.h> +#include "mi/mipointer_priv.h" + #include "scrnintstr.h" #include "servermd.h" #include "cursorstr.h" @@ -43,8 +45,6 @@ #define DELAYED_X_CURSOR_TIMEOUT 5 /* ms */ -static DevPrivateKeyRec xwl_cursor_private_key; - static void expand_source_and_mask(CursorPtr cursor, CARD32 *data) { @@ -80,29 +80,15 @@ expand_source_and_mask(CursorPtr cursor, CARD32 *data) static Bool xwl_realize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor) { - PixmapPtr pixmap; - - pixmap = xwl_shm_create_pixmap(screen, cursor->bits->width, - cursor->bits->height, 32, - CREATE_PIXMAP_USAGE_BACKING_PIXMAP); - dixSetPrivate(&cursor->devPrivates, &xwl_cursor_private_key, pixmap); - return TRUE; } static Bool xwl_unrealize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor) { - PixmapPtr pixmap; struct xwl_screen *xwl_screen; struct xwl_seat *xwl_seat; - pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key); - if (!pixmap) - return TRUE; - - dixSetPrivate(&cursor->devPrivates, &xwl_cursor_private_key, NULL); - /* When called from FreeCursor(), device is always NULL */ xwl_screen = xwl_screen_get(screen); xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) { @@ -110,7 +96,7 @@ xwl_unrealize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor) xwl_seat->x_cursor = NULL; } - return xwl_shm_destroy_pixmap(pixmap); + return TRUE; } static void @@ -173,8 +159,9 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat, xwl_cursor->frame_cb = wl_surface_frame(xwl_cursor->surface); wl_callback_add_listener(xwl_cursor->frame_cb, &frame_listener, xwl_cursor); - /* Hold a reference on the pixmap until it's released by the compositor */ - pixmap->refcnt++; + /* The pixmap will be destroyed in xwl_cursor_buffer_release_callback() + * once the compositor is done with it. + */ xwl_pixmap_set_buffer_release_cb(pixmap, xwl_cursor_buffer_release_callback, pixmap); @@ -220,7 +207,9 @@ xwl_seat_set_cursor(struct xwl_seat *xwl_seat) } cursor = xwl_seat->x_cursor; - pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key); + pixmap = xwl_shm_create_pixmap(xwl_screen->screen, cursor->bits->width, + cursor->bits->height, 32, + CREATE_PIXMAP_USAGE_BACKING_PIXMAP); if (!pixmap) return; @@ -263,7 +252,9 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool) } cursor = xwl_seat->x_cursor; - pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key); + pixmap = xwl_shm_create_pixmap(xwl_screen->screen, cursor->bits->width, + cursor->bits->height, 32, + CREATE_PIXMAP_USAGE_BACKING_PIXMAP); if (!pixmap) return; @@ -443,9 +434,6 @@ static miPointerScreenFuncRec xwl_pointer_screen_funcs = { Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen) { - if (!dixRegisterPrivateKey(&xwl_cursor_private_key, PRIVATE_CURSOR, 0)) - return FALSE; - return miPointerInitialize(xwl_screen->screen, &xwl_pointer_sprite_funcs, &xwl_pointer_screen_funcs, TRUE); diff --git a/hw/xwayland/xwayland-dmabuf.c b/hw/xwayland/xwayland-dmabuf.c index db7dc44ee..1676a82da 100644 --- a/hw/xwayland/xwayland-dmabuf.c +++ b/hw/xwayland/xwayland-dmabuf.c @@ -204,7 +204,7 @@ xwl_dmabuf_get_formats_for_device(struct xwl_dmabuf_feedback *xwl_feedback, drmD struct xwl_device_formats *dev_formats = &xwl_feedback->dev_formats[i]; /* Append the formats from this tranche to the list */ - ret = xnfreallocarray(ret, count + dev_formats->num_formats, sizeof(CARD32)); + ret = XNFreallocarray(ret, count + dev_formats->num_formats, sizeof(CARD32)); for (int j = 0; j < dev_formats->num_formats; j++) { Bool found = FALSE; @@ -410,7 +410,7 @@ xwl_add_format_and_mod_to_list(struct xwl_format **formats, if (xwl_format == NULL) { (*num_formats)++; - *formats = xnfrealloc(*formats, *num_formats * sizeof(*xwl_format)); + *formats = XNFrealloc(*formats, *num_formats * sizeof(*xwl_format)); xwl_format = &(*formats)[*num_formats - 1]; xwl_format->format = format; xwl_format->num_modifiers = 0; @@ -424,7 +424,7 @@ xwl_add_format_and_mod_to_list(struct xwl_format **formats, } xwl_format->num_modifiers++; - xwl_format->modifiers = xnfrealloc(xwl_format->modifiers, + xwl_format->modifiers = XNFrealloc(xwl_format->modifiers, xwl_format->num_modifiers * sizeof(uint64_t)); xwl_format->modifiers[xwl_format->num_modifiers - 1] = modifier; } @@ -596,7 +596,7 @@ xwl_dmabuf_feedback_tranche_done(void *data, if (!appended) { xwl_feedback->dev_formats_len++; - xwl_feedback->dev_formats = xnfrealloc(xwl_feedback->dev_formats, + xwl_feedback->dev_formats = XNFrealloc(xwl_feedback->dev_formats, sizeof(struct xwl_device_formats) * xwl_feedback->dev_formats_len); @@ -752,7 +752,7 @@ xwl_window_dmabuf_feedback_done(void *data, /* If the linux-dmabuf v4 per-surface feedback changed, make sure the * window buffers get re-created with appropriate parameters. */ - xwl_window_buffers_dispose(xwl_window); + xwl_window_buffers_dispose(xwl_window, FALSE); xwl_window_realloc_pixmap(xwl_window); } diff --git a/hw/xwayland/xwayland-drm-lease.c b/hw/xwayland/xwayland-drm-lease.c index 224ad4c73..30d363b59 100644 --- a/hw/xwayland/xwayland-drm-lease.c +++ b/hw/xwayland/xwayland-drm-lease.c @@ -26,6 +26,8 @@ #include <xwayland-config.h> +#include "os/client_priv.h" + #ifdef WITH_LIBDRM #include <xf86drm.h> #include <xf86drmMode.h> diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index b30cff935..05668b8e9 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -32,6 +32,10 @@ #include <fcntl.h> #include <errno.h> +#include <poll.h> +#ifdef DRI3 +#include <sys/eventfd.h> +#endif /* DRI3 */ #include <sys/stat.h> #include <xf86drm.h> #include <drm_fourcc.h> @@ -55,6 +59,7 @@ #include "xwayland-glamor-gbm.h" #include "xwayland-pixmap.h" #include "xwayland-screen.h" +#include "xwayland-window-buffers.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" #include "linux-drm-syncobj-v1-client-protocol.h" @@ -82,6 +87,12 @@ struct xwl_pixmap { unsigned int texture; struct gbm_bo *bo; Bool implicit_modifier; +#ifdef DRI3 + struct dri3_syncobj *syncobj; + uint64_t timeline_point; + int efd; + struct xwl_window_buffer *xwl_window_buffer; +#endif /* DRI3 */ }; static DevPrivateKeyRec xwl_gbm_private_key; @@ -225,6 +236,9 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, xwl_pixmap->bo = bo; xwl_pixmap->buffer = NULL; xwl_pixmap->implicit_modifier = implicit_modifier; +#if defined(XWL_HAS_GLAMOR) && defined(DRI3) + xwl_pixmap->efd = -1; +#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */ #ifdef GBM_BO_FD_FOR_PLANE if (xwl_gbm->dmabuf_capable) { @@ -445,6 +459,7 @@ xwl_glamor_gbm_destroy_pixmap(PixmapPtr pixmap) eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image); if (xwl_pixmap->bo) gbm_bo_destroy(xwl_pixmap->bo); + xwl_glamor_gbm_dispose_syncpts(pixmap); free(xwl_pixmap); } @@ -616,6 +631,13 @@ xwl_glamor_gbm_cleanup(struct xwl_screen *xwl_screen) { struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); + if (!xwl_gbm) + return; + + /* Cannot use GBM after clean-up, disable GLAMOR support from now on */ + ErrorF("XWAYLAND: Disabling GLAMOR support\n"); + xwl_screen->glamor = XWL_GLAMOR_NONE; + if (xwl_gbm->device_name) free(xwl_gbm->device_name); drmFreeDevice(&xwl_gbm->device); @@ -628,6 +650,8 @@ xwl_glamor_gbm_cleanup(struct xwl_screen *xwl_screen) if (xwl_screen->explicit_sync) wp_linux_drm_syncobj_manager_v1_destroy(xwl_screen->explicit_sync); + dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key, + NULL); free(xwl_gbm); } @@ -666,6 +690,7 @@ xwl_auth_state_client_callback(CallbackListPtr *pcbl, void *unused, void *data) } } +#ifdef DRI3 static void sync_callback(void *data, struct wl_callback *callback, uint32_t serial) { @@ -728,6 +753,7 @@ xwl_dri3_open_client(ClientPtr client, return Success; } +#endif /* DRI3 */ PixmapPtr glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds, @@ -968,6 +994,7 @@ xwl_glamor_dmabuf_import_sync_file(PixmapPtr pixmap, int sync_file) close(sync_file); } +#ifdef DRI3 struct xwl_dri3_syncobj { struct dri3_syncobj base; @@ -1226,6 +1253,7 @@ static dri3_screen_info_rec xwl_dri3_info = { .get_drawable_modifiers = xwl_glamor_get_drawable_modifiers, .import_syncobj = NULL, /* need to check for kernel support */ }; +#endif /* DRI3 */ static const char * get_render_node_path_for_device(const drmDevicePtr drm_device, @@ -1299,6 +1327,7 @@ xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device) if (!xwl_gbm->device_name) { xwl_glamor_gbm_cleanup(xwl_screen); + xwl_screen->expecting_event--; return; } @@ -1307,12 +1336,14 @@ xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device) ErrorF("wayland-egl: could not open %s (%s)\n", xwl_gbm->device_name, strerror(errno)); xwl_glamor_gbm_cleanup(xwl_screen); + xwl_screen->expecting_event--; return; } if (drmGetDevice2(xwl_gbm->drm_fd, 0, &xwl_gbm->device) != 0) { ErrorF("wayland-egl: Could not fetch DRM device %s\n", xwl_gbm->device_name); + xwl_screen->expecting_event--; return; } @@ -1388,6 +1419,21 @@ xwl_glamor_gbm_has_egl_extension(void) epoxy_has_egl_extension(NULL, "EGL_KHR_platform_gbm")); } +#ifdef DRI3 +static void +xwl_glamor_gbm_release_fence_avail(int fd, int xevents, void *data) +{ + struct xwl_pixmap *xwl_pixmap = data; + struct xwl_window_buffer *xwl_window_buffer = xwl_pixmap->xwl_window_buffer; + + SetNotifyFd(fd, NULL, 0, NULL); + close(fd); + xwl_pixmap->efd = -1; + + xwl_window_buffer_release(xwl_window_buffer); +} +#endif /* DRI3 */ + Bool xwl_glamor_supports_implicit_sync(struct xwl_screen *xwl_screen) { @@ -1403,6 +1449,121 @@ xwl_glamor_supports_syncobjs(struct xwl_screen *xwl_screen) xwl_gbm_get(xwl_screen)->supports_syncobjs; } +Bool +xwl_glamor_gbm_set_syncpts(struct xwl_window *xwl_window, PixmapPtr pixmap) +{ +#ifdef DRI3 + struct xwl_screen *xwl_screen = xwl_window->xwl_screen; + struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap); + uint64_t acquire_point; + uint64_t release_point; + int fence_fd; + + if (!xwl_screen->glamor) + return FALSE; + + if (!xwl_pixmap) { + ErrorF("XWAYLAND: Failed to set synchronization point, no backing xwl_pixmap!\n"); + return FALSE; + } + + acquire_point = ++xwl_pixmap->timeline_point; + release_point = ++xwl_pixmap->timeline_point; + + if (!xwl_pixmap->syncobj) { + struct dri3_syncobj *syncobj = xwl_glamor_dri3_syncobj_create(xwl_screen); + if (!syncobj) + goto fail; + xwl_pixmap->syncobj = syncobj; + } + + fence_fd = xwl_glamor_get_fence(xwl_screen); + if (fence_fd >= 0) + xwl_pixmap->syncobj->import_fence(xwl_pixmap->syncobj, acquire_point, fence_fd); + else + goto fail; + + xwl_glamor_dri3_syncobj_passthrough(xwl_window, + xwl_pixmap->syncobj, + xwl_pixmap->syncobj, + acquire_point, + release_point); + return TRUE; + +fail: + /* can't use explicit sync, we will do a glFinish() before presenting */ + if (xwl_pixmap->syncobj) { + xwl_pixmap->syncobj->free(xwl_pixmap->syncobj); + xwl_pixmap->syncobj = NULL; + } +#endif /* DRI3 */ + return FALSE; +} + +void +xwl_glamor_gbm_dispose_syncpts(PixmapPtr pixmap) +{ +#ifdef DRI3 + struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap); + struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen); + + if (!xwl_screen->glamor || !xwl_pixmap) + return; + + if (xwl_pixmap->syncobj) { + xwl_pixmap->syncobj->free(xwl_pixmap->syncobj); + xwl_pixmap->syncobj = NULL; + } + + if (xwl_pixmap->efd >= 0) { + SetNotifyFd(xwl_pixmap->efd, NULL, 0, NULL); + close(xwl_pixmap->efd); + } +#endif /* DRI3 */ +} + +void +xwl_glamor_gbm_wait_syncpts(PixmapPtr pixmap) +{ +#ifdef DRI3 + struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen); + struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap); + + if (!xwl_screen->glamor || !xwl_pixmap) + return; + + if (xwl_pixmap->syncobj) { + int fence_fd = xwl_pixmap->syncobj->export_fence(xwl_pixmap->syncobj, + xwl_pixmap->timeline_point); + + xwl_glamor_wait_fence(xwl_screen, fence_fd); + } +#endif /* DRI3 */ +} + +void +xwl_glamor_gbm_wait_release_fence(struct xwl_window *xwl_window, + PixmapPtr pixmap, + struct xwl_window_buffer *xwl_window_buffer) +{ +#ifdef DRI3 + struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap); + struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen); + + if (!xwl_screen->glamor || !xwl_pixmap || !xwl_window_buffer) + return; + + xwl_pixmap->xwl_window_buffer = xwl_window_buffer; + /* wait until the release fence is available before re-using this buffer */ + xwl_pixmap->efd = eventfd(0, EFD_CLOEXEC); + SetNotifyFd(xwl_pixmap->efd, xwl_glamor_gbm_release_fence_avail, X_NOTIFY_READ, + xwl_pixmap); + xwl_pixmap->syncobj->submitted_eventfd(xwl_pixmap->syncobj, + xwl_pixmap->timeline_point, + xwl_pixmap->efd); +#endif /* DRI3 */ +} + static Bool xwl_glamor_try_to_make_context_current(struct xwl_screen *xwl_screen) { @@ -1514,6 +1675,11 @@ xwl_glamor_gbm_init_main_dev(struct xwl_screen *xwl_screen) } main_dev = xwl_screen->default_feedback.main_dev; + if (!main_dev) { + ErrorF("No main linux-dmabuf device advertised by compositor\n"); + return FALSE; + } + if (!(main_dev->available_nodes & (1 << DRM_NODE_RENDER))) { ErrorF("Main linux-dmabuf device has no render node\n"); return FALSE; @@ -1619,7 +1785,7 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen) } /* NVIDIA driver does not support implicit sync */ xwl_gbm->implicit_sync = !strstr(egl_vendor, "NVIDIA"); - +#ifdef DRI3 if (xwl_gbm_supports_syncobjs(xwl_screen) && epoxy_has_egl_extension(xwl_screen->egl_display, "ANDROID_native_fence_sync")) @@ -1630,7 +1796,7 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen) wp_linux_drm_syncobj_manager_v1_destroy(xwl_screen->explicit_sync); xwl_screen->explicit_sync = NULL; } - +#endif /* DRI3 */ return TRUE; error: if (xwl_screen->egl_display != EGL_NO_DISPLAY) { @@ -1647,7 +1813,7 @@ Bool xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen) { struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); - +#ifdef DRI3 if (xwl_gbm->supports_syncobjs) { xwl_dri3_info.version = 4; xwl_dri3_info.import_syncobj = xwl_dri3_import_syncobj; @@ -1657,7 +1823,7 @@ xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen) ErrorF("Failed to initialize dri3\n"); goto error; } - +#endif /* DRI3 */ if (xwl_gbm->fd_render_node) goto skip_drm_auth; @@ -1701,7 +1867,7 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen) if (!dixRegisterPrivateKey(&xwl_gbm_private_key, PRIVATE_SCREEN, 0)) return FALSE; - xwl_gbm = calloc(sizeof(*xwl_gbm), 1); + xwl_gbm = calloc(1, sizeof(*xwl_gbm)); if (!xwl_gbm) { ErrorF("glamor: Not enough memory to setup GBM, disabling\n"); return FALSE; diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h index 9083f2578..b346a0ba6 100644 --- a/hw/xwayland/xwayland-glamor-gbm.h +++ b/hw/xwayland/xwayland-glamor-gbm.h @@ -42,4 +42,12 @@ Bool xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen); Bool xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen); drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen); +/* Explicit buffer synchronization points */ +Bool xwl_glamor_gbm_set_syncpts(struct xwl_window *xwl_window, PixmapPtr pixmap); +void xwl_glamor_gbm_dispose_syncpts(PixmapPtr pixmap); +void xwl_glamor_gbm_wait_syncpts(PixmapPtr pixmap); +void xwl_glamor_gbm_wait_release_fence(struct xwl_window *xwl_window, + PixmapPtr pixmap, + struct xwl_window_buffer *xwl_window_buffer); + #endif /* XWAYLAND_GLAMOR_GBM_H */ diff --git a/hw/xwayland/xwayland-glamor-xv.c b/hw/xwayland/xwayland-glamor-xv.c index 23e7100e4..d0aaa02c7 100644 --- a/hw/xwayland/xwayland-glamor-xv.c +++ b/hw/xwayland/xwayland-glamor-xv.c @@ -32,10 +32,11 @@ #include <xwayland-config.h> -#include "glamor_priv.h" - #include <X11/extensions/Xv.h> +#include "Xext/xvdix_priv.h" + +#include "glamor_priv.h" #include "xwayland-glamor.h" #define NUM_FORMATS 3 @@ -203,7 +204,7 @@ xwl_glamor_xv_add_formats(XvAdaptorPtr pa) int i; totFormat = NUM_FORMATS; - pFormat = xnfcalloc(totFormat, sizeof(XvFormatRec)); + pFormat = XNFcallocarray(totFormat, sizeof(XvFormatRec)); pScreen = pa->pScreen; for (pf = pFormat, i = 0, numFormat = 0; i < NUM_FORMATS; i++) { numVisuals = pScreen->numVisuals; @@ -216,7 +217,7 @@ xwl_glamor_xv_add_formats(XvAdaptorPtr pa) void *moreSpace; totFormat *= 2; - moreSpace = xnfreallocarray(pFormat, totFormat, + moreSpace = XNFreallocarray(pFormat, totFormat, sizeof(XvFormatRec)); pFormat = moreSpace; pf = pFormat + numFormat; @@ -246,10 +247,10 @@ xwl_glamor_xv_add_ports(XvAdaptorPtr pa) int nPorts; int i; - pPorts = xnfcalloc(NUM_PORTS, sizeof(XvPortRec)); + pPorts = XNFcallocarray(NUM_PORTS, sizeof(XvPortRec)); xwlXvScreen = dixLookupPrivate(&(pa->pScreen)->devPrivates, xwlXvScreenPrivateKey); - xwlXvScreen->port_privates = xnfcalloc(NUM_PORTS, + xwlXvScreen->port_privates = XNFcallocarray(NUM_PORTS, sizeof(glamor_port_private)); PortResource = XvGetRTPort(); @@ -280,7 +281,7 @@ xwl_glamor_xv_add_attributes(XvAdaptorPtr pa) { int i; - pa->pAttributes = xnfcalloc(glamor_xv_num_attributes, sizeof(XvAttributeRec)); + pa->pAttributes = XNFcallocarray(glamor_xv_num_attributes, sizeof(XvAttributeRec)); memcpy(pa->pAttributes, glamor_xv_attributes, glamor_xv_num_attributes * sizeof(XvAttributeRec)); @@ -293,7 +294,7 @@ xwl_glamor_xv_add_attributes(XvAdaptorPtr pa) static void xwl_glamor_xv_add_images(XvAdaptorPtr pa) { - pa->pImages = xnfcalloc(glamor_xv_num_images, sizeof(XvImageRec)); + pa->pImages = XNFcallocarray(glamor_xv_num_images, sizeof(XvImageRec)); memcpy(pa->pImages, glamor_xv_images, glamor_xv_num_images * sizeof(XvImageRec)); pa->nImages = glamor_xv_num_images; @@ -307,7 +308,7 @@ xwl_glamor_xv_add_encodings(XvAdaptorPtr pa) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texsize); - pe = xnfcalloc(1, sizeof(XvEncodingRec)); + pe = XNFcallocarray(1, sizeof(XvEncodingRec)); pe->id = 0; pe->pScreen = pa->pScreen; pe->name = strdup(ENCODER_NAME); @@ -337,7 +338,7 @@ xwl_glamor_xv_add_adaptors(ScreenPtr pScreen) XvScreen->nAdaptors = 0; XvScreen->pAdaptors = NULL; - pa = xnfcalloc(1, sizeof(XvAdaptorRec)); + pa = XNFcallocarray(1, sizeof(XvAdaptorRec)); pa->pScreen = pScreen; pa->type = (unsigned char) (XvInputMask | XvImageMask); pa->ddStopVideo = xwl_glamor_xv_stop_video; diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c index 604658284..6618a0a34 100644 --- a/hw/xwayland/xwayland-glamor.c +++ b/hw/xwayland/xwayland-glamor.c @@ -93,14 +93,21 @@ xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap) { ScreenPtr screen = pixmap->drawable.pScreen; PixmapPtr backing_pixmap = screen->GetWindowPixmap(present_window); + struct xwl_window *xwl_window = xwl_window_from_window(present_window); + WindowPtr surface_window = xwl_window->surface_window; if (pixmap->drawable.depth != backing_pixmap->drawable.depth) { if (pixmap->drawable.depth == 32) return FALSE; - return xwl_present_maybe_redirect_window(present_window, pixmap); + return xwl_present_maybe_redirect_window(present_window); } + if (surface_window->redirectDraw == RedirectDrawAutomatic && + surface_window->drawable.depth != 32 && + surface_window->parent->drawable.depth == 32) + xwl_present_maybe_redirect_window(surface_window); + return TRUE; } @@ -191,14 +198,17 @@ xwl_glamor_get_fence(struct xwl_screen *xwl_screen) return fence_fd; } +/* Takes ownership of fence_fd, specifically eglCreateSyncKHR does */ void xwl_glamor_wait_fence(struct xwl_screen *xwl_screen, int fence_fd) { EGLint attribs[3]; EGLSyncKHR sync; - if (!xwl_screen->glamor) + if (!xwl_screen->glamor) { + close(fence_fd); return; + } xwl_glamor_egl_make_current(xwl_screen); diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index da7e80e88..de41c7c78 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -31,12 +31,14 @@ #include "dix/dix_priv.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" +#include "mi/mipointer_priv.h" #include <inputstr.h> #include <xkbsrv.h> #include <xserver-properties.h> #include <inpututils.h> -#include <mi.h> #include <mipointer.h> #include <mipointrst.h> #include <misc.h> @@ -56,6 +58,7 @@ #include "pointer-gestures-unstable-v1-client-protocol.h" #include "xwayland-keyboard-grab-unstable-v1-client-protocol.h" #include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h" +#include "xdg-system-bell-v1-client-protocol.h" #define SCROLL_AXIS_HORIZ 2 #define SCROLL_AXIS_VERT 3 @@ -597,6 +600,9 @@ xwl_seat_leave_ptr(struct xwl_seat *xwl_seat, Bool focus_lost) { DeviceIntPtr dev = get_pointer_device(xwl_seat); + if (!dev) + return; + if (focus_lost) CheckMotion(NULL, GetMaster(dev, POINTER_OR_FLOAT)); @@ -1182,9 +1188,20 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, XkbUpdateDescActions(xkb, xkb->min_key_code, XkbNumKeys(xkb), &changes); - if (xwl_seat->keyboard->key) + memcpy( + xwl_seat->keyboard->kbdfeed->ctrl.autoRepeats, + xkb->ctrls->per_key_repeat, + XkbPerKeyBitArraySize + ); + if (xwl_seat->keyboard->key) { /* Keep the current controls */ XkbCopyControls(xkb, xwl_seat->keyboard->key->xkbInfo->desc); + memcpy( + xkb->ctrls->per_key_repeat, + xwl_seat->keyboard->kbdfeed->ctrl.autoRepeats, + XkbPerKeyBitArraySize + ); + } XkbDeviceApplyKeymap(xwl_seat->keyboard, xkb); @@ -1212,6 +1229,10 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, xwl_seat->xwl_screen->serial = serial; xwl_seat->keyboard_focus = surface; + /* If `leave` wasn't sent (for a destroyed surface), release keys here. */ + wl_array_for_each(k, &xwl_seat->keys) + QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8); + wl_array_copy(&xwl_seat->keys, keys); wl_array_for_each(k, &xwl_seat->keys) QueueKeyboardEvents(xwl_seat->keyboard, EnterNotify, *k + 8); @@ -1226,6 +1247,7 @@ xwl_seat_leave_kbd(struct xwl_seat *xwl_seat) wl_array_for_each(k, &xwl_seat->keys) QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8); + xwl_seat->keys.size = 0; xwl_seat->keyboard_focus = NULL; @@ -1267,11 +1289,12 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, old_state = dev->key->xkbInfo->state; new_state = &dev->key->xkbInfo->state; + new_state->base_group = 0; + new_state->latched_group = 0; new_state->locked_group = group & XkbAllGroupsMask; new_state->base_mods = mods_depressed & XkbAllModifiersMask; + new_state->latched_mods = mods_latched & XkbAllModifiersMask; new_state->locked_mods = mods_locked & XkbAllModifiersMask; - XkbLatchModifiers(dev, XkbAllModifiersMask, - mods_latched & XkbAllModifiersMask); XkbComputeDerivedState(dev->key->xkbInfo); @@ -1343,7 +1366,7 @@ keyboard_check_repeat (DeviceIntPtr dev, XkbSrvInfoPtr xkbi, unsigned key) } } - p = xnfalloc(sizeof(struct sync_pending)); + p = XNFalloc(sizeof(struct sync_pending)); p->pending_dev = dev; callback = wl_display_sync (xwl_screen->display); xorg_list_add(&p->l, &xwl_seat->sync_pending); @@ -1659,6 +1682,7 @@ add_device(struct xwl_seat *xwl_seat, dev->public.devicePrivate = xwl_seat; dev->type = SLAVE; dev->spriteInfo->spriteOwner = FALSE; + dev->ignoreXkbActionsBehaviors = TRUE; return dev; } @@ -2166,22 +2190,17 @@ tablet_tool_down(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial) { struct xwl_tablet_tool *xwl_tablet_tool = data; struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; - ValuatorMask mask; + xwl_tablet_tool->tip = TRUE; xwl_seat->xwl_screen->serial = serial; - - valuator_mask_zero(&mask); - QueuePointerEvents(xwl_tablet_tool->xdevice, ButtonPress, 1, 0, &mask); } static void tablet_tool_up(void *data, struct zwp_tablet_tool_v2 *tool) { struct xwl_tablet_tool *xwl_tablet_tool = data; - ValuatorMask mask; - valuator_mask_zero(&mask); - QueuePointerEvents(xwl_tablet_tool->xdevice, ButtonRelease, 1, 0, &mask); + xwl_tablet_tool->tip = FALSE; } static void @@ -2304,7 +2323,7 @@ tablet_tool_button_state(void *data, struct zwp_tablet_tool_v2 *tool, { struct xwl_tablet_tool *xwl_tablet_tool = data; struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; - uint32_t *mask = &xwl_tablet_tool->buttons_now; + uint32_t *mask = &xwl_tablet_tool->buttons; int xbtn = 0; /* BTN_0 .. BTN_9 */ @@ -2369,7 +2388,7 @@ tablet_tool_frame(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t time) { struct xwl_tablet_tool *xwl_tablet_tool = data; ValuatorMask mask; - uint32_t released, pressed, diff; + uint32_t effective_buttons, released, pressed, diff; int button; valuator_mask_zero(&mask); @@ -2385,9 +2404,14 @@ tablet_tool_frame(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t time) valuator_mask_zero(&mask); - diff = xwl_tablet_tool->buttons_prev ^ xwl_tablet_tool->buttons_now; - released = diff & ~xwl_tablet_tool->buttons_now; - pressed = diff & xwl_tablet_tool->buttons_now; + effective_buttons = xwl_tablet_tool->buttons; + if (xwl_tablet_tool->tip) { + SetBit(&effective_buttons, 0); + } + + diff = effective_buttons ^ xwl_tablet_tool->effective_buttons; + released = diff & ~effective_buttons; + pressed = diff & effective_buttons; button = 1; while (released) { @@ -2407,7 +2431,7 @@ tablet_tool_frame(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t time) pressed >>= 1; } - xwl_tablet_tool->buttons_prev = xwl_tablet_tool->buttons_now; + xwl_tablet_tool->effective_buttons = effective_buttons; while (xwl_tablet_tool->wheel_clicks) { if (xwl_tablet_tool->wheel_clicks < 0) { @@ -2869,7 +2893,7 @@ tablet_seat_handle_add_tablet(void *data, struct zwp_tablet_seat_v2 *tablet_seat struct xwl_seat *xwl_seat = data; struct xwl_tablet *xwl_tablet; - xwl_tablet = calloc(sizeof *xwl_tablet, 1); + xwl_tablet = calloc(1, sizeof *xwl_tablet); if (xwl_tablet == NULL) { ErrorF("%s ENOMEM\n", __func__); return; @@ -2900,7 +2924,7 @@ tablet_seat_handle_add_tool(void *data, struct zwp_tablet_seat_v2 *tablet_seat, struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; struct xwl_tablet_tool *xwl_tablet_tool; - xwl_tablet_tool = calloc(sizeof *xwl_tablet_tool, 1); + xwl_tablet_tool = calloc(1, sizeof *xwl_tablet_tool); if (xwl_tablet_tool == NULL) { ErrorF("%s ENOMEM\n", __func__); return; @@ -2923,7 +2947,7 @@ tablet_seat_handle_add_pad(void *data, struct zwp_tablet_seat_v2 *tablet_seat, struct xwl_seat *xwl_seat = data; struct xwl_tablet_pad *xwl_tablet_pad; - xwl_tablet_pad = calloc(sizeof *xwl_tablet_pad, 1); + xwl_tablet_pad = calloc(1, sizeof *xwl_tablet_pad); if (xwl_tablet_pad == NULL) { ErrorF("%s ENOMEM\n", __func__); return; @@ -3082,6 +3106,15 @@ init_keyboard_shortcuts_inhibit(struct xwl_screen *xwl_screen, 1); } +static void +init_system_bell(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version) +{ + xwl_screen->system_bell = + wl_registry_bind(xwl_screen->registry, id, + &xdg_system_bell_v1_interface, + 1); +} + /* The compositor may send us wl_seat and its capabilities before sending e.g. relative_pointer_manager or pointer_gesture interfaces. This would result in devices being created in capabilities handler, but listeners not, because @@ -3133,6 +3166,8 @@ input_handler(void *data, struct wl_registry *registry, uint32_t id, init_keyboard_grab(xwl_screen, id, version); } else if (strcmp(interface, zwp_keyboard_shortcuts_inhibit_manager_v1_interface.name) == 0) { init_keyboard_shortcuts_inhibit(xwl_screen, id, version); + } else if (strcmp(interface, xdg_system_bell_v1_interface.name) == 0) { + init_system_bell(xwl_screen, id, version); } } @@ -3155,6 +3190,28 @@ ProcessInputEvents(void) void DDXRingBell(int volume, int pitch, int duration) { + ScreenPtr screen = screenInfo.screens[0]; + struct xwl_screen *xwl_screen; + struct xwl_seat *xwl_seat; + + xwl_screen = xwl_screen_get(screen); + if (!xwl_screen->system_bell) + return; + + xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) { + if (!xwl_seat->keyboard) + continue; + + if (!xwl_seat->keyboard->coreEvents) + continue; + + if (!xwl_seat->keyboard_focus) + continue; + + DebugF("XWAYLAND: Ringing the bell\n"); + xdg_system_bell_v1_ring (xwl_screen->system_bell, xwl_seat->keyboard_focus); + return; + } } static Bool @@ -3188,6 +3245,15 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window) if (master->lastSlave != get_pointer_device(xwl_seat)) return FALSE; + /* If we left the surface with a button down, it means the wayland compositor + * has grabbed the pointer so we will not get button release events from the + * compositor, so leave the window processing untouched, so that we do not + * end up with the wrong cursor, for example, when processing events once + * the pointer enters the X11 surface again. + */ + if (master->button->buttonsDown) + return FALSE; + if (xwl_seat->focus_window != NULL && xwl_seat->cursor_confinement_window != NULL && xwl_seat->focus_window != xwl_seat->cursor_confinement_window) @@ -3580,6 +3646,7 @@ InitInput(int argc, char *argv[]) mieqInit(); + inputInfo.keyboard->ignoreXkbActionsBehaviors = TRUE; xwl_screen->input_registry = wl_display_get_registry(xwl_screen->display); wl_registry_add_listener(xwl_screen->input_registry, &input_listener, xwl_screen); diff --git a/hw/xwayland/xwayland-input.h b/hw/xwayland/xwayland-input.h index d40bca08a..0a742f017 100644 --- a/hw/xwayland/xwayland-input.h +++ b/hw/xwayland/xwayland-input.h @@ -148,8 +148,9 @@ struct xwl_tablet_tool { double rotation; double slider; - uint32_t buttons_now, - buttons_prev; + uint32_t buttons; + Bool tip; + uint32_t effective_buttons; int32_t wheel_clicks; diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c index 7c8ebd49a..dd0d71690 100644 --- a/hw/xwayland/xwayland-output.c +++ b/hw/xwayland/xwayland-output.c @@ -30,6 +30,7 @@ #include <X11/Xatom.h> #include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "randr/randrstr_priv.h" #include "xwayland-cvt.h" @@ -404,9 +405,18 @@ xwl_output_find_mode(struct xwl_output *xwl_output, RROutputPtr output = xwl_output->randr_output; int i; - /* width & height -1 means we want the actual output mode, which is idx 0 */ - if (width == -1 && height == -1 && output->modes) - return output->modes[0]; + /* width & height -1 means we want the actual output mode */ + if (width == -1 && height == -1) { + if (xwl_output->mode_width > 0 && xwl_output->mode_height > 0) { + /* If running rootful, use the current mode size to search for the mode */ + width = xwl_output->mode_width; + height = xwl_output->mode_height; + } + else if (output->modes) { + /* else return the mode at first idx 0 */ + return output->modes[0]; + } + } for (i = 0; i < output->numModes; i++) { if (output->modes[i]->mode.width == width && output->modes[i]->mode.height == height) @@ -900,6 +910,8 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, struct xwl_output *xwl_output; char name[MAX_OUTPUT_NAME] = { 0 }; + --xwl_screen->expecting_event; + xwl_output = calloc(1, sizeof *xwl_output); if (xwl_output == NULL) { ErrorF("%s ENOMEM\n", __func__); @@ -948,7 +960,6 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, * use it when binding to the xdg-output protocol... */ xorg_list_append(&xwl_output->link, &xwl_screen->output_list); - --xwl_screen->expecting_event; if (xwl_screen->xdg_output_manager) xwl_output_get_xdg_output(xwl_output); @@ -1187,7 +1198,7 @@ xwl_output_set_transform(struct xwl_output *xwl_output) } if (xwl_output->transform == NULL) { - xwl_output->transform = xnfalloc(sizeof(RRTransformRec)); + xwl_output->transform = XNFalloc(sizeof(RRTransformRec)); RRTransformInit(xwl_output->transform); } diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c index 4d2410568..07d58ee6a 100644 --- a/hw/xwayland/xwayland-present.c +++ b/hw/xwayland/xwayland-present.c @@ -31,7 +31,9 @@ #endif #include <windowstr.h> #include <present.h> +#ifdef DRI3 #include <sys/eventfd.h> +#endif /* DRI3 */ #include "xwayland-present.h" #include "xwayland-screen.h" @@ -328,7 +330,7 @@ xwl_present_free_event(struct xwl_present_event *event) static void xwl_present_free_idle_vblank(present_vblank_ptr vblank) { -#ifdef XWL_HAS_GLAMOR +#if defined(XWL_HAS_GLAMOR) && defined(DRI3) if (vblank->release_syncobj) { /* transfer implicit fence to release syncobj */ int fence_fd = xwl_glamor_dmabuf_export_sync_file(vblank->pixmap); @@ -336,7 +338,7 @@ xwl_present_free_idle_vblank(present_vblank_ptr vblank) vblank->release_point, fence_fd); } else -#endif /* XWL_HAS_GLAMOR */ +#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */ present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence); xwl_present_free_event(xwl_present_event_from_vblank(vblank)); @@ -393,7 +395,9 @@ static void xwl_present_flip_notify_vblank(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc) { WindowPtr window = vblank->window; +#ifdef DRI3 struct xwl_screen *xwl_screen = xwl_screen_get(window->drawable.pScreen); +#endif /* DRI3 */ struct xwl_present_window *xwl_present_window = xwl_present_window_priv(window); uint8_t mode = PresentCompleteModeFlip; @@ -507,7 +511,7 @@ xwl_present_buffer_release(void *data) vblank = &event->vblank; -#ifdef XWL_HAS_GLAMOR +#if defined(XWL_HAS_GLAMOR) && defined(DRI3) if (vblank->release_syncobj) { /* transfer implicit fence to release syncobj */ int fence_fd = xwl_glamor_dmabuf_export_sync_file(vblank->pixmap); @@ -515,7 +519,7 @@ xwl_present_buffer_release(void *data) vblank->release_point, fence_fd); } else -#endif /* XWL_HAS_GLAMOR */ +#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */ present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence); xwl_present_window = xwl_present_window_priv(vblank->window); @@ -866,7 +870,7 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage) struct xwl_present_event *event = xwl_present_event_from_vblank(vblank); Bool implicit_sync = TRUE; - if (!xwl_window) + if (!xwl_window || !xwl_window->allow_commits) return FALSE; buffer = xwl_pixmap_get_wl_buffer(pixmap); @@ -881,7 +885,7 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage) event->pixmap = pixmap; -#ifdef XWL_HAS_GLAMOR +#if defined(XWL_HAS_GLAMOR) && defined(DRI3) if (vblank->acquire_syncobj && vblank->release_syncobj) { if (xwl_window->xwl_screen->explicit_sync) { xwl_glamor_dri3_syncobj_passthrough(xwl_window, @@ -898,7 +902,7 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage) xwl_glamor_dmabuf_import_sync_file(vblank->pixmap, fence_fd); } } -#endif /* XWL_HAS_GLAMOR */ +#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */ if (implicit_sync) { xwl_pixmap_set_buffer_release_cb(pixmap, xwl_present_buffer_release, event); @@ -950,7 +954,7 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage) return TRUE; } -#ifdef XWL_HAS_GLAMOR +#if defined(XWL_HAS_GLAMOR) && defined(DRI3) static void xwl_present_acquire_fence_avail(int fd, int xevents, void *data) { @@ -962,13 +966,13 @@ xwl_present_acquire_fence_avail(int fd, int xevents, void *data) xwl_present_re_execute(vblank); } -#endif /* XWL_HAS_GLAMOR */ +#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */ static Bool xwl_present_wait_acquire_fence_avail(struct xwl_screen *xwl_screen, present_vblank_ptr vblank) { -#ifdef XWL_HAS_GLAMOR +#if defined(XWL_HAS_GLAMOR) && defined(DRI3) /* If the compositor does not support explicit sync we need to wait for the * acquire fence to be submitted before flipping. */ if (vblank->flip && !xwl_screen->explicit_sync && @@ -982,7 +986,7 @@ xwl_present_wait_acquire_fence_avail(struct xwl_screen *xwl_screen, vblank->efd); return TRUE; } -#endif /* XWL_HAS_GLAMOR */ +#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */ return FALSE; } @@ -1284,7 +1288,7 @@ xwl_present_unrealize_window(struct xwl_present_window *xwl_present_window) } Bool -xwl_present_maybe_redirect_window(WindowPtr window, PixmapPtr pixmap) +xwl_present_maybe_redirect_window(WindowPtr window) { struct xwl_present_window *xwl_present_window = xwl_present_window_get_priv(window); struct xwl_window *xwl_window = xwl_window_from_window(window); @@ -1297,17 +1301,20 @@ xwl_present_maybe_redirect_window(WindowPtr window, PixmapPtr pixmap) return FALSE; } + xwl_present_window->redirected = TRUE; + xwl_window_update_surface_window(xwl_window); if (xwl_window->surface_window != window) { compUnredirectWindow(serverClient, window, CompositeRedirectManual); + xwl_present_window->redirected = FALSE; xwl_present_window->redirect_failed = TRUE; + xwl_window_update_surface_window(xwl_window); return FALSE; } if (!xwl_window->surface_window_damage) xwl_window->surface_window_damage = RegionCreate(NullBox, 1); - xwl_present_window->redirected = TRUE; return TRUE; } @@ -1345,6 +1352,14 @@ xwl_present_maybe_unredirect_window(WindowPtr window) } Bool +xwl_present_window_redirected(WindowPtr window) +{ + struct xwl_present_window *xwl_present_window = xwl_present_window_get_priv(window); + + return xwl_present_window->redirected; +} + +Bool xwl_present_init(ScreenPtr screen) { struct xwl_screen *xwl_screen = xwl_screen_get(screen); diff --git a/hw/xwayland/xwayland-present.h b/hw/xwayland/xwayland-present.h index 808e54182..527233910 100644 --- a/hw/xwayland/xwayland-present.h +++ b/hw/xwayland/xwayland-present.h @@ -81,7 +81,8 @@ void xwl_present_frame_callback(struct xwl_present_window *xwl_present_window); Bool xwl_present_init(ScreenPtr screen); void xwl_present_cleanup(WindowPtr window); void xwl_present_unrealize_window(struct xwl_present_window *xwl_present_window); -Bool xwl_present_maybe_redirect_window(WindowPtr window, PixmapPtr pixmap); +Bool xwl_present_maybe_redirect_window(WindowPtr window); Bool xwl_present_maybe_unredirect_window(WindowPtr window); +Bool xwl_present_window_redirected(WindowPtr window); #endif /* XWAYLAND_PRESENT_H */ diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c index 287fe8b06..5bc3551e3 100644 --- a/hw/xwayland/xwayland-screen.c +++ b/hw/xwayland/xwayland-screen.c @@ -35,8 +35,13 @@ #endif #include <X11/Xatom.h> +#include <X11/Xfuncproto.h> +#include "dix/input_priv.h" +#include "dix/property_priv.h" +#include "os/client_priv.h" #include "os/osdep.h" +#include "os/xserver_poll.h" #include <micmap.h> #include <misyncshm.h> @@ -46,7 +51,6 @@ #include <propertyst.h> #include <inputstr.h> #include <xacestr.h> -#include <xserver_poll.h> #include "xwayland-cursor.h" #include "xwayland-screen.h" @@ -981,6 +985,12 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) return FALSE; } + xwl_screen->display = wl_display_connect(NULL); + if (xwl_screen->display == NULL) { + ErrorF("could not connect to wayland server\n"); + return FALSE; + } + #ifdef XWL_HAS_GLAMOR if (xwl_screen->glamor && !xwl_glamor_init_gbm(xwl_screen)) { ErrorF("xwayland glamor: failed to setup GBM backend, falling back to sw accel\n"); @@ -1009,12 +1019,6 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) if (!monitorResolution) monitorResolution = DEFAULT_DPI; - xwl_screen->display = wl_display_connect(NULL); - if (xwl_screen->display == NULL) { - ErrorF("could not connect to wayland server\n"); - return FALSE; - } - if (use_fixed_size) { if (!xwl_screen_init_randr_fixed(xwl_screen)) return FALSE; diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h index 0800fb392..49a167a12 100644 --- a/hw/xwayland/xwayland-screen.h +++ b/hw/xwayland/xwayland-screen.h @@ -117,6 +117,7 @@ struct xwl_screen { struct wp_tearing_control_manager_v1 *tearing_control_manager; struct wp_fractional_scale_manager_v1 *fractional_scale_manager; struct wp_linux_drm_syncobj_manager_v1 *explicit_sync; + struct xdg_system_bell_v1 *system_bell; struct xorg_list drm_lease_devices; struct xorg_list queued_drm_lease_devices; struct xorg_list drm_leases; diff --git a/hw/xwayland/xwayland-types.h b/hw/xwayland/xwayland-types.h index 73a674633..d3fd2a0fc 100644 --- a/hw/xwayland/xwayland-types.h +++ b/hw/xwayland/xwayland-types.h @@ -31,5 +31,6 @@ struct xwl_window; struct xwl_screen; struct xwl_drm_lease; struct xwl_output; +struct xwl_window_buffer; #endif /* XWAYLAND_TYPES_H */ diff --git a/hw/xwayland/xwayland-vidmode.c b/hw/xwayland/xwayland-vidmode.c index 77e57b1e4..a4ca0eaf1 100644 --- a/hw/xwayland/xwayland-vidmode.c +++ b/hw/xwayland/xwayland-vidmode.c @@ -25,9 +25,7 @@ * authorization from the copyright holder(s) and author(s). */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c index 2e8b0859c..a470ef313 100644 --- a/hw/xwayland/xwayland-window-buffers.c +++ b/hw/xwayland/xwayland-window-buffers.c @@ -31,6 +31,7 @@ #include "xwayland-window.h" #include "xwayland-pixmap.h" #include "xwayland-screen.h" +#include "xwayland-glamor-gbm.h" #include "xwayland-window-buffers.h" #ifdef XWL_HAS_GLAMOR #include "glamor.h" @@ -38,7 +39,9 @@ #include "dri3.h" #include <poll.h> +#ifdef DRI3 #include <sys/eventfd.h> +#endif #include "linux-drm-syncobj-v1-client-protocol.h" #define BUFFER_TIMEOUT 1 * 1000 /* ms */ @@ -47,11 +50,6 @@ struct xwl_window_buffer { struct xwl_window *xwl_window; PixmapPtr pixmap; RegionPtr damage_region; -#ifdef XWL_HAS_GLAMOR - struct dri3_syncobj *syncobj; - uint64_t timeline_point; - int efd; -#endif /* XWL_HAS_GLAMOR */ int refcnt; uint32_t time; struct xorg_list link_buffer; @@ -90,9 +88,6 @@ xwl_window_buffer_new(struct xwl_window *xwl_window) xwl_window_buffer->damage_region = RegionCreate(NullBox, 1); xwl_window_buffer->pixmap = NullPixmap; xwl_window_buffer->refcnt = 1; -#ifdef XWL_HAS_GLAMOR - xwl_window_buffer->efd = -1; -#endif /* XWL_HAS_GLAMOR */ xorg_list_init(&xwl_window_buffer->link_buffer); @@ -109,31 +104,31 @@ xwl_window_buffer_destroy_pixmap(struct xwl_window_buffer *xwl_window_buffer) xwl_window_buffer->pixmap = NullPixmap; } -static Bool -xwl_window_buffer_maybe_dispose(struct xwl_window_buffer *xwl_window_buffer) +static void +xwl_window_buffer_dispose(struct xwl_window_buffer *xwl_window_buffer) { - assert(xwl_window_buffer->refcnt > 0); - - if (--xwl_window_buffer->refcnt) - return FALSE; - RegionDestroy(xwl_window_buffer->damage_region); - if (xwl_window_buffer->pixmap) - xwl_window_buffer_destroy_pixmap (xwl_window_buffer); - + if (xwl_window_buffer->pixmap) { #ifdef XWL_HAS_GLAMOR - if (xwl_window_buffer->syncobj) - xwl_window_buffer->syncobj->free(xwl_window_buffer->syncobj); - - if (xwl_window_buffer->efd >= 0) { - SetNotifyFd(xwl_window_buffer->efd, NULL, 0, NULL); - close(xwl_window_buffer->efd); - } + xwl_glamor_gbm_dispose_syncpts(xwl_window_buffer->pixmap); #endif /* XWL_HAS_GLAMOR */ + xwl_window_buffer_destroy_pixmap (xwl_window_buffer); + } xorg_list_del(&xwl_window_buffer->link_buffer); free(xwl_window_buffer); +} + +static Bool +xwl_window_buffer_maybe_dispose(struct xwl_window_buffer *xwl_window_buffer) +{ + assert(xwl_window_buffer->refcnt > 0); + + if (--xwl_window_buffer->refcnt) + return FALSE; + + xwl_window_buffer_dispose(xwl_window_buffer); return TRUE; } @@ -238,19 +233,11 @@ xwl_window_buffer_release_callback(void *data) xwl_window); } -#ifdef XWL_HAS_GLAMOR -static void -xwl_window_buffers_release_fence_avail(int fd, int xevents, void *data) +void +xwl_window_buffer_release(struct xwl_window_buffer *xwl_window_buffer) { - struct xwl_window_buffer *xwl_window_buffer = data; - - SetNotifyFd(fd, NULL, 0, NULL); - close(fd); - xwl_window_buffer->efd = -1; - - xwl_window_buffer_release_callback(data); + xwl_window_buffer_release_callback(xwl_window_buffer); } -#endif /* XWL_HAS_GLAMOR */ void xwl_window_buffers_init(struct xwl_window *xwl_window) @@ -259,8 +246,17 @@ xwl_window_buffers_init(struct xwl_window *xwl_window) xorg_list_init(&xwl_window->window_buffers_unavailable); } +static void +xwl_window_buffer_disposal(struct xwl_window_buffer *xwl_window_buffer, Bool force) +{ + if (force) + xwl_window_buffer_dispose(xwl_window_buffer); + else + xwl_window_buffer_maybe_dispose(xwl_window_buffer); +} + void -xwl_window_buffers_dispose(struct xwl_window *xwl_window) +xwl_window_buffers_dispose(struct xwl_window *xwl_window, Bool force) { struct xwl_window_buffer *xwl_window_buffer, *tmp; @@ -272,14 +268,14 @@ xwl_window_buffers_dispose(struct xwl_window *xwl_window) &xwl_window->window_buffers_available, link_buffer) { xorg_list_del(&xwl_window_buffer->link_buffer); - xwl_window_buffer_maybe_dispose(xwl_window_buffer); + xwl_window_buffer_disposal(xwl_window_buffer, force); } xorg_list_for_each_entry_safe(xwl_window_buffer, tmp, &xwl_window->window_buffers_unavailable, link_buffer) { xorg_list_del(&xwl_window_buffer->link_buffer); - xwl_window_buffer_maybe_dispose(xwl_window_buffer); + xwl_window_buffer_disposal(xwl_window_buffer, force); } if (xwl_window->window_buffers_timer) @@ -370,54 +366,39 @@ xwl_window_realloc_pixmap(struct xwl_window *xwl_window) screen->DestroyPixmap(window_pixmap); } -#ifdef XWL_HAS_GLAMOR static Bool -xwl_window_buffers_set_syncpts(struct xwl_window_buffer *xwl_window_buffer) +xwl_window_handle_pixmap_sync(struct xwl_window *xwl_window, + PixmapPtr pixmap, + struct xwl_window_buffer *xwl_window_buffer) { - struct xwl_window *xwl_window = xwl_window_buffer->xwl_window; + Bool implicit_sync = TRUE; +#ifdef XWL_HAS_GLAMOR struct xwl_screen *xwl_screen = xwl_window->xwl_screen; - uint64_t acquire_point = ++xwl_window_buffer->timeline_point; - uint64_t release_point = ++xwl_window_buffer->timeline_point; - - if (!xwl_window_buffer->syncobj) { - struct dri3_syncobj *syncobj = xwl_glamor_dri3_syncobj_create(xwl_screen); - if (!syncobj) - goto fail; - xwl_window_buffer->syncobj = syncobj; - } - - int fence_fd = xwl_glamor_get_fence(xwl_screen); - if (fence_fd >= 0) - xwl_window_buffer->syncobj->import_fence(xwl_window_buffer->syncobj, - acquire_point, fence_fd); - else - goto fail; - xwl_glamor_dri3_syncobj_passthrough(xwl_window, - xwl_window_buffer->syncobj, - xwl_window_buffer->syncobj, - acquire_point, - release_point); - return TRUE; - -fail: - /* can't use explicit sync, we will do a glFinish() before presenting */ - if (xwl_window_buffer->syncobj) { - xwl_window_buffer->syncobj->free(xwl_window_buffer->syncobj); - xwl_window_buffer->syncobj = NULL; + if (!xwl_glamor_supports_implicit_sync(xwl_screen)) { + if (xwl_screen->explicit_sync && xwl_glamor_gbm_set_syncpts(xwl_window, pixmap)) { + implicit_sync = FALSE; + /* wait until the release fence is available before re-using this buffer */ + xwl_glamor_gbm_wait_release_fence(xwl_window, pixmap, xwl_window_buffer); + } else { + /* If glamor does not support implicit sync and we can't use + * explicit sync, wait for the GPU to be idle before presenting. + * Note that buffer re-use will still be unsynchronized :( + */ + glamor_finish(xwl_screen->screen); + } } - return FALSE; -} #endif /* XWL_HAS_GLAMOR */ + return implicit_sync; +} PixmapPtr -xwl_window_swap_pixmap(struct xwl_window *xwl_window) +xwl_window_swap_pixmap(struct xwl_window *xwl_window, Bool handle_sync) { struct xwl_screen *xwl_screen = xwl_window->xwl_screen; WindowPtr surface_window = xwl_window->surface_window; struct xwl_window_buffer *xwl_window_buffer; PixmapPtr window_pixmap; - Bool implicit_sync = TRUE; window_pixmap = (*xwl_screen->screen->GetWindowPixmap) (surface_window); @@ -428,17 +409,9 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window) RegionPtr full_damage = xwl_window_buffer->damage_region; BoxPtr pBox = RegionRects(full_damage); int nBox = RegionNumRects(full_damage); - #ifdef XWL_HAS_GLAMOR - if (xwl_window_buffer->syncobj) { - int fence_fd = - xwl_window_buffer->syncobj->export_fence(xwl_window_buffer->syncobj, - xwl_window_buffer->timeline_point); - xwl_glamor_wait_fence(xwl_screen, fence_fd); - close(fence_fd); - } + xwl_glamor_gbm_wait_syncpts(xwl_window_buffer->pixmap); #endif /* XWL_HAS_GLAMOR */ - while (nBox--) { copy_pixmap_area(window_pixmap, xwl_window_buffer->pixmap, @@ -458,6 +431,8 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window) if (xwl_is_client_pixmap(window_pixmap)) { xwl_window_buffer->pixmap = NULL; xwl_window_buffer_maybe_dispose(xwl_window_buffer); + if (handle_sync) + xwl_window_handle_pixmap_sync(xwl_window, window_pixmap, NULL); return window_pixmap; } } else { @@ -468,8 +443,11 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window) window_pixmap->refcnt++; xwl_window_realloc_pixmap(xwl_window); - if (!xwl_window_buffer) + if (!xwl_window_buffer) { + if (handle_sync) + xwl_window_handle_pixmap_sync(xwl_window, window_pixmap, NULL); return window_pixmap; + } } xwl_window_buffer->pixmap = window_pixmap; @@ -477,27 +455,8 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window) /* Hold a reference on the buffer until it's released by the compositor */ xwl_window_buffer->refcnt++; -#ifdef XWL_HAS_GLAMOR - if (!xwl_glamor_supports_implicit_sync(xwl_screen)) { - if (xwl_screen->explicit_sync && xwl_window_buffers_set_syncpts(xwl_window_buffer)) { - implicit_sync = FALSE; - /* wait until the release fence is available before re-using this buffer */ - xwl_window_buffer->efd = eventfd(0, EFD_CLOEXEC); - SetNotifyFd(xwl_window_buffer->efd, xwl_window_buffers_release_fence_avail, - X_NOTIFY_READ, xwl_window_buffer); - xwl_window_buffer->syncobj->submitted_eventfd(xwl_window_buffer->syncobj, - xwl_window_buffer->timeline_point, - xwl_window_buffer->efd); - } else - /* If glamor does not support implicit sync and we can't use - * explicit sync, wait for the GPU to be idle before presenting. - * Note that buffer re-use will still be unsynchronized :( - */ - glamor_finish(xwl_screen->screen); - } -#endif /* XWL_HAS_GLAMOR */ - - if (implicit_sync) { + if (handle_sync && + xwl_window_handle_pixmap_sync(xwl_window, window_pixmap, xwl_window_buffer)) { xwl_pixmap_set_buffer_release_cb(xwl_window_buffer->pixmap, xwl_window_buffer_release_callback, xwl_window_buffer); diff --git a/hw/xwayland/xwayland-window-buffers.h b/hw/xwayland/xwayland-window-buffers.h index 8b463e671..dabb343c1 100644 --- a/hw/xwayland/xwayland-window-buffers.h +++ b/hw/xwayland/xwayland-window-buffers.h @@ -31,12 +31,11 @@ #include "xwayland-types.h" -struct xwl_window_buffer; - void xwl_window_buffer_add_damage_region(struct xwl_window *xwl_window); +void xwl_window_buffer_release(struct xwl_window_buffer *xwl_window_buffer); void xwl_window_buffers_init(struct xwl_window *xwl_window); -void xwl_window_buffers_dispose(struct xwl_window *xwl_window); +void xwl_window_buffers_dispose(struct xwl_window *xwl_window, Bool force); void xwl_window_realloc_pixmap(struct xwl_window *xwl_window); -PixmapPtr xwl_window_swap_pixmap(struct xwl_window *xwl_window); +PixmapPtr xwl_window_swap_pixmap(struct xwl_window *xwl_window, Bool handle_sync); #endif /* XWAYLAND_WINDOW_BUFFERS_H */ diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index 05f45e16f..b717fcf3c 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -23,9 +23,7 @@ * SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <float.h> #include <math.h> @@ -34,6 +32,9 @@ #include <X11/X.h> #include <X11/Xatom.h> +#include "dix/dix_priv.h" +#include "dix/property_priv.h" + #include "compositeext.h" #include "compint.h" #include "inputstr.h" @@ -316,7 +317,7 @@ damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data) window_pixmap = xwl_screen->screen->GetWindowPixmap(xwl_window->surface_window); if (xwl_is_client_pixmap(window_pixmap)) - xwl_screen->screen->DestroyPixmap(xwl_window_swap_pixmap(xwl_window)); + xwl_screen->screen->DestroyPixmap(xwl_window_swap_pixmap(xwl_window, FALSE)); } static void @@ -494,6 +495,18 @@ window_get_client_toplevel(WindowPtr window) return window; } +static Bool +is_output_suitable_for_fullscreen(struct xwl_output *xwl_output) +{ + if (xwl_output == NULL) + return FALSE; + + if (xwl_output->width == 0 || xwl_output->height == 0) + return FALSE; + + return TRUE; +} + static struct xwl_output * xwl_window_get_output(struct xwl_window *xwl_window) { @@ -501,11 +514,11 @@ xwl_window_get_output(struct xwl_window *xwl_window) struct xwl_output *xwl_output; xwl_output = xwl_output_get_output_from_name(xwl_screen, xwl_screen->output_name); - if (xwl_output) + if (is_output_suitable_for_fullscreen(xwl_output)) return xwl_output; xwl_output = xwl_output_from_wl_output(xwl_screen, xwl_window->wl_output); - if (xwl_output) + if (is_output_suitable_for_fullscreen(xwl_output)) return xwl_output; return xwl_screen_get_first_output(xwl_screen); @@ -1053,7 +1066,7 @@ xwl_window_enter_output(struct xwl_window *xwl_window, struct xwl_output *xwl_ou { struct xwl_window_output *window_output; - window_output = xnfcalloc(1, sizeof(struct xwl_window_output)); + window_output = XNFcallocarray(1, sizeof(struct xwl_window_output)); window_output->xwl_output = xwl_output; xorg_list_add(&window_output->link, &xwl_window->xwl_output_list); } @@ -1351,6 +1364,9 @@ xwl_window_update_surface_window(struct xwl_window *xwl_window) if (!RegionEqual(&window->winSize, &surface_window->winSize)) break; + if (!window->mapped) + break; + /* The surface window must be top-level for its window pixmap */ window_pixmap = screen->GetWindowPixmap(window); if (window_pixmap == surface_pixmap) @@ -1365,6 +1381,10 @@ xwl_window_update_surface_window(struct xwl_window *xwl_window) if (window->drawable.depth == 32) continue; + if (window->redirectDraw == RedirectDrawManual && + !xwl_present_window_redirected(window)) + break; + surface_window = window; } @@ -1398,7 +1418,7 @@ xwl_window_update_surface_window(struct xwl_window *xwl_window) } if (surface_window->drawable.depth != xwl_window->surface_window->drawable.depth) - xwl_window_buffers_dispose(xwl_window); + xwl_window_buffers_dispose(xwl_window, FALSE); xwl_window->surface_window = surface_window; register_damage(xwl_window); @@ -1609,7 +1629,7 @@ release_wl_surface_for_window_legacy_delay(struct xwl_window *xwl_window) * and Wayland processing so that the compositor has the time to * establish the association before the wl_surface is destroyed. */ - xwl_wl_surface = xnfcalloc(1, sizeof *xwl_wl_surface); + xwl_wl_surface = XNFcallocarray(1, sizeof *xwl_wl_surface); xwl_wl_surface->wl_surface = xwl_window->surface; xorg_list_add(&xwl_wl_surface->link, &xwl_window->xwl_screen->pending_wl_surface_destroy); @@ -1634,28 +1654,15 @@ release_wl_surface_for_window(struct xwl_window *xwl_window) release_wl_surface_for_window_legacy_delay(xwl_window); } -Bool -xwl_unrealize_window(WindowPtr window) +static void +xwl_window_dispose(struct xwl_window *xwl_window) { - ScreenPtr screen = window->drawable.pScreen; - struct xwl_screen *xwl_screen; - struct xwl_window *xwl_window; + struct xwl_screen *xwl_screen = xwl_window->xwl_screen; struct xwl_seat *xwl_seat; - Bool ret; - - xwl_screen = xwl_screen_get(screen); - - xwl_window = xwl_window_get(window); - if (xwl_window) - compUnredirectWindow(serverClient, window, CompositeRedirectManual); - - screen->UnrealizeWindow = xwl_screen->UnrealizeWindow; - ret = (*screen->UnrealizeWindow) (window); - xwl_screen->UnrealizeWindow = screen->UnrealizeWindow; - screen->UnrealizeWindow = xwl_unrealize_window; + WindowPtr window = xwl_window->toplevel; + ScreenPtr screen = xwl_screen->screen; - if (!xwl_window) - return ret; + compUnredirectWindow(serverClient, window, CompositeRedirectManual); xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) { if (xwl_seat->focus_window == xwl_window) @@ -1695,9 +1702,10 @@ xwl_unrealize_window(WindowPtr window) release_wl_surface_for_window(xwl_window); xorg_list_del(&xwl_window->link_damage); xorg_list_del(&xwl_window->link_window); - unregister_damage(xwl_window); - xwl_window_buffers_dispose(xwl_window); + /* Special case for the root window in rootful mode */ + xwl_window_buffers_dispose(xwl_window, + (!xwl_screen->rootless && window == screen->root)); if (xwl_window->window_buffers_timer) TimerFree(xwl_window->window_buffers_timer); @@ -1709,6 +1717,25 @@ xwl_unrealize_window(WindowPtr window) free(xwl_window); dixSetPrivate(&window->devPrivates, &xwl_window_private_key, NULL); +} + +Bool +xwl_unrealize_window(WindowPtr window) +{ + ScreenPtr screen = window->drawable.pScreen; + struct xwl_screen *xwl_screen = xwl_screen_get(screen); + struct xwl_window *xwl_window = xwl_window_get(window); + Bool ret; + + if (xwl_window) { + unregister_damage(xwl_window); + xwl_window_dispose(xwl_window); + } + + screen->UnrealizeWindow = xwl_screen->UnrealizeWindow; + ret = (*screen->UnrealizeWindow) (window); + xwl_screen->UnrealizeWindow = screen->UnrealizeWindow; + screen->UnrealizeWindow = xwl_unrealize_window; return ret; } @@ -1740,7 +1767,7 @@ xwl_window_set_window_pixmap(WindowPtr window, old_pixmap->drawable.height == pixmap->drawable.height)) return; - xwl_window_buffers_dispose(xwl_window); + xwl_window_buffers_dispose(xwl_window, FALSE); } Bool @@ -1917,11 +1944,15 @@ xwl_destroy_window(WindowPtr window) { ScreenPtr screen = window->drawable.pScreen; struct xwl_screen *xwl_screen = xwl_screen_get(screen); + struct xwl_window *xwl_window = xwl_window_get(window); Bool ret; if (xwl_screen->present) xwl_present_cleanup(window); + if (xwl_window) + xwl_window_dispose(xwl_window); + screen->DestroyWindow = xwl_screen->DestroyWindow; if (screen->DestroyWindow) @@ -1946,7 +1977,7 @@ xwl_window_attach_buffer(struct xwl_window *xwl_window) PixmapPtr pixmap; int i; - pixmap = xwl_window_swap_pixmap(xwl_window); + pixmap = xwl_window_swap_pixmap(xwl_window, TRUE); buffer = xwl_pixmap_get_wl_buffer(pixmap); if (!buffer) { diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h index 30d49c699..ba5c3a078 100644 --- a/hw/xwayland/xwayland-window.h +++ b/hw/xwayland/xwayland-window.h @@ -34,6 +34,9 @@ #include <unistd.h> #include <X11/X.h> + +#include "dix/property_priv.h" + #include <dix.h> #include <propertyst.h> #include <validate.h> diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c index 4976a3d7e..4198e8d85 100644 --- a/hw/xwayland/xwayland-xtest.c +++ b/hw/xwayland/xwayland-xtest.c @@ -31,6 +31,8 @@ #include <libei.h> #include "dix/dix_priv.h" +#include "dix/input_priv.h" +#include "os/client_priv.h" #include <inputstr.h> #include <inpututils.h> @@ -360,11 +362,12 @@ setup_ei(ClientPtr client) } xwl_ei_client = calloc(1, sizeof *xwl_ei_client); - xwl_ei_client->cmdline = xstrdup(cmdname); if (!xwl_ei_client) { error_ei("OOM, cannot setup EI\n"); goto out; } + + xwl_ei_client->cmdline = Xstrdup(cmdname); xorg_list_init(&xwl_ei_client->link); ei = ei_new(NULL); @@ -726,6 +729,38 @@ xwl_dequeue_emulated_events(struct xwl_ei_client *xwl_ei_client) } static void +xwl_ei_update_caps(struct xwl_ei_client *xwl_ei_client, + struct ei_device *ei_device) +{ + struct xwl_abs_device *abs; + + if (ei_device == xwl_ei_client->ei_pointer) + xwl_ei_client->accept_pointer = true; + + if (ei_device == xwl_ei_client->ei_keyboard) + xwl_ei_client->accept_keyboard = true; + + xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices, link) { + if (ei_device == abs->device) + xwl_ei_client->accept_abs = true; + } +} + +static bool +xwl_ei_devices_are_ready(struct xwl_ei_client *xwl_ei_client) +{ + if ((xwl_ei_client->accept_keyboard || + !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_KEYBOARD)) && + (xwl_ei_client->accept_pointer || + !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_POINTER)) && + (xwl_ei_client->accept_abs || + !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_POINTER_ABSOLUTE))) + return true; + + return false; +} + +static void xwl_handle_ei_event(int fd, int ready, void *data) { struct xwl_ei_client *xwl_ei_client = data; @@ -830,32 +865,25 @@ xwl_handle_ei_event(int fd, int ready, void *data) break; case EI_EVENT_DEVICE_RESUMED: debug_ei("Device resumed\n"); - if (ei_device == xwl_ei_client->ei_pointer) - xwl_ei_client->accept_pointer = true; - if (ei_device == xwl_ei_client->ei_keyboard) - xwl_ei_client->accept_keyboard = true; - { - struct xwl_abs_device *abs; - - xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices, - link) { - if (ei_device == abs->device) - xwl_ei_client->accept_abs = true; - } - } - + xwl_ei_update_caps(xwl_ei_client, ei_device); /* Server has accepted our device (or resumed them), * we can now start sending events */ /* FIXME: Maybe add a timestamp and discard old events? */ - xwl_ei_start_emulating(xwl_ei_client); - xwl_dequeue_emulated_events(xwl_ei_client); + if (xwl_ei_devices_are_ready(xwl_ei_client)) { + xwl_ei_start_emulating(xwl_ei_client); + xwl_dequeue_emulated_events(xwl_ei_client); + } if (!xwl_ei_client->client && xorg_list_is_empty(&xwl_ei_client->pending_emulated_events)) /* All events dequeued and client has disconnected in the meantime */ xwl_ei_stop_emulating(xwl_ei_client); break; + case EI_EVENT_KEYBOARD_MODIFIERS: + debug_ei("Ignored event %s (%d)\n", ei_event_type_to_string(type), type); + /* Don't care */ + break; default: - error_ei("Unhandled event %d\n", type); + error_ei("Unhandled event %s (%d)\n", ei_event_type_to_string(type), type); break; } ei_event_unref(e); diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index cbd2437d6..1ff032287 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -25,7 +25,7 @@ #include <xwayland-config.h> -#if !defined(SYSV) && !defined(WIN32) +#if !defined(WIN32) #include <sys/resource.h> #endif @@ -33,12 +33,16 @@ #include <errno.h> #include <X11/Xatom.h> +#include <X11/Xfuncproto.h> #include "dix/dix_priv.h" #include "dix/screenint_priv.h" #include "os/cmdline.h" +#include "os/client_priv.h" #include "os/ddx_priv.h" +#include "os/fmt.h" #include "os/osdep.h" +#include "os/xserver_poll.h" #include <selection.h> #include <micmap.h> @@ -48,7 +52,6 @@ #include <glx_extinit.h> #include <opaque.h> #include <os.h> -#include <xserver_poll.h> #include <propertyst.h> #include <version-config.h> @@ -369,7 +372,7 @@ ProcXwlQueryVersion(ClientPtr client) swaps(&reply.minorVersion); } - WriteReplyToClient(client, sizeof(reply), &reply); + WriteToClient(client, sizeof(reply), &reply); return Success; } @@ -377,8 +380,6 @@ static int _X_COLD SProcXwlQueryVersion(ClientPtr client) { REQUEST(xXwlQueryVersionReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXwlQueryVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c index 6aced4f9c..c50464a60 100644 --- a/hw/xwin/InitInput.c +++ b/hw/xwin/InitInput.c @@ -29,6 +29,9 @@ #ifdef HAVE_XWIN_CONFIG_H #include <xwin-config.h> #endif + +#include "mi/mi_priv.h" + #include "win.h" #include "dixstruct_priv.h" #include "inputstr.h" diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 4d0bbdfa3..541503552 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -68,6 +68,8 @@ typedef WINAPI HRESULT(*SHGETFOLDERPATHPROC) (HWND hwndOwner, #include "extinit_priv.h" #include "pseudoramiX/pseudoramiX.h" +#include "dix/dix_priv.h" + #include "glx_extinit.h" #ifdef XWIN_GLX_WINDOWS #include "glx/glwindows.h" diff --git a/hw/xwin/dri/windowsdri.c b/hw/xwin/dri/windowsdri.c index 3666e97dd..5d4c5ea54 100644 --- a/hw/xwin/dri/windowsdri.c +++ b/hw/xwin/dri/windowsdri.c @@ -21,9 +21,7 @@ * IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> @@ -191,7 +189,6 @@ static int SProcWindowsDRIQueryVersion(ClientPtr client) { REQUEST(xWindowsDRIQueryVersionReq); - swaps(&stuff->length); return ProcWindowsDRIQueryVersion(client); } @@ -199,7 +196,6 @@ static int SProcWindowsDRIQueryDirectRenderingCapable(ClientPtr client) { REQUEST(xWindowsDRIQueryDirectRenderingCapableReq); - swaps(&stuff->length); swapl(&stuff->screen); return ProcWindowsDRIQueryDirectRenderingCapable(client); } @@ -208,7 +204,6 @@ static int SProcWindowsDRIQueryDrawable(ClientPtr client) { REQUEST(xWindowsDRIQueryDrawableReq); - swaps(&stuff->length); swapl(&stuff->screen); swapl(&stuff->drawable); return ProcWindowsDRIQueryDrawable(client); @@ -218,7 +213,6 @@ static int SProcWindowsDRIFBConfigToPixelFormat(ClientPtr client) { REQUEST(xWindowsDRIFBConfigToPixelFormatReq); - swaps(&stuff->length); swapl(&stuff->screen); swapl(&stuff->fbConfigID); return ProcWindowsDRIFBConfigToPixelFormat(client); diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man index 8d4af41db..385e90ceb 100644 --- a/hw/xwin/man/XWin.man +++ b/hw/xwin/man/XWin.man @@ -31,7 +31,8 @@ containing the whole screen but this root window (traditionally covered with an pattern) is hidden from view, so only top-level X windows are seen. .SH OPTIONS -In addition to the normal server options described in the \fIXserver(1)\fP +In addition to the normal server options described in the +.BR Xserver (1) manual page, \fIXWin\fP accepts the following command line switches, \fIall\fP of which are optional: @@ -110,7 +111,8 @@ Currently \fB\-fullscreen\fP may only be applied to one X screen. .TP 8 .B "\-icon" \fIicon-specifier\fP Override the window icon for the screen window from the default. -The \fIicon-specifier\fP is as defined in \fIXWinrc(@filemansuffix@)\fP. +The \fIicon-specifier\fP is as defined in +.BR XWinrc (@filemansuffix@). .TP 8 .B \-nodecoration Do not give the Cygwin/X window a \fIWindows\fP window border, title bar, @@ -292,8 +294,9 @@ fullscreen with a DirectDraw engine. This parameter is ignored if \fB\-fullscreen\fP is not specified. .SH MISCELLANEOUS OPTIONS -See also the normal server options described in the \fIXserver(1)\fP -manual page +See also the normal server options described in the +.BR Xserver (1) +manual page. .TP 8 .B \-help @@ -326,23 +329,29 @@ values will yield a still more detailed debug output. .TP 8 .B "\-xkbrules \fIrule\fP" .TP 8 -.B "\-xkbvariant \fIvariant\fp" +.B "\-xkbvariant \fIvariant\fP" These options configure the xkeyboard extension to load -a particular keyboard map as the X server starts. The behavior is similar -to the \fIsetxkbmap\fP(1) program. +a particular keyboard map as the X server starts. +The behavior is similar to the +.BR setxkbmap (1) +program. -See the \fIxkeyboard-config\fP(@miscmansuffix@) manual page for a list of -keyboard configurations. +See the +.BR xkeyboard\-config (@miscmansuffix@) +manual page for a list of keyboard configurations. -The keyboard layout data is located at \fI@datadir@/X11/xkb/\fP. Additional information -can be found in the README files there and in the \fIsetxkbmap\fP(1) manual page. +The keyboard layout data is located at \fI@datadir@/X11/xkb/\fP. +Additional information can be found in the README files there and in the +.BR setxkbmap (1) +manual page. For example, in order to load a German layout for a pc105 keyboard, use the options: .br .I " \-xkblayout de \-xkbmodel pc105" -Alternatively, you can use the \fIsetxkbmap\fP(1) program after \fIXWin\fP is -running. +Alternatively, you can use the +.BR setxkbmap (1) +program after \fIXWin\fP is running. The default is to select a keyboard configuration matching your current layout as reported by \fIWindows\fP, if known, or the default X server configuration @@ -385,17 +394,24 @@ window, in both the generic case and for particular programs. \fIXWin -multiwindow\fP produces for each top-level X-window. .br * To change the style that is associated to the \fIWindows\fP window that -\fXWin I-multiwindow\fP produces for each top-level X window. +\fIXWin -multiwindow\fP produces for each top-level X window. .PP -The format of the \fI.XWinrc\fP file is given in the XWinrc(5) manual page. +The format of the \fI.XWinrc\fP file is given in the +.BR XWinrc (5) +manual page. .SH EXAMPLES Need some examples .SH "SEE ALSO" -X(@miscmansuffix@), Xserver(1), xdm(1), xinit(1), XWinrc(@filemansuffix@), -setxkbmap(1), xkeyboard-config(@miscmansuffix@). +.BR X (@miscmansuffix@), +.BR Xserver (1), +.BR xdm (1), +.BR xinit (1), +.BR XWinrc (@filemansuffix@), +.BR setxkbmap (1), +.BR xkeyboard-config (@miscmansuffix@). .SH BUGS diff --git a/hw/xwin/man/XWinrc.man b/hw/xwin/man/XWinrc.man index 3c1ed067d..bff8f96d6 100644 --- a/hw/xwin/man/XWinrc.man +++ b/hw/xwin/man/XWinrc.man @@ -7,9 +7,10 @@ XWinrc\- XWin Server Resource Configuration File. .SH DESCRIPTION The X Server for the X Window System on the Cygwin/X environment -running on Microsoft Windows, \fIXWin\fP can be optionally configured -with the \fIXWinrc\fP file. A system-wide configuration file should -be placed in \fI +running on Microsoft Windows, +.BR XWin (1) +can be optionally configured with the \fIXWinrc\fP file. +A system-wide configuration file should be placed in \fI @sysconfdir@/X11/system.XWinrc\fP, a per-user file should be put at \fI$HOME/.XWinrc\fP. The \fIsystem.XWinrc\fP file is read only if no \fI$HOME/.XWinrc\fP exist. @@ -135,7 +136,6 @@ such items should be included at the start or at the end of the menu. .SH Icon Instructions When specifying an \fIicon-specifier\fP in the following commands several different formats are allowed: -.PP .IP \fI"NAME.ICO"\fP 16 filename of an .ico format file .br @@ -248,7 +248,7 @@ This example makes an oclock window frameless in \fI-multiwindow\fP mode .SH "SEE ALSO" - XWin(1) +.BR XWin (1) .SH AUTHOR diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 1c4af37e1..49a2031d3 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -139,9 +139,11 @@ #endif /* HAVE_MMAP */ #include <X11/X.h> +#include <X11/Xfuncproto.h> #include <X11/Xproto.h> #include <X11/Xos.h> #include <X11/Xprotostr.h> + #include "scrnintstr.h" #include "pixmapstr.h" #include "pixmap.h" diff --git a/hw/xwin/winallpriv.c b/hw/xwin/winallpriv.c index 1212cbba9..7e96ae3d8 100644 --- a/hw/xwin/winallpriv.c +++ b/hw/xwin/winallpriv.c @@ -58,7 +58,7 @@ winAllocatePrivates(ScreenPtr pScreen) } /* Allocate memory for the screen private structure */ - pScreenPriv = calloc(sizeof(winPrivScreenRec), 1); + pScreenPriv = calloc(1, sizeof(winPrivScreenRec)); if (!pScreenPriv) { ErrorF("winAllocateScreenPrivates - malloc () failed\n"); return FALSE; @@ -140,7 +140,7 @@ winAllocateCmapPrivates(ColormapPtr pCmap) } /* Allocate memory for our private structure */ - pCmapPriv = calloc(sizeof(winPrivCmapRec), 1); + pCmapPriv = calloc(1, sizeof(winPrivCmapRec)); if (!pCmapPriv) { ErrorF("winAllocateCmapPrivates - malloc () failed\n"); return FALSE; diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c index cac17153f..6a846902e 100644 --- a/hw/xwin/winclipboard/xevents.c +++ b/hw/xwin/winclipboard/xevents.c @@ -637,8 +637,7 @@ winClipboardFlushXEvents(HWND hwnd, if (xtpText_value) { free(xtpText_value); } - if (pszConvertData) - free(pszConvertData); + free(pszConvertData); if (hGlobal && pszGlobalData) GlobalUnlock(hGlobal); diff --git a/hw/xwin/winclipboard/xwinclip.man b/hw/xwin/winclipboard/xwinclip.man index f0c2fc32b..0f1d2c540 100644 --- a/hw/xwin/winclipboard/xwinclip.man +++ b/hw/xwin/winclipboard/xwinclip.man @@ -17,8 +17,14 @@ It also monitors the contents of the Windows clipboard for changes, taking owner CLIPBOARD selections, and making the contents of the Windows clipboard available in them. .B Note well: -The \fIXWin(1)\fP X server has internal clipboard integration that is enabled by default. -Do \fINOT\fP run \fIxwinclip\fP unless \fIXWin(1)\fP has been started with the -noclipboard option. +The +.BR XWin (1) +X server has internal clipboard integration that is enabled by default. +Do \fINOT\fP run \fIxwinclip\fP unless +.BR XWin (1) +has been started with the +.B -noclipboard +option. .SH OPTIONS \fIxwinclip\fP accepts the following optional command line switches: @@ -31,7 +37,7 @@ Specifies the X server display to connect to. Do not monitor the PRIMARY selection. .SH "SEE ALSO" -XWin(1) +.BR XWin (1) .SH BUGS Only text clipboard contents are supported. @@ -49,7 +55,9 @@ client which owns the selection to convert the selection to our requested format using a fixed timeout. After requesting conversion of the selection, if no events are received from the X client which owns the selection for one second, the conversion is assumed to have failed. -The XWin(1) server should indicate somehow (by placing an atom on the root window?) that it is running with its +The +.BR XWin (1) +server should indicate somehow (by placing an atom on the root window?) that it is running with its internal clipboard integration enabled, and xwinclip should notice this and exit with an appropriate error. Probably many other bugs. diff --git a/hw/xwin/wincmap.c b/hw/xwin/wincmap.c index df69ba78b..3567afad5 100644 --- a/hw/xwin/wincmap.c +++ b/hw/xwin/wincmap.c @@ -36,6 +36,8 @@ #endif #include "win.h" +#include "dix/colormap_priv.h" + /* * Local prototypes */ diff --git a/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c index e3238ae76..58247675f 100644 --- a/hw/xwin/wincreatewnd.c +++ b/hw/xwin/wincreatewnd.c @@ -31,6 +31,9 @@ #ifdef HAVE_XWIN_CONFIG_H #include <xwin-config.h> #endif + +#include "dix/dix_priv.h" + #include "win.h" #include "shellapi.h" diff --git a/hw/xwin/wincursor.c b/hw/xwin/wincursor.c index 3fc050bfa..6b42c990e 100644 --- a/hw/xwin/wincursor.c +++ b/hw/xwin/wincursor.c @@ -36,6 +36,9 @@ #endif #include "win.h" #include "winmsg.h" + +#include "mi/mipointer_priv.h" + #include <cursorstr.h> #include <mipointrst.h> #include <servermd.h> diff --git a/hw/xwin/windisplay.c b/hw/xwin/windisplay.c index 17f0c7789..52ece1d88 100644 --- a/hw/xwin/windisplay.c +++ b/hw/xwin/windisplay.c @@ -30,6 +30,8 @@ #endif #include <opaque.h> // for display +#include "dix/dix_priv.h" // for display + #include "windisplay.h" #include "winmsg.h" diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c index ed505e47d..bdf03f053 100644 --- a/hw/xwin/winerror.c +++ b/hw/xwin/winerror.c @@ -37,6 +37,8 @@ #include <../xfree86/common/xorgVersion.h> #include "win.h" +#include "dix/input_priv.h" + void OsVendorVErrorF(const char *pszFormat, va_list va_args) { @@ -48,7 +50,7 @@ OsVendorVErrorF(const char *pszFormat, va_list va_args) pthread_mutex_lock(&s_pmPrinting); /* Print the error message to a log file, could be stderr */ - LogVWrite(0, pszFormat, va_args); + LogVMessageVerb(X_NONE, 0, pszFormat, va_args); /* Unlock the printing mutex */ pthread_mutex_unlock(&s_pmPrinting); diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index 037ab1ecc..8956b859e 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -34,6 +34,9 @@ #ifdef HAVE_XWIN_CONFIG_H #include <xwin-config.h> #endif + +#include "mi/mi_priv.h" + #include "win.h" #include "dix/dix_priv.h" diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 4aca28930..24e226c51 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -1137,9 +1137,7 @@ winDestroyPixmapMultiwindow(PixmapPtr pPixmap) pPixmapPriv->pbmih = NULL; /* Free the pixmap memory */ - free(pPixmap); - pPixmap = NULL; - + FreePixmap(pPixmap); return TRUE; } diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index a50d96bfd..2d5ebc2f5 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -1395,9 +1395,9 @@ winInitWM(void **ppWMInfo, pthread_mutex_t * ppmServerStarted, int dwScreen, HWND hwndScreen, Bool compositeWM) { - WMProcArgPtr pArg = calloc(sizeof(WMProcArgRec), 1); - WMInfoPtr pWMInfo = calloc(sizeof(WMInfoRec), 1); - XMsgProcArgPtr pXMsgArg = calloc(sizeof(XMsgProcArgRec), 1); + WMProcArgPtr pArg = calloc(1, sizeof(WMProcArgRec)); + WMInfoPtr pWMInfo = calloc(1, sizeof(WMInfoRec)); + XMsgProcArgPtr pXMsgArg = calloc(1, sizeof(XMsgProcArgRec)); /* Bail if the input parameters are bad */ if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) { diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index d325727ac..edc1c0a03 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -39,6 +39,7 @@ #include "win.h" #include "dix/dix_priv.h" +#include "mi/mipointer_priv.h" #include "dixevents.h" #include "winmultiwindowclass.h" diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index 2884134b4..38ce01f08 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -36,6 +36,8 @@ #endif #include "win.h" +#include "dix/colormap_priv.h" + #define FAIL_MSG_MAX_BLT 10 /* @@ -1135,7 +1137,7 @@ winDestroyColormapShadowDDNL(ColormapPtr pColormap) * will not have had winUninstallColormap called on it. Thus, * we need to handle the default colormap in a special way. */ - if (pColormap->flags & IsDefault) { + if (pColormap->flags & CM_IsDefault) { #if ENABLE_DEBUG winDebug ("winDestroyColormapShadowDDNL - Destroying default colormap\n"); diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c index 6b61d85e3..f8317ad27 100644 --- a/hw/xwin/winshadgdi.c +++ b/hw/xwin/winshadgdi.c @@ -33,6 +33,8 @@ #endif #include "win.h" +#include "dix/colormap_priv.h" + /* * Local function prototypes */ @@ -1162,8 +1164,8 @@ winCreateColormapShadowGDI(ColormapPtr pColormap) dwEntriesMax = pVisual->ColormapEntries; /* Allocate a Windows logical color palette with max entries */ - lpPaletteNew = calloc(sizeof(LOGPALETTE) - + (dwEntriesMax - 1) * sizeof(PALETTEENTRY), 1); + lpPaletteNew = calloc(1, sizeof(LOGPALETTE) + + (dwEntriesMax - 1) * sizeof(PALETTEENTRY)); if (lpPaletteNew == NULL) { ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette " "with %d entries\n", (int) dwEntriesMax); @@ -1209,7 +1211,7 @@ winDestroyColormapShadowGDI(ColormapPtr pColormap) * will not have had winUninstallColormap called on it. Thus, * we need to handle the default colormap in a special way. */ - if (pColormap->flags & IsDefault) { + if (pColormap->flags & CM_IsDefault) { #if ENABLE_DEBUG winDebug("winDestroyColormapShadowGDI - Destroying default " "colormap\n"); diff --git a/hw/xwin/wintrayicon.c b/hw/xwin/wintrayicon.c index 5d1e6aefa..7da170d27 100644 --- a/hw/xwin/wintrayicon.c +++ b/hw/xwin/wintrayicon.c @@ -38,6 +38,8 @@ #include "winprefs.h" #include "winclipboard/winclipboard.h" +#include "dix/dix_priv.h" + /* * Initialize the tray icon */ diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 2509018b6..f15ab3a96 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -37,6 +37,9 @@ #endif #include "win.h" #include <commctrl.h> + +#include "mi/mipointer_priv.h" + #include "winprefs.h" #include "winconfig.h" #include "winmsg.h" diff --git a/include/client.h b/include/client.h index 87f2b1172..d71dc8d05 100644 --- a/include/client.h +++ b/include/client.h @@ -29,32 +29,8 @@ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif /* HAVE_DIX_CONFIG_H */ -#include <X11/Xfuncproto.h> -#include <sys/types.h> - -/* Client IDs. Use GetClientPid, GetClientCmdName and GetClientCmdArgs - * instead of accessing the fields directly. */ -typedef struct { - pid_t pid; /* process ID, -1 if not available */ - const char *cmdname; /* process name, NULL if not available */ - const char *cmdargs; /* process arguments, NULL if not available */ -} ClientIdRec, *ClientIdPtr; struct _Client; - -/* Initialize and clean up. */ -void ReserveClientIds(struct _Client *client); -void ReleaseClientIds(struct _Client *client); - -/* Determine client IDs for caching. Exported on purpose for - * extensions such as SELinux. */ -extern _X_EXPORT pid_t DetermineClientPid(struct _Client *client); -extern _X_EXPORT void DetermineClientCmd(pid_t, const char **cmdname, - const char **cmdargs); - -/* Query cached client IDs. Exported on purpose for drivers. */ -extern _X_EXPORT pid_t GetClientPid(struct _Client *client); -extern _X_EXPORT const char *GetClientCmdName(struct _Client *client); -extern _X_EXPORT const char *GetClientCmdArgs(struct _Client *client); +typedef struct _ClientId *ClientIdPtr; #endif /* CLIENT_H */ diff --git a/include/colormap.h b/include/colormap.h index dabfbd92c..e8da083ab 100644 --- a/include/colormap.h +++ b/include/colormap.h @@ -51,49 +51,10 @@ SOFTWARE. #include "screenint.h" #include "window.h" -/* these follow X.h's AllocNone and AllocAll */ -#define CM_PSCREEN 2 -#define CM_PWIN 3 -/* Passed internally in colormap.c */ -#define REDMAP 0 -#define GREENMAP 1 -#define BLUEMAP 2 -#define PSEUDOMAP 3 -#define AllocPrivate (-1) -#define AllocTemporary (-2) #define DynamicClass 1 -/* Values for the flags field of a colormap. These should have 1 bit set - * and not overlap */ -#define IsDefault 1 -#define AllAllocated 2 -#define BeingCreated 4 - typedef CARD32 Pixel; -/* moved to screenint.h: typedef struct _ColormapRec *ColormapPtr */ -typedef struct _colorResource *colorResourcePtr; - -extern _X_EXPORT int CreateColormap(Colormap /*mid */ , - ScreenPtr /*pScreen */ , - VisualPtr /*pVisual */ , - ColormapPtr * /*ppcmap */ , - int /*alloc */ , - int /*client */ ); - -extern _X_EXPORT int FreeColormap(void *pmap, - XID mid); - -extern _X_EXPORT int TellLostMap(WindowPtr pwin, - void *value); - -extern _X_EXPORT int TellGainedMap(WindowPtr pwin, - void *value); - -extern _X_EXPORT int CopyColormapAndFree(Colormap /*mid */ , - ColormapPtr /*pSrc */ , - int /*client */ ); - extern _X_EXPORT int AllocColor(ColormapPtr /*pmap */ , unsigned short * /*pred */ , unsigned short * /*pgreen */ , @@ -101,55 +62,6 @@ extern _X_EXPORT int AllocColor(ColormapPtr /*pmap */ , Pixel * /*pPix */ , int /*client */ ); -extern _X_EXPORT void FakeAllocColor(ColormapPtr /*pmap */ , - xColorItem * /*item */ ); - -extern _X_EXPORT void FakeFreeColor(ColormapPtr /*pmap */ , - Pixel /*pixel */ ); - -extern _X_EXPORT int QueryColors(ColormapPtr /*pmap */ , - int /*count */ , - Pixel * /*ppixIn */ , - xrgb * /*prgbList */ , - ClientPtr client); - -extern _X_EXPORT int FreeClientPixels(void *pcr, - XID fakeid); - -extern _X_EXPORT int AllocColorCells(int /*client */ , - ColormapPtr /*pmap */ , - int /*colors */ , - int /*planes */ , - Bool /*contig */ , - Pixel * /*ppix */ , - Pixel * /*masks */ ); - -extern _X_EXPORT int AllocColorPlanes(int /*client */ , - ColormapPtr /*pmap */ , - int /*colors */ , - int /*r */ , - int /*g */ , - int /*b */ , - Bool /*contig */ , - Pixel * /*pixels */ , - Pixel * /*prmask */ , - Pixel * /*pgmask */ , - Pixel * /*pbmask */ ); - -extern _X_EXPORT int FreeColors(ColormapPtr /*pmap */ , - int /*client */ , - int /*count */ , - Pixel * /*pixels */ , - Pixel /*mask */ ); - -extern _X_EXPORT int StoreColors(ColormapPtr /*pmap */ , - int /*count */ , - xColorItem * /*defs */ , - ClientPtr client); - -extern _X_EXPORT int IsMapInstalled(Colormap /*map */ , - WindowPtr /*pWin */ ); - extern _X_EXPORT Bool ResizeVisualArray(ScreenPtr /* pScreen */ , int /* new_vis_count */ , DepthPtr /* depth */ ); diff --git a/include/colormapst.h b/include/colormapst.h index 53b61cb22..78545f90d 100644 --- a/include/colormapst.h +++ b/include/colormapst.h @@ -91,8 +91,8 @@ typedef struct _ColormapRec { short class; /* PseudoColor or DirectColor */ XID mid; /* client's name for colormap */ ScreenPtr pScreen; /* screen map is associated with */ - short flags; /* 1 = IsDefault - * 2 = AllAllocated */ + short flags; /* 1 = CM_IsDefault + * 2 = CM_AllAllocated */ int freeRed; int freeGreen; int freeBlue; diff --git a/include/cursor.h b/include/cursor.h index d198f711d..50796d047 100644 --- a/include/cursor.h +++ b/include/cursor.h @@ -57,76 +57,15 @@ SOFTWARE. /* Provide support for alpha composited cursors */ #define ARGB_CURSOR -struct _DeviceIntRec; - typedef struct _Cursor *CursorPtr; +// FUN FACT: If you typedef a pointer type, like the `CursorPtr` above +// then `const CursorPtr` or `CursorPtr const` actually means `struct _Cursor *const`, a constant pointer +// which is probably not what you want(a pointer to constant). +// Maybe better just keep the `*` around, or you have to typedef a separate constPtr type. +typedef struct _Cursor const *ConstCursorPtr; typedef struct _CursorMetric *CursorMetricPtr; -extern _X_EXPORT CursorPtr rootCursor; - extern _X_EXPORT int FreeCursor(void *pCurs, XID cid); -extern _X_EXPORT CursorPtr RefCursor(CursorPtr /* cursor */); -extern _X_EXPORT CursorPtr UnrefCursor(CursorPtr /* cursor */); -extern _X_EXPORT int CursorRefCount(const CursorPtr /* cursor */); - -extern _X_EXPORT int AllocARGBCursor(unsigned char * /*psrcbits */ , - unsigned char * /*pmaskbits */ , - CARD32 * /*argb */ , - CursorMetricPtr /*cm */ , - unsigned /*foreRed */ , - unsigned /*foreGreen */ , - unsigned /*foreBlue */ , - unsigned /*backRed */ , - unsigned /*backGreen */ , - unsigned /*backBlue */ , - CursorPtr * /*ppCurs */ , - ClientPtr /*client */ , - XID /*cid */ ); - -extern _X_EXPORT int AllocGlyphCursor(Font /*source */ , - unsigned int /*sourceChar */ , - Font /*mask */ , - unsigned int /*maskChar */ , - unsigned /*foreRed */ , - unsigned /*foreGreen */ , - unsigned /*foreBlue */ , - unsigned /*backRed */ , - unsigned /*backGreen */ , - unsigned /*backBlue */ , - CursorPtr * /*ppCurs */ , - ClientPtr /*client */ , - XID /*cid */ ); - -extern _X_EXPORT CursorPtr CreateRootCursor(char * /*pfilename */ , - unsigned int /*glyph */ ); - -extern _X_EXPORT int ServerBitsFromGlyph(FontPtr /*pfont */ , - unsigned int /*ch */ , - CursorMetricPtr /*cm */ , - unsigned char ** /*ppbits */ ); - -extern _X_EXPORT Bool CursorMetricsFromGlyph(FontPtr /*pfont */ , - unsigned /*ch */ , - CursorMetricPtr /*cm */ ); - -extern _X_EXPORT void CheckCursorConfinement(WindowPtr /*pWin */ ); - -extern _X_EXPORT void NewCurrentScreen(struct _DeviceIntRec * /*pDev */ , - ScreenPtr /*newScreen */ , - int /*x */ , - int /*y */ ); - -extern _X_EXPORT Bool PointerConfinedToScreen(struct _DeviceIntRec * /* pDev */ - ); - -extern _X_EXPORT void GetSpritePosition(struct _DeviceIntRec * /* pDev */ , - int * /*px */ , - int * /*py */ ); - -#ifdef PANORAMIX -extern _X_EXPORT int XineramaGetCursorScreen(struct _DeviceIntRec *pDev); -#endif /* PANORAMIX */ - #endif /* CURSOR_H */ diff --git a/include/dix.h b/include/dix.h index f656e2796..65e66e06c 100644 --- a/include/dix.h +++ b/include/dix.h @@ -52,7 +52,6 @@ SOFTWARE. #include "window.h" #include "input.h" #include "cursor.h" -#include "geext.h" #include "events.h" #include <X11/extensions/XI.h> @@ -121,7 +120,7 @@ SOFTWARE. typedef struct _TimeStamp *TimeStampPtr; #ifndef _XTYPEDEF_CLIENTPTR -typedef struct _Client *ClientPtr; /* also in misc.h */ +typedef struct _Client *ClientPtr; #define _XTYPEDEF_CLIENTPTR #endif @@ -407,4 +406,15 @@ IsFloating(DeviceIntPtr dev); extern _X_EXPORT void *lastGLContext; +/** + * @brief get display string for given screen + * + * Entry point for drivers/modules that really need to know what + * display ID we're running on (eg. xrdp). + * + * @param pScreen pointer to ScreenRec to query. + * @return pointer to string, valid as long as the pScreen is, owned by DIX. + */ +_X_EXPORT const char *dixGetDisplayName(ScreenPtr *pScreen); + #endif /* DIX_H */ diff --git a/include/dixfontstr.h b/include/dixfontstr.h index eae1a3b58..dbf991d35 100644 --- a/include/dixfontstr.h +++ b/include/dixfontstr.h @@ -27,7 +27,6 @@ SOFTWARE. #include "servermd.h" #include "dixfont.h" #include <X11/fonts/fontstruct.h> -#include <X11/fonts/libxfont2.h> #include <X11/Xproto.h> /* for xQueryFontReply */ #define FONTCHARSET(font) (font) diff --git a/include/dixgrabs.h b/include/dixgrabs.h deleted file mode 100644 index dc1068fef..000000000 --- a/include/dixgrabs.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************ - -Copyright 1996 by Thomas E. Dickey <dickey@clark.net> - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of the above listed -copyright holder(s) not be used in advertising or publicity pertaining -to distribution of the software without specific, written prior -permission. - -THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD -TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE -LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ - -#ifndef DIXGRABS_H -#define DIXGRABS_H 1 - -struct _GrabParameters; - -extern void PrintDeviceGrabInfo(DeviceIntPtr dev); -extern void UngrabAllDevices(Bool kill_client); - -extern GrabPtr AllocGrab(const GrabPtr src); -extern void FreeGrab(GrabPtr grab); -extern Bool CopyGrab(GrabPtr dst, const GrabPtr src); - -extern GrabPtr CreateGrab(int /* client */ , - DeviceIntPtr /* device */ , - DeviceIntPtr /* modDevice */ , - WindowPtr /* window */ , - enum InputLevel /* grabtype */ , - GrabMask * /* mask */ , - struct _GrabParameters * /* param */ , - int /* type */ , - KeyCode /* keybut */ , - WindowPtr /* confineTo */ , - CursorPtr /* cursor */ ); - -extern _X_EXPORT int DeletePassiveGrab(void *value, - XID id); - -extern _X_EXPORT Bool GrabMatchesSecond(GrabPtr /* pFirstGrab */ , - GrabPtr /* pSecondGrab */ , - Bool /*ignoreDevice */ ); - -extern _X_EXPORT int AddPassiveGrabToList(ClientPtr /* client */ , - GrabPtr /* pGrab */ ); - -extern _X_EXPORT Bool DeletePassiveGrabFromList(GrabPtr /* pMinuendGrab */ ); - -extern Bool GrabIsPointerGrab(GrabPtr grab); -extern Bool GrabIsKeyboardGrab(GrabPtr grab); -extern Bool GrabIsGestureGrab(GrabPtr grab); -#endif /* DIXGRABS_H */ diff --git a/include/dixstruct.h b/include/dixstruct.h index 3607ea88a..66f6081b0 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -73,6 +73,8 @@ typedef struct _saveSet { #define SaveSetAssignToRoot(ss,tr) ((ss).toRoot = (tr)) #define SaveSetAssignMap(ss,m) ((ss).map = (m)) +struct _ClientId; + typedef struct _Client { void *requestBuffer; void *osPrivate; /* for OS layer, including scheduler */ @@ -109,7 +111,7 @@ typedef struct _Client { int smart_stop_tick; DeviceIntPtr clientPtr; - ClientIdPtr clientIds; + struct _ClientId *clientIds; int req_fds; } ClientRec; diff --git a/include/extinit.h b/include/extinit.h index a92aef935..1ad7cf1c3 100644 --- a/include/extinit.h +++ b/include/extinit.h @@ -73,9 +73,9 @@ extern _X_EXPORT Bool noDPMSExtension; extern _X_EXPORT Bool noGlxExtension; #endif -#ifdef PANORAMIX +#ifdef XINERAMA extern _X_EXPORT Bool noPanoramiXExtension; -#endif +#endif /* XINERAMA */ #ifdef RANDR extern _X_EXPORT Bool noRRExtension; diff --git a/include/extinit_priv.h b/include/extinit_priv.h index 186fe8ad2..3b150f6d7 100644 --- a/include/extinit_priv.h +++ b/include/extinit_priv.h @@ -8,8 +8,6 @@ #include "extinit.h" -extern Bool noGEExtension; - void CompositeExtensionInit(void); void DamageExtensionInit(void); void DbeExtensionInit(void); diff --git a/include/globals.h b/include/globals.h index 887e788c8..1ce5e8d39 100644 --- a/include/globals.h +++ b/include/globals.h @@ -30,8 +30,8 @@ extern _X_EXPORT char *SeatId; extern _X_EXPORT char *ConnectionInfo; extern _X_EXPORT sig_atomic_t inSignalContext; -#ifdef PANORAMIX +#ifdef XINERAMA extern _X_EXPORT Bool PanoramiXExtensionDisabledHack; -#endif +#endif /* XINERAMA */ #endif /* !_XSERV_GLOBAL_H_ */ diff --git a/include/hotplug.h b/include/hotplug.h index 6fe76c806..1b9e63c04 100644 --- a/include/hotplug.h +++ b/include/hotplug.h @@ -26,58 +26,9 @@ #ifndef HOTPLUG_H #define HOTPLUG_H -#include "list.h" +#include <X11/Xfuncproto.h> -extern _X_EXPORT void config_pre_init(void); extern _X_EXPORT void config_init(void); extern _X_EXPORT void config_fini(void); -/* Bump this each time you add something to the struct - * so that drivers can easily tell what is available - */ -#define ODEV_ATTRIBUTES_VERSION 1 - -struct OdevAttributes { - /* path to kernel device node - Linux e.g. /dev/dri/card0 */ - char *path; - - /* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ - char *syspath; - - /* DRI-style bus id */ - char *busid; - - /* Server managed FD */ - int fd; - - /* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ - int major; - - /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ - int minor; - - /* kernel driver name */ - char *driver; -}; - -/* Note starting with xserver 1.16 this function never fails */ -struct OdevAttributes * -config_odev_allocate_attributes(void); - -void -config_odev_free_attributes(struct OdevAttributes *attribs); - -typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs); -void config_odev_probe(config_odev_probe_proc_ptr probe_callback); - -#ifdef CONFIG_UDEV_KMS -void NewGPUDeviceRequest(struct OdevAttributes *attribs); -void DeleteGPUDeviceRequest(struct OdevAttributes *attribs); -#endif - -#define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0")) - -struct xf86_platform_device * -xf86_find_platform_device_by_devnum(int major, int minor); - #endif /* HOTPLUG_H */ diff --git a/include/input.h b/include/input.h index fd5b7c4df..de89ee37d 100644 --- a/include/input.h +++ b/include/input.h @@ -288,9 +288,6 @@ extern _X_EXPORT void set_button_down(DeviceIntPtr pDev, int button, int type); extern _X_EXPORT void set_button_up(DeviceIntPtr pDev, int button, int type); extern _X_EXPORT int button_is_down(DeviceIntPtr pDev, int button, int type); -extern void InitCoreDevices(void); -extern void InitXTestDevices(void); - extern _X_EXPORT DeviceIntPtr AddInputDevice(ClientPtr /*client */ , DeviceProc /*deviceProc */ , Bool /*autoStart */ ); @@ -303,13 +300,6 @@ extern _X_EXPORT Bool ActivateDevice(DeviceIntPtr /*device */ , extern _X_EXPORT Bool DisableDevice(DeviceIntPtr /*device */ , BOOL /* sendevent */ ); -extern void DisableAllDevices(void); -extern int InitAndStartDevices(void); - -extern void CloseDownDevices(void); -extern void AbortDevices(void); - -extern void UndisplayDevices(void); extern _X_EXPORT int RemoveDevice(DeviceIntPtr /*dev */ , BOOL /* sendevent */ ); @@ -329,11 +319,6 @@ extern _X_EXPORT Bool InitButtonClassDeviceStruct(DeviceIntPtr /*device */ , Atom * /* labels */ , CARD8 * /*map */ ); -extern _X_INTERNAL ValuatorClassPtr AllocValuatorClass(ValuatorClassPtr src, - int numAxes); -extern _X_INTERNAL void FreeDeviceClass(int type, void **class); - - extern _X_EXPORT Bool InitValuatorClassDeviceStruct(DeviceIntPtr /*device */ , int /*numAxes */ , Atom * /* labels */ , @@ -430,30 +415,6 @@ extern _X_EXPORT Bool InitKeyboardDeviceStructFromString(DeviceIntPtr dev, BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func); -extern int ApplyPointerMapping(DeviceIntPtr /* pDev */ , - CARD8 * /* map */ , - int /* len */ , - ClientPtr /* client */ ); - -extern Bool BadDeviceMap(BYTE * /*buff */ , - int /*length */ , - unsigned /*low */ , - unsigned /*high */ , - XID * /*errval */ ); - -extern void NoteLedState(DeviceIntPtr /*keybd */ , - int /*led */ , - Bool /*on */ ); - -extern void MaybeStopHint(DeviceIntPtr /*device */ , - ClientPtr /*client */ ); - -extern void ProcessPointerEvent(InternalEvent * /* ev */ , - DeviceIntPtr /*mouse */ ); - -extern void ProcessKeyboardEvent(InternalEvent * /*ev */ , - DeviceIntPtr /*keybd */ ); - extern _X_EXPORT void ProcessInputEvents(void); extern _X_EXPORT void InitInput(int /*argc */ , @@ -465,14 +426,6 @@ extern _X_EXPORT int GetMaximumEventsNum(void); extern _X_EXPORT InternalEvent *InitEventList(int num_events); extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events); -extern void CreateClassesChangedEvent(InternalEvent *event, - DeviceIntPtr master, - DeviceIntPtr slave, int flags); - -extern InternalEvent *UpdateFromMaster(InternalEvent *events, - DeviceIntPtr pDev, - int type, int *num_events); - extern _X_EXPORT int GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, @@ -493,54 +446,6 @@ extern _X_EXPORT void QueueKeyboardEvents(DeviceIntPtr pDev, int type, int key_code); -extern int GetTouchEvents(InternalEvent *events, - DeviceIntPtr pDev, - uint32_t ddx_touchid, - uint16_t type, - uint32_t flags, const ValuatorMask *mask); - -void QueueTouchEvents(DeviceIntPtr device, - int type, - uint32_t ddx_touchid, - int flags, const ValuatorMask *mask); - -void InitGestureEvent(InternalEvent *ievent, DeviceIntPtr dev, CARD32 ms, - int type, uint16_t num_touches, uint32_t flags, - double delta_x, double delta_y, - double delta_unaccel_x, double delta_unaccel_y, - double scale, double delta_angle); - -int GetGestureEvents(InternalEvent *events, DeviceIntPtr dev, - uint16_t type, uint16_t num_touches, uint32_t flags, - double delta_x, double delta_y, - double delta_unaccel_x, - double delta_unaccel_y, - double scale, double delta_angle); - - -void QueueGesturePinchEvents(DeviceIntPtr dev, uint16_t type, - uint16_t num_touches, uint32_t flags, - double delta_x, double delta_y, - double delta_unaccel_x, - double delta_unaccel_y, - double scale, double delta_angle); - -void QueueGestureSwipeEvents(DeviceIntPtr dev, uint16_t type, - uint16_t num_touches, uint32_t flags, - double delta_x, double delta_y, - double delta_unaccel_x, - double delta_unaccel_y); - -extern int GetTouchOwnershipEvents(InternalEvent *events, - DeviceIntPtr pDev, - TouchPointInfoPtr ti, - uint8_t mode, XID resource, uint32_t flags); - -extern void GetDixTouchEnd(InternalEvent *ievent, - DeviceIntPtr dev, - TouchPointInfoPtr ti, - uint32_t flags); - extern _X_EXPORT int GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask); @@ -548,12 +453,6 @@ extern _X_EXPORT int GetProximityEvents(InternalEvent *events, extern _X_EXPORT void QueueProximityEvents(DeviceIntPtr pDev, int type, const ValuatorMask *mask); -#ifdef PANORAMIX -_X_EXPORT -#endif -extern void PostSyntheticMotion(DeviceIntPtr pDev, - int x, int y, int screen, unsigned long time); - extern _X_EXPORT int GetMotionHistorySize(void); extern _X_EXPORT void AllocateMotionHistory(DeviceIntPtr pDev); @@ -564,11 +463,6 @@ extern _X_EXPORT int GetMotionHistory(DeviceIntPtr pDev, unsigned long stop, ScreenPtr pScreen, BOOL core); -extern void ReleaseButtonsAndKeys(DeviceIntPtr dev); - -extern int AttachDevice(ClientPtr client, - DeviceIntPtr slave, DeviceIntPtr master); - extern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd); extern _X_EXPORT DeviceIntPtr GetMaster(DeviceIntPtr dev, int type); @@ -578,25 +472,11 @@ extern _X_EXPORT int AllocDevicePair(ClientPtr client, DeviceIntPtr *keybd, DeviceProc ptr_proc, DeviceProc keybd_proc, Bool master); -extern void DeepCopyDeviceClasses(DeviceIntPtr from, - DeviceIntPtr to, DeviceChangedEvent *dce); /* Helper functions. */ extern _X_EXPORT int generate_modkeymap(ClientPtr client, DeviceIntPtr dev, KeyCode **modkeymap, int *max_keys_per_mod); -extern int change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *map, - int max_keys_per_mod); -extern int AllocXTestDevice(ClientPtr client, const char *name, - DeviceIntPtr *ptr, DeviceIntPtr *keybd, - DeviceIntPtr master_ptr, DeviceIntPtr master_keybd); -extern BOOL IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master); -extern DeviceIntPtr GetXTestDevice(DeviceIntPtr master); -extern void SendDevicePresenceEvent(int deviceid, int type); -extern void DeliverDeviceClassesChangedEvent(int sourceid, Time time); -extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes * - attrs); -extern _X_EXPORT void FreeInputAttributes(InputAttributes * attrs); enum TouchListenerState { TOUCH_LISTENER_AWAITING_BEGIN = 0, /**< Waiting for a TouchBegin event */ @@ -622,103 +502,10 @@ enum GestureListenerType { GESTURE_LISTENER_REGULAR }; -extern void TouchInitDDXTouchPoint(DeviceIntPtr dev, - DDXTouchPointInfoPtr ddxtouch); -extern DDXTouchPointInfoPtr TouchBeginDDXTouch(DeviceIntPtr dev, - uint32_t ddx_id); -extern void TouchEndDDXTouch(DeviceIntPtr dev, DDXTouchPointInfoPtr ti); -extern DDXTouchPointInfoPtr TouchFindByDDXID(DeviceIntPtr dev, - uint32_t ddx_id, Bool create); -extern Bool TouchInitTouchPoint(TouchClassPtr touch, ValuatorClassPtr v, - int index); -extern void TouchFreeTouchPoint(DeviceIntPtr dev, int index); -extern TouchPointInfoPtr TouchBeginTouch(DeviceIntPtr dev, int sourceid, - uint32_t touchid, - Bool emulate_pointer); -extern TouchPointInfoPtr TouchFindByClientID(DeviceIntPtr dev, - uint32_t client_id); -extern void TouchEndTouch(DeviceIntPtr dev, TouchPointInfoPtr ti); -extern Bool TouchEventHistoryAllocate(TouchPointInfoPtr ti); -extern void TouchEventHistoryFree(TouchPointInfoPtr ti); -extern void TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev); -extern void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, - XID resource); -extern Bool TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource); -extern void TouchAddListener(TouchPointInfoPtr ti, XID resource, int resource_type, - enum InputLevel level, enum TouchListenerType type, - enum TouchListenerState state, WindowPtr window, GrabPtr grab); -extern Bool TouchRemoveListener(TouchPointInfoPtr ti, XID resource); -extern void TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti, - InternalEvent *ev); -extern Bool TouchBuildSprite(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, - InternalEvent *ev); -extern Bool TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite); -extern int TouchConvertToPointerEvent(const InternalEvent *ev, - InternalEvent *motion, - InternalEvent *button); -extern int TouchGetPointerEventType(const InternalEvent *ev); -extern void TouchRemovePointerGrab(DeviceIntPtr dev); -extern void TouchListenerGone(XID resource); -extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, - int listener, int mode); -extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode, - uint32_t touchid, Window grab_window, XID *error); -extern void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev); -extern void TouchEmitTouchEnd(DeviceIntPtr dev, TouchPointInfoPtr ti, int flags, XID resource); -extern void TouchAcceptAndEnd(DeviceIntPtr dev, int touchid); - -extern Bool GestureInitGestureInfo(GestureInfoPtr gesture); -extern void GestureFreeGestureInfo(GestureInfoPtr gesture); -extern GestureInfoPtr GestureBeginGesture(DeviceIntPtr dev, InternalEvent *ev); -extern GestureInfoPtr GestureFindActiveByEventType(DeviceIntPtr dev, int type); -extern void GestureEndGesture(GestureInfoPtr gi); -extern Bool GestureResourceIsOwner(GestureInfoPtr gi, XID resource); -extern void GestureAddListener(GestureInfoPtr gi, XID resource, int resource_type, - enum GestureListenerType type, - WindowPtr window, GrabPtr grab); -extern void GestureSetupListener(DeviceIntPtr dev, GestureInfoPtr gi, - InternalEvent *ev); -extern Bool GestureBuildSprite(DeviceIntPtr sourcedev, GestureInfoPtr gi); -extern void GestureListenerGone(XID resource); -extern void GestureEndActiveGestures(DeviceIntPtr dev); -extern void GestureEmitGestureEndToOwner(DeviceIntPtr dev, GestureInfoPtr gi); -extern void ProcessGestureEvent(InternalEvent *ev, DeviceIntPtr dev); - -/* misc event helpers */ -extern void CopyPartialInternalEvent(InternalEvent* dst_event, const InternalEvent* src_event); -extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients); -extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event); -extern Bool WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent *ev); -extern int GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type); -void FixUpEventFromWindow(SpritePtr pSprite, - xEvent *xE, - WindowPtr pWin, Window child, Bool calcChild); -extern Bool PointInBorderSize(WindowPtr pWin, int x, int y); -extern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y); -extern int EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win); -extern Bool ActivatePassiveGrab(DeviceIntPtr dev, GrabPtr grab, - InternalEvent *ev, InternalEvent *real_event); -extern void ActivateGrabNoDelivery(DeviceIntPtr dev, GrabPtr grab, - InternalEvent *event, - InternalEvent *real_event); -/** - * Masks specifying the type of event to deliver for an InternalEvent; used - * by EventIsDeliverable. - * @defgroup EventIsDeliverable return flags - * @{ - */ -#define EVENT_XI1_MASK (1 << 0) /**< XI1.x event */ -#define EVENT_CORE_MASK (1 << 1) /**< Core event */ -#define EVENT_DONT_PROPAGATE_MASK (1 << 2) /**< DontPropagate mask set */ -#define EVENT_XI2_MASK (1 << 3) /**< XI2 mask set on window */ -/* @} */ - -enum EventDeliveryState { - EVENT_DELIVERED, /**< Event has been delivered to a client */ - EVENT_NOT_DELIVERED, /**< Event was not delivered to any client */ - EVENT_SKIP, /**< Event can be discarded by the caller */ - EVENT_REJECTED, /**< Event was rejected for delivery to the client */ -}; +extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes * + attrs); + +extern _X_EXPORT void FreeInputAttributes(InputAttributes * attrs); /* Implemented by the DDX. */ extern _X_EXPORT int NewInputDeviceRequest(InputOption *options, @@ -726,22 +513,7 @@ extern _X_EXPORT int NewInputDeviceRequest(InputOption *options, DeviceIntPtr *dev); extern _X_EXPORT void DeleteInputDeviceRequest(DeviceIntPtr dev); extern _X_EXPORT void RemoveInputDeviceTraces(const char *config_info); - extern _X_EXPORT void DDXRingBell(int volume, int pitch, int duration); - -#define VALUATOR_MODE_ALL_AXES -1 -extern _X_HIDDEN int valuator_get_mode(DeviceIntPtr dev, int axis); -extern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode); - -/* Set to TRUE by default - os/utils.c sets it to FALSE on user request, - xfixes/cursor.c uses it to determine if the cursor is enabled */ -extern Bool EnableCursor; - -/* Set to FALSE by default - ChangeWindowAttributes sets it to TRUE on - * CWCursor, xfixes/cursor.c uses it to determine if the cursor is enabled - */ -extern Bool CursorVisible; - extern _X_EXPORT ValuatorMask *valuator_mask_new(int num_valuators); extern _X_EXPORT void valuator_mask_free(ValuatorMask **mask); extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask, @@ -783,8 +555,6 @@ extern _X_EXPORT Bool valuator_mask_fetch_unaccelerated(const ValuatorMask *mask int valuator, double *accel, double *unaccel); -extern _X_HIDDEN void valuator_mask_drop_unaccelerated(ValuatorMask *mask); - /* InputOption handling interface */ extern _X_EXPORT InputOption *input_option_new(InputOption *list, const char *key, @@ -800,30 +570,11 @@ extern _X_EXPORT void input_option_set_key(InputOption *opt, const char *key); extern _X_EXPORT void input_option_set_value(InputOption *opt, const char *value); -extern _X_HIDDEN Bool point_on_screen(ScreenPtr pScreen, int x, int y); -extern _X_HIDDEN void update_desktop_dimensions(void); - -extern _X_HIDDEN void input_constrain_cursor(DeviceIntPtr pDev, ScreenPtr screen, - int current_x, int current_y, - int dest_x, int dest_y, - int *out_x, int *out_y, - int *nevents, InternalEvent* events); - extern _X_EXPORT void input_lock(void); extern _X_EXPORT void input_unlock(void); extern _X_EXPORT void input_force_unlock(void); extern _X_EXPORT int in_input_thread(void); -extern void InputThreadPreInit(void); -extern void InputThreadInit(void); -extern void InputThreadFini(void); - -extern int InputThreadRegisterDev(int fd, - NotifyFdProcPtr readInputProc, - void *readInputArgs); - -extern int InputThreadUnregisterDev(int fd); - extern _X_EXPORT Bool InputThreadEnable; #endif /* INPUT_H */ diff --git a/include/inputstr.h b/include/inputstr.h index 24dd48841..6ed2d928d 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -54,7 +54,6 @@ SOFTWARE. #include "window.h" #include "dixstruct.h" #include "cursorstr.h" -#include "geext.h" #include "privates.h" extern _X_EXPORT void AssignTypeAndName(DeviceIntPtr dev, @@ -223,13 +222,13 @@ typedef struct _SpriteRec { WindowPtr win; /* window of logical position */ HotSpot hot; /* logical pointer position */ HotSpot hotPhys; /* physical pointer position */ -#ifdef PANORAMIX +#ifdef XINERAMA ScreenPtr screen; /* all others are in Screen 0 coordinates */ RegionRec Reg1; /* Region 1 for confining motion */ RegionRec Reg2; /* Region 2 for confining virtual motion */ WindowPtr windows[MAXSCREENS]; WindowPtr confineWin; /* confine window */ -#endif +#endif /* XINERAMA */ /* The window trace information is used at dix/events.c to avoid having * to compute all the windows between the root and the current pointer * window each time a button or key goes down. The grabs on each of those @@ -500,18 +499,6 @@ typedef struct _XIPropertyHandler { int (*DeleteProperty) (DeviceIntPtr dev, Atom property); } XIPropertyHandler, *XIPropertyHandlerPtr; -/* states for devices */ - -#define NOT_GRABBED 0 -#define THAWED 1 -#define THAWED_BOTH 2 /* not a real state */ -#define FREEZE_NEXT_EVENT 3 -#define FREEZE_BOTH_NEXT_EVENT 4 -#define FROZEN 5 /* any state >= has device frozen */ -#define FROZEN_NO_EVENT 5 -#define FROZEN_WITH_EVENT 6 -#define THAW_OTHERS 7 - typedef struct _GrabInfoRec { TimeStamp grabTime; Bool fromPassiveGrab; /* true if from passive grab */ @@ -631,6 +618,8 @@ typedef struct _DeviceIntRec { DeviceSendEventsProc sendEventsProc; struct _SyncCounter *idle_counter; + + Bool ignoreXkbActionsBehaviors; /* TRUE if keys don't trigger behaviors and actions */ } DeviceIntRec; typedef struct { diff --git a/include/meson.build b/include/meson.build index 9f84f2b95..994b4cfba 100644 --- a/include/meson.build +++ b/include/meson.build @@ -146,11 +146,13 @@ conf_data.set('HAVE_GETUID', cc.has_function('getuid') ? '1' : false) conf_data.set('HAVE_GETEUID', cc.has_function('geteuid') ? '1' : false) conf_data.set('HAVE_ISASTREAM', cc.has_function('isastream') ? '1' : false) conf_data.set('HAVE_ISSETUGID', cc.has_function('issetugid') ? '1' : false) +conf_data.set('HAVE_GETADDRINFO', cc.has_function('getaddrinfo') ? '1' : false) conf_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs') ? '1' : false) conf_data.set('HAVE_GETPEEREID', cc.has_function('getpeereid') ? '1' : false) conf_data.set('HAVE_GETPEERUCRED', cc.has_function('getpeerucred') ? '1' : false) conf_data.set('HAVE_GETPROGNAME', cc.has_function('getprogname') ? '1' : false) conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid') ? '1' : false) +conf_data.set('HAVE_INET_NTOP', cc.has_function('inet_ntop') ? '1' : false) conf_data.set('HAVE_MEMFD_CREATE', cc.has_function('memfd_create') ? '1' : false) conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp') ? '1' : false) conf_data.set('HAVE_MMAP', cc.has_function('mmap') ? '1' : false) @@ -165,17 +167,22 @@ conf_data.set('HAVE_SETITIMER', cc.has_function('setitimer') ? '1' : false) conf_data.set('HAVE_SHMCTL64', cc.has_function('shmctl64') ? '1' : false) conf_data.set('HAVE_SIGACTION', cc.has_function('sigaction') ? '1' : false) conf_data.set('HAVE_SIGPROCMASK', cc.has_function('sigprocmask') ? '1' : false) +# HAVE_SOCKLEN_T is used by xtrans when IPv6 is disabled +conf_data.set('HAVE_SOCKLEN_T', cc.has_type('socklen_t', prefix: '#include <sys/socket.h>') ? '1' : false) conf_data.set('HAVE_STRCASECMP', cc.has_function('strcasecmp') ? '1' : false) conf_data.set('HAVE_STRCASESTR', cc.has_function('strcasestr') ? '1' : false) conf_data.set('HAVE_STRLCAT', cc.has_function('strlcat', dependencies: libbsd_dep) ? '1' : false) conf_data.set('HAVE_STRLCPY', cc.has_function('strlcpy', dependencies: libbsd_dep) ? '1' : false) conf_data.set('HAVE_STRNCASECMP', cc.has_function('strncasecmp') ? '1' : false) conf_data.set('HAVE_STRNDUP', cc.has_function('strndup') and cc.has_header_symbol('string.h', 'strndup') ? '1' : false) +# HAVE_STRUCT_SOCKADDR_STORAGE is used by xtrans >= 1.6 +conf_data.set('HAVE_STRUCT_SOCKADDR_STORAGE', cc.has_type('struct sockaddr_storage', prefix: '#include <sys/socket.h>') ? '1' : false) conf_data.set('HAVE_TIMINGSAFE_MEMCMP', cc.has_function('timingsafe_memcmp') ? '1' : false) conf_data.set('HAVE_VASPRINTF', cc.has_function('vasprintf') ? '1' : false) conf_data.set('HAVE_VSNPRINTF', cc.has_function('vsnprintf') ? '1' : false) conf_data.set('HAVE_WALKCONTEXT', cc.has_function('walkcontext') ? '1' : false) conf_data.set('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include <sys/ucred.h>') ? '1' : false) +conf_data.set('LOCK_SERVER', host_machine.system() != 'windows' ? '1' : false) # Don't let X dependencies typedef 'pointer' conf_data.set('_XTYPEDEF_POINTER', '1') @@ -199,7 +206,6 @@ conf_data.set('TCPCONN', '1') conf_data.set('UNIXCONN', host_machine.system() != 'windows' ? '1' : false) conf_data.set('IPv6', build_ipv6 ? '1' : false) -conf_data.set('BIGREQS', '1') conf_data.set('COMPOSITE', '1') conf_data.set('DAMAGE', '1') conf_data.set('DBE', '1') @@ -211,7 +217,11 @@ if build_glx conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_variable(pkgconfig : 'dridriverdir')) endif conf_data.set('MITSHM', build_mitshm ? '1' : false) + +# for backwards compat with drivers, still setting the old PANORAMIX symbol conf_data.set('PANORAMIX', build_xinerama ? '1' : false) +conf_data.set('XINERAMA', build_xinerama ? '1' : false) + conf_data.set('PRESENT', '1') conf_data.set('RANDR', '1') conf_data.set('RES', build_res ? '1' : false) @@ -294,7 +304,6 @@ if host_machine.system() == 'kfreebsd' endif if host_machine.system() == 'netbsd' - supports_pccons = true supports_pcvt = true supports_wscons = true csrg_based = true @@ -438,7 +447,6 @@ endif if build_xorg install_data( [ - 'XIstubs.h', 'Xprintf.h', 'callback.h', 'client.h', @@ -453,7 +461,6 @@ if build_xorg 'dixevents.h', 'dixfont.h', 'dixfontstr.h', - 'dixgrabs.h', 'dixstruct.h', 'events.h', 'exevents.h', @@ -492,7 +499,6 @@ if build_xorg 'displaymode.h', 'window.h', 'windowstr.h', - 'xkbfile.h', 'xkbsrv.h', 'xkbstr.h', 'xkbrules.h', diff --git a/include/misc.h b/include/misc.h index 795cf1890..ba179ff87 100644 --- a/include/misc.h +++ b/include/misc.h @@ -176,17 +176,6 @@ typedef struct _xReq *xReqPtr; #endif -#ifndef PATH_MAX -#include <sys/param.h> -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif -#endif - /** * Calculate the number of bytes needed to hold bits. * @param bits The minimum number of bits needed. @@ -234,31 +223,8 @@ padding_for_int32(const int bytes) return ((-bytes) & 3); } - extern _X_EXPORT char **xstrtokenize(const char *str, const char *separators); -/** - * Compare the two version numbers comprising of major.minor. - * - * @return A value less than 0 if a is less than b, 0 if a is equal to b, - * or a value greater than 0 - */ -static inline int -version_compare(uint32_t a_major, uint32_t a_minor, - uint32_t b_major, uint32_t b_minor) -{ - if (a_major > b_major) - return 1; - if (a_major < b_major) - return -1; - if (a_minor > b_minor) - return 1; - if (a_minor < b_minor) - return -1; - - return 0; -} - /* some macros to help swap requests, replies, and events */ #define LengthRestB(stuff) \ @@ -388,10 +354,6 @@ extern _X_EXPORT void SwapLongs(CARD32 *list, unsigned long count); extern _X_EXPORT void SwapShorts(short *list, unsigned long count); -extern _X_EXPORT void MakePredeclaredAtoms(void); - -extern _X_EXPORT int Ones(unsigned long /*mask */ ); - typedef struct _xPoint *DDXPointPtr; typedef struct pixman_box16 *BoxPtr; typedef struct _xEvent *xEventPtr; diff --git a/include/opaque.h b/include/opaque.h index b17380915..7850792e8 100644 --- a/include/opaque.h +++ b/include/opaque.h @@ -33,47 +33,8 @@ from The Open Group. #include "globals.h" -extern _X_EXPORT int LimitClients; -extern _X_EXPORT volatile char isItTimeToYield; -extern _X_EXPORT volatile char dispatchException; - -/* bit values for dispatchException */ -#define DE_RESET 1 -#define DE_TERMINATE 2 -#define DE_PRIORITYCHANGE 4 /* set when a client's priority changes */ - -extern _X_EXPORT int ScreenSaverBlanking; -extern _X_EXPORT int ScreenSaverAllowExposures; -extern _X_EXPORT int defaultScreenSaverBlanking; -extern _X_EXPORT int defaultScreenSaverAllowExposures; -extern _X_EXPORT const char *display; -extern _X_EXPORT int displayfd; -extern _X_EXPORT Bool explicit_display; - -extern _X_EXPORT Bool disableBackingStore; -extern _X_EXPORT Bool enableBackingStore; +// needed by libglx and libglamor (server modules) extern _X_EXPORT Bool enableIndirectGLX; -extern _X_EXPORT Bool PartialNetwork; -extern _X_EXPORT Bool RunFromSigStopParent; - -#ifdef RLIMIT_DATA -extern _X_EXPORT int limitDataSpace; -#endif -#ifdef RLIMIT_STACK -extern _X_EXPORT int limitStackSpace; -#endif -#ifdef RLIMIT_NOFILE -extern _X_EXPORT int limitNoFile; -#endif -extern _X_EXPORT Bool defeatAccessControl; -extern _X_EXPORT Bool whiteRoot; extern _X_EXPORT Bool bgNoneRoot; -extern _X_EXPORT Bool CoreDump; -extern _X_EXPORT Bool NoListenAll; - -extern _X_EXPORT Bool AllowByteSwappedClients; - -extern Bool party_like_its_1989; /* -retro mode */ - #endif /* OPAQUE_H */ diff --git a/include/os.h b/include/os.h index 7a4bc2351..3949ff5aa 100644 --- a/include/os.h +++ b/include/os.h @@ -50,14 +50,14 @@ SOFTWARE. #include "misc.h" #include <stdarg.h> #include <stdint.h> -#if defined(HAVE_REALLOCARRAY) -#include <stdlib.h> /* for reallocarray */ -#endif +#include <stdlib.h> #include <string.h> #ifdef MONOTONIC_CLOCK #include <time.h> #endif +#include <X11/Xfuncproto.h> + #define SCREEN_SAVER_ON 0 #define SCREEN_SAVER_OFF 1 #define SCREEN_SAVER_FORCER 2 @@ -79,56 +79,18 @@ typedef struct _NewClientRec *NewClientPtr; #define xnfstrdup(s) XNFstrdup(s) #define xallocarray(num, size) reallocarray(NULL, (num), (size)) -#define xnfallocarray(num, size) XNFreallocarray(NULL, (num), (size)) -#define xnfreallocarray(ptr, num, size) XNFreallocarray((ptr), (num), (size)) #endif #include <stdio.h> #include <stdarg.h> -extern _X_EXPORT Bool WaitForSomething(Bool clients_are_ready); - -extern _X_EXPORT int ReadRequestFromClient(ClientPtr /*client */ ); - extern _X_EXPORT int ReadFdFromClient(ClientPtr client); -extern _X_EXPORT int WriteFdToClient(ClientPtr client, int fd, Bool do_close); - -extern _X_EXPORT Bool InsertFakeRequest(ClientPtr /*client */ , - char * /*data */ , - int /*count */ ); - -extern _X_EXPORT void ResetCurrentRequest(ClientPtr /*client */ ); - -extern _X_EXPORT void FlushAllOutput(void); - -extern _X_EXPORT void FlushIfCriticalOutputPending(void); - extern _X_EXPORT void SetCriticalOutputPending(void); extern _X_EXPORT int WriteToClient(ClientPtr /*who */ , int /*count */ , const void * /*buf */ ); -extern _X_EXPORT void ResetOsBuffers(void); - -extern _X_EXPORT void NotifyParentProcess(void); - -extern _X_EXPORT void CreateWellKnownSockets(void); - -extern _X_EXPORT void ResetWellKnownSockets(void); - -extern _X_EXPORT void CloseWellKnownConnections(void); - -extern _X_EXPORT XID AuthorizationIDOfClient(ClientPtr /*client */ ); - -extern _X_EXPORT const char *ClientAuthorized(ClientPtr /*client */ , - unsigned int /*proto_n */ , - char * /*auth_proto */ , - unsigned int /*string_n */ , - char * /*auth_string */ ); - -extern _X_EXPORT void CloseDownConnection(ClientPtr /*client */ ); - typedef void (*NotifyFdProcPtr)(int fd, int ready, void *data); #define X_NOTIFY_NONE 0x0 @@ -147,10 +109,6 @@ extern _X_EXPORT void IgnoreClient(ClientPtr /*client */ ); extern _X_EXPORT void AttendClient(ClientPtr /*client */ ); -extern _X_EXPORT void ListenOnOpenFD(int /* fd */ , int /* noxauth */ ); - -extern _X_EXPORT Bool AddClientOnOpenFD(int /* fd */ ); - extern _X_EXPORT CARD32 GetTimeInMillis(void); extern _X_EXPORT CARD64 GetTimeInMicros(void); @@ -175,9 +133,6 @@ extern _X_EXPORT void TimerCheck(void); extern _X_EXPORT void TimerCancel(OsTimerPtr /* pTimer */ ); extern _X_EXPORT void TimerFree(OsTimerPtr /* pTimer */ ); -extern _X_EXPORT void SetScreenSaverTimer(void); -extern _X_EXPORT void FreeScreenSaverTimer(void); - extern _X_EXPORT void GiveUp(int /*sig */ ); /* @@ -255,20 +210,12 @@ typedef int (*OsSigWrapperPtr) (int /* sig */ ); extern _X_EXPORT OsSigWrapperPtr OsRegisterSigWrapper(OsSigWrapperPtr newWrap); -extern _X_EXPORT void -LockServer(void); -extern _X_EXPORT void -UnlockServer(void); - extern _X_EXPORT Bool PrivsElevated(void); extern _X_EXPORT int GetClientFd(ClientPtr); -extern _X_EXPORT Bool -ClientIsLocal(ClientPtr client); - /* stuff for ReplyCallback */ extern _X_EXPORT CallbackListPtr ReplyCallback; typedef struct { @@ -369,12 +316,6 @@ LogClose(enum ExitCode error); extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value); extern _X_EXPORT void -LogVWrite(int verb, const char *f, va_list args) -_X_ATTRIBUTE_PRINTF(2, 0); -extern _X_EXPORT void -LogWrite(int verb, const char *f, ...) -_X_ATTRIBUTE_PRINTF(2, 3); -extern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) _X_ATTRIBUTE_PRINTF(3, 0); extern _X_EXPORT void @@ -402,11 +343,6 @@ LogHdrMessageVerb(MessageType type, int verb, const char *hdr_format, ...) _X_ATTRIBUTE_PRINTF(3, 0) _X_ATTRIBUTE_PRINTF(5, 6); -extern _X_EXPORT void -LogHdrMessage(MessageType type, const char *msg_format, - va_list msg_args, const char *hdr_format, ...) -_X_ATTRIBUTE_PRINTF(2, 0) -_X_ATTRIBUTE_PRINTF(4, 5); extern _X_EXPORT void FatalError(const char *f, ...) @@ -443,4 +379,15 @@ xorg_backtrace(void); typedef _sigset_t sigset_t; #endif +/* only for backwards compat with drivers that haven't kept up yet + (xf86-video-intel) + + @todo revise after next stable release +*/ +_X_DEPRECATED +static inline int System(const char* cmdline) +{ + return system(cmdline); +} + #endif /* OS_H */ diff --git a/include/property.h b/include/property.h index 6ee8a8398..6c879e6d9 100644 --- a/include/property.h +++ b/include/property.h @@ -51,20 +51,6 @@ SOFTWARE. typedef struct _Property *PropertyPtr; -typedef struct _PropertyStateRec { - WindowPtr win; - PropertyPtr prop; - int state; -} PropertyStateRec; - -extern CallbackListPtr PropertyStateCallback; - -extern _X_EXPORT int dixLookupProperty(PropertyPtr * /*result */ , - WindowPtr /*pWin */ , - Atom /*proprty */ , - ClientPtr /*pClient */ , - Mask /*access_mode */ ); - extern _X_EXPORT int dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, @@ -79,6 +65,4 @@ extern _X_EXPORT int DeleteProperty(ClientPtr /*client */ , WindowPtr /*pWin */ , Atom /*propName */ ); -extern _X_EXPORT void DeleteAllWindowProperties(WindowPtr /*pWin */ ); - #endif /* PROPERTY_H */ diff --git a/include/screenint.h b/include/screenint.h index e136f31cf..fc313042d 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -53,6 +53,10 @@ typedef struct _PixmapFormat *PixmapFormatPtr; typedef struct _Visual *VisualPtr; typedef struct _Depth *DepthPtr; typedef struct _Screen *ScreenPtr; + +extern _X_EXPORT void AttachOutputGPU(ScreenPtr pScreen, ScreenPtr newScreen); +extern _X_EXPORT void DetachOutputGPU(ScreenPtr output); + typedef struct _ColormapRec *ColormapPtr; #endif /* SCREENINT_H */ diff --git a/include/swapreq.h b/include/swapreq.h index d696aa05e..bf6514670 100644 --- a/include/swapreq.h +++ b/include/swapreq.h @@ -30,77 +30,70 @@ extern void SwapColorItem(xColorItem * /* pItem */ ); extern void SwapConnClientPrefix(xConnClientPrefix * /* pCCP */ ); -#undef SWAPREQ_PROC - -#define SWAPREQ_PROC(func) extern int func(ClientPtr /* client */) - -SWAPREQ_PROC(SProcAllocColor); -SWAPREQ_PROC(SProcAllocColorCells); -SWAPREQ_PROC(SProcAllocColorPlanes); -SWAPREQ_PROC(SProcAllocNamedColor); -SWAPREQ_PROC(SProcChangeActivePointerGrab); -SWAPREQ_PROC(SProcChangeGC); -SWAPREQ_PROC(SProcChangeHosts); -SWAPREQ_PROC(SProcChangeKeyboardControl); -SWAPREQ_PROC(SProcChangeKeyboardMapping); -SWAPREQ_PROC(SProcChangePointerControl); -SWAPREQ_PROC(SProcChangeProperty); -SWAPREQ_PROC(SProcChangeWindowAttributes); -SWAPREQ_PROC(SProcClearToBackground); -SWAPREQ_PROC(SProcConfigureWindow); -SWAPREQ_PROC(SProcConvertSelection); -SWAPREQ_PROC(SProcCopyArea); -SWAPREQ_PROC(SProcCopyColormapAndFree); -SWAPREQ_PROC(SProcCopyGC); -SWAPREQ_PROC(SProcCopyPlane); -SWAPREQ_PROC(SProcCreateColormap); -SWAPREQ_PROC(SProcCreateCursor); -SWAPREQ_PROC(SProcCreateGC); -SWAPREQ_PROC(SProcCreateGlyphCursor); -SWAPREQ_PROC(SProcCreatePixmap); -SWAPREQ_PROC(SProcCreateWindow); -SWAPREQ_PROC(SProcDeleteProperty); -SWAPREQ_PROC(SProcFillPoly); -SWAPREQ_PROC(SProcFreeColors); -SWAPREQ_PROC(SProcGetImage); -SWAPREQ_PROC(SProcGetMotionEvents); -SWAPREQ_PROC(SProcGetProperty); -SWAPREQ_PROC(SProcGrabButton); -SWAPREQ_PROC(SProcGrabKey); -SWAPREQ_PROC(SProcGrabKeyboard); -SWAPREQ_PROC(SProcGrabPointer); -SWAPREQ_PROC(SProcImageText); -SWAPREQ_PROC(SProcInternAtom); -SWAPREQ_PROC(SProcListFonts); -SWAPREQ_PROC(SProcListFontsWithInfo); -SWAPREQ_PROC(SProcLookupColor); -SWAPREQ_PROC(SProcNoOperation); -SWAPREQ_PROC(SProcOpenFont); -SWAPREQ_PROC(SProcPoly); -SWAPREQ_PROC(SProcPolyText); -SWAPREQ_PROC(SProcPutImage); -SWAPREQ_PROC(SProcQueryBestSize); -SWAPREQ_PROC(SProcQueryColors); -SWAPREQ_PROC(SProcQueryExtension); -SWAPREQ_PROC(SProcRecolorCursor); -SWAPREQ_PROC(SProcReparentWindow); -SWAPREQ_PROC(SProcResourceReq); -SWAPREQ_PROC(SProcRotateProperties); -SWAPREQ_PROC(SProcSendEvent); -SWAPREQ_PROC(SProcSetClipRectangles); -SWAPREQ_PROC(SProcSetDashes); -SWAPREQ_PROC(SProcSetFontPath); -SWAPREQ_PROC(SProcSetInputFocus); -SWAPREQ_PROC(SProcSetScreenSaver); -SWAPREQ_PROC(SProcSetSelectionOwner); -SWAPREQ_PROC(SProcSimpleReq); -SWAPREQ_PROC(SProcStoreColors); -SWAPREQ_PROC(SProcStoreNamedColor); -SWAPREQ_PROC(SProcTranslateCoords); -SWAPREQ_PROC(SProcUngrabButton); -SWAPREQ_PROC(SProcUngrabKey); -SWAPREQ_PROC(SProcWarpPointer); - -#undef SWAPREQ_PROC +int SProcAllocColor(ClientPtr client); +int SProcAllocColorCells(ClientPtr client); +int SProcAllocColorPlanes(ClientPtr client); +int SProcAllocNamedColor(ClientPtr client); +int SProcChangeActivePointerGrab(ClientPtr client); +int SProcChangeGC(ClientPtr client); +int SProcChangeHosts(ClientPtr client); +int SProcChangeKeyboardControl(ClientPtr client); +int SProcChangeKeyboardMapping(ClientPtr client); +int SProcChangePointerControl(ClientPtr client); +int SProcChangeProperty(ClientPtr client); +int SProcChangeWindowAttributes(ClientPtr client); +int SProcClearToBackground(ClientPtr client); +int SProcConfigureWindow(ClientPtr client); +int SProcConvertSelection(ClientPtr client); +int SProcCopyArea(ClientPtr client); +int SProcCopyColormapAndFree(ClientPtr client); +int SProcCopyGC(ClientPtr client); +int SProcCopyPlane(ClientPtr client); +int SProcCreateColormap(ClientPtr client); +int SProcCreateCursor(ClientPtr client); +int SProcCreateGC(ClientPtr client); +int SProcCreateGlyphCursor(ClientPtr client); +int SProcCreatePixmap(ClientPtr client); +int SProcCreateWindow(ClientPtr client); +int SProcDeleteProperty(ClientPtr client); +int SProcFillPoly(ClientPtr client); +int SProcFreeColors(ClientPtr client); +int SProcGetImage(ClientPtr client); +int SProcGetMotionEvents(ClientPtr client); +int SProcGetProperty(ClientPtr client); +int SProcGrabButton(ClientPtr client); +int SProcGrabKey(ClientPtr client); +int SProcGrabKeyboard(ClientPtr client); +int SProcGrabPointer(ClientPtr client); +int SProcImageText(ClientPtr client); +int SProcInternAtom(ClientPtr client); +int SProcListFonts(ClientPtr client); +int SProcListFontsWithInfo(ClientPtr client); +int SProcLookupColor(ClientPtr client); +int SProcOpenFont(ClientPtr client); +int SProcPoly(ClientPtr client); +int SProcPolyText(ClientPtr client); +int SProcPutImage(ClientPtr client); +int SProcQueryBestSize(ClientPtr client); +int SProcQueryColors(ClientPtr client); +int SProcQueryExtension(ClientPtr client); +int SProcRecolorCursor(ClientPtr client); +int SProcReparentWindow(ClientPtr client); +int SProcResourceReq(ClientPtr client); +int SProcRotateProperties(ClientPtr client); +int SProcSendEvent(ClientPtr client); +int SProcSetClipRectangles(ClientPtr client); +int SProcSetDashes(ClientPtr client); +int SProcSetFontPath(ClientPtr client); +int SProcSetInputFocus(ClientPtr client); +int SProcSetScreenSaver(ClientPtr client); +int SProcSetSelectionOwner(ClientPtr client); +int SProcSimpleReq(ClientPtr client); +int SProcStoreColors(ClientPtr client); +int SProcStoreNamedColor(ClientPtr client); +int SProcTranslateCoords(ClientPtr client); +int SProcUngrabButton(ClientPtr client); +int SProcUngrabKey(ClientPtr client); +int SProcWarpPointer(ClientPtr client); #endif /* SWAPREQ_H */ diff --git a/include/xkbfile.h b/include/xkbfile.h deleted file mode 100644 index bfc83ac92..000000000 --- a/include/xkbfile.h +++ /dev/null @@ -1,239 +0,0 @@ -/************************************************************ - Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. - - Permission to use, copy, modify, and distribute this - software and its documentation for any purpose and without - fee is hereby granted, provided that the above copyright - notice appear in all copies and that both that copyright - notice and this permission notice appear in supporting - documentation, and that the name of Silicon Graphics not be - used in advertising or publicity pertaining to distribution - of the software without specific prior written permission. - Silicon Graphics makes no representation about the suitability - of this software for any purpose. It is provided "as is" - without any express or implied warranty. - - SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH - THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ********************************************************/ - -#ifndef _XKBFILE_H_ -#define _XKBFILE_H_ 1 - -#include "xkbstr.h" - -/***====================================================================***/ - -#define XkbXKMFile 0 -#define XkbCFile 1 -#define XkbXKBFile 2 -#define XkbMessage 3 - -typedef void (*XkbFileAddOnFunc) (FILE * /* file */ , - XkbDescPtr /* result */ , - Bool /* topLevel */ , - Bool /* showImplicit */ , - int /* fileSection */ , - void * /* priv */ - ); - -/***====================================================================***/ - -#define _XkbSuccess 0 /* unused */ -#define _XkbErrMissingNames 1 -#define _XkbErrMissingTypes 2 -#define _XkbErrMissingReqTypes 3 -#define _XkbErrMissingSymbols 4 -#define _XkbErrMissingVMods 5 /* unused */ -#define _XkbErrMissingIndicators 6 /* unused */ -#define _XkbErrMissingCompatMap 7 -#define _XkbErrMissingSymInterps 8 /* unused */ -#define _XkbErrMissingGeometry 9 -#define _XkbErrIllegalDoodad 10 /* unused */ -#define _XkbErrIllegalTOCType 11 /* unused */ -#define _XkbErrIllegalContents 12 -#define _XkbErrEmptyFile 13 /* unused */ -#define _XkbErrFileNotFound 14 /* unused */ -#define _XkbErrFileCannotOpen 15 /* unused */ -#define _XkbErrBadValue 16 -#define _XkbErrBadMatch 17 -#define _XkbErrBadTypeName 18 -#define _XkbErrBadTypeWidth 19 -#define _XkbErrBadFileType 20 -#define _XkbErrBadFileVersion 21 -#define _XkbErrBadFileFormat 22 /* unused */ -#define _XkbErrBadAlloc 23 -#define _XkbErrBadLength 24 -#define _XkbErrXReqFailure 25 /* unused */ -#define _XkbErrBadImplementation 26 - -/***====================================================================***/ - -_XFUNCPROTOBEGIN - -extern _X_EXPORT char *XkbIndentText(unsigned /* size */ - ); - -extern _X_EXPORT char *XkbAtomText(Atom /* atm */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbKeysymText(KeySym /* sym */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbStringText(char * /* str */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbKeyNameText(char * /* name */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbModIndexText(unsigned /* ndx */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbModMaskText(unsigned /* mask */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbVModIndexText(XkbDescPtr /* xkb */ , - unsigned /* ndx */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbVModMaskText(XkbDescPtr /* xkb */ , - unsigned /* modMask */ , - unsigned /* mask */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbConfigText(unsigned /* config */ , - unsigned /* format */ - ); - -extern _X_EXPORT const char *XkbSIMatchText(unsigned /* type */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbIMWhichStateMaskText(unsigned /* use_which */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbControlsMaskText(unsigned /* ctrls */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbGeomFPText(int /* val */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbDoodadTypeText(unsigned /* type */ , - unsigned /* format */ - ); - -extern _X_EXPORT const char *XkbActionTypeText(unsigned /* type */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbActionText(XkbDescPtr /* xkb */ , - XkbAction * /* action */ , - unsigned /* format */ - ); - -extern _X_EXPORT char *XkbBehaviorText(XkbDescPtr /* xkb */ , - XkbBehavior * /* behavior */ , - unsigned /* format */ - ); - -/***====================================================================***/ - -#define _XkbKSLower (1<<0) -#define _XkbKSUpper (1<<1) - -#define XkbKSIsLower(k) (_XkbKSCheckCase(k)&_XkbKSLower) -#define XkbKSIsUpper(k) (_XkbKSCheckCase(k)&_XkbKSUpper) -#define XkbKSIsKeypad(k) (((k)>=XK_KP_Space)&&((k)<=XK_KP_Equal)) - -extern _X_EXPORT unsigned _XkbKSCheckCase(KeySym /* sym */ - ); - -extern _X_EXPORT int XkbFindKeycodeByName(XkbDescPtr /* xkb */ , - char * /* name */ , - Bool /* use_aliases */ - ); - -/***====================================================================***/ - -extern _X_EXPORT unsigned XkbConvertGetByNameComponents(Bool /* toXkm */ , - unsigned /* orig */ - ); - -/***====================================================================***/ - -extern _X_EXPORT Bool XkbWriteXKBKeycodes(FILE * /* file */ , - XkbDescPtr /* result */ , - Bool /* topLevel */ , - Bool /* showImplicit */ , - XkbFileAddOnFunc /* addOn */ , - void * /* priv */ - ); - -extern _X_EXPORT Bool XkbWriteXKBKeyTypes(FILE * /* file */ , - XkbDescPtr /* result */ , - Bool /* topLevel */ , - Bool /* showImplicit */ , - XkbFileAddOnFunc /* addOn */ , - void * /* priv */ - ); - -extern _X_EXPORT Bool XkbWriteXKBCompatMap(FILE * /* file */ , - XkbDescPtr /* result */ , - Bool /* topLevel */ , - Bool /* showImplicit */ , - XkbFileAddOnFunc /* addOn */ , - void * /* priv */ - ); - -extern _X_EXPORT Bool XkbWriteXKBSymbols(FILE * /* file */ , - XkbDescPtr /* result */ , - Bool /* topLevel */ , - Bool /* showImplicit */ , - XkbFileAddOnFunc /* addOn */ , - void * /* priv */ - ); - -extern _X_EXPORT Bool XkbWriteXKBGeometry(FILE * /* file */ , - XkbDescPtr /* result */ , - Bool /* topLevel */ , - Bool /* showImplicit */ , - XkbFileAddOnFunc /* addOn */ , - void * /* priv */ - ); - -extern _X_EXPORT Bool XkbWriteXKBKeymapForNames(FILE * /* file */ , - XkbComponentNamesPtr /* names */ - , - XkbDescPtr /* xkb */ , - unsigned /* want */ , - unsigned /* need */ - ); - -/***====================================================================***/ - -extern _X_EXPORT unsigned XkmReadFile(FILE * /* file */ , - unsigned /* need */ , - unsigned /* want */ , - XkbDescPtr * /* result */ - ); - -_XFUNCPROTOEND -#endif /* _XKBFILE_H_ */ diff --git a/include/xkbrules.h b/include/xkbrules.h index ab5b4b266..20ea78e17 100644 --- a/include/xkbrules.h +++ b/include/xkbrules.h @@ -44,77 +44,4 @@ typedef struct _XkbRF_VarDefs { const char *options; } XkbRF_VarDefsRec, *XkbRF_VarDefsPtr; -typedef struct _XkbRF_Rule { - int number; - int layout_num; - int variant_num; - const char *model; - const char *layout; - const char *variant; - const char *option; - /* yields */ - const char *keycodes; - const char *symbols; - const char *types; - const char *compat; - const char *geometry; - unsigned flags; -} XkbRF_RuleRec, *XkbRF_RulePtr; - -typedef struct _XkbRF_Group { - int number; - const char *name; - char *words; -} XkbRF_GroupRec, *XkbRF_GroupPtr; - -#define XkbRF_PendingMatch (1L<<1) -#define XkbRF_Option (1L<<2) -#define XkbRF_Append (1L<<3) -#define XkbRF_Normal (1L<<4) -#define XkbRF_Invalid (1L<<5) - -typedef struct _XkbRF_Rules { - unsigned short sz_rules; - unsigned short num_rules; - XkbRF_RulePtr rules; - unsigned short sz_groups; - unsigned short num_groups; - XkbRF_GroupPtr groups; -} XkbRF_RulesRec, *XkbRF_RulesPtr; - -/***====================================================================***/ - -_XFUNCPROTOBEGIN - -/* Seems preferable to dragging xkbstr.h in. */ - struct _XkbComponentNames; - -extern _X_EXPORT Bool XkbRF_GetComponents(XkbRF_RulesPtr /* rules */ , - XkbRF_VarDefsPtr /* var_defs */ , - struct _XkbComponentNames * /* names */ - ); - -extern _X_EXPORT Bool XkbRF_LoadRules(FILE * /* file */ , - XkbRF_RulesPtr /* rules */ - ); - -extern _X_EXPORT Bool XkbRF_LoadRulesByName(char * /* base */ , - char * /* locale */ , - XkbRF_RulesPtr /* rules */ - ); - -/***====================================================================***/ - -extern _X_EXPORT XkbRF_RulesPtr XkbRF_Create(void); - -extern _X_EXPORT void XkbRF_Free(XkbRF_RulesPtr /* rules */ , - Bool /* freeRules */ - ); - -/***====================================================================***/ - -#define _XKB_RF_NAMES_PROP_ATOM "_XKB_RULES_NAMES" -#define _XKB_RF_NAMES_PROP_MAXLEN 1024 - -_XFUNCPROTOEND #endif /* _XKBRULES_H_ */ diff --git a/include/xkbsrv.h b/include/xkbsrv.h index c182b5330..ab3a40743 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -232,9 +232,6 @@ typedef struct _XkbSrvLedInfo { #define _XkbClientInitialized (1<<7) #define _XkbClientIsAncient (1<<6) -#define _XkbWantsDetectableAutoRepeat(c)\ - ((c)->xkbClientFlags&XkbPCF_DetectableAutoRepeatMask) - /* * Settings for flags field */ @@ -821,7 +818,7 @@ extern _X_EXPORT Bool XkbDeviceApplyKeymap(DeviceIntPtr /* dst */ , extern _X_EXPORT void XkbCopyControls(XkbDescPtr /* dst */ , XkbDescPtr /* src */ ); -#include "xkbfile.h" +#include "xkbstr.h" #include "xkbrules.h" extern _X_EXPORT unsigned int XkbDDXLoadKeymapByNames(DeviceIntPtr /* keybd */ , diff --git a/include/xorg-server.h.meson.in b/include/xorg-server.h.meson.in index 1ffc58548..d0572c9d4 100644 --- a/include/xorg-server.h.meson.in +++ b/include/xorg-server.h.meson.in @@ -20,9 +20,6 @@ #error Include xorg-config.h when building the X server #endif -/* Support BigRequests extension */ -#mesondefine BIGREQS - /* Default font path */ #mesondefine COMPILEDDEFAULTFONTPATH @@ -70,6 +67,7 @@ /* Internal define for Xinerama */ #mesondefine PANORAMIX +#mesondefine XINERAMA /* Support Present extension */ #mesondefine PRESENT diff --git a/man/Xserver.man b/man/Xserver.man index a9aad463b..e21cc4a25 100644 --- a/man/Xserver.man +++ b/man/Xserver.man @@ -31,7 +31,7 @@ Xserver \- X Window System display server .SH SYNOPSIS .B X -[option ...] +[option \&...\&] .SH DESCRIPTION .I X is the generic name for the X Window System display server. It is @@ -39,13 +39,15 @@ frequently a link or a copy of the appropriate server binary for driving the most frequently used server on a given machine. .SH "STARTING THE SERVER" The X server is usually started from the X Display Manager program -\fIxdm\fP(1) or a similar display manager program. +.BR xdm (1) +or a similar display manager program. This utility is run from the system boot files and takes care of keeping the server running, prompting for usernames and passwords, and starting up the user sessions. .PP Installations that run more than one window system may need to use the -\fIxinit\fP(1) utility instead of a display manager. However, \fIxinit\fP is +.BR xinit (1) +utility instead of a display manager. However, \fIxinit\fP is to be considered a tool for building startup scripts and is not intended for use by end users. Site administrators are \fBstrongly\fP urged to use a display manager, or build other interfaces for novice users. @@ -54,7 +56,7 @@ The X server may also be started directly by the user, though this method is usually reserved for testing and is not recommended for normal operation. On some platforms, the user must have special permission to start the X server, often because access to certain -devices (e.g. \fI/dev/mouse\fP) is restricted. Where applicable, the +devices (e.g.\& \fI/dev/mouse\fP) is restricted. Where applicable, the X server notifies systemd when it is ready to process requests. .PP When the X server starts up, it typically takes over the display. If @@ -73,12 +75,14 @@ should override values specified via other mechanisms. .B :\fIdisplaynumber\fP The X server runs as the given \fIdisplaynumber\fP, which by default is 0. If multiple X servers are to run simultaneously on a host, each must have -a unique display number. See the DISPLAY -NAMES section of the \fIX\fP(@miscmansuffix@) manual page to learn how to +a unique display number. +See the DISPLAY NAMES section of the +.BR X (@miscmansuffix@) +manual page to learn how to specify which display number clients should try to use. .TP 8 .B \-a \fInumber\fP -sets pointer acceleration (i.e. the ratio of how much is reported to how much +sets pointer acceleration (i.e., the ratio of how much is reported to how much the user actually moved the pointer). .TP 8 .B \-ac @@ -98,34 +102,42 @@ Audit lines are sent as standard error output. .TP 8 .B \-auth \fIauthorization-file\fP specifies a file which contains a collection of authorization records used -to authenticate access. See also the \fIxdm\fP(1) and -\fIXsecurity\fP(@miscmansuffix@) manual pages. -.TP 8 -.BI \-background\ none -Asks the driver not to clear the background on startup, if the driver supports that. -May be useful for smooth transition with eg. fbdev driver. +to authenticate access. +See also the +.BR xdm (1) +and +.BR Xsecurity (@miscmansuffix@) +manual pages. +.TP 8 +.B \-background none +Asks the driver not to clear the background on startup, +if the driver supports that. +May be useful for smooth transition with e.g.\& fbdev driver. For security reasons this is not the default as the screen contents might show a previous user session. .TP 8 .B \-br sets the default root window to solid black instead of the standard root weave -pattern. This is the default unless -retro or -wr is specified. +pattern. +This is the default unless \-retro or \-wr is specified. .TP 8 .B \-bs disables backing store support on all screens. .TP 8 -.B \+byteswappedclients -Allow connections from clients with an endianess different to that of the server. +.B +byteswappedclients +Allow connections from clients with an endianess different to that of the +server. .TP 8 .B \-byteswappedclients -Prohibit connections from clients with an endianess different to that of the server. -This is the default unless \fB\+byteswappedclients\fP is specified. +Prohibit connections from clients with an endianess different to that of the +server. +This is the default unless \fB+byteswappedclients\fP is specified. .TP 8 .B \-c turns off key-click. .TP 8 .B c \fIvolume\fP -sets key-click volume (allowable range: 0-100). +sets key-click volume (allowable range: 0\(en100). .TP 8 .B \-cc \fIclass\fP sets the visual class for the root window of color screens. @@ -160,19 +172,21 @@ default state is platform and configuration specific. disables DPMS (display power management services). The default state is platform and configuration specific. .TP 8 -.BI \-extension extensionName -disables named extension. If an unknown extension name is specified, +.BI "\-extension " extensionName +disables named extension. +If an unknown extension name is specified, a list of accepted extension names is printed. .TP 8 -.BI +extension extensionName -enables named extension. If an unknown extension name is specified, +.BI "+extension " extensionName +enables named extension. +If an unknown extension name is specified, a list of accepted extension names is printed. .TP 8 .B \-f \fIvolume\fP -sets beep (bell) volume (allowable range: 0-100). +sets beep (bell) volume (allowable range: 0\(en100). .TP 8 -.B \-fakescreenfps \fFps\fP -sets fake presenter screen default fps (allowable range: 1-600). +.B \-fakescreenfps \fIfps\fP +sets fake presenter screen default fps (allowable range: 1\(en600). .TP 8 .B \-fp \fIfontPath\fP sets the search path for fonts. This path is a comma separated list @@ -251,11 +265,11 @@ turns off auto-repeat. .B r turns on auto-repeat. .TP 8 -.B -retro +.B \-retro starts the server with the classic stipple and cursor visible. The default is to start with a black root window, and to suppress display of the cursor -until the first time an application calls XDefineCursor(). For kdrive -servers, this implies -zap. +until the first time an application calls XDefineCursor(). +For kdrive servers, this implies \-zap. .TP 8 .B \-s \fIminutes\fP sets screen-saver timeout time in minutes. @@ -264,16 +278,17 @@ sets screen-saver timeout time in minutes. disables save under support on all screens. .TP 8 .B \-seat \fIseat\fP -seat to run on. Takes a string identifying a seat in a platform -specific syntax. On platforms which support this feature this may be +seat to run on. Takes a string identifying a seat in a platform +specific syntax. On platforms which support this feature this may be used to limit the server to expose only a specific subset of devices connected to the system. .TP 8 .B \-t \fInumber\fP -sets pointer acceleration threshold in pixels (i.e. after how many pixels +sets pointer acceleration threshold in pixels (i.e., after how many pixels pointer acceleration should take effect). .TP 8 -.B \-terminate \fI[delay]\fP +.BR \-terminate " ["\c +.IR delay ] causes the server to terminate at server reset, instead of continuing to run. This overrides a previous .B \-noreset @@ -302,8 +317,8 @@ pattern. loads the specified extension at init. This is a no-op for most implementations. .TP 8 -.B [+-]xinerama -enables(+) or disables(-) the XINERAMA extension. The default state is +.RB [ +\- ] xinerama +enables(+) or disables(\-) the XINERAMA extension. The default state is platform and configuration specific. .SH SERVER DEPENDENT OPTIONS Some X servers accept the following options: @@ -367,7 +382,8 @@ enables XDMCP and sends Query packets to the specified enable XDMCP and broadcasts BroadcastQuery packets to the network. The first responding display manager will be chosen for the session. .TP 8 -.B \-multicast [\fIaddress\fP [\fIhop count\fP]] +.BR \-multicast " ["\c +.IR address " [" "hop count" ]] Enable XDMCP and multicast BroadcastQuery packets to the network. The first responding display manager is chosen for the session. If an address is specified, the multicast is sent to that address. If no @@ -410,14 +426,15 @@ data (not that it is very private, being on the command line!). Yet another XDMCP specific value, this one allows the display manager to identify each display so that it can locate the shared key. .SH XKEYBOARD OPTIONS -X servers that support the XKEYBOARD (a.k.a. \*qXKB\*q) extension accept the +X servers that support the XKEYBOARD (a.k.a.\& \*qXKB\*q) extension accept the following options. All layout files specified on the command line must be located in the XKB base directory or a subdirectory, and specified as the relative path from the XKB base directory. The default XKB base directory is .IR @projectroot@/lib/X11/xkb . .TP 8 -.BR [+-]accessx " [ \fItimeout\fP [ \fItimeout_mask\fP [ \fIfeedback\fP [ \fIoptions_mask\fP ] ] ] ]" -enables(+) or disables(-) AccessX key sequences. +.RB [ +\- ] accessx " [ \fItimeout\fP [ \fItimeout_mask\fP [ \ +\fIfeedback\fP [ \fIoptions_mask\fP ] ] ] ]" +enables(+) or disables(\-) AccessX key sequences. .TP 8 .B \-xkbdir \fIdirectory\fP base directory for keyboard layout files. This option is not available @@ -437,15 +454,18 @@ loads keyboard description in \fIfilename\fP on server startup. .SH "NETWORK CONNECTIONS" The X server supports client connections via a platform-dependent subset of the following transport types: TCP/IP, Unix Domain sockets, -and several varieties of SVR4 local connections. See the DISPLAY -NAMES section of the \fIX\fP(@miscmansuffix@) manual page to learn how to +and several varieties of SVR4 local connections. +See the DISPLAY NAMES section of the +.BR X (@miscmansuffix@) +manual page to learn how to specify which transport type clients should try to use. .SH GRANTING ACCESS The X server implements a platform-dependent subset of the following authorization protocols: MIT-MAGIC-COOKIE-1, XDM-AUTHORIZATION-1, -XDM-AUTHORIZATION-2, SUN-DES-1, and MIT-KERBEROS-5. See the -\fIXsecurity\fP(@miscmansuffix@) manual page for information on the -operation of these protocols. +Host Access, and Server Interpreted. +See the +.BR Xsecurity (@miscmansuffix@) +manual page for information on the operation of these protocols. .PP Authorization data required by the above protocols is passed to the server in a private file named with the \fB\-auth\fP command line @@ -455,9 +475,10 @@ If this file contains any authorization records, the local host is not automatically allowed access to the server, and only clients which send one of the authorization records contained in the file in the connection setup information will be allowed access. See the -\fIXau\fP manual page for a description of the binary format of this -file. See \fIxauth\fP(1) for maintenance of this file, and distribution -of its contents to remote hosts. +.BR Xau (3) +manual page for a description of the binary format of this file. See +.BR xauth (1) +for maintenance of this file, and distribution of its contents to remote hosts. .PP The X server also uses a host-based access control list for deciding whether or not to accept connections from clients on a particular machine. @@ -465,9 +486,11 @@ If no other authorization mechanism is being used, this list initially consists of the host on which the server is running as well as any machines listed in the file \fI/etc/X\fBn\fI.hosts\fR, where \fBn\fP is the display number of the server. Each line of the file should -contain either an Internet hostname (e.g. expo.lcs.mit.edu) +contain either an Internet hostname (e.g., expo.lcs.mit.edu) or a complete name in the format -\fIfamily\fP:\fIname\fP as described in the \fIxhost\fP(1) manual page. +\fIfamily\fP:\fIname\fP as described in the +.BR xhost (1) +manual page. There should be no leading or trailing spaces on any lines. For example: .sp .in +8 @@ -482,21 +505,13 @@ local: Users can add or remove hosts from this list and enable or disable access control using the \fIxhost\fP command from the same machine as the server. .PP -If the X FireWall Proxy (\fIxfwp\fP) is being used without a sitepolicy, -host-based authorization must be turned on for clients to be able to -connect to the X server via the \fIxfwp\fP. If \fIxfwp\fP is run without -a configuration file and thus no sitepolicy is defined, if \fIxfwp\fP -is using an X server where xhost + has been run to turn off host-based -authorization checks, when a client tries to connect to this X server -via \fIxfwp\fP, the X server will deny the connection. See \fIxfwp\fP(1) -for more information about this proxy. -.PP The X protocol intrinsically does not have any notion of window operation permissions or place any restrictions on what a client can do; if a program can connect to a display, it has full run of the screen. X servers that support the SECURITY extension fare better because clients -can be designated untrusted via the authorization they use to connect; see -the \fIxauth\fP(1) manual page for details. Restrictions are imposed +can be designated untrusted via the authorization they use to connect; see the +.BR xauth (1) +manual page for details. Restrictions are imposed on untrusted clients that curtail the mischief they can do. See the SECURITY extension specification for a complete list of these restrictions. .PP @@ -534,20 +549,21 @@ The default font path is @default_font_path@ . .LP A special kind of directory can be specified using the \fBcatalogue\fP: -prefix. Directories specified this way can contain symlinks pointing to the -real font directories. See the FONTPATH.D section for details. +prefix. Directories specified this way can contain symlinks pointing to the +real font directories. See the FONTPATH.D section for details. .LP -The font path can be set with the \fB\-fp\fP option or by \fIxset\fP(1) +The font path can be set with the \fB\-fp\fP option or by +.BR xset (1) after the server has started. .SH "FONTPATH.D" You can specify a special kind of font path in the form \fBcatalogue:<dir>\fR. The directory specified after the catalogue: prefix will be scanned for symlinks and each symlink destination will be added as a local fontfile FPE. .PP -The symlink can be suffixed by attributes such as '\fBunscaled\fR', which -will be passed through to the underlying fontfile FPE. The only exception is -the newly introduced '\fBpri\fR' attribute, which will be used for ordering -the font paths specified by the symlinks. +The symlink can be suffixed by attributes such as \&'\fBunscaled\fR', +which will be passed through to the underlying fontfile FPE. +The only exception is the newly introduced \&'\fBpri\fR' attribute, +which will be used for ordering the font paths specified by the symlinks. An example configuration: @@ -561,8 +577,8 @@ An example configuration: This will add /usr/share/X11/fonts/misc as the first FPE with the attribute \N'39'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with -the attribute 'unscaled' etc. This is functionally equivalent to setting -the following font path: +the attribute \&'unscaled' etc. +This is functionally equivalent to setting the following font path: .nf /usr/share/X11/fonts/misc:unscaled, @@ -577,46 +593,72 @@ the following font path: .I /etc/X\fBn\fP.hosts Initial access control list for display number \fBn\fP .TP 30 -.IR @datadir@/fonts/X11/misc , @datadir@/fonts/X11/75dpi , @datadir@/fonts/X11/100dpi +.IR @datadir@/fonts/X11/misc ", " @datadir@/fonts/X11/75dpi ", " @datadir@/fonts/X11/100dpi Bitmap font directories .TP 30 -.IR @datadir@/fonts/X11/TTF , @datadir@/fonts/X11/Type1 +.IR @datadir@/fonts/X11/TTF ", " @datadir@/fonts/X11/Type1 Outline font directories .TP 30 .I /tmp/.X11-unix/X\fBn\fP Unix domain socket for display number \fBn\fP .TP 30 .I /usr/adm/X\fBn\fPmsgs -Error log file for display number \fBn\fP if run from \fIinit\fP(@adminmansuffix@) +Error log file for display number \fBn\fP if run from +.BR init (@adminmansuffix@) .TP 30 -.I @projectroot@/lib/X11/xdm/xdm-errors -Default error log file if the server is run from \fIxdm\fP(1) +.I @projectroot@/lib/X11/xdm/xdm\-errors +Default error log file if the server is run from +.BR xdm (1) .SH "SEE ALSO" -General information: \fIX\fP(@miscmansuffix@) +General information: +.BR X (@miscmansuffix@) .PP Protocols: .I "X Window System Protocol," .I "The X Font Service Protocol," .I "X Display Manager Control Protocol" .PP -Fonts: \fIbdftopcf\fP(1), \fImkfontdir\fP(1), \fImkfontscale\fP(1), -\fIxfs\fP(1), \fIxlsfonts\fP(1), \fIxfontsel\fP(1), \fIxfd\fP(1), +Fonts: +.BR bdftopcf (1), +.BR mkfontdir (1), +.BR mkfontscale (1), +.BR xfs (1), +.BR xlsfonts (1), +.BR xfontsel (1), +.BR xfd (1), .I "X Logical Font Description Conventions" .PP -Keyboards: \fIxkeyboard-config\fP(@miscmansuffix@) +Keyboards: +.BR xkeyboard\-config (@miscmansuffix@) .PP -Security: \fIXsecurity\fP(@miscmansuffix@), \fIxauth\fP(1), \fIXau\fP(1), -\fIxdm\fP(1), \fIxhost\fP(1), \fIxfwp\fP(1), +Security: +.BR Xsecurity (@miscmansuffix@), +.BR xauth (1), +.BR Xau (3), +.BR xdm (1), +.BR xhost (1), .I "Security Extension Specification" .PP -Starting the server: \fIstartx\fP(1), \fIxdm\fP(1), \fIxinit\fP(1) +Starting the server: +.BR startx (1), +.BR xdm (1), +.BR xinit (1) .PP -Controlling the server once started: \fIxset\fP(1), \fIxsetroot\fP(1), -\fIxhost\fP(1), \fIxinput\fP(1), \fIxrandr\fP(1) +Controlling the server once started: +.BR xset (1), +.BR xsetroot (1), +.BR xhost (1), +.BR xinput (1), +.BR xrandr (1) .PP Server-specific man pages: -\fIXorg\fP(1), \fIXephyr\fP(1), \fIXnest\fP(1), -\fIXvfb\fP(1), \fIXquartz\fP(1), \fIXWin\fP(1). +.BR Xorg (1), +.BR Xwayland (1), +.BR Xephyr (1), +.BR Xnest (1), +.BR Xvfb (1), +.BR Xquartz (1), +.BR XWin (1). .PP Server internal documentation: .I "Definition of the Porting Layer for the X v11 Sample Server" diff --git a/man/meson.build b/man/meson.build index 2961469c5..eca10561b 100644 --- a/man/meson.build +++ b/man/meson.build @@ -27,7 +27,8 @@ manpage_config.set('modulepath', module_dir) # wtf doesn't this work # manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), libexecdir)) manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), 'libexec')) -manpage_config.set('default_font_path', default_font_path) +# \: allows nroff to insert a line break at that position +manpage_config.set('default_font_path', default_font_path.replace(',', ',\\:')) install_man(configure_file( input: 'Xserver.man', diff --git a/meson.build b/meson.build index 94dea6970..abab17ed3 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,7 @@ project('xserver', 'c', 'c_std=gnu99', ], version: '21.1.99.1', - meson_version: '>= 0.56.0', + meson_version: '>= 0.58.0', ) release_date = '2021-07-05' @@ -13,6 +13,7 @@ cc = meson.get_compiler('c') add_project_arguments('-fno-strict-aliasing', language : 'c') add_project_arguments('-fvisibility=hidden', language : 'c') +add_project_arguments('-Wvla', language: 'c') add_project_link_arguments('-fvisibility=hidden', language : 'c') @@ -46,6 +47,7 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang' '-Werror=address', '-Werror=int-to-pointer-cast', '-Werror=pointer-to-int-cast', + '-Wvla', ] else test_wflags = [] @@ -63,14 +65,15 @@ add_project_arguments(common_wflags, language : ['c', 'objc']) libdrm_req = '>= 2.4.116' libselinux_req = '>= 2.0.86' xext_req = '>= 1.0.99.4' +xproto_req = '>= 7.0.31' wayland_req = '>= 1.21.0' -wayland_protocols_req = '>= 1.34' +wayland_protocols_req = '>= 1.38' gbm_req = '>= 10.2' xf86dgaproto_req = '>= 2.0.99.1' xshmfence_req = '>= 1.1' x11_dep = dependency('x11') -xproto_dep = dependency('xproto', version: '>= 7.0.31', fallback: ['xorgproto', 'ext_xorgproto']) +xproto_dep = dependency('xproto', version: xproto_req, fallback: ['xorgproto', 'ext_xorgproto']) randrproto_dep = dependency('randrproto', version: '>= 1.6.0', fallback: ['xorgproto', 'ext_xorgproto']) renderproto_dep = dependency('renderproto', version: '>= 0.11', fallback: ['xorgproto', 'ext_xorgproto']) xextproto_dep = dependency('xextproto', version: '>= 7.2.99.901', fallback: ['xorgproto', 'ext_xorgproto']) @@ -174,15 +177,18 @@ else default_font_path = dfp endif -hal_option = get_option('hal') glamor_option = get_option('glamor') +hal_option = get_option('hal') +if ['windows', 'darwin', 'cygwin'].contains(host_machine.system()) + hal_option = 'false' +endif + build_udev = get_option('udev') build_udev_kms = get_option('udev_kms') -if ['windows', 'darwin', 'cygwin'].contains(host_machine.system()) +if ['windows', 'darwin', 'cygwin', 'freebsd', 'netbsd', 'openbsd', 'sunos'].contains(host_machine.system()) build_udev = false build_udev_kms = false - hal_option = 'false' endif if get_option('systemd_logind') == 'auto' @@ -225,7 +231,6 @@ if (host_machine.system() != 'darwin' and dependency('wayland-protocols', version: wayland_protocols_req, required: xwayland_required), dependency('libxcvt', fallback: ['libxcvt', 'libxcvt_dep'], required: xwayland_required), ] - if build_glamor xwayland_dep += dependency('xshmfence', version: xshmfence_req, required: xwayland_required) xwayland_dep += dependency('libdrm', version: libdrm_req, required: xwayland_required) @@ -241,25 +246,21 @@ if (host_machine.system() != 'darwin' and endforeach endif -build_xnest = false -if (host_machine.system() != 'windows') - if get_option('xnest') != 'false' - xnest_required = get_option('xnest') == 'true' - - xnest_dep = [ - dependency('xext', version: xext_req, required: xnest_required), - dependency('x11', required: xnest_required), - dependency('xau', required: xnest_required), - ] - - build_xnest = true - # check for all the deps being found, to handle 'auto' mode. - foreach d: xnest_dep - if not d.found() - build_xnest = false - endif - endforeach - endif +## configure Xnest - nesting X server +build_xnest = get_option('xnest') != 'false' +xnest_required = get_option('xnest') == 'true' +xnest_dep = [ + dependency('xext', version: xext_req, required: xnest_required), + dependency('x11', required: xnest_required), + dependency('xau', required: xnest_required), +] +if get_option('xnest') == 'auto' + # check for all the deps being found, to handle 'auto' mode. + foreach d: xnest_dep + if not d.found() + build_xnest = false + endif + endforeach endif build_xwin = false @@ -286,11 +287,38 @@ if build_xquartz build_rootless = true endif +build_xephyr = get_option('xephyr') +build_xvfb = get_option('xvfb') + +summary({ + 'Xorg': build_xorg, + 'Xwayland': build_xwayland, + 'Xnest': build_xnest, + 'Xvfb': build_xvfb, + 'Xwin': build_xwin, + 'Xquartz': build_xquartz, + }, + section: 'DDX', + bool_yn: true, +) + +# IPv6 support +have_AF_INET6 = cc.compiles(''' +#ifdef WIN32 +#include <winsock2.h> +#else +#include <sys/socket.h> +#endif +int main(void) { int foo = AF_INET6; return foo; }''') if get_option('ipv6') == 'auto' - build_ipv6 = cc.has_function('getaddrinfo') + build_ipv6 = cc.has_function('getaddrinfo') and have_AF_INET6 else build_ipv6 = get_option('ipv6') == 'true' endif +if build_ipv6 and not have_AF_INET6 + error('ipv6 support needs AF_INET6') +endif +message('IPv6 support: ' + (build_ipv6 ? 'YES' : 'NO')) int10 = get_option('int10') if int10 == 'auto' @@ -495,14 +523,24 @@ else build_dri2 = get_option('dri2') == 'true' endif +if host_machine.system() in ['freebsd', 'openbsd'] + epoll_dep = dependency('epoll-shim') +else + epoll_dep = [] +endif + +have_eventfd = cc.has_header('sys/eventfd.h', dependencies: epoll_dep) if get_option('dri3') == 'auto' - build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found() + build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found() and have_eventfd else build_dri3 = get_option('dri3') == 'true' if build_dri3 if not xshmfence_dep.found() error('DRI3 requested, but xshmfence not found') endif + if not have_eventfd + error('DRI3 requested, but sys/eventfd.h not found') + endif endif endif @@ -847,6 +885,7 @@ if build_xorg sdk_required_modules = [ 'pixman-1 >= 0.27.2', + f'xproto @xproto_req@', ] # XXX this isn't trying very hard, but hard enough. diff --git a/meson_options.txt b/meson_options.txt index e831d1dc9..94698f218 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -33,8 +33,6 @@ option('serverconfigdir', type: 'string', option('glx', type: 'boolean', value: true) option('xdmcp', type: 'boolean', value: true) option('xdm-auth-1', type: 'boolean', value: true) -option('secure-rpc', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', - description: 'Enable Secure-RPC (DES) authentication') option('ipv6', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto') option('input_thread', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto') diff --git a/mi/meson.build b/mi/meson.build index 9f97d149c..cccdb06eb 100644 --- a/mi/meson.build +++ b/mi/meson.build @@ -1,6 +1,5 @@ srcs_mi = [ 'miarc.c', - 'mibitblt.c', 'micmap.c', 'micopy.c', 'midash.c', @@ -8,7 +7,6 @@ srcs_mi = [ 'mieq.c', 'miexpose.c', 'mifillarc.c', - 'mifillrct.c', 'migc.c', 'miglblt.c', 'mioverlay.c', @@ -67,64 +67,12 @@ typedef struct _miDash *miDashPtr; /* miarc.c */ -extern _X_EXPORT void miWideArc(DrawablePtr pDraw, - GCPtr pGC, - int narcs, - xArc * parcs); - extern _X_EXPORT void miPolyArc(DrawablePtr /*pDraw */ , GCPtr /*pGC */ , int /*narcs */ , xArc * /*parcs */ ); -/* mibitblt.c */ - -extern _X_EXPORT RegionPtr miCopyArea(DrawablePtr /*pSrcDrawable */ , - DrawablePtr /*pDstDrawable */ , - GCPtr /*pGC */ , - int /*xIn */ , - int /*yIn */ , - int /*widthSrc */ , - int /*heightSrc */ , - int /*xOut */ , - int /*yOut */ - ); - -extern _X_EXPORT RegionPtr miCopyPlane(DrawablePtr /*pSrcDrawable */ , - DrawablePtr /*pDstDrawable */ , - GCPtr /*pGC */ , - int /*srcx */ , - int /*srcy */ , - int /*width */ , - int /*height */ , - int /*dstx */ , - int /*dsty */ , - unsigned long /*bitPlane */ - ); - -extern _X_EXPORT void miGetImage(DrawablePtr /*pDraw */ , - int /*sx */ , - int /*sy */ , - int /*w */ , - int /*h */ , - unsigned int /*format */ , - unsigned long /*planeMask */ , - char * /*pdstLine */ - ); - -extern _X_EXPORT void miPutImage(DrawablePtr /*pDraw */ , - GCPtr /*pGC */ , - int /*depth */ , - int /*x */ , - int /*y */ , - int /*w */ , - int /*h */ , - int /*leftPad */ , - int /*format */ , - char * /*pImage */ - ); - /* micopy.c */ #define miGetCompositeClip(pGC) ((pGC)->pCompositeClip) @@ -160,71 +108,12 @@ miDoCopy(DrawablePtr pSrcDrawable, int xOut, int yOut, miCopyProc copyProc, Pixel bitplane, void *closure); -/* micursor.c */ - -extern _X_EXPORT void miRecolorCursor(DeviceIntPtr /* pDev */ , - ScreenPtr /*pScr */ , - CursorPtr /*pCurs */ , - Bool /*displayed */ - ); - -/* midash.c */ - -extern _X_EXPORT void miStepDash(int /*dist */ , - int * /*pDashIndex */ , - unsigned char * /*pDash */ , - int /*numInDashList */ , - int * /*pDashOffset */ - ); - /* mieq.c */ #ifndef INPUT_H typedef struct _DeviceRec *DevicePtr; #endif -extern _X_EXPORT Bool mieqInit(void - ); - -extern _X_EXPORT void mieqFini(void); - -extern _X_EXPORT void mieqEnqueue(DeviceIntPtr /*pDev */ , - InternalEvent * /*e */ - ); - -extern _X_EXPORT void mieqSwitchScreen(DeviceIntPtr /* pDev */ , - ScreenPtr /*pScreen */ , - Bool /*set_dequeue_screen */ - ); - -extern _X_EXPORT void mieqProcessDeviceEvent(DeviceIntPtr /* dev */ , - InternalEvent * /* event */ , - ScreenPtr /* screen */ - ); - -extern _X_EXPORT void mieqProcessInputEvents(void - ); - -extern _X_EXPORT void mieqAddCallbackOnDrained(CallbackProcPtr callback, - void *param); - -extern _X_EXPORT void mieqRemoveCallbackOnDrained(CallbackProcPtr callback, - void *param); - -extern DeviceIntPtr CopyGetMasterEvent(DeviceIntPtr /* sdev */ , - InternalEvent * /* original */ , - InternalEvent * /* copy */ - ); - -/** - * Custom input event handler. If you need to process input events in some - * other way than the default path, register an input event handler for the - * given internal event type. - */ -typedef void (*mieqHandler) (int screen, InternalEvent *event, - DeviceIntPtr dev); -void _X_EXPORT mieqSetHandler(int event, mieqHandler handler); - /* miexpose.c */ extern _X_EXPORT RegionPtr miHandleExposures(DrawablePtr /*pSrcDrawable */ , @@ -238,32 +127,13 @@ extern _X_EXPORT RegionPtr miHandleExposures(DrawablePtr /*pSrcDrawable */ , int /*dsty */ ); -extern _X_EXPORT void miSendExposures(WindowPtr /*pWin */ , - RegionPtr /*pRgn */ , - int /*dx */ , - int /*dy */ - ); - extern _X_EXPORT void miWindowExposures(WindowPtr /*pWin */ , RegionPtr /*prgn */); -extern _X_EXPORT void miPaintWindow(WindowPtr /*pWin */ , - RegionPtr /*prgn */ , - int /*what */ - ); - extern _X_EXPORT void miClearDrawable(DrawablePtr /*pDraw */ , GCPtr /*pGC */ ); -/* mifillrct.c */ - -extern _X_EXPORT void miPolyFillRect(DrawablePtr /*pDrawable */ , - GCPtr /*pGC */ , - int /*nrectFill */ , - xRectangle * /*prectInit */ - ); - /* miglblt.c */ extern _X_EXPORT void miPolyGlyphBlt(DrawablePtr pDrawable, @@ -365,11 +235,6 @@ extern _X_EXPORT void miPushPixels(GCPtr /*pGC */ , ); /* miscrinit.c */ - -extern _X_EXPORT void -miSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h, - unsigned int subWindowMode); - extern _X_EXPORT Bool miModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, @@ -399,18 +264,6 @@ extern _X_EXPORT Bool miScreenInit(ScreenPtr pScreen, /* mivaltree.c */ -extern _X_EXPORT int miShapedWindowIn(RegionPtr /*universe */ , - RegionPtr /*bounding */ , - BoxPtr /*rect */ , - int /*x */ , - int /*y */ - ); - -extern _X_EXPORT int miValidateTree(WindowPtr /*pParent */ , - WindowPtr /*pChild */ , - VTKind /*kind */ - ); - extern _X_EXPORT void miWideLine(DrawablePtr /*pDrawable */ , GCPtr /*pGC */ , int /*mode */ , @@ -431,62 +284,6 @@ extern _X_EXPORT void miPolylines(DrawablePtr pDrawable, int npt, DDXPointPtr pPts); -/* miwindow.c */ - -extern _X_EXPORT void miClearToBackground(WindowPtr /*pWin */ , - int /*x */ , - int /*y */ , - int /*w */ , - int /*h */ , - Bool /*generateExposures */ - ); - -extern _X_EXPORT void miMarkWindow(WindowPtr /*pWin */ - ); - -extern _X_EXPORT Bool miMarkOverlappedWindows(WindowPtr /*pWin */ , - WindowPtr /*pFirst */ , - WindowPtr * /*ppLayerWin */ - ); - -extern _X_EXPORT void miHandleValidateExposures(WindowPtr /*pWin */ - ); - -extern _X_EXPORT void miMoveWindow(WindowPtr /*pWin */ , - int /*x */ , - int /*y */ , - WindowPtr /*pNextSib */ , - VTKind /*kind */ - ); - -extern _X_EXPORT void miResizeWindow(WindowPtr /*pWin */ , - int /*x */ , - int /*y */ , - unsigned int /*w */ , - unsigned int /*h */ , - WindowPtr /*pSib */ - ); - -extern _X_EXPORT WindowPtr miGetLayerWindow(WindowPtr /*pWin */ - ); - -extern _X_EXPORT void miSetShape(WindowPtr /*pWin */ , - int /*kind */ - ); - -extern _X_EXPORT void miChangeBorderWidth(WindowPtr /*pWin */ , - unsigned int /*width */ - ); - -extern _X_EXPORT void miMarkUnrealizedWindow(WindowPtr /*pChild */ , - WindowPtr /*pWin */ , - Bool /*fromConfigure */ - ); - -extern _X_EXPORT WindowPtr miSpriteTrace(SpritePtr pSprite, int x, int y); - -extern _X_EXPORT WindowPtr miXYToWindow(ScreenPtr pScreen, SpritePtr pSprite, int x, int y); - /* mizerarc.c */ extern _X_EXPORT void miZeroPolyArc(DrawablePtr /*pDraw */ , diff --git a/mi/mi_priv.h b/mi/mi_priv.h index 26c9d158f..a9360c9b3 100644 --- a/mi/mi_priv.h +++ b/mi/mi_priv.h @@ -5,8 +5,71 @@ #ifndef _XSERVER_MI_PRIV_H #define _XSERVER_MI_PRIV_H -#include "screenint.h" +#include <X11/Xdefs.h> +#include <X11/Xprotostr.h> + +#include "dix/screenint_priv.h" +#include "include/callback.h" +#include "include/events.h" +#include "include/gc.h" +#include "include/pixmap.h" +#include "include/regionstr.h" +#include "include/screenint.h" +#include "include/validate.h" +#include "include/window.h" +#include "mi/mi.h" + +#define SetInstalledmiColormap(s,c) \ + (dixSetPrivate(&(s)->devPrivates, micmapScrPrivateKey, c)) void miScreenClose(ScreenPtr pScreen); +void miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs); +void miStepDash(int dist, int * pDashIndex, unsigned char * pDash, + int numInDashList, int *pDashOffset); + +Bool mieqInit(void); +void mieqFini(void); +void mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e); +void mieqSwitchScreen(DeviceIntPtr pDev, ScreenPtr pScreen, Bool set_dequeue_screen); +void mieqProcessDeviceEvent(DeviceIntPtr dev, InternalEvent *event, ScreenPtr screen); +void mieqProcessInputEvents(void); +void mieqAddCallbackOnDrained(CallbackProcPtr callback, void *param); +void mieqRemoveCallbackOnDrained(CallbackProcPtr callback, void *param); + +/** + * Custom input event handler. If you need to process input events in some + * other way than the default path, register an input event handler for the + * given internal event type. + */ +typedef void (*mieqHandler) (int screen, InternalEvent *event, + DeviceIntPtr dev); +void mieqSetHandler(int event, mieqHandler handler); + +void miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy); + +void miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what); + +void miSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h, + unsigned int subWindowMode); +int miShapedWindowIn(RegionPtr universe, RegionPtr bounding, BoxPtr rect, + int x, int y); +int miValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind); + +void miClearToBackground(WindowPtr pWin, int x, int y, int w, int h, + Bool generateExposures); +void miMarkWindow(WindowPtr pWin); +Bool miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, + WindowPtr *ppLayerWin); +void miHandleValidateExposures(WindowPtr pWin); +void miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind); +void miResizeWindow(WindowPtr pWin, int x, int y, unsigned int w, + unsigned int h, WindowPtr pSib); +WindowPtr miGetLayerWindow(WindowPtr pWin); +void miSetShape(WindowPtr pWin, int kind); +void miChangeBorderWidth(WindowPtr pWin, unsigned int width); +void miMarkUnrealizedWindow(WindowPtr pChild, WindowPtr pWin, Bool fromConfigure); +WindowPtr miSpriteTrace(SpritePtr pSprite, int x, int y); +WindowPtr miXYToWindow(ScreenPtr pScreen, SpritePtr pSprite, int x, int y); + #endif /* _XSERVER_MI_PRIV_H */ diff --git a/mi/miarc.c b/mi/miarc.c index 3a0ecc446..9ea4a6155 100644 --- a/mi/miarc.c +++ b/mi/miarc.c @@ -46,22 +46,22 @@ SOFTWARE. /* Author: Keith Packard and Bob Scheifler */ /* Warning: this code is toxic, do not dally very long here. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <math.h> #include <X11/X.h> #include <X11/Xprotostr.h> +#include <X11/Xfuncproto.h> + +#include "mi/mi_priv.h" + #include "misc.h" #include "gcstruct.h" #include "scrnintstr.h" #include "pixmapstr.h" #include "windowstr.h" #include "mifpoly.h" -#include "mi.h" #include "mifillarc.h" -#include <X11/Xfuncproto.h> #define EPSILON 0.000001 #define ISEQUAL(a,b) (fabs((a) - (b)) <= EPSILON) diff --git a/mi/mibitblt.c b/mi/mibitblt.c deleted file mode 100644 index 0b13e49e4..000000000 --- a/mi/mibitblt.c +++ /dev/null @@ -1,776 +0,0 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* Author: Todd Newman (aided and abetted by Mr. Drewry) */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xprotostr.h> - -#include "misc.h" -#include "gcstruct.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "mi.h" -#include "regionstr.h" -#include <X11/Xmd.h> -#include "servermd.h" - -#ifdef __MINGW32__ -#define ffs __builtin_ffs -#endif - -/* MICOPYAREA -- public entry for the CopyArea request - * For each rectangle in the source region - * get the pixels with GetSpans - * set them in the destination with SetSpans - * We let SetSpans worry about clipping to the destination. - */ -_X_COLD RegionPtr -miCopyArea(DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - int xIn, int yIn, int widthSrc, int heightSrc, int xOut, int yOut) -{ - DDXPointPtr ppt, pptFirst; - unsigned int *pwidthFirst, *pwidth, *pbits; - BoxRec srcBox, *prect; - - /* may be a new region, or just a copy */ - RegionPtr prgnSrcClip; - - /* non-0 if we've created a src clip */ - RegionPtr prgnExposed; - int realSrcClip = 0; - int srcx, srcy, dstx, dsty, i, j, y, width, height, xMin, xMax, yMin, yMax; - unsigned int *ordering; - int numRects; - BoxPtr boxes; - - srcx = xIn + pSrcDrawable->x; - srcy = yIn + pSrcDrawable->y; - - /* If the destination isn't realized, this is easy */ - if (pDstDrawable->type == DRAWABLE_WINDOW && - !((WindowPtr) pDstDrawable)->realized) - return NULL; - - /* clip the source */ - if (pSrcDrawable->type == DRAWABLE_PIXMAP) { - BoxRec box; - - box.x1 = pSrcDrawable->x; - box.y1 = pSrcDrawable->y; - box.x2 = pSrcDrawable->x + (int) pSrcDrawable->width; - box.y2 = pSrcDrawable->y + (int) pSrcDrawable->height; - - prgnSrcClip = RegionCreate(&box, 1); - realSrcClip = 1; - } - else { - if (pGC->subWindowMode == IncludeInferiors) { - prgnSrcClip = NotClippedByChildren((WindowPtr) pSrcDrawable); - realSrcClip = 1; - } - else - prgnSrcClip = &((WindowPtr) pSrcDrawable)->clipList; - } - - /* If the src drawable is a window, we need to translate the srcBox so - * that we can compare it with the window's clip region later on. */ - srcBox.x1 = srcx; - srcBox.y1 = srcy; - srcBox.x2 = srcx + widthSrc; - srcBox.y2 = srcy + heightSrc; - - dstx = xOut; - dsty = yOut; - if (pGC->miTranslate) { - dstx += pDstDrawable->x; - dsty += pDstDrawable->y; - } - - pptFirst = ppt = xallocarray(heightSrc, sizeof(DDXPointRec)); - pwidthFirst = pwidth = xallocarray(heightSrc, sizeof(unsigned int)); - numRects = RegionNumRects(prgnSrcClip); - boxes = RegionRects(prgnSrcClip); - ordering = xallocarray(numRects, sizeof(unsigned int)); - if (!pptFirst || !pwidthFirst || !ordering) { - free(ordering); - free(pwidthFirst); - free(pptFirst); - if (realSrcClip) - RegionDestroy(prgnSrcClip); - return NULL; - } - - /* If not the same drawable then order of move doesn't matter. - Following assumes that boxes are sorted from top - to bottom and left to right. - */ - if ((pSrcDrawable != pDstDrawable) && - ((pGC->subWindowMode != IncludeInferiors) || - (pSrcDrawable->type == DRAWABLE_PIXMAP) || - (pDstDrawable->type == DRAWABLE_PIXMAP))) - for (i = 0; i < numRects; i++) - ordering[i] = i; - else { /* within same drawable, must sequence moves carefully! */ - if (dsty <= srcBox.y1) { /* Scroll up or stationary vertical. - Vertical order OK */ - if (dstx <= srcBox.x1) /* Scroll left or stationary horizontal. - Horizontal order OK as well */ - for (i = 0; i < numRects; i++) - ordering[i] = i; - else { /* scroll right. must reverse horizontal banding of rects. */ - for (i = 0, j = 1, xMax = 0; i < numRects; j = i + 1, xMax = i) { - /* find extent of current horizontal band */ - y = boxes[i].y1; /* band has this y coordinate */ - while ((j < numRects) && (boxes[j].y1 == y)) - j++; - /* reverse the horizontal band in the output ordering */ - for (j--; j >= xMax; j--, i++) - ordering[i] = j; - } - } - } - else { /* Scroll down. Must reverse vertical banding. */ - if (dstx < srcBox.x1) { /* Scroll left. Horizontal order OK. */ - for (i = numRects - 1, j = i - 1, yMin = i, yMax = 0; - i >= 0; j = i - 1, yMin = i) { - /* find extent of current horizontal band */ - y = boxes[i].y1; /* band has this y coordinate */ - while ((j >= 0) && (boxes[j].y1 == y)) - j--; - /* reverse the horizontal band in the output ordering */ - for (j++; j <= yMin; j++, i--, yMax++) - ordering[yMax] = j; - } - } - else /* Scroll right or horizontal stationary. - Reverse horizontal order as well (if stationary, horizontal - order can be swapped without penalty and this is faster - to compute). */ - for (i = 0, j = numRects - 1; i < numRects; i++, j--) - ordering[i] = j; - } - } - - for (i = 0; i < numRects; i++) { - prect = &boxes[ordering[i]]; - xMin = max(prect->x1, srcBox.x1); - xMax = min(prect->x2, srcBox.x2); - yMin = max(prect->y1, srcBox.y1); - yMax = min(prect->y2, srcBox.y2); - /* is there anything visible here? */ - if (xMax <= xMin || yMax <= yMin) - continue; - - ppt = pptFirst; - pwidth = pwidthFirst; - y = yMin; - height = yMax - yMin; - width = xMax - xMin; - - for (j = 0; j < height; j++) { - /* We must untranslate before calling GetSpans */ - ppt->x = xMin; - ppt++->y = y++; - *pwidth++ = width; - } - pbits = xallocarray(height, PixmapBytePad(width, pSrcDrawable->depth)); - if (pbits) { - (*pSrcDrawable->pScreen->GetSpans) (pSrcDrawable, width, pptFirst, - (int *) pwidthFirst, height, - (char *) pbits); - ppt = pptFirst; - pwidth = pwidthFirst; - xMin -= (srcx - dstx); - y = yMin - (srcy - dsty); - for (j = 0; j < height; j++) { - ppt->x = xMin; - ppt++->y = y++; - *pwidth++ = width; - } - - (*pGC->ops->SetSpans) (pDstDrawable, pGC, (char *) pbits, pptFirst, - (int *) pwidthFirst, height, TRUE); - free(pbits); - } - } - prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, xIn, yIn, - widthSrc, heightSrc, xOut, yOut); - if (realSrcClip) - RegionDestroy(prgnSrcClip); - - free(ordering); - free(pwidthFirst); - free(pptFirst); - return prgnExposed; -} - -/* MIGETPLANE -- gets a bitmap representing one plane of pDraw - * A helper used for CopyPlane and XY format GetImage - * No clever strategy here, we grab a scanline at a time, pull out the - * bits and then stuff them in a 1 bit deep map. - */ -/* - * This should be replaced with something more general. mi shouldn't have to - * care about such things as scanline padding et alia. - */ -_X_COLD static MiBits * -miGetPlane(DrawablePtr pDraw, int planeNum, /* number of the bitPlane */ - int sx, int sy, int w, int h, MiBits * result) -{ - int i, j, k, width, bitsPerPixel, widthInBytes; - DDXPointRec pt = { 0, 0 }; - MiBits pixel; - MiBits bit; - unsigned char *pCharsOut = NULL; - -#if BITMAP_SCANLINE_UNIT == 8 -#define OUT_TYPE unsigned char -#endif -#if BITMAP_SCANLINE_UNIT == 16 -#define OUT_TYPE CARD16 -#endif -#if BITMAP_SCANLINE_UNIT == 32 -#define OUT_TYPE CARD32 -#endif -#if BITMAP_SCANLINE_UNIT == 64 -#define OUT_TYPE CARD64 -#endif - - OUT_TYPE *pOut; - int delta = 0; - - sx += pDraw->x; - sy += pDraw->y; - widthInBytes = BitmapBytePad(w); - if (!result) - result = calloc(h, widthInBytes); - if (!result) - return NULL; - bitsPerPixel = pDraw->bitsPerPixel; - pOut = (OUT_TYPE *) result; - if (bitsPerPixel == 1) { - pCharsOut = (unsigned char *) result; - width = w; - } - else { - delta = (widthInBytes / (BITMAP_SCANLINE_UNIT / 8)) - - (w / BITMAP_SCANLINE_UNIT); - width = 1; -#if IMAGE_BYTE_ORDER == MSBFirst - planeNum += (32 - bitsPerPixel); -#endif - } - pt.y = sy; - for (i = h; --i >= 0; pt.y++) { - pt.x = sx; - if (bitsPerPixel == 1) { - (*pDraw->pScreen->GetSpans) (pDraw, width, &pt, &width, 1, - (char *) pCharsOut); - pCharsOut += widthInBytes; - } - else { - k = 0; - for (j = w; --j >= 0; pt.x++) { - /* Fetch the next pixel */ - (*pDraw->pScreen->GetSpans) (pDraw, width, &pt, &width, 1, - (char *) &pixel); - /* - * Now get the bit and insert into a bitmap in XY format. - */ - bit = (pixel >> planeNum) & 1; -#if 0 - /* XXX assuming bit order == byte order */ -#if BITMAP_BIT_ORDER == LSBFirst - bit <<= k; -#else - bit <<= ((BITMAP_SCANLINE_UNIT - 1) - k); -#endif -#else - /* XXX assuming byte order == LSBFirst */ - if (screenInfo.bitmapBitOrder == LSBFirst) - bit <<= k; - else - bit <<= ((screenInfo.bitmapScanlineUnit - 1) - - (k % screenInfo.bitmapScanlineUnit)) + - ((k / screenInfo.bitmapScanlineUnit) * - screenInfo.bitmapScanlineUnit); -#endif - *pOut |= (OUT_TYPE) bit; - k++; - if (k == BITMAP_SCANLINE_UNIT) { - pOut++; - k = 0; - } - } - pOut += delta; - } - } - return result; - -} - -/* MIOPQSTIPDRAWABLE -- use pbits as an opaque stipple for pDraw. - * Drawing through the clip mask we SetSpans() the bits into a - * bitmap and stipple those bits onto the destination drawable by doing a - * PolyFillRect over the whole drawable, - * then we invert the bitmap by copying it onto itself with an alu of - * GXinvert, invert the foreground/background colors of the gc, and draw - * the background bits. - * Note how the clipped out bits of the bitmap are always the background - * color so that the stipple never causes FillRect to draw them. - */ -_X_COLD static void -miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc, - MiBits * pbits, int srcx, int w, int h, int dstx, int dsty) -{ - int oldfill, i; - unsigned long oldfg; - int *pwidth, *pwidthFirst; - ChangeGCVal gcv[6]; - PixmapPtr pStipple, pPixmap; - DDXPointRec oldOrg; - GCPtr pGCT; - DDXPointPtr ppt, pptFirst; - xRectangle rect; - RegionPtr prgnSrcClip; - - pPixmap = (*pDraw->pScreen->CreatePixmap) - (pDraw->pScreen, w + srcx, h, 1, CREATE_PIXMAP_USAGE_SCRATCH); - if (!pPixmap) - return; - - /* Put the image into a 1 bit deep pixmap */ - pGCT = GetScratchGC(1, pDraw->pScreen); - if (!pGCT) { - (*pDraw->pScreen->DestroyPixmap) (pPixmap); - return; - } - /* First set the whole pixmap to 0 */ - gcv[0].val = 0; - ChangeGC(NullClient, pGCT, GCBackground, gcv); - ValidateGC((DrawablePtr) pPixmap, pGCT); - miClearDrawable((DrawablePtr) pPixmap, pGCT); - ppt = pptFirst = xallocarray(h, sizeof(DDXPointRec)); - pwidth = pwidthFirst = xallocarray(h, sizeof(int)); - if (!pptFirst || !pwidthFirst) { - free(pwidthFirst); - free(pptFirst); - FreeScratchGC(pGCT); - return; - } - - /* we need a temporary region because ChangeClip must be assumed - to destroy what it's sent. note that this means we don't - have to free prgnSrcClip ourselves. - */ - prgnSrcClip = RegionCreate(NULL, 0); - RegionCopy(prgnSrcClip, prgnSrc); - RegionTranslate(prgnSrcClip, srcx, 0); - (*pGCT->funcs->ChangeClip) (pGCT, CT_REGION, prgnSrcClip, 0); - ValidateGC((DrawablePtr) pPixmap, pGCT); - - /* Since we know pDraw is always a pixmap, we never need to think - * about translation here */ - for (i = 0; i < h; i++) { - ppt->x = 0; - ppt++->y = i; - *pwidth++ = w + srcx; - } - - (*pGCT->ops->SetSpans) ((DrawablePtr) pPixmap, pGCT, (char *) pbits, - pptFirst, pwidthFirst, h, TRUE); - free(pwidthFirst); - free(pptFirst); - - /* Save current values from the client GC */ - oldfill = pGC->fillStyle; - pStipple = pGC->stipple; - if (pStipple) - pStipple->refcnt++; - oldOrg = pGC->patOrg; - - /* Set a new stipple in the drawable */ - gcv[0].val = FillStippled; - gcv[1].ptr = pPixmap; - gcv[2].val = dstx - srcx; - gcv[3].val = dsty; - - ChangeGC(NullClient, pGC, - GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, - gcv); - ValidateGC(pDraw, pGC); - - /* Fill the drawable with the stipple. This will draw the - * foreground color wherever 1 bits are set, leaving everything - * with 0 bits untouched. Note that the part outside the clip - * region is all 0s. */ - rect.x = dstx; - rect.y = dsty; - rect.width = w; - rect.height = h; - (*pGC->ops->PolyFillRect) (pDraw, pGC, 1, &rect); - - /* Invert the tiling pixmap. This sets 0s for 1s and 1s for 0s, only - * within the clipping region, the part outside is still all 0s */ - gcv[0].val = GXinvert; - ChangeGC(NullClient, pGCT, GCFunction, gcv); - ValidateGC((DrawablePtr) pPixmap, pGCT); - (*pGCT->ops->CopyArea) ((DrawablePtr) pPixmap, (DrawablePtr) pPixmap, - pGCT, 0, 0, w + srcx, h, 0, 0); - - /* Swap foreground and background colors on the GC for the drawable. - * Now when we fill the drawable, we will fill in the "Background" - * values */ - oldfg = pGC->fgPixel; - gcv[0].val = pGC->bgPixel; - gcv[1].val = oldfg; - gcv[2].ptr = pPixmap; - ChangeGC(NullClient, pGC, GCForeground | GCBackground | GCStipple, gcv); - ValidateGC(pDraw, pGC); - /* PolyFillRect might have bashed the rectangle */ - rect.x = dstx; - rect.y = dsty; - rect.width = w; - rect.height = h; - (*pGC->ops->PolyFillRect) (pDraw, pGC, 1, &rect); - - /* Now put things back */ - if (pStipple) - pStipple->refcnt--; - gcv[0].val = oldfg; - gcv[1].val = pGC->fgPixel; - gcv[2].val = oldfill; - gcv[3].ptr = pStipple; - gcv[4].val = oldOrg.x; - gcv[5].val = oldOrg.y; - ChangeGC(NullClient, pGC, - GCForeground | GCBackground | GCFillStyle | GCStipple | - GCTileStipXOrigin | GCTileStipYOrigin, gcv); - - ValidateGC(pDraw, pGC); - /* put what we hope is a smaller clip region back in the scratch gc */ - (*pGCT->funcs->ChangeClip) (pGCT, CT_NONE, NULL, 0); - FreeScratchGC(pGCT); - (*pDraw->pScreen->DestroyPixmap) (pPixmap); - -} - -/* MICOPYPLANE -- public entry for the CopyPlane request. - * strategy: - * First build up a bitmap out of the bits requested - * build a source clip - * Use the bitmap we've built up as a Stipple for the destination - */ -_X_COLD RegionPtr -miCopyPlane(DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GCPtr pGC, - int srcx, - int srcy, - int width, int height, int dstx, int dsty, unsigned long bitPlane) -{ - MiBits *ptile; - BoxRec box; - RegionPtr prgnSrc, prgnExposed; - - /* incorporate the source clip */ - - box.x1 = srcx + pSrcDrawable->x; - box.y1 = srcy + pSrcDrawable->y; - box.x2 = box.x1 + width; - box.y2 = box.y1 + height; - /* clip to visible drawable */ - if (box.x1 < pSrcDrawable->x) - box.x1 = pSrcDrawable->x; - if (box.y1 < pSrcDrawable->y) - box.y1 = pSrcDrawable->y; - if (box.x2 > pSrcDrawable->x + (int) pSrcDrawable->width) - box.x2 = pSrcDrawable->x + (int) pSrcDrawable->width; - if (box.y2 > pSrcDrawable->y + (int) pSrcDrawable->height) - box.y2 = pSrcDrawable->y + (int) pSrcDrawable->height; - if (box.x1 > box.x2) - box.x2 = box.x1; - if (box.y1 > box.y2) - box.y2 = box.y1; - prgnSrc = RegionCreate(&box, 1); - - if (pSrcDrawable->type != DRAWABLE_PIXMAP) { - /* clip to visible drawable */ - - if (pGC->subWindowMode == IncludeInferiors) { - RegionPtr clipList = NotClippedByChildren((WindowPtr) pSrcDrawable); - - RegionIntersect(prgnSrc, prgnSrc, clipList); - RegionDestroy(clipList); - } - else - RegionIntersect(prgnSrc, prgnSrc, - &((WindowPtr) pSrcDrawable)->clipList); - } - - box = *RegionExtents(prgnSrc); - RegionTranslate(prgnSrc, -box.x1, -box.y1); - - if ((box.x2 > box.x1) && (box.y2 > box.y1)) { - /* minimize the size of the data extracted */ - /* note that we convert the plane mask bitPlane into a plane number */ - box.x1 -= pSrcDrawable->x; - box.x2 -= pSrcDrawable->x; - box.y1 -= pSrcDrawable->y; - box.y2 -= pSrcDrawable->y; - ptile = miGetPlane(pSrcDrawable, ffs(bitPlane) - 1, - box.x1, box.y1, - box.x2 - box.x1, box.y2 - box.y1, (MiBits *) NULL); - if (ptile) { - miOpqStipDrawable(pDstDrawable, pGC, prgnSrc, ptile, 0, - box.x2 - box.x1, box.y2 - box.y1, - dstx + box.x1 - srcx, dsty + box.y1 - srcy); - free(ptile); - } - } - prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, - width, height, dstx, dsty); - RegionDestroy(prgnSrc); - return prgnExposed; -} - -/* MIGETIMAGE -- public entry for the GetImage Request - * We're getting the image into a memory buffer. While we have to use GetSpans - * to read a line from the device (since we don't know what that looks like), - * we can just write into the destination buffer - * - * two different strategies are used, depending on whether we're getting the - * image in Z format or XY format - * Z format: - * Line at a time, GetSpans a line into the destination buffer, then if the - * planemask is not all ones, we do a SetSpans into a temporary buffer (to get - * bits turned off) and then another GetSpans to get stuff back (because - * pixmaps are opaque, and we are passed in the memory to write into). This is - * pretty ugly and slow but works. Life is hard. - * XY format: - * get the single plane specified in planemask - */ -_X_COLD void -miGetImage(DrawablePtr pDraw, int sx, int sy, int w, int h, - unsigned int format, unsigned long planeMask, char *pDst) -{ - unsigned char depth; - int i, linelength, width, srcx, srcy; - DDXPointRec pt = { 0, 0 }; - PixmapPtr pPixmap = NULL; - GCPtr pGC = NULL; - - depth = pDraw->depth; - if (format == ZPixmap) { - if ((((1LL << depth) - 1) & planeMask) != (1LL << depth) - 1) { - ChangeGCVal gcv; - xPoint xpt; - - pGC = GetScratchGC(depth, pDraw->pScreen); - if (!pGC) - return; - pPixmap = (*pDraw->pScreen->CreatePixmap) - (pDraw->pScreen, w, 1, depth, CREATE_PIXMAP_USAGE_SCRATCH); - if (!pPixmap) { - FreeScratchGC(pGC); - return; - } - /* - * Clear the pixmap before doing anything else - */ - ValidateGC((DrawablePtr) pPixmap, pGC); - xpt.x = xpt.y = 0; - width = w; - (*pGC->ops->FillSpans) ((DrawablePtr) pPixmap, pGC, 1, &xpt, &width, - TRUE); - - /* alu is already GXCopy */ - gcv.val = (XID) planeMask; - ChangeGC(NullClient, pGC, GCPlaneMask, &gcv); - ValidateGC((DrawablePtr) pPixmap, pGC); - } - - linelength = PixmapBytePad(w, depth); - srcx = sx + pDraw->x; - srcy = sy + pDraw->y; - for (i = 0; i < h; i++) { - pt.x = srcx; - pt.y = srcy + i; - width = w; - (*pDraw->pScreen->GetSpans) (pDraw, w, &pt, &width, 1, pDst); - if (pPixmap) { - pt.x = 0; - pt.y = 0; - width = w; - (*pGC->ops->SetSpans) ((DrawablePtr) pPixmap, pGC, pDst, - &pt, &width, 1, TRUE); - (*pDraw->pScreen->GetSpans) ((DrawablePtr) pPixmap, w, &pt, - &width, 1, pDst); - } - pDst += linelength; - } - if (pPixmap) { - (*pGC->pScreen->DestroyPixmap) (pPixmap); - FreeScratchGC(pGC); - } - } - else { - (void) miGetPlane(pDraw, ffs(planeMask) - 1, sx, sy, w, h, - (MiBits *) pDst); - } -} - -/* MIPUTIMAGE -- public entry for the PutImage request - * Here we benefit from knowing the format of the bits pointed to by pImage, - * even if we don't know how pDraw represents them. - * Three different strategies are used depending on the format - * XYBitmap Format: - * we just use the Opaque Stipple helper function to cover the destination - * Note that this covers all the planes of the drawable with the - * foreground color (masked with the GC planemask) where there are 1 bits - * and the background color (masked with the GC planemask) where there are - * 0 bits - * XYPixmap format: - * what we're called with is a series of XYBitmaps, but we only want - * each XYPixmap to update 1 plane, instead of updating all of them. - * we set the foreground color to be all 1s and the background to all 0s - * then for each plane, we set the plane mask to only effect that one - * plane and recursive call ourself with the format set to XYBitmap - * (This clever idea courtesy of RGD.) - * ZPixmap format: - * This part is simple, just call SetSpans - */ -_X_COLD void -miPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, - int x, int y, int w, int h, int leftPad, int format, char *pImage) -{ - DDXPointPtr pptFirst, ppt; - int *pwidthFirst, *pwidth; - RegionPtr prgnSrc; - BoxRec box; - unsigned long oldFg, oldBg; - ChangeGCVal gcv[3]; - unsigned long oldPlanemask; - unsigned long i; - long bytesPer; - - if (!w || !h) - return; - switch (format) { - case XYBitmap: - - box.x1 = 0; - box.y1 = 0; - box.x2 = w; - box.y2 = h; - prgnSrc = RegionCreate(&box, 1); - - miOpqStipDrawable(pDraw, pGC, prgnSrc, (MiBits *) pImage, - leftPad, w, h, x, y); - RegionDestroy(prgnSrc); - break; - - case XYPixmap: - depth = pGC->depth; - oldPlanemask = pGC->planemask; - oldFg = pGC->fgPixel; - oldBg = pGC->bgPixel; - gcv[0].val = (XID) ~0; - gcv[1].val = (XID) 0; - ChangeGC(NullClient, pGC, GCForeground | GCBackground, gcv); - bytesPer = (long) h *BitmapBytePad(w + leftPad); - - for (i = (unsigned long) 1 << (depth - 1); i != 0; i >>= 1, pImage += bytesPer) { - if (i & oldPlanemask) { - gcv[0].val = (XID) i; - ChangeGC(NullClient, pGC, GCPlaneMask, gcv); - ValidateGC(pDraw, pGC); - (*pGC->ops->PutImage) (pDraw, pGC, 1, x, y, w, h, leftPad, - XYBitmap, (char *) pImage); - } - } - gcv[0].val = (XID) oldPlanemask; - gcv[1].val = (XID) oldFg; - gcv[2].val = (XID) oldBg; - ChangeGC(NullClient, pGC, GCPlaneMask | GCForeground | GCBackground, - gcv); - ValidateGC(pDraw, pGC); - break; - - case ZPixmap: - ppt = pptFirst = xallocarray(h, sizeof(DDXPointRec)); - pwidth = pwidthFirst = xallocarray(h, sizeof(int)); - if (!pptFirst || !pwidthFirst) { - free(pwidthFirst); - free(pptFirst); - return; - } - if (pGC->miTranslate) { - x += pDraw->x; - y += pDraw->y; - } - - for (i = 0; i < h; i++) { - ppt->x = x; - ppt->y = y + i; - ppt++; - *pwidth++ = w; - } - - (*pGC->ops->SetSpans) (pDraw, pGC, (char *) pImage, pptFirst, - pwidthFirst, h, TRUE); - free(pwidthFirst); - free(pptFirst); - break; - } -} diff --git a/mi/micmap.c b/mi/micmap.c index b4fbbe712..e8b3ad568 100644 --- a/mi/micmap.c +++ b/mi/micmap.c @@ -27,18 +27,26 @@ * are may be debatable. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> + +#include "dix/colormap_priv.h" +#include "mi/mi_priv.h" +#include "os/osdep.h" + #include "scrnintstr.h" #include "colormapst.h" #include "resource.h" #include "globals.h" #include "micmap.h" +#define ALL_VISUALS (StaticGrayMask|GrayScaleMask|StaticColorMask|\ + PseudoColorMask|TrueColorMask|DirectColorMask) +#define LARGE_VISUALS (TrueColorMask|DirectColorMask) +#define SMALL_VISUALS (StaticGrayMask|GrayScaleMask|StaticColorMask|PseudoColorMask) + DevPrivateKeyRec micmapScrPrivateKeyRec; int @@ -322,7 +330,6 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, Pixel redMask, Pixel greenMask, Pixel blueMask) { miVisualsPtr new, *prev, v; - int count; new = malloc(sizeof *new); if (!new) @@ -340,10 +347,7 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, new->redMask = redMask; new->greenMask = greenMask; new->blueMask = blueMask; - count = (visuals >> 1) & 033333333333; - count = visuals - count - ((count >> 1) & 033333333333); - count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */ - new->count = count; + new->count = Ones(visuals); for (prev = &miVisuals; (v = *prev); prev = &v->next); *prev = new; return TRUE; diff --git a/mi/micmap.h b/mi/micmap.h index 0e344b7ac..d8bf7e2c2 100644 --- a/mi/micmap.h +++ b/mi/micmap.h @@ -6,8 +6,6 @@ #define GetInstalledmiColormap(s) \ ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, micmapScrPrivateKey)) -#define SetInstalledmiColormap(s,c) \ - (dixSetPrivate(&(s)->devPrivates, micmapScrPrivateKey, c)) extern _X_EXPORT DevPrivateKeyRec micmapScrPrivateKeyRec; @@ -49,19 +47,4 @@ extern _X_EXPORT Bool miInitVisuals(VisualPtr *, DepthPtr *, int *, int *, #define TrueColorMask (1 << TrueColor) #define DirectColorMask (1 << DirectColor) -#define ALL_VISUALS (StaticGrayMask|\ - GrayScaleMask|\ - StaticColorMask|\ - PseudoColorMask|\ - TrueColorMask|\ - DirectColorMask) - -#define LARGE_VISUALS (TrueColorMask|\ - DirectColorMask) - -#define SMALL_VISUALS (StaticGrayMask|\ - GrayScaleMask|\ - StaticColorMask|\ - PseudoColorMask) - #endif /* _MICMAP_H_ */ diff --git a/mi/micopy.c b/mi/micopy.c index 40096f24c..f2bc9deef 100644 --- a/mi/micopy.c +++ b/mi/micopy.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "mi.h" #include "scrnintstr.h" diff --git a/mi/midash.c b/mi/midash.c index 08f11aa38..fa3a02074 100644 --- a/mi/midash.c +++ b/mi/midash.c @@ -43,9 +43,9 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "mi/mi_priv.h" #include "regionstr.h" #include "mistruct.h" diff --git a/mi/midispcur.c b/mi/midispcur.c index e5a982976..305b6fc68 100644 --- a/mi/midispcur.c +++ b/mi/midispcur.c @@ -29,9 +29,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> @@ -408,7 +406,7 @@ miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, pGC = pBuffer->pSaveGC; if (pSave->drawable.serialNumber != pGC->serialNumber) ValidateGC((DrawablePtr) pSave, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC, + (void) (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC, x, y, w, h, 0, 0); return TRUE; } @@ -432,7 +430,7 @@ miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, pGC = pBuffer->pRestoreGC; if (pWin->drawable.serialNumber != pGC->serialNumber) ValidateGC((DrawablePtr) pWin, pGC); - (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, + (void) (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, 0, 0, w, h, x, y); return TRUE; } @@ -32,24 +32,27 @@ in this Software without prior written authorization from The Open Group. * */ -#if HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> #include <X11/Xproto.h> +#include <X11/extensions/XI.h> +#include <X11/extensions/XIproto.h> +#include <X11/extensions/geproto.h> + +#include "dix/cursor_priv.h" +#include "mi/mi_priv.h" +#include "mi/mipointer_priv.h" +#include "os/screensaver.h" + #include "misc.h" #include "windowstr.h" #include "pixmapstr.h" #include "inputstr.h" #include "inpututils.h" -#include "mi.h" #include "mipointer.h" #include "scrnintstr.h" -#include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> -#include <X11/extensions/geproto.h> #include "extinit.h" #include "exglobals.h" #include "eventstr.h" @@ -382,7 +385,7 @@ FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev, * @param copy The event after being copied * @return The master device or NULL if the device is a floating slave. */ -DeviceIntPtr +static DeviceIntPtr CopyGetMasterEvent(DeviceIntPtr sdev, InternalEvent *original, InternalEvent *copy) { diff --git a/mi/miexpose.c b/mi/miexpose.c index 29ac46486..4af84310c 100644 --- a/mi/miexpose.c +++ b/mi/miexpose.c @@ -71,15 +71,15 @@ Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> +#include <X11/Xmd.h> #include <X11/Xproto.h> #include <X11/Xprotostr.h> #include "dix/dix_priv.h" +#include "mi/mi_priv.h" #include "misc.h" #include "regionstr.h" @@ -88,17 +88,13 @@ Equipment Corporation. #include "windowstr.h" #include "pixmap.h" #include "input.h" - #include "dixstruct.h" -#include "mi.h" -#include <X11/Xmd.h> - #include "globals.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ /* machine-independent graphics exposure code. any device that uses @@ -325,7 +321,7 @@ miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy) pe->u.expose.count = i; } -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { int scrnum = pWin->drawable.pScreen->myNum; int x = 0, y = 0; @@ -356,7 +352,7 @@ miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy) pEvent[i].u.expose.y += y; } } -#endif +#endif /* XINERAMA */ DeliverEvents(pWin, pEvent, numRects, NullWindow); @@ -407,9 +403,6 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) BoxPtr pbox; xRectangle *prect; int numRects, regionnumrects; -#ifdef COMPOSITE - WindowPtr orig_pWin = pWin; -#endif /* * Distance from screen to destination drawable, use this @@ -496,6 +489,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) #ifdef COMPOSITE /* Make sure alpha will sample as 1.0 for opaque windows */ if (drawable->depth == 32) { + WindowPtr orig_pWin = pWin; int effective_depth = orig_pWin->drawable.depth; if (effective_depth == 32) { diff --git a/mi/mifillarc.c b/mi/mifillarc.c index 888519edf..1f467db28 100644 --- a/mi/mifillarc.c +++ b/mi/mifillarc.c @@ -26,9 +26,7 @@ Author: Bob Scheifler, MIT X Consortium ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <math.h> #include <X11/X.h> @@ -26,9 +26,7 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "scrnintstr.h" #include "gcstruct.h" diff --git a/mi/miglblt.c b/mi/miglblt.c index 169d44ffc..4314b4091 100644 --- a/mi/miglblt.c +++ b/mi/miglblt.c @@ -44,9 +44,7 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> diff --git a/mi/miinitext.c b/mi/miinitext.c index 04f320118..1864e28c5 100644 --- a/mi/miinitext.c +++ b/mi/miinitext.c @@ -71,21 +71,26 @@ SOFTWARE. * authorization from the copyright holder(s) and author(s). */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef HAVE_XORG_CONFIG_H #include <xorg-config.h> #include "xf86Extensions.h" #endif -#ifdef HAVE_XNEST_CONFIG_H -#include <xnest-config.h> +/* some DDXes must explicitly prohibit some extensions */ +#ifdef DISABLE_EXT_COMPOSITE #undef COMPOSITE +#endif + +#ifdef DISABLE_EXT_DPMS #undef DPMSExtension #endif +#ifdef DISABLE_EXT_MITSHM +#undef MITSHM +#endif + #include "misc.h" #include "extension.h" #include "extinit_priv.h" @@ -97,7 +102,7 @@ SOFTWARE. /* List of built-in (statically linked) extensions */ static const ExtensionModule staticExtensions[] = { - {GEExtensionInit, "Generic Event Extension", &noGEExtension}, + {GEExtensionInit, "Generic Event Extension", NULL}, {ShapeExtensionInit, "SHAPE", &noShapeExtension}, #ifdef MITSHM {ShmExtensionInit, "MIT-SHM", &noMITShmExtension}, @@ -113,9 +118,9 @@ static const ExtensionModule staticExtensions[] = { #ifdef XCSECURITY {SecurityExtensionInit, "SECURITY", &noSecurityExtension}, #endif -#ifdef PANORAMIX +#ifdef XINERAMA {PanoramiXExtensionInit, "XINERAMA", &noPanoramiXExtension}, -#endif +#endif /* XINERAMA */ /* must be before Render to layer DisplayCursor correctly */ {XFixesExtensionInit, "XFIXES", &noXFixesExtension}, #ifdef XF86BIGFONT diff --git a/mi/miline.h b/mi/miline.h index c1a51c15c..7ef3b015a 100644 --- a/mi/miline.h +++ b/mi/miline.h @@ -49,10 +49,6 @@ in this Software without prior written authorization from The Open Group. #define OCTANT7 (1 << (YMAJOR)) #define OCTANT8 (1 << (0)) -#define XMAJOROCTANTS (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8) - -#define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5) - /* * Devices can configure the rendering of routines in mi, mfb, and cfb* * by specifying a thin line bias to be applied to a particular screen @@ -108,17 +104,6 @@ extern _X_EXPORT void miSetZeroLineBias(ScreenPtr /* pScreen */ , if (y > ymax) outcode |= OUT_BELOW;\ } -#define SWAPINT(i, j) \ -{ int _t = i; i = j; j = _t; } - -#define SWAPPT(i, j) \ -{ DDXPointRec _t; _t = i; i = j; j = _t; } - -#define SWAPINT_PAIR(x1, y1, x2, y2)\ -{ int t = x1; x1 = x2; x2 = t;\ - t = y1; y1 = y2; y2 = t;\ -} - #define miGetZeroLineBias(_pScreen) ((unsigned long) (unsigned long*)\ dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey)) @@ -142,11 +127,6 @@ extern _X_EXPORT void miSetZeroLineBias(ScreenPtr /* pScreen */ , #define FIXUP_ERROR(_e, _octant, _bias) \ (_e) -= (((_bias) >> (_octant)) & 1) -#define IsXMajorOctant(_octant) (!((_octant) & YMAJOR)) -#define IsYMajorOctant(_octant) ((_octant) & YMAJOR) -#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING) -#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING) - extern _X_EXPORT DevPrivateKeyRec miZeroLineScreenKeyRec; #define miZeroLineScreenKey (&miZeroLineScreenKeyRec) diff --git a/mi/mioverlay.c b/mi/mioverlay.c index b8b7a5ba8..820133e10 100644 --- a/mi/mioverlay.c +++ b/mi/mioverlay.c @@ -1,14 +1,15 @@ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> + +#include "dix/cursor_priv.h" +#include "mi/mi_priv.h" + #include "scrnintstr.h" #include <X11/extensions/shapeproto.h> #include "validate.h" #include "windowstr.h" -#include "mi.h" #include "gcstruct.h" #include "regionstr.h" #include "privates.h" @@ -1631,12 +1632,6 @@ miOverlayGetPrivateClips(WindowPtr pWin, return FALSE; } -void -miOverlaySetTransFunction(ScreenPtr pScreen, miOverlayTransFunc transFunc) -{ - MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->MakeTransparent = transFunc; -} - Bool miOverlayCopyUnderlay(ScreenPtr pScreen) { @@ -1860,7 +1855,7 @@ MarkUnderlayWindow(WindowPtr pWin) if (pTree->valdata) return; pTree->valdata = - (miOverlayValDataPtr) xnfalloc(sizeof(miOverlayValDataRec)); + (miOverlayValDataPtr) XNFalloc(sizeof(miOverlayValDataRec)); pTree->valdata->oldAbsCorner.x = pWin->drawable.x; pTree->valdata->oldAbsCorner.y = pWin->drawable.y; pTree->valdata->borderVisible = NullRegion; diff --git a/mi/mioverlay.h b/mi/mioverlay.h index f7ed027e9..420a846c2 100644 --- a/mi/mioverlay.h +++ b/mi/mioverlay.h @@ -22,7 +22,6 @@ miOverlayGetPrivateClips(WindowPtr pWin, extern _X_EXPORT Bool miOverlayCollectUnderlayRegions(WindowPtr, RegionPtr *); extern _X_EXPORT void miOverlayComputeCompositeClip(GCPtr, WindowPtr); extern _X_EXPORT Bool miOverlayCopyUnderlay(ScreenPtr); -extern _X_EXPORT void miOverlaySetTransFunction(ScreenPtr, miOverlayTransFunc); extern _X_EXPORT void miOverlaySetRootClip(ScreenPtr, Bool); #endif /* __MIOVERLAY_H */ diff --git a/mi/mipointer.c b/mi/mipointer.c index e330cc122..ae5fa6fad 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -46,20 +46,21 @@ in this Software without prior written authorization from The Open Group. * DIX, DDX and some drivers. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> #include <X11/Xproto.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" +#include "mi/mipointer_priv.h" #include "misc.h" #include "windowstr.h" #include "pixmapstr.h" -#include "mi.h" #include "scrnintstr.h" #include "mipointrst.h" #include "cursorstr.h" @@ -115,6 +116,10 @@ static void miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x, static InternalEvent *mipointermove_events; /* for WarpPointer MotionNotifies */ +static void +miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr, + CursorPtr pCurs, Bool displayed); + Bool miPointerInitialize(ScreenPtr pScreen, miPointerSpriteFuncPtr spriteFuncs, @@ -203,6 +208,8 @@ miPointerDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) return FALSE; pPointer = MIPOINTER(pDev); + if (!pPointer) + return FALSE; pPointer->pCursor = pCursor; pPointer->pScreen = pScreen; @@ -225,6 +232,8 @@ miPointerConstrainCursor(DeviceIntPtr pDev, ScreenPtr pScreen, BoxPtr pBox) miPointerPtr pPointer; pPointer = MIPOINTER(pDev); + if (!pPointer) + return; pPointer->limits = *pBox; pPointer->confined = PointerConfinedToScreen(pDev); @@ -276,6 +285,9 @@ miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen, SetupScreen(pScreen); miPointerPtr pPointer = MIPOINTER(pDev); + if (!pPointer) + return TRUE; + pPointer->generateEvent = generateEvent; if (pScreen->ConstrainCursorHarder) @@ -288,7 +300,7 @@ miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen, return TRUE; } -void +static void miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, Bool displayed) { @@ -382,6 +394,8 @@ miPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) BOOL changedScreen = FALSE; pPointer = MIPOINTER(pDev); + if (!pPointer) + return; if (pPointer->pScreen != pScreen) { mieqSwitchScreen(pDev, pScreen, TRUE); @@ -397,9 +411,9 @@ miPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) * updated to the second screen, and we never receive any events. * (FDO bug #18668) */ if (changedScreen -#ifdef PANORAMIX +#ifdef XINERAMA && noPanoramiXExtension -#endif +#endif /* XINERAMA */ ) { DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER); /* Hack for CVE-2023-5380: if we're moving @@ -507,6 +521,9 @@ miPointerInvalidateSprite(DeviceIntPtr pDev) miPointerPtr pPointer; pPointer = MIPOINTER(pDev); + if (!pPointer) + return; + pPointer->pSpriteCursor = (CursorPtr) 1; } @@ -525,6 +542,8 @@ miPointerSetScreen(DeviceIntPtr pDev, int screen_no, int x, int y) miPointerPtr pPointer; pPointer = MIPOINTER(pDev); + if (!pPointer) + return; pScreen = screenInfo.screens[screen_no]; mieqSwitchScreen(pDev, pScreen, FALSE); @@ -569,6 +588,8 @@ miPointerMoveNoEvent(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) SetupScreen(pScreen); pPointer = MIPOINTER(pDev); + if (!pPointer) + return; /* Hack: We mustn't call into ->MoveCursor for anything but the * VCP, as this may cause a non-HW rendered cursor to be rendered while @@ -721,8 +742,15 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, void miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y) { - *x = MIPOINTER(pDev)->x; - *y = MIPOINTER(pDev)->y; + miPointerPtr pPointer = MIPOINTER(pDev); + if (pPointer) { + *x = pPointer->x; + *y = pPointer->y; + } + else { + *x = 0; + *y = 0; + } } /** diff --git a/mi/mipointer.h b/mi/mipointer.h index 00f523740..ba1710a25 100644 --- a/mi/mipointer.h +++ b/mi/mipointer.h @@ -77,24 +77,8 @@ extern _X_EXPORT Bool miDCInitialize(ScreenPtr /*pScreen */ , miPointerScreenFuncPtr /*screenFuncs */ ); -extern _X_EXPORT Bool miPointerInitialize(ScreenPtr /*pScreen */ , - miPointerSpriteFuncPtr - /*spriteFuncs */ , - miPointerScreenFuncPtr - /*screenFuncs */ , - Bool /*waitForUpdate */ - ); - -extern _X_EXPORT void miPointerWarpCursor(DeviceIntPtr /*pDev */ , - ScreenPtr /*pScreen */ , - int /*x */ , - int /*y */ - ); - extern _X_EXPORT ScreenPtr miPointerGetScreen(DeviceIntPtr pDev); -extern _X_EXPORT void -miPointerSetScreen(DeviceIntPtr pDev, int screen_num, int x, int y); /* Returns the current cursor position. */ extern _X_EXPORT void @@ -106,25 +90,40 @@ extern _X_EXPORT ScreenPtr miPointerSetPosition(DeviceIntPtr pDev, int mode, double *x, double *y, int *nevents, InternalEvent *events); -extern _X_EXPORT void -miPointerUpdateSprite(DeviceIntPtr pDev); - -/* Invalidate current sprite, forcing reload on next - * sprite setting (window crossing, grab action, etc) - */ -extern _X_EXPORT void -miPointerInvalidateSprite(DeviceIntPtr pDev); - -/* Sets whether the sprite should be updated immediately on pointer moves */ -extern _X_EXPORT Bool -miPointerSetWaitForUpdate(ScreenPtr pScreen, Bool wait); - -extern _X_EXPORT DevPrivateKeyRec miPointerPrivKeyRec; - -#define miPointerPrivKey (&miPointerPrivKeyRec) - extern _X_EXPORT DevPrivateKeyRec miPointerScreenKeyRec; #define miPointerScreenKey (&miPointerScreenKeyRec) +/** + * @brief initialize pointer cursor with custom handling + * + * For DDX'es that need their own handling of pointer cursors, + * and can't use the generic "soft cursor" that's created via + * miDCInitialize(). + * + * That can be the case on certain video HW with it's own sprite support, + * or on remote display protocols like RDP, where the client get the cursor + * pixmaps sent over the wire and is responsible for painting it on his side. + * + * Overwrites ScreenPtr vectors: + * + * ConstrainCursor, CursorLimits, DisplayCursor, RealizeCursor, + * UnrealizeCursor, SetCursorPosition, RecolorCursor, DeviceCursorCleanup + * DeviceCursorInitialize + * + * Hooks to ScreenPtr vectors: CloseScreen + * + * @param pScreen pointer to ScreenRec the pointer handling applies to + * @param spireFuncs pointer to miPointerSpriteFuncPtr call vectors + * @param screenFuncs pointer to miPointerScreenFuncPtr call vectors + * @param waitForUpdate TRUE if MI shouldn't redraw the pointer immediately, + but wait for somebody else triggering it explicitly + * @return TRUE on success, FALSE usually indicates allocation failure + */ +_X_EXPORT Bool +miPointerInitialize(ScreenPtr pScreen, + miPointerSpriteFuncPtr spriteFuncs, + miPointerScreenFuncPtr screenFuncs, + Bool waitForUpdate); + #endif /* MIPOINTER_H */ diff --git a/mi/mipointer_priv.h b/mi/mipointer_priv.h new file mode 100644 index 000000000..cc4ce9940 --- /dev/null +++ b/mi/mipointer_priv.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_MI_MIPOINTER_PRIV_H +#define _XSERVER_MI_MIPOINTER_PRIV_H + +#include <X11/Xdefs.h> + +#include "dix/screenint_priv.h" +#include "include/input.h" +#include "mi/mipointer.h" + +void miPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y); +void miPointerSetScreen(DeviceIntPtr pDev, int screen_num, int x, int y); +void miPointerUpdateSprite(DeviceIntPtr pDev); + + /* Invalidate current sprite, forcing reload on next + * sprite setting (window crossing, grab action, etc) + */ +void miPointerInvalidateSprite(DeviceIntPtr pDev); + +/* Sets whether the sprite should be updated immediately on pointer moves */ +Bool miPointerSetWaitForUpdate(ScreenPtr pScreen, Bool wait); + +extern DevPrivateKeyRec miPointerPrivKeyRec; + +#define miPointerPrivKey (&miPointerPrivKeyRec) + +#endif /* _XSERVER_MI_MIPOINTER_PRIV_H */ diff --git a/mi/mipoly.c b/mi/mipoly.c index a97e2bb64..3cdb56925 100644 --- a/mi/mipoly.c +++ b/mi/mipoly.c @@ -48,9 +48,7 @@ SOFTWARE. * * Written by Brian Kelleher; June 1986 */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include "windowstr.h" diff --git a/mi/mipolypnt.c b/mi/mipolypnt.c index 1c4150dfb..1f688a028 100644 --- a/mi/mipolypnt.c +++ b/mi/mipolypnt.c @@ -43,9 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xprotostr.h> diff --git a/mi/mipolyrect.c b/mi/mipolyrect.c index 7ebf9db8d..acec81fb3 100644 --- a/mi/mipolyrect.c +++ b/mi/mipolyrect.c @@ -43,9 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xprotostr.h> diff --git a/mi/mipolyseg.c b/mi/mipolyseg.c index 7909b398b..cdfcba1dd 100644 --- a/mi/mipolyseg.c +++ b/mi/mipolyseg.c @@ -43,9 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xprotostr.h> diff --git a/mi/mipolytext.c b/mi/mipolytext.c index f1e5ed867..ea3d1b017 100644 --- a/mi/mipolytext.c +++ b/mi/mipolytext.c @@ -52,9 +52,7 @@ SOFTWARE. * Date: Thu Feb 5 1987 */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> diff --git a/mi/mipushpxl.c b/mi/mipushpxl.c index f6a1b5259..028b8633e 100644 --- a/mi/mipushpxl.c +++ b/mi/mipushpxl.c @@ -43,9 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include "gcstruct.h" diff --git a/mi/miscrinit.c b/mi/miscrinit.c index 57571b9ab..8165d0f38 100644 --- a/mi/miscrinit.c +++ b/mi/miscrinit.c @@ -26,9 +26,7 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> @@ -62,6 +60,8 @@ typedef struct { int ysize; } miScreenInitParmsRec, *miScreenInitParmsPtr; +#define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5) + /* this plugs into pScreen->ModifyPixmapHeader */ Bool miModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, diff --git a/mi/misprite.c b/mi/misprite.c index e0af13ad9..67357a914 100644 --- a/mi/misprite.c +++ b/mi/misprite.c @@ -29,21 +29,22 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xproto.h> +#include <X11/fonts/font.h> +#include <X11/fonts/fontstruct.h> +#include "dix/colormap_priv.h" #include "dix/dix_priv.h" +#include "mi/mipointer_priv.h" #include "misc.h" #include "pixmapstr.h" #include "input.h" #include "mi.h" #include "cursorstr.h" -#include <X11/fonts/font.h> #include "scrnintstr.h" #include "colormapst.h" #include "windowstr.h" @@ -51,7 +52,6 @@ in this Software without prior written authorization from The Open Group. #include "mipointer.h" #include "misprite.h" #include "dixfontstr.h" -#include <X11/fonts/fontstruct.h> #include "inputstr.h" #include "damage.h" diff --git a/mi/misprite.h b/mi/misprite.h index 099cd0e38..aa67f3229 100644 --- a/mi/misprite.h +++ b/mi/misprite.h @@ -31,18 +31,16 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ -extern Bool miSpriteInitialize(ScreenPtr /*pScreen */ , - miPointerScreenFuncPtr /*screenFuncs */ - ); - -extern Bool miDCRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); -extern Bool miDCUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); -extern Bool miDCPutUpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, - CursorPtr pCursor, int x, int y, - unsigned long source, unsigned long mask); -extern Bool miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, - int x, int y, int w, int h); -extern Bool miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, - int x, int y, int w, int h); -extern Bool miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen); -extern void miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen); +Bool miSpriteInitialize(ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs); + +Bool miDCRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); +Bool miDCUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); +Bool miDCPutUpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, + CursorPtr pCursor, int x, int y, + unsigned long source, unsigned long mask); +Bool miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, + int x, int y, int w, int h); +Bool miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, + int x, int y, int w, int h); +Bool miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen); +void miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen); diff --git a/mi/mivaltree.c b/mi/mivaltree.c index ea6889fdc..edab5dc1b 100644 --- a/mi/mivaltree.c +++ b/mi/mivaltree.c @@ -88,15 +88,15 @@ Equipment Corporation. * Bob Scheifler -- avoid miComputeClips for unmapped windows, * valdata changes */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> + +#include "mi/mi_priv.h" + #include "scrnintstr.h" #include "validate.h" #include "windowstr.h" -#include "mi.h" #include "regionstr.h" #include "mivalidate.h" #include "globals.h" diff --git a/mi/miwideline.c b/mi/miwideline.c index 6e02d70cb..0498e9cd8 100644 --- a/mi/miwideline.c +++ b/mi/miwideline.c @@ -52,9 +52,7 @@ SOFTWARE. * bresenham zero-width lines, except walks an X edge */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #ifdef _XOPEN_SOURCE @@ -65,11 +63,13 @@ SOFTWARE. #undef _XOPEN_SOURCE #endif #include <X11/X.h> + +#include "mi/mi_priv.h" + #include "windowstr.h" #include "gcstruct.h" #include "regionstr.h" #include "miwideline.h" -#include "mi.h" typedef struct { int count; /* number of spans */ diff --git a/mi/miwindow.c b/mi/miwindow.c index 39c279e18..a4b97a7b8 100644 --- a/mi/miwindow.c +++ b/mi/miwindow.c @@ -44,15 +44,17 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/extensions/shapeconst.h> + +#include "dix/cursor_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" + #include "regionstr.h" #include "region.h" -#include "mi.h" #include "windowstr.h" #include "scrnintstr.h" #include "pixmapstr.h" @@ -124,7 +126,7 @@ miMarkWindow(WindowPtr pWin) if (pWin->valdata) return; - val = (ValidatePtr) xnfalloc(sizeof(ValidateRec)); + val = (ValidatePtr) XNFalloc(sizeof(ValidateRec)); val->before.oldAbsCorner.x = pWin->drawable.x; val->before.oldAbsCorner.y = pWin->drawable.y; val->before.borderVisible = NullRegion; diff --git a/mi/mizerarc.c b/mi/mizerarc.c index e1b5f0c18..90dde9f8b 100644 --- a/mi/mizerarc.c +++ b/mi/mizerarc.c @@ -32,17 +32,17 @@ Author: Bob Scheifler, MIT X Consortium * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289 */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <math.h> #include <X11/X.h> #include <X11/Xprotostr.h> + +#include "mi/mi_priv.h" + #include "regionstr.h" #include "gcstruct.h" #include "pixmapstr.h" -#include "mi.h" #include "mizerarc.h" #define FULLCIRCLE (360 * 64) diff --git a/mi/mizerclip.c b/mi/mizerclip.c index 0ae964190..75c6f70db 100644 --- a/mi/mizerclip.c +++ b/mi/mizerclip.c @@ -43,9 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> @@ -397,6 +395,19 @@ the numerator is therefore (2^32 - 1), which does not overflow an unsigned #define EQN8 (T_2NDX | T_ADDDY | T_BIASSUBONE | T_DIV2DY) #define EQN8B (T_2NDX | T_ADDDY | T_BIASSUBONE | T_DIV2DY) +#define SWAPINT(i, j) \ +{ int _t = i; i = j; j = _t; } + +#define SWAPINT_PAIR(x1, y1, x2, y2)\ +{ int t = x1; x1 = x2; x2 = t;\ + t = y1; y1 = y2; y2 = t;\ +} + +#define IsXMajorOctant(_octant) (!((_octant) & YMAJOR)) +#define IsYMajorOctant(_octant) ((_octant) & YMAJOR) +#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING) +#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING) + /* miZeroClipLine * * returns: 1 for partially clipped line diff --git a/mi/mizerline.c b/mi/mizerline.c index 1a0ca3427..dc4790ba8 100644 --- a/mi/mizerline.c +++ b/mi/mizerline.c @@ -43,9 +43,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> diff --git a/miext/damage/damage.c b/miext/damage/damage.c index 0ed392ca2..0b626eba4 100644 --- a/miext/damage/damage.c +++ b/miext/damage/damage.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> @@ -1504,7 +1502,8 @@ damageDestroyPixmap(PixmapPtr pPixmap) } } unwrap(pScrPriv, pScreen, DestroyPixmap); - (*pScreen->DestroyPixmap) (pPixmap); + if (pScreen->DestroyPixmap) + pScreen->DestroyPixmap(pPixmap); wrap(pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); return TRUE; } diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c index 44c2c3789..b91b7dce5 100644 --- a/miext/rootless/rootlessCommon.c +++ b/miext/rootless/rootlessCommon.c @@ -29,9 +29,7 @@ * use or other dealings in this Software without prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> /* For NULL */ #include <limits.h> /* For CHAR_BIT */ @@ -135,10 +133,8 @@ RootlessResolveColormap(ScreenPtr pScreen, int first_color, } unsigned long RootlessWID(WindowPtr pWindow) { - ScreenPtr pScreen = pWindow->drawable.pScreen; WindowPtr top = TopLevelParent(pWindow); RootlessWindowRec *winRec; - PixmapPtr curPixmap; if (top == NULL) { return 0; diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c index 5af18a4a0..1f6822831 100644 --- a/miext/rootless/rootlessGC.c +++ b/miext/rootless/rootlessGC.c @@ -29,9 +29,7 @@ * use or other dealings in this Software without prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> /* For NULL */ #include "mi.h" diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c index 79fe3507b..ddb1cf607 100644 --- a/miext/rootless/rootlessScreen.c +++ b/miext/rootless/rootlessScreen.c @@ -29,11 +29,16 @@ * use or other dealings in this Software without prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include "mi.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> + +#include "dix/colormap_priv.h" +#include "mi/mi_priv.h" + #include "scrnintstr.h" #include "gcstruct.h" #include "pixmapstr.h" @@ -43,11 +48,6 @@ #include "picturestr.h" #include "colormapst.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <string.h> - #include "rootlessCommon.h" #include "rootlessWindow.h" diff --git a/miext/rootless/rootlessValTree.c b/miext/rootless/rootlessValTree.c index 409e6a092..beacff99f 100644 --- a/miext/rootless/rootlessValTree.c +++ b/miext/rootless/rootlessValTree.c @@ -89,16 +89,16 @@ Equipment Corporation. * Bob Scheifler -- avoid miComputeClips for unmapped windows, * valdata changes */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> /* For NULL */ -#include <X11/X.h> +#include <X11/X.h> + +#include "mi/mi_priv.h" + #include "scrnintstr.h" #include "validate.h" #include "windowstr.h" -#include "mi.h" #include "regionstr.h" #include "mivalidate.h" diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index 643dedff6..f1cdec307 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -29,17 +29,18 @@ * use or other dealings in this Software without prior written authorization. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> /* For NULL */ #include <limits.h> /* For CHAR_BIT */ #include <assert.h> #include <X11/Xatom.h> + +#include "mi/mi_priv.h" +#include "dix_priv.h" + #ifdef __APPLE__ #include <Xplugin.h> -#include "mi.h" #include "pixmapstr.h" #include "windowstr.h" //#include <X11/extensions/applewm.h> @@ -795,24 +796,12 @@ StartFrameResize(WindowPtr pWin, Bool gravity, ScreenPtr pScreen = pWin->drawable.pScreen; RootlessWindowRec *winRec = WINREC(pWin); - BoxRec rect; - int oldX2, newX2; - int oldY2, newY2; unsigned int weight; - oldX2 = oldX + oldW, newX2 = newX + newW; - oldY2 = oldY + oldH, newY2 = newY + newH; - /* Decide which resize weighting to use */ weight = ResizeWeighting(oldX, oldY, oldW, oldH, oldBW, newX, newY, newW, newH, newBW); - /* Compute intersection between old and new rects */ - rect.x1 = max(oldX, newX); - rect.y1 = max(oldY, newY); - rect.x2 = min(oldX2, newX2); - rect.y2 = min(oldY2, newY2); - RL_DEBUG_MSG("RESIZE TOPLEVEL WINDOW with gravity %i ", gravity); RL_DEBUG_MSG("%d %d %d %d %d %d %d %d %d %d\n", oldX, oldY, oldW, oldH, oldBW, newX, newY, newW, newH, newBW); @@ -849,8 +838,6 @@ FinishFrameResize(WindowPtr pWin, Bool gravity, int oldX, int oldY, unsigned int newBW) { ScreenPtr pScreen = pWin->drawable.pScreen; - RootlessWindowRec *winRec = WINREC(pWin); - int i; /* Redraw everything. FIXME: there must be times when we don't need to do this. Perhaps when top-left weighting and no gravity? */ diff --git a/miext/shadow/sh3224.c b/miext/shadow/sh3224.c index 5d8f27482..e93b5a7fd 100644 --- a/miext/shadow/sh3224.c +++ b/miext/shadow/sh3224.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include "dix-config.h" -#endif #include "shadow.h" #include "fb.h" diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c index e8d0d51b0..cecedee7d 100644 --- a/miext/shadow/shadow.c +++ b/miext/shadow/shadow.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shafb4.c b/miext/shadow/shafb4.c index ae59e2d32..5610ad6bc 100644 --- a/miext/shadow/shafb4.c +++ b/miext/shadow/shafb4.c @@ -23,9 +23,7 @@ * Based on shpacked.c, which is Copyright © 2000 Keith Packard */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shafb8.c b/miext/shadow/shafb8.c index d2b73fc64..7bb72031d 100644 --- a/miext/shadow/shafb8.c +++ b/miext/shadow/shafb8.c @@ -23,9 +23,7 @@ * Based on shpacked.c, which is Copyright © 2000 Keith Packard */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shiplan2p4.c b/miext/shadow/shiplan2p4.c index f37c58d71..ac46bb8b7 100644 --- a/miext/shadow/shiplan2p4.c +++ b/miext/shadow/shiplan2p4.c @@ -23,9 +23,7 @@ * Based on shpacked.c, which is Copyright © 2000 Keith Packard */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shiplan2p8.c b/miext/shadow/shiplan2p8.c index 44cb8d336..01a5c076f 100644 --- a/miext/shadow/shiplan2p8.c +++ b/miext/shadow/shiplan2p8.c @@ -23,9 +23,7 @@ * Based on shpacked.c, which is Copyright © 2000 Keith Packard */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shpacked.c b/miext/shadow/shpacked.c index 5220854c1..25c0dd1ba 100644 --- a/miext/shadow/shpacked.c +++ b/miext/shadow/shpacked.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shplanar.c b/miext/shadow/shplanar.c index 92c7971d2..4c5cf951a 100644 --- a/miext/shadow/shplanar.c +++ b/miext/shadow/shplanar.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shplanar8.c b/miext/shadow/shplanar8.c index 412335940..622430b2b 100644 --- a/miext/shadow/shplanar8.c +++ b/miext/shadow/shplanar8.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdlib.h> diff --git a/miext/shadow/shrot16pack.c b/miext/shadow/shrot16pack.c index 0b7faca6a..a4fad6d46 100644 --- a/miext/shadow/shrot16pack.c +++ b/miext/shadow/shrot16pack.c @@ -23,8 +23,6 @@ #define FUNC shadowUpdateRotate16 #define Data CARD16 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot16pack_180.c b/miext/shadow/shrot16pack_180.c index d8f2633e5..746351e75 100644 --- a/miext/shadow/shrot16pack_180.c +++ b/miext/shadow/shrot16pack_180.c @@ -24,8 +24,6 @@ #define Data CARD16 #define ROTATE 180 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot16pack_270.c b/miext/shadow/shrot16pack_270.c index 4aa471325..fd8b5f68d 100644 --- a/miext/shadow/shrot16pack_270.c +++ b/miext/shadow/shrot16pack_270.c @@ -24,8 +24,6 @@ #define Data CARD16 #define ROTATE 270 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot16pack_270YX.c b/miext/shadow/shrot16pack_270YX.c index 0df1fd51f..5386bb4da 100644 --- a/miext/shadow/shrot16pack_270YX.c +++ b/miext/shadow/shrot16pack_270YX.c @@ -24,8 +24,6 @@ #define Data CARD16 #define ROTATE 270 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpackYX.h" diff --git a/miext/shadow/shrot16pack_90.c b/miext/shadow/shrot16pack_90.c index 81e49151a..4a8848f65 100644 --- a/miext/shadow/shrot16pack_90.c +++ b/miext/shadow/shrot16pack_90.c @@ -24,8 +24,6 @@ #define Data CARD16 #define ROTATE 90 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot16pack_90YX.c b/miext/shadow/shrot16pack_90YX.c index 5fc3b236a..77fd87058 100644 --- a/miext/shadow/shrot16pack_90YX.c +++ b/miext/shadow/shrot16pack_90YX.c @@ -24,8 +24,6 @@ #define Data CARD16 #define ROTATE 90 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpackYX.h" diff --git a/miext/shadow/shrot32pack.c b/miext/shadow/shrot32pack.c index 4a9cbc0ff..083e21661 100644 --- a/miext/shadow/shrot32pack.c +++ b/miext/shadow/shrot32pack.c @@ -23,8 +23,6 @@ #define FUNC shadowUpdateRotate32 #define Data CARD32 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot32pack_180.c b/miext/shadow/shrot32pack_180.c index 8f5fb5760..29cde5060 100644 --- a/miext/shadow/shrot32pack_180.c +++ b/miext/shadow/shrot32pack_180.c @@ -24,8 +24,6 @@ #define Data CARD32 #define ROTATE 180 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot32pack_270.c b/miext/shadow/shrot32pack_270.c index 7d52fd2bf..d25d20e39 100644 --- a/miext/shadow/shrot32pack_270.c +++ b/miext/shadow/shrot32pack_270.c @@ -24,8 +24,6 @@ #define Data CARD32 #define ROTATE 270 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot32pack_90.c b/miext/shadow/shrot32pack_90.c index 0abeb5cdd..36aabc111 100644 --- a/miext/shadow/shrot32pack_90.c +++ b/miext/shadow/shrot32pack_90.c @@ -24,8 +24,6 @@ #define Data CARD32 #define ROTATE 90 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot8pack.c b/miext/shadow/shrot8pack.c index 552d838f3..3e583b021 100644 --- a/miext/shadow/shrot8pack.c +++ b/miext/shadow/shrot8pack.c @@ -23,8 +23,6 @@ #define FUNC shadowUpdateRotate8 #define Data CARD8 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot8pack_180.c b/miext/shadow/shrot8pack_180.c index 526d8f15f..2cf313127 100644 --- a/miext/shadow/shrot8pack_180.c +++ b/miext/shadow/shrot8pack_180.c @@ -24,8 +24,6 @@ #define Data CARD8 #define ROTATE 180 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot8pack_270.c b/miext/shadow/shrot8pack_270.c index 73f82a712..16ef5df14 100644 --- a/miext/shadow/shrot8pack_270.c +++ b/miext/shadow/shrot8pack_270.c @@ -24,8 +24,6 @@ #define Data CARD8 #define ROTATE 270 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrot8pack_90.c b/miext/shadow/shrot8pack_90.c index 73060cad1..b5e4fb991 100644 --- a/miext/shadow/shrot8pack_90.c +++ b/miext/shadow/shrot8pack_90.c @@ -24,8 +24,6 @@ #define Data CARD8 #define ROTATE 90 -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "shrotpack.h" diff --git a/miext/shadow/shrotate.c b/miext/shadow/shrotate.c index 174553788..ec90fa5fe 100644 --- a/miext/shadow/shrotate.c +++ b/miext/shadow/shrotate.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include "scrnintstr.h" diff --git a/miext/sync/misync.c b/miext/sync/misync.c index 48234ef8a..806f7adbe 100644 --- a/miext/sync/misync.c +++ b/miext/sync/misync.c @@ -21,9 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "scrnintstr.h" #include "misync_priv.h" diff --git a/miext/sync/misyncfd.c b/miext/sync/misyncfd.c index 42a75024d..c2ad550c1 100644 --- a/miext/sync/misyncfd.c +++ b/miext/sync/misyncfd.c @@ -20,9 +20,9 @@ * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "dix/input_priv.h" #include "scrnintstr.h" #include "misync_priv.h" diff --git a/miext/sync/misyncshm.c b/miext/sync/misyncshm.c index 1e8865e89..fa163a3df 100644 --- a/miext/sync/misyncshm.c +++ b/miext/sync/misyncshm.c @@ -20,9 +20,7 @@ * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <fcntl.h> #include <sys/mman.h> diff --git a/os/WaitFor.c b/os/WaitFor.c index ea84570b1..a616850ab 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -52,9 +52,7 @@ SOFTWARE. * *****************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <errno.h> #include <stdio.h> @@ -66,11 +64,13 @@ SOFTWARE. #include "dix/dix_priv.h" #include "os/busfault.h" +#include "os/client_priv.h" +#include "os/screensaver.h" #include "misc.h" #include "osdep.h" #include "dixstruct_priv.h" -#include "opaque.h" +#include "globals.h" #ifdef DPMSExtension #include "dpmsproc.h" #endif @@ -416,13 +416,13 @@ NextDPMSTimeout(INT32 timeout) switch (DPMSPowerLevel) { case DPMSModeOn: DPMS_CHECK_TIMEOUT(DPMSStandbyTime) - + /* fallthrough */ case DPMSModeStandby: DPMS_CHECK_TIMEOUT(DPMSSuspendTime) - + /* fallthrough */ case DPMSModeSuspend: DPMS_CHECK_TIMEOUT(DPMSOffTime) - + /* fallthrough */ default: /* DPMSModeOff */ return 0; } diff --git a/os/access.c b/os/access.c index c7a2ab8c5..98095a5a1 100644 --- a/os/access.c +++ b/os/access.c @@ -76,9 +76,7 @@ SOFTWARE. * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef WIN32 #include <X11/Xwinsock.h> @@ -124,12 +122,9 @@ SOFTWARE. #include <sys/un.h> #endif -#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) +#if defined(SVR4) || defined(__GNU__) #include <sys/utsname.h> #endif -#if defined(SYSV) && defined(__i386__) -#include <sys/stream.h> -#endif #ifdef __GNU__ #undef SIOCGIFCONF #include <netdb.h> @@ -159,24 +154,15 @@ SOFTWARE. #ifdef HAVE_GETIFADDRS #include <ifaddrs.h> -#endif +#else -/* Solaris provides an extended interface SIOCGLIFCONF. Other systems - * may have this as well, but the code has only been tested on Solaris - * so far, so we only enable it there. Other platforms may be added as - * needed. - * - * Test for Solaris commented out -- TSI @ UQV 2003.06.13 - */ +/* Solaris provides an extended interface SIOCGLIFCONF. */ #ifdef SIOCGLIFCONF -/* #if defined(__sun) */ #define USE_SIOCGLIFCONF -/* #endif */ #endif +#endif /* HAVE_GETIFADDRS */ -#if defined(IPv6) && defined(AF_INET6) #include <arpa/inet.h> -#endif #endif /* WIN32 */ @@ -188,12 +174,12 @@ SOFTWARE. #include <X11/Xos_r.h> #include "os/auth.h" +#include "os/client_priv.h" +#include "os/osdep.h" #include "dixstruct.h" -#include "osdep.h" #include "xace.h" -#include "rpcauth.h" #include "xdmcp.h" Bool defeatAccessControl = FALSE; @@ -402,38 +388,6 @@ AccessUsingXdmcp(void) LocalHostEnabled = FALSE; } -#if defined(SVR4) && !defined(__sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) - -/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */ - -static int -ifioctl(int fd, int cmd, char *arg) -{ - struct strioctl ioc; - int ret; - - memset((char *) &ioc, 0, sizeof(ioc)); - ioc.ic_cmd = cmd; - ioc.ic_timout = 0; - if (cmd == SIOCGIFCONF) { - ioc.ic_len = ((struct ifconf *) arg)->ifc_len; - ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf; - } - else { - ioc.ic_len = sizeof(struct ifreq); - ioc.ic_dp = arg; - } - ret = ioctl(fd, I_STR, (char *) &ioc); - if (ret >= 0 && cmd == SIOCGIFCONF) -#ifdef SVR4 - ((struct ifconf *) arg)->ifc_len = ioc.ic_len; -#endif - return ret; -} -#else -#define ifioctl ioctl -#endif - /* * DefineSelf (fd): * @@ -458,13 +412,13 @@ DefineSelf(int fd) union { struct sockaddr sa; struct sockaddr_in in; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) struct sockaddr_in6 in6; #endif } saddr; struct sockaddr_in *inetaddr; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) struct sockaddr_in6 *inet6addr; #endif struct sockaddr_in broad_addr; @@ -489,7 +443,7 @@ DefineSelf(int fd) memcpy(&(inetaddr->sin_addr), hp->h_addr, hp->h_length); len = sizeof(saddr.sa); break; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case AF_INET6: inet6addr = (struct sockaddr_in6 *) (&(saddr.sa)); memcpy(&(inet6addr->sin6_addr), hp->h_addr, hp->h_length); @@ -533,7 +487,7 @@ DefineSelf(int fd) XdmcpRegisterBroadcastAddress((struct sockaddr_in *) &broad_addr); } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if (family == FamilyInternet6 && !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *) addr))) { XdmcpRegisterConnection(family, (char *) addr, len); @@ -581,7 +535,7 @@ DefineSelf(int fd) #define ifraddr_size(a) (sizeof (a)) #endif -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) static void in6_fillscopeid(struct sockaddr_in6 *sin6) { @@ -662,7 +616,7 @@ DefineSelf(int fd) #define IFR_IFR_NAME ifr->ifr_name #endif - if (ifioctl(fd, IFC_IOCTL_REQ, (void *) &ifc) < 0) + if (ioctl(fd, IFC_IOCTL_REQ, (void *) &ifc) < 0) ErrorF("Getting interface configuration (4): %s\n", strerror(errno)); cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN; @@ -674,7 +628,7 @@ DefineSelf(int fd) &len, (void **) &addr); if (family == -1 || family == FamilyLocal) continue; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (family == FamilyInternet6) in6_fillscopeid((struct sockaddr_in6 *) &IFR_IFR_ADDR); #endif @@ -702,7 +656,7 @@ DefineSelf(int fd) * If this isn't an Internet Address, don't register it. */ if (family != FamilyInternet -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) && family != FamilyInternet6 #endif ) @@ -715,7 +669,7 @@ DefineSelf(int fd) if (family == FamilyInternet && addr[0] == 127 && addr[1] == 0 && addr[2] == 0 && addr[3] == 1) continue; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if (family == FamilyInternet6 && IN6_IS_ADDR_LOOPBACK((struct in6_addr *) addr)) continue; @@ -732,7 +686,7 @@ DefineSelf(int fd) XdmcpRegisterConnection(family, (char *) addr, len); -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) /* IPv6 doesn't support broadcasting, so we drop out here */ if (family == FamilyInternet6) continue; @@ -766,12 +720,12 @@ DefineSelf(int fd) struct ifreq broad_req; broad_req = *ifr; - if (ifioctl(fd, SIOCGIFFLAGS, (void *) &broad_req) != -1 && + if (ioctl(fd, SIOCGIFFLAGS, (void *) &broad_req) != -1 && (broad_req.ifr_flags & IFF_BROADCAST) && (broad_req.ifr_flags & IFF_UP) ) { broad_req = *ifr; - if (ifioctl(fd, SIOCGIFBRDADDR, (void *) &broad_req) != -1) + if (ioctl(fd, SIOCGIFBRDADDR, (void *) &broad_req) != -1) broad_addr = broad_req.ifr_addr; else continue; @@ -799,7 +753,7 @@ DefineSelf(int fd) (void **) &addr); if (family == -1 || family == FamilyLocal) continue; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (family == FamilyInternet6) in6_fillscopeid((struct sockaddr_in6 *) ifr->ifa_addr); #endif @@ -823,7 +777,7 @@ DefineSelf(int fd) * If this isn't an Internet Address, don't register it. */ if (family != FamilyInternet -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) && family != FamilyInternet6 #endif ) @@ -848,13 +802,13 @@ DefineSelf(int fd) if (len == 4 && addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0) continue; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if (family == FamilyInternet6 && IN6_IS_ADDR_LOOPBACK((struct in6_addr *) addr)) continue; #endif XdmcpRegisterConnection(family, (char *) addr, len); -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (family == FamilyInternet6) /* IPv6 doesn't support broadcasting, so we drop out here */ continue; @@ -942,12 +896,10 @@ ResetHosts(const char *display) char *ptr; int i, hostlen; -#if defined(TCPCONN) && (!defined(IPv6) || !defined(AF_INET6)) +#if defined(TCPCONN) && (!defined(IPv6)) union { struct sockaddr sa; -#if defined(TCPCONN) struct sockaddr_in in; -#endif /* TCPCONN */ } saddr; #endif int family = 0; @@ -984,7 +936,7 @@ ResetHosts(const char *display) *ptr = 0; hostlen = strlen(ohostname) + 1; for (i = 0; i < hostlen; i++) - lhostname[i] = tolower(ohostname[i]); + lhostname[i] = tolower((unsigned char)ohostname[i]); hostname = ohostname; if (!strncmp("local:", lhostname, 6)) { family = FamilyLocalHost; @@ -996,19 +948,13 @@ ResetHosts(const char *display) family = FamilyInternet; hostname = ohostname + 5; } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if (!strncmp("inet6:", lhostname, 6)) { family = FamilyInternet6; hostname = ohostname + 6; } #endif #endif -#ifdef SECURE_RPC - else if (!strncmp("nis:", lhostname, 4)) { - family = FamilyNetname; - hostname = ohostname + 4; - } -#endif else if (!strncmp("si:", lhostname, 3)) { family = FamilyServerInterpreted; hostname = ohostname + 3; @@ -1022,18 +968,13 @@ ResetHosts(const char *display) } } else -#ifdef SECURE_RPC - if ((family == FamilyNetname) || (strchr(hostname, '@'))) { - SecureRPCInit(); - (void) NewHost(FamilyNetname, hostname, strlen(hostname), - FALSE); - } - else -#endif /* SECURE_RPC */ #if defined(TCPCONN) { -#if defined(IPv6) && defined(AF_INET6) - if ((family == FamilyInternet) || (family == FamilyInternet6) || +#if defined(HAVE_GETADDRINFO) + if ((family == FamilyInternet) || +#if defined(IPv6) + (family == FamilyInternet6) || +#endif (family == FamilyWild)) { struct addrinfo *addresses; struct addrinfo *a; @@ -1052,7 +993,7 @@ ResetHosts(const char *display) freeaddrinfo(addresses); } } -#else +#else /* HAVE_GETADDRINFO */ #ifdef XTHREADS_NEEDS_BYNAMEPARAMS _Xgethostbynameparams hparams; #endif @@ -1079,7 +1020,7 @@ ResetHosts(const char *display) #endif } } -#endif /* IPv6 */ +#endif /* HAVE_GETADDRINFO */ } #endif /* TCPCONN */ family = FamilyWild; @@ -1318,7 +1259,7 @@ AuthorizedClient(ClientPtr client) return Success; /* untrusted clients can't change host access */ - rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + rc = XaceHookServerAccess(client, DixManageAccess); if (rc != Success) return rc; @@ -1342,14 +1283,8 @@ AddHost(ClientPtr client, int family, unsigned length, /* of bytes in pAddr */ len = length; LocalHostEnabled = TRUE; break; -#ifdef SECURE_RPC - case FamilyNetname: - len = length; - SecureRPCInit(); - break; -#endif case FamilyInternet: -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case FamilyInternet6: #endif case FamilyDECnet: @@ -1431,26 +1366,23 @@ RemoveHost(ClientPtr client, int family, unsigned length, /* of bytes in p len = length; LocalHostEnabled = FALSE; break; -#ifdef SECURE_RPC - case FamilyNetname: - len = length; - break; -#endif case FamilyInternet: -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case FamilyInternet6: #endif case FamilyDECnet: case FamilyChaos: case FamilyServerInterpreted: if ((len = CheckAddr(family, pAddr, length)) < 0) { - client->errorValue = length; + if (client) + client->errorValue = length; return BadValue; } break; case FamilyLocal: default: - client->errorValue = family; + if (client) + client->errorValue = family; return BadValue; } for (prev = &validhosts; @@ -1521,7 +1453,7 @@ CheckAddr(int family, const void *pAddr, unsigned length) else len = -1; break; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case FamilyInternet6: if (length == sizeof(struct in6_addr)) len = length; @@ -1606,7 +1538,7 @@ ConvertAddr(register struct sockaddr *saddr, int *len, void **addr) *len = sizeof(struct in_addr); *addr = (void *) &(((struct sockaddr_in *) saddr)->sin_addr); return FamilyInternet; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case AF_INET6: { struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr; @@ -1836,8 +1768,12 @@ siHostnameAddrMatch(int family, void *addr, int len, * support for other address families, such as DECnet, could be added if * desired. */ -#if defined(IPv6) && defined(AF_INET6) - if ((family == FamilyInternet) || (family == FamilyInternet6)) { +#if defined(HAVE_GETADDRINFO) + if ((family == FamilyInternet) +#if defined(IPv6) + || (family == FamilyInternet6) +#endif + ) { char hostname[SI_HOSTNAME_MAXLEN]; struct addrinfo *addresses; struct addrinfo *a; @@ -1862,7 +1798,7 @@ siHostnameAddrMatch(int family, void *addr, int len, freeaddrinfo(addresses); } } -#else /* IPv6 not supported, use gethostbyname instead for IPv4 */ +#else /* getaddrinfo not supported, use gethostbyname instead for IPv4 */ if (family == FamilyInternet) { register struct hostent *hp; @@ -1872,7 +1808,7 @@ siHostnameAddrMatch(int family, void *addr, int len, char hostname[SI_HOSTNAME_MAXLEN]; int f, hostaddrlen; void *hostaddr; - const char **addrlist; + char **addrlist; if (siAddrLen >= sizeof(hostname)) return FALSE; @@ -1897,7 +1833,9 @@ siHostnameAddrMatch(int family, void *addr, int len, if ((f == family) && (len == hostaddrlen) && (memcmp(addr, hostaddr, len) == 0)) { res = TRUE; +#ifdef h_addr break; +#endif } } } @@ -1959,7 +1897,7 @@ siHostnameCheckAddr(const char *valueString, int length, void *typePriv) return len; } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) /*** * "ipv6" server interpreted type * @@ -2169,7 +2107,7 @@ static void siTypesInitialize(void) { siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL); -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL); #endif #if !defined(NO_LOCAL_CLIENT_CRED) @@ -31,9 +31,7 @@ from The Open Group. * Author: Keith Packard, MIT X Consortium */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xauth.h> @@ -50,7 +48,6 @@ from The Open Group. #include "os/auth.h" -#include "rpcauth.h" #include "xdmcp.h" #include "xdmauth.h" #include "mitauth.h" @@ -85,15 +82,6 @@ static struct protocol protocols[] = { #endif }, #endif -#ifdef SECURE_RPC - {(unsigned short) 9, "SUN-DES-1", - SecureRPCAdd, SecureRPCCheck, SecureRPCReset, - SecureRPCFromID, SecureRPCRemove, -#ifdef XCSECURITY - NULL -#endif - }, -#endif }; #define NUM_AUTHORIZATION ARRAY_SIZE(protocols) @@ -111,4 +111,6 @@ int ChangeAccessControl(ClientPtr client, int fEnabled); void AccessUsingXdmcp(void); +extern Bool defeatAccessControl; + #endif /* _XSERVER_OS_AUTH_H */ diff --git a/os/backtrace.c b/os/backtrace.c index e4cb91b1c..281747de4 100644 --- a/os/backtrace.c +++ b/os/backtrace.c @@ -21,9 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "os.h" #include "misc.h" @@ -92,13 +90,13 @@ print_registers(int frame, unw_cursor_t cursor) ErrorFSigSafe("Registers at frame #%d:\n", frame); for (i = 0; i < num_regs; i++) { - uint64_t val; + unw_word_t val; ret = unw_get_reg(&cursor, regs[i].regnum, &val); if (ret < 0) { ErrorFSigSafe("unw_get_reg(%s) failed: %s [%d]\n", regs[i].name, unw_strerror(ret), ret); } else { - ErrorFSigSafe(" %s: 0x%" PRIx64 "\n", regs[i].name, val); + ErrorFSigSafe(" %s: 0x%" PRIxPTR "\n", regs[i].name, val); } } } @@ -190,10 +188,10 @@ xorg_backtrace(void) #include <dlfcn.h> #include <execinfo.h> +#define BT_SIZE 64 void xorg_backtrace(void) { - const int BT_SIZE = 64; void *array[BT_SIZE]; const char *mod; int size, i; diff --git a/os/busfault.c b/os/busfault.c index 7e6d4612e..3f653965c 100644 --- a/os/busfault.c +++ b/os/busfault.c @@ -20,9 +20,7 @@ * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/Xos.h> #include <X11/Xdefs.h> diff --git a/os/client.c b/os/client.c index 6a119afc1..bcbaee677 100644 --- a/os/client.c +++ b/os/client.c @@ -50,12 +50,14 @@ * * Author: Rami Ylimäki <rami.ylimaki@vincit.fi> */ +#include <dix-config.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> -#include "client.h" +#include "os/client_priv.h" + #include "os.h" #include "dixstruct.h" @@ -325,18 +327,25 @@ DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs) if (n != 1) return; argv = kvm_getargv(kd, kp, 0); - *cmdname = strdup(argv[0]); - i = 1; - while (argv[i] != NULL) { - len += strlen(argv[i]) + 1; - i++; + if (cmdname) { + if (argv == NULL || argv[0] == NULL) + return; + else + *cmdname = strdup(argv[0]); } - *cmdargs = calloc(1, len); - i = 1; - while (argv[i] != NULL) { - strlcat(*cmdargs, argv[i], len); - strlcat(*cmdargs, " ", len); - i++; + if (cmdargs) { + i = 1; + while (argv[i] != NULL) { + len += strlen(argv[i]) + 1; + i++; + } + *cmdargs = calloc(1, len); + i = 1; + while (argv[i] != NULL) { + strlcat(*(char **)cmdargs, argv[i], len); + strlcat(*(char **)cmdargs, " ", len); + i++; + } } kvm_close(kd); } @@ -445,7 +454,7 @@ ReserveClientIds(struct _Client *client) return; assert(!client->clientIds); - client->clientIds = calloc(1, sizeof(ClientIdRec)); + client->clientIds = calloc(1, sizeof(struct _ClientId)); if (!client->clientIds) return; diff --git a/os/client_priv.h b/os/client_priv.h new file mode 100644 index 000000000..88da283da --- /dev/null +++ b/os/client_priv.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + * Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). + */ +#ifndef _XSERVER_DIX_CLIENT_PRIV_H +#define _XSERVER_DIX_CLIENT_PRIV_H + +#include <sys/types.h> +#include <X11/Xdefs.h> +#include <X11/Xfuncproto.h> + +/* Client IDs. Use GetClientPid, GetClientCmdName and GetClientCmdArgs + * instead of accessing the fields directly. */ +struct _ClientId { + pid_t pid; /* process ID, -1 if not available */ + const char *cmdname; /* process name, NULL if not available */ + const char *cmdargs; /* process arguments, NULL if not available */ +}; + +struct _Client; + +/* Initialize and clean up. */ +void ReserveClientIds(struct _Client *client); +void ReleaseClientIds(struct _Client *client); + +/* Determine client IDs for caching. Exported on purpose for + * extensions such as SELinux. */ +pid_t DetermineClientPid(struct _Client *client); +void DetermineClientCmd(pid_t, const char **cmdname, const char **cmdargs); + +/* Query cached client IDs. Exported on purpose for drivers. */ +pid_t GetClientPid(struct _Client *client); +const char *GetClientCmdName(struct _Client *client); +const char *GetClientCmdArgs(struct _Client *client); + +Bool ClientIsLocal(struct _Client *client); +XID AuthorizationIDOfClient(struct _Client *client); +const char *ClientAuthorized(struct _Client *client, + unsigned int proto_n, + char *auth_proto, + unsigned int string_n, + char *auth_string); +Bool AddClientOnOpenFD(int fd); +void ListenOnOpenFD(int fd, int noxauth); +int ReadRequestFromClient(struct _Client *client); +int WriteFdToClient(struct _Client *client, int fd, Bool do_close); +Bool InsertFakeRequest(struct _Client *client, char *data, int count); +void FlushAllOutput(void); +void FlushIfCriticalOutputPending(void); +void ResetOsBuffers(void); +void NotifyParentProcess(void); +void CreateWellKnownSockets(void); +void ResetWellKnownSockets(void); +void CloseWellKnownConnections(void); + +/* exported only for DRI module, but should not be used by external drivers */ +_X_EXPORT void ResetCurrentRequest(struct _Client *client); + +#endif /* _XSERVER_DIX_CLIENT_PRIV_H */ diff --git a/os/connection.c b/os/connection.c index 5a724fd4f..d0d7c10c5 100644 --- a/os/connection.c +++ b/os/connection.c @@ -60,9 +60,7 @@ SOFTWARE. * *****************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef WIN32 #include <X11/Xwinsock.h> @@ -99,11 +97,12 @@ SOFTWARE. #include "dix/dix_priv.h" #include "os/audit.h" #include "os/auth.h" +#include "os/client_priv.h" #include "os/osdep.h" #include "misc.h" /* for typedef of pointer */ -#include "opaque.h" #include "dixstruct_priv.h" +#include "globals.h" #include "xace.h" #ifdef HAVE_GETPEERUCRED @@ -125,8 +124,6 @@ struct ospoll *server_poll; Bool NewOutputPending; /* not yet attempted to write some new output */ Bool NoListenAll; /* Don't establish any listening sockets */ -Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or - equivalent) will send SIGCONT back. */ static char dynamic_display[7]; /* display name */ Bool PartialNetwork; /* continue even if unable to bind all addrs */ #if !defined(WIN32) @@ -209,8 +206,6 @@ NotifyParentProcess(void) kill(ParentProcess, SIGUSR1); } } - if (RunFromSigStopParent) - raise(SIGSTOP); #ifdef HAVE_SYSTEMD_DAEMON /* If we have been started as a systemd service, tell systemd that we are ready. Otherwise sd_notify() won't do anything. */ @@ -240,7 +235,7 @@ void CreateWellKnownSockets(void) { int i; - int partial; + int partial = 0; /* display is initialized to "0" by main(). It is then set to the display * number if specified on the command line. */ @@ -393,11 +388,20 @@ AuthAudit(ClientPtr client, Bool letin, strlcpy(addr, "local host", sizeof(addr)); break; #if defined(TCPCONN) - case AF_INET: - snprintf(addr, sizeof(addr), "IP %s", - inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr)); + case AF_INET:{ +#if defined(HAVE_INET_NTOP) + char ipaddr[INET_ADDRSTRLEN]; + + inet_ntop(AF_INET, &((struct sockaddr_in *) saddr)->sin_addr, + ipaddr, sizeof(ipaddr)); +#else + const char *ipaddr = + inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr); +#endif + snprintf(addr, sizeof(addr), "IP %s", ipaddr); + } break; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case AF_INET6:{ char ipaddr[INET6_ADDRSTRLEN]; @@ -579,7 +583,7 @@ ClientAuthorized(ClientPtr client, XdmcpOpenDisplay(priv->fd); #endif /* XDMCP */ - XaceHook(XACE_AUTH_AVAIL, client, auth_id); + XaceHookAuthAvail(client, auth_id); /* At this point, if the client is authorized to change the access control * list, we should getpeername() information, and add the client to @@ -866,7 +870,7 @@ OnlyListenToOneClient(ClientPtr client) { int rc; - rc = XaceHook(XACE_SERVER_ACCESS, client, DixGrabAccess); + rc = XaceHookServerAccess(client, DixGrabAccess); if (rc != Success) return rc; @@ -1035,9 +1039,9 @@ ListenOnOpenFD(int fd, int noxauth) /* Allocate space to store it */ ListenTransFds = - xnfreallocarray(ListenTransFds, ListenTransCount + 1, sizeof(int)); + XNFreallocarray(ListenTransFds, ListenTransCount + 1, sizeof(int)); ListenTransConns = - xnfreallocarray(ListenTransConns, ListenTransCount + 1, + XNFreallocarray(ListenTransConns, ListenTransCount + 1, sizeof(XtransConnInfo)); /* Store it */ @@ -12,4 +12,26 @@ void FormatUInt64(uint64_t num, char *string); void FormatUInt64Hex(uint64_t num, char *string); void FormatDouble(double dbl, char *string); +/** + * Compare the two version numbers comprising of major.minor. + * + * @return A value less than 0 if a is less than b, 0 if a is equal to b, + * or a value greater than 0 + */ +static inline int +version_compare(uint32_t a_major, uint32_t a_minor, + uint32_t b_major, uint32_t b_minor) +{ + if (a_major > b_major) + return 1; + if (a_major < b_major) + return -1; + if (a_minor > b_minor) + return 1; + if (a_minor < b_minor) + return -1; + + return 0; +} + #endif /* _XSERVER_OS_FMT_H */ diff --git a/os/inputthread.c b/os/inputthread.c index 07f192c40..623648256 100644 --- a/os/inputthread.c +++ b/os/inputthread.c @@ -25,9 +25,7 @@ * Tiago Vignatti <vignatti at freedesktop org> */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <errno.h> @@ -35,6 +33,7 @@ #include <unistd.h> #include <pthread.h> +#include "dix/input_priv.h" #include "os/ddx_priv.h" #include "inputstr.h" @@ -51,9 +51,7 @@ SOFTWARE. * *****************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #undef DEBUG_COMMUNICATION @@ -76,9 +74,10 @@ SOFTWARE. #include <X11/Xproto.h> #include "dix/dix_priv.h" +#include "os/client_priv.h" +#include "os/osdep.h" #include "os.h" -#include "osdep.h" #include "opaque.h" #include "dixstruct.h" #include "misc.h" @@ -301,6 +300,10 @@ ReadRequestFromClient(ClientPtr client) needed = get_big_req_len(request, client); } client->req_len = needed; + if (needed > MAXINT >> 2) { + /* Check for potential integer overflow */ + return -(BadLength); + } needed <<= 2; /* needed is in bytes now */ } if (gotnow < needed) { @@ -359,13 +362,8 @@ ReadRequestFromClient(ClientPtr client) if (result <= 0) { if ((result < 0) && ETEST(errno)) { mark_client_not_ready(client); -#if defined(SVR4) && defined(__i386__) && !defined(__sun) - if (0) -#endif - { - YieldControlNoInput(client); - return 0; - } + YieldControlNoInput(client); + return 0; } YieldControlDeath(); return -1; @@ -396,6 +394,8 @@ ReadRequestFromClient(ClientPtr client) needed = get_big_req_len(request, client); } client->req_len = needed; + if (needed > MAXINT >> 2) + return -(BadLength); needed <<= 2; } if (gotnow < needed) { @@ -443,7 +443,7 @@ ReadRequestFromClient(ClientPtr client) */ gotnow -= needed; - if (!gotnow) + if (!gotnow && !oci->ignoreBytes) AvailableInput = oc; if (move_header) { if (client->req_len < bytes_to_int32(sizeof(xBigReq) - sizeof(xReq))) { @@ -75,9 +75,9 @@ OR PERFORMANCE OF THIS SOFTWARE. * authorization from the copyright holder(s) and author(s). */ -#ifdef HAVE_DIX_CONFIG_H +#define _POSIX_THREAD_SAFE_FUNCTIONS // for localtime_r on mingw32 + #include <dix-config.h> -#endif #include <errno.h> #include <stdio.h> @@ -85,21 +85,18 @@ OR PERFORMANCE OF THIS SOFTWARE. #include <stdlib.h> /* for malloc() */ #include <sys/stat.h> #include <time.h> +#include <X11/Xfuncproto.h> #include <X11/Xos.h> +#include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "os/audit.h" #include "os/ddx_priv.h" #include "os/fmt.h" #include "os/osdep.h" -#include "input.h" #include "opaque.h" -#ifdef WIN32 -#include <process.h> -#define getpid(x) _getpid(x) -#endif - #ifdef XF86BIGFONT #include "xf86bigfontsrv.h" #endif @@ -111,12 +108,8 @@ OR PERFORMANCE OF THIS SOFTWARE. void (*OsVendorVErrorFProc) (const char *, va_list args) = NULL; /* Default logging parameters. */ -#ifndef DEFAULT_LOG_VERBOSITY #define DEFAULT_LOG_VERBOSITY 0 -#endif -#ifndef DEFAULT_LOG_FILE_VERBOSITY #define DEFAULT_LOG_FILE_VERBOSITY 3 -#endif static FILE *logFile = NULL; static int logFileFd = -1; @@ -139,42 +132,18 @@ asm(".desc ___crashreporter_info__, 0x10"); #endif /* Prefix strings for log messages. */ -#ifndef X_UNKNOWN_STRING #define X_UNKNOWN_STRING "(\?\?)" -#endif -#ifndef X_PROBE_STRING #define X_PROBE_STRING "(--)" -#endif -#ifndef X_CONFIG_STRING #define X_CONFIG_STRING "(**)" -#endif -#ifndef X_DEFAULT_STRING #define X_DEFAULT_STRING "(==)" -#endif -#ifndef X_CMDLINE_STRING #define X_CMDLINE_STRING "(++)" -#endif -#ifndef X_NOTICE_STRING #define X_NOTICE_STRING "(!!)" -#endif -#ifndef X_ERROR_STRING #define X_ERROR_STRING "(EE)" -#endif -#ifndef X_WARNING_STRING #define X_WARNING_STRING "(WW)" -#endif -#ifndef X_INFO_STRING #define X_INFO_STRING "(II)" -#endif -#ifndef X_NOT_IMPLEMENTED_STRING #define X_NOT_IMPLEMENTED_STRING "(NI)" -#endif -#ifndef X_DEBUG_STRING #define X_DEBUG_STRING "(DB)" -#endif -#ifndef X_NONE_STRING #define X_NONE_STRING "" -#endif static size_t strlen_sigsafe(const char *s) @@ -531,6 +500,7 @@ vpnprintf(char *string, int size_in, const char *f, va_list args) break; case 'x': + case 'X': // not actually upper case, but at least accepting '%X' if (length_modifier & LMOD_LONGLONG) ui = va_arg(args, unsigned long long); else if (length_modifier & LMOD_LONG) @@ -620,11 +590,7 @@ LogSWrite(int verb, const char *buf, size_t len, Bool end_line) struct tm tm; char fmt_tm[32]; -#ifdef WIN32 - localtime_s(&tm, &t); -#else localtime_r(&t, &tm); -#endif strftime(fmt_tm, sizeof(fmt_tm) - 1, "%Y-%m-%d %H:%M:%S", &tm); fprintf(logFile, "[%s] ", fmt_tm); @@ -659,22 +625,6 @@ LogSWrite(int verb, const char *buf, size_t len, Bool end_line) (void) ret; } -void -LogVWrite(int verb, const char *f, va_list args) -{ - return LogVMessageVerb(X_NONE, verb, f, args); -} - -void -LogWrite(int verb, const char *f, ...) -{ - va_list args; - - va_start(args, f); - LogVWrite(verb, f, args); - va_end(args); -} - /* Returns the Message Type string to prepend to a logging message, or NULL * if the message will be dropped due to insufficient verbosity. */ static const char * @@ -864,37 +814,6 @@ LogHdrMessageVerb(MessageType type, int verb, const char *msg_format, va_end(hdr_args); } -void -LogHdrMessage(MessageType type, const char *msg_format, va_list msg_args, - const char *hdr_format, ...) -{ - va_list hdr_args; - - va_start(hdr_args, hdr_format); - LogVHdrMessageVerb(type, 1, msg_format, msg_args, hdr_format, hdr_args); - va_end(hdr_args); -} - -void -AbortServer(void) - _X_NORETURN; - -void -AbortServer(void) -{ -#ifdef XF86BIGFONT - XF86BigfontCleanup(); -#endif - CloseWellKnownConnections(); - OsCleanup(TRUE); - AbortDevices(); - ddxGiveUp(EXIT_ERR_ABORT); - fflush(stderr); - if (CoreDump) - OsAbort(); - exit(1); -} - #define AUDIT_PREFIX "AUDIT: %s: %ld: " #ifndef AUDIT_TIMEOUT #define AUDIT_TIMEOUT ((CARD32)(120 * 1000)) /* 2 mn */ @@ -1043,7 +962,7 @@ VErrorF(const char *f, va_list args) if (OsVendorVErrorFProc) OsVendorVErrorFProc(f, args); else - LogVWrite(-1, f, args); + LogVMessageVerb(X_NONE, -1, f, args); } void @@ -1076,7 +995,7 @@ void LogPrintMarkers(void) { /* Show what the message marker symbols mean. */ - LogWrite(0, "Markers: "); + LogMessageVerb(X_NONE, 0, "Markers: "); LogMessageVerb(X_PROBED, 0, "probed, "); LogMessageVerb(X_CONFIG, 0, "from config file, "); LogMessageVerb(X_DEFAULT, 0, "default setting,\n\t"); diff --git a/os/meson.build b/os/meson.build index 25a00af90..e12e2c9e7 100644 --- a/os/meson.build +++ b/os/meson.build @@ -12,6 +12,7 @@ srcs_os = [ 'mitauth.c', 'osinit.c', 'ospoll.c', + 'serverlock.c', 'string.c', 'utils.c', 'xdmauth.c', @@ -59,41 +60,6 @@ endif os_dep = [] os_c_args = [] -rpc_dep = [] -opt_secure_rpc = get_option('secure-rpc') -if opt_secure_rpc != 'false' - build_secure_rpc = true - - # prefer libtirpc (if available), otherwise ensure RPC functions are - # provided by libc. - rpc_dep = dependency('libtirpc', required: false, include_type: 'system') - if not (rpc_dep.found() or cc.has_header('rpc/rpc.h')) - if opt_secure_rpc == 'true' - error('secure-rpc requested, but neither libtirpc or libc RPC support were found') - else - message('secure-rpc disabled since neither libtirpc or libc RPC support were found') - build_secure_rpc = false - endif - endif - # XXX: also check if RPC library provides xdr_opaque_auth, authdes_(sec)create ??? - - if not (cc.has_member('struct authdes_cred', 'adc_fullname', - prefix : '#include <rpc/rpc.h>', - dependencies: rpc_dep)) - if opt_secure_rpc == 'true' - error('secure-rpc requested, but RPC implementation lacking struct authdes_cred') - else - message('secure-rpc disable since RPC implementation lacking struct authdes_cred') - build_secure_rpc = false - endif - endif - - if build_secure_rpc - os_c_args += '-DSECURE_RPC' - srcs_os += 'rpcauth.c' - endif -endif - if get_option('xres') # Only the XRes extension cares about the client ID. os_c_args += '-DCLIENTIDS' @@ -125,7 +91,6 @@ libxserver_os = static_library('libxserver_os', common_dep, dl_dep, sha1_dep, - rpc_dep, os_dep, dependency('xau') ], diff --git a/os/mitauth.c b/os/mitauth.c index 44e3329c2..4383ac7ae 100644 --- a/os/mitauth.c +++ b/os/mitauth.c @@ -31,9 +31,7 @@ from The Open Group. * Author: Keith Packard, MIT X Consortium */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include "os.h" diff --git a/os/osdep.h b/os/osdep.h index 0687f568d..7a1b46bf3 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -60,6 +60,12 @@ SOFTWARE. #include <limits.h> #include <stddef.h> #include <X11/Xos.h> +#include <X11/Xmd.h> +#include <X11/Xdefs.h> + +#ifndef __has_builtin +# define __has_builtin(x) 0 /* Compatibility with older compilers */ +#endif /* If EAGAIN and EWOULDBLOCK are distinct errno values, then we check errno * for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX @@ -147,13 +153,11 @@ static inline void uname(struct utsname *uts) { const char *Win32TempDir(void); -int System(const char *cmdline); static inline void Fclose(void *f) { fclose(f); } static inline void *Fopen(const char *a, const char *b) { return fopen(a,b); } #else /* WIN32 */ -int System(const char *); void *Popen(const char *, const char *); void *Fopen(const char *, const char *); int Fclose(void *f); @@ -187,6 +191,7 @@ void OsBlockSignals(void); void OsReleaseSignals(void); void OsResetSignals(void); void OsAbort(void) _X_NORETURN; +void AbortServer(void) _X_NORETURN; void MakeClientGrabPervious(ClientPtr client); void MakeClientGrabImpervious(ClientPtr client); @@ -198,4 +203,37 @@ void ListenToAllClients(void); /* allow DDX to force using another clock */ void ForceClockId(clockid_t forced_clockid); +Bool WaitForSomething(Bool clients_are_ready); +void CloseDownConnection(ClientPtr client); + +extern int LimitClients; +extern Bool PartialNetwork; + +extern int limitDataSpace; +extern int limitStackSpace; +extern int limitNoFile; + +extern Bool CoreDump; +extern Bool NoListenAll; +extern Bool AllowByteSwappedClients; + +#if __has_builtin(__builtin_popcountl) +# define Ones __builtin_popcountl +#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 + */ +static inline int +Ones(unsigned long mask) +{ + unsigned long y; + + y = (mask >> 1) & 033333333333; + y = mask - y - ((y >> 1) & 033333333333); + return (((y + (y >> 3)) & 030707070707) % 077); +} +#endif + #endif /* _OSDEP_H_ */ diff --git a/os/osinit.c b/os/osinit.c index 2c4604b87..3a132faee 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -44,9 +44,7 @@ SOFTWARE. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <errno.h> #include <stdio.h> @@ -56,21 +54,22 @@ SOFTWARE. #ifdef HAVE_DLFCN_H #include <dlfcn.h> #endif -#ifdef HAVE_BACKTRACE +#if defined(HAVE_BACKTRACE) && defined(HAVE_EXECINFO_H) #include <execinfo.h> #endif +#include "dix/dix_priv.h" #include "os/busfault.h" #include "os/osdep.h" +#include "os/serverlock.h" #include "misc.h" #include "os.h" #include "opaque.h" -#include "misc.h" #include "dixstruct.h" #include "dixstruct_priv.h" -#if !defined(SYSV) && !defined(WIN32) +#if !defined(WIN32) #include <sys/resource.h> #endif @@ -205,7 +204,7 @@ OsInit(void) if (!server_poll) FatalError("failed to allocate poll structure"); -#ifdef HAVE_BACKTRACE +#if defined(HAVE_BACKTRACE) && defined(HAVE_EXECINFO_H) /* * initialize the backtracer, since the ctor calls dlopen(), which * calls malloc(), which isn't signal-safe. @@ -253,7 +252,7 @@ OsInit(void) dup2(fileno(err), 2); fclose(err); } -#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__) +#if defined(SVR4) || defined(WIN32) || defined(__CYGWIN__) { static char buf[BUFSIZ]; diff --git a/os/ospoll.c b/os/ospoll.c index c68aabc87..dc2ecd10f 100644 --- a/os/ospoll.c +++ b/os/ospoll.c @@ -20,14 +20,15 @@ * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#include <X11/X.h> -#include <X11/Xproto.h> #include <stdlib.h> #include <unistd.h> +#include <X11/X.h> +#include <X11/Xproto.h> + +#include "os/xserver_poll.h" + #include "misc.h" /* for typedef of pointer */ #include "ospoll.h" #include "list.h" diff --git a/os/reallocarray.c b/os/reallocarray.c index c415e09af..3c34f7ff9 100644 --- a/os/reallocarray.c +++ b/os/reallocarray.c @@ -15,9 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/types.h> #include <errno.h> diff --git a/os/rpcauth.c b/os/rpcauth.c deleted file mode 100644 index d3d4e4bd8..000000000 --- a/os/rpcauth.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - -Copyright 1991, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -/* - * SUN-DES-1 authentication mechanism - * Author: Mayank Choudhary, Sun Microsystems - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifdef SECURE_RPC - -#include <X11/X.h> -#include <X11/Xauth.h> - -#include "os/auth.h" - -#include "misc.h" -#include "os.h" -#include "osdep.h" -#include "dixstruct.h" -#include "rpcauth.h" - -#include <rpc/rpc.h> - -#ifdef __sun -/* <rpc/auth.h> only includes this if _KERNEL is #defined... */ -extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *); -#endif - -static enum auth_stat why; - -static char * -authdes_ezdecode(const char *inmsg, int len) -{ - struct rpc_msg msg; - char cred_area[MAX_AUTH_BYTES]; - char verf_area[MAX_AUTH_BYTES]; - char *temp_inmsg; - struct svc_req r; - bool_t res0, res1; - XDR xdr; - SVCXPRT xprt; - - temp_inmsg = malloc(len); - if (temp_inmsg == NULL) { - why = AUTH_FAILED; /* generic error, since there is no AUTH_BADALLOC */ - return NULL; - } - memcpy(temp_inmsg, inmsg, len); - - memset((char *) &msg, 0, sizeof(msg)); - memset((char *) &r, 0, sizeof(r)); - memset(cred_area, 0, sizeof(cred_area)); - memset(verf_area, 0, sizeof(verf_area)); - - msg.rm_call.cb_cred.oa_base = cred_area; - msg.rm_call.cb_verf.oa_base = verf_area; - why = AUTH_FAILED; - xdrmem_create(&xdr, temp_inmsg, len, XDR_DECODE); - - if ((r.rq_clntcred = malloc(MAX_AUTH_BYTES)) == NULL) - goto bad1; - r.rq_xprt = &xprt; - - /* decode into msg */ - res0 = xdr_opaque_auth(&xdr, &(msg.rm_call.cb_cred)); - res1 = xdr_opaque_auth(&xdr, &(msg.rm_call.cb_verf)); - if (!(res0 && res1)) - goto bad2; - - /* do the authentication */ - - r.rq_cred = msg.rm_call.cb_cred; /* read by opaque stuff */ - if (r.rq_cred.oa_flavor != AUTH_DES) { - why = AUTH_TOOWEAK; - goto bad2; - } -#ifdef SVR4 - if ((why = __authenticate(&r, &msg)) != AUTH_OK) { -#else - if ((why = _authenticate(&r, &msg)) != AUTH_OK) { -#endif - goto bad2; - } - return (((struct authdes_cred *) r.rq_clntcred)->adc_fullname.name); - - bad2: - free(r.rq_clntcred); - bad1: - return ((char *) 0); /* ((struct authdes_cred *) NULL); */ -} - -static XID rpc_id = (XID) ~0L; - -static Bool -CheckNetName(unsigned char *addr, short len, void *closure) -{ - return (len == strlen((char *) closure) && - strncmp((char *) addr, (char *) closure, len) == 0); -} - -static char rpc_error[MAXNETNAMELEN + 50]; - -_X_HIDDEN XID -SecureRPCCheck(unsigned short data_length, const char *data, - ClientPtr client, const char **reason) -{ - char *fullname; - - if (rpc_id == (XID) ~0L) { - *reason = "Secure RPC authorization not initialized"; - } - else { - fullname = authdes_ezdecode(data, data_length); - if (fullname == (char *) 0) { - snprintf(rpc_error, sizeof(rpc_error), - "Unable to authenticate secure RPC client (why=%d)", why); - *reason = rpc_error; - } - else { - if (ForEachHostInFamily(FamilyNetname, CheckNetName, fullname)) - return rpc_id; - snprintf(rpc_error, sizeof(rpc_error), - "Principal \"%s\" is not authorized to connect", fullname); - *reason = rpc_error; - } - } - return (XID) ~0L; -} - -_X_HIDDEN void -SecureRPCInit(void) -{ - if (rpc_id == (XID) ~0L) - AddAuthorization(9, "SUN-DES-1", 0, (char *) 0); -} - -_X_HIDDEN int -SecureRPCAdd(unsigned short data_length, const char *data, XID id) -{ - if (data_length) - AddHost((void *) 0, FamilyNetname, data_length, data); - rpc_id = id; - return 1; -} - -_X_HIDDEN int -SecureRPCReset(void) -{ - rpc_id = (XID) ~0L; - return 1; -} - -_X_HIDDEN int -SecureRPCFromID(XID id, unsigned short *data_lenp, char **datap) -{ - return 0; -} - -_X_HIDDEN int -SecureRPCRemove(unsigned short data_length, const char *data) -{ - return 0; -} -#endif /* SECURE_RPC */ diff --git a/os/rpcauth.h b/os/rpcauth.h deleted file mode 100644 index 255eafcea..000000000 --- a/os/rpcauth.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _XSERVER_OS_RPCAUTH_H -#define _XSERVER_OS_RPCAUTH_H - -#include "auth.h" - -void SecureRPCInit(AuthInitArgs); -XID SecureRPCCheck(AuthCheckArgs); -int SecureRPCAdd(AuthAddCArgs); -int SecureRPCFromID(AuthFromIDArgs); -int SecureRPCRemove(AuthRemCArgs); -int SecureRPCReset(AuthRstCArgs); - -#endif /* _XSERVER_OS_RPCAUTH_H */ diff --git a/os/screensaver.h b/os/screensaver.h new file mode 100644 index 000000000..c52c42bb4 --- /dev/null +++ b/os/screensaver.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_OS_SCREENSAVER_H +#define _XSERVER_OS_SCREENSAVER_H + +void SetScreenSaverTimer(void); +void FreeScreenSaverTimer(void); + +#endif /* _XSERVER_OS_SCREENSAVER_H */ diff --git a/os/serverlock.c b/os/serverlock.c new file mode 100644 index 000000000..36efc9bc0 --- /dev/null +++ b/os/serverlock.c @@ -0,0 +1,253 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +Copyright 1994 Quarterdeck Office Systems. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Digital and +Quarterdeck not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. + +*/ +#include <dix-config.h> + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "dix/dix_priv.h" +#include "os/serverlock.h" +#include "os/osdep.h" + +#include "os.h" +#include "opaque.h" + +/* + * Explicit support for a server lock file like the ones used for UUCP. + * For architectures with virtual terminals that can run more than one + * server at a time. This keeps the servers from stomping on each other + * if the user forgets to give them different display numbers. + */ +#define LOCK_DIR "/tmp" +#define LOCK_TMP_PREFIX "/.tX" +#define LOCK_PREFIX "/.X" +#define LOCK_SUFFIX "-lock" + +#ifdef LOCK_SERVER + +static Bool StillLocking = FALSE; +static char LockFile[PATH_MAX]; +static Bool nolock = FALSE; + +/* + * LockServer -- + * Check if the server lock file exists. If so, check if the PID + * contained inside is valid. If so, then die. Otherwise, create + * the lock file containing the PID. + */ +void +LockServer(void) +{ + char tmp[PATH_MAX], pid_str[12]; + int lfd, i, haslock, l_pid, t; + const char *tmppath = LOCK_DIR; + int len; + char port[20]; + + if (nolock || NoListenAll) + return; + /* + * Path names + */ + snprintf(port, sizeof(port), "%d", atoi(display)); + len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) : + strlen(LOCK_TMP_PREFIX); + len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1; + if (len > sizeof(LockFile)) + FatalError("Display name `%s' is too long\n", port); + (void) sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port); + (void) sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port); + + /* + * Create a temporary file containing our PID. Attempt three times + * to create the file. + */ + StillLocking = TRUE; + i = 0; + do { + i++; + lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644); + if (lfd < 0) + sleep(2); + else + break; + } while (i < 3); + if (lfd < 0) { + unlink(tmp); + i = 0; + do { + i++; + lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644); + if (lfd < 0) + sleep(2); + else + break; + } while (i < 3); + } + if (lfd < 0) + FatalError("Could not create lock file in %s\n", tmp); + snprintf(pid_str, sizeof(pid_str), "%10lu\n", (unsigned long) getpid()); + if (write(lfd, pid_str, 11) != 11) + FatalError("Could not write pid to lock file in %s\n", tmp); + (void) fchmod(lfd, 0444); + (void) close(lfd); + + /* + * OK. Now the tmp file exists. Try three times to move it in place + * for the lock. + */ + i = 0; + haslock = 0; + while ((!haslock) && (i++ < 3)) { + haslock = (link(tmp, LockFile) == 0); + if (haslock) { + /* + * We're done. + */ + break; + } + else if (errno == EEXIST) { + /* + * Read the pid from the existing file + */ + lfd = open(LockFile, O_RDONLY | O_NOFOLLOW); + if (lfd < 0) { + unlink(tmp); + FatalError("Can't read lock file %s\n", LockFile); + } + pid_str[0] = '\0'; + if (read(lfd, pid_str, 11) != 11) { + /* + * Bogus lock file. + */ + unlink(LockFile); + close(lfd); + continue; + } + pid_str[11] = '\0'; + sscanf(pid_str, "%d", &l_pid); + close(lfd); + + /* + * Now try to kill the PID to see if it exists. + */ + errno = 0; + t = kill(l_pid, 0); + if ((t < 0) && (errno == ESRCH)) { + /* + * Stale lock file. + */ + unlink(LockFile); + continue; + } + else if (((t < 0) && (errno == EPERM)) || (t == 0)) { + /* + * Process is still active. + */ + unlink(tmp); + FatalError + ("Server is already active for display %s\n%s %s\n%s\n", + port, "\tIf this server is no longer running, remove", + LockFile, "\tand start again."); + } + } + else { + unlink(tmp); + FatalError + ("Linking lock file (%s) in place failed: %s\n", + LockFile, strerror(errno)); + } + } + unlink(tmp); + if (!haslock) + FatalError("Could not create server lock file: %s\n", LockFile); + StillLocking = FALSE; +} + +/* + * UnlockServer -- + * Remove the server lock file. + */ +void +UnlockServer(void) +{ + if (nolock || NoListenAll) + return; + + if (!StillLocking) { + + (void) unlink(LockFile); + } +} + +void DisableServerLock(void) { + nolock = TRUE; +} + +void LockServerUseMsg(void) { + ErrorF("-nolock disable the locking mechanism\n"); +} + +#else /* LOCK_SERVER */ + +void LockServer(void) {} +void UnlockServer(void) {} +void DisableServerLock(void) {} +void LockServerUseMsg(void) {} + +#endif /* LOCK_SERVER */ diff --git a/os/serverlock.h b/os/serverlock.h new file mode 100644 index 000000000..dae1cf2a4 --- /dev/null +++ b/os/serverlock.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_SERVERLOCK_H +#define _XSERVER_SERVERLOCK_H + +void LockServer(void); +void UnlockServer(void); +void DisableServerLock(void); +void LockServerUseMsg(void); + +#endif /* _XSERVER_SERVERLOCK_H */ diff --git a/os/strcasecmp.c b/os/strcasecmp.c index 2692f7f1e..50c2a3528 100644 --- a/os/strcasecmp.c +++ b/os/strcasecmp.c @@ -27,9 +27,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <ctype.h> #include "dix.h" diff --git a/os/strcasestr.c b/os/strcasestr.c index 4e483a940..771bb00e4 100644 --- a/os/strcasestr.c +++ b/os/strcasestr.c @@ -30,9 +30,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <ctype.h> #include <string.h> diff --git a/os/strlcat.c b/os/strlcat.c index 316dfa9d1..538e7ab3f 100644 --- a/os/strlcat.c +++ b/os/strlcat.c @@ -14,9 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/types.h> #include <string.h> diff --git a/os/strlcpy.c b/os/strlcpy.c index 52e7203b2..82c158a9f 100644 --- a/os/strlcpy.c +++ b/os/strlcpy.c @@ -14,9 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <sys/types.h> #include <string.h> diff --git a/os/strndup.c b/os/strndup.c index e0eddf13d..4606ab413 100644 --- a/os/strndup.c +++ b/os/strndup.c @@ -27,9 +27,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stddef.h> #include <stdlib.h> diff --git a/os/utils.c b/os/utils.c index cf579aa3e..ef1d3eab0 100644 --- a/os/utils.c +++ b/os/utils.c @@ -48,9 +48,7 @@ OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef __CYGWIN__ #include <stdlib.h> @@ -80,6 +78,7 @@ __stdcall unsigned long GetTickCount(void); #include <X11/Xtrans/Xtrans.h> #include "os/audit.h" +#include "os/client_priv.h" #include "input.h" #include "dixfont.h" @@ -91,7 +90,7 @@ __stdcall unsigned long GetTickCount(void); #ifndef WIN32 #include <sys/wait.h> #endif -#if !defined(SYSV) && !defined(WIN32) +#if !defined(WIN32) #include <sys/resource.h> #endif #include <sys/stat.h> @@ -106,10 +105,12 @@ __stdcall unsigned long GetTickCount(void); #endif #include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "os/auth.h" #include "os/cmdline.h" #include "os/ddx_priv.h" #include "os/osdep.h" +#include "os/serverlock.h" #include "dixstruct.h" #include "xkbsrv.h" @@ -168,13 +169,10 @@ Bool noXFree86DRIExtension = FALSE; Bool noXFree86VidModeExtension = FALSE; #endif Bool noXFixesExtension = FALSE; -#ifdef PANORAMIX +#ifdef XINERAMA /* Xinerama is disabled by default unless enabled via +xinerama */ Bool noPanoramiXExtension = TRUE; -#endif -#ifdef XV -Bool noXvExtension = FALSE; -#endif +#endif /* XINERAMA */ #ifdef DRI2 Bool noDRI2Extension = FALSE; #endif @@ -192,9 +190,9 @@ Bool enableIndirectGLX = FALSE; Bool AllowByteSwappedClients = FALSE; -#ifdef PANORAMIX +#ifdef XINERAMA Bool PanoramiXExtensionDisabledHack = FALSE; -#endif +#endif /* XINERAMA */ char *SeatId = NULL; @@ -223,186 +221,6 @@ OsSignal(int sig, OsSigHandlerPtr handler) #endif } -/* - * Explicit support for a server lock file like the ones used for UUCP. - * For architectures with virtual terminals that can run more than one - * server at a time. This keeps the servers from stomping on each other - * if the user forgets to give them different display numbers. - */ -#define LOCK_DIR "/tmp" -#define LOCK_TMP_PREFIX "/.tX" -#define LOCK_PREFIX "/.X" -#define LOCK_SUFFIX "-lock" - -#if !defined(WIN32) || defined(__CYGWIN__) -#define LOCK_SERVER -#endif - -#ifndef LOCK_SERVER -void -LockServer(void) -{} - -void -UnlockServer(void) -{} -#else /* LOCK_SERVER */ -static Bool StillLocking = FALSE; -static char LockFile[PATH_MAX]; -static Bool nolock = FALSE; - -/* - * LockServer -- - * Check if the server lock file exists. If so, check if the PID - * contained inside is valid. If so, then die. Otherwise, create - * the lock file containing the PID. - */ -void -LockServer(void) -{ - char tmp[PATH_MAX], pid_str[12]; - int lfd, i, haslock, l_pid, t; - const char *tmppath = LOCK_DIR; - int len; - char port[20]; - - if (nolock || NoListenAll) - return; - /* - * Path names - */ - snprintf(port, sizeof(port), "%d", atoi(display)); - len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) : - strlen(LOCK_TMP_PREFIX); - len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1; - if (len > sizeof(LockFile)) - FatalError("Display name `%s' is too long\n", port); - (void) sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port); - (void) sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port); - - /* - * Create a temporary file containing our PID. Attempt three times - * to create the file. - */ - StillLocking = TRUE; - i = 0; - do { - i++; - lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644); - if (lfd < 0) - sleep(2); - else - break; - } while (i < 3); - if (lfd < 0) { - unlink(tmp); - i = 0; - do { - i++; - lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644); - if (lfd < 0) - sleep(2); - else - break; - } while (i < 3); - } - if (lfd < 0) - FatalError("Could not create lock file in %s\n", tmp); - snprintf(pid_str, sizeof(pid_str), "%10lu\n", (unsigned long) getpid()); - if (write(lfd, pid_str, 11) != 11) - FatalError("Could not write pid to lock file in %s\n", tmp); - (void) fchmod(lfd, 0444); - (void) close(lfd); - - /* - * OK. Now the tmp file exists. Try three times to move it in place - * for the lock. - */ - i = 0; - haslock = 0; - while ((!haslock) && (i++ < 3)) { - haslock = (link(tmp, LockFile) == 0); - if (haslock) { - /* - * We're done. - */ - break; - } - else if (errno == EEXIST) { - /* - * Read the pid from the existing file - */ - lfd = open(LockFile, O_RDONLY | O_NOFOLLOW); - if (lfd < 0) { - unlink(tmp); - FatalError("Can't read lock file %s\n", LockFile); - } - pid_str[0] = '\0'; - if (read(lfd, pid_str, 11) != 11) { - /* - * Bogus lock file. - */ - unlink(LockFile); - close(lfd); - continue; - } - pid_str[11] = '\0'; - sscanf(pid_str, "%d", &l_pid); - close(lfd); - - /* - * Now try to kill the PID to see if it exists. - */ - errno = 0; - t = kill(l_pid, 0); - if ((t < 0) && (errno == ESRCH)) { - /* - * Stale lock file. - */ - unlink(LockFile); - continue; - } - else if (((t < 0) && (errno == EPERM)) || (t == 0)) { - /* - * Process is still active. - */ - unlink(tmp); - FatalError - ("Server is already active for display %s\n%s %s\n%s\n", - port, "\tIf this server is no longer running, remove", - LockFile, "\tand start again."); - } - } - else { - unlink(tmp); - FatalError - ("Linking lock file (%s) in place failed: %s\n", - LockFile, strerror(errno)); - } - } - unlink(tmp); - if (!haslock) - FatalError("Could not create server lock file: %s\n", LockFile); - StillLocking = FALSE; -} - -/* - * UnlockServer -- - * Remove the server lock file. - */ -void -UnlockServer(void) -{ - if (nolock || NoListenAll) - return; - - if (!StillLocking) { - - (void) unlink(LockFile); - } -} -#endif /* LOCK_SERVER */ - /* Force connections to close on SIGHUP from init */ void @@ -550,9 +368,7 @@ UseMsg(void) #ifdef RLIMIT_STACK ErrorF("-ls int limit stack space to N Kb\n"); #endif -#ifdef LOCK_SERVER - ErrorF("-nolock disable the locking mechanism\n"); -#endif + LockServerUseMsg(); ErrorF("-maxclients n set maximum number of clients (power of two)\n"); ErrorF("-nolisten string don't listen on protocol\n"); ErrorF("-listen string listen on protocol\n"); @@ -576,14 +392,12 @@ UseMsg(void) ErrorF("-v screen-saver without video blanking\n"); ErrorF("-wr create root window with white background\n"); ErrorF("-maxbigreqsize set maximal bigrequest size \n"); -#ifdef PANORAMIX +#ifdef XINERAMA ErrorF("+xinerama Enable XINERAMA extension\n"); ErrorF("-xinerama Disable XINERAMA extension\n"); -#endif - ErrorF - ("-dumbSched Disable smart scheduling and threaded input, enable old behavior\n"); +#endif /* XINERAMA */ + ErrorF("-dumbSched Disable smart scheduling and threaded input, enable old behavior\n"); ErrorF("-schedInterval int Set scheduler interval in msec\n"); - ErrorF("-sigstop Enable SIGSTOP based startup\n"); ErrorF("+extension name Enable extension\n"); ErrorF("-extension name Disable extension\n"); ListStaticExtensions(); @@ -623,7 +437,7 @@ VerifyDisplayName(const char *d) for digits, or exception of :0.0 and similar (two decimal points max) */ for (i = 0; i < strlen(d); i++) { - if (!isdigit(d[i])) { + if (!isdigit((unsigned char)d[i])) { if (d[i] != '.' || period_found) return 0; period_found = TRUE; @@ -766,9 +580,7 @@ ProcessCommandLine(int argc, char *argv[]) else if (strcmp(argv[i], "-displayfd") == 0) { if (++i < argc) { displayfd = atoi(argv[i]); -#ifdef LOCK_SERVER - nolock = TRUE; -#endif + DisableServerLock(); } else UseMsg(); @@ -857,24 +669,24 @@ ProcessCommandLine(int argc, char *argv[]) ("Warning: the -nolock option can only be used by root\n"); else #endif - nolock = TRUE; + DisableServerLock(); } #endif - else if ( strcmp( argv[i], "-maxclients") == 0) - { - if (++i < argc) { - LimitClients = atoi(argv[i]); - if (LimitClients != 64 && - LimitClients != 128 && - LimitClients != 256 && - LimitClients != 512 && + else if ( strcmp( argv[i], "-maxclients") == 0) + { + if (++i < argc) { + LimitClients = atoi(argv[i]); + if (LimitClients != 64 && + LimitClients != 128 && + LimitClients != 256 && + LimitClients != 512 && LimitClients != 1024 && LimitClients != 2048) { - FatalError("maxclients must be one of 64, 128, 256, 512, 1024 or 2048\n"); - } - } else - UseMsg(); - } + FatalError("maxclients must be one of 64, 128, 256, 512, 1024 or 2048\n"); + } + } else + UseMsg(); + } else if (strcmp(argv[i], "-nolisten") == 0) { if (++i < argc) { if (_XSERVTransNoListen(argv[i])) @@ -941,7 +753,7 @@ ProcessCommandLine(int argc, char *argv[]) else if (strcmp(argv[i], "-terminate") == 0) { dispatchExceptionAtReset = DE_TERMINATE; terminateDelay = -1; - if ((i + 1 < argc) && (isdigit(*argv[i + 1]))) + if ((i + 1 < argc) && (isdigit((unsigned char)*argv[i + 1]))) terminateDelay = atoi(argv[++i]); terminateDelay = max(0, terminateDelay); } @@ -978,7 +790,7 @@ ProcessCommandLine(int argc, char *argv[]) UseMsg(); } } -#ifdef PANORAMIX +#ifdef XINERAMA else if (strcmp(argv[i], "+xinerama") == 0) { noPanoramiXExtension = FALSE; } @@ -988,7 +800,7 @@ ProcessCommandLine(int argc, char *argv[]) else if (strcmp(argv[i], "-disablexineramaextension") == 0) { PanoramiXExtensionDisabledHack = TRUE; } -#endif +#endif /* XINERAMA */ else if (strcmp(argv[i], "-I") == 0) { /* ignore all remaining arguments */ break; @@ -1034,9 +846,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } - else if (strcmp(argv[i], "-sigstop") == 0) { - RunFromSigStopParent = TRUE; - } else if (strcmp(argv[i], "+extension") == 0) { if (++i < argc) { if (!EnableDisableExtension(argv[i], TRUE)) @@ -1075,7 +884,7 @@ set_font_authorizations(char **authorizations, int *authlen, void *client) char hname[1024], *hnameptr; unsigned int len; -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) struct addrinfo hints, *ai = NULL; #else struct hostent *host; @@ -1086,7 +895,7 @@ set_font_authorizations(char **authorizations, int *authlen, void *client) #endif gethostname(hname, 1024); -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; if (getaddrinfo(hname, NULL, &hints, &ai) == 0) { @@ -1116,7 +925,7 @@ set_font_authorizations(char **authorizations, int *authlen, void *client) p += sizeof(AUTHORIZATION_NAME); memcpy(p, hnameptr, len); p += len; -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) if (ai) { freeaddrinfo(ai); } @@ -1487,49 +1296,6 @@ Win32TempDir(void) else return "/tmp"; } - -int -System(const char *cmdline) -{ - STARTUPINFO si = (STARTUPINFO) { - .cb = sizeof(si), - }; - PROCESS_INFORMATION pi = (PROCESS_INFORMATION){0}; - DWORD dwExitCode; - char *cmd = strdup(cmdline); - - if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { - LPVOID buffer; - - if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &buffer, 0, NULL)) { - ErrorF("[xkb] Starting '%s' failed!\n", cmdline); - } - else { - ErrorF("[xkb] Starting '%s' failed: %s", cmdline, (char *) buffer); - LocalFree(buffer); - } - - free(cmd); - return -1; - } - /* Wait until child process exits. */ - WaitForSingleObject(pi.hProcess, INFINITE); - - GetExitCodeProcess(pi.hProcess, &dwExitCode); - - /* Close process and thread handles. */ - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - free(cmd); - - return dwExitCode; -} #endif Bool @@ -1602,26 +1368,6 @@ PrivsElevated(void) * external wrapper utility. */ -/* Consider LD* variables insecure? */ -#ifndef REMOVE_ENV_LD -#define REMOVE_ENV_LD 1 -#endif - -/* Remove long environment variables? */ -#ifndef REMOVE_LONG_ENV -#define REMOVE_LONG_ENV 1 -#endif - -/* - * Disallow stdout or stderr as pipes? It's possible to block the X server - * when piping stdout+stderr to a pipe. - * - * Don't enable this because it looks like it's going to cause problems. - */ -#ifndef NO_OUTPUT_PIPES -#define NO_OUTPUT_PIPES 0 -#endif - /* Check args and env only if running setuid (euid == 0 && euid != uid) ? */ #ifndef CHECK_EUID #ifndef WIN32 @@ -1631,49 +1377,26 @@ PrivsElevated(void) #endif #endif -/* - * Maybe the locale can be faked to make isprint(3) report that everything - * is printable? Avoid it by default. - */ -#ifndef USE_ISPRINT -#define USE_ISPRINT 0 -#endif - #define MAX_ARG_LENGTH 128 #define MAX_ENV_LENGTH 256 #define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */ -#if USE_ISPRINT -#include <ctype.h> -#define checkPrintable(c) isprint(c) -#else #define checkPrintable(c) (((c) & 0x7f) >= 0x20 && ((c) & 0x7f) != 0x7f) -#endif enum BadCode { NotBad = 0, UnsafeArg, ArgTooLong, UnprintableArg, - EnvTooLong, - OutputIsPipe, InternalError }; -#if defined(VENDORSUPPORT) -#define BUGADDRESS VENDORSUPPORT -#elif defined(BUILDERADDR) -#define BUGADDRESS BUILDERADDR -#else -#define BUGADDRESS "xorg@freedesktop.org" -#endif - void CheckUserParameters(int argc, char **argv, char **envp) { enum BadCode bad = NotBad; int i = 0, j; - char *a, *e = NULL; + char *a = NULL; #if CHECK_EUID if (PrivsElevated()) @@ -1708,61 +1431,19 @@ CheckUserParameters(int argc, char **argv, char **envp) for (i = 0; envp[i]; i++) { /* Check for bad environment variables and values */ -#if REMOVE_ENV_LD while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) { for (j = i; envp[j]; j++) { envp[j] = envp[j + 1]; } } -#endif if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) { -#if REMOVE_LONG_ENV for (j = i; envp[j]; j++) { envp[j] = envp[j + 1]; } i--; -#else - char *eq; - int len; - - eq = strchr(envp[i], '='); - if (!eq) - continue; - len = eq - envp[i]; - e = strndup(envp[i], len); - if (!e) { - bad = InternalError; - break; - } - if (len >= 4 && - (strcmp(e + len - 4, "PATH") == 0 || - strcmp(e, "TERMCAP") == 0)) { - if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) { - bad = EnvTooLong; - break; - } - else { - free(e); - } - } - else { - bad = EnvTooLong; - break; - } -#endif } } } -#if NO_OUTPUT_PIPES - if (!bad) { - struct stat buf; - - if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode)) - bad = OutputIsPipe; - if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode)) - bad = OutputIsPipe; - } -#endif } switch (bad) { case NotBad: @@ -1777,12 +1458,6 @@ CheckUserParameters(int argc, char **argv, char **envp) ErrorF("Command line argument number %d contains unprintable" " characters\n", i); break; - case EnvTooLong: - ErrorF("Environment variable `%s' is too long\n", e); - break; - case OutputIsPipe: - ErrorF("Stdout and/or stderr is a pipe\n"); - break; case InternalError: ErrorF("Internal Error\n"); break; @@ -1873,3 +1548,19 @@ os_move_fd(int fd) return newfd; } #endif + +void +AbortServer(void) +{ +#ifdef XF86BIGFONT + XF86BigfontCleanup(); +#endif + CloseWellKnownConnections(); + OsCleanup(TRUE); + AbortDevices(); + ddxGiveUp(EXIT_ERR_ABORT); + fflush(stderr); + if (CoreDump) + OsAbort(); + exit(1); +} diff --git a/os/xdmauth.c b/os/xdmauth.c index 21b79e943..3a676e188 100644 --- a/os/xdmauth.c +++ b/os/xdmauth.c @@ -33,9 +33,7 @@ from The Open Group. * Author: Keith Packard, MIT X Consortium */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/os/xdmcp.c b/os/xdmcp.c index edf69590b..955cee1b4 100644 --- a/os/xdmcp.c +++ b/os/xdmcp.c @@ -13,9 +13,7 @@ * */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #ifdef WIN32 #include <X11/Xwinsock.h> @@ -40,6 +38,7 @@ #include <X11/X.h> #include <X11/Xmd.h> +#include "dix/dix_priv.h" #include "os/auth.h" #include "misc.h" @@ -48,7 +47,6 @@ #include "xdmauth.h" #include "input.h" #include "dixstruct.h" -#include "opaque.h" #define XSERV_t #define TRANS_SERVER @@ -72,7 +70,7 @@ static const char *defaultDisplayClass = "MIT-unspecified"; static int xdmcpSocket, sessionSocket; static xdmcp_states state; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) static int xdmcpSocket6; static struct sockaddr_storage req_sockaddr; #else @@ -91,10 +89,12 @@ static char *xdmAuthCookie; static XdmcpBuffer buffer; -#if defined(IPv6) && defined(AF_INET6) - +#if defined(HAVE_GETADDRINFO) static struct addrinfo *mgrAddr; static struct addrinfo *mgrAddrFirst; +#endif + +#if defined(IPv6) #define SOCKADDR_TYPE struct sockaddr_storage #define SOCKADDR_FAMILY(s) ((struct sockaddr *)&(s))->sa_family @@ -130,7 +130,7 @@ static SOCKADDR_TYPE FromAddress; static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen; #endif -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) static struct multicastinfo { struct multicastinfo *next; struct addrinfo *ai; @@ -183,7 +183,7 @@ static void get_fromaddr_by_name(int argc, char **argv, int i); -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) static int get_mcast_options(int argc, char **argv, int i); @@ -226,7 +226,7 @@ XdmcpUseMsg(void) { ErrorF("-query host-name contact named host for XDMCP\n"); ErrorF("-broadcast broadcast for XDMCP\n"); -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) ErrorF("-multicast [addr [hops]] IPv6 multicast for XDMCP\n"); #endif ErrorF("-indirect host-name contact named host for indirect XDMCP\n"); @@ -265,7 +265,7 @@ XdmcpOptions(int argc, char **argv, int i) XdmcpDefaultListen(); return i + 1; } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (strcmp(argv[i], "-multicast") == 0) { i = get_mcast_options(argc, argv, ++i); XDM_INIT_STATE = XDM_MULTICAST; @@ -471,7 +471,7 @@ XdmcpRegisterConnection(int type, const char *address, int addrlen) if (SOCKADDR_FAMILY(FromAddress) == AF_INET) { fromAddr = &((struct sockaddr_in *) &FromAddress)->sin_addr; } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET6) && IN6_IS_ADDR_V4MAPPED(& ((struct sockaddr_in6 *) @@ -482,7 +482,7 @@ XdmcpRegisterConnection(int type, const char *address, int addrlen) } #endif } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if (addrlen == sizeof(struct in6_addr)) { if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) { fromAddr = &((struct sockaddr_in6 *) &FromAddress)->sin6_addr; @@ -579,7 +579,7 @@ xdmcp_reset(void) timeOutRtx = 0; if (xdmcpSocket >= 0) SetNotifyFd(xdmcpSocket, XdmcpSocketNotify, X_NOTIFY_READ, NULL); -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (xdmcpSocket6 >= 0) SetNotifyFd(xdmcpSocket6, XdmcpSocketNotify, X_NOTIFY_READ, NULL); #endif @@ -715,7 +715,7 @@ static ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" }; static void receive_packet(int socketfd) { -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) struct sockaddr_storage from; #else struct sockaddr_in from; @@ -774,7 +774,7 @@ send_packet(void) case XDM_QUERY: case XDM_BROADCAST: case XDM_INDIRECT: -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case XDM_MULTICAST: #endif send_query_msg(); @@ -838,15 +838,19 @@ timeout(void) return; } -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) { /* Try next address */ for (mgrAddr = mgrAddr->ai_next;; mgrAddr = mgrAddr->ai_next) { if (mgrAddr == NULL) { mgrAddr = mgrAddrFirst; } - if (mgrAddr->ai_family == AF_INET || mgrAddr->ai_family == AF_INET6) + if (mgrAddr->ai_family == AF_INET) + break; +#if defined(IPv6) + if (mgrAddr->ai_family == AF_INET6) break; +#endif } #ifndef SIN6_LEN ManagerAddressLen = mgrAddr->ai_addrlen; @@ -862,7 +866,7 @@ timeout(void) case XDM_COLLECT_BROADCAST_QUERY: state = XDM_BROADCAST; break; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case XDM_COLLECT_MULTICAST_QUERY: state = XDM_MULTICAST; break; @@ -919,7 +923,7 @@ get_xdmcp_sock(void) int soopts = 1; int socketfd = -1; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) XdmcpWarning("INET6 UDP socket creation failed"); #endif @@ -936,7 +940,7 @@ get_xdmcp_sock(void) if (SOCKADDR_FAMILY(FromAddress) == AF_INET) socketfd = xdmcpSocket; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) socketfd = xdmcpSocket6; #endif @@ -955,7 +959,7 @@ send_query_msg(void) XdmcpHeader header; Bool broadcast = FALSE; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) Bool multicast = FALSE; #endif int i; @@ -972,7 +976,7 @@ send_query_msg(void) state = XDM_COLLECT_BROADCAST_QUERY; broadcast = TRUE; break; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case XDM_MULTICAST: header.opcode = (CARD16) BROADCAST_QUERY; state = XDM_COLLECT_MULTICAST_QUERY; @@ -998,7 +1002,7 @@ send_query_msg(void) (XdmcpNetaddr) &BroadcastAddresses[i], sizeof(struct sockaddr_in)); } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) else if (multicast) { struct multicastinfo *mcl; struct addrinfo *ai; @@ -1030,7 +1034,7 @@ send_query_msg(void) } #endif else { -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (SOCKADDR_FAMILY(ManagerAddress) == AF_INET6) socketfd = xdmcpSocket6; #endif @@ -1059,7 +1063,7 @@ recv_willing_msg(struct sockaddr *from, int fromlen, unsigned length) XdmcpSelectHost(from, fromlen, &authenticationName); break; case XDM_COLLECT_BROADCAST_QUERY: -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case XDM_COLLECT_MULTICAST_QUERY: #endif case XDM_COLLECT_INDIRECT_QUERY: @@ -1090,7 +1094,7 @@ send_request_msg(void) case AF_INET: XdmcpConnectionType = FamilyInternet; break; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) case AF_INET6: XdmcpConnectionType = FamilyInternet6; break; @@ -1154,7 +1158,7 @@ send_request_msg(void) XdmcpDisposeARRAY8(&authenticationData); XdmcpWriteARRAYofARRAY8(&buffer, &AuthorizationNames); XdmcpWriteARRAY8(&buffer, &ManufacturerDisplayID); -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6) socketfd = xdmcpSocket6; #endif @@ -1248,7 +1252,7 @@ send_manage_msg(void) XdmcpWriteCARD16(&buffer, DisplayNumber); XdmcpWriteARRAY8(&buffer, &DisplayClass); state = XDM_AWAIT_MANAGE_RESPONSE; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6) socketfd = xdmcpSocket6; #endif @@ -1305,7 +1309,7 @@ send_keepalive_msg(void) XdmcpWriteCARD32(&buffer, SessionID); state = XDM_AWAIT_ALIVE_RESPONSE; -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6) socketfd = xdmcpSocket6; #endif @@ -1353,12 +1357,12 @@ get_addr_by_name(const char *argtype, const char *namestr, int port, int socktype, SOCKADDR_TYPE * addr, SOCKLEN_TYPE * addrlen -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) , struct addrinfo **aip, struct addrinfo **aifirstp #endif ) { -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) struct addrinfo *ai; struct addrinfo hints; char portstr[6]; @@ -1385,8 +1389,12 @@ get_addr_by_name(const char *argtype, if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) { for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) { - if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6) + if (ai->ai_family == AF_INET) + break; +#if defined(IPv6) + if (ai->ai_family == AF_INET6) break; +#endif } if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) { FatalError("Xserver: %s host %s not on supported network type\n", @@ -1402,7 +1410,7 @@ get_addr_by_name(const char *argtype, FatalError("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype, namestr); } -#else +#else /* HAVE_GETADDRINFO */ struct hostent *hep; #ifdef XTHREADS_NEEDS_BYNAMEPARAMS @@ -1424,7 +1432,7 @@ get_addr_by_name(const char *argtype, FatalError("Xserver: %s host on strange network %s\n", argtype, namestr); } -#endif +#endif /* HAVE_GETADDRINFO */ } static void @@ -1437,7 +1445,7 @@ get_manager_by_name(int argc, char **argv, int i) get_addr_by_name(argv[i], argv[i + 1], xdm_udp_port, SOCK_DGRAM, &ManagerAddress, &ManagerAddressLen -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) , &mgrAddr, &mgrAddrFirst #endif ); @@ -1446,7 +1454,7 @@ get_manager_by_name(int argc, char **argv, int i) static void get_fromaddr_by_name(int argc, char **argv, int i) { -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) struct addrinfo *ai = NULL; struct addrinfo *aifirst = NULL; #endif @@ -1454,18 +1462,18 @@ get_fromaddr_by_name(int argc, char **argv, int i) FatalError("Xserver: missing -from host name in command line\n"); } get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) , &ai, &aifirst #endif ); -#if defined(IPv6) && defined(AF_INET6) +#if defined(HAVE_GETADDRINFO) if (aifirst != NULL) freeaddrinfo(aifirst); #endif xdm_from = argv[i]; } -#if defined(IPv6) && defined(AF_INET6) +#if defined(IPv6) static int get_mcast_options(int argc, char **argv, int i) { diff --git a/os/xprintf.c b/os/xprintf.c index e19e1ca03..9e93ac9b2 100644 --- a/os/xprintf.c +++ b/os/xprintf.c @@ -56,9 +56,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/Xos.h> #include "os.h" diff --git a/os/xserver_poll.c b/os/xserver_poll.c index 1927dfa10..64b94f199 100644 --- a/os/xserver_poll.c +++ b/os/xserver_poll.c @@ -73,21 +73,20 @@ Includes \*---------------------------------------------------------------------------*/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <unistd.h> /* standard Unix definitions */ #include <sys/types.h> /* system types */ #include <sys/time.h> /* time definitions */ #include <assert.h> /* assertion macros */ #include <string.h> /* string functions */ -#include "xserver_poll.h" #if defined(WIN32) && !defined(__CYGWIN__) #include <X11/Xwinsock.h> #endif +#include "os/xserver_poll.h" + /*---------------------------------------------------------------------------*\ Macros \*---------------------------------------------------------------------------*/ diff --git a/include/xserver_poll.h b/os/xserver_poll.h index 0f3a37c73..0f3a37c73 100644 --- a/include/xserver_poll.h +++ b/os/xserver_poll.h diff --git a/os/xsha1.c b/os/xsha1.c index f2863f523..a1a2448af 100644 --- a/os/xsha1.c +++ b/os/xsha1.c @@ -23,9 +23,7 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "os.h" #include "os/xsha1.h" diff --git a/os/xstrans.c b/os/xstrans.c index 2bc79e7ae..c9363db71 100644 --- a/os/xstrans.c +++ b/os/xstrans.c @@ -1,16 +1,7 @@ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/Xfuncproto.h> -/* ErrorF is used by xtrans */ -#ifndef HAVE_DIX_CONFIG_H -extern _X_EXPORT void -ErrorF(const char *f, ...) -_X_ATTRIBUTE_PRINTF(1, 2); -#endif - #define TRANS_REOPEN #define TRANS_SERVER #define XSERV_t diff --git a/present/meson.build b/present/meson.build index 1a74a9cbc..bc806a668 100644 --- a/present/meson.build +++ b/present/meson.build @@ -21,6 +21,7 @@ libxserver_present = static_library('libxserver_present', include_directories: inc, dependencies: [ common_dep, + epoll_dep, dependency('presentproto', version: '>= 1.2') ], ) diff --git a/present/present.c b/present/present.c index 6fb73901e..336816e27 100644 --- a/present/present.c +++ b/present/present.c @@ -19,6 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> #include "present_priv.h" #include <gcstruct.h> @@ -84,7 +85,7 @@ present_copy_region(DrawablePtr drawable, (*gc->funcs->ChangeClip)(gc, CT_REGION, update, 0); } ValidateGC(drawable, gc); - (*gc->ops->CopyArea)(&pixmap->drawable, + (void) (*gc->ops->CopyArea)(&pixmap->drawable, drawable, gc, 0, 0, diff --git a/present/present.h b/present/present.h index c6762cecc..3aeed270b 100644 --- a/present/present.h +++ b/present/present.h @@ -23,7 +23,9 @@ #ifndef _PRESENT_H_ #define _PRESENT_H_ +#include <X11/Xfuncproto.h> #include <X11/extensions/presentproto.h> + #include "randrstr.h" #include "presentext.h" diff --git a/present/present_event.c b/present/present_event.c index b35609b23..0c1855ec4 100644 --- a/present/present_event.c +++ b/present/present_event.c @@ -19,6 +19,9 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> + +#include "Xext/geext.h" #include "present_priv.h" diff --git a/present/present_execute.c b/present/present_execute.c index 5253344a1..449ea5c53 100644 --- a/present/present_execute.c +++ b/present/present_execute.c @@ -19,6 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> #include "present_priv.h" #include <unistd.h> diff --git a/present/present_fake.c b/present/present_fake.c index f4a3bd887..3ce7295aa 100644 --- a/present/present_fake.c +++ b/present/present_fake.c @@ -19,6 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> #include "present_priv.h" #include "list.h" diff --git a/present/present_fence.c b/present/present_fence.c index aca04a580..821cd6098 100644 --- a/present/present_fence.c +++ b/present/present_fence.c @@ -19,6 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> #include "present_priv.h" #include <gcstruct.h> diff --git a/present/present_priv.h b/present/present_priv.h index 351f98621..aea4ad52e 100644 --- a/present/present_priv.h +++ b/present/present_priv.h @@ -345,7 +345,7 @@ present_send_idle_notify(WindowPtr window, CARD32 serial, PixmapPtr pixmap, pres int present_select_input(ClientPtr client, - CARD32 eid, + XID eid, WindowPtr window, CARD32 event_mask); diff --git a/present/present_request.c b/present/present_request.c index cc947b11b..02f8846c8 100644 --- a/present/present_request.c +++ b/present/present_request.c @@ -343,7 +343,6 @@ sproc_present_query_version(ClientPtr client) REQUEST(xPresentQueryVersionReq); REQUEST_SIZE_MATCH(xPresentQueryVersionReq); - swaps(&stuff->length); swapl(&stuff->majorVersion); swapl(&stuff->minorVersion); return (*proc_present_vector[stuff->presentReqType]) (client); @@ -355,7 +354,6 @@ sproc_present_pixmap(ClientPtr client) REQUEST(xPresentPixmapReq); REQUEST_AT_LEAST_SIZE(xPresentPixmapReq); - swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->pixmap); swapl(&stuff->valid); @@ -375,7 +373,6 @@ sproc_present_notify_msc(ClientPtr client) REQUEST(xPresentNotifyMSCReq); REQUEST_SIZE_MATCH(xPresentNotifyMSCReq); - swaps(&stuff->length); swapl(&stuff->window); swapll(&stuff->target_msc); swapll(&stuff->divisor); @@ -389,7 +386,6 @@ sproc_present_select_input (ClientPtr client) REQUEST(xPresentSelectInputReq); REQUEST_SIZE_MATCH(xPresentSelectInputReq); - swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->eventMask); return (*proc_present_vector[stuff->presentReqType]) (client); @@ -400,7 +396,6 @@ sproc_present_query_capabilities (ClientPtr client) { REQUEST(xPresentQueryCapabilitiesReq); REQUEST_SIZE_MATCH(xPresentQueryCapabilitiesReq); - swaps(&stuff->length); swapl(&stuff->target); return (*proc_present_vector[stuff->presentReqType]) (client); } @@ -413,8 +408,6 @@ sproc_present_pixmap_synced(ClientPtr client) REQUEST(xPresentPixmapSyncedReq); REQUEST_AT_LEAST_SIZE(xPresentPixmapSyncedReq); - swaps(&stuff->length); - swapl(&stuff->window); swapl(&stuff->pixmap); diff --git a/present/present_scmd.c b/present/present_scmd.c index 5f05f8fc9..b60e1b143 100644 --- a/present/present_scmd.c +++ b/present/present_scmd.c @@ -19,6 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> #include "present_priv.h" #include <misync.h> diff --git a/present/present_screen.c b/present/present_screen.c index 0589b2ee9..ae56f9032 100644 --- a/present/present_screen.c +++ b/present/present_screen.c @@ -19,6 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> #include "present_priv.h" @@ -244,10 +245,10 @@ present_extension_init(void) ExtensionEntry *extension; int i; -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return; -#endif +#endif /* XINERAMA */ extension = AddExtension(PRESENT_NAME, PresentNumberEvents, PresentNumberErrors, proc_present_dispatch, sproc_present_dispatch, diff --git a/present/present_vblank.c b/present/present_vblank.c index 1c0461e84..72a8b2e3e 100644 --- a/present/present_vblank.c +++ b/present/present_vblank.c @@ -19,6 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> #include "present_priv.h" #include <unistd.h> diff --git a/present/presentext.h b/present/presentext.h index f177f55dc..57bd6a6b4 100644 --- a/present/presentext.h +++ b/present/presentext.h @@ -23,7 +23,8 @@ #ifndef _PRESENTEXT_H_ #define _PRESENTEXT_H_ -extern _X_EXPORT void -present_extension_init(void); +#include <X11/Xfuncproto.h> + +_X_EXPORT void present_extension_init(void); #endif /* _PRESENTEXT_H_ */ diff --git a/pseudoramiX/pseudoramiX.c b/pseudoramiX/pseudoramiX.c index 3623fadc7..d2a51dbac 100644 --- a/pseudoramiX/pseudoramiX.c +++ b/pseudoramiX/pseudoramiX.c @@ -33,9 +33,9 @@ Equipment Corporation. ******************************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include <X11/Xfuncproto.h> #include "pseudoramiX.h" #include "extnsionst.h" @@ -46,8 +46,8 @@ #include <X11/extensions/panoramiXproto.h> #include "globals.h" -#define TRACE PseudoramiXTrace("TRACE " __FILE__ ":%s",__FUNCTION__) -#define DEBUG_LOG PseudoramiXDebug +#define TRACE LogMessageVerb(X_NONE, 10, "TRACE " __FILE__ ":%s", __FUNCTION__) +#define DEBUG_LOG(...) LogMessageVerb(X_NONE, 3, __VA_ARGS__); Bool noPseudoramiXExtension = FALSE; extern Bool noRRXineramaExtension; @@ -100,34 +100,6 @@ static int pseudoramiXScreensAllocated = 0; static int pseudoramiXNumScreens = 0; static unsigned long pseudoramiXGeneration = 0; -static void -PseudoramiXTrace(const char *format, ...) - _X_ATTRIBUTE_PRINTF(1, 2); - -static void -PseudoramiXTrace(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - LogVMessageVerb(X_NONE, 10, format, ap); - va_end(ap); -} - -static void -PseudoramiXDebug(const char *format, ...) - _X_ATTRIBUTE_PRINTF(1, 2); - -static void -PseudoramiXDebug(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - LogVMessageVerb(X_NONE, 3, format, ap); - va_end(ap); -} - // Add a PseudoramiX screen. // The rest of the X server will know nothing about this screen. // Can be called before or after extension init. @@ -435,7 +407,6 @@ SProcPseudoramiXQueryVersion(ClientPtr client) TRACE; - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); return ProcPseudoramiXQueryVersion(client); } @@ -447,7 +418,6 @@ SProcPseudoramiXGetState(ClientPtr client) TRACE; - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); return ProcPseudoramiXGetState(client); } @@ -459,7 +429,6 @@ SProcPseudoramiXGetScreenCount(ClientPtr client) TRACE; - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); return ProcPseudoramiXGetScreenCount(client); } @@ -471,7 +440,6 @@ SProcPseudoramiXGetScreenSize(ClientPtr client) TRACE; - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); return ProcPseudoramiXGetScreenSize(client); } @@ -483,7 +451,6 @@ SProcPseudoramiXIsActive(ClientPtr client) TRACE; - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXineramaIsActiveReq); return ProcPseudoramiXIsActive(client); } @@ -495,7 +462,6 @@ SProcPseudoramiXQueryScreens(ClientPtr client) TRACE; - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); return ProcPseudoramiXQueryScreens(client); } diff --git a/randr/randr.c b/randr/randr.c index 3cb4cbd39..3459c4d76 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -26,9 +26,7 @@ * Keith Packard, Intel Corporation */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "randrstr_priv.h" #include "extinit_priv.h" @@ -446,9 +444,9 @@ RRExtensionInit(void) RRCrtcInitErrorValue(); RROutputInitErrorValue(); RRProviderInitErrorValue(); -#ifdef PANORAMIX +#ifdef XINERAMA RRXineramaExtensionInit(); -#endif +#endif /* XINERAMA */ } void diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index b47f0aeac..42421b1ce 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1305,7 +1305,7 @@ ProcRRSetCrtcConfig(ClientPtr client) CARD8 status; REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); - numOutputs = (stuff->length - bytes_to_int32(SIZEOF(xRRSetCrtcConfigReq))); + numOutputs = (client->req_len - bytes_to_int32(sizeof(xRRSetCrtcConfigReq))); VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 8cb79b199..615e89312 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -23,6 +23,7 @@ #include "dix/dix_priv.h" #include "randr/randrstr_priv.h" +#include "os/fmt.h" #include "protocol-versions.h" diff --git a/randr/rrlease.c b/randr/rrlease.c index 4d92b4af9..b6083cd2a 100644 --- a/randr/rrlease.c +++ b/randr/rrlease.c @@ -25,6 +25,7 @@ #include "dix/dix_priv.h" #include "randr/randrstr_priv.h" +#include "os/client_priv.h" #include "swaprep.h" diff --git a/randr/rrmode.c b/randr/rrmode.c index 23d5c70d8..20ff4525d 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -304,7 +304,7 @@ ProcRRCreateMode(ClientPtr client) modeInfo = &stuff->modeInfo; name = (char *) (stuff + 1); - units_after = (stuff->length - bytes_to_int32(sizeof(xRRCreateModeReq))); + units_after = (client->req_len - bytes_to_int32(sizeof(xRRCreateModeReq))); /* check to make sure requested name fits within the data provided */ if (bytes_to_int32(modeInfo->nameLength) > units_after) diff --git a/randr/rrmonitor.c b/randr/rrmonitor.c index 9280061ff..b3712c0ca 100644 --- a/randr/rrmonitor.c +++ b/randr/rrmonitor.c @@ -672,7 +672,7 @@ ProcRRSetMonitor(ClientPtr client) REQUEST_AT_LEAST_SIZE(xRRSetMonitorReq); - if (stuff->monitor.noutput != stuff->length - (SIZEOF(xRRSetMonitorReq) >> 2)) + if (stuff->monitor.noutput != client->req_len - (sizeof(xRRSetMonitorReq) >> 2)) return BadLength; r = dixLookupWindow(&window, stuff->window, client, DixGetAttrAccess); diff --git a/randr/rrpointer.c b/randr/rrpointer.c index b301d050d..bd394530a 100644 --- a/randr/rrpointer.c +++ b/randr/rrpointer.c @@ -19,6 +19,9 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> + +#include "dix/cursor_priv.h" #include "randrstr.h" #include "inputstr.h" diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 327a0656c..f97c3464f 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -19,11 +19,15 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> + +#include <X11/Xatom.h> + +#include "dix/dix_priv.h" #include "randrstr_priv.h" #include "propertyst.h" #include "swaprep.h" -#include <X11/Xatom.h> static int DeliverPropertyEvent(WindowPtr pWin, void *value) @@ -516,7 +520,7 @@ ProcRRConfigureOutputProperty(ClientPtr client) return BadAccess; num_valid = - stuff->length - bytes_to_int32(sizeof(xRRConfigureOutputPropertyReq)); + client->req_len - bytes_to_int32(sizeof(xRRConfigureOutputPropertyReq)); return RRConfigureOutputProperty(output, stuff->property, stuff->pending, stuff->range, FALSE, num_valid, (INT32 *) (stuff + 1)); diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 9c874aa37..c67de88ae 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -224,10 +224,11 @@ ProcRRGetProviderInfo (ClientPtr client) } if (provider->output_source) { providers[i] = provider->output_source->id; - if (client->swapped) - swapl(&providers[i]); prov_cap[i] = RR_Capability_SourceOutput; + if (client->swapped) { + swapl(&providers[i]); swapl(&prov_cap[i]); + } i++; } xorg_list_for_each_entry(provscreen, &pScreen->secondary_list, secondary_head) { @@ -249,7 +250,7 @@ ProcRRGetProviderInfo (ClientPtr client) memcpy(name, provider->name, rep.nameLength); if (client->swapped) { - swaps(&rep.sequenceNumber); + swaps(&rep.sequenceNumber); swapl(&rep.length); swapl(&rep.capabilities); swaps(&rep.nCrtcs); diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c index 7f22c7e34..e84e0dff3 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -19,6 +19,9 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ +#include <dix-config.h> + +#include "dix/dix_priv.h" #include "randrstr_priv.h" #include "propertyst.h" @@ -179,7 +182,11 @@ RRChangeProviderProperty(RRProviderPtr provider, Atom property, Atom type, if (mode == PropModeReplace || len > 0) { void *new_data = NULL, *old_data = NULL; - + if (total_len > MAXINT / size_in_bytes) { + if (add) + RRDestroyProviderProperty(prop); + return BadValue; + } total_size = total_len * size_in_bytes; new_value.data = (void *) malloc(total_size); if (!new_value.data && total_size) { @@ -484,7 +491,7 @@ ProcRRConfigureProviderProperty(ClientPtr client) VERIFY_RR_PROVIDER(stuff->provider, provider, DixReadAccess); num_valid = - stuff->length - bytes_to_int32(sizeof(xRRConfigureProviderPropertyReq)); + client->req_len - bytes_to_int32(sizeof(xRRConfigureProviderPropertyReq)); return RRConfigureProviderProperty(provider, stuff->property, stuff->pending, stuff->range, FALSE, num_valid, (INT32 *) (stuff + 1)); diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c index 1f29d9d39..6de8775b0 100644 --- a/randr/rrsdispatch.c +++ b/randr/rrsdispatch.c @@ -28,7 +28,6 @@ SProcRRQueryVersion(ClientPtr client) REQUEST(xRRQueryVersionReq); REQUEST_SIZE_MATCH(xRRQueryVersionReq); - swaps(&stuff->length); swapl(&stuff->majorVersion); swapl(&stuff->minorVersion); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -40,7 +39,6 @@ SProcRRGetScreenInfo(ClientPtr client) REQUEST(xRRGetScreenInfoReq); REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - swaps(&stuff->length); swapl(&stuff->window); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -58,7 +56,6 @@ SProcRRSetScreenConfig(ClientPtr client) REQUEST_SIZE_MATCH(xRR1_0SetScreenConfigReq); } - swaps(&stuff->length); swapl(&stuff->drawable); swapl(&stuff->timestamp); swaps(&stuff->sizeID); @@ -72,7 +69,6 @@ SProcRRSelectInput(ClientPtr client) REQUEST(xRRSelectInputReq); REQUEST_SIZE_MATCH(xRRSelectInputReq); - swaps(&stuff->length); swapl(&stuff->window); swaps(&stuff->enable); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -84,7 +80,6 @@ SProcRRGetScreenSizeRange(ClientPtr client) REQUEST(xRRGetScreenSizeRangeReq); REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq); - swaps(&stuff->length); swapl(&stuff->window); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -95,7 +90,6 @@ SProcRRSetScreenSize(ClientPtr client) REQUEST(xRRSetScreenSizeReq); REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); - swaps(&stuff->length); swapl(&stuff->window); swaps(&stuff->width); swaps(&stuff->height); @@ -110,6 +104,16 @@ SProcRRGetScreenResources(ClientPtr client) REQUEST(xRRGetScreenResourcesReq); REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); + swapl(&stuff->window); + return (*ProcRandrVector[stuff->randrReqType]) (client); +} + +static int _X_COLD +SProcRRGetScreenResourcesCurrent(ClientPtr client) +{ + REQUEST(xRRGetScreenResourcesCurrentReq); + + REQUEST_SIZE_MATCH(xRRGetScreenResourcesCurrentReq); swaps(&stuff->length); swapl(&stuff->window); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -121,7 +125,6 @@ SProcRRGetOutputInfo(ClientPtr client) REQUEST(xRRGetOutputInfoReq); REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->configTimestamp); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -133,7 +136,6 @@ SProcRRListOutputProperties(ClientPtr client) REQUEST(xRRListOutputPropertiesReq); REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); - swaps(&stuff->length); swapl(&stuff->output); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -144,7 +146,6 @@ SProcRRQueryOutputProperty(ClientPtr client) REQUEST(xRRQueryOutputPropertyReq); REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->property); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -156,7 +157,6 @@ SProcRRConfigureOutputProperty(ClientPtr client) REQUEST(xRRConfigureOutputPropertyReq); REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->property); SwapRestL(stuff); @@ -169,7 +169,6 @@ SProcRRChangeOutputProperty(ClientPtr client) REQUEST(xRRChangeOutputPropertyReq); REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->property); swapl(&stuff->type); @@ -196,7 +195,6 @@ SProcRRDeleteOutputProperty(ClientPtr client) REQUEST(xRRDeleteOutputPropertyReq); REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->property); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -208,7 +206,6 @@ SProcRRGetOutputProperty(ClientPtr client) REQUEST(xRRGetOutputPropertyReq); REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->property); swapl(&stuff->type); @@ -225,7 +222,6 @@ SProcRRCreateMode(ClientPtr client) REQUEST(xRRCreateModeReq); REQUEST_AT_LEAST_SIZE(xRRCreateModeReq); - swaps(&stuff->length); swapl(&stuff->window); modeinfo = &stuff->modeInfo; @@ -250,7 +246,6 @@ SProcRRDestroyMode(ClientPtr client) REQUEST(xRRDestroyModeReq); REQUEST_SIZE_MATCH(xRRDestroyModeReq); - swaps(&stuff->length); swapl(&stuff->mode); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -261,7 +256,6 @@ SProcRRAddOutputMode(ClientPtr client) REQUEST(xRRAddOutputModeReq); REQUEST_SIZE_MATCH(xRRAddOutputModeReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->mode); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -273,7 +267,6 @@ SProcRRDeleteOutputMode(ClientPtr client) REQUEST(xRRDeleteOutputModeReq); REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); - swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->mode); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -285,7 +278,6 @@ SProcRRGetCrtcInfo(ClientPtr client) REQUEST(xRRGetCrtcInfoReq); REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); - swaps(&stuff->length); swapl(&stuff->crtc); swapl(&stuff->configTimestamp); return (*ProcRandrVector[stuff->randrReqType]) (client); @@ -297,7 +289,6 @@ SProcRRSetCrtcConfig(ClientPtr client) REQUEST(xRRSetCrtcConfigReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); - swaps(&stuff->length); swapl(&stuff->crtc); swapl(&stuff->timestamp); swapl(&stuff->configTimestamp); @@ -315,7 +306,6 @@ SProcRRGetCrtcGammaSize(ClientPtr client) REQUEST(xRRGetCrtcGammaSizeReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); - swaps(&stuff->length); swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -326,7 +316,6 @@ SProcRRGetCrtcGamma(ClientPtr client) REQUEST(xRRGetCrtcGammaReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); - swaps(&stuff->length); swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -337,7 +326,6 @@ SProcRRSetCrtcGamma(ClientPtr client) REQUEST(xRRSetCrtcGammaReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq); - swaps(&stuff->length); swapl(&stuff->crtc); swaps(&stuff->size); SwapRestS(stuff); @@ -354,7 +342,6 @@ SProcRRSetCrtcTransform(ClientPtr client) REQUEST(xRRSetCrtcTransformReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq); - swaps(&stuff->length); swapl(&stuff->crtc); SwapLongs((CARD32 *) &stuff->transform, bytes_to_int32(sizeof(xRenderTransform))); @@ -375,7 +362,6 @@ SProcRRGetCrtcTransform(ClientPtr client) REQUEST(xRRGetCrtcTransformReq); REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq); - swaps(&stuff->length); swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -386,7 +372,6 @@ SProcRRGetPanning(ClientPtr client) REQUEST(xRRGetPanningReq); REQUEST_SIZE_MATCH(xRRGetPanningReq); - swaps(&stuff->length); swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -397,7 +382,6 @@ SProcRRSetPanning(ClientPtr client) REQUEST(xRRSetPanningReq); REQUEST_SIZE_MATCH(xRRSetPanningReq); - swaps(&stuff->length); swapl(&stuff->crtc); swapl(&stuff->timestamp); swaps(&stuff->left); @@ -421,7 +405,6 @@ SProcRRSetOutputPrimary(ClientPtr client) REQUEST(xRRSetOutputPrimaryReq); REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq); - swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->output); return ProcRandrVector[stuff->randrReqType] (client); @@ -433,7 +416,6 @@ SProcRRGetOutputPrimary(ClientPtr client) REQUEST(xRRGetOutputPrimaryReq); REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq); - swaps(&stuff->length); swapl(&stuff->window); return ProcRandrVector[stuff->randrReqType] (client); } @@ -444,7 +426,6 @@ SProcRRGetProviders(ClientPtr client) REQUEST(xRRGetProvidersReq); REQUEST_SIZE_MATCH(xRRGetProvidersReq); - swaps(&stuff->length); swapl(&stuff->window); return ProcRandrVector[stuff->randrReqType] (client); } @@ -455,7 +436,6 @@ SProcRRGetProviderInfo(ClientPtr client) REQUEST(xRRGetProviderInfoReq); REQUEST_SIZE_MATCH(xRRGetProviderInfoReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->configTimestamp); return ProcRandrVector[stuff->randrReqType] (client); @@ -467,7 +447,6 @@ SProcRRSetProviderOffloadSink(ClientPtr client) REQUEST(xRRSetProviderOffloadSinkReq); REQUEST_SIZE_MATCH(xRRSetProviderOffloadSinkReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->sink_provider); swapl(&stuff->configTimestamp); @@ -480,7 +459,6 @@ SProcRRSetProviderOutputSource(ClientPtr client) REQUEST(xRRSetProviderOutputSourceReq); REQUEST_SIZE_MATCH(xRRSetProviderOutputSourceReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->source_provider); swapl(&stuff->configTimestamp); @@ -493,7 +471,6 @@ SProcRRListProviderProperties(ClientPtr client) REQUEST(xRRListProviderPropertiesReq); REQUEST_SIZE_MATCH(xRRListProviderPropertiesReq); - swaps(&stuff->length); swapl(&stuff->provider); return ProcRandrVector[stuff->randrReqType] (client); } @@ -504,7 +481,6 @@ SProcRRQueryProviderProperty(ClientPtr client) REQUEST(xRRQueryProviderPropertyReq); REQUEST_SIZE_MATCH(xRRQueryProviderPropertyReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->property); return ProcRandrVector[stuff->randrReqType] (client); @@ -516,7 +492,6 @@ SProcRRConfigureProviderProperty(ClientPtr client) REQUEST(xRRConfigureProviderPropertyReq); REQUEST_AT_LEAST_SIZE(xRRConfigureProviderPropertyReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->property); /* TODO: no way to specify format? */ @@ -530,7 +505,6 @@ SProcRRChangeProviderProperty(ClientPtr client) REQUEST(xRRChangeProviderPropertyReq); REQUEST_AT_LEAST_SIZE(xRRChangeProviderPropertyReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->property); swapl(&stuff->type); @@ -554,7 +528,6 @@ SProcRRDeleteProviderProperty(ClientPtr client) REQUEST(xRRDeleteProviderPropertyReq); REQUEST_SIZE_MATCH(xRRDeleteProviderPropertyReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->property); return ProcRandrVector[stuff->randrReqType] (client); @@ -566,7 +539,6 @@ SProcRRGetProviderProperty(ClientPtr client) REQUEST(xRRGetProviderPropertyReq); REQUEST_SIZE_MATCH(xRRGetProviderPropertyReq); - swaps(&stuff->length); swapl(&stuff->provider); swapl(&stuff->property); swapl(&stuff->type); @@ -580,7 +552,6 @@ SProcRRGetMonitors(ClientPtr client) { REQUEST(xRRGetMonitorsReq); REQUEST_SIZE_MATCH(xRRGetMonitorsReq); - swaps(&stuff->length); swapl(&stuff->window); return ProcRandrVector[stuff->randrReqType] (client); } @@ -590,7 +561,6 @@ SProcRRSetMonitor(ClientPtr client) { REQUEST(xRRSetMonitorReq); REQUEST_AT_LEAST_SIZE(xRRGetMonitorsReq); - swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->monitor.name); swaps(&stuff->monitor.noutput); @@ -607,7 +577,6 @@ SProcRRDeleteMonitor(ClientPtr client) { REQUEST(xRRDeleteMonitorReq); REQUEST_SIZE_MATCH(xRRDeleteMonitorReq); - swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->name); return ProcRandrVector[stuff->randrReqType] (client); @@ -618,7 +587,6 @@ SProcRRCreateLease(ClientPtr client) { REQUEST(xRRCreateLeaseReq); REQUEST_AT_LEAST_SIZE(xRRCreateLeaseReq); - swaps(&stuff->length); swapl(&stuff->window); swaps(&stuff->nCrtcs); swaps(&stuff->nOutputs); @@ -631,7 +599,6 @@ SProcRRFreeLease(ClientPtr client) { REQUEST(xRRFreeLeaseReq); REQUEST_SIZE_MATCH(xRRFreeLeaseReq); - swaps(&stuff->length); swapl(&stuff->lid); return ProcRandrVector[stuff->randrReqType] (client); } @@ -667,7 +634,7 @@ int (*SProcRandrVector[RRNumberRequests]) (ClientPtr) = { SProcRRGetCrtcGamma, /* 23 */ SProcRRSetCrtcGamma, /* 24 */ /* V1.3 additions */ - SProcRRGetScreenResources, /* 25 GetScreenResourcesCurrent */ + SProcRRGetScreenResourcesCurrent, /* 25 */ SProcRRSetCrtcTransform, /* 26 */ SProcRRGetCrtcTransform, /* 27 */ SProcRRGetPanning, /* 28 */ diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c index 36d53dc1e..e2f489ae0 100644 --- a/randr/rrxinerama.c +++ b/randr/rrxinerama.c @@ -338,19 +338,9 @@ ProcRRXineramaDispatch(ClientPtr client) /* SProc */ static int _X_COLD -SProcRRXineramaQueryVersion(ClientPtr client) -{ - REQUEST(xPanoramiXQueryVersionReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); - return ProcRRXineramaQueryVersion(client); -} - -static int _X_COLD SProcRRXineramaGetState(ClientPtr client) { REQUEST(xPanoramiXGetStateReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); swapl(&stuff->window); return ProcRRXineramaGetState(client); @@ -360,7 +350,6 @@ static int _X_COLD SProcRRXineramaGetScreenCount(ClientPtr client) { REQUEST(xPanoramiXGetScreenCountReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); swapl(&stuff->window); return ProcRRXineramaGetScreenCount(client); @@ -370,38 +359,19 @@ static int _X_COLD SProcRRXineramaGetScreenSize(ClientPtr client) { REQUEST(xPanoramiXGetScreenSizeReq); - swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); swapl(&stuff->window); swapl(&stuff->screen); return ProcRRXineramaGetScreenSize(client); } -static int _X_COLD -SProcRRXineramaIsActive(ClientPtr client) -{ - REQUEST(xXineramaIsActiveReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXineramaIsActiveReq); - return ProcRRXineramaIsActive(client); -} - -static int _X_COLD -SProcRRXineramaQueryScreens(ClientPtr client) -{ - REQUEST(xXineramaQueryScreensReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); - return ProcRRXineramaQueryScreens(client); -} - int SProcRRXineramaDispatch(ClientPtr client) { REQUEST(xReq); switch (stuff->data) { case X_PanoramiXQueryVersion: - return SProcRRXineramaQueryVersion(client); + return ProcRRXineramaQueryVersion(client); case X_PanoramiXGetState: return SProcRRXineramaGetState(client); case X_PanoramiXGetScreenCount: @@ -409,9 +379,9 @@ SProcRRXineramaDispatch(ClientPtr client) case X_PanoramiXGetScreenSize: return SProcRRXineramaGetScreenSize(client); case X_XineramaIsActive: - return SProcRRXineramaIsActive(client); + return ProcRRXineramaIsActive(client); case X_XineramaQueryScreens: - return SProcRRXineramaQueryScreens(client); + return ProcRRXineramaQueryScreens(client); } return BadRequest; } @@ -419,10 +389,10 @@ SProcRRXineramaDispatch(ClientPtr client) void RRXineramaExtensionInit(void) { -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) return; -#endif +#endif /* XINERAMA */ if (noRRXineramaExtension) return; diff --git a/record/record.c b/record/record.c index b0a7aff15..e8004a85f 100644 --- a/record/record.c +++ b/record/record.c @@ -32,11 +32,11 @@ and Jim Haggerty of Metheus. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include "dix/cursor_priv.h" #include "dix/eventconvert.h" +#include "os/osdep.h" #include "dixstruct.h" #include "extnsionst.h" @@ -50,12 +50,12 @@ and Jim Haggerty of Metheus. #include <stdio.h> #include <assert.h> -#ifdef PANORAMIX +#ifdef XINERAMA #include "globals.h" #include "panoramiX.h" #include "panoramiXsrv.h" #include "cursor.h" -#endif +#endif /* XINERAMA */ #include "protocol-versions.h" @@ -714,7 +714,7 @@ RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP, xEvent swappedEvent; xEvent *pEvToRecord = pev; -#ifdef PANORAMIX +#ifdef XINERAMA xEvent shiftedEvent; if (!noPanoramiXExtension && @@ -722,7 +722,7 @@ RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP, pev->u.u.type == ButtonPress || pev->u.u.type == ButtonRelease || pev->u.u.type == KeyPress || pev->u.u.type == KeyRelease)) { - int scr = XineramaGetCursorScreen(inputInfo.pointer); + int scr = inputInfo.pointer->spriteInfo->sprite->screen->myNum; memcpy(&shiftedEvent, pev, sizeof(xEvent)); shiftedEvent.u.keyButtonPointer.rootX += @@ -731,7 +731,7 @@ RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP, screenInfo.screens[scr]->y - screenInfo.screens[0]->y; pEvToRecord = &shiftedEvent; } -#endif /* PANORAMIX */ +#endif /* XINERAMA */ if (pContext->pRecordingClient->swapped) { (*EventSwapVector[pEvToRecord->u.u.type & 0177]) @@ -1299,6 +1299,13 @@ RecordSanityCheckRegisterClients(RecordContextPtr pContext, ClientPtr client, int i; XID recordingClient; + /* LimitClients is 2048 at max, way less that MAXINT */ + if (stuff->nClients > LimitClients) + return BadValue; + + if (stuff->nRanges > (MAXINT - 4 * stuff->nClients) / SIZEOF(xRecordRange)) + return BadValue; + if (((client->req_len << 2) - SIZEOF(xRecordRegisterClientsReq)) != 4 * stuff->nClients + SIZEOF(xRecordRange) * stuff->nRanges) return BadLength; @@ -1393,17 +1400,13 @@ typedef struct { short first, last; /* if for extension, major opcode interval */ } SetInfoRec, *SetInfoPtr; -#if defined(ERR) && defined(__sun) -#undef ERR /* Avoid conflict with Solaris <sys/regset.h> */ -#endif - /* These constant are used to index into an array of SetInfoRec. */ enum { REQ, /* set info for requests */ - REP, /* set info for replies */ - ERR, /* set info for errors */ - DEV, /* set info for device events */ - DLEV, /* set info for delivered events */ - PREDEFSETS + RI_REP, /* set info for replies */ + RI_ERR, /* set info for errors */ + RI_DEV, /* set info for device events */ + RI_DLEV, /* set info for delivered events */ + RI_PREDEFSETS }; /* number of predefined array entries */ /* RecordAllocIntervals @@ -1583,7 +1586,7 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, * protocol types, plus one per range for extension requests, plus one per * range for extension replies. */ - maxSets = PREDEFSETS + 2 * stuff->nRanges; + maxSets = RI_PREDEFSETS + 2 * stuff->nRanges; si = xallocarray(maxSets, sizeof(SetInfoRec)); if (!si) { err = BadAlloc; @@ -1595,7 +1598,7 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, for (i = 0; i < maxSets; i++) si[i].intervals = NULL; - pExtReqSets = si + PREDEFSETS; + pExtReqSets = si + RI_PREDEFSETS; pExtRepSets = pExtReqSets + stuff->nRanges; pRanges = (xRecordRange *) (((XID *) &stuff[1]) + stuff->nClients); @@ -1612,31 +1615,31 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, if (err != Success) goto bailout; - err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges, + err = RecordConvertRangesToIntervals(&si[RI_REP], pRanges, stuff->nRanges, offset_of(rr, coreRepliesFirst), NULL, NULL); if (err != Success) goto bailout; - err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges, + err = RecordConvertRangesToIntervals(&si[RI_REP], pRanges, stuff->nRanges, offset_of(rr, extRepliesMajorFirst), pExtRepSets, &nExtRepSets); if (err != Success) goto bailout; - err = RecordConvertRangesToIntervals(&si[ERR], pRanges, stuff->nRanges, + err = RecordConvertRangesToIntervals(&si[RI_ERR], pRanges, stuff->nRanges, offset_of(rr, errorsFirst), NULL, NULL); if (err != Success) goto bailout; - err = RecordConvertRangesToIntervals(&si[DLEV], pRanges, stuff->nRanges, + err = RecordConvertRangesToIntervals(&si[RI_DLEV], pRanges, stuff->nRanges, offset_of(rr, deliveredEventsFirst), NULL, NULL); if (err != Success) goto bailout; - err = RecordConvertRangesToIntervals(&si[DEV], pRanges, stuff->nRanges, + err = RecordConvertRangesToIntervals(&si[RI_DEV], pRanges, stuff->nRanges, offset_of(rr, deviceEventsFirst), NULL, NULL); if (err != Success) @@ -1716,38 +1719,38 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, else pRCAP->pRequestMajorOpSet = NULL; - if (si[REP].intervals) { + if (si[RI_REP].intervals) { pRCAP->pReplyMajorOpSet = - RecordCreateSet(si[REP].intervals, si[REP].nintervals, - (RecordSetPtr) ((char *) pRCAP + si[REP].offset), - si[REP].size); + RecordCreateSet(si[RI_REP].intervals, si[RI_REP].nintervals, + (RecordSetPtr) ((char *) pRCAP + si[RI_REP].offset), + si[RI_REP].size); } else pRCAP->pReplyMajorOpSet = NULL; - if (si[ERR].intervals) { + if (si[RI_ERR].intervals) { pRCAP->pErrorSet = - RecordCreateSet(si[ERR].intervals, si[ERR].nintervals, - (RecordSetPtr) ((char *) pRCAP + si[ERR].offset), - si[ERR].size); + RecordCreateSet(si[RI_ERR].intervals, si[RI_ERR].nintervals, + (RecordSetPtr) ((char *) pRCAP + si[RI_ERR].offset), + si[RI_ERR].size); } else pRCAP->pErrorSet = NULL; - if (si[DEV].intervals) { + if (si[RI_DEV].intervals) { pRCAP->pDeviceEventSet = - RecordCreateSet(si[DEV].intervals, si[DEV].nintervals, - (RecordSetPtr) ((char *) pRCAP + si[DEV].offset), - si[DEV].size); + RecordCreateSet(si[RI_DEV].intervals, si[RI_DEV].nintervals, + (RecordSetPtr) ((char *) pRCAP + si[RI_DEV].offset), + si[RI_DEV].size); } else pRCAP->pDeviceEventSet = NULL; - if (si[DLEV].intervals) { + if (si[RI_DLEV].intervals) { pRCAP->pDeliveredEventSet = - RecordCreateSet(si[DLEV].intervals, si[DLEV].nintervals, - (RecordSetPtr) ((char *) pRCAP + si[DLEV].offset), - si[DLEV].size); + RecordCreateSet(si[RI_DLEV].intervals, si[RI_DLEV].nintervals, + (RecordSetPtr) ((char *) pRCAP + si[RI_DLEV].offset), + si[RI_DLEV].size); } else pRCAP->pDeliveredEventSet = NULL; @@ -2492,8 +2495,6 @@ static int _X_COLD SProcRecordQueryVersion(ClientPtr client) { REQUEST(xRecordQueryVersionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xRecordQueryVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); @@ -2530,7 +2531,6 @@ SProcRecordCreateContext(ClientPtr client) REQUEST(xRecordCreateContextReq); int status; - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq); if ((status = SwapCreateRegister(client, (void *) stuff)) != Success) return status; @@ -2543,7 +2543,6 @@ SProcRecordRegisterClients(ClientPtr client) REQUEST(xRecordRegisterClientsReq); int status; - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq); if ((status = SwapCreateRegister(client, (void *) stuff)) != Success) return status; @@ -2554,8 +2553,6 @@ static int _X_COLD SProcRecordUnregisterClients(ClientPtr client) { REQUEST(xRecordUnregisterClientsReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq); swapl(&stuff->context); swapl(&stuff->nClients); @@ -2567,8 +2564,6 @@ static int _X_COLD SProcRecordGetContext(ClientPtr client) { REQUEST(xRecordGetContextReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xRecordGetContextReq); swapl(&stuff->context); return ProcRecordGetContext(client); @@ -2578,8 +2573,6 @@ static int _X_COLD SProcRecordEnableContext(ClientPtr client) { REQUEST(xRecordEnableContextReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xRecordEnableContextReq); swapl(&stuff->context); return ProcRecordEnableContext(client); @@ -2589,8 +2582,6 @@ static int _X_COLD SProcRecordDisableContext(ClientPtr client) { REQUEST(xRecordDisableContextReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xRecordDisableContextReq); swapl(&stuff->context); return ProcRecordDisableContext(client); @@ -2600,8 +2591,6 @@ static int _X_COLD SProcRecordFreeContext(ClientPtr client) { REQUEST(xRecordFreeContextReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xRecordFreeContextReq); swapl(&stuff->context); return ProcRecordFreeContext(client); diff --git a/record/set.c b/record/set.c index 74e40d93e..f071a4b3f 100644 --- a/record/set.c +++ b/record/set.c @@ -45,9 +45,7 @@ from The Open Group. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <string.h> diff --git a/render/animcur.c b/render/animcur.c index e736e4c24..1194cee7e 100644 --- a/render/animcur.c +++ b/render/animcur.c @@ -31,12 +31,13 @@ * delta times between each image. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include <X11/Xmd.h> + +#include "dix/cursor_priv.h" + #include "servermd.h" #include "scrnintstr.h" #include "dixstruct.h" @@ -304,6 +305,9 @@ AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor, int rc = BadAlloc, i; AnimCurPtr ac; + if (ncursor <= 0) + return BadValue; + for (i = 0; i < screenInfo.numScreens; i++) if (!GetAnimCurScreen(screenInfo.screens[i])) return BadImplementation; @@ -336,7 +340,7 @@ AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor, /* security creation/labeling check */ if (ac->timer) - rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, X11_RESTYPE_CURSOR, pCursor, + rc = XaceHookResourceAccess(client, cid, X11_RESTYPE_CURSOR, pCursor, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) { diff --git a/render/filter.c b/render/filter.c index 44f6b6465..546998a92 100644 --- a/render/filter.c +++ b/render/filter.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #define XK_LATIN1 #include <X11/keysymdef.h> diff --git a/render/glyph.c b/render/glyph.c index 5fa7f3b5b..57aa46789 100644 --- a/render/glyph.c +++ b/render/glyph.c @@ -22,9 +22,7 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "os/xsha1.h" diff --git a/render/matrix.c b/render/matrix.c index 83cd66c43..2d66e71de 100644 --- a/render/matrix.c +++ b/render/matrix.c @@ -20,9 +20,7 @@ * OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "misc.h" #include "scrnintstr.h" diff --git a/render/miindex.c b/render/miindex.c index 4119eef66..6b0bb2c9b 100644 --- a/render/miindex.c +++ b/render/miindex.c @@ -21,12 +21,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif -#ifndef _MIINDEX_H_ -#define _MIINDEX_H_ +#include "dix/colormap_priv.h" #include "scrnintstr.h" #include "gcstruct.h" @@ -328,5 +325,3 @@ miUpdateIndexed(ScreenPtr pScreen, } } } - -#endif /* _MIINDEX_H_ */ diff --git a/render/mipict.c b/render/mipict.c index 7fb03435b..ac376eb71 100644 --- a/render/mipict.c +++ b/render/mipict.c @@ -21,9 +21,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "os/osdep.h" #include "scrnintstr.h" #include "gcstruct.h" diff --git a/render/mirect.c b/render/mirect.c index 65f8d5efd..6302ec7f1 100644 --- a/render/mirect.c +++ b/render/mirect.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "scrnintstr.h" #include "gcstruct.h" diff --git a/render/mitrap.c b/render/mitrap.c index 17b6dcd1c..cccaf6f4a 100644 --- a/render/mitrap.c +++ b/render/mitrap.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "scrnintstr.h" #include "gcstruct.h" diff --git a/render/mitri.c b/render/mitri.c index 922f22a6a..876631574 100644 --- a/render/mitri.c +++ b/render/mitri.c @@ -21,9 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "scrnintstr.h" #include "gcstruct.h" diff --git a/render/picture.c b/render/picture.c index 45498b093..1126eb97e 100644 --- a/render/picture.c +++ b/render/picture.c @@ -22,9 +22,10 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "dix/colormap_priv.h" +#include "os/osdep.h" #include "misc.h" #include "scrnintstr.h" @@ -42,9 +43,9 @@ #include "picturestr_priv.h" #include "glyphstr_priv.h" #include "xace.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiXsrv.h" -#endif +#endif /* XINERAMA */ DevPrivateKeyRec PictureScreenPrivateKeyRec; DevPrivateKeyRec PictureWindowPrivateKeyRec; @@ -428,6 +429,9 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format) else { VisualPtr pVisual = PictureFindVisual(pScreen, format->index.vid); + if (pVisual == NULL) + return FALSE; + if (CreateColormap(FakeClientID(0), pScreen, pVisual, &format->index.pColormap, AllocNone, 0) != Success) @@ -760,7 +764,7 @@ CreatePicture(Picture pid, pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24); /* security creation/labeling check */ - *error = XaceHook(XACE_RESOURCE_ACCESS, client, pid, PictureType, pPicture, + *error = XaceHookResourceAccess(client, pid, PictureType, pPicture, X11_RESTYPE_PIXMAP, pDrawable, DixCreateAccess | DixSetAttrAccess); if (*error != Success) goto out; @@ -1002,7 +1006,7 @@ CreateConicalGradientPicture(Picture pid, xPointFixed * center, xFixed angle, static int cpAlphaMap(void **result, XID id, ScreenPtr screen, ClientPtr client, Mask mode) { -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { PanoramiXRes *res; int err = dixLookupResourceByType((void **)&res, id, XRT_PICTURE, @@ -1011,14 +1015,14 @@ cpAlphaMap(void **result, XID id, ScreenPtr screen, ClientPtr client, Mask mode) return err; id = res->info[screen->myNum].id; } -#endif +#endif /* XINERAMA */ return dixLookupResourceByType(result, id, PictureType, client, mode); } static int cpClipMask(void **result, XID id, ScreenPtr screen, ClientPtr client, Mask mode) { -#ifdef PANORAMIX +#ifdef XINERAMA if (!noPanoramiXExtension) { PanoramiXRes *res; int err = dixLookupResourceByType((void **)&res, id, XRT_PIXMAP, @@ -1027,7 +1031,7 @@ cpClipMask(void **result, XID id, ScreenPtr screen, ClientPtr client, Mask mode) return err; id = res->info[screen->myNum].id; } -#endif +#endif /* XINERAMA */ return dixLookupResourceByType(result, id, X11_RESTYPE_PIXMAP, client, mode); } diff --git a/render/picturestr.h b/render/picturestr.h index 001d37bfa..9768ae1bc 100644 --- a/render/picturestr.h +++ b/render/picturestr.h @@ -534,4 +534,13 @@ extern _X_EXPORT Bool extern _X_EXPORT Bool PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector); +/* only for backwards compat w/ drivers that haven't been updated yet + (xf86-video-intel) - don't ever use this in new code + + @todo revise after next stable release +*/ + +#define pict_f_vector pixman_f_vector +#define pict_f_transform pixman_f_transform + #endif /* _PICTURESTR_H_ */ diff --git a/render/picturestr_priv.h b/render/picturestr_priv.h index b5064a5ac..525471df4 100644 --- a/render/picturestr_priv.h +++ b/render/picturestr_priv.h @@ -38,9 +38,9 @@ Bool AnimCurInit(ScreenPtr pScreen); int AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid); -#ifdef PANORAMIX +#ifdef XINERAMA void PanoramiXRenderInit(void); void PanoramiXRenderReset(void); -#endif /* PANORAMIX */ +#endif /* XINERAMA */ #endif /* _XSERVER_PICTURESTR_PRIV_H_ */ diff --git a/render/render.c b/render/render.c index d43c4cf4b..6386c1962 100644 --- a/render/render.c +++ b/render/render.c @@ -22,17 +22,18 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include <stdint.h> #include <X11/X.h> #include <X11/Xproto.h> #include <X11/extensions/render.h> #include <X11/extensions/renderproto.h> #include <X11/Xfuncproto.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "os/osdep.h" #include "misc.h" #include "os.h" @@ -51,12 +52,10 @@ #include "xace.h" #include "protocol-versions.h" -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" -#endif - -#include <stdint.h> +#endif /* XINERAMA */ static int ProcRenderQueryVersion(ClientPtr pClient); static int ProcRenderQueryPictFormats(ClientPtr pClient); @@ -222,9 +221,9 @@ typedef struct _RenderClient { #define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey)) -#ifdef PANORAMIX +#ifdef XINERAMA RESTYPE XRT_PICTURE; -#endif +#endif /* XINERAMA */ void RenderExtensionInit(void) @@ -245,10 +244,10 @@ RenderExtensionInit(void) if (!extEntry) return; RenderErrBase = extEntry->errorBase; -#ifdef PANORAMIX +#ifdef XINERAMA if (XRT_PICTURE) SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture); -#endif +#endif /* XINERAMA */ SetResourceTypeErrorValue(PictureType, RenderErrBase + BadPicture); SetResourceTypeErrorValue(PictFormatType, RenderErrBase + BadPictFormat); SetResourceTypeErrorValue(GlyphSetType, RenderErrBase + BadGlyphSet); @@ -333,14 +332,14 @@ ProcRenderQueryPictFormats(ClientPtr client) REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); -#ifdef PANORAMIX +#ifdef XINERAMA if (noPanoramiXExtension) numScreens = screenInfo.numScreens; else numScreens = ((xConnSetup *) ConnectionInfo)->numRoots; #else numScreens = screenInfo.numScreens; -#endif +#endif /* XINERAMA */ ndepth = nformat = nvisual = 0; for (s = 0; s < numScreens; s++) { pScreen = screenInfo.screens[s]; @@ -929,7 +928,7 @@ ProcRenderCreateGlyphSet(ClientPtr client) if (!glyphSet) return BadAlloc; /* security creation/labeling check */ - rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType, + rc = XaceHookResourceAccess(client, stuff->gsid, GlyphSetType, glyphSet, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (rc != Success) return rc; @@ -1798,6 +1797,8 @@ ProcRenderCreateAnimCursor(ClientPtr client) ncursor = (client->req_len - (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1; + if (ncursor <= 0) + return BadValue; cursors = xallocarray(ncursor, sizeof(CursorPtr) + sizeof(CARD32)); if (!cursors) return BadAlloc; @@ -1862,7 +1863,7 @@ ProcRenderCreateSolidFill(ClientPtr client) if (!pPicture) return error; /* security creation/labeling check */ - error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + error = XaceHookResourceAccess(client, stuff->pid, PictureType, pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (error != Success) return error; @@ -1901,7 +1902,7 @@ ProcRenderCreateLinearGradient(ClientPtr client) if (!pPicture) return error; /* security creation/labeling check */ - error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + error = XaceHookResourceAccess(client, stuff->pid, PictureType, pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (error != Success) return error; @@ -1941,7 +1942,7 @@ ProcRenderCreateRadialGradient(ClientPtr client) if (!pPicture) return error; /* security creation/labeling check */ - error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + error = XaceHookResourceAccess(client, stuff->pid, PictureType, pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (error != Success) return error; @@ -1980,7 +1981,7 @@ ProcRenderCreateConicalGradient(ClientPtr client) if (!pPicture) return error; /* security creation/labeling check */ - error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, + error = XaceHookResourceAccess(client, stuff->pid, PictureType, pPicture, X11_RESTYPE_NONE, NULL, DixCreateAccess); if (error != Success) return error; @@ -2005,7 +2006,6 @@ SProcRenderQueryVersion(ClientPtr client) { REQUEST(xRenderQueryVersionReq); REQUEST_SIZE_MATCH(xRenderQueryVersionReq); - swaps(&stuff->length); swapl(&stuff->majorVersion); swapl(&stuff->minorVersion); return (*ProcRenderVector[stuff->renderReqType]) (client); @@ -2016,7 +2016,6 @@ SProcRenderQueryPictFormats(ClientPtr client) { REQUEST(xRenderQueryPictFormatsReq); REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); - swaps(&stuff->length); return (*ProcRenderVector[stuff->renderReqType]) (client); } @@ -2025,7 +2024,6 @@ SProcRenderQueryPictIndexValues(ClientPtr client) { REQUEST(xRenderQueryPictIndexValuesReq); REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); - swaps(&stuff->length); swapl(&stuff->format); return (*ProcRenderVector[stuff->renderReqType]) (client); } @@ -2041,7 +2039,6 @@ SProcRenderCreatePicture(ClientPtr client) { REQUEST(xRenderCreatePictureReq); REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); - swaps(&stuff->length); swapl(&stuff->pid); swapl(&stuff->drawable); swapl(&stuff->format); @@ -2055,7 +2052,6 @@ SProcRenderChangePicture(ClientPtr client) { REQUEST(xRenderChangePictureReq); REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); - swaps(&stuff->length); swapl(&stuff->picture); swapl(&stuff->mask); SwapRestL(stuff); @@ -2067,7 +2063,6 @@ SProcRenderSetPictureClipRectangles(ClientPtr client) { REQUEST(xRenderSetPictureClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - swaps(&stuff->length); swapl(&stuff->picture); swaps(&stuff->xOrigin); swaps(&stuff->yOrigin); @@ -2080,7 +2075,6 @@ SProcRenderFreePicture(ClientPtr client) { REQUEST(xRenderFreePictureReq); REQUEST_SIZE_MATCH(xRenderFreePictureReq); - swaps(&stuff->length); swapl(&stuff->picture); return (*ProcRenderVector[stuff->renderReqType]) (client); } @@ -2090,7 +2084,6 @@ SProcRenderComposite(ClientPtr client) { REQUEST(xRenderCompositeReq); REQUEST_SIZE_MATCH(xRenderCompositeReq); - swaps(&stuff->length); swapl(&stuff->src); swapl(&stuff->mask); swapl(&stuff->dst); @@ -2117,7 +2110,6 @@ SProcRenderTrapezoids(ClientPtr client) REQUEST(xRenderTrapezoidsReq); REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq); - swaps(&stuff->length); swapl(&stuff->src); swapl(&stuff->dst); swapl(&stuff->maskFormat); @@ -2133,7 +2125,6 @@ SProcRenderTriangles(ClientPtr client) REQUEST(xRenderTrianglesReq); REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - swaps(&stuff->length); swapl(&stuff->src); swapl(&stuff->dst); swapl(&stuff->maskFormat); @@ -2149,7 +2140,6 @@ SProcRenderTriStrip(ClientPtr client) REQUEST(xRenderTriStripReq); REQUEST_AT_LEAST_SIZE(xRenderTriStripReq); - swaps(&stuff->length); swapl(&stuff->src); swapl(&stuff->dst); swapl(&stuff->maskFormat); @@ -2165,7 +2155,6 @@ SProcRenderTriFan(ClientPtr client) REQUEST(xRenderTriFanReq); REQUEST_AT_LEAST_SIZE(xRenderTriFanReq); - swaps(&stuff->length); swapl(&stuff->src); swapl(&stuff->dst); swapl(&stuff->maskFormat); @@ -2198,7 +2187,6 @@ SProcRenderCreateGlyphSet(ClientPtr client) { REQUEST(xRenderCreateGlyphSetReq); REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq); - swaps(&stuff->length); swapl(&stuff->gsid); swapl(&stuff->format); return (*ProcRenderVector[stuff->renderReqType]) (client); @@ -2209,7 +2197,6 @@ SProcRenderReferenceGlyphSet(ClientPtr client) { REQUEST(xRenderReferenceGlyphSetReq); REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq); - swaps(&stuff->length); swapl(&stuff->gsid); swapl(&stuff->existing); return (*ProcRenderVector[stuff->renderReqType]) (client); @@ -2220,7 +2207,6 @@ SProcRenderFreeGlyphSet(ClientPtr client) { REQUEST(xRenderFreeGlyphSetReq); REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); - swaps(&stuff->length); swapl(&stuff->glyphset); return (*ProcRenderVector[stuff->renderReqType]) (client); } @@ -2235,7 +2221,6 @@ SProcRenderAddGlyphs(ClientPtr client) REQUEST(xRenderAddGlyphsReq); REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); - swaps(&stuff->length); swapl(&stuff->glyphset); swapl(&stuff->nglyphs); if (stuff->nglyphs & 0xe0000000) @@ -2270,7 +2255,6 @@ SProcRenderFreeGlyphs(ClientPtr client) { REQUEST(xRenderFreeGlyphsReq); REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); - swaps(&stuff->length); swapl(&stuff->glyphset); SwapRestL(stuff); return (*ProcRenderVector[stuff->renderReqType]) (client); @@ -2301,7 +2285,6 @@ SProcRenderCompositeGlyphs(ClientPtr client) break; } - swaps(&stuff->length); swapl(&stuff->src); swapl(&stuff->dst); swapl(&stuff->maskFormat); @@ -2363,7 +2346,6 @@ SProcRenderFillRectangles(ClientPtr client) REQUEST(xRenderFillRectanglesReq); REQUEST_AT_LEAST_SIZE(xRenderFillRectanglesReq); - swaps(&stuff->length); swapl(&stuff->dst); swaps(&stuff->color.red); swaps(&stuff->color.green); @@ -2379,7 +2361,6 @@ SProcRenderCreateCursor(ClientPtr client) REQUEST(xRenderCreateCursorReq); REQUEST_SIZE_MATCH(xRenderCreateCursorReq); - swaps(&stuff->length); swapl(&stuff->cid); swapl(&stuff->src); swaps(&stuff->x); @@ -2393,7 +2374,6 @@ SProcRenderSetPictureTransform(ClientPtr client) REQUEST(xRenderSetPictureTransformReq); REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); - swaps(&stuff->length); swapl(&stuff->picture); swapl(&stuff->transform.matrix11); swapl(&stuff->transform.matrix12); @@ -2413,7 +2393,6 @@ SProcRenderQueryFilters(ClientPtr client) REQUEST(xRenderQueryFiltersReq); REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); - swaps(&stuff->length); swapl(&stuff->drawable); return (*ProcRenderVector[stuff->renderReqType]) (client); } @@ -2424,7 +2403,6 @@ SProcRenderSetPictureFilter(ClientPtr client) REQUEST(xRenderSetPictureFilterReq); REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq); - swaps(&stuff->length); swapl(&stuff->picture); swaps(&stuff->nbytes); return (*ProcRenderVector[stuff->renderReqType]) (client); @@ -2436,7 +2414,6 @@ SProcRenderCreateAnimCursor(ClientPtr client) REQUEST(xRenderCreateAnimCursorReq); REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq); - swaps(&stuff->length); swapl(&stuff->cid); SwapRestL(stuff); return (*ProcRenderVector[stuff->renderReqType]) (client); @@ -2448,7 +2425,6 @@ SProcRenderAddTraps(ClientPtr client) REQUEST(xRenderAddTrapsReq); REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); - swaps(&stuff->length); swapl(&stuff->picture); swaps(&stuff->xOff); swaps(&stuff->yOff); @@ -2462,7 +2438,6 @@ SProcRenderCreateSolidFill(ClientPtr client) REQUEST(xRenderCreateSolidFillReq); REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq); - swaps(&stuff->length); swapl(&stuff->pid); swaps(&stuff->color.alpha); swaps(&stuff->color.red); @@ -2498,7 +2473,6 @@ SProcRenderCreateLinearGradient(ClientPtr client) REQUEST(xRenderCreateLinearGradientReq); REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq); - swaps(&stuff->length); swapl(&stuff->pid); swapl(&stuff->p1.x); swapl(&stuff->p1.y); @@ -2525,7 +2499,6 @@ SProcRenderCreateRadialGradient(ClientPtr client) REQUEST(xRenderCreateRadialGradientReq); REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq); - swaps(&stuff->length); swapl(&stuff->pid); swapl(&stuff->inner.x); swapl(&stuff->inner.y); @@ -2554,7 +2527,6 @@ SProcRenderCreateConicalGradient(ClientPtr client) REQUEST(xRenderCreateConicalGradientReq); REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq); - swaps(&stuff->length); swapl(&stuff->pid); swapl(&stuff->center.x); swapl(&stuff->center.y); @@ -2583,7 +2555,7 @@ SProcRenderDispatch(ClientPtr client) return BadRequest; } -#ifdef PANORAMIX +#ifdef XINERAMA #define VERIFY_XIN_PICTURE(pPicture, pid, client, mode) {\ int rc = dixLookupResourceByType((void **)&(pPicture), pid,\ XRT_PICTURE, client, mode);\ @@ -3331,4 +3303,4 @@ PanoramiXRenderReset(void) RenderErrBase = 0; } -#endif /* PANORAMIX */ +#endif /* XINERAMA */ diff --git a/test/fixes.c b/test/fixes.c index b5d57cf8f..454cccb4f 100644 --- a/test/fixes.c +++ b/test/fixes.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <stdlib.h> diff --git a/test/hashtabletest.c b/test/hashtabletest.c index 59c39b464..47225e44a 100644 --- a/test/hashtabletest.c +++ b/test/hashtabletest.c @@ -1,6 +1,4 @@ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <misc.h> #include <stdlib.h> diff --git a/test/input.c b/test/input.c index b0de20331..39057c828 100644 --- a/test/input.c +++ b/test/input.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include <X11/X.h> @@ -35,18 +33,19 @@ #include <X11/Xatom.h> #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" #include "dix/eventconvert.h" #include "dix/exevents_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" #include "misc.h" #include "resource.h" #include "windowstr.h" #include "inputstr.h" #include "exglobals.h" -#include "dixgrabs.h" #include "eventstr.h" #include "inpututils.h" -#include "mi.h" #include "assert.h" #include "tests-common.h" @@ -1214,27 +1213,27 @@ dix_input_attributes(void) assert(memcmp(orig, new, sizeof(InputAttributes)) == 0); FreeInputAttributes(new); - orig->product = xnfstrdup("product name"); + orig->product = XNFstrdup("product name"); new = DuplicateInputAttributes(orig); cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig->vendor = xnfstrdup("vendor name"); + orig->vendor = XNFstrdup("vendor name"); new = DuplicateInputAttributes(orig); cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig->device = xnfstrdup("device path"); + orig->device = XNFstrdup("device path"); new = DuplicateInputAttributes(orig); cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig->pnp_id = xnfstrdup("PnPID"); + orig->pnp_id = XNFstrdup("PnPID"); new = DuplicateInputAttributes(orig); cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig->usb_id = xnfstrdup("USBID"); + orig->usb_id = XNFstrdup("USBID"); new = DuplicateInputAttributes(orig); cmp_attr_fields(orig, new); FreeInputAttributes(new); @@ -1256,23 +1255,22 @@ static void dix_input_valuator_masks(void) { ValuatorMask *mask = NULL, *copy; - int nvaluators = MAX_VALUATORS; - double valuators[nvaluators]; - int val_ranged[nvaluators]; + double valuators[MAX_VALUATORS]; + int val_ranged[MAX_VALUATORS]; int i; int first_val, num_vals; - for (i = 0; i < nvaluators; i++) { + for (i = 0; i < MAX_VALUATORS; i++) { valuators[i] = i + 0.5; val_ranged[i] = i; } - mask = valuator_mask_new(nvaluators); + mask = valuator_mask_new(MAX_VALUATORS); assert(mask != NULL); assert(valuator_mask_size(mask) == 0); assert(valuator_mask_num_valuators(mask) == 0); - for (i = 0; i < nvaluators; i++) { + for (i = 0; i < MAX_VALUATORS; i++) { assert(!valuator_mask_isset(mask, i)); valuator_mask_set_double(mask, i, valuators[i]); assert(valuator_mask_isset(mask, i)); @@ -1282,13 +1280,13 @@ dix_input_valuator_masks(void) assert(valuator_mask_num_valuators(mask) == i + 1); } - for (i = 0; i < nvaluators; i++) { + for (i = 0; i < MAX_VALUATORS; i++) { assert(valuator_mask_isset(mask, i)); valuator_mask_unset(mask, i); /* we're removing valuators from the front, so size should stay the * same until the last bit is removed */ - if (i < nvaluators - 1) - assert(valuator_mask_size(mask) == nvaluators); + if (i < MAX_VALUATORS - 1) + assert(valuator_mask_size(mask) == MAX_VALUATORS); assert(!valuator_mask_isset(mask, i)); } @@ -1296,7 +1294,7 @@ dix_input_valuator_masks(void) valuator_mask_zero(mask); assert(valuator_mask_size(mask) == 0); assert(valuator_mask_num_valuators(mask) == 0); - for (i = 0; i < nvaluators; i++) + for (i = 0; i < MAX_VALUATORS; i++) assert(!valuator_mask_isset(mask, i)); first_val = 5; @@ -1305,7 +1303,7 @@ dix_input_valuator_masks(void) valuator_mask_set_range(mask, first_val, num_vals, val_ranged); assert(valuator_mask_size(mask) == first_val + num_vals); assert(valuator_mask_num_valuators(mask) == num_vals); - for (i = 0; i < nvaluators; i++) { + for (i = 0; i < MAX_VALUATORS; i++) { double val; if (i < first_val || i >= first_val + num_vals) { @@ -1322,14 +1320,14 @@ dix_input_valuator_masks(void) } } - copy = valuator_mask_new(nvaluators); + copy = valuator_mask_new(MAX_VALUATORS); valuator_mask_copy(copy, mask); assert(mask != copy); assert(valuator_mask_size(mask) == valuator_mask_size(copy)); assert(valuator_mask_num_valuators(mask) == valuator_mask_num_valuators(copy)); - for (i = 0; i < nvaluators; i++) { + for (i = 0; i < MAX_VALUATORS; i++) { double a, b; assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i)); diff --git a/test/list.c b/test/list.c index 06a9afc1e..b93cfd43a 100644 --- a/test/list.c +++ b/test/list.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/Xlib.h> #include <list.h> @@ -94,7 +92,7 @@ test_xorg_list_add(void) c = xorg_list_first_entry(&parent.children, struct child, node); assert(memcmp(c, &child[2], sizeof(struct child)) == 0); -}; +} static void test_xorg_list_append(void) @@ -136,7 +134,7 @@ test_xorg_list_append(void) xorg_list_for_each_entry(c, &parent.children, node) { assert(memcmp(c, &child[i++], sizeof(struct child)) == 0); } -}; +} static void test_xorg_list_del(void) diff --git a/test/misc.c b/test/misc.c index ba7a80b51..5dbe8cade 100644 --- a/test/misc.c +++ b/test/misc.c @@ -24,16 +24,17 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> + +#include "dix/input_priv.h" +#include "os/fmt.h" + #include "misc.h" #include "scrnintstr.h" #include "dix.h" #include "dixstruct.h" - #include "tests-common.h" static void @@ -234,6 +235,4 @@ misc_test(void) NULL, }; return testfuncs; - - return 0; } diff --git a/test/scripts/build-travis-osx.sh b/test/scripts/build-travis-osx.sh index d9632490d..e0ec8e2cf 100755 --- a/test/scripts/build-travis-osx.sh +++ b/test/scripts/build-travis-osx.sh @@ -45,6 +45,6 @@ fi popd # build -meson _build/ -Dprefix=/opt/X11 -Dsecure-rpc=false +meson _build/ -Dprefix=/opt/X11 DESTDIR=$(pwd)/staging ninja -C _build/ install ninja -C _build/ test diff --git a/test/signal-logging.c b/test/signal-logging.c index 22966ed4c..db8efa852 100644 --- a/test/signal-logging.c +++ b/test/signal-logging.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include <unistd.h> diff --git a/test/simple-xinit.c b/test/simple-xinit.c index 57e7eed57..39daf54c9 100644 --- a/test/simple-xinit.c +++ b/test/simple-xinit.c @@ -21,9 +21,7 @@ * IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/Xfuncproto.h> diff --git a/test/string.c b/test/string.c index 6fa4882d9..be971e623 100644 --- a/test/string.c +++ b/test/string.c @@ -29,9 +29,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <assert.h> #include "os.h" diff --git a/test/sync/sync.c b/test/sync/sync.c index bd1b0addd..955e283a9 100644 --- a/test/sync/sync.c +++ b/test/sync/sync.c @@ -124,19 +124,19 @@ test_set_counter(xcb_connection_t *c) static void test_change_counter_basic(xcb_connection_t *c) { - int iterations = 4; - xcb_sync_query_counter_cookie_t queries[iterations]; +#define T1_ITERATIONS 4 + xcb_sync_query_counter_cookie_t queries[T1_ITERATIONS]; xcb_sync_counter_t counter = xcb_generate_id(c); xcb_sync_create_counter(c, counter, sync_value(0)); - for (int i = 0; i < iterations; i++) { + for (int i = 0; i < T1_ITERATIONS; i++) { xcb_sync_change_counter(c, counter, sync_value(i)); queries[i] = xcb_sync_query_counter_unchecked(c, counter); } int64_t expected_value = 0; - for (int i = 0; i < iterations; i++) { + for (int i = 0; i < T1_ITERATIONS; i++) { expected_value += i; int64_t value = counter_value(c, queries[i]); @@ -154,9 +154,9 @@ test_change_counter_basic(xcb_connection_t *c) static void test_change_counter_overflow(xcb_connection_t *c) { - int iterations = 4; - xcb_sync_query_counter_cookie_t queries[iterations]; - xcb_void_cookie_t changes[iterations]; +#define T2_ITERATIONS 4 + xcb_sync_query_counter_cookie_t queries[T2_ITERATIONS]; + xcb_void_cookie_t changes[T2_ITERATIONS]; static const struct { int64_t a, b; } overflow_args[] = { @@ -260,9 +260,13 @@ test_change_alarm_delta(xcb_connection_t *c) xcb_sync_create_alarm(c, alarm, 0, NULL); for (int i = 0; i < ARRAY_SIZE(some_values); i++) { - uint32_t values[] = { some_values[i] >> 32, some_values[i] }; + uint32_t mask = XCB_SYNC_CA_TEST_TYPE | XCB_SYNC_CA_DELTA; + uint32_t test_type = (some_values[i] >= 0 ? + XCB_SYNC_TESTTYPE_POSITIVE_COMPARISON : + XCB_SYNC_TESTTYPE_NEGATIVE_COMPARISON); + uint32_t values[] = { test_type, some_values[i] >> 32, some_values[i] }; - xcb_sync_change_alarm(c, alarm, XCB_SYNC_CA_DELTA, values); + xcb_sync_change_alarm(c, alarm, mask, values); queries[i] = xcb_sync_query_alarm_unchecked(c, alarm); } diff --git a/test/test_xkb.c b/test/test_xkb.c index 303bbec53..11a0f4ce8 100644 --- a/test/test_xkb.c +++ b/test/test_xkb.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <xkb-config.h> @@ -46,7 +44,6 @@ #include <xkbsrv.h> #include "../xkb/xkbgeom.h" #include <X11/extensions/XKMformat.h> -#include "xkbfile.h" #include <assert.h> #include "tests-common.h" diff --git a/test/touch.c b/test/touch.c index e4d14f63d..3e9100a9f 100644 --- a/test/touch.c +++ b/test/touch.c @@ -24,15 +24,15 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> + +#include "dix/input_priv.h" + #include "inputstr.h" #include "assert.h" #include "scrnintstr.h" - #include "tests-common.h" static void @@ -62,7 +62,7 @@ touch_grow_queue(void) memset(&dev, 0, sizeof(dev)); dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ - dev.name = xnfstrdup("test device"); + dev.name = XNFstrdup("test device"); dev.id = 2; InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute); @@ -128,7 +128,7 @@ touch_find_ddxid(void) memset(&dev, 0, sizeof(dev)); dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ - dev.name = xnfstrdup("test device"); + dev.name = XNFstrdup("test device"); dev.id = 2; InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute); @@ -202,7 +202,7 @@ touch_begin_ddxtouch(void) memset(&dev, 0, sizeof(dev)); dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ - dev.name = xnfstrdup("test device"); + dev.name = XNFstrdup("test device"); dev.id = 2; inputInfo.devices = &dev; @@ -252,7 +252,7 @@ touch_begin_touch(void) memset(&dev, 0, sizeof(dev)); dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ - dev.name = xnfstrdup("test device"); + dev.name = XNFstrdup("test device"); dev.id = 2; ti = TouchBeginTouch(&dev, sourceid, touchid, TRUE); @@ -289,7 +289,7 @@ touch_init(void) memset(&dev, 0, sizeof(dev)); dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ - dev.name = xnfstrdup("test device"); + dev.name = XNFstrdup("test device"); memset(&sprite, 0, sizeof(sprite)); dev.spriteInfo = &sprite; diff --git a/test/xfree86.c b/test/xfree86.c index 7cbd37f40..d964f0b0b 100644 --- a/test/xfree86.c +++ b/test/xfree86.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <assert.h> diff --git a/test/xi1/protocol-xchangedevicecontrol.c b/test/xi1/protocol-xchangedevicecontrol.c index 4c1a1740a..1ec1d1a26 100644 --- a/test/xi1/protocol-xchangedevicecontrol.c +++ b/test/xi1/protocol-xchangedevicecontrol.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for ChangeDeviceControl request. diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c index aae84180a..821b4b132 100644 --- a/test/xi2/protocol-common.c +++ b/test/xi2/protocol-common.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <errno.h> #include <stdint.h> diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index e1317ca1b..f340838c2 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -23,9 +23,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include <X11/extensions/XI2proto.h> diff --git a/test/xi2/protocol-xigetclientpointer.c b/test/xi2/protocol-xigetclientpointer.c index 6a066b022..f01199e84 100644 --- a/test/xi2/protocol-xigetclientpointer.c +++ b/test/xi2/protocol-xigetclientpointer.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XIGetClientPointer request. diff --git a/test/xi2/protocol-xigetselectedevents.c b/test/xi2/protocol-xigetselectedevents.c index 937b52b2e..b13077955 100644 --- a/test/xi2/protocol-xigetselectedevents.c +++ b/test/xi2/protocol-xigetselectedevents.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XIGetSelectedEvents request. @@ -141,8 +139,18 @@ request_XIGetSelectedEvents(xXIGetSelectedEventsReq * req, int error) wrapped_WriteToClient = reply_XIGetSelectedEvents; client.swapped = TRUE; + + /* MUST NOT swap req->length here ! + + The handler proc's don't use that field anymore, thus also SProc's + wont swap it. But this test program uses that field to initialize + client->req_len (see above). We previously had to swap it here, so + that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + now, still swapping itself would break if this function is called + again and writing back a errornously swapped value + */ + swapl(&req->win); - swaps(&req->length); rc = SProcXIGetSelectedEvents(&client); assert(rc == error); } diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c index bc9866493..18413a853 100644 --- a/test/xi2/protocol-xipassivegrabdevice.c +++ b/test/xi2/protocol-xipassivegrabdevice.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XIPassiveGrab request. @@ -146,7 +144,17 @@ request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req, assert(client_request.errorValue == errval); client_request.swapped = TRUE; - swaps(&req->length); + + /* MUST NOT swap req->length here ! + + The handler proc's don't use that field anymore, thus also SProc's + wont swap it. But this test program uses that field to initialize + client->req_len (see above). We previously had to swap it here, so + that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + now, still swapping itself would break if this function is called + again and writing back a errornously swapped value + */ + swapl(&req->time); swapl(&req->grab_window); swapl(&req->cursor); diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c index f0b03a19a..daa3f6024 100644 --- a/test/xi2/protocol-xiquerydevice.c +++ b/test/xi2/protocol-xiquerydevice.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include <X11/X.h> diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c index 394fc7c00..8a7ae608b 100644 --- a/test/xi2/protocol-xiquerypointer.c +++ b/test/xi2/protocol-xiquerypointer.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XIQueryPointer request. diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c index b8145bc1c..f452333e6 100644 --- a/test/xi2/protocol-xiqueryversion.c +++ b/test/xi2/protocol-xiqueryversion.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XIQueryVersion request and reply. diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c index 9389bd27e..237c8f00b 100644 --- a/test/xi2/protocol-xiselectevents.c +++ b/test/xi2/protocol-xiselectevents.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XISelectEvents request. @@ -109,8 +107,17 @@ request_XISelectEvent(xXISelectEventsReq * req, int error) mask = next; } + /* MUST NOT swap req->length here ! + + The handler proc's don't use that field anymore, thus also SProc's + wont swap it. But this test program uses that field to initialize + client->req_len (see above). We previously had to swap it here, so + that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + now, still swapping itself would break if this function is called + again and writing back a errornously swapped value + */ + swapl(&req->win); - swaps(&req->length); swaps(&req->num_masks); rc = SProcXISelectEvents(&client); assert(rc == error); diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c index 881fcf3f1..674bc9b18 100644 --- a/test/xi2/protocol-xisetclientpointer.c +++ b/test/xi2/protocol-xisetclientpointer.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XISetClientPointer request. @@ -68,8 +66,18 @@ request_XISetClientPointer(xXISetClientPointerReq * req, int error) assert(client_request.errorValue == req->deviceid); client_request.swapped = TRUE; + + /* MUST NOT swap req->length here ! + + The handler proc's don't use that field anymore, thus also SProc's + wont swap it. But this test program uses that field to initialize + client->req_len (see above). We previously had to swap it here, so + that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + now, still swapping itself would break if this function is called + again and writing back a errornously swapped value + */ + swapl(&req->win); - swaps(&req->length); swaps(&req->deviceid); rc = SProcXISetClientPointer(&client_request); assert(rc == error); diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c index 417d9adfc..d225e79ed 100644 --- a/test/xi2/protocol-xiwarppointer.c +++ b/test/xi2/protocol-xiwarppointer.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif /* * Protocol testing for XIWarpPointer request. diff --git a/test/xi2/xi2.c b/test/xi2/xi2.c index 03022ebfa..b49a8fe8d 100644 --- a/test/xi2/xi2.c +++ b/test/xi2/xi2.c @@ -24,9 +24,7 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdint.h> #include "inpututils.h" diff --git a/test/xtest.c b/test/xtest.c index 1dc7078b1..e1057b82c 100644 --- a/test/xtest.c +++ b/test/xtest.c @@ -24,13 +24,13 @@ /* Test relies on assert() */ #undef NDEBUG -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + #include <stdint.h> #include <X11/Xatom.h> #include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "input.h" #include "inputstr.h" @@ -41,7 +41,6 @@ #include "xkbsrv.h" #include "xserver-properties.h" #include "syncsrv.h" - #include "tests-common.h" /** diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 51c7b3010..a2c4159d1 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -42,11 +42,11 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/input_priv.h" #include "xfixesint.h" #include "scrnintstr.h" @@ -301,8 +301,6 @@ SProcXFixesSelectCursorInput(ClientPtr client) { REQUEST(xXFixesSelectCursorInputReq); REQUEST_SIZE_MATCH(xXFixesSelectCursorInputReq); - - swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->eventMask); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); @@ -373,7 +371,7 @@ ProcXFixesGetCursorImage(ClientPtr client) pCursor = CursorForClient(client); if (!pCursor) return BadCursor; - rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, X11_RESTYPE_CURSOR, + rc = XaceHookResourceAccess(client, pCursor->id, X11_RESTYPE_CURSOR, pCursor, X11_RESTYPE_NONE, NULL, DixReadAccess); if (rc != Success) return rc; @@ -381,8 +379,8 @@ ProcXFixesGetCursorImage(ClientPtr client) width = pCursor->bits->width; height = pCursor->bits->height; npixels = width * height; - rep = calloc(sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32), - 1); + rep = calloc(1, + sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32)); if (!rep) return BadAlloc; @@ -421,7 +419,6 @@ int _X_COLD SProcXFixesGetCursorImage(ClientPtr client) { REQUEST(xXFixesGetCursorImageReq); - swaps(&stuff->length); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); } @@ -449,8 +446,6 @@ int _X_COLD SProcXFixesSetCursorName(ClientPtr client) { REQUEST(xXFixesSetCursorNameReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq); swapl(&stuff->cursor); swaps(&stuff->nbytes); @@ -498,8 +493,6 @@ int _X_COLD SProcXFixesGetCursorName(ClientPtr client) { REQUEST(xXFixesGetCursorNameReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq); swapl(&stuff->cursor); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); @@ -522,7 +515,7 @@ ProcXFixesGetCursorImageAndName(ClientPtr client) pCursor = CursorForClient(client); if (!pCursor) return BadCursor; - rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, X11_RESTYPE_CURSOR, + rc = XaceHookResourceAccess(client, pCursor->id, X11_RESTYPE_CURSOR, pCursor, X11_RESTYPE_NONE, NULL, DixReadAccess | DixGetAttrAccess); if (rc != Success) return rc; @@ -533,8 +526,8 @@ ProcXFixesGetCursorImageAndName(ClientPtr client) name = pCursor->name ? NameForAtom(pCursor->name) : ""; nbytes = strlen(name); nbytesRound = pad_to_int32(nbytes); - rep = calloc(sizeof(xXFixesGetCursorImageAndNameReply) + - npixels * sizeof(CARD32) + nbytesRound, 1); + rep = calloc(1, sizeof(xXFixesGetCursorImageAndNameReply) + + npixels * sizeof(CARD32) + nbytesRound); if (!rep) return BadAlloc; @@ -578,7 +571,6 @@ int _X_COLD SProcXFixesGetCursorImageAndName(ClientPtr client) { REQUEST(xXFixesGetCursorImageAndNameReq); - swaps(&stuff->length); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); } @@ -705,8 +697,6 @@ int _X_COLD SProcXFixesChangeCursor(ClientPtr client) { REQUEST(xXFixesChangeCursorReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesChangeCursorReq); swapl(&stuff->source); swapl(&stuff->destination); @@ -744,8 +734,6 @@ int _X_COLD SProcXFixesChangeCursorByName(ClientPtr client) { REQUEST(xXFixesChangeCursorByNameReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXFixesChangeCursorByNameReq); swapl(&stuff->source); swaps(&stuff->nbytes); @@ -880,8 +868,7 @@ ProcXFixesHideCursor(ClientPtr client) * This is the first time this client has hid the cursor * for this screen. */ - ret = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, - DixHideAccess); + ret = XaceHookScreenAccess(client, pWin->drawable.pScreen, DixHideAccess); if (ret != Success) return ret; @@ -904,8 +891,6 @@ int _X_COLD SProcXFixesHideCursor(ClientPtr client) { REQUEST(xXFixesHideCursorReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesHideCursorReq); swapl(&stuff->window); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); @@ -938,8 +923,7 @@ ProcXFixesShowCursor(ClientPtr client) return BadMatch; } - rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, - DixShowAccess); + rc = XaceHookScreenAccess(client, pWin->drawable.pScreen, DixShowAccess); if (rc != Success) return rc; @@ -955,8 +939,6 @@ int _X_COLD SProcXFixesShowCursor(ClientPtr client) { REQUEST(xXFixesShowCursorReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesShowCursorReq); swapl(&stuff->window); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); @@ -1030,7 +1012,6 @@ SProcXFixesCreatePointerBarrier(ClientPtr client) REQUEST_AT_LEAST_SIZE(xXFixesCreatePointerBarrierReq); - swaps(&stuff->length); swaps(&stuff->num_devices); REQUEST_FIXED_SIZE(xXFixesCreatePointerBarrierReq, pad_to_int32(stuff->num_devices * sizeof(CARD16))); @@ -1063,8 +1044,6 @@ int _X_COLD SProcXFixesDestroyPointerBarrier(ClientPtr client) { REQUEST(xXFixesDestroyPointerBarrierReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesDestroyPointerBarrierReq); swapl(&stuff->barrier); return ProcXFixesVector[stuff->xfixesReqType] (client); diff --git a/xfixes/disconnect.c b/xfixes/disconnect.c index e412942b1..5b2945a4a 100644 --- a/xfixes/disconnect.c +++ b/xfixes/disconnect.c @@ -42,14 +42,11 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" #include "xfixesint.h" -#include "opaque.h" static DevPrivateKeyRec ClientDisconnectPrivateKeyRec; @@ -69,6 +66,7 @@ ProcXFixesSetClientDisconnectMode(ClientPtr client) ClientDisconnectPtr pDisconnect = GetClientDisconnect(client); REQUEST(xXFixesSetClientDisconnectModeReq); + REQUEST_SIZE_MATCH(xXFixesSetClientDisconnectModeReq); pDisconnect->disconnect_mode = stuff->disconnect_mode; @@ -79,10 +77,7 @@ int _X_COLD SProcXFixesSetClientDisconnectMode(ClientPtr client) { REQUEST(xXFixesSetClientDisconnectModeReq); - - swaps(&stuff->length); - - REQUEST_AT_LEAST_SIZE(xXFixesSetClientDisconnectModeReq); + REQUEST_SIZE_MATCH(xXFixesSetClientDisconnectModeReq); swapl(&stuff->disconnect_mode); @@ -116,9 +111,6 @@ int _X_COLD SProcXFixesGetClientDisconnectMode(ClientPtr client) { REQUEST(xXFixesGetClientDisconnectModeReq); - - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXFixesGetClientDisconnectModeReq); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); diff --git a/xfixes/region.c b/xfixes/region.c index 4595f8f2d..17c1bd4b7 100644 --- a/xfixes/region.c +++ b/xfixes/region.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" #include "render/picturestr_priv.h" @@ -97,8 +95,6 @@ int _X_COLD SProcXFixesCreateRegion(ClientPtr client) { REQUEST(xXFixesCreateRegionReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq); swapl(&stuff->region); SwapRestS(stuff); @@ -141,8 +137,6 @@ int _X_COLD SProcXFixesCreateRegionFromBitmap(ClientPtr client) { REQUEST(xXFixesCreateRegionFromBitmapReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesCreateRegionFromBitmapReq); swapl(&stuff->region); swapl(&stuff->bitmap); @@ -200,8 +194,6 @@ int _X_COLD SProcXFixesCreateRegionFromWindow(ClientPtr client) { REQUEST(xXFixesCreateRegionFromWindowReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesCreateRegionFromWindowReq); swapl(&stuff->region); swapl(&stuff->window); @@ -243,8 +235,6 @@ int _X_COLD SProcXFixesCreateRegionFromGC(ClientPtr client) { REQUEST(xXFixesCreateRegionFromGCReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesCreateRegionFromGCReq); swapl(&stuff->region); swapl(&stuff->gc); @@ -285,8 +275,6 @@ int _X_COLD SProcXFixesCreateRegionFromPicture(ClientPtr client) { REQUEST(xXFixesCreateRegionFromPictureReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesCreateRegionFromPictureReq); swapl(&stuff->region); swapl(&stuff->picture); @@ -309,8 +297,6 @@ int _X_COLD SProcXFixesDestroyRegion(ClientPtr client) { REQUEST(xXFixesDestroyRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq); swapl(&stuff->region); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); @@ -347,8 +333,6 @@ int _X_COLD SProcXFixesSetRegion(ClientPtr client) { REQUEST(xXFixesSetRegionReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq); swapl(&stuff->region); SwapRestS(stuff); @@ -376,8 +360,6 @@ int _X_COLD SProcXFixesCopyRegion(ClientPtr client) { REQUEST(xXFixesCopyRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesCopyRegionReq); swapl(&stuff->source); swapl(&stuff->destination); @@ -418,8 +400,6 @@ int _X_COLD SProcXFixesCombineRegion(ClientPtr client) { REQUEST(xXFixesCombineRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesCombineRegionReq); swapl(&stuff->source1); swapl(&stuff->source2); @@ -462,8 +442,6 @@ int _X_COLD SProcXFixesInvertRegion(ClientPtr client) { REQUEST(xXFixesInvertRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesInvertRegionReq); swapl(&stuff->source); swaps(&stuff->x); @@ -492,8 +470,6 @@ int _X_COLD SProcXFixesTranslateRegion(ClientPtr client) { REQUEST(xXFixesTranslateRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq); swapl(&stuff->region); swaps(&stuff->dx); @@ -521,8 +497,6 @@ int _X_COLD SProcXFixesRegionExtents(ClientPtr client) { REQUEST(xXFixesRegionExtentsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq); swapl(&stuff->source); swapl(&stuff->destination); @@ -586,8 +560,6 @@ int _X_COLD SProcXFixesFetchRegion(ClientPtr client) { REQUEST(xXFixesFetchRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesFetchRegionReq); swapl(&stuff->region); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); @@ -629,8 +601,6 @@ int _X_COLD SProcXFixesSetGCClipRegion(ClientPtr client) { REQUEST(xXFixesSetGCClipRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq); swapl(&stuff->gc); swapl(&stuff->region); @@ -719,8 +689,6 @@ int _X_COLD SProcXFixesSetWindowShapeRegion(ClientPtr client) { REQUEST(xXFixesSetWindowShapeRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq); swapl(&stuff->dest); swaps(&stuff->xOff); @@ -752,8 +720,6 @@ int _X_COLD SProcXFixesSetPictureClipRegion(ClientPtr client) { REQUEST(xXFixesSetPictureClipRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesSetPictureClipRegionReq); swapl(&stuff->picture); swapl(&stuff->region); @@ -805,8 +771,6 @@ int _X_COLD SProcXFixesExpandRegion(ClientPtr client) { REQUEST(xXFixesExpandRegionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xXFixesExpandRegionReq); swapl(&stuff->source); swapl(&stuff->destination); @@ -817,7 +781,7 @@ SProcXFixesExpandRegion(ClientPtr client) return (*ProcXFixesVector[stuff->xfixesReqType]) (client); } -#ifdef PANORAMIX +#ifdef XINERAMA #include "panoramiX.h" #include "panoramiXsrv.h" @@ -927,4 +891,4 @@ PanoramiXFixesSetPictureClipRegion(ClientPtr client) return result; } -#endif +#endif /* XINERAMA */ diff --git a/xfixes/saveset.c b/xfixes/saveset.c index 981d15b86..145c146df 100644 --- a/xfixes/saveset.c +++ b/xfixes/saveset.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" @@ -66,7 +64,6 @@ SProcXFixesChangeSaveSet(ClientPtr client) REQUEST(xXFixesChangeSaveSetReq); REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq); - swaps(&stuff->length); swapl(&stuff->window); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); } diff --git a/xfixes/select.c b/xfixes/select.c index ebdd77181..665a288aa 100644 --- a/xfixes/select.c +++ b/xfixes/select.c @@ -20,9 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "dix/dix_priv.h" @@ -43,7 +41,7 @@ typedef struct _SelectionEvent *SelectionEventPtr; typedef struct _SelectionEvent { SelectionEventPtr next; - Atom selection; + Selection *selection; CARD32 eventMask; ClientPtr pClient; WindowPtr pWindow; @@ -79,14 +77,14 @@ XFixesSelectionCallback(CallbackListPtr *callbacks, void *data, void *args) } UpdateCurrentTimeIf(); for (e = selectionEvents; e; e = e->next) { - if (e->selection == selection->selection && (e->eventMask & eventMask)) { + if (e->selection == selection && (e->eventMask & eventMask)) { xXFixesSelectionNotifyEvent ev = { .type = XFixesEventBase + XFixesSelectionNotify, .subtype = subtype, .window = e->pWindow->drawable.id, .owner = (subtype == XFixesSetSelectionOwnerNotify) ? selection->window : 0, - .selection = e->selection, + .selection = e->selection->selection, .timestamp = currentTime.milliseconds, .selectionTimestamp = selection->lastTimeChanged.milliseconds }; @@ -120,13 +118,14 @@ CheckSelectionCallback(void) static int XFixesSelectSelectionInput(ClientPtr pClient, - Atom selection, WindowPtr pWindow, CARD32 eventMask) + Atom selection_name, WindowPtr pWindow, CARD32 eventMask) { void *val; int rc; SelectionEventPtr *prev, e; + Selection *selection; - rc = XaceHook(XACE_SELECTION_ACCESS, pClient, selection, DixGetAttrAccess); + rc = dixLookupSelection(&selection, selection_name, pClient, DixGetAttrAccess); if (rc != Success) return rc; @@ -203,9 +202,7 @@ int _X_COLD SProcXFixesSelectSelectionInput(ClientPtr client) { REQUEST(xXFixesSelectSelectionInputReq); - REQUEST_SIZE_MATCH(xXFixesSelectSelectionInputReq); - swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->selection); swapl(&stuff->eventMask); diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c index 69b8241a4..6634b8179 100644 --- a/xfixes/xfixes.c +++ b/xfixes/xfixes.c @@ -42,9 +42,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif + +#include "os/fmt.h" #include "xfixesint.h" #include "protocol-versions.h" @@ -166,7 +166,6 @@ SProcXFixesQueryVersion(ClientPtr client) REQUEST(xXFixesQueryVersionReq); REQUEST_SIZE_MATCH(xXFixesQueryVersionReq); - swaps(&stuff->length); swapl(&stuff->majorVersion); swapl(&stuff->minorVersion); return (*ProcXFixesVector[stuff->xfixesReqType]) (client); @@ -254,7 +253,7 @@ XFixesExtensionInit(void) } } -#ifdef PANORAMIX +#ifdef XINERAMA int (*PanoramiXSaveXFixesVector[XFixesNumberRequests]) (ClientPtr); @@ -284,4 +283,4 @@ PanoramiXFixesReset(void) ProcXFixesVector[i] = PanoramiXSaveXFixesVector[i]; } -#endif +#endif /* XINERAMA */ diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h index a1dd6fe63..5d64e94d1 100644 --- a/xfixes/xfixesint.h +++ b/xfixes/xfixesint.h @@ -310,10 +310,10 @@ Bool XFixesShouldDisconnectClient(ClientPtr client); /* Xinerama */ -#ifdef PANORAMIX +#ifdef XINERAMA extern int (*PanoramiXSaveXFixesVector[XFixesNumberRequests]) (ClientPtr); void PanoramiXFixesInit(void); void PanoramiXFixesReset(void); -#endif +#endif /* XINERAMA */ #endif /* _XFIXESINT_H_ */ diff --git a/xkb/XKBAlloc.c b/xkb/XKBAlloc.c index 18557b804..c8bf82d2f 100644 --- a/xkb/XKBAlloc.c +++ b/xkb/XKBAlloc.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> @@ -194,8 +192,10 @@ XkbAllocNames(XkbDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases) free(prev_radio_groups); } } - if (names->radio_groups == NULL) + if (names->radio_groups == NULL) { + names->num_rg = 0; return BadAlloc; + } names->num_rg = nTotalRG; } return Success; diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c index f0cda24fe..d0cc51e99 100644 --- a/xkb/XKBGAlloc.c +++ b/xkb/XKBGAlloc.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c index fa4c86d44..fa8f5527e 100644 --- a/xkb/XKBMAlloc.c +++ b/xkb/XKBMAlloc.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> @@ -41,7 +39,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. Status XkbAllocClientMap(XkbDescPtr xkb, unsigned which, unsigned nTotalTypes) { - register int i; XkbClientMapPtr map; if ((xkb == NULL) || @@ -103,8 +100,7 @@ XkbAllocClientMap(XkbDescPtr xkb, unsigned which, unsigned nTotalTypes) map->syms[0] = NoSymbol; } if (map->key_sym_map == NULL) { - i = xkb->max_key_code + 1; - map->key_sym_map = calloc(i, sizeof(XkbSymMapRec)); + map->key_sym_map = calloc(MAP_LENGTH, sizeof(XkbSymMapRec)); if (map->key_sym_map == NULL) return BadAlloc; } @@ -115,8 +111,7 @@ XkbAllocClientMap(XkbDescPtr xkb, unsigned which, unsigned nTotalTypes) (xkb->max_key_code < xkb->min_key_code)) return BadMatch; if (map->modmap == NULL) { - i = xkb->max_key_code + 1; - map->modmap = calloc(i, sizeof(unsigned char)); + map->modmap = calloc(MAP_LENGTH, sizeof(unsigned char)); if (map->modmap == NULL) return BadAlloc; } @@ -149,8 +144,7 @@ XkbAllocServerMap(XkbDescPtr xkb, unsigned which, unsigned nNewActions) (xkb->max_key_code < xkb->min_key_code)) return BadMatch; if (map->explicit == NULL) { - i = xkb->max_key_code + 1; - map->explicit = calloc(i, sizeof(unsigned char)); + map->explicit = calloc(MAP_LENGTH, sizeof(unsigned char)); if (map->explicit == NULL) return BadAlloc; } @@ -185,8 +179,7 @@ XkbAllocServerMap(XkbDescPtr xkb, unsigned which, unsigned nNewActions) ((map->size_acts - map->num_acts) * sizeof(XkbAction))); } if (map->key_acts == NULL) { - i = xkb->max_key_code + 1; - map->key_acts = calloc(i, sizeof(unsigned short)); + map->key_acts = calloc(MAP_LENGTH, sizeof(unsigned short)); if (map->key_acts == NULL) return BadAlloc; } @@ -197,8 +190,7 @@ XkbAllocServerMap(XkbDescPtr xkb, unsigned which, unsigned nNewActions) (xkb->max_key_code < xkb->min_key_code)) return BadMatch; if (map->behaviors == NULL) { - i = xkb->max_key_code + 1; - map->behaviors = calloc(i, sizeof(XkbBehavior)); + map->behaviors = calloc(MAP_LENGTH, sizeof(XkbBehavior)); if (map->behaviors == NULL) return BadAlloc; } @@ -209,8 +201,7 @@ XkbAllocServerMap(XkbDescPtr xkb, unsigned which, unsigned nNewActions) (xkb->max_key_code < xkb->min_key_code)) return BadMatch; if (map->vmodmap == NULL) { - i = xkb->max_key_code + 1; - map->vmodmap = calloc(i, sizeof(unsigned short)); + map->vmodmap = calloc(MAP_LENGTH, sizeof(unsigned short)); if (map->vmodmap == NULL) return BadAlloc; } @@ -651,18 +642,9 @@ XkbChangeKeycodeRange(XkbDescPtr xkb, if (maxKC > xkb->max_key_code) { if (changes) changes->map.max_key_code = maxKC; - tmp = maxKC - xkb->max_key_code; + tmp = MAP_LENGTH - xkb->max_key_code; if (xkb->map) { if (xkb->map->key_sym_map) { - XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map; - - xkb->map->key_sym_map = reallocarray(xkb->map->key_sym_map, - maxKC + 1, - sizeof(XkbSymMapRec)); - if (!xkb->map->key_sym_map) { - free(prev_key_sym_map); - return BadAlloc; - } memset((char *) &xkb->map->key_sym_map[xkb->max_key_code], 0, tmp * sizeof(XkbSymMapRec)); if (changes) { @@ -675,15 +657,6 @@ XkbChangeKeycodeRange(XkbDescPtr xkb, } } if (xkb->map->modmap) { - unsigned char *prev_modmap = xkb->map->modmap; - - xkb->map->modmap = reallocarray(xkb->map->modmap, - maxKC + 1, - sizeof(unsigned char)); - if (!xkb->map->modmap) { - free(prev_modmap); - return BadAlloc; - } memset((char *) &xkb->map->modmap[xkb->max_key_code], 0, tmp); if (changes) { changes->map.changed = _ExtendRange(changes->map.changed, @@ -698,15 +671,6 @@ XkbChangeKeycodeRange(XkbDescPtr xkb, } if (xkb->server) { if (xkb->server->behaviors) { - XkbBehavior *prev_behaviors = xkb->server->behaviors; - - xkb->server->behaviors = reallocarray(xkb->server->behaviors, - maxKC + 1, - sizeof(XkbBehavior)); - if (!xkb->server->behaviors) { - free(prev_behaviors); - return BadAlloc; - } memset((char *) &xkb->server->behaviors[xkb->max_key_code], 0, tmp * sizeof(XkbBehavior)); if (changes) { @@ -720,15 +684,6 @@ XkbChangeKeycodeRange(XkbDescPtr xkb, } } if (xkb->server->key_acts) { - unsigned short *prev_key_acts = xkb->server->key_acts; - - xkb->server->key_acts = reallocarray(xkb->server->key_acts, - maxKC + 1, - sizeof(unsigned short)); - if (!xkb->server->key_acts) { - free(prev_key_acts); - return BadAlloc; - } memset((char *) &xkb->server->key_acts[xkb->max_key_code], 0, tmp * sizeof(unsigned short)); if (changes) { @@ -742,15 +697,6 @@ XkbChangeKeycodeRange(XkbDescPtr xkb, } } if (xkb->server->vmodmap) { - unsigned short *prev_vmodmap = xkb->server->vmodmap; - - xkb->server->vmodmap = reallocarray(xkb->server->vmodmap, - maxKC + 1, - sizeof(unsigned short)); - if (!xkb->server->vmodmap) { - free(prev_vmodmap); - return BadAlloc; - } memset((char *) &xkb->server->vmodmap[xkb->max_key_code], 0, tmp * sizeof(unsigned short)); if (changes) { @@ -765,14 +711,6 @@ XkbChangeKeycodeRange(XkbDescPtr xkb, } } if ((xkb->names) && (xkb->names->keys)) { - XkbKeyNameRec *prev_keys = xkb->names->keys; - - xkb->names->keys = reallocarray(xkb->names->keys, - maxKC + 1, sizeof(XkbKeyNameRec)); - if (!xkb->names->keys) { - free(prev_keys); - return BadAlloc; - } memset((char *) &xkb->names->keys[xkb->max_key_code], 0, tmp * sizeof(XkbKeyNameRec)); if (changes) { @@ -793,7 +731,7 @@ XkbResizeKeyActions(XkbDescPtr xkb, int key, int needed) register int i, nActs; XkbAction *newActs; - if (needed == 0) { + if (needed <= 0) { xkb->server->key_acts[key] = 0; return NULL; } diff --git a/xkb/XKBMisc.c b/xkb/XKBMisc.c index 0a3b5cbc7..fd180fad2 100644 --- a/xkb/XKBMisc.c +++ b/xkb/XKBMisc.c @@ -24,16 +24,17 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> #include <X11/Xproto.h> +#include <X11/keysym.h> + +#include "xkb/xkbfmisc_priv.h" + #include "misc.h" #include "inputstr.h" -#include <X11/keysym.h> #include <xkbsrv.h> /***====================================================================***/ @@ -552,6 +553,7 @@ XkbChangeTypesOfKey(XkbDescPtr xkb, i = XkbSetNumGroups(i, 0); xkb->map->key_sym_map[key].group_info = i; XkbResizeKeySyms(xkb, key, 0); + XkbResizeKeyActions(xkb, key, 0); return Success; } diff --git a/xkb/ddxBeep.c b/xkb/ddxBeep.c index 52353ea81..86b6e7c99 100644 --- a/xkb/ddxBeep.c +++ b/xkb/ddxBeep.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/xkb/ddxCtrls.c b/xkb/ddxCtrls.c index 964ac3d51..e542a37f1 100644 --- a/xkb/ddxCtrls.c +++ b/xkb/ddxCtrls.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/xkb/ddxKillSrv.c b/xkb/ddxKillSrv.c index 7c7e73970..e4531388c 100644 --- a/xkb/ddxKillSrv.c +++ b/xkb/ddxKillSrv.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/xkb/ddxLEDs.c b/xkb/ddxLEDs.c index e5aecb523..e6520ea76 100644 --- a/xkb/ddxLEDs.c +++ b/xkb/ddxLEDs.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 18e0ec3be..a231e96bf 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <xkb-config.h> @@ -40,7 +38,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/extensions/XI.h> #include <X11/extensions/XKM.h> +#include "dix/dix_priv.h" #include "os/osdep.h" +#include "xkb/xkbfile_priv.h" +#include "xkb/xkbfmisc_priv.h" +#include "xkb/xkbrules_priv.h" #include "inputstr.h" #include "scrnintstr.h" @@ -183,7 +185,7 @@ RunXkbComp(xkbcomp_buffer_callback callback, void *userdata) #ifndef WIN32 if (Pclose(out) == 0) #else - if (fclose(out) == 0 && System(buf) >= 0) + if (fclose(out) == 0 && system(buf) >= 0) #endif { if (xkbDebugFlags) @@ -192,7 +194,7 @@ RunXkbComp(xkbcomp_buffer_callback callback, void *userdata) #ifdef WIN32 unlink(tmpname); #endif - return xnfstrdup(keymap); + return XNFstrdup(keymap); } else { LogMessage(X_ERROR, "Error compiling keymap (%s) executing '%s'\n", @@ -434,14 +436,14 @@ XkbDDXNamesFromRules(DeviceIntPtr keybd, if (!XkbRF_LoadRules(file, rules)) { LogMessage(X_ERROR, "XKB: Couldn't parse rules file %s\n", rules_name); fclose(file); - XkbRF_Free(rules, TRUE); + XkbRF_Free(rules); return FALSE; } memset(names, 0, sizeof(*names)); complete = XkbRF_GetComponents(rules, defs, names); fclose(file); - XkbRF_Free(rules, TRUE); + XkbRF_Free(rules); if (!complete) LogMessage(X_ERROR, "XKB: Rules returned no components\n"); diff --git a/xkb/ddxPrivate.c b/xkb/ddxPrivate.c index fcde3a18c..26faaa563 100644 --- a/xkb/ddxPrivate.c +++ b/xkb/ddxPrivate.c @@ -1,7 +1,5 @@ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <X11/X.h> #include "windowstr.h" diff --git a/xkb/ddxVT.c b/xkb/ddxVT.c index f3cd26a97..91b690071 100644 --- a/xkb/ddxVT.c +++ b/xkb/ddxVT.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/xkb/maprules.c b/xkb/maprules.c index e071ab539..8a1944ef5 100644 --- a/xkb/maprules.c +++ b/xkb/maprules.c @@ -24,9 +24,7 @@ ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <ctype.h> @@ -42,6 +40,9 @@ #include <X11/Xfuncs.h> #include <X11/Xatom.h> #include <X11/keysym.h> + +#include "xkb/xkbrules_priv.h" + #include "misc.h" #include "inputstr.h" #include "dix.h" @@ -49,7 +50,11 @@ #include "xkbstr.h" #include <xkbsrv.h> -/***====================================================================***/ + +#define XkbRF_PendingMatch (1L<<1) +#define XkbRF_Option (1L<<2) +#define XkbRF_Append (1L<<3) +#define XkbRF_Normal (1L<<4) #define DFLT_LINE_SIZE 128 @@ -257,7 +262,6 @@ SetUpRemap(InputLine * line, RemapSpec * remap) { char *tok, *str; unsigned present, l_ndx_present, v_ndx_present; - register int i; int len, ndx; _Xstrtokparams strtok_buf; Bool found; @@ -272,7 +276,7 @@ SetUpRemap(InputLine * line, RemapSpec * remap) str = NULL; if (strcmp(tok, "=") == 0) continue; - for (i = 0; i < MAX_WORDS; i++) { + for (int i = 0; i < MAX_WORDS; i++) { len = strlen(cname[i]); if (strncmp(cname[i], tok, len) == 0) { if (strlen(tok) > len) { @@ -318,7 +322,7 @@ SetUpRemap(InputLine * line, RemapSpec * remap) unsigned mask = PART_MASK; ErrorF("Mapping needs at least one of "); - for (i = 0; (i < MAX_WORDS); i++) { + for (int i = 0; (i < MAX_WORDS); i++) { if ((1L << i) & mask) { mask &= ~(1L << i); if (mask) @@ -371,8 +375,7 @@ CheckLine(InputLine * line, RemapSpec * remap, XkbRF_RulePtr rule, XkbRF_GroupPtr group) { char *str, *tok; - register int nread, i; - FileSpec tmp; + register int nread; _Xstrtokparams strtok_buf; Bool append = FALSE; @@ -393,6 +396,8 @@ CheckLine(InputLine * line, return FALSE; group->name = Xstrdup(gname); group->words = Xstrdup(words); + + int i; for (i = 1, words = group->words; *words; words++) { if (*words == ' ') { *words++ = '\0'; @@ -413,7 +418,9 @@ CheckLine(InputLine * line, DebugF("Illegal line of data ignored\n"); return FALSE; } - memset((char *) &tmp, 0, sizeof(FileSpec)); + + FileSpec tmp = { 0 }; + str = line->line; for (nread = 0; (tok = _XStrtok(str, " ", strtok_buf)) != NULL; nread++) { str = NULL; @@ -456,7 +463,7 @@ CheckLine(InputLine * line, rule->geometry = Xstrdup(tmp.name[GEOMETRY]); rule->layout_num = rule->variant_num = 0; - for (i = 0; i < nread; i++) { + for (int i = 0; i < nread; i++) { if (remap->remap[i].index) { if (remap->remap[i].word == LAYOUT) rule->layout_num = remap->remap[i].index; @@ -484,9 +491,7 @@ _Concat(char *str1, const char *str2) static void squeeze_spaces(char *p1) { - char *p2; - - for (p2 = p1; *p2; p2++) { + for (char *p2 = p1; *p2; p2++) { *p1 = *p2; if (*p1 != ' ') p1++; @@ -512,7 +517,6 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) else { char *p; char *layout; - int i; layout = Xstrdup(defs->layout); if (layout == NULL) @@ -520,7 +524,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) squeeze_spaces(layout); mdefs->layout[1] = layout; p = layout; - for (i = 2; i <= XkbNumKbdGroups; i++) { + for (int i = 2; i <= XkbNumKbdGroups; i++) { if ((p = strchr(p, ','))) { *p++ = '\0'; mdefs->layout[i] = p; @@ -541,7 +545,6 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) else { char *p; char *variant; - int i; variant = Xstrdup(defs->variant); if (variant == NULL) @@ -549,7 +552,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) squeeze_spaces(variant); mdefs->variant[1] = variant; p = variant; - for (i = 2; i <= XkbNumKbdGroups; i++) { + for (int i = 2; i <= XkbNumKbdGroups; i++) { if ((p = strchr(p, ','))) { *p++ = '\0'; mdefs->variant[i] = p; @@ -965,84 +968,41 @@ XkbRF_LoadRules(FILE * file, XkbRF_RulesPtr rules) return TRUE; } -Bool -XkbRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules) -{ - FILE *file; - char buf[PATH_MAX]; - Bool ok; - - if ((!base) || (!rules)) - return FALSE; - if (locale) { - if (snprintf(buf, PATH_MAX, "%s-%s", base, locale) >= PATH_MAX) - return FALSE; - } - else { - if (strlen(base) + 1 > PATH_MAX) - return FALSE; - strcpy(buf, base); - } - - file = fopen(buf, "r"); - if ((!file) && (locale)) { /* fallback if locale was specified */ - strcpy(buf, base); - file = fopen(buf, "r"); - } - if (!file) - return FALSE; - ok = XkbRF_LoadRules(file, rules); - fclose(file); - return ok; -} - -/***====================================================================***/ - -XkbRF_RulesPtr -XkbRF_Create(void) -{ - return calloc(1, sizeof(XkbRF_RulesRec)); -} - -/***====================================================================***/ - void -XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules) +XkbRF_Free(XkbRF_RulesPtr rules) { - int i; - XkbRF_RulePtr rule; - XkbRF_GroupPtr group; - if (!rules) return; + if (rules->rules) { - for (i = 0, rule = rules->rules; i < rules->num_rules; i++, rule++) { - free((void *) rule->model); - free((void *) rule->layout); - free((void *) rule->variant); - free((void *) rule->option); - free((void *) rule->keycodes); - free((void *) rule->symbols); - free((void *) rule->types); - free((void *) rule->compat); - free((void *) rule->geometry); - memset((char *) rule, 0, sizeof(XkbRF_RuleRec)); + XkbRF_RulePtr r = rules->rules; + int num = rules->num_rules; + for (int i = 0; i < num; i++) { + // the typecast on free() is necessary because the pointers are const + free((void *) r[i].model); + free((void *) r[i].layout); + free((void *) r[i].variant); + free((void *) r[i].option); + free((void *) r[i].keycodes); + free((void *) r[i].symbols); + free((void *) r[i].types); + free((void *) r[i].compat); + free((void *) r[i].geometry); } free(rules->rules); - rules->num_rules = rules->sz_rules = 0; - rules->rules = NULL; } if (rules->groups) { - for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) { - free((void *) group->name); - free(group->words); + XkbRF_GroupPtr g = rules->groups; + int num = rules->num_groups; + for (int i = 0; i < num; i++) { + // the typecast on free() is necessary because the pointers are const + free((void *) g[i].name); + free(g[i].words); } free(rules->groups); - rules->num_groups = 0; - rules->groups = NULL; } - if (freeRules) - free(rules); + + free(rules); return; } @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> @@ -35,6 +33,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/extensions/XKMformat.h> #include "dix/dix_priv.h" +#include "os/osdep.h" +#include "xkb/xkbfmisc_priv.h" #include "misc.h" #include "inputstr.h" @@ -256,7 +256,7 @@ ProcXkbSelectEvents(ClientPtr client) register unsigned bit, ndx, maskLeft, dataLeft, size; from.c8 = (CARD8 *) &stuff[1]; - dataLeft = (stuff->length * 4) - SIZEOF(xkbSelectEventsReq); + dataLeft = (client->req_len * 4) - sizeof(xkbSelectEventsReq); maskLeft = (stuff->affectWhich & (~XkbMapNotifyMask)); for (ndx = 0, bit = 1; (maskLeft != 0); ndx++, bit <<= 1) { if ((bit & maskLeft) == 0) @@ -562,7 +562,7 @@ ProcXkbBell(ClientPtr client) for (other = inputInfo.devices; other; other = other->next) { if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixBellAccess); + rc = XaceHookDeviceAccess(client, other, DixBellAccess); if (rc == Success) _XkbBell(client, other, pWin, stuff->bellClass, stuff->bellID, stuff->pitch, stuff->duration, @@ -1095,10 +1095,10 @@ XkbSizeKeySyms(XkbDescPtr xkb, xkbGetMapReply * rep) len = rep->nKeySyms * SIZEOF(xkbSymMapWireDesc); symMap = &xkb->map->key_sym_map[rep->firstKeySym]; for (i = nSyms = 0; i < rep->nKeySyms; i++, symMap++) { - if (symMap->offset != 0) { - nSymsThisKey = XkbNumGroups(symMap->group_info) * symMap->width; - nSyms += nSymsThisKey; - } + nSymsThisKey = XkbNumGroups(symMap->group_info) * symMap->width; + if (nSymsThisKey == 0) + continue; + nSyms += nSymsThisKey; } len += nSyms * 4; rep->totalSyms = nSyms; @@ -2749,8 +2749,7 @@ ProcXkbSetMap(ClientPtr client) for (other = inputInfo.devices; other; other = other->next) { if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) { rc = _XkbSetMapChecks(client, other, stuff, tmp, FALSE); if (rc != Success) @@ -2783,8 +2782,7 @@ ProcXkbSetMap(ClientPtr client) for (other = inputInfo.devices; other; other = other->next) { if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) _XkbSetMap(client, other, stuff, tmp); /* ignore rc. if the SetMap failed although the check above @@ -2993,13 +2991,13 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev, XkbSymInterpretPtr sym; unsigned int skipped = 0; - if ((unsigned) (req->firstSI + req->nSI) > compat->num_si) { - compat->num_si = req->firstSI + req->nSI; + if ((unsigned) (req->firstSI + req->nSI) > compat->size_si) { + compat->num_si = compat->size_si = req->firstSI + req->nSI; compat->sym_interpret = reallocarray(compat->sym_interpret, - compat->num_si, + compat->size_si, sizeof(XkbSymInterpretRec)); if (!compat->sym_interpret) { - compat->num_si = 0; + compat->num_si = compat->size_si = 0; return BadAlloc; } } @@ -3123,8 +3121,7 @@ ProcXkbSetCompatMap(ClientPtr client) for (other = inputInfo.devices; other; other = other->next) { if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) { /* dry-run */ rc = _XkbSetCompatMap(client, other, stuff, data, TRUE); @@ -3145,8 +3142,7 @@ ProcXkbSetCompatMap(ClientPtr client) for (other = inputInfo.devices; other; other = other->next) { if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) { rc = _XkbSetCompatMap(client, other, stuff, data, FALSE); if (rc != Success) @@ -3377,7 +3373,7 @@ ProcXkbSetIndicatorMap(ClientPtr client) if (stuff->which & bit) nIndicators++; } - if (stuff->length != ((SIZEOF(xkbSetIndicatorMapReq) + + if (client->req_len != ((sizeof(xkbSetIndicatorMapReq) + (nIndicators * SIZEOF(xkbIndicatorMapWireDesc))) / 4)) { return BadLength; @@ -3407,8 +3403,7 @@ ProcXkbSetIndicatorMap(ClientPtr client) for (other = inputInfo.devices; other; other = other->next) { if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixSetAttrAccess); + rc = XaceHookDeviceAccess(client, other, DixSetAttrAccess); if (rc == Success) _XkbSetIndicatorMap(client, other, stuff->which, from); } @@ -3576,7 +3571,6 @@ static int _XkbSetNamedIndicator(ClientPtr client, DeviceIntPtr dev, xkbSetNamedIndicatorReq * stuff) { - unsigned int extDevReason; unsigned int statec, namec, mapc; XkbSrvLedInfoPtr sli; int led = 0; @@ -3598,11 +3592,9 @@ _XkbSetNamedIndicator(ClientPtr client, DeviceIntPtr dev, return BadAlloc; namec = mapc = statec = 0; - extDevReason = 0; namec |= (1 << led); sli->namesPresent |= ((stuff->indicator != None) ? (1 << led) : 0); - extDevReason |= XkbXI_IndicatorNamesMask; if (stuff->setMap) { map->flags = stuff->flags; @@ -3676,7 +3668,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) if ((other != dev) && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev && (other->kbdfeed || other->leds) && - (XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess) + (XaceHookDeviceAccess(client, other, DixSetAttrAccess) == Success)) { rc = _XkbCreateIndicatorMap(other, stuff->indicator, stuff->ledClass, stuff->ledID, &map, @@ -3700,7 +3692,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) if ((other != dev) && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev && (other->kbdfeed || other->leds) && - (XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess) + (XaceHookDeviceAccess(client, other, DixSetAttrAccess) == Success)) { _XkbSetNamedIndicator(client, other, stuff); } @@ -4285,8 +4277,8 @@ _XkbSetNamesCheck(ClientPtr client, DeviceIntPtr dev, return BadAtom; } } - if ((tmp - ((CARD32 *) stuff)) != stuff->length) { - client->errorValue = stuff->length; + if ((tmp - ((CARD32 *) stuff)) != client->req_len) { + client->errorValue = client->req_len; return BadLength; } @@ -4539,8 +4531,7 @@ ProcXkbSetNames(ClientPtr client) if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) { rc = _XkbSetNamesCheck(client, other, stuff, tmp); if (rc != Success) @@ -4563,8 +4554,7 @@ ProcXkbSetNames(ClientPtr client) if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) _XkbSetNames(client, other, stuff); } @@ -5040,7 +5030,7 @@ XkbComputeGetGeometryReplySize(XkbGeometryPtr geom, } static int XkbSendGeometry(ClientPtr client, - XkbGeometryPtr geom, xkbGetGeometryReply * rep, Bool freeGeom) + XkbGeometryPtr geom, xkbGetGeometryReply *rep) { char *desc, *start; int len; @@ -5092,8 +5082,6 @@ XkbSendGeometry(ClientPtr client, WriteToClient(client, len, start); if (start != NULL) free((char *) start); - if (freeGeom) - XkbFreeGeometry(geom, XkbGeomAllMask, TRUE); return Success; } @@ -5124,9 +5112,15 @@ ProcXkbGetGeometry(ClientPtr client) }; status = XkbComputeGetGeometryReplySize(geom, &rep, stuff->name); if (status != Success) - return status; - else - return XkbSendGeometry(client, geom, &rep, shouldFree); + goto free_out; + + status = XkbSendGeometry(client, geom, &rep); + +free_out: + if (shouldFree) + XkbFreeGeometry(geom, XkbGeomAllMask, TRUE); + + return status; } /***====================================================================***/ @@ -5692,8 +5686,7 @@ ProcXkbSetGeometry(ClientPtr client) for (other = inputInfo.devices; other; other = other->next) { if ((other != dev) && other->key && !IsMaster(other) && GetMaster(other, MASTER_KEYBOARD) == dev) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) _XkbSetGeometry(client, other, stuff); } @@ -5880,11 +5873,11 @@ ProcXkbListComponents(ClientPtr client) return BadLength; size = *((uint8_t *)str); len = (str + size + 1) - ((unsigned char *) stuff); - if ((XkbPaddedSize(len) / 4) > stuff->length) + if ((XkbPaddedSize(len) / 4) > client->req_len) return BadLength; str += (size + 1); } - if ((XkbPaddedSize(len) / 4) != stuff->length) + if ((XkbPaddedSize(len) / 4) != client->req_len) return BadLength; rep = (xkbListComponentsReply) { .type = X_Reply, @@ -5914,6 +5907,45 @@ ProcXkbListComponents(ClientPtr client) return Success; } +static unsigned +XkbConvertGetByNameComponents(Bool toXkm, unsigned orig) +{ + unsigned rtrn; + + rtrn = 0; + if (toXkm) { + if (orig & XkbGBN_TypesMask) + rtrn |= XkmTypesMask; + if (orig & XkbGBN_CompatMapMask) + rtrn |= XkmCompatMapMask; + if (orig & XkbGBN_SymbolsMask) + rtrn |= XkmSymbolsMask; + if (orig & XkbGBN_IndicatorMapMask) + rtrn |= XkmIndicatorsMask; + if (orig & XkbGBN_KeyNamesMask) + rtrn |= XkmKeyNamesMask; + if (orig & XkbGBN_GeometryMask) + rtrn |= XkmGeometryMask; + } + else { + if (orig & XkmTypesMask) + rtrn |= XkbGBN_TypesMask; + if (orig & XkmCompatMapMask) + rtrn |= XkbGBN_CompatMapMask; + if (orig & XkmSymbolsMask) + rtrn |= XkbGBN_SymbolsMask; + if (orig & XkmIndicatorsMask) + rtrn |= XkbGBN_IndicatorMapMask; + if (orig & XkmKeyNamesMask) + rtrn |= XkbGBN_KeyNamesMask; + if (orig & XkmGeometryMask) + rtrn |= XkbGBN_GeometryMask; + if (orig != 0) + rtrn |= XkbGBN_OtherNamesMask; + } + return rtrn; +} + /***====================================================================***/ int ProcXkbGetKbdByName(ClientPtr client) @@ -5966,7 +5998,7 @@ ProcXkbGetKbdByName(ClientPtr client) names.geometry = GetComponentSpec(client, stuff, &str, TRUE, &status); if (status == Success) { len = str - ((unsigned char *) stuff); - if ((XkbPaddedSize(len) / 4) != stuff->length) + if ((XkbPaddedSize(len) / 4) != client->req_len) status = BadLength; } @@ -6201,7 +6233,7 @@ ProcXkbGetKbdByName(ClientPtr client) if (reported & (XkbGBN_KeyNamesMask | XkbGBN_OtherNamesMask)) XkbSendNames(client, new, &nrep); if (reported & XkbGBN_GeometryMask) - XkbSendGeometry(client, new->geom, &grep, FALSE); + XkbSendGeometry(client, new->geom, &grep); if (rep.loaded) { XkbDescPtr old_xkb; xkbNewKeyboardNotify nkn; @@ -6827,7 +6859,7 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev, if (status != Success) return status; } - if (((wire - ((char *) stuff)) / 4) != stuff->length) + if (((wire - ((char *) stuff)) / 4) != client->req_len) return BadLength; return Success; @@ -6918,8 +6950,7 @@ ProcXkbSetDeviceInfo(ClientPtr client) GetMaster(other, MASTER_KEYBOARD) == dev) && ((stuff->deviceSpec == XkbUseCoreKbd && other->key) || (stuff->deviceSpec == XkbUseCorePtr && other->button))) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) { rc = _XkbSetDeviceInfoCheck(client, other, stuff); if (rc != Success) @@ -6943,8 +6974,7 @@ ProcXkbSetDeviceInfo(ClientPtr client) GetMaster(other, MASTER_KEYBOARD) == dev) && ((stuff->deviceSpec == XkbUseCoreKbd && other->key) || (stuff->deviceSpec == XkbUseCorePtr && other->button))) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, other, - DixManageAccess); + rc = XaceHookDeviceAccess(client, other, DixManageAccess); if (rc == Success) { rc = _XkbSetDeviceInfo(client, other, stuff); if (rc != Success) @@ -6969,7 +6999,7 @@ ProcXkbSetDebuggingFlags(ClientPtr client) REQUEST(xkbSetDebuggingFlagsReq); REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq); - rc = XaceHook(XACE_SERVER_ACCESS, client, DixDebugAccess); + rc = XaceHookServerAccess(client, DixDebugAccess); if (rc != Success) return rc; @@ -6984,7 +7014,7 @@ ProcXkbSetDebuggingFlags(ClientPtr client) ErrorF("[xkb] XkbDebug: Setting debug controls to 0x%lx\n", (long) newCtrls); } - extraLength = (stuff->length << 2) - sz_xkbSetDebuggingFlagsReq; + extraLength = (client->req_len << 2) - sz_xkbSetDebuggingFlagsReq; if (stuff->msgLength > 0) { char *msg; diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index fffcf31f5..32892ac20 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #if !defined(WIN32) #include <sys/time.h> @@ -38,6 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/keysym.h> #include <X11/extensions/XIproto.h> +#include "dix/input_priv.h" #include "xkb/xkbsrv_priv.h" #include "exglobals.h" diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 99bb6574e..aad475e6f 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -24,28 +24,30 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <ctype.h> #include <stdio.h> #include <math.h> +#include <ctype.h> #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> +#include "dix/cursor_priv.h" #include "dix/dix_priv.h" +#include "dix/dixgrabs_priv.h" +#include "dix/input_priv.h" +#include "mi/mi_priv.h" +#include "mi/mipointer_priv.h" #include "xkb/xkbsrv_priv.h" #include "misc.h" #include "inputstr.h" #include "exevents.h" #include "eventstr.h" -#include "mi.h" #include "mipointer.h" #include "inpututils.h" -#include "dixgrabs.h" #define EXTENSION_EVENT_BASE 64 @@ -1372,9 +1374,12 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event) (event->type == ET_ButtonPress)); if (pressEvent) { - if (keyEvent) - act = XkbGetKeyAction(xkbi, &xkbi->state, key); - else { + if (keyEvent) { + if (kbd->ignoreXkbActionsBehaviors) + act.type = XkbSA_NoAction; + else + act = XkbGetKeyAction(xkbi, &xkbi->state, key); + } else { act = XkbGetButtonAction(kbd, dev, key); key |= BTN_ACT_FLAG; } diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index e6325d875..cfe9ba11c 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <X11/X.h> diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 1e189a3f0..d187a1e87 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <xkb-config.h> @@ -50,7 +48,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "property.h" #include "scrnintstr.h" #include "xkbgeom.h" -#include "xkbfile.h" + +#define _XKB_RF_NAMES_PROP_ATOM "_XKB_RULES_NAMES" #define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1) @@ -75,13 +74,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #endif -#define MAX_TOC 16 -typedef struct _SrvXkmInfo { - DeviceIntPtr dev; - FILE *file; - XkbDescPtr xkb; -} SrvXkmInfo; - /***====================================================================***/ #ifndef XKB_DFLT_RULES_PROP @@ -215,11 +207,11 @@ XkbInitRules(XkbRMLVOSet *rmlvo, const char *variant, const char *options) { - rmlvo->rules = rules ? xnfstrdup(rules) : NULL; - rmlvo->model = model ? xnfstrdup(model) : NULL; - rmlvo->layout = layout ? xnfstrdup(layout) : NULL; - rmlvo->variant = variant ? xnfstrdup(variant) : NULL; - rmlvo->options = options ? xnfstrdup(options) : NULL; + rmlvo->rules = rules ? XNFstrdup(rules) : NULL; + rmlvo->model = model ? XNFstrdup(model) : NULL; + rmlvo->layout = layout ? XNFstrdup(layout) : NULL; + rmlvo->variant = variant ? XNFstrdup(variant) : NULL; + rmlvo->options = options ? XNFstrdup(options) : NULL; } static void @@ -778,11 +770,11 @@ XkbProcessArguments(int argc, char *argv[], int i) else { XkbWantAccessX = 1; - if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) { + if (((i + 1) < argc) && (isdigit((unsigned char)argv[i + 1][0]))) { XkbDfltAccessXTimeout = atoi(argv[++i]); j++; - if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) { + if (((i + 1) < argc) && (isdigit((unsigned char)argv[i + 1][0]))) { /* * presumption that the reasonably useful range of * values fits in 0..MAXINT since SunOS 4 doesn't @@ -792,14 +784,14 @@ XkbProcessArguments(int argc, char *argv[], int i) strtol(argv[++i], NULL, 16); j++; } - if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) { + if (((i + 1) < argc) && (isdigit((unsigned char)argv[i + 1][0]))) { if (argv[++i][0] == '1') XkbDfltAccessXFeedback = XkbAccessXFeedbackMask; else XkbDfltAccessXFeedback = 0; j++; } - if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) { + if (((i + 1) < argc) && (isdigit((unsigned char)argv[i + 1][0]))) { XkbDfltAccessXOptions = (unsigned short) strtol(argv[++i], NULL, 16); j++; diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c index 7ac6b1ad9..749123577 100644 --- a/xkb/xkbLEDs.c +++ b/xkb/xkbLEDs.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <ctype.h> diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c index 972f35170..f768bedff 100644 --- a/xkb/xkbPrKeyEv.c +++ b/xkb/xkbPrKeyEv.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <ctype.h> #include <stdio.h> @@ -35,6 +33,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/Xproto.h> #include <X11/keysym.h> +#include "dix/input_priv.h" #include "xkb/xkbsrv_priv.h" #include "misc.h" @@ -68,7 +67,7 @@ XkbProcessKeyboardEvent(DeviceEvent *event, DeviceIntPtr keybd) /* do anything to implement the behavior, but it *does* report that */ /* key is hardwired */ - if (!(behavior.type & XkbKB_Permanent)) { + if (!keybd->ignoreXkbActionsBehaviors && !(behavior.type & XkbKB_Permanent)) { switch (behavior.type) { case XkbKB_Default: /* Neither of these should happen in practice, but ignore them diff --git a/xkb/xkbSwap.c b/xkb/xkbSwap.c index efbdb81c1..00fd04d38 100644 --- a/xkb/xkbSwap.c +++ b/xkb/xkbSwap.c @@ -24,9 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include "stdio.h" #include <X11/X.h> @@ -45,8 +43,6 @@ static int _X_COLD SProcXkbUseExtension(ClientPtr client) { REQUEST(xkbUseExtensionReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbUseExtensionReq); swaps(&stuff->wantedMajor); swaps(&stuff->wantedMinor); @@ -57,8 +53,6 @@ static int _X_COLD SProcXkbSelectEvents(ClientPtr client) { REQUEST(xkbSelectEventsReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq); swaps(&stuff->deviceSpec); swaps(&stuff->affectWhich); @@ -135,8 +129,6 @@ static int _X_COLD SProcXkbBell(ClientPtr client) { REQUEST(xkbBellReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbBellReq); swaps(&stuff->deviceSpec); swaps(&stuff->bellClass); @@ -152,8 +144,6 @@ static int _X_COLD SProcXkbGetState(ClientPtr client) { REQUEST(xkbGetStateReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetStateReq); swaps(&stuff->deviceSpec); return ProcXkbGetState(client); @@ -163,8 +153,6 @@ static int _X_COLD SProcXkbLatchLockState(ClientPtr client) { REQUEST(xkbLatchLockStateReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbLatchLockStateReq); swaps(&stuff->deviceSpec); swaps(&stuff->groupLatch); @@ -175,8 +163,6 @@ static int _X_COLD SProcXkbGetControls(ClientPtr client) { REQUEST(xkbGetControlsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetControlsReq); swaps(&stuff->deviceSpec); return ProcXkbGetControls(client); @@ -186,8 +172,6 @@ static int _X_COLD SProcXkbSetControls(ClientPtr client) { REQUEST(xkbSetControlsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbSetControlsReq); swaps(&stuff->deviceSpec); swaps(&stuff->affectInternalVMods); @@ -219,8 +203,6 @@ static int _X_COLD SProcXkbGetMap(ClientPtr client) { REQUEST(xkbGetMapReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetMapReq); swaps(&stuff->deviceSpec); swaps(&stuff->full); @@ -233,8 +215,6 @@ static int _X_COLD SProcXkbSetMap(ClientPtr client) { REQUEST(xkbSetMapReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSetMapReq); swaps(&stuff->deviceSpec); swaps(&stuff->present); @@ -249,8 +229,6 @@ static int _X_COLD SProcXkbGetCompatMap(ClientPtr client) { REQUEST(xkbGetCompatMapReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetCompatMapReq); swaps(&stuff->deviceSpec); swaps(&stuff->firstSI); @@ -262,8 +240,6 @@ static int _X_COLD SProcXkbSetCompatMap(ClientPtr client) { REQUEST(xkbSetCompatMapReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSetCompatMapReq); swaps(&stuff->deviceSpec); swaps(&stuff->firstSI); @@ -275,8 +251,6 @@ static int _X_COLD SProcXkbGetIndicatorState(ClientPtr client) { REQUEST(xkbGetIndicatorStateReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq); swaps(&stuff->deviceSpec); return ProcXkbGetIndicatorState(client); @@ -286,8 +260,6 @@ static int _X_COLD SProcXkbGetIndicatorMap(ClientPtr client) { REQUEST(xkbGetIndicatorMapReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetIndicatorMapReq); swaps(&stuff->deviceSpec); swapl(&stuff->which); @@ -298,8 +270,6 @@ static int _X_COLD SProcXkbSetIndicatorMap(ClientPtr client) { REQUEST(xkbSetIndicatorMapReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq); swaps(&stuff->deviceSpec); swapl(&stuff->which); @@ -310,8 +280,6 @@ static int _X_COLD SProcXkbGetNamedIndicator(ClientPtr client) { REQUEST(xkbGetNamedIndicatorReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq); swaps(&stuff->deviceSpec); swaps(&stuff->ledClass); @@ -324,8 +292,6 @@ static int _X_COLD SProcXkbSetNamedIndicator(ClientPtr client) { REQUEST(xkbSetNamedIndicatorReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbSetNamedIndicatorReq); swaps(&stuff->deviceSpec); swaps(&stuff->ledClass); @@ -340,8 +306,6 @@ static int _X_COLD SProcXkbGetNames(ClientPtr client) { REQUEST(xkbGetNamesReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetNamesReq); swaps(&stuff->deviceSpec); swapl(&stuff->which); @@ -352,8 +316,6 @@ static int _X_COLD SProcXkbSetNames(ClientPtr client) { REQUEST(xkbSetNamesReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSetNamesReq); swaps(&stuff->deviceSpec); swaps(&stuff->virtualMods); @@ -367,8 +329,6 @@ static int _X_COLD SProcXkbGetGeometry(ClientPtr client) { REQUEST(xkbGetGeometryReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetGeometryReq); swaps(&stuff->deviceSpec); swapl(&stuff->name); @@ -379,8 +339,6 @@ static int _X_COLD SProcXkbSetGeometry(ClientPtr client) { REQUEST(xkbSetGeometryReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSetGeometryReq); swaps(&stuff->deviceSpec); swapl(&stuff->name); @@ -397,8 +355,6 @@ static int _X_COLD SProcXkbPerClientFlags(ClientPtr client) { REQUEST(xkbPerClientFlagsReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbPerClientFlagsReq); swaps(&stuff->deviceSpec); swapl(&stuff->change); @@ -413,8 +369,6 @@ static int _X_COLD SProcXkbListComponents(ClientPtr client) { REQUEST(xkbListComponentsReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbListComponentsReq); swaps(&stuff->deviceSpec); swaps(&stuff->maxNames); @@ -425,8 +379,6 @@ static int _X_COLD SProcXkbGetKbdByName(ClientPtr client) { REQUEST(xkbGetKbdByNameReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq); swaps(&stuff->deviceSpec); swaps(&stuff->want); @@ -438,8 +390,6 @@ static int _X_COLD SProcXkbGetDeviceInfo(ClientPtr client) { REQUEST(xkbGetDeviceInfoReq); - - swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq); swaps(&stuff->deviceSpec); swaps(&stuff->wanted); @@ -452,8 +402,6 @@ static int _X_COLD SProcXkbSetDeviceInfo(ClientPtr client) { REQUEST(xkbSetDeviceInfoReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSetDeviceInfoReq); swaps(&stuff->deviceSpec); swaps(&stuff->change); @@ -465,8 +413,6 @@ static int _X_COLD SProcXkbSetDebuggingFlags(ClientPtr client) { REQUEST(xkbSetDebuggingFlagsReq); - - swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq); swapl(&stuff->affectFlags); swapl(&stuff->flags); diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index cdd5eb004..8ca92bd15 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -48,9 +48,7 @@ DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <ctype.h> @@ -932,6 +930,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) { void *tmp = NULL; int i; + int gap; XkbKeyTypePtr stype = NULL, dtype = NULL; /* client map */ @@ -961,15 +960,20 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } dst->map->num_syms = src->map->num_syms; dst->map->size_syms = src->map->size_syms; + gap = MAP_LENGTH - (src->max_key_code + 1); if (src->map->key_sym_map) { - if (src->max_key_code != dst->max_key_code) { + if (!dst->map->key_sym_map) { tmp = reallocarray(dst->map->key_sym_map, - src->max_key_code + 1, sizeof(XkbSymMapRec)); + MAP_LENGTH, sizeof(XkbSymMapRec)); if (!tmp) return FALSE; dst->map->key_sym_map = tmp; } + if (gap > 0) { + memset((char *) &dst->map->key_sym_map[gap], 0, + gap * sizeof(XkbSymMapRec)); + } memcpy(dst->map->key_sym_map, src->map->key_sym_map, (src->max_key_code + 1) * sizeof(XkbSymMapRec)); } @@ -1140,12 +1144,15 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } if (src->map->modmap) { - if (src->max_key_code != dst->max_key_code) { - tmp = realloc(dst->map->modmap, src->max_key_code + 1); + if (!dst->map->modmap) { + tmp = realloc(dst->map->modmap, MAP_LENGTH); if (!tmp) return FALSE; dst->map->modmap = tmp; } + if (gap > 0) { + memset(dst->map->modmap + gap, 0, gap); + } memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1); } else { @@ -1165,6 +1172,7 @@ static Bool _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) { void *tmp = NULL; + int gap; /* server map */ if (src->server) { @@ -1175,13 +1183,16 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) dst->server = tmp; } + gap = MAP_LENGTH - (src->max_key_code + 1); if (src->server->explicit) { - if (src->max_key_code != dst->max_key_code) { - tmp = realloc(dst->server->explicit, src->max_key_code + 1); + if (!dst->server->explicit) { + tmp = realloc(dst->server->explicit, MAP_LENGTH); if (!tmp) return FALSE; dst->server->explicit = tmp; } + if (gap > 0) + memset(dst->server->explicit + gap, 0, gap); memcpy(dst->server->explicit, src->server->explicit, src->max_key_code + 1); } @@ -1209,13 +1220,15 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) dst->server->num_acts = src->server->num_acts; if (src->server->key_acts) { - if (src->max_key_code != dst->max_key_code) { + if (!dst->server->key_acts) { tmp = reallocarray(dst->server->key_acts, - src->max_key_code + 1, sizeof(unsigned short)); + MAP_LENGTH, sizeof(unsigned short)); if (!tmp) return FALSE; dst->server->key_acts = tmp; } + if (gap > 0) + memset((char *) &dst->server->key_acts[gap], 0, gap * sizeof(unsigned short)); memcpy(dst->server->key_acts, src->server->key_acts, (src->max_key_code + 1) * sizeof(unsigned short)); } @@ -1225,13 +1238,15 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) } if (src->server->behaviors) { - if (src->max_key_code != dst->max_key_code) { + if (!dst->server->behaviors) { tmp = reallocarray(dst->server->behaviors, - src->max_key_code + 1, sizeof(XkbBehavior)); + MAP_LENGTH, sizeof(XkbBehavior)); if (!tmp) return FALSE; dst->server->behaviors = tmp; } + if (gap > 0) + memset((char *) &dst->server->behaviors[gap], 0, gap * sizeof(XkbBehavior)); memcpy(dst->server->behaviors, src->server->behaviors, (src->max_key_code + 1) * sizeof(XkbBehavior)); } @@ -1243,13 +1258,15 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) memcpy(dst->server->vmods, src->server->vmods, XkbNumVirtualMods); if (src->server->vmodmap) { - if (src->max_key_code != dst->max_key_code) { + if (!dst->server->vmodmap) { tmp = reallocarray(dst->server->vmodmap, - src->max_key_code + 1, sizeof(unsigned short)); + MAP_LENGTH, sizeof(unsigned short)); if (!tmp) return FALSE; dst->server->vmodmap = tmp; } + if (gap > 0) + memset((char *) &dst->server->vmodmap[gap], 0, gap * sizeof(unsigned short)); memcpy(dst->server->vmodmap, src->server->vmodmap, (src->max_key_code + 1) * sizeof(unsigned short)); } @@ -1270,6 +1287,7 @@ static Bool _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) { void *tmp = NULL; + int gap; /* names */ if (src->names) { @@ -1279,14 +1297,17 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) return FALSE; } + gap = MAP_LENGTH - (src->max_key_code + 1); if (src->names->keys) { - if (src->max_key_code != dst->max_key_code) { - tmp = reallocarray(dst->names->keys, src->max_key_code + 1, + if (!dst->names->keys) { + tmp = reallocarray(dst->names->keys, MAP_LENGTH, sizeof(XkbKeyNameRec)); if (!tmp) return FALSE; dst->names->keys = tmp; } + if (gap > 0) + memset((char *) &dst->names->keys[gap], 0, gap * sizeof(XkbKeyNameRec)); memcpy(dst->names->keys, src->names->keys, (src->max_key_code + 1) * sizeof(XkbKeyNameRec)); } @@ -1466,8 +1487,8 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) strcpy(dprop->value, sprop->value); } else { - dprop->name = xstrdup(sprop->name); - dprop->value = xstrdup(sprop->value); + dprop->name = Xstrdup(sprop->name); + dprop->value = Xstrdup(sprop->value); } } @@ -1520,7 +1541,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) strcpy(dcolor->spec, scolor->spec); } else { - dcolor->spec = xstrdup(scolor->spec); + dcolor->spec = Xstrdup(scolor->spec); } dcolor->pixel = scolor->pixel; } diff --git a/xkb/xkbfile_priv.h b/xkb/xkbfile_priv.h new file mode 100644 index 000000000..3a37b9d49 --- /dev/null +++ b/xkb/xkbfile_priv.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + * Copyright © 1994 by Silicon Graphics Computer Systems, Inc. + */ +#ifndef _XSERVER_XKB_XKBFILE_PRIV_H +#define _XSERVER_XKB_XKBFILE_PRIV_H + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xdefs.h> + +#include "xkbstr.h" + +/* XKB error codes */ +#define _XkbErrMissingNames 1 +#define _XkbErrMissingTypes 2 +#define _XkbErrMissingReqTypes 3 +#define _XkbErrMissingSymbols 4 +#define _XkbErrMissingCompatMap 7 +#define _XkbErrMissingGeometry 9 +#define _XkbErrIllegalContents 12 +#define _XkbErrBadValue 16 +#define _XkbErrBadMatch 17 +#define _XkbErrBadTypeName 18 +#define _XkbErrBadTypeWidth 19 +#define _XkbErrBadFileType 20 +#define _XkbErrBadFileVersion 21 +#define _XkbErrBadAlloc 23 +#define _XkbErrBadLength 24 +#define _XkbErrBadImplementation 26 + +/* + * read xkm file + * + * @param file the FILE to read from + * @param need mask of needed elements (fails if some are missing) + * @param want mask of wanted elements + * @param result pointer to xkb descriptor to load the data into + * @return mask of elements missing (from need | want) + */ +unsigned XkmReadFile(FILE *file, unsigned need, unsigned want, + XkbDescPtr *result); + +#endif /* _XSERVER_XKB_XKBFILE_PRIV_H */ diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c index 47da228ca..2ec3b85ed 100644 --- a/xkb/xkbfmisc.c +++ b/xkb/xkbfmisc.c @@ -24,21 +24,21 @@ ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <ctype.h> #include <stdlib.h> - #include <X11/Xos.h> #include <X11/Xfuncs.h> #include <X11/extensions/XKMformat.h> - #include <X11/X.h> #include <X11/keysym.h> #include <X11/Xproto.h> + +#include "xkb/xkbfmisc_priv.h" +#include "xkb/xkbout_priv.h" + #include "misc.h" #include "inputstr.h" #include "dix.h" @@ -392,42 +392,3 @@ XkbFindKeycodeByName(XkbDescPtr xkb, char *name, Bool use_aliases) } return 0; } - -unsigned -XkbConvertGetByNameComponents(Bool toXkm, unsigned orig) -{ - unsigned rtrn; - - rtrn = 0; - if (toXkm) { - if (orig & XkbGBN_TypesMask) - rtrn |= XkmTypesMask; - if (orig & XkbGBN_CompatMapMask) - rtrn |= XkmCompatMapMask; - if (orig & XkbGBN_SymbolsMask) - rtrn |= XkmSymbolsMask; - if (orig & XkbGBN_IndicatorMapMask) - rtrn |= XkmIndicatorsMask; - if (orig & XkbGBN_KeyNamesMask) - rtrn |= XkmKeyNamesMask; - if (orig & XkbGBN_GeometryMask) - rtrn |= XkmGeometryMask; - } - else { - if (orig & XkmTypesMask) - rtrn |= XkbGBN_TypesMask; - if (orig & XkmCompatMapMask) - rtrn |= XkbGBN_CompatMapMask; - if (orig & XkmSymbolsMask) - rtrn |= XkbGBN_SymbolsMask; - if (orig & XkmIndicatorsMask) - rtrn |= XkbGBN_IndicatorMapMask; - if (orig & XkmKeyNamesMask) - rtrn |= XkbGBN_KeyNamesMask; - if (orig & XkmGeometryMask) - rtrn |= XkbGBN_GeometryMask; - if (orig != 0) - rtrn |= XkbGBN_OtherNamesMask; - } - return rtrn; -} diff --git a/xkb/xkbfmisc_priv.h b/xkb/xkbfmisc_priv.h new file mode 100644 index 000000000..b08947b91 --- /dev/null +++ b/xkb/xkbfmisc_priv.h @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_XKB_XKBFMISC_PRIV_H +#define _XSERVER_XKB_XKBFMISC_PRIV_H + +/* needed for X11/keysymdef.h to define all symdefs */ +#define XK_MISCELLANY + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xdefs.h> +#include <X11/keysymdef.h> + +#include "xkbstr.h" + +/* + * return mask bits for _XkbKSCheckCase() + */ +#define _XkbKSLower (1<<0) +#define _XkbKSUpper (1<<1) + +/* + * check whether given KeySym is a upper or lower case key + * + * @param sym the KeySym to check + * @return mask of _XkbKS* flags + */ +unsigned int _XkbKSCheckCase(KeySym sym); + +/* + * check whether given KeySym is an lower case key + * + * @param k the KeySym to check + * @return TRUE if k is a lower case key + */ +static inline Bool XkbKSIsLower(KeySym k) { return _XkbKSCheckCase(k)&_XkbKSLower; } + +/* + * check whether given KeySym is an upper case key + * + * @param k the KeySym to check + * @return TRUE if k is a upper case key + */ +static inline Bool XkbKSIsUpper(KeySym k) { return _XkbKSCheckCase(k)&_XkbKSUpper; } + +/* + * check whether given KeySym is an keypad key + * + * @param k the KeySym to check + * @return TRUE if k is a keypad key + */ +static inline Bool XkbKSIsKeypad(KeySym k) { return (((k)>=XK_KP_Space)&&((k)<=XK_KP_Equal)); } + +/* + * find a keycode by its name + * + * @param xkb pointer to xkb descriptor + * @param name the key name + * @param use_aliases TRUE if aliases should be resolved + * @return keycode ID + */ +int XkbFindKeycodeByName(XkbDescPtr xkb, char *name, Bool use_aliases); + +/* + * write keymap for given component names + * + * @param file the FILE to write to + * @param names pointer to list of keymap component names to write out + * @param xkb pointer to xkb descriptor + * @param want bitmask of wanted elements + * @param need bitmask of needed elements + * @return TRUE if succeeded +*/ +Bool XkbWriteXKBKeymapForNames(FILE *file, XkbComponentNamesPtr names, + XkbDescPtr xkb, unsigned want, unsigned need); + +#endif /* _XSERVER_XKB_XKBFMISC_PRIV_H */ diff --git a/xkb/xkbout.c b/xkb/xkbout.c index 46e07db3f..a8b2f1523 100644 --- a/xkb/xkbout.c +++ b/xkb/xkbout.c @@ -24,19 +24,21 @@ ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <X11/Xfuncs.h> - #include <X11/X.h> #include <X11/keysym.h> #include <X11/Xproto.h> #include <X11/extensions/XKMformat.h> + +#include "xkb/xkbfmisc_priv.h" +#include "xkb/xkbout_priv.h" +#include "xkb/xkbtext_priv.h" + #include "misc.h" #include "inputstr.h" #include "dix.h" @@ -44,7 +46,6 @@ #include <xkbsrv.h> #include "xkbgeom.h" -#include "xkbfile.h" #define VMOD_HIDE_VALUE 0 #define VMOD_SHOW_VALUE 1 diff --git a/xkb/xkbout_priv.h b/xkb/xkbout_priv.h new file mode 100644 index 000000000..790a009ec --- /dev/null +++ b/xkb/xkbout_priv.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_XKB_XKBFOUT_PRIV_H +#define _XSERVER_XKB_XKBFOUT_PRIV_H + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xdefs.h> + +#include "xkbstr.h" + +typedef void (*XkbFileAddOnFunc) (FILE *file, + XkbDescPtr result, + Bool topLevel, + Bool showImplicit, + int fileSection, + void *priv); + +Bool XkbWriteXKBKeyTypes(FILE *file, XkbDescPtr result, Bool topLevel, + Bool showImplicit, XkbFileAddOnFunc addOn, void *priv); +Bool XkbWriteXKBKeycodes(FILE *file, XkbDescPtr result, Bool topLevel, + Bool showImplicit, XkbFileAddOnFunc addOn, void *priv); +Bool XkbWriteXKBCompatMap(FILE *file, XkbDescPtr result, Bool topLevel, + Bool showImplicit, XkbFileAddOnFunc addOn, void *priv); +Bool XkbWriteXKBSymbols(FILE *file, XkbDescPtr result, Bool topLevel, + Bool showImplicit, XkbFileAddOnFunc addOn, void *priv); +Bool XkbWriteXKBGeometry(FILE *file, XkbDescPtr result, Bool topLevel, + Bool showImplicit, XkbFileAddOnFunc addOn, void *priv); + +#endif /* _XSERVER_XKB_XKBFOUT_PRIV_H */ diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h new file mode 100644 index 000000000..deb29d093 --- /dev/null +++ b/xkb/xkbrules_priv.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_XKB_XKBRULES_PRIV_H +#define _XSERVER_XKB_XKBRULES_PRIV_H + +#include <stdio.h> +#include <stdlib.h> +#include <X11/Xdefs.h> + +#include "include/xkbrules.h" + +typedef struct _XkbRF_Rule { + int number; + int layout_num; + int variant_num; + const char *model; + const char *layout; + const char *variant; + const char *option; + /* yields */ + const char *keycodes; + const char *symbols; + const char *types; + const char *compat; + const char *geometry; + unsigned flags; +} XkbRF_RuleRec, *XkbRF_RulePtr; + +typedef struct _XkbRF_Group { + int number; + const char *name; + char *words; +} XkbRF_GroupRec, *XkbRF_GroupPtr; + +typedef struct _XkbRF_Rules { + unsigned short sz_rules; + unsigned short num_rules; + XkbRF_RulePtr rules; + unsigned short sz_groups; + unsigned short num_groups; + XkbRF_GroupPtr groups; +} XkbRF_RulesRec, *XkbRF_RulesPtr; + +struct _XkbComponentNames; + +Bool XkbRF_GetComponents(XkbRF_RulesPtr rules, + XkbRF_VarDefsPtr var_defs, + struct _XkbComponentNames *names); + +Bool XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules); + +static inline XkbRF_RulesPtr XkbRF_Create(void) +{ + return calloc(1, sizeof(XkbRF_RulesRec)); +} + +void XkbRF_Free(XkbRF_RulesPtr rules); + +#endif /* _XSERVER_XKB_XKBRULES_PRIV_H */ diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c index 7f377fdfc..5d8caf4fb 100644 --- a/xkb/xkbtext.c +++ b/xkb/xkbtext.c @@ -24,19 +24,18 @@ ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> #include <ctype.h> #include <stdlib.h> - #include <X11/Xos.h> - #include <X11/X.h> #include <X11/Xproto.h> #include <X11/extensions/XKMformat.h> + +#include "xkb/xkbtext_priv.h" + #include "misc.h" #include "inputstr.h" #include "dix.h" @@ -63,7 +62,7 @@ tbGetBuffer(unsigned size) if (size > tb->size) { free(tb->buffer); - tb->buffer = xnfalloc(size); + tb->buffer = XNFalloc(size); tb->size = size; } return tb->buffer; @@ -71,6 +70,20 @@ tbGetBuffer(unsigned size) /***====================================================================***/ +static inline char * +tbGetBufferString(const char *str) +{ + size_t size = strlen(str) + 1; + char *rtrn = tbGetBuffer((unsigned) size); + + if (rtrn != NULL) + memcpy(rtrn, str, size); + + return rtrn; +} + +/***====================================================================***/ + char * XkbAtomText(Atom atm, unsigned format) { @@ -79,11 +92,7 @@ XkbAtomText(Atom atm, unsigned format) atmstr = NameForAtom(atm); if (atmstr != NULL) { - int len; - - len = strlen(atmstr) + 1; - rtrn = tbGetBuffer(len); - strlcpy(rtrn, atmstr, len); + rtrn = tbGetBufferString(atmstr); } else { rtrn = tbGetBuffer(1); @@ -91,9 +100,9 @@ XkbAtomText(Atom atm, unsigned format) } if (format == XkbCFile) { for (tmp = rtrn; *tmp != '\0'; tmp++) { - if ((tmp == rtrn) && (!isalpha(*tmp))) + if ((tmp == rtrn) && (!isalpha((unsigned char)*tmp))) *tmp = '_'; - else if (!isalnum(*tmp)) + else if (!isalnum((unsigned char)*tmp)) *tmp = '_'; } } @@ -151,11 +160,12 @@ XkbVModMaskText(XkbDescPtr xkb, char *str, buf[VMOD_BUFFER_SIZE]; if ((modMask == 0) && (mask == 0)) { - rtrn = tbGetBuffer(5); + const int rtrnsize = 5; + rtrn = tbGetBuffer(rtrnsize); if (format == XkbCFile) - sprintf(rtrn, "0"); + snprintf(rtrn, rtrnsize, "0"); else - sprintf(rtrn, "none"); + snprintf(rtrn, rtrnsize, "none"); return rtrn; } if (modMask != 0) @@ -174,14 +184,14 @@ XkbVModMaskText(XkbDescPtr xkb, len = strlen(tmp) + 1 + (str == buf ? 0 : 1); if (format == XkbCFile) len += 4; - if ((str - (buf + len)) <= VMOD_BUFFER_SIZE) { - if (str != buf) { - if (format == XkbCFile) - *str++ = '|'; - else - *str++ = '+'; - len--; - } + if ((str - buf) + len > VMOD_BUFFER_SIZE) + continue; /* Skip */ + if (str != buf) { + if (format == XkbCFile) + *str++ = '|'; + else + *str++ = '+'; + len--; } if (format == XkbCFile) sprintf(str, "%sMask", tmp); @@ -232,7 +242,6 @@ static const char *modNames[XkbNumModifiers] = { char * XkbModIndexText(unsigned ndx, unsigned format) { - char *rtrn; char buf[100]; if (format == XkbCFile) { @@ -251,9 +260,7 @@ XkbModIndexText(unsigned ndx, unsigned format) else snprintf(buf, sizeof(buf), "ILLEGAL_%02x", ndx); } - rtrn = tbGetBuffer(strlen(buf) + 1); - strcpy(rtrn, buf); - return rtrn; + return tbGetBufferString(buf); } char * @@ -295,8 +302,7 @@ XkbModMaskText(unsigned mask, unsigned format) } } } - rtrn = tbGetBuffer(strlen(buf) + 1); - strcpy(rtrn, buf); + rtrn = tbGetBufferString(buf); return rtrn; } @@ -306,8 +312,9 @@ XkbModMaskText(unsigned mask, unsigned format) XkbConfigText(unsigned config, unsigned format) { static char *buf; + const int bufsize = 32; - buf = tbGetBuffer(32); + buf = tbGetBuffer(bufsize); switch (config) { case XkmSemanticsFile: strcpy(buf, "Semantics"); @@ -341,7 +348,7 @@ XkbConfigText(unsigned config, unsigned format) strcpy(buf, "VirtualMods"); break; default: - sprintf(buf, "unknown(%d)", config); + snprintf(buf, bufsize, "unknown(%d)", config); break; } return buf; @@ -440,7 +447,7 @@ static const char *imWhichNames[] = { char * XkbIMWhichStateMaskText(unsigned use_which, unsigned format) { - int len; + int len, bufsize; unsigned i, bit, tmp; char *buf; @@ -458,7 +465,8 @@ XkbIMWhichStateMaskText(unsigned use_which, unsigned format) len += 9; } } - buf = tbGetBuffer(len + 1); + bufsize = len + 1; + buf = tbGetBuffer(bufsize); tmp = use_which & XkbIM_UseAnyMods; for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) { if (tmp & bit) { @@ -466,13 +474,14 @@ XkbIMWhichStateMaskText(unsigned use_which, unsigned format) if (format == XkbCFile) { if (len != 0) buf[len++] = '|'; - sprintf(&buf[len], "XkbIM_Use%s", imWhichNames[i]); - buf[len + 9] = toupper(buf[len + 9]); + snprintf(&buf[len], bufsize - len, + "XkbIM_Use%s", imWhichNames[i]); + buf[len + 9] = toupper((unsigned char)buf[len + 9]); } else { if (len != 0) buf[len++] = '+'; - sprintf(&buf[len], "%s", imWhichNames[i]); + snprintf(&buf[len], bufsize - len, "%s", imWhichNames[i]); } len += strlen(&buf[len]); } @@ -529,7 +538,7 @@ XkbControlsMaskText(unsigned ctrls, unsigned format) if (len != 0) buf[len++] = '|'; sprintf(&buf[len], "Xkb%sMask", ctrlNames[i]); - buf[len + 3] = toupper(buf[len + 3]); + buf[len + 3] = toupper((unsigned char)buf[len + 3]); } else { if (len != 0) @@ -560,7 +569,7 @@ XkbStringText(char *str, unsigned format) else if (format == XkbXKMFile) return str; for (ok = TRUE, len = 0, in = str; *in != '\0'; in++, len++) { - if (!isprint(*in)) { + if (!isprint((unsigned char)*in)) { ok = FALSE; switch (*in) { case '\n': @@ -581,7 +590,7 @@ XkbStringText(char *str, unsigned format) return str; buf = tbGetBuffer(len + 1); for (in = str, out = buf; *in != '\0'; in++) { - if (isprint(*in)) + if (isprint((unsigned char)*in)) *out++ = *in; else { *out++ = '\\'; @@ -619,18 +628,27 @@ XkbGeomFPText(int val, unsigned format) { int whole, frac; char *buf; + const int bufsize = 13; - buf = tbGetBuffer(12); + buf = tbGetBuffer(bufsize); if (format == XkbCFile) { - sprintf(buf, "%d", val); + snprintf(buf, bufsize, "%d", val); } else { whole = val / XkbGeomPtsPerMM; - frac = val % XkbGeomPtsPerMM; - if (frac != 0) - sprintf(buf, "%d.%d", whole, frac); + frac = abs(val % XkbGeomPtsPerMM); + if (frac != 0) { + if (val < 0) + { + int wholeabs; + wholeabs = abs(whole); + snprintf(buf, bufsize, "-%d.%d", wholeabs, frac); + } + else + snprintf(buf, bufsize, "%d.%d", whole, frac); + } else - sprintf(buf, "%d", whole); + snprintf(buf, bufsize, "%d", whole); } return buf; } @@ -641,7 +659,8 @@ XkbDoodadTypeText(unsigned type, unsigned format) char *buf; if (format == XkbCFile) { - buf = tbGetBuffer(24); + const int bufsize = 24; + buf = tbGetBuffer(bufsize); if (type == XkbOutlineDoodad) strcpy(buf, "XkbOutlineDoodad"); else if (type == XkbSolidDoodad) @@ -653,10 +672,11 @@ XkbDoodadTypeText(unsigned type, unsigned format) else if (type == XkbLogoDoodad) strcpy(buf, "XkbLogoDoodad"); else - sprintf(buf, "UnknownDoodad%d", type); + snprintf(buf, bufsize, "UnknownDoodad%d", type); } else { - buf = tbGetBuffer(12); + const int bufsize = 12; + buf = tbGetBuffer(bufsize); if (type == XkbOutlineDoodad) strcpy(buf, "outline"); else if (type == XkbSolidDoodad) @@ -668,7 +688,7 @@ XkbDoodadTypeText(unsigned type, unsigned format) else if (type == XkbLogoDoodad) strcpy(buf, "logo"); else - sprintf(buf, "unknown%d", type); + snprintf(buf, bufsize, "unknown%d", type); } return buf; } @@ -1214,7 +1234,7 @@ static actionCopy copyActionArgs[XkbSA_NumActions] = { char * XkbActionText(XkbDescPtr xkb, XkbAction *action, unsigned format) { - char buf[ACTION_SZ], *tmp; + char buf[ACTION_SZ]; int sz; if (format == XkbCFile) { @@ -1235,16 +1255,13 @@ XkbActionText(XkbDescPtr xkb, XkbAction *action, unsigned format) CopyOtherArgs(xkb, action, buf, &sz); TryCopyStr(buf, ")", &sz); } - tmp = tbGetBuffer(strlen(buf) + 1); - if (tmp != NULL) - strcpy(tmp, buf); - return tmp; + return tbGetBufferString(buf); } char * XkbBehaviorText(XkbDescPtr xkb, XkbBehavior * behavior, unsigned format) { - char buf[256], *tmp; + char buf[256]; if (format == XkbCFile) { if (behavior->type == XkbKB_Default) @@ -1265,6 +1282,8 @@ XkbBehaviorText(XkbDescPtr xkb, XkbBehavior * behavior, unsigned format) } else if (type == XkbKB_RadioGroup) { int g; + char *tmp; + size_t tmpsize; g = ((behavior->data) & (~XkbKB_RGAllowNone)) + 1; if (XkbKB_RGAllowNone & behavior->data) { @@ -1273,10 +1292,11 @@ XkbBehaviorText(XkbDescPtr xkb, XkbBehavior * behavior, unsigned format) } else tmp = buf; + tmpsize = sizeof(buf) - (tmp - buf); if (permanent) - sprintf(tmp, "permanentRadioGroup= %d", g); + snprintf(tmp, tmpsize, "permanentRadioGroup= %d", g); else - sprintf(tmp, "radioGroup= %d", g); + snprintf(tmp, tmpsize, "radioGroup= %d", g); } else if ((type == XkbKB_Overlay1) || (type == XkbKB_Overlay2)) { int ndx, kc; @@ -1298,10 +1318,7 @@ XkbBehaviorText(XkbDescPtr xkb, XkbBehavior * behavior, unsigned format) snprintf(buf, sizeof(buf), "overlay%d= %s", ndx, kn); } } - tmp = tbGetBuffer(strlen(buf) + 1); - if (tmp != NULL) - strcpy(tmp, buf); - return tmp; + return tbGetBufferString(buf); } /***====================================================================***/ diff --git a/xkb/xkbtext_priv.h b/xkb/xkbtext_priv.h new file mode 100644 index 000000000..0841002a4 --- /dev/null +++ b/xkb/xkbtext_priv.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net> + */ +#ifndef _XSERVER_XKB_XKBTEXT_PRIV_H +#define _XSERVER_XKB_XKBTEXT_PRIV_H + +#include <X11/X.h> + +#include "xkbstr.h" + +#define XkbXKMFile 0 +#define XkbCFile 1 +#define XkbXKBFile 2 +#define XkbMessage 3 + +char *XkbIndentText(unsigned size); +char *XkbAtomText(Atom atm, unsigned format); +char *XkbKeysymText(KeySym sym, unsigned format); +char *XkbStringText(char *str, unsigned format); +char *XkbKeyNameText(char *name, unsigned format); +char *XkbModIndexText(unsigned ndx, unsigned format); +char *XkbModMaskText(unsigned mask, unsigned format); +char *XkbVModIndexText(XkbDescPtr xkb, unsigned ndx, unsigned format); +char *XkbVModMaskText(XkbDescPtr xkb, unsigned modMask, unsigned mask, + unsigned format); +char *XkbConfigText(unsigned config, unsigned format); +const char *XkbSIMatchText(unsigned type, unsigned format); +char *XkbIMWhichStateMaskText(unsigned use_which, unsigned format); +char *XkbControlsMaskText(unsigned ctrls, unsigned format); +char *XkbGeomFPText(int val, unsigned format); +char *XkbDoodadTypeText(unsigned type, unsigned format); +const char *XkbActionTypeText(unsigned type, unsigned format); +char *XkbActionText(XkbDescPtr xkb, XkbAction *action, unsigned format); +char *XkbBehaviorText(XkbDescPtr xkb, XkbBehavior *behavior, unsigned format); + +#endif /* _XSERVER_XKB_XKBTEXT_PRIV_H */ diff --git a/xkb/xkmread.c b/xkb/xkmread.c index def60def8..cdcb443ba 100644 --- a/xkb/xkmread.c +++ b/xkb/xkmread.c @@ -24,19 +24,19 @@ ********************************************************/ -#ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> -#endif #include <stdio.h> - #include <X11/Xos.h> #include <X11/Xfuncs.h> - #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> #include <X11/extensions/XKMformat.h> + +#include "xkb/xkbfile_priv.h" +#include "xkb/xkbfmisc_priv.h" + #include "misc.h" #include "inputstr.h" #include "xkbstr.h" diff --git a/xorg-server.pc.in b/xorg-server.pc.in index 1de1c6c50..ffa639e3d 100644 --- a/xorg-server.pc.in +++ b/xorg-server.pc.in @@ -14,6 +14,7 @@ abi_extension=@abi_extension@ Name: xorg-server Description: Modular X.Org X Server +URL: https://gitlab.freedesktop.org/xorg/xserver/ Version: @PACKAGE_VERSION@ Requires.private: @SDK_REQUIRED_MODULES@ Cflags: -I${sdkdir} @symbol_visibility@ |