Compare commits

..

24 Commits

Author SHA1 Message Date
Matthieu Herrb 69f2ed24b2 Update MAINTAINERS : fix Matthieu's email 2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 4184c31986 scripts: get_maintainers.pl: fixup for xserver tree
The script checks for certain files in the kernel tree, so it needs to
be fixed up for working with xserver tree.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 861fc55e7c scripts: steal get_maintainer.pl from Linux kernel
This is a nice tool for finding the maintainers and mailing lists
for specific files/directories, and also suited for being called
by other tooling.

Copying it over as-is from the Linux tree. Subsequent commits will
tweak it for working with the Xserver tree.

X-Original-Commit: 0a8db05b571ad5b8d5c8774a004c0424260a90bd
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 881663aa5b MAINTAINERS: add entry for documentation
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 50e98ab247 MAINTAINERS: add entry for tests
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult e7034c0778 MAINTAINERS: add entry for OS layer
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 3662bca04e MAINTAINERS: add entry for misc extensions
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 3ed3f3017e MAINTAINERS: add entry for double buffer extension
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 73690c341a MAINTAINERS: add entry for pseudoramix subsystem
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult e05020951a MAINTAINERS: add entry for present extension
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 4ed8f1e82d MAINTAINERS: add entry for sync extension
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 254ff48524 MAINTAINERS: add entry for shadow extension
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult d9a41770dc MAINTAINERS: add entry for record extension
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 9f6f55c27d MAINTAINERS: add entry for Xwin server
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 72f7f051c7 MAINTAINERS: add entry for framebuffer subsystem
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 1c60b5c410 MAINTAINERS: comment out broken M: tags
get_maintainer.pl can't cope w/ ? in the M: tag, so comment them out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult edcd5b7f8f MAINTAINERS: add Jeremy Sequoia for Rootless and Xquartz
Jeremy told me he's practically maintainer of the Rootless subsystem as well
as Xquartz server, but this hasn't been formally accounted yet (he's already
recorded for MacOS port). So, let's tidy up our book-keeping an give him
the proper attribution for his work in this areas.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 4605fdc254 MAINTAINERS: add xorg-devel to Xwayland entry
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 3513ade990 MAINTAINERS: add second F tag for damage extension
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 54ea9d5e56 MAINTAINERS: add F tag for Configuration subsystem
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult bf7b145faf MAINTAINERS: drop entries for removed stuff
Since this file should reflect the actual reality of this tree,
it doesn't make sense keeping historical records in here. Therefore
dropping entries for stuff that has long been removed from Xserver
tree (or never had been part of it).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult ce53c903ea MAINTAINERS: drop non-xserver entries
Since this file is just meant for the Xserver itself (and also shall replace
the corresponding entries in xorg-docs repo), dropping everything that's
outside of this source tree.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult 7c3d16b936 MAINTAINERS: take Xnest maintainership
Picking up maintenance of Xnest and adding myself as maintainer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
Enrico Weigelt, metux IT consult d25383dac3 MAINTAINERS: copy over from xorg-docs
First step decoupling Xserver maintainers list from xorg-docs. Later commits
will drop every but the xserver tree itself. Once it's landed, xorg-docs
can just point over here.

Rationale:

* the Xserver itself already is a big project with lots of maintainers and
  evolving independently from other X packages.
* having this in a separate repo risk letting it run out of sync with actual
  reality, and even worse doesn't support having different maintainerships
  for different branches (eg. release lines, semi-forks, ...)
* having the xserver-related parts inside the Xserver tree makes it easier
  for tooling like get_maintainers.pl - eg. useful for finding maintainers
  or maillists for specific pathes
* clean code bases should be self-documenting, instead of spreading it to lots
  of external places (extra repos, wikis, etc)

X-Source-Commit: 9024082a504df81741a1b334963ff4842ffe934e
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 09:50:44 +00:00
1175 changed files with 53316 additions and 30183 deletions

View File

@ -1,24 +0,0 @@
# 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

View File

@ -1,65 +0,0 @@
name: 🐞 Bug report
description: Create a report to help us improve
labels: [bug, needs-triage]
#type: bug
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to help everyone identify and fix the bug. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: dropdown
id: affected-version
attributes:
label: Select the version
options:
- 25.0.0.X
- Git master branch
- other or don't know
default: 1
validations:
required: true
- type: textarea
id: description
attributes:
label: Describe your issue
placeholder: When I did X then Y happened.
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
placeholder: |
1. Start ...
2. Do this
3. Do that
validations:
required: true
- type: textarea
id: expected
attributes:
label: What did you expect?
placeholder: I expected this to happen.
- type: textarea
id: environment
attributes:
label: Additional Information
description: Additional information you want to provide such as logs, system info, environment, screenshots, etc.
placeholder: |
Add any other context about the bug here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xserver/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for reporting this issue! We will get back to you as soon as possible.

View File

@ -1,49 +0,0 @@
name: ✨ Feature request
description: Suggest a feature for this software
labels: [enhancement, needs-triage]
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to properly describe the new software feature you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: "Describe the feature"
placeholder: A thing in X that allows to do Y.
validations:
required: true
- type: textarea
id: rationale
attributes:
label: "It should be implemented because"
placeholder: Doing Y is needed for Z.
validations:
required: true
- type: textarea
id: alternative
attributes:
label: "What are the alternatives?"
placeholder: We could do A or B instead.
- type: textarea
id: context
attributes:
label: Additional context
description: Additional information you want to provide such as references to related issues or protocols, the implications on existing use cases, etc.
placeholder: |
Add any other context about the feature request here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xserver/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for your suggestion! Let's see together if it can be implemented.

View File

@ -1,50 +0,0 @@
name: 🔧 Code cleanup
description: Level up the source code
labels: [code-cleanup, needs-triage]
#type: codecleanup
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to properly describe the code cleanup you are suggesting. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: "Describe the cleanup"
placeholder: C in X needs to be changed into D.
validations:
required: true
- type: textarea
id: rationale
attributes:
label: "It should be done because"
placeholder: Having D is needed for E.
validations:
required: true
- type: textarea
id: alternative
attributes:
label: "What are the alternatives?"
placeholder: We could do A or B instead.
- type: textarea
id: context
attributes:
label: Additional context
description: Additional information you want to provide such as implications on existing code, how to ensure API/ABI stability, which tests are needed or to be run, related issues, etc.
placeholder: |
Add any other context about the cleanup here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xserver/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for looking at the source code! Let's see together how it can be improved.

View File

@ -1,39 +0,0 @@
name: 🔖 Documentation update
description: Make your mark for better documentation
labels: [documentation, needs-triage]
#type: docchange
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to help others understand our software. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: Describe the update
placeholder: These things need to be better documented.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Additional Information
description: Additional information you want to provide such as tickets related to changes in the software, affected files, screenshots, etc.
placeholder: |
Add any other context about the update here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xserver/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for requesting this update! We will get back to you as soon as possible.

View File

@ -1,44 +0,0 @@
name: ✅ Organizational task
description: Create a task for project organization
labels: [needs-triage, organization]
#type: task
body:
- type: markdown
attributes:
value: |
Please fill out the sections below to get organizational things done. If you have a general idea or question then please use the [discussions](https://github.com/orgs/X11Libre/discussions).
- type: textarea
id: description
attributes:
label: Describe the task
placeholder: These things need to be done.
validations:
required: true
- type: textarea
id: rationale
attributes:
label: "It should be done because"
placeholder: Doing Y is needed for Z.
- type: textarea
id: environment
attributes:
label: Additional Information
description: Additional information you want to provide such as the context for bigger tasks, the implicatons on existing workflows, related issues, etc.
placeholder: |
Add any other context about the task here.
- type: checkboxes
id: checks
attributes:
label: Extra fields
options:
- label: I have checked the existing [issues](https://github.com/X11Libre/xserver/issues)
required: true
- label: I have read the [Contributing Guidelines](https://github.com/X11Libre/xserver/blob/master/CONTRIBUTING.md)
required: true
- label: I'd like to work on this issue
- type: markdown
attributes:
value: |
Thanks for adding this task! We will get back to you as soon as possible.

View File

@ -1,8 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: XLibre Community Support
url: https://github.com/orgs/X11Libre/discussions
about: Please ask and answer questions here.
- name: Mailing List
url: https://www.freelists.org/list/xlibre
about: You can join the discussions on our mailing list.

View File

@ -1,32 +0,0 @@
#!/bin/bash
set -e
. .github/scripts/util.sh
export PKG_CONFIG_PATH="/usr/local/lib/x86_64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH"
export ACLOCAL_PATH="/usr/share/aclocal:/usr/local/share/aclocal"
export X11L_DRV_GIT=https://github.com/X11Libre/
mkdir -p $DRV_BUILD_DIR
cd $DRV_BUILD_DIR
build_drv_ac xf86-input-elographics $X11L_DRV_GIT/xf86-input-elographics master
build_drv_ac xf86-input-evdev $X11L_DRV_GIT/xf86-input-evdev master
build_drv_ac xf86-input-libinput $X11L_DRV_GIT/xf86-input-libinput master
build_drv_ac xf86-input-mouse $X11L_DRV_GIT/xf86-input-mouse master
build_drv_ac xf86-input-synaptics $X11L_DRV_GIT/xf86-input-synaptics master
build_drv_ac xf86-video-amdgpu $X11L_DRV_GIT/xf86-video-amdgpu xf86-video-amdgpu-23.0.0
build_drv_ac xf86-video-ati $X11L_DRV_GIT/xf86-video-ati xf86-video-ati-22.0.0
build_drv_ac xf86-video-intel $X11L_DRV_GIT/xf86-video-intel.git master
build_drv_ac xf86-video-nouveau $X11L_DRV_GIT/xf86-video-nouveau xf86-video-nouveau-1.0.18
build_drv_ac xf86-video-omap $X11L_DRV_GIT/xf86-video-omap master
build_drv_ac xf86-video-qxl $X11L_DRV_GIT/xf86-video-qxl master
build_drv_ac xf86-video-r128 $X11L_DRV_GIT/xf86-video-r128 master
build_drv_ac xf86-video-vesa $X11L_DRV_GIT/xf86-video-vesa xf86-video-vesa-2.6.0
build_drv_ac xf86-video-vmware $X11L_DRV_GIT/xf86-video-vmware xf86-video-vmware-13.4.0
# doesn't compile on Linux
# build_drv_ac xf86-input-mouse $X11L_DRV_GIT/xf86-input-mouse master
# build_drv_ac xf86-input-keyboard $X11L_DRV_GIT/xf86-input-keyboard master

View File

@ -1,13 +0,0 @@
export X11_OS=`uname -s`
export X11_PREFIX="${X11_PREFIX:-$HOME/x11}"
export X11_BUILD_DIR="${X11_BUILD_DIR:-$HOME/build-deps}"
export DRV_BUILD_DIR="${DRV_BUILD_DIR:-$HOME/build-drivers}"
case "$X11_OS" in
Darwin) export FDO_CI_CONCURRENT=`sysctl -n hw.logicalcpu` ;;
Linux) export FDO_CI_CONCURRENT=`nproc` ;;
esac
export PATH="$X11_PREFIX/bin:$PATH"
export PKG_CONFIG_PATH="$X11_PREFIX/lib/x86_64-linux-gnu/pkgconfig:$X11_PREFIX/lib/pkgconfig:$X11_PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"

View File

@ -1,34 +0,0 @@
#!/bin/bash
set -e
. .github/scripts/util.sh
mkdir -p $X11_BUILD_DIR
cd $X11_BUILD_DIR
build_meson rendercheck https://gitlab.freedesktop.org/xorg/test/rendercheck rendercheck-1.6
if [ "$X11_OS" = "Linux" ]; then
build_meson drm https://gitlab.freedesktop.org/mesa/drm libdrm-2.4.121 \
-Domap=enabled
fi
build_meson libxcvt https://gitlab.freedesktop.org/xorg/lib/libxcvt libxcvt-0.1.0
build_ac xorgproto https://gitlab.freedesktop.org/xorg/proto/xorgproto xorgproto-2024.1
if [ "$X11_OS" = "Linux" ]; then
build_meson wayland https://gitlab.freedesktop.org/wayland/wayland 1.21.0 \
-Dtests=false -Ddocumentation=false -Ddtd_validation=false
build_meson wayland-protocols https://gitlab.freedesktop.org/wayland/wayland-protocols 1.38
build_meson libdecor https://gitlab.freedesktop.org/libdecor/libdecor 0.1.1 \
-D{demo,install_demo}=false
build_meson libei https://gitlab.freedesktop.org/libinput/libei 1.0.0 \
-Dtests=disabled -Ddocumentation=[] -Dliboeffis=enabled
fi
if [ "$X11_OS" = "Darwin" ]; then
build_ac xset https://gitlab.freedesktop.org/xorg/app/xset xset-1.2.5
fi
build_ac_xts xts https://gitlab.freedesktop.org/xorg/test/xts master # dbbfa96c036e596346147081cbceda136e7c86c1
clone_source piglit https://gitlab.freedesktop.org/mesa/piglit main # 265896c86f90cb72e8f218ba6a3617fca8b9a1e3
echo '[xts]' > piglit/piglit.conf
echo "path=$X11_BUILD_DIR/xts" >> piglit/piglit.conf

View File

@ -1,38 +0,0 @@
#!/bin/sh
set -e
brew update
brew install \
autoconf \
automake \
bdftopcf \
libapplewm \
libtool \
libx11 \
libxau \
libxaw \
libxcb \
libxdmcp \
libxext \
libxfixes \
libxfont2 \
libxkbfile \
libxi \
libxmu \
libxrender \
libxt \
libxtst \
meson \
mkfontscale \
pkgconf \
pixman \
util-macros \
xdpyinfo \
xkbcomp \
xkeyboard-config \
xtrans
pip3 install --break-system-packages \
mako

View File

@ -1,95 +0,0 @@
#!/bin/bash
set -e
# Packages which are needed by this script, but not for the xserver build
EPHEMERAL="
libexpat-dev
libgles2-mesa-dev
libxkbcommon-dev
x11-utils
x11-xserver-utils
xauth
xvfb
"
apt-get update
apt-get install -y \
$EPHEMERAL \
autoconf \
automake \
build-essential \
ca-certificates \
libaudit-dev \
libbsd-dev \
libcairo2-dev \
libdbus-1-dev \
libdrm-dev \
libegl1-mesa-dev \
libepoxy-dev \
libevdev2 \
libexpat1 \
libffi-dev \
libgbm-dev \
libgcrypt-dev \
libgl1-mesa-dev \
libgles2 \
libglx-mesa0 \
libinput10 \
libinput-dev \
libnvidia-egl-wayland-dev \
libpciaccess-dev \
libpixman-1-dev \
libselinux1-dev \
libspice-protocol-dev \
libsystemd-dev \
libudev-dev \
libunwind-dev \
libx11-dev \
libx11-xcb-dev \
libxau-dev \
libxaw7-dev \
libxcb-glx0-dev \
libxcb-icccm4-dev \
libxcb-image0-dev \
libxcb-keysyms1-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-shm0-dev \
libxcb-util0-dev \
libxcb-xf86dri0-dev \
libxcb-xkb-dev \
libxcb-xv0-dev \
libxcb1-dev \
libxdmcp-dev \
libxext-dev \
libxfixes-dev \
libxfont-dev \
libxi-dev \
libxinerama-dev \
libxkbcommon0 \
libxkbfile-dev \
libxmu-dev \
libxmuu-dev \
libxpm-dev \
libxrender-dev \
libxres-dev \
libxshmfence-dev \
libxt-dev \
libxtst-dev \
libxv-dev \
mesa-common-dev \
meson \
nettle-dev \
libpango1.0-dev \
pkg-config \
x11-xkb-utils \
xfonts-utils \
xkb-data \
xtrans-dev \
xutils-dev \
libxaw7-dev \
python3-mako

View File

@ -1,161 +0,0 @@
#!/bin/bash
apt-mark auto \
7zip \
7zip-rar \
acl \
ant \
apache2 \
apache2-bin \
aria2 \
azure-cli \
brotli \
buildah \
chrony \
cifs-utils \
clang-format-16 \
clang-format-17 \
clang-format-18 \
clang-tidy-16 \
clang-tidy-17 \
clang-tidy-18 \
cloud-init \
dbus \
dotnet-sdk-8.0 \
eatmydata \
efibootmgr \
firefox \
fonts-noto-color-emoji \
gfortran \
gfortran-12 \
gfortran-13 \
gfortran-14 \
google-chrome-stable \
google-cloud-cli \
haveged \
keyutils \
kubectl \
libeatmydata1 \
libgmp-dev \
liblz4-dev \
libmysqlclient-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
libtss2-esys-3.0.2-0t64 \
libtss2-mu-4.0.1-0t64 \
libtss2-rc0t64 \
libwrap0 \
libyaml-dev \
lsscsi \
lz4 \
mediainfo \
mercurial \
microsoft-edge-stable \
mysql-client \
mysql-server \
ncurses-base \
ncurses-bin \
ncurses-term \
nginx \
nvme-cli \
packages-microsoft-prod \
php-pear \
php8.3 \
php8.3-amqp \
php8.3-apcu \
php8.3-bcmath \
php8.3-bz2 \
php8.3-cgi \
php8.3-cli \
php8.3-common \
php8.3-curl \
php8.3-dba \
php8.3-dev \
php8.3-enchant \
php8.3-fpm \
php8.3-gd \
php8.3-gmp \
php8.3-igbinary \
php8.3-imagick \
php8.3-imap \
php8.3-interbase \
php8.3-intl \
php8.3-ldap \
php8.3-mbstring \
php8.3-memcache \
php8.3-memcached \
php8.3-mongodb \
php8.3-mysql \
php8.3-odbc \
php8.3-opcache \
php8.3-pcov \
php8.3-pgsql \
php8.3-phpdbg \
php8.3-pspell \
php8.3-readline \
php8.3-redis \
php8.3-snmp \
php8.3-soap \
php8.3-sqlite3 \
php8.3-sybase \
php8.3-tidy \
php8.3-xdebug \
php8.3-xml \
php8.3-xsl \
php8.3-yaml \
php8.3-zip \
php8.3-zmq \
pigz \
podman \
pollinate \
postgresql-16 \
powershell \
python-babel-localedata \
python3-babel \
python3-dev \
python3-jinja2 \
python3-json-pointer \
python3-jsonpatch \
python3-jsonschema \
python3-markupsafe \
python3-parted \
python3-pyrsistent \
python3-serial \
python3-six \
python3-tz \
python3-venv \
rpm \
ruby-full \
session-manager-plugin \
shellcheck \
shim-signed \
skopeo \
snap \
snmp \
software-properties-common \
sphinxsearch \
sqlite3 \
swig \
sysstat \
systemd-coredump \
temurin-11-jdk \
temurin-17-jdk \
temurin-21-jdk \
temurin-8-jdk \
texinfo \
tk \
tree \
tzdata \
ubuntu-server \
ubuntu-standard \
unzip \
upx-ucl \
util-linux \
walinuxagent \
xvfb \
xz-utils \
zip \
zsync
apt-get autoremove -y

View File

@ -1,110 +0,0 @@
. .github/scripts/conf.sh
clone_source() {
local pkgname="$1"
local url="$2"
local ref="$3"
if [ ! -f $pkgname/.git/config ]; then
echo "need to clone $pkgname"
git clone $url $pkgname --branch=$ref --depth 1
else
echo "already cloned $pkgname"
fi
}
build_meson() {
local pkgname="$1"
local url="$2"
local ref="$3"
shift
shift
shift
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref"
(
cd $pkgname
meson "$@" build -Dprefix=$X11_PREFIX
ninja -j${FDO_CI_CONCURRENT:-4} -C build install
)
touch $X11_PREFIX/$pkgname.DONE
fi
}
build_ac() {
local pkgname="$1"
local url="$2"
local ref="$3"
shift
shift
shift
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref"
(
cd $pkgname
./autogen.sh --prefix=$X11_PREFIX
make -j${FDO_CI_CONCURRENT:-4} install
)
touch $X11_PREFIX/$pkgname.DONE
fi
}
build_drv_ac() {
local pkgname="$1"
local url="$2"
local ref="$3"
shift
shift
shift
clone_source "$pkgname" "$url" "$ref"
(
cd $pkgname
./autogen.sh # --prefix=$X11_PREFIX
make -j${FDO_CI_CONCURRENT:-4} # install
)
}
build_ac_xts() {
local pkgname="$1"
local url="$2"
local ref="$3"
shift
shift
shift
if [ -f $X11_PREFIX/$pkgname.DONE ]; then
echo "package $pkgname already built"
else
clone_source "$pkgname" "$url" "$ref"
(
cd $pkgname
CFLAGS='-fcommon'
if [ "$X11_OS" = "Darwin" ]; then
# xts5/include/XtTest.h includes <X11/Intrinsic.h> => needs xt
# xts5/src/libXtaw/*.c include <X11/Xaw/*.h> and <X11/Xmu/*.h> => need xmu and xaw7
sed -E -i~ 's|(\[XTS\], \[)|\1xt xmu xaw7 |' configure.ac
# xts5/Xlib14/X{mb,wc}TextListToTextProperty.m define a function accepting `XTextProperty` but call it passing
#`XTextProperty*`; since the parameter is seemingly meant for output, accept it as pointer
sed -E -i~ -e 's|(XTextProperty)[[:space:]]+(text_prop_good)|\1 *\2|' -e 's|(style_good),[[:space:]]*&(text_prop_good)|\1,\2|' -e 's|text_prop_good\.|text_prop_good->|' xts5/Xlib14/X{mb,wc}TextListToTextProperty.m
# xts5/Xlib*/*.m forward-declare `strcpy()` which is incompatible with _FORTIFY_SOURCE > 0 where `strcpy` is
# a macro; set _FORTIFY_SOURCE to 0 as we don't care much about security in this test code
CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"
# declarations for `XtAppSetError{,Msg}Handler()` in <X11/Intrinsic.h> (libXt) make it hard to write warning-
# free code: they want a noreturn-annotated handler as input but return old handler without noreturn annotation,
# so e.g. `XtAppSetErrorHandler(XtAppSetErrorHandler(NULL))` (similar to xts5/Xt13/XtAppSetError*Handler.m)
# doesn't compile complaining about incompatible function pointers, at least with Apple Clang 16 (not sure why
# it treats this warning as error by default though)
if cc -Werror=unknown-warning-option -Wincompatible-function-pointer-types -c -xc -o /dev/null /dev/null 2>/dev/null; then
CFLAGS="$CFLAGS -Wno-error=incompatible-function-pointer-types"
fi
fi
./autogen.sh --prefix=$X11_PREFIX CFLAGS="$CFLAGS"
make -j${FDO_CI_CONCURRENT:-4} install
)
touch $X11_PREFIX/$pkgname.DONE
fi
}

View File

@ -1,182 +0,0 @@
name: Build X servers
permissions:
contents: read
env:
MESON_BUILDDIR: "build"
X11_PREFIX: /home/runner/x11
X11_BUILD_DIR: /home/runner/build-deps
on:
push:
pull_request:
jobs:
xserver-build-ubuntu:
env:
MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=true -Dwerror=false -Dxcsecurity=true -Dxorg=true -Dxvfb=true -Dxnest=true
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: prepare build environment
run: |
MACHINE=`gcc -dumpmachine`
echo "MACHINE=$MACHINE" >> "$GITHUB_ENV"
echo "PKG_CONFIG_PATH=$X11_PREFIX/share/pkgconfig:$X11_PREFIX/lib/$MACHINE/pkgconfig:$X11_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" >> "$GITHUB_ENV"
sudo chown root /bin/tar && sudo chmod u+s /bin/tar
- name: apt cache
uses: actions/cache@v4
with:
path: /var/cache/apt
key: apt-cache-${{ hashFiles('.github/scripts/ubuntu/install-pkg.sh') }}
restore-keys: apt-cache-
- name: pkg install
run: sudo .github/scripts/ubuntu/install-pkg.sh
- name: X11 prereq cache
uses: actions/cache@v4
with:
path: |
${{ env.X11_PREFIX }}
${{ env.X11_BUILD_DIR }}/xts
${{ env.X11_BUILD_DIR }}/piglit
key: ${{ runner.name }}-x11-deps-${{ hashFiles('.github/scripts/install-prereq.sh') }}
restore-keys: ${{ runner.name }}-x11-deps-
- name: generic prereq
run: .github/scripts/install-prereq.sh
- name: build
run: .gitlab-ci/meson-build.sh
- name: tests (may fail)
continue-on-error: true
run: meson test -C "${{ env.MESON_BUILDDIR }}" --print-errorlogs || true
env:
XTEST_DIR: ${{ env.X11_BUILD_DIR }}/xts
PIGLIT_DIR: ${{ env.X11_BUILD_DIR }}/piglit
- name: archive build logs
uses: actions/upload-artifact@v4
with:
name: build-logs
path: |
build/meson-logs/*
- name: ddx build check
run: .gitlab-ci/check-ddx-build.sh
- name: manpage check
run: .gitlab-ci/manpages-check
drivers-build-ubuntu:
env:
MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=false -Dwerror=false -Dxcsecurity=false -Dxorg=true -Dxvfb=false -Dxnest=false
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: prepare build environment
run: |
MACHINE=`gcc -dumpmachine`
echo "MACHINE=$MACHINE" >> "$GITHUB_ENV"
echo "PKG_CONFIG_PATH=$X11_PREFIX/share/pkgconfig:$X11_PREFIX/lib/$MACHINE/pkgconfig:$X11_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" >> "$GITHUB_ENV"
sudo chown root /bin/tar && sudo chmod u+s /bin/tar
- name: apt cache
uses: actions/cache@v4
with:
path: /var/cache/apt
key: apt-cache-${{ hashFiles('.github/scripts/ubuntu/install-pkg.sh') }}
restore-keys: apt-cache-
- name: pkg install
run: sudo .github/scripts/ubuntu/install-pkg.sh
- name: X11 prereq cache
uses: actions/cache@v4
with:
path: |
${{ env.X11_PREFIX }}
${{ env.X11_BUILD_DIR }}/xts
${{ env.X11_BUILD_DIR }}/piglit
key: ${{ runner.name }}-x11-deps-${{ hashFiles('.github/scripts/install-prereq.sh') }}
restore-keys: ${{ runner.name }}-x11-deps-
- name: generic prereq
run: .github/scripts/install-prereq.sh
- name: build xserver sdk
run: |
echo -n > .meson_environment
echo "export MESON_BUILDDIR=$MESON_BUILDDIR" >> .meson_environment
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> .meson_environment
.gitlab-ci/meson-build.sh --skip-test
sudo meson install --no-rebuild -C "$MESON_BUILDDIR"
sudo mkdir -p /usr/local/lib/$MACHINE/xorg/modules # /home/runner/x11/lib/xorg/modules
sudo chown -R runner /usr/local/lib/$MACHINE/xorg/modules # /home/runner/x11/lib/xorg/modules
- name: compile drivers
run: .github/scripts/compile-drivers.sh
xserver-build-macos:
env:
MESON_ARGS: -Dprefix=/tmp -Dglx=false -Dxnest=false
X11_PREFIX: /Users/runner/x11
X11_BUILD_DIR: /Users/runner/build-deps
runs-on: macos-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: prepare build environment
run: |
echo "PKG_CONFIG_PATH=$X11_PREFIX/share/pkgconfig:$X11_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" >> "$GITHUB_ENV"
- name: homebrew cache
uses: actions/cache@v4
with:
path: /Users/runner/Library/Caches/Homebrew
key: ${{ runner.os }}-homebrew-cache-${{ hashFiles('.github/scripts/macos/install-pkg.sh') }}
restore-keys: ${{ runner.os }}-homebrew-cache-
- name: pkg install
run: .github/scripts/macos/install-pkg.sh
- name: X11 prereq cache
uses: actions/cache@v4
with:
path: |
${{ env.X11_PREFIX }}
${{ env.X11_BUILD_DIR }}/xts
${{ env.X11_BUILD_DIR }}/piglit
key: ${{ runner.os }}-x11-deps-${{ hashFiles('.github/scripts/install-prereq.sh') }}
restore-keys: ${{ runner.os }}-x11-deps-
- name: generic prereq
run: .github/scripts/install-prereq.sh
- name: build
run: .gitlab-ci/meson-build.sh
- name: tests (may fail)
continue-on-error: true
run: meson test -C "${{ env.MESON_BUILDDIR }}" --print-errorlogs -j1 || true
env:
XTEST_DIR: ${{ env.X11_BUILD_DIR }}/xts
PIGLIT_DIR: ${{ env.X11_BUILD_DIR }}/piglit
- name: archive build logs
uses: actions/upload-artifact@v4
with:
name: build-logs-macos
path: |
build/meson-logs/*
- name: ddx build check
run: .gitlab-ci/check-ddx-build.sh
- name: manpage check
run: .gitlab-ci/manpages-check

View File

@ -4,7 +4,7 @@
# Please see the ci-templates documentation for details: # Please see the ci-templates documentation for details:
# https://freedesktop.pages.freedesktop.org/ci-templates/ # https://freedesktop.pages.freedesktop.org/ci-templates/
.templates_sha: &template_sha ef5e4669b7500834a17ffe9277e15fbb6d977fff # see https://docs.gitlab.com/ee/ci/yaml/#includefile .templates_sha: &template_sha c5626190ec14b475271288dda7a7dae8dbe0cd76 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
# FDO_DISTRIBUTION_TAG is the tag of the docker image used for the build jobs. # 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. # If the image doesn't exist yet, the docker-image stage generates it.
@ -16,29 +16,23 @@
# gcc/clang or other packages, which might break the build with older commits # gcc/clang or other packages, which might break the build with older commits
# using the same tag. # using the same tag.
variables: variables:
FDO_UPSTREAM_REPO: 'xorg/xserver' FDO_UPSTREAM_REPO: xorg/xserver
MESON_BUILDDIR: 'build' FDO_DISTRIBUTION_VERSION: bullseye-slim
REPO_URL_XORGPROTO: 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/debian-install.sh'
XORG_DEBIAN_VERSION: 'bullseye-slim' FDO_DISTRIBUTION_TAG: "2023-06-20-libei.0"
XORG_DEBIAN_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/debian-install.sh'
XORG_DEBIAN_TAG: '2025-03-07-libdrm.1'
XORG_FREEBSD_VERSION: '14.2'
XORG_FREEBSD_EXEC: ''
XORG_FREEBSD_TAG: '2025-05-27-xcb'
include: include:
- project: 'freedesktop/ci-templates' - project: 'freedesktop/ci-templates'
ref: *template_sha ref: *template_sha
file: file: '/templates/debian.yml'
- '/templates/debian.yml' - project: 'freedesktop/ci-templates'
- '/templates/freebsd.yml' ref: *template_sha
- '/templates/ci-fairy.yml' file: '/templates/ci-fairy.yml'
- template: Security/SAST.gitlab-ci.yml - template: Security/SAST.gitlab-ci.yml
stages: stages:
- docker-image - docker-image
- build-and-test - build-and-test
- drivers
- test - test
.ci-run-policy: .ci-run-policy:
@ -50,109 +44,25 @@ stages:
# Cancel CI run if a newer commit is pushed to the same branch # Cancel CI run if a newer commit is pushed to the same branch
interruptible: true interruptible: true
# This is everything but the DDXen
.dix_paths: &dix_paths
# Directories
- .gitlab-ci/**/*
- composite/**/*
- config/**/*
- damageext/**/*
- dbe/**/*
- dix/**/*
- doc/**/*
- dri3/**/*
- exa/**/*
- fb/**/*
- glamor/**/*
- glx/**/*
- include/**/*
- m4/**/*
- man/**/*
- mi/**/*
- miext/**/*
- os/**/*
- present/**/*
- pseudoramiX/**/*
- randr/**/*
- record/**/*
- render/**/*
- test/**/*
- Xext/**/*
- xfixes/**/*
- Xi/**/*
- xkb/**/*
# Files
- hw/meson.build
- .gitlab-ci.yml
- meson*
- xorg-server.m4
- xorg-server.pc.in
- xserver.ent.in
.xorg_paths: &xorg_paths
- hw/xfree86/**/*
.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 libxvmc xcb-util xcb-util-wm'
FDO_IMAGE_SIZE: '30G'
debian-bullseye: debian-bullseye:
extends: extends:
- .fdo.container-build@debian - .fdo.container-build@debian
- .ci-run-policy - .ci-run-policy
- .debian
stage: docker-image stage: docker-image
variables: variables:
GIT_STRATEGY: none GIT_STRATEGY: none
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: .common-build-and-test:
extends: extends:
- .xorg-image@debian - .fdo.distribution-image@debian
- .ci-run-policy - .ci-run-policy
stage: build-and-test stage: build-and-test
artifacts: artifacts:
when: always when: always
paths: paths:
- $MESON_BUILDDIR/meson-logs/ - build/meson-logs/
- $MESON_BUILDDIR/test/piglit-results/ - build/test/piglit-results/
variables: variables:
MESON_ARGS: -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=true -Dwerror=true -Dxcsecurity=true -Dxv=true -Dxvmc=true
CCACHE_COMPILERCHECK: content CCACHE_COMPILERCHECK: content
CCACHE_DIR: /cache/xserver/cache CCACHE_DIR: /cache/xserver/cache
LC_ALL: C.UTF-8 LC_ALL: C.UTF-8
@ -166,202 +76,54 @@ freebsd-image:
meson: meson:
extends: .common-build-and-test extends: .common-build-and-test
script: script:
- .gitlab-ci/meson-build.sh --run-test - .gitlab-ci/build-and-test.sh
- .gitlab-ci/check-piglit-results.sh
- .gitlab-ci/manpages-check - .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: >
-Dxorg=${BUILD_XORG} -Dxephyr=${BUILD_XEPHYR} -Dxvfb=${BUILD_XVFB} -Dxnest=${BUILD_XNEST}
BUILD_XEPHYR: true
BUILD_XNEST: true
BUILD_XORG: true
BUILD_XVFB: true
MESON_EXTRA_ARGS: ${MESON_DDX_BUILD_ARGS}
meson-noglamor: meson-noglamor:
extends: meson extends: meson
variables: variables:
MESON_EXTRA_ARGS: -Dglamor=false ${MESON_DDX_BUILD_ARGS} MESON_EXTRA_OPTIONS: >
-Dglamor=false
meson-nolibdecor:
extends: meson
variables:
MESON_EXTRA_OPTIONS: >
-Dlibdecor=false
mingw-cross-build: mingw-cross-build:
extends: .common-build-and-test extends: .common-build-and-test
script: script:
- .gitlab-ci/meson-build.sh --run-install - meson --cross-file=.gitlab-ci/cross-i686-w64-mingw32.txt -Dglx=false -Dsecure-rpc=false -Dlisten_tcp=true build/
variables: - ninja -j${FDO_CI_CONCURRENT:-4} -C build/ install
MESON_ARGS: --cross-file=.gitlab-ci/cross-i686-w64-mingw32.txt -Dglx=false -Dlisten_tcp=true -Dxvmc=true -Dxv=true
freebsd:
stage: build-and-test
extends:
- .xorg-image@freebsd
variables:
MESON_ARGS: -Dglx=false -Dglamor=false -Dudev=false -Dudev_kms=false -Dxvmc=true -Dxv=true
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 extra packages, as long as image cant be rebuilt
- /app/vmctl exec "pkg update && pkg add libxvmc xcb-util xcb-util-wm"
# 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: meson-dist:
extends: .common-build-and-test extends: .common-build-and-test
artifacts: artifacts:
when: always when: always
paths: paths:
- $MESON_BUILDDIR/meson-logs/ - build/meson-logs/
- $MESON_BUILDDIR/xserver-*/$MESON_BUILDDIR/meson-logs/ - build/xserver-*/build/meson-logs/
- xserver-tarball/install/
script: script:
- .gitlab-ci/meson-build.sh --run-dist - .gitlab-ci/dist.sh
- mkdir xserver-tarball
- tar xf $MESON_BUILDDIR/meson-dist/xserver-*.tar.xz -C xserver-tarball --strip-components=1
- .gitlab-ci/meson-build.sh -C xserver-tarball --skip-test --skip-dist --run-install
variables:
MESON_DIST_ARGS: --no-tests
MESON_EXTRA_ARGS: -Dprefix=$CI_PROJECT_DIR/xserver-tarball/install/
xf86-driver-build-test: #
# Verify that commit messages are as expected
#
check-commits:
extends: extends:
- .xorg-image@debian - .fdo.ci-fairy
- .ci-run-policy stage: test
stage: drivers
parallel:
matrix:
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-elographics
SHA: xf86-input-elographics-1.4.4
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev
SHA: xf86-input-evdev-2.11.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-joystick
SHA: fa296d27fb479107fa6328a7565f665de2de98d3 # 5 commits ahead of 1.6.4
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput
SHA: xf86-input-libinput-1.5.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-mouse
SHA: xf86-input-mouse-1.9.5
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-synaptics
SHA: xf86-input-synaptics-1.10.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-vmmouse
SHA: 3bbcb6a143bb3f53e5b776fb70a4933229c1781a # 2 commits ahead of 13.2.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-input-void
SHA: b43e11eeb8b96aa87da910991da8b005d9847783 # 4 commits ahead of 1.4.2
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu
SHA: 2cb59a92de4a19909682a35e4f31f3c02de2899f # 18 commits ahead of 23.0.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-apm
SHA: 196784e691b8f8739792439434ffa002e9f5cdfa # 14 commits ahead of 1.3.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-ark
SHA: 109745d5c7e6982ee0dabbc5a233c1f2667ad5c9 # 9 commits ahead of 0.7.4
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-ast
SHA: db56de34bdf70f1904dba50d98774aaa950a2ca5 # 10 commits ahead of 1.1.6
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-ati
SHA: c610c037369500089baddd86aa3cf8046f3dc48b # 11 commits ahead of 22.0.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-chips
SHA: 4503aece04cc8860df18ce946633b5449a0cb47b # 7 commits ahead of 1.5.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-cirrus
SHA: 15d68316524c593bd67a6ea59b5c746a94c6c1f6 # 10 commits ahead of 1.6.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-dummy
SHA: 3a407a34c4a2b6b263a535b6aa7b49dd70784fdf # 9 commits ahead of 0.4.1
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-fbdev
SHA: c8d9f3be7e95689d793bb2f45a5dddf409e46811 # 15 commits ahead of 0.5.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-i128
SHA: 4fd0309834deca78e5ef6cad5ecba8864a308ba5 # 7 commits ahead of 1.4.1
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-i740
SHA: d610334264e82a18477b9a5c3a4095c49c18f47b # 11 commits ahead of 1.4.0
- REPO: https://gitlab.freedesktop.org/metux/xf86-video-intel
SHA: submit/fixes-for-xserver # temporary
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-mach64
SHA: 878048e3aec04c6bb8034f21afdfff37e3528c5f # 20 commits ahead of 6.9.7
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-mga
SHA: 66ee371516c48c30b67684317a8e3c24ba7f1f4e # 11 commits ahead of 2.0.1
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-neomagic
SHA: 69cafdeebf7c338ede076424f9bcb97f26ede7a8 # 8 commits ahead of 1.3.1
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-nested
SHA: 86b6dc3bb6d78f40905ecc63df3635b284214836 # no release yet
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-nouveau
SHA: xf86-video-nouveau-1.0.18
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-nv
SHA: a8608636da97fdd880edb1bce919a0d3029f24dd # 15 commits ahead of 2.1.23
- REPO: https://gitlab.freedesktop.org/metux/xf86-video-qxl
SHA: incubate # temporary
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-r128
SHA: bc21fcdffa623bb8e7150e1da69aeaed6cd7c5d2 # 1 commits ahead of 6.13.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-rendition
SHA: 49d50f1fdeb4dc81895fec81be9fae1dc78e5974 # 14 commits ahead of 4.2.7
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-s3virge
SHA: 8834f100114ba136d52590e711054ab063306421 # 11 commits ahead of 1.11.1
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-savage
SHA: 09f6c06f0a793c7d297f152227b551c128f20875 # 8 commits ahead of 2.4.1
- REPO: https://gitlab.freedesktop.org/metux/xf86-video-siliconmotion
SHA: incubate # temporary
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-sis
SHA: ee451146c0afd735b50488588f82f3f158e9da03 # 68 commits ahead of 0.12.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-sisusb
SHA: ccff93b681968463d00793a9a7c5c2db8301634f # 30 commits ahead of 0.12.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-suncg14
SHA: 471e04fe84abaf2f868fb85566d99495142692a9 # 9 commits ahead of 1.1.3
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-suncg3
SHA: 8162844221f6d59e540c3c3a146a9c581d413949 # 9 commits ahead of 1.1.3
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-suncg6
SHA: 37a28d0d9dbb9b0c6631aa7b09d558d5f552c627 # 10 commits ahead of 1.1.3
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-sunffb
SHA: 6100635debdda392ca420e87c5b0d70bd22dfed8 # 14 commits ahead of 1.2.3
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-sunleo
SHA: 6d56a007f3d47fa43e95f1a0c8619be00b0c1c97 # 10 commits ahead of 1.2.3
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-suntcx
SHA: c1c0e384b95da18b81793612b90f693891f2e476 # 9 commits ahead of 1.1.3
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-tdfx
SHA: 5253278119a4db07b5a01856f0de34e576f4dcdd # 9 commits ahead of 1.5.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-trident
SHA: fddaa2084b9aac51a845ee1ede8c498cbc9330cf # 13 commits ahead of 1.4.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-v4l
SHA: eb1e55874cbacf7455f70269581a877e88e3bf37 # 15 commits ahead of 0.3.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-vbox
SHA: ec4bc6b8e9d1a83526573d27afd099debbd5b86b # 7 commits ahead of 1.0.1
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-vesa
SHA: 5b33e95acb831768c52d491de079a1adcae762e0 # 10 commits ahead of 2.6.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-vmware
SHA: 92cc4534146dd84c0d843759cdb30f75abddddd6 # 6 commits ahead 13.4.0
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-voodoo
SHA: c70353ddf49d557c596a47b835b6b8d8bbe35ebe # 15 commits ahead of 1.2.6
- REPO: https://gitlab.freedesktop.org/xorg/driver/xf86-video-xgi
SHA: e73ff14a7f1b7562ff447aad527641cc35f557ae # 49 commits ahead 1.6.1
script: script:
# built xserver is taken from meson-dist job - ci-fairy check-commits --junit-xml=results.xml
- export PKG_CONFIG_PATH=$(pwd)/xserver-tarball/install/lib/x86_64-linux-gnu/pkgconfig except:
- export ACLOCAL_PATH=$(pwd)/xserver-tarball/install/share/aclocal/ - master@xorg/xserver
- unset MESON_EXTRA_ARGS
- DRIVER=$(basename $REPO)
- git clone "$REPO" "$DRIVER"
- git -C "$DRIVER" checkout "$SHA"
- |
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-dist
dependencies:
- meson-dist
variables: variables:
GIT_DEPTH: 1 GIT_DEPTH: 100
MESON_ARGS: -Dprefix=/usr/ artifacts:
MESON_EXTRA_ARGS: -Dxnest=false -Dxvfb=false -Dxquartz=false -Ddocs=false reports:
junit: results.xml
allow_failure: true
# #
# Verify that the merge request has the allow-collaboration checkbox ticked # Verify that the merge request has the allow-collaboration checkbox ticked
@ -369,10 +131,7 @@ xf86-driver-build-test:
check-merge-request: check-merge-request:
extends: extends:
- .fdo.ci-fairy - .fdo.ci-fairy
needs: []
stage: test stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script: script:
- ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
artifacts: artifacts:

31
.gitlab-ci/build-and-test.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
set -e
set -o xtrace
check_piglit_results ()
{
local EXPECTED_RESULTS=build/test/piglit-results/$1
local DEPENDENCY=build/$2
if ! test -e $DEPENDENCY; then
return
fi
if test -e $EXPECTED_RESULTS; then
return
fi
echo Expected $EXPECTED_RESULTS does not exist
exit 1
}
meson -Dc_args="-fno-common" -Dprefix=/usr -Dxephyr=true -Dwerror=true $MESON_EXTRA_OPTIONS build/
export PIGLIT_DIR=/root/piglit XTEST_DIR=/root/xts LP_NUM_THREADS=0
ninja -j${FDO_CI_CONCURRENT:-4} -C build/
meson test --num-processes ${FDO_CI_CONCURRENT:-4} --print-errorlogs -C build/
check_piglit_results xephyr-glamor hw/kdrive/ephyr/Xephyr.p/ephyr_glamor.c.o
check_piglit_results xvfb hw/vfb/Xvfb
check_piglit_results xwayland hw/xwayland/Xwayland

View File

@ -1,25 +0,0 @@
#!/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_XQUARTZ" == true ]] && check_executable "hw/xquartz/mach-startup/Xquartz"
[[ "$BUILD_XVFB" == true ]] && check_executable "hw/vfb/Xvfb"
exit 0

View File

@ -1,29 +0,0 @@
#!/bin/bash
set -e
set -o xtrace
if [[ -z "$MESON_BUILDDIR" ]]; then
echo "\$MESON_BUILDDIR not set"
exit 1
fi
check_piglit_results ()
{
local EXPECTED_RESULTS="$MESON_BUILDDIR"/test/piglit-results/$1
local DEPENDENCY="$MESON_BUILDDIR"/$2
if ! test -e $DEPENDENCY; then
return
fi
if test -e $EXPECTED_RESULTS; then
return
fi
echo Expected $EXPECTED_RESULTS does not exist
exit 1
}
check_piglit_results xephyr-glamor hw/kdrive/ephyr/Xephyr.p/ephyr_glamor.c.o
check_piglit_results xvfb hw/vfb/Xvfb

View File

@ -11,7 +11,7 @@ HOST=$1
cat >/usr/local/bin/${HOST}-pkg-config <<EOF cat >/usr/local/bin/${HOST}-pkg-config <<EOF
#!/bin/sh #!/bin/sh
PKG_CONFIG_SYSROOT_DIR=/usr/${HOST} PKG_CONFIG_LIBDIR=/usr/${HOST}/lib/pkgconfig:/usr/${HOST}/share/pkgconfig pkg-config \$@ PKG_CONFIG_SYSROOT_DIR=/usr/${HOST} PKG_CONFIG_LIBDIR=/usr/${HOST}/lib/pkgconfig:/usr/share/pkgconfig pkg-config \$@
EOF EOF
chmod +x /usr/local/bin/${HOST}-pkg-config chmod +x /usr/local/bin/${HOST}-pkg-config
@ -49,7 +49,7 @@ build 'https://gitlab.freedesktop.org/pixman/pixman.git' 'pixman-0.38.4'
build 'https://gitlab.freedesktop.org/xorg/lib/pthread-stubs.git' '0.4' build 'https://gitlab.freedesktop.org/xorg/lib/pthread-stubs.git' '0.4'
# we can't use the xorgproto pkgconfig files from /usr/share/pkgconfig, because # we can't use the xorgproto pkgconfig files from /usr/share/pkgconfig, because
# these would add -I/usr/include to CFLAGS, which breaks cross-compilation # these would add -I/usr/include to CFLAGS, which breaks cross-compilation
build 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' 'xorgproto-2024.1' '--datadir=/lib' build 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' 'xorgproto-2023.2' '--datadir=/lib'
build 'https://gitlab.freedesktop.org/xorg/lib/libXau.git' 'libXau-1.0.9' build 'https://gitlab.freedesktop.org/xorg/lib/libXau.git' 'libXau-1.0.9'
build 'https://gitlab.freedesktop.org/xorg/proto/xcbproto.git' 'xcb-proto-1.14.1' build 'https://gitlab.freedesktop.org/xorg/proto/xcbproto.git' 'xcb-proto-1.14.1'
build 'https://gitlab.freedesktop.org/xorg/lib/libxcb.git' 'libxcb-1.14' build 'https://gitlab.freedesktop.org/xorg/lib/libxcb.git' 'libxcb-1.14'
@ -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/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/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/libXfixes.git' 'libXfixes-5.0.3'
build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-util.git' 'xcb-util-0.4.1-gitlab' build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-util.git' '0.4.0'
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-image.git' '0.4.0'
build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-wm.git' 'xcb-util-wm-0.4.2' build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-wm.git' '0.4.1'
# workaround xcb_windefs.h leaking all Windows API types into X server build # 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 # (some of which clash which types defined by Xmd.h) XXX: This is a bit of a

View File

@ -6,8 +6,10 @@ set -o xtrace
# Packages which are needed by this script, but not for the xserver build # Packages which are needed by this script, but not for the xserver build
EPHEMERAL=" EPHEMERAL="
libcairo2-dev libcairo2-dev
libevdev-dev
libexpat-dev libexpat-dev
libgles2-mesa-dev libgles2-mesa-dev
libinput-dev
libxkbcommon-dev libxkbcommon-dev
x11-utils x11-utils
x11-xserver-utils x11-xserver-utils
@ -15,10 +17,6 @@ EPHEMERAL="
xvfb xvfb
" "
# 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
apt-get install -y \ apt-get install -y \
$EPHEMERAL \ $EPHEMERAL \
autoconf \ autoconf \
@ -36,6 +34,7 @@ apt-get install -y \
libcairo2 \ libcairo2 \
libcairo2-dev \ libcairo2-dev \
libdbus-1-dev \ libdbus-1-dev \
libdmx-dev \
libdrm-dev \ libdrm-dev \
libegl1-mesa-dev \ libegl1-mesa-dev \
libepoxy-dev \ libepoxy-dev \
@ -48,24 +47,21 @@ apt-get install -y \
libgles2 \ libgles2 \
libglx-mesa0 \ libglx-mesa0 \
libinput10 \ libinput10 \
libinput-dev \ libnvidia-egl-wayland-dev \
libpango1.0-0 \ libpango1.0-0 \
libpango1.0-dev \ libpango1.0-dev \
libpciaccess-dev \ libpciaccess-dev \
libpixman-1-dev \ libpixman-1-dev \
libselinux1-dev \ libselinux1-dev \
libspice-protocol-dev \
libsystemd-dev \ libsystemd-dev \
libtool \ libtool \
libudev-dev \ libudev-dev \
libunwind-dev \ libunwind-dev \
libwayland-dev \
libx11-dev \ libx11-dev \
libx11-xcb-dev \ libx11-xcb-dev \
libxau-dev \ libxau-dev \
libxaw7-dev \ libxaw7-dev \
libxcb-damage0-dev \
libxcb-dri2-0-dev \
libxcb-dri3-dev \
libxcb-glx0-dev \ libxcb-glx0-dev \
libxcb-icccm4-dev \ libxcb-icccm4-dev \
libxcb-image0-dev \ libxcb-image0-dev \
@ -75,15 +71,11 @@ apt-get install -y \
libxcb-render0-dev \ libxcb-render0-dev \
libxcb-shape0-dev \ libxcb-shape0-dev \
libxcb-shm0-dev \ libxcb-shm0-dev \
libxcb-sync-dev \
libxcb-util0-dev \ libxcb-util0-dev \
libxcb-xf86dri0-dev \ libxcb-xf86dri0-dev \
libxcb-xinput-dev \
libxcb-xkb-dev \ libxcb-xkb-dev \
libxcb-xv0-dev \ libxcb-xv0-dev \
libxcb1-dev \ libxcb1-dev \
libxcursor-dev \
libxdamage-dev \
libxdmcp-dev \ libxdmcp-dev \
libxext-dev \ libxext-dev \
libxfixes-dev \ libxfixes-dev \
@ -95,20 +87,15 @@ apt-get install -y \
libxmu-dev \ libxmu-dev \
libxmuu-dev \ libxmuu-dev \
libxpm-dev \ libxpm-dev \
libxrandr-dev \
libxrender-dev \ libxrender-dev \
libxres-dev \ libxres-dev \
libxshmfence-dev \ libxshmfence-dev \
libxss-dev \
libxt-dev \ libxt-dev \
libxtst-dev \ libxtst-dev \
libxv-dev \ libxv-dev \
libxvmc-dev \
libxxf86vm-dev \
libz-mingw-w64-dev \ libz-mingw-w64-dev \
linux-libc-dev/bullseye-backports \
mesa-common-dev \ mesa-common-dev \
meson/bullseye-backports \ meson \
mingw-w64-tools \ mingw-w64-tools \
nettle-dev \ nettle-dev \
pkg-config \ pkg-config \
@ -117,7 +104,6 @@ apt-get install -y \
python3-mako \ python3-mako \
python3-numpy \ python3-numpy \
python3-six \ python3-six \
valgrind \
weston \ weston \
x11-xkb-utils \ x11-xkb-utils \
xfonts-utils \ xfonts-utils \
@ -129,8 +115,8 @@ apt-get install -y \
cd /root cd /root
# drm 2.4.116 for drmSyncobjEventfd # Xwayland requires drm 2.4.109 for drmGetDeviceFromDevId
git clone https://gitlab.freedesktop.org/mesa/drm --depth 1 --branch=libdrm-2.4.121 git clone https://gitlab.freedesktop.org/mesa/drm --depth 1 --branch=libdrm-2.4.109
cd drm cd drm
meson _build meson _build
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
@ -145,14 +131,46 @@ ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd .. cd ..
rm -rf libxcvt rm -rf libxcvt
# xserver requires xorgproto >= 2024.1 # xserver requires xorgproto >= 2023.2 for XWAYLAND
git clone https://gitlab.freedesktop.org/xorg/proto/xorgproto.git --depth 1 --branch=xorgproto-2024.1 git clone https://gitlab.freedesktop.org/xorg/proto/xorgproto.git --depth 1 --branch=xorgproto-2023.2
pushd xorgproto pushd xorgproto
./autogen.sh ./autogen.sh
make -j${FDO_CI_CONCURRENT:-4} install make -j${FDO_CI_CONCURRENT:-4} install
popd popd
rm -rf xorgproto rm -rf xorgproto
# wayland-protocols requires wayland-scanner 1.20, but Debian bullseye has 1.18 only
git clone https://gitlab.freedesktop.org/wayland/wayland.git --depth 1 --branch=1.21.0
cd wayland
meson -Dtests=false -Ddocumentation=false -Ddtd_validation=false _build
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
rm -rf wayland
# Xwayland requires wayland-protocols >= 1.30, but Debian bullseye has 1.20 only
git clone https://gitlab.freedesktop.org/wayland/wayland-protocols.git --depth 1 --branch=1.30
cd wayland-protocols
meson _build
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
rm -rf wayland-protocols
# Install libdecor for Xwayland
git clone https://gitlab.gnome.org/jadahl/libdecor.git --depth 1 --branch=0.1.0
cd libdecor
meson _build -D{demo,install_demo}=false
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
rm -rf libdecor
# Install libei for Xwayland
git clone https://gitlab.freedesktop.org/libinput/libei.git --depth 1 --branch=1.0.0
cd libei
meson setup _build -Dtests=disabled -Ddocumentation=[] -Dliboeffis=enabled
ninja -C _build -j${FDO_CI_CONCURRENT:-4} install
cd ..
rm -rf libei
git clone https://gitlab.freedesktop.org/mesa/piglit.git git clone https://gitlab.freedesktop.org/mesa/piglit.git
cd piglit cd piglit
git checkout 265896c86f90cb72e8f218ba6a3617fca8b9a1e3 git checkout 265896c86f90cb72e8f218ba6a3617fca8b9a1e3
@ -160,8 +178,10 @@ cd ..
git clone https://gitlab.freedesktop.org/xorg/test/xts git clone https://gitlab.freedesktop.org/xorg/test/xts
cd xts cd xts
git checkout 12a887c2c72c4258962b56ced7b0aec782f1ffed git checkout dbbfa96c036e596346147081cbceda136e7c86c1
./autogen.sh # 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
xvfb-run make -j${FDO_CI_CONCURRENT:-4} xvfb-run make -j${FDO_CI_CONCURRENT:-4}
cd .. cd ..

14
.gitlab-ci/dist.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
set -o xtrace
meson build/
meson dist --no-tests -C build/
cd build
tar xf meson-dist/xserver-*.tar.xz
cd xserver-*/
meson -Dc_args="-fno-common" -Dprefix=/usr -Dwerror=true build/
DESTDIR=$PWD/install/ ninja -j${FDO_CI_CONCURRENT:-4} -C build/ install

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
find build/ -type f -regex ".*\.[1-9]$" -exec grep -E \ find build/ -regex ".*\.[1-9]$" -exec grep -E \
@vendorversion@\|\ @vendorversion@\|\
@xorgversion@\|\ @xorgversion@\|\
@xservername@\|\ @xservername@\|\

View File

@ -1,145 +0,0 @@
#!/usr/bin/env bash
#
# This script is sourced from here:
# https://gitlab.freedesktop.org/whot/meson-helper
#
# SPDX-License-Identifier: MIT
#
# Usage:
# meson-build.sh
# [-C directory] ... change to directory before doing anything
# [--skip-build] ... skip the compilation
# [--skip-test|--run-test] ... skip or explicitly run meson test
# [--skip-dist|--run-dist] ... skip or explicitly run meson dist
# [--skip-install|--run-install] ... skip or explicitly run meson install
#
#
# Environment variables:
# If the .meson_environment file exists in $PWD, it is sourced at the start of the script.
# This file is sourced before the -C directory option takes effect.
#
# MESON_BUILDDIR
# MESON_ARGS, MESON_EXTRA_ARGS:
# Args passed to meson setup. The MESON_EXTRA_ARGS exist to make it easier for
# callers to have a default set of arguments and a variable set of arguments.
# MESON_TEST_ARGS, MESON_DIST_ARGS, MESON_INSTALL_ARGS:
# Args passed directly to the respective meson command. If these args are set it implies
# --run-$cmd. Use --skip-$cmd to skip.
# NINJA_ARGS - args passed to ninja via meson compile
set -x
if [[ -f .meson_environment ]]; then
. .meson_environment
fi
# If test args are set, we assume we want to run the tests
MESON_RUN_TEST="$MESON_TEST_ARGS"
MESON_RUN_INSTALL="$MESON_INSTALL_ARGS"
MESON_RUN_DIST="$MESON_DIST_ARGS"
while [[ $# -gt 0 ]]; do
case $1 in
-C)
directory=$2
shift 2
pushd "$directory" || exit 1
;;
--skip-setup)
shift
MESON_SKIP_SETUP="1"
;;
--skip-build)
shift
MESON_SKIP_BUILD="1"
;;
--skip-test)
shift
MESON_RUN_TEST=""
;;
--run-test)
shift
MESON_RUN_TEST="1"
;;
--skip-dist)
shift
MESON_RUN_DIST=""
;;
--run-dist)
shift
MESON_RUN_DIST="1"
;;
--skip-install)
shift
MESON_RUN_INSTALL=""
;;
--run-install)
shift
MESON_RUN_INSTALL="1"
;;
*)
echo "Unknow commandline argument $1"
exit 1
;;
esac
done
if [[ -z "$MESON_BUILDDIR" ]]; then
echo "\$MESON_BUILDDIR undefined."
exit 1
fi
# emulate a few gitlab variables to make it easier to
# run and debug locally.
if [[ -z "$CI_JOB_ID" ]] || [[ -z "$CI_JOB_NAME" ]]; then
echo "Missing \$CI_JOB_ID or \$CI_JOB_NAME".
CI_PROJECT_NAME=$(basename "$PWD")
CI_JOB_ID=$(date +%s)
CI_JOB_NAME="$CI_PROJECT_NAME-job-local"
echo "Simulating gitlab environment: "
echo " CI_JOB_ID=$CI_JOB_ID"
echo " CI_JOB_NAME=$CI_JOB_NAME"
fi
if [[ -n "$FDO_CI_CONCURRENT" ]]; then
jobcount="-j$FDO_CI_CONCURRENT"
export MESON_TESTTHREADS="$FDO_CI_CONCURRENT"
fi
if [[ -n "$MESON_EXTRA_ARGS" ]]; then
MESON_ARGS="$MESON_ARGS $MESON_EXTRA_ARGS"
fi
echo "*************************************************"
echo "builddir: $MESON_BUILDDIR"
echo "meson args: $MESON_ARGS"
echo "ninja args: $NINJA_ARGS"
echo "meson test args: $MESON_TEST_ARGS"
echo "job count: ${jobcount-0}"
echo "*************************************************"
set -e
if [[ -z "$MESON_SKIP_SETUP" ]]; then
rm -rf "$MESON_BUILDDIR"
meson setup "$MESON_BUILDDIR" $MESON_ARGS
fi
meson configure "$MESON_BUILDDIR"
if [[ -z "$MESON_SKIP_BUILD" ]]; then
if [[ -n "$NINJA_ARGS" ]]; then
ninja_args="--ninja-args $NINJA_ARGS"
fi
meson compile -v -C "$MESON_BUILDDIR" $jobcount $ninja_args
fi
if [[ -n "$MESON_RUN_TEST" ]]; then
meson test -C "$MESON_BUILDDIR" --print-errorlogs $MESON_TEST_ARGS
fi
if [[ -n "$MESON_RUN_INSTALL" ]]; then
meson install --no-rebuild -C "$MESON_BUILDDIR" $MESON_INSTALL_ARGS
fi
if [[ -n "$MESON_RUN_DIST" ]]; then
meson dist -C "$MESON_BUILDDIR" $MESON_DIST_ARGS
fi

View File

@ -277,8 +277,7 @@ Paulo Zanoni <paulo.r.zanoni@intel.com> Paulo Ricardo Zanoni <pzanoni@mandriva.c
Pekka Paalanen <pekka.paalanen@collabora.co.uk> <pekka.paalanen@collabora.com> Pekka Paalanen <pekka.paalanen@collabora.co.uk> <pekka.paalanen@collabora.com>
Peter Harris <pharris2@rocketsoftware.com> <peter.harris@hummingbird.com> Peter Harris <pharris@opentext.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.hutterer@redhat.com>
Peter Hutterer <peter.hutterer@who-t.net> <peter@cs.unisa.edu.au> Peter Hutterer <peter.hutterer@who-t.net> <peter@cs.unisa.edu.au>

View File

@ -1 +0,0 @@
404

View File

@ -1,18 +0,0 @@
# Contribution Guidelines
1. All commits need a sign-off by the author (except for drafts)
If additional reviewers gave their ack, a proper attribution
header may be added.
2. Commit messages should explain what's really done here and their
headlines need a short an precise subject. See history for examples.
Keep in mind that history is also a piece of documentation.
3. Once release is out, bugfixes should be submitted separately, against
the affected release branch(es) as well as master (so multiple pull requests)
4. If new functions or types are introduced, these should be documented
in-code, so we can generate docs directly from the code :)
5. Use pull request tags if you can - if we need some more, just ask.

View File

@ -8,7 +8,6 @@ possible, and insert their name to this list. Please sort by surname
for people, and by the full name for other entities (e.g. Juliusz for people, and by the full name for other entities (e.g. Juliusz
Chroboczek sorts before Intel Corporation sorts before Daniel Stone). Chroboczek sorts before Intel Corporation sorts before Daniel Stone).
Copyright © 2025 Enrico Weigelt, metux IT consult
Copyright © 2011 Dave Airlie Copyright © 2011 Dave Airlie
Copyright © 2000-2001 Juliusz Chroboczek Copyright © 2000-2001 Juliusz Chroboczek
Copyright © 1998 Egbert Eich Copyright © 1998 Egbert Eich

1
CoC.md
View File

@ -1 +0,0 @@
-ENOENT

351
MAINTAINERS Normal file
View File

@ -0,0 +1,351 @@
(Format of this file shamelessly stolen from the Linux kernel.)
Maintainer guidelines:
1) Please test your changes and the changes you receive prior to
checkin. The more varied the testing, the better.
2) It's nice to release alpha versions to the appropriate list for
testing.
3) Make sure your changes compile!
Rules:
1) The first person to complain about an unresponsive maintainer
automatically assumes maintainership of the code in question.
Unlike the kernel maintainers file, this goes more or less alphabetically
by component within each subsystem, rather than alphabetically on maintainer
name.
M: Maintainer
L: Mailing list that is relevant to this area
W: Web-page with status/info
S: Status, one of the following:
Supported: Someone is actually paid to look after this.
Maintained: Someone actually looks after it.
Odd Fixes: It has a maintainer but they don't have time to do
much other than throw the odd patch in. See below..
Unmaintained: No current maintainer [but maybe you could take the
role as you write your new code].
Deactivated: Package is about to be obsoleted. A deactivated
package will not receive general fixes unless a user
requires this package to be reactivated first.
Obsolete: Old code. Something tagged obsolete generally means
it has been replaced by a better system and you
should be using that.
C: URI for *chat* protocol, server and channel where developers
usually hang out, for example irc://server/channel.
T: SCM tree location.
F: Files and directories wildcard patterns.
One pattern per line. Multiple F: lines acceptable.
X: Excluded files and directories that are NOT maintained
One pattern per line. Multiple F: lines acceptable.
Please use gitlab to submit issue reports & merge requests for all projects
that use gitlab.
For patch submission instructions, see:
https://www.x.org/wiki/Development/Documentation/SubmittingPatches
Xserver core
------------
All subsystems
C: irc://irc.oftc.net/xorg-devel
W: https://wiki.x.org
T: https://gitlab.freedesktop.org/xorg/xserver
Composite extension
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: composite
Configuration subsystem
M: Adam Jackson <ajax@nwnk.net>
L: xorg-devel@lists.x.org
S: Maintained
F: config
Damage extension
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: damageext
F: miext/damage
Device Independent X (DIX)
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: dix
Documentation
# M: ?
L: xorg-devel@lists.x.org
S: Unmaintaind
F: doc
F: man
Double buffer extension
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: dbe
DRI subsystem
M: Adam Jackson <ajax@nwnk.net>
L: xorg-devel@lists.x.org
S: Maintained
F: hw/xfree86/dri*
F: dri3
EXA subsystem
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: exa
Framebuffer subsystem
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: fb
Glamor subsystem
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: glamor
GL subsystem
M: Ian Romanick <idr@us.ibm.com>
L: xorg-devel@lists.x.org
S: Maintained
F: GL
KDrive
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: hw/kdrive
Loader subsystem
M: Adam Jackson <ajax@nwnk.net>
L: xorg-devel@lists.x.org
S: Maintained
F: hw/xfree86/loader
Misc extensions
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: Xext
OS layer
# M: ?
L: xorg-devel@lists.x.org
S: Maintined
F: os
Present extension
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: present
Pseudoramix (rootless Xinerama) subsystem
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: pseudoramiX
Randr extension
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: randr
Record extension
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: record
Render extension
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: render
Rootless subsystem
M: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
L: xorg-devel@lists.x.org
S: Maintained
F: miext/rootless
Shadow extension
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: miext/shadow
Sync extension
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: miext/sync
Tests
# M: ?
L: xorg-devel@lists.x.org
S: Unmaintained
F: test
XACE subsystem (security policy extensions framework)
M: Eamon Walsh <ewalsh@tycho.nsa.gov>
L: xorg-devel@lists.x.org
W: http://people.freedesktop.org/~ewalsh/xace_proposal.html
S: Maintained
Xfixes extension
M: Keith Packard <keithp@keithp.com>
L: xorg-devel@lists.x.org
S: Maintained
F: xfixes
XKB
M: Daniel Stone <daniel@fooishbar.org>
L: xorg-devel@lists.x.org
S: Maintained
S: Please contact Daniel if you're planning to work on this
F: xkb
Input subsystem
M: Daniel Stone <daniel@fooishbar.org>
M: Peter Hutterer <peter.hutterer@who-t.net>
L: xorg-devel@lists.x.org
S: Maintained
F: Xi
Xquartz server
M: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
L: xorg-devel@lists.x.org
L: xquartz-dev@lists.macosforge.org
W: https://www.xquartz.org/
S: Maintained
F: hw/xquartz
Xorg server
# M: ?
L: xorg-devel@lists.x.org
S: Maintained, for now
F: hw/xfree86
Xwayland server
M: Olivier Fourdan <ofourdan@redhat.com>
L: wayland-devel@lists.freedesktop.org
L: xorg-devel@lists.x.org
W: https://wayland.freedesktop.org/xserver.html
S: Maintained
F: hw/xwayland
Xwin server
# M: ?
L: xorg-devel@lists.x.org
S: Maintained
F: hw/xwin
Xvfb server
# M: ?
L: xorg-devel@lists.x.org
S: Unmaintained
F: hw/vfb
Xnest server
M: Enrico Weigelt <info@metux.net>
L: xorg-devel@lists.x.org
S: Maintained
F: hw/xnest
X.Org OS ports
--------------
FreeBSD
# M: ?
L: xorg-devel@lists.x.org
S: Unmaintained
Linux/i386
M: Egbert Eich <eich@freedesktop.org>
L: xorg-devel@lists.x.org
S: Maintained
Linux/x86_64
M: Egbert Eich <eich@freedesktop.org>
L: xorg-devel@lists.x.org
S: Maintained
Linux/ia64
M: Jesse Barnes <jbarnes@virtuousgeek.org>
L: xorg-devel@lists.x.org
S: Maintained
Linux/ppc
M: Benjamin Herrenschmidt <benh@kernel.crashing.org>
L: xorg-devel@lists.x.org
S: Maintained
Linux/sparc
# M: ?
L: xorg-devel@lists.x.org
S: Unmaintained
Mac OS X (Xquartz)
M: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
L: xquartz-dev@lists.macosforge.org
W: https://www.xquartz.org/
L: xorg-devel@lists.x.org
S: Maintained
NetBSD
# M: ?
L: xorg-devel@lists.x.org
S: Unmaintained
OpenBSD
M: Matthieu Herrb <matthieu@herrb.eu>
L: xorg-devel@lists.x.org
S: Maintained
SCO (OpenServer 5)
M: Kean Johnston <jkj@freedesktop.org>
L: xorg-devel@lists.x.org
S: Unmaintained
Solaris (x86 & sparc) & illumos
M: Alan Coopersmith <alan.coopersmith@oracle.com>
M: Niveditha Rau <niveditha.rau@oracle.com>
L: xorg-devel@lists.x.org
W: https://github.com/oracle/solaris-userland/tree/master/components/x11
S: Maintained
USL (UnixWare 7.1.x, OpenServer 6)
M: Kean Johnston <jkj@freedesktop.org>
L: xorg-devel@lists.x.org
S: Unmaintained
Cygwin
M: Jon TURNEY <jon.turney@dronecode.org.uk>
M: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
L: cygwin-xfree@cygwin.com
W: https://x.cygwin.com/
S: Maintained
MinGW
M: Colin Harrison <colin.harrison@virgin.net>
W: http://www.straightrunning.com/XmingNotes/
S: Maintained
GNU/Hurd
M: Samuel Thibault <samuel.thibault@ens-lyon.org>
L: bug-hurd@gnu.org
S: Maintained

141
README.md
View File

@ -1,128 +1,35 @@
XLibre Xserver X Server
=============== --------
Xlibre is a fork of the [Xorg Xserver](https://gitlab.freedesktop.org/xorg/xserver) The X server accepts requests from client applications to create windows,
with lots of code cleanups and enhanced functionality. which are (normally rectangular) "virtual screens" that the client program
can draw into.
This fork was necessary since toxic elements within Xorg projects, moles Windows are then composed on the actual screen by the X server
from BigTech, are boycotting any substantial work on Xorg, in order to (or by a separate composite manager) as directed by the window manager,
destroy the project, to eliminate competition of their own products. which usually communicates with the user via graphical controls such as buttons
Classic "embrace, extend, extinguish" tactics. and draggable titlebars and borders.
Right after journalists first began covering the planned fork Xlibre, For a comprehensive overview of X Server and X Window System, consult the
on June 6th 2025, Redhat employees started a purge on the Xlibre founder's following article:
GitLab account on freedesktop.org: deleted the git repo, tickets, merge https://en.wikipedia.org/wiki/X_server
requests, etc, and so fired the shot that the whole world heard.
This is an independent project, not at all affiliated with BigTech or any All questions regarding this software should be directed at the
of their subsidiaries or tax evasion tools, nor any political activists Xorg mailing list:
groups, state actors, etc. It's explicitly free of any "DEI" or similar
discriminatory policies. Anybody who's treating others nicely is welcomed.
It doesn't matter which country you're coming from, your political views, https://lists.freedesktop.org/mailman/listinfo/xorg
your race, your sex, your age, your food menu, whether you wear boots or
heels, whether you're furry or fairy, Conan or McKay, comic character, a
small furry creature from Alpha Centauri, or just a boring average person.
Anybody who's interested in bringing X forward is welcome.
Together we'll make X great again! The primary development code repository can be found at:
Upgrade notice https://gitlab.freedesktop.org/xorg/xserver
--------------
* Module ABIs have changed - drivers MUST be recompiled against this Xserver For patch submission instructions, see:
version, otherwise the Xserver can crash or fail to start up correctly.
* If your console is locked up (no input possible, not even VT switch), then https://www.x.org/wiki/Development/Documentation/SubmittingPatches
most likely the input driver couldn't be loaded due to a version mismatch.
When unsure, it's best to be prepared to ssh into your machine from another one
or set a timer that's calling `chvt 1` after certain time, so you don't
need a cold reboot.
Or, make sure that you have magic `SysRq` key enabled (`Alt+PrtSc`)
via sysctl (`kernel.sysrq=1`), then press following combination depending on keyboard
layout to make kernel regain control over keyboard to make VT switching work:
- QWERTY/AZERTY keyboard layout: `SysRq + R`
- Dvorak/Colemak keyboard layout: `SysRq + P`
* Proprietary Nvidia drivers might break: they still haven't managed to do As with other projects hosted on freedesktop.org, X.Org follows its
even simple cleanups to catch up with Xorg master for about a year. Code of Conduct, based on the Contributor Covenant. Please conduct
All attempts to get into direct mail contact have failed. We're trying to yourself in a respectful and civilized manner when using the above
work around this, but cannot give any guarantees. But you can make it work mailing lists, bug trackers, etc:
by adding `Option "IgnoreABI" "1"` line to `ServerFlags` section in Xorg config.
* Most Xorg drivers should run as-is (once recompiled!), with some exceptions. https://www.freedesktop.org/wiki/CodeOfConduct
See `.gitlab-ci.yml` for the versions/branches built along with Xlibre.
Driver repositories
-------------------
Since Redhat had deleted and banned all X11Libre repositories from freedesktop.org,
the driver repositories are now moved to GitHub:
| Driver | Git repository | Release tag |
| --- | --- | --- |
| xf86-input-elographics: | https://github.com/X11Libre/xf86-input-elographics | xlibre-xf86-input-elographics-1.4.4.1 |
| xf86-input-evdev: | https://github.com/X11Libre/xf86-input-evdev | xlibre-xf86-input-evdev-2.11.0.1 |
| xf86-input-void: | https://github.com/X11Libre/xf86-input-void | xlibre-xf86-input-void-1.4.2.1 |
| xf86-input-joystick: | https://github.com/X11Libre/xf86-input-joystick | xlibre-xf86-input-joystick-1.6.4.1 |
| xf86-input-keyboard: | https://github.com/X11Libre/xf86-input-keyboard | xlibre-xf86-input-keyboard-2.1.0.1 |
| xf86-input-libinput: | https://github.com/X11Libre/xf86-input-libinput | xlibre-xf86-input-libinput-1.5.0.1 |
| xf86-input-mouse: | https://github.com/X11Libre/xf86-input-mouse | xlibre-xf86-input-mouse-1.9.5.1 |
| xf86-input-synaptics: | https://github.com/X11Libre/xf86-input-synaptics | xlibre-xf86-input-synaptics-1.10.0.1 |
| xf86-input-vmmouse: | https://github.com/X11Libre/xf86-input-vmmouse | xlibre-xf86-input-vmmouse-13.2.0.1 |
| xf86-input-wacom: | https://github.com/X11Libre/xf86-input-wacom | xlibre-xf86-input-wacom-1.2.3.1 |
| xf86-video-amdgpu: | https://github.com/X11Libre/xf86-video-amdgpu | xlibre-xf86-video-amdgpu-23.0.0.1 |
| xf86-video-apm: | https://github.com/X11Libre/xf86-video-apm | xlibre-xf86-video-apm-1.3.0.1 |
| xf86-video-ark: | https://github.com/X11Libre/xf86-video-ark | xfree-xf86-video-ark-0.7.6.1 |
| xf86-video-ast: | https://github.com/X11Libre/xf86-video-ast | xlibre-xf86-video-ast-1.2.0 |
| xf86-video-ati: | https://github.com/X11Libre/xf86-video-ati | xfree-xf86-video-ati-22.0.0.1 |
| xf86-video-chips: | https://github.com/X11Libre/xf86-video-chips | xlibre-xf86-video-chips-1.5.0.1 |
| xf86-video-cirrus: | https://github.com/X11Libre/xf86-video-cirrus | xlibre-xf86-video-cirrus-1.6.0.1 |
| xf86-video-dummy: | https://github.com/X11Libre/xf86-video-dummy | xlibre-xf86-video-dummy-0.4.1.1 |
| xf86-video-fbdev: | https://github.com/X11Libre/xf86-video-fbdev | xlibre-xf86-video-fbdev-0.5.1.1 |
| xf86-video-freedreno: | https://github.com/X11Libre/xf86-video-freedreno | xlibre-xf86-video-freedreno-1.4.0.1 |
| xf86-video-geode: | https://github.com/X11Libre/xf86-video-geode | xlibre-xf86-video-geode-2.18.1.1 |
| xf86-video-i128: | https://github.com/X11Libre/xf86-video-i128 | xlibre-xf86-video-i128-1.4.1.1 |
| xf86-video-i740: | https://github.com/X11Libre/xf86-video-i740 | xlibre-xf86-video-i740-1.4.0.1 |
| xf86-video-intel: | https://github.com/X11Libre/xf86-video-intel | xlibre-xf86-video-intel-3.0.0.1 |
| xf86-video-mach64: | https://github.com/X11Libre/xf86-video-mach64 | xlibre-xf86-video-mach64-6.10.0.1 |
| xf86-video-mga: | https://github.com/X11Libre/xf86-video-mga | xlibre-xf86-video-mga-2.1.0.1 |
| xf86-video-neomagic: | https://github.com/X11Libre/xf86-video-neomagic | xlibre-xf86-video-neomagic-1.3.1.1 |
| xf86-video-nested: | https://github.com/X11Libre/xf86-video-nested | xlibre-xf86-video-nested-1.0.0.1 |
| xf86-video-nouveau: | https://github.com/X11Libre/xf86-video-nouveau | xlibre-xf86-video-nouveau-1.0.18.1 |
| xf86-video-nv: | https://github.com/X11Libre/xf86-video-nv | xlibre-xf86-video-nv-2.1.23.1 |
| xf86-video-omap: | https://github.com/X11Libre/xf86-video-omap | xlibre-xf86-video-omap-0.4.5.1 |
| xf86-video-qxl: | https://github.com/X11Libre/xf86-video-qxl | xlibre-xf86-video-qxl-0.1.6.1 |
| xf86-video-r128: | https://github.com/X11Libre/xf86-video-r128 | xlibre-xf86-video-r128-6.13.0.1 |
| xf86-video-rendition: | https://github.com/X11Libre/xf86-video-rendition | xlibre-xf86-video-rendition-4.2.7.1 |
| xf86-video-s3virge: | https://github.com/X11Libre/xf86-video-s3virge | xlibre-xf86-video-s3virge-1.11.1.1 |
| xf86-video-savage: | https://github.com/X11Libre/xf86-video-savage | xlibre-xf86-video-savage-2.4.1.1 |
| xf86-video-siliconmotion: | https://github.com/X11Libre/xf86-video-siliconmotion | xlibre-xf86-video-siliconmotion-1.7.10.1 |
| xf86-video-sis: | https://github.com/X11Libre/xf86-video-sis | xlibre-xf86-video-sis-0.12.0.1 |
| xf86-video-sisusb: | https://github.com/X11Libre/xf86-video-sisusb | xlibre-xf86-video-sisusb-0.9.7.1 |
| xf86-video-suncg14: | https://github.com/X11Libre/xf86-video-suncg14 | xlibre-xf86-video-suncg14-1.2.0 |
| xf86-video-suncg3: | https://github.com/X11Libre/xf86-video-suncg3 | xlibre-xf86-video-suncg3-1.1.3.0 |
| xf86-video-suncg6: | https://github.com/X11Libre/xf86-video-suncg6 | xlibre-xf86-video-suncg6-1.1.3.1 |
| xf86-video-sunffb: | https://github.com/X11Libre/xf86-video-sunffb | xlibre-xf86-video-sunffb-1.2.3.1 |
| xf86-video-sunleo: | https://github.com/X11Libre/xf86-video-sunleo | xlibre-xf86-video-sunleo-1.2.3.1 |
| xf86-video-suntcx: | https://github.com/X11Libre/xf86-video-suntcx | xlibre-xf86-video-suntcx-1.1.3.1 |
| xf86-video-tdfx: | https://github.com/X11Libre/xf86-video-tdfx | xlibre-xf86-video-tdfx-1.5.0.1 |
| xf86-video-trident: | https://github.com/X11Libre/xf86-video-trident | xlibre-xf86-video-trident-1.4.0.1 |
| xf86-video-vbox: | https://github.com/X11Libre/xf86-video-vbox | xlibre-xf86-video-vbox-1.0.1.1 |
| xf86-video-v4l: | https://github.com/X11Libre/xf86-video-v4l | xlibre-xf86-video-v4l-0.3.0.1 |
| xf86-video-vesa: | https://github.com/X11Libre/xf86-video-vesa | xlibre-xf86-video-vesa-2.6.0.1 |
| xf86-video-vmware: | https://github.com/X11Libre/xf86-video-vmware | xlibre-xf86-video-vmware-13.4.0.1 |
| xf86-video-voodoo: | https://github.com/X11Libre/xf86-video-voodoo | xlibre-xf86-video-voodoo-1.2.6.1 |
| xf86-video-wsfb: | https://github.com/X11Libre/xf86-video-wsfb | xlibre-xf86-video-wsfb-0.4.1.1 |
| xf86-video-xgi: | https://github.com/X11Libre/xf86-video-xgi | xlibre-xf86-video-xgi-1.6.1.1 |
Contact
-------
| | |
| --- | --- |
| Mailing list: | https://www.freelists.org/list/xlibre |
| Telegram channel: | https://t.me/x11dev |
| Matrix room (mirror of tg group): | https://matrix.to/#/#xlibre:matrix.org |

View File

@ -26,20 +26,19 @@ from The Open Group.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/bigreqsproto.h>
#include "dix/dix_priv.h"
#include "miext/extinit_priv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "extnsionst.h" #include "extnsionst.h"
#include <X11/extensions/bigreqsproto.h>
#include "opaque.h" #include "opaque.h"
#include "extinit.h"
static int static int
ProcBigReqDispatch(ClientPtr client) ProcBigReqDispatch(ClientPtr client)
@ -47,6 +46,9 @@ ProcBigReqDispatch(ClientPtr client)
REQUEST(xBigReqEnableReq); REQUEST(xBigReqEnableReq);
xBigReqEnableReply rep; xBigReqEnableReply rep;
if (client->swapped) {
swaps(&stuff->length);
}
if (stuff->brReqType != X_BigReqEnable) if (stuff->brReqType != X_BigReqEnable)
return BadRequest; return BadRequest;
REQUEST_SIZE_MATCH(xBigReqEnableReq); REQUEST_SIZE_MATCH(xBigReqEnableReq);

View File

@ -26,28 +26,24 @@ Equipment Corporation.
******************************************************************/ ******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/dpmsproto.h>
#include "miext/extinit_priv.h"
#include "os/screensaver.h"
#include "Xext/geext_priv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "opaque.h" #include "opaque.h"
#include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h" #include "dpmsproc.h"
#include "extinit.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "windowstr.h" #include "windowstr.h"
#include "protocol-versions.h" #include "protocol-versions.h"
Bool noDPMSExtension = FALSE;
CARD16 DPMSPowerLevel = 0; CARD16 DPMSPowerLevel = 0;
Bool DPMSDisabledSwitch = FALSE; Bool DPMSDisabledSwitch = FALSE;
CARD32 DPMSStandbyTime = -1; CARD32 DPMSStandbyTime = -1;
@ -145,9 +141,10 @@ ProcDPMSSelectInput(register ClientPtr client)
} }
/* build the entry */ /* build the entry */
pNewEvent = calloc(1, sizeof(DPMSEventRec)); pNewEvent = (DPMSEventPtr)malloc(sizeof(DPMSEventRec));
if (!pNewEvent) if (!pNewEvent)
return BadAlloc; return BadAlloc;
pNewEvent->next = 0;
pNewEvent->client = client; pNewEvent->client = client;
pNewEvent->mask = stuff->eventMask; pNewEvent->mask = stuff->eventMask;
/* /*
@ -163,10 +160,10 @@ ProcDPMSSelectInput(register ClientPtr client)
* of clients selecting input * of clients selecting input
*/ */
if (i != Success || !pHead) { if (i != Success || !pHead) {
pHead = calloc(1, sizeof(DPMSEventPtr)); pHead = (DPMSEventPtr *)malloc(sizeof(DPMSEventPtr));
if (!pHead || if (!pHead ||
!AddResource(eventResource, DPMSEventType, (void *)pHead)) { !AddResource(eventResource, DPMSEventType, (void *)pHead)) {
FreeResource(clientResource, X11_RESTYPE_NONE); FreeResource(clientResource, RT_NONE);
return BadAlloc; return BadAlloc;
} }
*pHead = 0; *pHead = 0;
@ -495,16 +492,42 @@ static int _X_COLD
SProcDPMSGetVersion(ClientPtr client) SProcDPMSGetVersion(ClientPtr client)
{ {
REQUEST(xDPMSGetVersionReq); REQUEST(xDPMSGetVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSGetVersionReq); REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
swaps(&stuff->majorVersion); swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion);
return ProcDPMSGetVersion(client); return ProcDPMSGetVersion(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 static int _X_COLD
SProcDPMSSetTimeouts(ClientPtr client) SProcDPMSSetTimeouts(ClientPtr client)
{ {
REQUEST(xDPMSSetTimeoutsReq); REQUEST(xDPMSSetTimeoutsReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq); REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
swaps(&stuff->standby); swaps(&stuff->standby);
@ -513,10 +536,34 @@ SProcDPMSSetTimeouts(ClientPtr client)
return ProcDPMSSetTimeouts(client); return ProcDPMSSetTimeouts(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 static int _X_COLD
SProcDPMSForceLevel(ClientPtr client) SProcDPMSForceLevel(ClientPtr client)
{ {
REQUEST(xDPMSForceLevelReq); REQUEST(xDPMSForceLevelReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSForceLevelReq); REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
swaps(&stuff->level); swaps(&stuff->level);
@ -524,10 +571,22 @@ SProcDPMSForceLevel(ClientPtr client)
return ProcDPMSForceLevel(client); return ProcDPMSForceLevel(client);
} }
static int _X_COLD
SProcDPMSInfo(ClientPtr client)
{
REQUEST(xDPMSInfoReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSInfoReq);
return ProcDPMSInfo(client);
}
static int _X_COLD static int _X_COLD
SProcDPMSSelectInput(ClientPtr client) SProcDPMSSelectInput(ClientPtr client)
{ {
REQUEST(xDPMSSelectInputReq); REQUEST(xDPMSSelectInputReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDPMSSelectInputReq); REQUEST_SIZE_MATCH(xDPMSSelectInputReq);
swapl(&stuff->eventMask); swapl(&stuff->eventMask);
return ProcDPMSSelectInput(client); return ProcDPMSSelectInput(client);
@ -543,19 +602,19 @@ SProcDPMSDispatch(ClientPtr client)
case X_DPMSGetVersion: case X_DPMSGetVersion:
return SProcDPMSGetVersion(client); return SProcDPMSGetVersion(client);
case X_DPMSCapable: case X_DPMSCapable:
return ProcDPMSCapable(client); return SProcDPMSCapable(client);
case X_DPMSGetTimeouts: case X_DPMSGetTimeouts:
return ProcDPMSGetTimeouts(client); return SProcDPMSGetTimeouts(client);
case X_DPMSSetTimeouts: case X_DPMSSetTimeouts:
return SProcDPMSSetTimeouts(client); return SProcDPMSSetTimeouts(client);
case X_DPMSEnable: case X_DPMSEnable:
return ProcDPMSEnable(client); return SProcDPMSEnable(client);
case X_DPMSDisable: case X_DPMSDisable:
return ProcDPMSDisable(client); return SProcDPMSDisable(client);
case X_DPMSForceLevel: case X_DPMSForceLevel:
return SProcDPMSForceLevel(client); return SProcDPMSForceLevel(client);
case X_DPMSInfo: case X_DPMSInfo:
return ProcDPMSInfo(client); return SProcDPMSInfo(client);
case X_DPMSSelectInput: case X_DPMSSelectInput:
return SProcDPMSSelectInput(client); return SProcDPMSSelectInput(client);
default: default:
@ -588,7 +647,7 @@ DPMSExtensionInit(void)
ClientType = CreateNewResourceType(DPMSFreeClient, "DPMSClient"); ClientType = CreateNewResourceType(DPMSFreeClient, "DPMSClient");
DPMSEventType = CreateNewResourceType(DPMSFreeEvents, "DPMSEvent"); DPMSEventType = CreateNewResourceType(DPMSFreeEvents, "DPMSEvent");
eventResource = dixAllocServerXID(); eventResource = FakeClientID(0);
if (DPMSEnabled && ClientType && DPMSEventType && if (DPMSEnabled && ClientType && DPMSEventType &&
(extEntry = AddExtension(DPMSExtensionName, 0, 0, (extEntry = AddExtension(DPMSExtensionName, 0, 0,

View File

@ -1,6 +1,8 @@
/* Prototypes for functions that the DDX must provide */ /* Prototypes for functions that the DDX must provide */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#ifndef _DPMSPROC_H_ #ifndef _DPMSPROC_H_
#define _DPMSPROC_H_ #define _DPMSPROC_H_

View File

@ -23,37 +23,26 @@
* Author: Peter Hutterer, University of South Australia, NICTA * Author: Peter Hutterer, University of South Australia, NICTA
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/extensions/ge.h>
#include <X11/extensions/geproto.h>
#include "miext/extinit_priv.h"
#include "Xext/geext_priv.h"
#include "windowstr.h" #include "windowstr.h"
#include "protocol-versions.h" #include <X11/extensions/ge.h>
#define MAXEXTENSIONS 128 #include "geint.h"
#include "geext.h"
#include "protocol-versions.h"
#include "extinit.h"
DevPrivateKeyRec GEClientPrivateKeyRec; DevPrivateKeyRec GEClientPrivateKeyRec;
#define GEClientPrivateKey (&GEClientPrivateKeyRec) GEExtension GEExtensions[MAXEXTENSIONS];
/** Struct to keep information about registered extensions */ /* Major available requests */
typedef struct _GEExtension { static const int version_requests[] = {
/** Event swapping routine */ X_GEQueryVersion, /* before client sends QueryVersion */
void (*evswap) (xGenericEvent *from, xGenericEvent *to); X_GEQueryVersion, /* must be set to last request in version 1 */
} 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 */ /* Forward declarations */
static void SGEGenericEvent(xEvent *from, xEvent *to); static void SGEGenericEvent(xEvent *from, xEvent *to);
@ -100,6 +89,11 @@ ProcGEQueryVersion(ClientPtr client)
return Success; return Success;
} }
static int (*ProcGEVector[GENumberRequests]) (ClientPtr) = {
/* Version 1.0 */
ProcGEQueryVersion,
};
/************************************************************/ /************************************************************/
/* swapped request handlers */ /* swapped request handlers */
/************************************************************/ /************************************************************/
@ -107,12 +101,19 @@ static int _X_COLD
SProcGEQueryVersion(ClientPtr client) SProcGEQueryVersion(ClientPtr client)
{ {
REQUEST(xGEQueryVersionReq); REQUEST(xGEQueryVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xGEQueryVersionReq); REQUEST_SIZE_MATCH(xGEQueryVersionReq);
swaps(&stuff->majorVersion); swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion);
return ProcGEQueryVersion(client); return (*ProcGEVector[stuff->ReqType]) (client);
} }
static int (*SProcGEVector[GENumberRequests]) (ClientPtr) = {
/* Version 1.0 */
SProcGEQueryVersion
};
/************************************************************/ /************************************************************/
/* callbacks */ /* callbacks */
/************************************************************/ /************************************************************/
@ -121,29 +122,32 @@ SProcGEQueryVersion(ClientPtr client)
static int static int
ProcGEDispatch(ClientPtr client) ProcGEDispatch(ClientPtr client)
{ {
REQUEST(xReq); GEClientInfoPtr pGEClient = GEGetClient(client);
switch (stuff->data) { REQUEST(xGEReq);
case X_GEQueryVersion:
return ProcGEQueryVersion(client); if (pGEClient->major_version >= ARRAY_SIZE(version_requests))
default:
return BadRequest; return BadRequest;
} if (stuff->ReqType > version_requests[pGEClient->major_version])
return BadRequest;
return (ProcGEVector[stuff->ReqType]) (client);
} }
/* dispatch swapped requests */ /* dispatch swapped requests */
static int _X_COLD static int _X_COLD
SProcGEDispatch(ClientPtr client) SProcGEDispatch(ClientPtr client)
{ {
REQUEST(xReq); GEClientInfoPtr pGEClient = GEGetClient(client);
swaps(&stuff->length);
switch (stuff->data) { REQUEST(xGEReq);
case X_GEQueryVersion:
return SProcGEQueryVersion(client); if (pGEClient->major_version >= ARRAY_SIZE(version_requests))
default:
return BadRequest; return BadRequest;
} if (stuff->ReqType > version_requests[pGEClient->major_version])
return BadRequest;
return (*SProcGEVector[stuff->ReqType]) (client);
} }
/* Reset extension. Called on server shutdown. */ /* Reset extension. Called on server shutdown. */
@ -182,16 +186,24 @@ SGEGenericEvent(xEvent *from, xEvent *to)
void void
GEExtensionInit(void) GEExtensionInit(void)
{ {
ExtensionEntry *extEntry;
if (!dixRegisterPrivateKey if (!dixRegisterPrivateKey
(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec))) (&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n"); FatalError("GEExtensionInit: GE private request failed.\n");
if (!AddExtension(GE_NAME, 0, GENumberErrors, ProcGEDispatch, SProcGEDispatch, if ((extEntry = AddExtension(GE_NAME,
GEResetProc, StandardMinorOpcode)) 0, GENumberErrors,
FatalError("GEInit: AddExtensions failed.\n"); ProcGEDispatch, SProcGEDispatch,
GEResetProc, StandardMinorOpcode)) != 0) {
memset(GEExtensions, 0, sizeof(GEExtensions)); memset(GEExtensions, 0, sizeof(GEExtensions));
EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent; EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent;
}
else {
FatalError("GEInit: AddExtensions failed.\n");
}
} }
/************************************************************/ /************************************************************/
@ -215,3 +227,14 @@ GERegisterExtension(int extension,
/* extension opcodes are > 128, might as well save some space here */ /* extension opcodes are > 128, might as well save some space here */
GEExtensions[EXT_MASK(extension)].evswap = ev_swap; GEExtensions[EXT_MASK(extension)].evswap = ev_swap;
} }
/* Sets type and extension field for a generic event. This is just an
* auxiliary function, extensions could do it manually too.
*/
void
GEInitEvent(xGenericEvent *ev, int extension)
{
ev->type = GenericEvent;
ev->extension = extension;
ev->length = 0;
}

81
Xext/geext.h Normal file
View File

@ -0,0 +1,81 @@
/*
Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
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 AUTHOR 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 author 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 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))
/* Interface for other extensions */
extern _X_EXPORT void GERegisterExtension(int extension,
void (*ev_dispatch) (xGenericEvent
*from,
xGenericEvent
*to));
extern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension);
#endif /* _GEEXT_H_ */

View File

@ -1,22 +0,0 @@
/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#ifndef _XORG_GEEXT_PRIV_H
#define _XORG_GEEXT_PRIV_H
#include <X11/Xproto.h>
typedef void (*XorgGESwapProcPtr) (xGenericEvent *from, xGenericEvent *to);
/*
* Register generic event extension dispatch handler
*
* @param extension base opcode
* @param event swap handler function
*/
_X_EXPORT /* just for Nvidia legacy */
void GERegisterExtension(int extension, XorgGESwapProcPtr swap_handler);
#endif /* _XORG_GEEXT_PRIV_H */

51
Xext/geint.h Normal file
View File

@ -0,0 +1,51 @@
/*
* 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_ */

View File

@ -1,9 +1,8 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include "dix/resource_priv.h"
#include "misc.h" #include "misc.h"
#include "hashtable.h" #include "hashtable.h"
@ -42,7 +41,7 @@ ht_create(int keySize,
{ {
int c; int c;
int numBuckets; int numBuckets;
HashTable ht = calloc(1, sizeof(struct HashTableRec)); HashTable ht = malloc(sizeof(struct HashTableRec));
if (!ht) { if (!ht) {
return NULL; return NULL;
@ -55,7 +54,7 @@ ht_create(int keySize,
ht->elements = 0; ht->elements = 0;
ht->bucketBits = INITHASHSIZE; ht->bucketBits = INITHASHSIZE;
numBuckets = 1 << ht->bucketBits; numBuckets = 1 << ht->bucketBits;
ht->buckets = calloc(numBuckets, sizeof(*ht->buckets)); ht->buckets = xallocarray(numBuckets, sizeof(*ht->buckets));
ht->cdata = cdata; ht->cdata = cdata;
if (ht->buckets) { if (ht->buckets) {
@ -96,7 +95,7 @@ double_size(HashTable ht)
int newNumBuckets = 1 << newBucketBits; int newNumBuckets = 1 << newBucketBits;
int c; int c;
newBuckets = calloc(newNumBuckets, sizeof(*ht->buckets)); newBuckets = xallocarray(newNumBuckets, sizeof(*ht->buckets));
if (newBuckets) { if (newBuckets) {
for (c = 0; c < newNumBuckets; ++c) { for (c = 0; c < newNumBuckets; ++c) {
xorg_list_init(&newBuckets[c]); xorg_list_init(&newBuckets[c]);
@ -130,7 +129,7 @@ ht_add(HashTable ht, const void *key)
if (!elem) { if (!elem) {
goto outOfMemory; goto outOfMemory;
} }
elem->key = calloc(1, ht->keySize); elem->key = malloc(ht->keySize);
if (!elem->key) { if (!elem->key) {
goto outOfMemory; goto outOfMemory;
} }

View File

@ -51,7 +51,7 @@ typedef struct {
@param[in] cdata Opaque data that will be passed to hash and @param[in] cdata Opaque data that will be passed to hash and
comparison functions comparison functions
*/ */
HashTable ht_create(int keySize, extern _X_EXPORT HashTable ht_create(int keySize,
int dataSize, int dataSize,
HashFunc hash, HashFunc hash,
HashCompareFunc compare, HashCompareFunc compare,
@ -59,7 +59,7 @@ HashTable ht_create(int keySize,
/** @brief HtDestruct deinitializes the structure. It does not free the /** @brief HtDestruct deinitializes the structure. It does not free the
memory allocated to HashTableRec memory allocated to HashTableRec
*/ */
void ht_destroy(HashTable ht); extern _X_EXPORT void ht_destroy(HashTable ht);
/** @brief Adds a new key to the hash table. The key will be copied /** @brief Adds a new key to the hash table. The key will be copied
and a pointer to the value will be returned. The data will and a pointer to the value will be returned. The data will
@ -75,12 +75,12 @@ void ht_destroy(HashTable ht);
to avoid returning NULL. Obviously the data pointed cannot be to avoid returning NULL. Obviously the data pointed cannot be
modified, as implied by dataSize being 0. modified, as implied by dataSize being 0.
*/ */
void *ht_add(HashTable ht, const void *key); extern _X_EXPORT void *ht_add(HashTable ht, const void *key);
/** @brief Removes a key from the hash table along with its /** @brief Removes a key from the hash table along with its
associated data, which will be free'd. associated data, which will be free'd.
*/ */
void ht_remove(HashTable ht, const void *key); extern _X_EXPORT void ht_remove(HashTable ht, const void *key);
/** @brief Finds the associated data of a key from the hash table. /** @brief Finds the associated data of a key from the hash table.
@ -93,27 +93,27 @@ void ht_remove(HashTable ht, const void *key);
use HtMember instead to determine if a key has been use HtMember instead to determine if a key has been
inserted. inserted.
*/ */
void *ht_find(HashTable ht, const void *key); extern _X_EXPORT void *ht_find(HashTable ht, const void *key);
/** @brief A generic hash function */ /** @brief A generic hash function */
unsigned ht_generic_hash(void *cdata, extern _X_EXPORT unsigned ht_generic_hash(void *cdata,
const void *ptr, const void *ptr,
int numBits); int numBits);
/** @brief A generic comparison function. It compares data byte-wise. */ /** @brief A generic comparison function. It compares data byte-wise. */
int ht_generic_compare(void *cdata, extern _X_EXPORT int ht_generic_compare(void *cdata,
const void *l, const void *l,
const void *r); const void *r);
/** @brief A debugging function that dumps the distribution of the /** @brief A debugging function that dumps the distribution of the
hash table: for each bucket, list the number of elements hash table: for each bucket, list the number of elements
contained within. */ contained within. */
void ht_dump_distribution(HashTable ht); extern _X_EXPORT void ht_dump_distribution(HashTable ht);
/** @brief A debugging function that dumps the contents of the hash /** @brief A debugging function that dumps the contents of the hash
table: for each bucket, list the elements contained table: for each bucket, list the elements contained
within. */ within. */
void ht_dump_contents(HashTable ht, extern _X_EXPORT void ht_dump_contents(HashTable ht,
void (*print_key)(void *opaque, void *key), void (*print_key)(void *opaque, void *key),
void (*print_value)(void *opaque, void *value), void (*print_value)(void *opaque, void *value),
void* opaque); void* opaque);
@ -123,14 +123,14 @@ void ht_dump_contents(HashTable ht,
be NULL. It uses HashXID underneath, and should HashXID be be NULL. It uses HashXID underneath, and should HashXID be
unable to hash the value, it switches into using the generic unable to hash the value, it switches into using the generic
hash function. */ hash function. */
unsigned ht_resourceid_hash(void *cdata, extern _X_EXPORT unsigned ht_resourceid_hash(void *cdata,
const void * data, const void * data,
int numBits); int numBits);
/** @brief A comparison function to be used for comparing resource /** @brief A comparison function to be used for comparing resource
IDs when used with HashTables. It makes no use of cdata, IDs when used with HashTables. It makes no use of cdata,
so that can be NULL. */ so that can be NULL. */
int ht_resourceid_compare(void *cdata, extern _X_EXPORT int ht_resourceid_compare(void *cdata,
const void *a, const void *a,
const void *b); const void *b);

View File

@ -9,6 +9,8 @@ srcs_xext = [
] ]
hdrs_xext = [ hdrs_xext = [
'geext.h',
'geint.h',
'syncsdk.h', 'syncsdk.h',
] ]
@ -35,6 +37,7 @@ endif
if build_xace if build_xace
srcs_xext += 'xace.c' srcs_xext += 'xace.c'
hdrs_xext += ['xace.h', 'xacestr.h']
endif endif
if build_xf86bigfont if build_xf86bigfont
@ -43,6 +46,7 @@ endif
if build_xinerama if build_xinerama
srcs_xext += ['panoramiX.c', 'panoramiXprocs.c', 'panoramiXSwap.c'] srcs_xext += ['panoramiX.c', 'panoramiXprocs.c', 'panoramiXSwap.c']
hdrs_xext += ['panoramiX.h', 'panoramiXsrv.h']
endif endif
if build_xsecurity if build_xsecurity
@ -58,13 +62,13 @@ if build_xv
hdrs_xext += ['xvdix.h', 'xvmcext.h'] hdrs_xext += ['xvdix.h', 'xvmcext.h']
endif endif
libxserver_xext = static_library('xserver_xext', libxserver_xext = static_library('libxserver_xext',
srcs_xext, srcs_xext,
include_directories: inc, include_directories: inc,
dependencies: common_dep, dependencies: common_dep,
) )
libxserver_xext_vidmode = static_library('xserver_xext_vidmode', libxserver_xext_vidmode = static_library('libxserver_xext_vidmode',
'vidmode.c', 'vidmode.c',
include_directories: inc, include_directories: inc,
dependencies: common_dep, dependencies: common_dep,

View File

@ -1,208 +0,0 @@
#include <dix-config.h>
#include <string.h>
#include <X11/Xdefs.h>
#include "os/auth.h"
#include "namespace.h"
struct Xnamespace ns_root = {
.allowMouseMotion = TRUE,
.allowShape = TRUE,
.allowTransparency = TRUE,
.allowXInput = TRUE,
.allowXKeyboard = TRUE,
.builtin = TRUE,
.name = NS_NAME_ROOT,
.refcnt = 1,
.superPower = TRUE,
};
struct Xnamespace ns_anon = {
.builtin = TRUE,
.name = NS_NAME_ANONYMOUS,
.refcnt = 1,
};
struct xorg_list ns_list = { 0 };
char *namespaceConfigFile = NULL;
static struct Xnamespace* select_ns(const char* name)
{
struct Xnamespace *walk;
xorg_list_for_each_entry(walk, &ns_list, entry) {
if (strcmp(walk->name, name)==0)
return walk;
}
struct Xnamespace *newns = calloc(1, sizeof(struct Xnamespace));
newns->name = strdup(name);
xorg_list_append(&newns->entry, &ns_list);
return newns;
}
#define atox(c) ('0' <= c && c <= '9' ? c - '0' : \
'a' <= c && c <= 'f' ? c - 'a' + 10 : \
'A' <= c && c <= 'F' ? c - 'A' + 10 : -1)
// warning: no error checking, no buffer clearing
static int hex2bin(const char *in, char *out)
{
while (in[0] && in[1]) {
int top = atox(in[0]);
if (top == -1)
return 0;
int bottom = atox(in[1]);
if (bottom == -1)
return 0;
*out++ = (top << 4) | bottom;
in += 2;
}
return 1;
}
/*
* loadConfig
*
* Load the container config
*/
static void parseLine(char *line, struct Xnamespace **walk_ns)
{
// trim newline and comments
char *c1 = strchr(line, '\n');
if (c1 != NULL)
*c1 = 0;
c1 = strchr(line, '#');
if (c1 != NULL)
*c1 = 0;
/* get the first token */
char *token = strtok(line, " ");
if (token == NULL)
return;
// if no "container" statement hasn't been issued yet, use root NS
struct Xnamespace * curr = (*walk_ns ? *walk_ns : &ns_root);
if (strcmp(token, "container") == 0)
{
if ((token = strtok(NULL, " ")) == NULL)
{
XNS_LOG("container missing id\n");
return;
}
curr = *walk_ns = select_ns(token);
return;
}
if (strcmp(token, "auth") == 0)
{
token = strtok(NULL, " ");
if (token == NULL)
return;
struct auth_token *new_token = calloc(1, sizeof(struct auth_token));
if (new_token == NULL)
FatalError("Xnamespace: failed allocating token\n");
new_token->authProto = strdup(token);
token = strtok(NULL, " ");
new_token->authTokenLen = strlen(token)/2;
new_token->authTokenData = calloc(1, new_token->authTokenLen);
if (!new_token->authTokenData) {
free(new_token);
return;
}
hex2bin(token, new_token->authTokenData);
new_token->authId = AddAuthorization(strlen(new_token->authProto),
new_token->authProto,
new_token->authTokenLen,
new_token->authTokenData);
xorg_list_append(&new_token->entry, &curr->auth_tokens);
return;
}
if (strcmp(token, "allow") == 0)
{
while ((token = strtok(NULL, " ")) != NULL)
{
if (strcmp(token, "mouse-motion") == 0)
curr->allowMouseMotion = TRUE;
else if (strcmp(token, "shape") == 0)
curr->allowShape = TRUE;
else if (strcmp(token, "transparency") == 0)
curr->allowTransparency = TRUE;
else if (strcmp(token, "xinput") == 0)
curr->allowXInput = TRUE;
else if (strcmp(token, "xkeyboard") == 0)
curr->allowXKeyboard = TRUE;
else
XNS_LOG("unknown allow: %s\n", token);
}
return;
}
if (strcmp(token, "superpower") == 0)
{
curr->superPower = TRUE;
return;
}
XNS_LOG("unknown token \"%s\"\n", token);
}
Bool XnsLoadConfig(void)
{
xorg_list_append_ndup(&ns_root.entry, &ns_list);
xorg_list_append_ndup(&ns_anon.entry, &ns_list);
if (!namespaceConfigFile) {
XNS_LOG("no namespace config given - Xnamespace disabled\n");
return FALSE;
}
FILE *fp = fopen(namespaceConfigFile, "r");
if (fp == NULL) {
FatalError("failed loading container config: %s\n", namespaceConfigFile);
return FALSE;
}
struct Xnamespace *walk_ns = NULL;
char linebuf[1024];
while (fgets(linebuf, sizeof(linebuf), fp) != NULL)
parseLine(linebuf, &walk_ns);
fclose(fp);
XNS_LOG("loaded namespace config file: %s\n", namespaceConfigFile);
struct Xnamespace *ns;
xorg_list_for_each_entry(ns, &ns_list, entry) {
XNS_LOG("namespace: \"%s\" \n", ns->name);
struct auth_token *at;
xorg_list_for_each_entry(at, &ns->auth_tokens, entry) {
XNS_LOG(" auth: \"%s\" \"", at->authProto);
for (int i=0; i<at->authTokenLen; i++)
printf("%02X", (unsigned char)at->authTokenData[i]);
printf("\"\n");
}
}
return TRUE;
}
struct Xnamespace *XnsFindByName(const char* name) {
struct Xnamespace *walk;
xorg_list_for_each_entry(walk, &ns_list, entry) {
if (strcmp(walk->name, name)==0)
return walk;
}
return NULL;
}

View File

@ -1,34 +0,0 @@
#define HOOK_NAME "client"
#include <dix-config.h>
#include "dix/dix_priv.h"
#include "dix/extension_priv.h"
#include "dix/registry_priv.h"
#include "mi/miinitext.h"
#include "include/extinit.h"
#include "include/extnsionst.h"
#include "include/propertyst.h"
#include "include/protocol-versions.h"
#include "include/windowstr.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
void hookClient(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceClientAccessRec);
struct XnamespaceClientPriv *obj = XnsClientPriv(param->target);
if (subj->ns->superPower || XnsClientSameNS(subj, obj))
return;
XNS_HOOK_LOG("BLOCKED access on client %d\n", param->target->index);
/* returning BadValue instead of BadAccess, because we're pretending
the requested client doens't even exist at all. */
param->status = BadValue;
}

View File

@ -1,45 +0,0 @@
#define HOOK_NAME "clienstate"
#include <dix-config.h>
#include "dix/registry_priv.h"
#include "os/client_priv.h"
#include "os/auth.h"
#include "namespace.h"
#include "hooks.h"
void hookClientState(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(NewClientInfoRec);
switch (client->clientState) {
case ClientStateInitial:
// better assign *someting* than null -- clients can't do anything yet anyways
XnamespaceAssignClient(subj, &ns_anon);
break;
case ClientStateRunning:
subj->authId = AuthorizationIDOfClient(client);
short unsigned int name_len = 0, data_len = 0;
const char * name = NULL;
char * data = NULL;
if (AuthorizationFromID(subj->authId, &name_len, &name, &data_len, &data)) {
XnamespaceAssignClient(subj, XnsFindByAuth(name_len, name, data_len, data));
} else {
XNS_HOOK_LOG("no auth data - assuming anon\n");
}
break;
case ClientStateRetained:
XnamespaceAssignClient(subj, NULL);
break;
case ClientStateGone:
XnamespaceAssignClient(subj, NULL);
break;
default:
XNS_HOOK_LOG("unknown state =%d\n", client->clientState);
break;
}
}

View File

@ -1,64 +0,0 @@
#define HOOK_NAME "device"
#include <dix-config.h>
#include <X11/extensions/XIproto.h>
#include <X11/extensions/XI2proto.h>
#include <X11/extensions/XKB.h>
#include "dix/dix_priv.h"
#include "dix/extension_priv.h"
#include "dix/registry_priv.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
void hookDevice(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceDeviceAccessRec);
if (subj->ns->superPower)
goto pass;
// should be safe to pass for anybody
switch (client->majorOp) {
case X_QueryPointer:
case X_GetInputFocus:
case X_GetKeyboardMapping:
case X_GetModifierMapping:
case X_GrabButton: // needed by xterm -- should be safe
goto pass;
case EXTENSION_MAJOR_XKEYBOARD:
switch(client->minorOp) {
case X_kbSelectEvents: // needed by xterm
case X_kbGetMap: // needed by xterm
case X_kbBell: // needed by GIMP
case X_kbPerClientFlags: // needed by firefox
case X_kbGetState: // needed by firefox
case X_kbGetNames: // needed by firefox
case X_kbGetControls: // needed by firefox
goto pass;
default:
XNS_HOOK_LOG("BLOCKED unhandled XKEYBOARD %s\n", LookupRequestName(client->majorOp, client->minorOp));
goto block;
}
case EXTENSION_MAJOR_XINPUT:
switch (client->minorOp) {
case X_ListInputDevices:
case X_XIQueryDevice:
goto pass;
default:
XNS_HOOK_LOG("BLOCKED unhandled Xinput request\n");
goto block;
}
}
block:
param->status = BadAccess;
return;
pass:
param->status = Success;
return;
}

View File

@ -1,67 +0,0 @@
#define HOOK_NAME "ext-access"
#include <dix-config.h>
#include "dix/dix_priv.h"
#include "dix/extension_priv.h"
#include "dix/registry_priv.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
/* called on X_QueryExtension */
void hookExtAccess(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceExtAccessRec);
/* root NS has super powers */
if (subj->ns->superPower)
goto pass;
switch (param->ext->index + EXTENSION_BASE) {
/* unrestricted access */
case EXTENSION_MAJOR_BIG_REQUESTS:
case EXTENSION_MAJOR_DAMAGE:
case EXTENSION_MAJOR_DOUBLE_BUFFER:
case EXTENSION_MAJOR_GENERIC_EVENT:
case EXTENSION_MAJOR_PRESENT:
case EXTENSION_MAJOR_SYNC:
case EXTENSION_MAJOR_XC_MISC:
case EXTENSION_MAJOR_XFIXES:
case EXTENSION_MAJOR_XKEYBOARD:
case EXTENSION_MAJOR_XRESOURCE:
goto pass;
/* really blacklisted */
case EXTENSION_MAJOR_MIT_SCREEN_SAVER:
case EXTENSION_MAJOR_RECORD:
case EXTENSION_MAJOR_SECURITY:
case EXTENSION_MAJOR_XTEST:
case EXTENSION_MAJOR_XVIDEO:
goto reject;
/* only allowed if namespace has flag set */
case EXTENSION_MAJOR_SHAPE:
if (subj->ns->allowShape)
goto pass;
goto reject;
/* only allowed if namespace has flag set */
case EXTENSION_MAJOR_XINPUT:
if (subj->ns->allowXInput)
goto pass;
goto reject;
}
XNS_HOOK_LOG("unhandled extension query: %s (%d)\n", param->ext->name, param->ext->index);
return;
reject:
param->status = BadAccess;
return;
pass:
param->status = Success;
return;
}

View File

@ -1,115 +0,0 @@
#define HOOK_NAME "ext-dispatch"
#include <dix-config.h>
#include <stdio.h>
#include <X11/Xdefs.h> // syncproto.h is broken
#include <X11/Xmd.h>
#include <X11/extensions/syncproto.h>
#include <X11/extensions/XIproto.h>
#include <X11/extensions/XKB.h>
#include <X11/extensions/xfixeswire.h>
#include "dix/dix_priv.h"
#include "dix/extension_priv.h"
#include "dix/registry_priv.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
void hookExtDispatch(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceExtAccessRec);
/* root NS has super powers */
if (subj->ns->superPower)
goto pass;
switch (client->majorOp) {
/* unrestricted access to these */
case EXTENSION_MAJOR_BIG_REQUESTS:
case EXTENSION_MAJOR_DAMAGE:
case EXTENSION_MAJOR_DOUBLE_BUFFER:
case EXTENSION_MAJOR_GENERIC_EVENT:
case EXTENSION_MAJOR_PRESENT:
case EXTENSION_MAJOR_XC_MISC:
case EXTENSION_MAJOR_XRESOURCE:
goto pass;
/* allow several operations */
case EXTENSION_MAJOR_XKEYBOARD:
if (subj->ns->allowXKeyboard)
goto pass;
switch (client->minorOp) {
case X_kbUseExtension:
case X_kbGetMap:
case X_kbSelectEvents: // fixme: might need special filtering
case X_kbGetState:
case X_kbGetNames:
case X_kbGetControls:
case X_kbPerClientFlags:
goto pass;
}
XNS_HOOK_LOG("BLOCKED unhandled XKEYBOARD call: %s\n", param->ext->name);
goto reject;
/* allow if namespace has flag set */
case EXTENSION_MAJOR_SHAPE:
if (subj->ns->allowShape)
goto pass;
break;
case EXTENSION_MAJOR_XINPUT:
if (subj->ns->allowXInput)
goto pass;
switch (client->minorOp) {
case X_ListInputDevices:
goto pass;
}
break;
case EXTENSION_MAJOR_XFIXES:
switch (client->minorOp) {
case X_XFixesQueryVersion:
case X_XFixesCreateRegion:
case X_XFixesSetCursorName:
case X_XFixesSelectSelectionInput:
goto pass;
}
XNS_HOOK_LOG("BLOCKED unhandled XFIXES call: %s\n", param->ext->name);
goto reject;
break;
case EXTENSION_MAJOR_SYNC:
switch (client->minorOp) {
case X_SyncCreateCounter:
case X_SyncDestroyCounter:
case X_SyncInitialize:
case X_SyncSetCounter:
goto pass;
}
XNS_HOOK_LOG("REJECT unhandled SYNC call: %s\n", param->ext->name);
goto reject;
break;
/* really blacklisted */
case EXTENSION_MAJOR_MIT_SCREEN_SAVER:
case EXTENSION_MAJOR_RECORD:
case EXTENSION_MAJOR_SECURITY:
case EXTENSION_MAJOR_XTEST:
goto reject;
break;
}
XNS_HOOK_LOG("unhandled extension call: %s\n", param->ext->name);
return;
reject:
XNS_HOOK_LOG("rejecting extension call: %s\n", param->ext->name);
param->status = BadAccess;
return;
pass:
param->status = Success;
return;
}

View File

@ -1,71 +0,0 @@
#define HOOK_NAME "initroot"
#include <dix-config.h>
#include <stdio.h>
#include <X11/Xatom.h>
#include <X11/Xmd.h>
#include "dix/window_priv.h"
#include "namespace.h"
#include "hooks.h"
static inline int setWinStrProp(WindowPtr pWin, Atom name, const char *text) {
return dixChangeWindowProperty(serverClient, pWin, name, XA_STRING,
8, PropModeReplace, strlen(text), text, TRUE);
}
void hookInitRootWindow(CallbackListPtr *pcbl, void *data, void *screen)
{
ScreenPtr pScreen = (ScreenPtr)screen;
// only act on first screen
if (pScreen->myNum)
return;
/* create the virtual root windows */
WindowPtr realRoot = pScreen->root;
assert(realRoot);
struct Xnamespace *walk;
xorg_list_for_each_entry(walk, &ns_list, entry) {
if (strcmp(walk->name, NS_NAME_ROOT)==0) {
walk->rootWindow = realRoot;
XNS_LOG("<%s> actual root 0x%0x\n", walk->name, walk->rootWindow->drawable.id);
continue;
}
int rc = 0;
WindowPtr pWin = dixCreateWindow(
FakeClientID(0), realRoot, 0, 0, 23, 23,
0, /* bw */
InputOutput,
0, /* vmask */
NULL, /* vlist */
0, /* depth */
serverClient,
wVisual(realRoot), /* visual */
&rc);
if (!pWin)
FatalError("hookInitRootWindow: cant create per-namespace root window for %s\n", walk->name);
Mask mask = pWin->eventMask;
pWin->eventMask = 0; /* subterfuge in case AddResource fails */
if (!AddResource(pWin->drawable.id, X11_RESTYPE_WINDOW, (void *) pWin))
FatalError("hookInitRootWindow: cant add per-namespace root window as resource\n");
pWin->eventMask = mask;
walk->rootWindow = pWin;
// set window name
char buf[PATH_MAX] = { 0 };
snprintf(buf, sizeof(buf)-1, "XNS-ROOT:%s", walk->name);
setWinStrProp(pWin, XA_WM_NAME, buf);
XNS_LOG("<%s> virtual root 0x%0x\n", walk->name, walk->rootWindow->drawable.id);
}
}

View File

@ -1,47 +0,0 @@
#define HOOK_NAME "property"
#include <dix-config.h>
#include <stdio.h>
#include "dix/dix_priv.h"
#include "dix/registry_priv.h"
#include "include/propertyst.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
static inline Bool winIsRoot(WindowPtr pWin) {
if (!pWin)
return FALSE;
if (pWin->drawable.pScreen->root == pWin)
return TRUE;
return FALSE;
}
void hookPropertyAccess(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XacePropertyAccessRec);
struct XnamespaceClientPriv *obj = XnsClientPriv(dixClientForWindow(param->pWin));
ATOM name = (*param->ppProp)->propertyName;
if (XnsClientSameNS(subj, obj))
return;
if (param->pWin == subj->ns->rootWindow)
return;
if (winIsRoot(param->pWin)) {
XNS_HOOK_LOG("window is the screen's root window\n");
} else {
XNS_HOOK_LOG("not a root window\n");
}
XNS_HOOK_LOG("access to property %s (atom 0x%x) window 0x%lx of client %d\n",
NameForAtom(name),
name,
(unsigned long)param->pWin->drawable.id,
dixClientForWindow(param->pWin)->index);
}

View File

@ -1,75 +0,0 @@
#define HOOK_NAME "recieve"
#include <dix-config.h>
#include <X11/Xmd.h>
#include "dix/extension_priv.h"
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "Xext/xacestr.h"
#include "Xi/exglobals.h"
#include "namespace.h"
#include "hooks.h"
static inline Bool isRootWin(WindowPtr pWin) {
return (pWin->parent == NullWindow && dixClientForWindow(pWin) == serverClient);
}
void
hookReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceReceiveAccessRec);
struct XnamespaceClientPriv *obj = XnsClientPriv(dixClientForWindow(param->pWin));
// send and receive within same namespace permitted without restrictions
if (XnsClientSameNS(subj, obj))
goto pass;
for (int i=0; i<param->count; i++) {
const int type = param->events[i].u.u.type;
switch (type) {
case GenericEvent: {
xGenericEvent *gev = (xGenericEvent*)&param->events[i].u;
if (gev->extension == EXTENSION_MAJOR_XINPUT) {
switch (gev->evtype) {
case XI_RawMotion:
if ((!subj->ns->allowMouseMotion) || !isRootWin(param->pWin))
goto reject;
continue;
case XI_RawKeyPress:
case XI_RawKeyRelease:
goto reject;
default:
XNS_HOOK_LOG("XI unknown %d\n", gev->evtype);
goto reject;
}
}
XNS_HOOK_LOG("BLOCKED #%d generic event extension=%d\n", i, gev->extension);
goto reject;
}
break;
default:
XNS_HOOK_LOG("BLOCKED event type #%d 0%0x 0%0x %s %s%s\n", i, type, param->events[i].u.u.detail,
LookupEventName(type), (type & 128) ? "fake" : "",
isRootWin(param->pWin) ? " (root window)" : "");
goto reject;
break;
}
}
pass:
return;
reject:
param->status = BadAccess;
XNS_HOOK_LOG("BLOCKED client %d [NS %s] receiving event sent to window 0x%lx of client %d [NS %s]\n",
client->index,
subj->ns->name,
(unsigned long)param->pWin->drawable.id,
dixClientForWindow(param->pWin)->index,
obj->ns->name);
return;
}

View File

@ -1,142 +0,0 @@
#define HOOK_NAME "resource"
#include <dix-config.h>
#include <X11/extensions/XI2proto.h>
#include "dix/dix_priv.h"
#include "dix/extension_priv.h"
#include "dix/registry_priv.h"
#include "dix/window_priv.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
static int checkAllowed(Mask requested, Mask allowed) {
return ((requested & allowed) == requested);
}
void hookResourceAccess(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceResourceAccessRec);
ClientPtr owner = dixLookupXIDOwner(param->id);
struct XnamespaceClientPriv *obj = XnsClientPriv(owner);
// server can do anything
if (param->client == serverClient)
goto pass;
// special filtering for windows: block transparency for untrusted clients
if (param->rtype == X11_RESTYPE_WINDOW) {
WindowPtr pWindow = (WindowPtr) param->res;
if (param->access_mode & DixCreateAccess) {
if (!subj->ns->allowTransparency) {
pWindow->forcedBG = TRUE;
}
}
}
// resource access inside same container is always permitted
if (XnsClientSameNS(subj, obj))
goto pass;
// check for root windows (screen or ns-virtual)
if (param->rtype == X11_RESTYPE_WINDOW) {
WindowPtr pWindow = (WindowPtr) param->res;
/* white-listed operations on namespace's virtual root window */
if (pWindow == subj->ns->rootWindow) {
switch (client->majorOp) {
case X_DeleteProperty:
case X_ChangeProperty:
case X_GetProperty:
case X_RotateProperties:
case X_QueryTree:
goto pass;
}
XNS_HOOK_LOG("unhandled access to NS' virtual root window 0x%0x\n", pWindow->drawable.id);
}
/* white-listed operations on actual root window */
if (pWindow && (pWindow == pWindow->drawable.pScreen->root)) {
switch (client->majorOp) {
case X_CreateWindow:
if (checkAllowed(param->access_mode, DixAddAccess))
goto pass;
break;
case X_CreateGC:
case X_CreatePixmap:
if (checkAllowed(param->access_mode, DixGetAttrAccess))
goto pass;
break;
// we reach here when destroying a top-level window:
// ProcDestroyWindow() checks whether one may remove a child
// from it's parent.
case X_DestroyWindow:
if (param->access_mode == DixRemoveAccess)
goto pass;
break;
case X_TranslateCoords:
case X_QueryTree:
goto pass;
case X_ChangeWindowAttributes:
case X_QueryPointer:
goto reject;
case X_SendEvent:
/* send hook needs to take care of this */
goto pass;
case EXTENSION_MAJOR_XINPUT:
switch(client->minorOp) {
// needed by xeyes. we should filter the mask
case X_XISelectEvents:
goto pass;
}
XNS_HOOK_LOG("unhandled XI operation on (real) root window\n");
goto reject;
}
}
}
/* server resources */
if (obj->isServer) {
if (param->rtype == X11_RESTYPE_COLORMAP) {
if (checkAllowed(param->access_mode, DixReadAccess | DixGetPropAccess | DixUseAccess | DixGetAttrAccess | DixAddAccess))
goto pass;
}
if (param->rtype == X11_RESTYPE_WINDOW) {
/* allowed ones should already been catched above */
XNS_HOOK_LOG("REJECT server owned window 0x%0x!\n", ((WindowPtr)param->res)->drawable.id);
goto reject;
}
if (checkAllowed(param->access_mode, DixReadAccess))
goto pass;
}
reject: ;
char accModeStr[128];
LookupDixAccessName(param->access_mode, (char*)&accModeStr, sizeof(accModeStr));
XNS_HOOK_LOG("BLOCKED access 0x%07lx %s to %s 0x%06lx of client %d @ %s\n",
(unsigned long)param->access_mode,
accModeStr,
LookupResourceName(param->rtype),
(unsigned long)param->id,
owner->index, // resource owner
obj->ns->name);
param->status = BadAccess;
return;
pass:
// request is passed as it is (or already had been rewritten)
param->status = Success;
}

View File

@ -1,67 +0,0 @@
#define HOOK_NAME "selection"
#include <dix-config.h>
#include <stdio.h>
#include "dix/selection_priv.h"
#include "namespace.h"
#include "hooks.h"
static inline const char *stripNS(const char* name) {
if ((!name) || (name[0] != '<'))
return name; // can this ever happen ?
const char *got = strchr(name, '>');
if (!got)
return name;
return ++got;
}
/*
* This hook is rewriting the client visible selection names to internally used,
* per namespace ones. Whenever a client is asking for a selection, it's name
* is replaced by a namespaced one, e.g. asking for "PRIMARY" while being in
* namespace "foo" will become "<foo>PRIMARY"
*
* A malicious client could still send specially crafted messages to others,
* asking them to send their selection data to him. This needs to be solved
* separately, by a send hook.
*/
void hookSelectionFilter(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(SelectionFilterParamRec);
/* no rewrite if client is in root namespace */
if (subj->ns->superPower)
return;
const char *origSelectionName = NameForAtom(param->selection);
char selname[PATH_MAX] = { 0 };
snprintf(selname, sizeof(selname)-1, "<%s>%s", subj->ns->name, origSelectionName);
Atom realSelection = MakeAtom(selname, strlen(selname), TRUE);
switch (param->op) {
case SELECTION_FILTER_GETOWNER:
case SELECTION_FILTER_SETOWNER:
case SELECTION_FILTER_CONVERT:
case SELECTION_FILTER_LISTEN:
// TODO: check whether window really belongs to the client
param->selection = realSelection;
break;
case SELECTION_FILTER_NOTIFY:
{
// need to translate back, since we're having the ns-prefixed name here
const char *stripped = stripNS(origSelectionName);
param->selection = MakeAtom(stripped, strlen(stripped), TRUE);
break;
}
// nothing to do here: already having the client visible name
case SELECTION_FILTER_EV_REQUEST:
case SELECTION_FILTER_EV_CLEAR:
break;
}
}

View File

@ -1,53 +0,0 @@
#define HOOK_NAME "send"
#include <dix-config.h>
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
/* TRUE if subj client is allowed to do things on obj)
* usually if they're in the same namespace or subj is in a parent
* namespace of obj
*/
static Bool clientAllowedOnClient(ClientPtr subj, ClientPtr obj) {
struct XnamespaceClientPriv *subjPriv = XnsClientPriv(subj);
struct XnamespaceClientPriv *objPriv = XnsClientPriv(obj);
if (subjPriv && subjPriv->ns->superPower)
return TRUE;
return XnsClientSameNS(subjPriv, objPriv);
}
void hookSend(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceSendAccessRec);
/* if no sending client, then it's coming internally from the server itself */
if (!client)
goto pass;
ClientPtr targetClient = dixClientForWindow(param->pWin);
struct XnamespaceClientPriv *obj = XnsClientPriv(targetClient);
if (clientAllowedOnClient(client, targetClient))
goto pass;
XNS_HOOK_LOG("BLOCK target @ %s\n", obj->ns->name);
for (int i = 0; i < param->count; i++) {
XNS_HOOK_LOG("sending event of type %s to window 0x%lx of client %d\n",
LookupEventName(param->events[i].u.u.type),
(unsigned long)param->pWin->drawable.id,
targetClient->index);
}
param->status = BadAccess;
return;
pass:
param->status = Success;
return;
}

View File

@ -1,37 +0,0 @@
#define HOOK_NAME "server"
#include <dix-config.h>
#include "dix/dix_priv.h"
#include "dix/registry_priv.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
void hookServerAccess(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(XaceServerAccessRec);
if (subj->ns->superPower)
goto pass;
switch (client->majorOp) {
case X_ListFonts:
case X_ListFontsWithInfo:
goto pass;
case X_GrabServer:
goto reject;
}
XNS_HOOK_LOG("BLOCKED access to server configuration request %s\n",
LookupRequestName(client->majorOp, client->minorOp));
reject:
param->status = BadAccess;
return;
pass:
param->status = Success;
}

View File

@ -1,44 +0,0 @@
#define HOOK_NAME "windowproperty"
#include <dix-config.h>
#include <X11/Xmd.h>
#include "dix/dix_priv.h"
#include "dix/property_priv.h"
#include "dix/window_priv.h"
#include "namespace.h"
#include "hooks.h"
void hookWindowProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(PropertyFilterParam);
// no redirect on super power
if (subj->ns->superPower)
return;
const ClientPtr owner = dixLookupXIDOwner(param->window);
if (!owner) {
param->status = BadWindow;
param->skip = TRUE;
XNS_HOOK_LOG("owner of window 0x%0x doesn't exist\n", param->window);
return;
}
// whitelist anything that goes to caller's own namespace
struct XnamespaceClientPriv *obj = XnsClientPriv(owner);
if (XnsClientSameNS(subj, obj))
return;
// allow access to namespace virtual root
if (param->window == subj->ns->rootWindow->drawable.id)
return;
// redirect root window access to namespace's virtual root
if (dixWindowIsRoot(param->window)) {
param->window = subj->ns->rootWindow->drawable.id;
return;
}
}

View File

@ -1,41 +0,0 @@
#ifndef __XSERVER_NAMESPACE_HOOKS_H
#define __XSERVER_NAMESPACE_HOOKS_H
#include "dix/registry_priv.h"
#include "include/misc.h"
#include "namespace.h"
#define XNS_HOOK_LOG(...) do { \
printf("XNS [" HOOK_NAME "] (#%d@%d) {%s} <%s>: ", \
(client ? client->index : -1), \
(client ? client->sequence : -1), \
(subj ? (subj->ns ? subj->ns->name : "(no ns)") : "<no client>"), \
LookupRequestName(client ? client->majorOp : 0, \
client ? client->minorOp : 0)); \
printf(__VA_ARGS__); \
} while (0)
#define XNS_HOOK_HEAD(t) \
t *param = calldata; \
ClientPtr client = param->client; \
if (!client) { \
/* XNS_LOG("hook %s NULL client\n", HOOK_NAME); */ \
} \
struct XnamespaceClientPriv *subj = XnsClientPriv(client);
void hookClient(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookClientState(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookDevice(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookExtAccess(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookExtDispatch(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookInitRootWindow(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookPropertyAccess(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookReceive(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookResourceAccess(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookSelectionFilter(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookSend(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookServerAccess(CallbackListPtr *pcbl, void *unused, void *calldata);
void hookWindowProperty(CallbackListPtr *pcbl, void *unused, void *calldata);
#endif /* __XSERVER_NAMESPACE_HOOKS_H */

View File

@ -1,22 +0,0 @@
libxserver_namespace = static_library(
'xserver_namespace',
[
'config.c',
'hook-client.c',
'hook-clientstate.c',
'hook-device.c',
'hook-ext-access.c',
'hook-ext-dispatch.c',
'hook-init-rootwindow.c',
'hook-property.c',
'hook-receive.c',
'hook-resource.c',
'hook-selection.c',
'hook-send.c',
'hook-server.c',
'hook-windowproperty.c',
'namespace.c',
],
include_directories: inc,
dependencies: common_dep,
)

View File

@ -1,92 +0,0 @@
#include <dix-config.h>
#include <stdio.h>
#include <X11/Xmd.h>
#include "dix/dix_priv.h"
#include "dix/property_priv.h"
#include "dix/selection_priv.h"
#include "include/os.h"
#include "miext/extinit_priv.h"
#include "Xext/xacestr.h"
#include "namespace.h"
#include "hooks.h"
Bool noNamespaceExtension = TRUE;
DevPrivateKeyRec namespaceClientPrivKeyRec = { 0 };
void
NamespaceExtensionInit(void)
{
XNS_LOG("initializing namespace extension ...\n");
/* load configuration */
if (!XnsLoadConfig()) {
XNS_LOG("No config file. disabling Xns extension\n");
return;
}
if (!(dixRegisterPrivateKey(&namespaceClientPrivKeyRec, PRIVATE_CLIENT,
sizeof(struct XnamespaceClientPriv)) &&
AddCallback(&ClientStateCallback, hookClientState, NULL) &&
AddCallback(&PostInitRootWindowCallback, hookInitRootWindow, NULL) &&
AddCallback(&PropertyFilterCallback, hookWindowProperty, NULL) &&
AddCallback(&SelectionFilterCallback, hookSelectionFilter, NULL) &&
XaceRegisterCallback(XACE_CLIENT_ACCESS, hookClient, NULL) &&
XaceRegisterCallback(XACE_DEVICE_ACCESS, hookDevice, NULL) &&
XaceRegisterCallback(XACE_EXT_DISPATCH, hookExtDispatch, NULL) &&
XaceRegisterCallback(XACE_EXT_ACCESS, hookExtAccess, NULL) &&
XaceRegisterCallback(XACE_PROPERTY_ACCESS, hookPropertyAccess, NULL) &&
XaceRegisterCallback(XACE_RECEIVE_ACCESS, hookReceive, NULL) &&
XaceRegisterCallback(XACE_RESOURCE_ACCESS, hookResourceAccess, NULL) &&
XaceRegisterCallback(XACE_SEND_ACCESS, hookSend, NULL) &&
XaceRegisterCallback(XACE_SERVER_ACCESS, hookServerAccess, NULL)))
FatalError("NamespaceExtensionInit: allocation failure\n");
/* Do the serverClient */
struct XnamespaceClientPriv *srv = XnsClientPriv(serverClient);
*srv = (struct XnamespaceClientPriv) { .isServer = TRUE };
XnamespaceAssignClient(srv, &ns_root);
}
void XnamespaceAssignClient(struct XnamespaceClientPriv *priv, struct Xnamespace *newns)
{
if (priv->ns != NULL)
priv->ns->refcnt--;
priv->ns = newns;
if (newns != NULL)
newns->refcnt++;
}
void XnamespaceAssignClientByName(struct XnamespaceClientPriv *priv, const char *name)
{
struct Xnamespace *newns = XnsFindByName(name);
if (newns == NULL)
newns = &ns_anon;
XnamespaceAssignClient(priv, newns);
}
struct Xnamespace* XnsFindByAuth(size_t szAuthProto, const char* authProto, size_t szAuthToken, const char* authToken)
{
struct Xnamespace *walk;
xorg_list_for_each_entry(walk, &ns_list, entry) {
struct auth_token *at;
xorg_list_for_each_entry(at, &walk->auth_tokens, entry) {
int protoLen = at->authProto ? strlen(at->authProto) : 0;
if ((protoLen == szAuthProto) &&
(at->authTokenLen == szAuthToken) &&
(memcmp(at->authTokenData, authToken, szAuthToken)==0) &&
(memcmp(at->authProto, authProto, szAuthProto)==0))
return walk;
}
}
// default to anonymous if credentials aren't assigned to specific NS
return &ns_anon;
}

View File

@ -1,82 +0,0 @@
#ifndef __XSERVER_NAMESPACE_H
#define __XSERVER_NAMESPACE_H
#include <stdio.h>
#include <X11/Xmd.h>
#include "include/dixstruct.h"
#include "include/list.h"
#include "include/privates.h"
#include "include/window.h"
#include "include/windowstr.h"
struct auth_token {
struct xorg_list entry;
const char *authProto;
char *authTokenData;
size_t authTokenLen;
XID authId;
};
struct Xnamespace {
struct xorg_list entry;
const char *name;
Bool builtin;
Bool allowMouseMotion;
Bool allowShape;
Bool allowTransparency;
Bool allowXInput;
Bool allowXKeyboard;
Bool superPower;
struct xorg_list auth_tokens;
size_t refcnt;
WindowPtr rootWindow;
};
extern struct xorg_list ns_list;
extern struct Xnamespace ns_root;
extern struct Xnamespace ns_anon;
struct XnamespaceClientPriv {
Bool isServer;
XID authId;
struct Xnamespace* ns;
};
#define NS_NAME_ROOT "root"
#define NS_NAME_ANONYMOUS "anon"
extern DevPrivateKeyRec namespaceClientPrivKeyRec;
Bool XnsLoadConfig(void);
struct Xnamespace *XnsFindByName(const char* name);
struct Xnamespace* XnsFindByAuth(size_t szAuthProto, const char* authProto, size_t szAuthToken, const char* authToken);
void XnamespaceAssignClient(struct XnamespaceClientPriv *priv, struct Xnamespace *ns);
void XnamespaceAssignClientByName(struct XnamespaceClientPriv *priv, const char *name);
static inline struct XnamespaceClientPriv *XnsClientPriv(ClientPtr client) {
if (client == NULL) return NULL;
return dixLookupPrivate(&client->devPrivates, &namespaceClientPrivKeyRec);
}
static inline Bool XnsClientSameNS(struct XnamespaceClientPriv *p1, struct XnamespaceClientPriv *p2)
{
if (!p1 && !p2)
return TRUE;
if (!p1 || !p2)
return FALSE;
return (p1->ns == p2->ns);
}
#define XNS_LOG(...) do { printf("XNS "); printf(__VA_ARGS__); } while (0)
static inline Bool streq(const char *a, const char *b)
{
if (!a && !b)
return TRUE;
if (!a || !b)
return FALSE;
return (strcmp(a,b) == 0);
}
#endif /* __XSERVER_NAMESPACE_H */

View File

@ -1,18 +0,0 @@
# auth <proto> <hex-key>
auth MIT-MAGIC-COOKIE-1 46f8e62b78e58962de0ceefc05ad90b0
auth MIT-MAGIC-COOKIE-1 56f8e62b78e58962de0ceefc05ad90b0
# container <name> <parent_name>
container xeyes root
auth MIT-MAGIC-COOKIE-1 46f8e62b78e58962de0ceefc05ad90b8
auth MIT-MAGIC-COOKIE-1 46f8e62b78e58962de0ceefc05ad90a8
allow mouse-motion
allow shape
allow xinput
container xclock root
auth MIT-MAGIC-COOKIE-1 46f8e62b78e58962de0ceefc05ad90b7
auth MIT-MAGIC-COOKIE-1 46f8e62b78e58962de0ceefc05ad91b7
auth MIT-MAGIC-COOKIE-1 46f8e62b78e58962de0ceefc05ad92b7
auth MIT-MAGIC-COOKIE-1 46f8e62b78e58962de0ceefc05ad93b7

View File

@ -23,21 +23,18 @@ dealings in this Software without prior written authorization from Digital
Equipment Corporation. Equipment Corporation.
******************************************************************/ ******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/Xarch.h> #include <X11/Xarch.h>
#include <X11/extensions/panoramiXproto.h>
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "dix/screen_hooks_priv.h"
#include "miext/extinit_priv.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h" #include "misc.h"
#include "cursor.h" #include "cursor.h"
#include "cursorstr.h" #include "cursorstr.h"
@ -49,13 +46,19 @@ Equipment Corporation.
#include "window.h" #include "window.h"
#include "windowstr.h" #include "windowstr.h"
#include "pixmapstr.h" #include "pixmapstr.h"
#include "panoramiX.h"
#include <X11/extensions/panoramiXproto.h>
#include "panoramiXsrv.h"
#include "globals.h" #include "globals.h"
#include "servermd.h" #include "servermd.h"
#include "resource.h" #include "resource.h"
#include "picturestr_priv.h" #include "picturestr.h"
#include "xfixesint.h" #include "xfixesint.h"
#include "damageextint.h" #include "damageextint.h"
#ifdef COMPOSITE
#include "compint.h" #include "compint.h"
#endif
#include "extinit.h"
#include "protocol-versions.h" #include "protocol-versions.h"
#ifdef GLXPROXY #ifdef GLXPROXY
@ -63,9 +66,6 @@ extern VisualPtr glxMatchVisual(ScreenPtr pScreen,
VisualPtr pVisual, ScreenPtr pMatchScreen); VisualPtr pVisual, ScreenPtr pMatchScreen);
#endif #endif
/* Xinerama is disabled by default unless enabled via +xinerama */
Bool noPanoramiXExtension = TRUE;
/* /*
* PanoramiX data declarations * PanoramiX data declarations
*/ */
@ -74,7 +74,7 @@ int PanoramiXPixWidth = 0;
int PanoramiXPixHeight = 0; int PanoramiXPixHeight = 0;
int PanoramiXNumScreens = 0; int PanoramiXNumScreens = 0;
RegionRec PanoramiXScreenRegion = { {0, 0, 0, 0}, NULL }; _X_EXPORT RegionRec PanoramiXScreenRegion = { {0, 0, 0, 0}, NULL };
static int PanoramiXNumDepths; static int PanoramiXNumDepths;
static DepthPtr PanoramiXDepths; static DepthPtr PanoramiXDepths;
@ -88,7 +88,7 @@ RESTYPE XRT_GC;
RESTYPE XRT_COLORMAP; RESTYPE XRT_COLORMAP;
static Bool VisualsEqual(VisualPtr, ScreenPtr, VisualPtr); static Bool VisualsEqual(VisualPtr, ScreenPtr, VisualPtr);
static XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr = &VisualsEqual; XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr = &VisualsEqual;
/* /*
* Function prototypes * Function prototypes
@ -123,6 +123,7 @@ typedef struct {
typedef struct { typedef struct {
CreateGCProcPtr CreateGC; CreateGCProcPtr CreateGC;
CloseScreenProcPtr CloseScreen;
} PanoramiXScreenRec, *PanoramiXScreenPtr; } PanoramiXScreenRec, *PanoramiXScreenPtr;
static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr); static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
@ -147,23 +148,21 @@ static const GCFuncs XineramaGCFuncs = {
pGCPriv->wrapFuncs = (pGC)->funcs;\ pGCPriv->wrapFuncs = (pGC)->funcs;\
(pGC)->funcs = &XineramaGCFuncs; (pGC)->funcs = &XineramaGCFuncs;
static void XineramaCloseScreen(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unsused) static Bool
XineramaCloseScreen(ScreenPtr pScreen)
{ {
dixScreenUnhookClose(pScreen, XineramaCloseScreen);
PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr) PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey); dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
if (!pScreenPriv) pScreen->CloseScreen = pScreenPriv->CloseScreen;
return;
pScreen->CreateGC = pScreenPriv->CreateGC; pScreen->CreateGC = pScreenPriv->CreateGC;
if (pScreen->myNum == 0) if (pScreen->myNum == 0)
RegionUninit(&PanoramiXScreenRegion); RegionUninit(&PanoramiXScreenRegion);
free(pScreenPriv); free(pScreenPriv);
dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey, NULL);
return (*pScreen->CloseScreen) (pScreen);
} }
static Bool static Bool
@ -353,7 +352,7 @@ PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
data.screen = screen; data.screen = screen;
data.id = id; data.id = id;
return LookupClientResourceComplex(dixClientForXID(id), type, return LookupClientResourceComplex(clients[CLIENT_ID(id)], type,
XineramaFindIDByScrnum, &data); XineramaFindIDByScrnum, &data);
} }
@ -369,7 +368,7 @@ XineramaRegisterConnectionBlockCallback(void (*func) (void))
{ {
XineramaConnectionCallbackList *newlist; XineramaConnectionCallbackList *newlist;
if (!(newlist = calloc(1, sizeof(XineramaConnectionCallbackList)))) if (!(newlist = malloc(sizeof(XineramaConnectionCallbackList))))
return FALSE; return FALSE;
newlist->next = ConnectionCallbackList; newlist->next = ConnectionCallbackList;
@ -385,7 +384,7 @@ XineramaInitData(void)
int i, w, h; int i, w, h;
RegionNull(&PanoramiXScreenRegion); RegionNull(&PanoramiXScreenRegion);
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS(i) {
BoxRec TheBox; BoxRec TheBox;
RegionRec ScreenRegion; RegionRec ScreenRegion;
@ -419,6 +418,13 @@ XineramaInitData(void)
} }
} }
void
XineramaReinitData(void)
{
RegionUninit(&PanoramiXScreenRegion);
XineramaInitData();
}
/* /*
* PanoramiXExtensionInit(): * PanoramiXExtensionInit():
* Called from InitExtensions in main(). * Called from InitExtensions in main().
@ -433,6 +439,7 @@ PanoramiXExtensionInit(void)
Bool success = FALSE; Bool success = FALSE;
ExtensionEntry *extEntry; ExtensionEntry *extEntry;
ScreenPtr pScreen = screenInfo.screens[0]; ScreenPtr pScreen = screenInfo.screens[0];
PanoramiXScreenPtr pScreenPriv;
if (noPanoramiXExtension) if (noPanoramiXExtension)
return; return;
@ -467,9 +474,9 @@ PanoramiXExtensionInit(void)
* run in non-PanoramiXeen mode. * run in non-PanoramiXeen mode.
*/ */
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS(i) {
pScreen = screenInfo.screens[i]; pScreen = screenInfo.screens[i];
PanoramiXScreenPtr pScreenPriv = calloc(1, sizeof(PanoramiXScreenRec)); pScreenPriv = malloc(sizeof(PanoramiXScreenRec));
dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey, dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
pScreenPriv); pScreenPriv);
if (!pScreenPriv) { if (!pScreenPriv) {
@ -477,10 +484,11 @@ PanoramiXExtensionInit(void)
return; return;
} }
dixScreenHookClose(pScreen, XineramaCloseScreen);
pScreenPriv->CreateGC = pScreen->CreateGC; pScreenPriv->CreateGC = pScreen->CreateGC;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CreateGC = XineramaCreateGC; pScreen->CreateGC = XineramaCreateGC;
pScreen->CloseScreen = XineramaCloseScreen;
} }
XRC_DRAWABLE = CreateNewResourceClass(); XRC_DRAWABLE = CreateNewResourceClass();
@ -576,7 +584,10 @@ PanoramiXExtensionInit(void)
PanoramiXRenderInit(); PanoramiXRenderInit();
PanoramiXFixesInit(); PanoramiXFixesInit();
PanoramiXDamageInit(); PanoramiXDamageInit();
#ifdef COMPOSITE
PanoramiXCompositeInit(); PanoramiXCompositeInit();
#endif
} }
Bool Bool
@ -795,6 +806,7 @@ extern void
PanoramiXConsolidate(void) PanoramiXConsolidate(void)
{ {
int i; int i;
PanoramiXRes *root, *defmap, *saver;
ScreenPtr pScreen = screenInfo.screens[0]; ScreenPtr pScreen = screenInfo.screens[0];
DepthPtr pDepth = pScreen->allowedDepths; DepthPtr pDepth = pScreen->allowedDepths;
VisualPtr pVisual = pScreen->visuals; VisualPtr pVisual = pScreen->visuals;
@ -808,26 +820,14 @@ PanoramiXConsolidate(void)
for (i = 0; i < pScreen->numVisuals; i++) for (i = 0; i < pScreen->numVisuals; i++)
PanoramiXMaybeAddVisual(pVisual++); PanoramiXMaybeAddVisual(pVisual++);
PanoramiXRes *root = calloc(1, sizeof(PanoramiXRes)); root = malloc(sizeof(PanoramiXRes));
if (!root)
return;
root->type = XRT_WINDOW; root->type = XRT_WINDOW;
PanoramiXRes *defmap = calloc(1, sizeof(PanoramiXRes)); defmap = malloc(sizeof(PanoramiXRes));
if (!defmap) {
free(root);
return;
}
defmap->type = XRT_COLORMAP; defmap->type = XRT_COLORMAP;
PanoramiXRes *saver = calloc(1, sizeof(PanoramiXRes)); saver = malloc(sizeof(PanoramiXRes));
if (!saver) {
free(root);
free(defmap);
return;
}
saver->type = XRT_WINDOW; saver->type = XRT_WINDOW;
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS(i) {
ScreenPtr scr = screenInfo.screens[i]; ScreenPtr scr = screenInfo.screens[i];
root->info[i].id = scr->root->drawable.id; root->info[i].id = scr->root->drawable.id;
@ -889,7 +889,9 @@ PanoramiXResetProc(ExtensionEntry * extEntry)
PanoramiXRenderReset(); PanoramiXRenderReset();
PanoramiXFixesReset(); PanoramiXFixesReset();
PanoramiXDamageReset(); PanoramiXDamageReset();
#ifdef COMPOSITE
PanoramiXCompositeReset (); PanoramiXCompositeReset ();
#endif
screenInfo.numScreens = PanoramiXNumScreens; screenInfo.numScreens = PanoramiXNumScreens;
for (i = 256; i--;) for (i = 256; i--;)
ProcVector[i] = SavedProcVector[i]; ProcVector[i] = SavedProcVector[i];
@ -1070,7 +1072,7 @@ ProcXineramaQueryScreens(ClientPtr client)
xXineramaScreenInfo scratch; xXineramaScreenInfo scratch;
int i; int i;
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS(i) {
scratch.x_org = screenInfo.screens[i]->x; scratch.x_org = screenInfo.screens[i]->x;
scratch.y_org = screenInfo.screens[i]->y; scratch.y_org = screenInfo.screens[i]->y;
scratch.width = screenInfo.screens[i]->width; scratch.width = screenInfo.screens[i]->width;
@ -1169,7 +1171,7 @@ XineramaGetImageData(DrawablePtr *pDrawables,
depth = (format == XYPixmap) ? 1 : pDraw->depth; depth = (format == XYPixmap) ? 1 : pDraw->depth;
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS(i) {
BoxRec TheBox; BoxRec TheBox;
ScreenPtr pScreen; ScreenPtr pScreen;
@ -1251,16 +1253,12 @@ XineramaGetImageData(DrawablePtr *pDrawables,
for (j = 0, index = (pitch * y) + x, index2 = 0; j < h; for (j = 0, index = (pitch * y) + x, index2 = 0; j < h;
j++, index += pitch, index2 += ScratchPitch) { j++, index += pitch, index2 += ScratchPitch) {
if (w) { if (w) {
if (!shift) { if (!shift)
assert(ScratchMem);
memcpy(data + index, ScratchMem + index2, w); memcpy(data + index, ScratchMem + index2, w);
} else
else {
assert(ScratchMem);
CopyBits(data + index, shift, CopyBits(data + index, shift,
ScratchMem + index2, w); ScratchMem + index2, w);
} }
}
if (leftover) { if (leftover) {
data[index + w] |= data[index + w] |=
@ -1279,7 +1277,6 @@ XineramaGetImageData(DrawablePtr *pDrawables,
w *= j; w *= j;
for (j = 0; j < h; j++) { for (j = 0; j < h; j++) {
assert(ScratchMem);
memcpy(data + (pitch * (y + j)) + x, memcpy(data + (pitch * (y + j)) + x,
ScratchMem + (ScratchPitch * j), w); ScratchMem + (ScratchPitch * j), w);
} }

View File

@ -32,14 +32,16 @@ Equipment Corporation.
* PanoramiX definitions * PanoramiX definitions
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#ifndef _PANORAMIX_H_ #ifndef _PANORAMIX_H_
#define _PANORAMIX_H_ #define _PANORAMIX_H_
#include <X11/Xmd.h> #define _PANORAMIX_SERVER
#include <X11/extensions/panoramiXproto.h> #include <X11/extensions/panoramiXproto.h>
#undef _PANORAMIX_SERVER
#include "gcstruct.h" #include "gcstruct.h"
#include "dixstruct.h" #include "dixstruct.h"
@ -69,6 +71,7 @@ typedef struct {
#define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++) #define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++)
#define FOR_NSCREENS_FORWARD_SKIP(j) for(j = 1; j < PanoramiXNumScreens; j++) #define FOR_NSCREENS_FORWARD_SKIP(j) for(j = 1; j < PanoramiXNumScreens; j++)
#define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--) #define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--)
#define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j)
#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) #define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared)

View File

@ -23,16 +23,13 @@ dealings in this Software without prior written authorization from Digital
Equipment Corporation. Equipment Corporation.
******************************************************************/ ******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/panoramiXproto.h>
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h" #include "misc.h"
#include "cursor.h" #include "cursor.h"
#include "cursorstr.h" #include "cursorstr.h"
@ -44,13 +41,28 @@ Equipment Corporation.
#include "window.h" #include "window.h"
#include "windowstr.h" #include "windowstr.h"
#include "pixmapstr.h" #include "pixmapstr.h"
#include "panoramiX.h"
#include <X11/extensions/panoramiXproto.h>
#include "panoramiXsrv.h"
#include "globals.h" #include "globals.h"
#include "panoramiXh.h" #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 static int _X_COLD
SProcPanoramiXGetState(ClientPtr client) SProcPanoramiXGetState(ClientPtr client)
{ {
REQUEST(xPanoramiXGetStateReq); REQUEST(xPanoramiXGetStateReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
swapl(&stuff->window); swapl(&stuff->window);
return ProcPanoramiXGetState(client); return ProcPanoramiXGetState(client);
@ -60,6 +72,8 @@ static int _X_COLD
SProcPanoramiXGetScreenCount(ClientPtr client) SProcPanoramiXGetScreenCount(ClientPtr client)
{ {
REQUEST(xPanoramiXGetScreenCountReq); REQUEST(xPanoramiXGetScreenCountReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
swapl(&stuff->window); swapl(&stuff->window);
return ProcPanoramiXGetScreenCount(client); return ProcPanoramiXGetScreenCount(client);
@ -69,19 +83,41 @@ static int _X_COLD
SProcPanoramiXGetScreenSize(ClientPtr client) SProcPanoramiXGetScreenSize(ClientPtr client)
{ {
REQUEST(xPanoramiXGetScreenSizeReq); REQUEST(xPanoramiXGetScreenSizeReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
swapl(&stuff->window); swapl(&stuff->window);
swapl(&stuff->screen); swapl(&stuff->screen);
return ProcPanoramiXGetScreenSize(client); 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 int _X_COLD
SProcPanoramiXDispatch(ClientPtr client) SProcPanoramiXDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data) {
case X_PanoramiXQueryVersion: case X_PanoramiXQueryVersion:
return ProcPanoramiXQueryVersion(client); return SProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState: case X_PanoramiXGetState:
return SProcPanoramiXGetState(client); return SProcPanoramiXGetState(client);
case X_PanoramiXGetScreenCount: case X_PanoramiXGetScreenCount:
@ -89,9 +125,9 @@ SProcPanoramiXDispatch(ClientPtr client)
case X_PanoramiXGetScreenSize: case X_PanoramiXGetScreenSize:
return SProcPanoramiXGetScreenSize(client); return SProcPanoramiXGetScreenSize(client);
case X_XineramaIsActive: case X_XineramaIsActive:
return ProcXineramaIsActive(client); return SProcXineramaIsActive(client);
case X_XineramaQueryScreens: case X_XineramaQueryScreens:
return ProcXineramaQueryScreens(client); return SProcXineramaQueryScreens(client);
} }
return BadRequest; return BadRequest;
} }

View File

@ -1,10 +1,8 @@
/* /*
* Server dispatcher function replacements * Server dispatcher function replacements
*/ */
#ifndef XSERVER_PANORAMIXH_H
#define XSERVER_PANORAMIXH_H
extern int PanoramiXCreateWindow(ClientPtr client); extern int PanoramiXCreateWindow(ClientPtr client);
extern int PanoramiXChangeWindowAttributes(ClientPtr client); extern int PanoramiXChangeWindowAttributes(ClientPtr client);
extern int PanoramiXDestroyWindow(ClientPtr client); extern int PanoramiXDestroyWindow(ClientPtr client);
@ -73,5 +71,3 @@ extern int connBlockScreenStart;
extern xConnSetupPrefix connSetupPrefix; extern xConnSetupPrefix connSetupPrefix;
extern int (*SavedProcVector[256]) (ClientPtr client); extern int (*SavedProcVector[256]) (ClientPtr client);
#endif /* XSERVER_PANORAMIXH_H */

View File

@ -25,26 +25,25 @@ Equipment Corporation.
/* Massively rewritten by Mark Vojkovich <markv@valinux.com> */ /* Massively rewritten by Mark Vojkovich <markv@valinux.com> */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include "dix/dix_priv.h"
#include "os/osdep.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "windowstr.h" #include "windowstr.h"
#include "dixfontstr.h" #include "dixfontstr.h"
#include "gcstruct.h" #include "gcstruct.h"
#include "colormapst.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "opaque.h" #include "opaque.h"
#include "inputstr.h" #include "inputstr.h"
#include "migc.h" #include "migc.h"
#include "misc.h" #include "misc.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "panoramiX.h"
#include "panoramiXsrv.h"
#include "resource.h" #include "resource.h"
#include "panoramiXh.h" #include "panoramiXh.h"
@ -116,7 +115,7 @@ PanoramiXCreateWindow(ClientPtr client)
} }
} }
if (!(newWin = calloc(1, sizeof(PanoramiXRes)))) if (!(newWin = malloc(sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newWin->type = XRT_WINDOW; newWin->type = XRT_WINDOW;
@ -476,7 +475,7 @@ PanoramiXConfigureWindow(ClientPtr client)
/* because we need the parent */ /* because we need the parent */
result = dixLookupResourceByType((void **) &pWin, stuff->window, result = dixLookupResourceByType((void **) &pWin, stuff->window,
X11_RESTYPE_WINDOW, client, DixWriteAccess); RT_WINDOW, client, DixWriteAccess);
if (result != Success) if (result != Success)
return result; return result;
@ -556,6 +555,7 @@ PanoramiXCirculateWindow(ClientPtr client)
int int
PanoramiXGetGeometry(ClientPtr client) PanoramiXGetGeometry(ClientPtr client)
{ {
xGetGeometryReply rep;
DrawablePtr pDraw; DrawablePtr pDraw;
int rc; int rc;
@ -566,7 +566,7 @@ PanoramiXGetGeometry(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
xGetGeometryReply rep = { rep = (xGetGeometryReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0, .length = 0,
@ -600,16 +600,7 @@ PanoramiXGetGeometry(ClientPtr client)
rep.borderWidth = pWin->borderWidth; rep.borderWidth = pWin->borderWidth;
} }
if (client->swapped) { WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
swaps(&rep.sequenceNumber);
swapl(&rep.root);
swaps(&rep.x);
swaps(&rep.y);
swaps(&rep.width);
swaps(&rep.height);
swaps(&rep.borderWidth);
}
WriteToClient(client, sizeof(xGetGeometryReply), &rep);
return Success; return Success;
} }
@ -621,6 +612,7 @@ PanoramiXTranslateCoords(ClientPtr client)
REQUEST(xTranslateCoordsReq); REQUEST(xTranslateCoordsReq);
int rc; int rc;
WindowPtr pWin, pDst; WindowPtr pWin, pDst;
xTranslateCoordsReply rep;
REQUEST_SIZE_MATCH(xTranslateCoordsReq); REQUEST_SIZE_MATCH(xTranslateCoordsReq);
rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess); rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess);
@ -629,8 +621,7 @@ PanoramiXTranslateCoords(ClientPtr client)
rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess); rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rep = (xTranslateCoordsReply) {
xTranslateCoordsReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0, .length = 0,
@ -681,13 +672,7 @@ PanoramiXTranslateCoords(ClientPtr client)
rep.dstY += screenInfo.screens[0]->y; rep.dstY += screenInfo.screens[0]->y;
} }
if (client->swapped) { WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
swaps(&rep.sequenceNumber);
swapl(&rep.child);
swaps(&rep.dstX);
swaps(&rep.dstY);
}
WriteToClient(client, sizeof(rep), &rep);
return Success; return Success;
} }
@ -707,7 +692,7 @@ PanoramiXCreatePixmap(ClientPtr client)
if (result != Success) if (result != Success)
return (result == BadValue) ? BadDrawable : result; return (result == BadValue) ? BadDrawable : result;
if (!(newPix = calloc(1, sizeof(PanoramiXRes)))) if (!(newPix = malloc(sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newPix->type = XRT_PIXMAP; newPix->type = XRT_PIXMAP;
@ -814,7 +799,7 @@ PanoramiXCreateGC(ClientPtr client)
} }
} }
if (!(newGC = calloc(1, sizeof(PanoramiXRes)))) if (!(newGC = malloc(sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newGC->type = XRT_GC; newGC->type = XRT_GC;
@ -930,7 +915,7 @@ PanoramiXCopyGC(ClientPtr client)
if (result != Success) if (result != Success)
return result; return result;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
stuff->srcGC = srcGC->info[j].id; stuff->srcGC = srcGC->info[j].id;
stuff->dstGC = dstGC->info[j].id; stuff->dstGC = dstGC->info[j].id;
result = (*SavedProcVector[X_CopyGC]) (client); result = (*SavedProcVector[X_CopyGC]) (client);
@ -1111,11 +1096,11 @@ PanoramiXCopyArea(ClientPtr client)
if ((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) { if ((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) {
DrawablePtr drawables[MAXSCREENS]; DrawablePtr drawables[MAXSCREENS];
DrawablePtr pDst; DrawablePtr pDst;
GCPtr pGC = NULL; GCPtr pGC;
char *data; char *data;
int pitch, rc; int pitch, rc;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
rc = dixLookupDrawable(drawables + j, src->info[j].id, client, 0, rc = dixLookupDrawable(drawables + j, src->info[j].id, client, 0,
DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
@ -1149,7 +1134,7 @@ PanoramiXCopyArea(ClientPtr client)
} }
free(data); free(data);
if (pGC && pGC->graphicsExposures) { if (pGC->graphicsExposures) {
RegionRec rgn; RegionRec rgn;
int dx, dy; int dx, dy;
BoxRec sourceBox; BoxRec sourceBox;
@ -1169,7 +1154,7 @@ PanoramiXCopyArea(ClientPtr client)
RegionInit(&rgn, &sourceBox, 1); RegionInit(&rgn, &sourceBox, 1);
/* subtract the (screen-space) clips of the source drawables */ /* subtract the (screen-space) clips of the source drawables */
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
ScreenPtr screen = screenInfo.screens[j]; ScreenPtr screen = screenInfo.screens[j];
RegionPtr sd; RegionPtr sd;
@ -1387,6 +1372,7 @@ PanoramiXPolyPoint(ClientPtr client)
{ {
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
int result, npoint, j; int result, npoint, j;
xPoint *origPts;
Bool isRoot; Bool isRoot;
REQUEST(xPolyPointReq); REQUEST(xPolyPointReq);
@ -1409,10 +1395,7 @@ PanoramiXPolyPoint(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) { if (npoint > 0) {
xPoint *origPts = calloc(npoint, sizeof(xPoint)); origPts = xallocarray(npoint, sizeof(xPoint));
if (!origPts)
return BadAlloc;
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1454,6 +1437,7 @@ PanoramiXPolyLine(ClientPtr client)
{ {
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
int result, npoint, j; int result, npoint, j;
xPoint *origPts;
Bool isRoot; Bool isRoot;
REQUEST(xPolyLineReq); REQUEST(xPolyLineReq);
@ -1476,9 +1460,7 @@ PanoramiXPolyLine(ClientPtr client)
isRoot = IS_ROOT_DRAWABLE(draw); isRoot = IS_ROOT_DRAWABLE(draw);
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0) { if (npoint > 0) {
xPoint *origPts = calloc(npoint, sizeof(xPoint)); origPts = xallocarray(npoint, sizeof(xPoint));
if (!origPts)
return BadAlloc;
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1520,6 +1502,7 @@ PanoramiXPolySegment(ClientPtr client)
{ {
int result, nsegs, i, j; int result, nsegs, i, j;
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
xSegment *origSegs;
Bool isRoot; Bool isRoot;
REQUEST(xPolySegmentReq); REQUEST(xPolySegmentReq);
@ -1546,9 +1529,7 @@ PanoramiXPolySegment(ClientPtr client)
return BadLength; return BadLength;
nsegs >>= 3; nsegs >>= 3;
if (nsegs > 0) { if (nsegs > 0) {
xSegment *origSegs = calloc(nsegs, sizeof(xSegment)); origSegs = xallocarray(nsegs, sizeof(xSegment));
if (!origSegs)
return BadAlloc;
memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1590,6 +1571,7 @@ PanoramiXPolyRectangle(ClientPtr client)
int result, nrects, i, j; int result, nrects, i, j;
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
Bool isRoot; Bool isRoot;
xRectangle *origRecs;
REQUEST(xPolyRectangleReq); REQUEST(xPolyRectangleReq);
@ -1615,9 +1597,7 @@ PanoramiXPolyRectangle(ClientPtr client)
return BadLength; return BadLength;
nrects >>= 3; nrects >>= 3;
if (nrects > 0) { if (nrects > 0) {
xRectangle *origRecs = calloc(nrects, sizeof(xRectangle)); origRecs = xallocarray(nrects, sizeof(xRectangle));
if (!origRecs)
return BadAlloc;
memcpy((char *) origRecs, (char *) &stuff[1], memcpy((char *) origRecs, (char *) &stuff[1],
nrects * sizeof(xRectangle)); nrects * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1658,6 +1638,7 @@ PanoramiXPolyArc(ClientPtr client)
int result, narcs, i, j; int result, narcs, i, j;
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
Bool isRoot; Bool isRoot;
xArc *origArcs;
REQUEST(xPolyArcReq); REQUEST(xPolyArcReq);
@ -1683,9 +1664,7 @@ PanoramiXPolyArc(ClientPtr client)
return BadLength; return BadLength;
narcs /= sizeof(xArc); narcs /= sizeof(xArc);
if (narcs > 0) { if (narcs > 0) {
xArc *origArcs = calloc(narcs, sizeof(xArc)); origArcs = xallocarray(narcs, sizeof(xArc));
if (!origArcs)
return BadAlloc;
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1724,6 +1703,7 @@ PanoramiXFillPoly(ClientPtr client)
int result, count, j; int result, count, j;
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
Bool isRoot; Bool isRoot;
DDXPointPtr locPts;
REQUEST(xFillPolyReq); REQUEST(xFillPolyReq);
@ -1746,9 +1726,7 @@ PanoramiXFillPoly(ClientPtr client)
count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq)); count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0) { if (count > 0) {
DDXPointPtr locPts = calloc(count, sizeof(DDXPointRec)); locPts = xallocarray(count, sizeof(DDXPointRec));
if (!locPts)
return BadAlloc;
memcpy((char *) locPts, (char *) &stuff[1], memcpy((char *) locPts, (char *) &stuff[1],
count * sizeof(DDXPointRec)); count * sizeof(DDXPointRec));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1791,6 +1769,8 @@ PanoramiXPolyFillRectangle(ClientPtr client)
int result, things, i, j; int result, things, i, j;
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
Bool isRoot; Bool isRoot;
xRectangle *origRects;
REQUEST(xPolyFillRectangleReq); REQUEST(xPolyFillRectangleReq);
REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
@ -1815,9 +1795,7 @@ PanoramiXPolyFillRectangle(ClientPtr client)
return BadLength; return BadLength;
things >>= 3; things >>= 3;
if (things > 0) { if (things > 0) {
xRectangle *origRects = calloc(things, sizeof(xRectangle)); origRects = xallocarray(things, sizeof(xRectangle));
if (!origRects)
return BadAlloc;
memcpy((char *) origRects, (char *) &stuff[1], memcpy((char *) origRects, (char *) &stuff[1],
things * sizeof(xRectangle)); things * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1858,6 +1836,7 @@ PanoramiXPolyFillArc(ClientPtr client)
PanoramiXRes *gc, *draw; PanoramiXRes *gc, *draw;
Bool isRoot; Bool isRoot;
int result, narcs, i, j; int result, narcs, i, j;
xArc *origArcs;
REQUEST(xPolyFillArcReq); REQUEST(xPolyFillArcReq);
@ -1883,9 +1862,7 @@ PanoramiXPolyFillArc(ClientPtr client)
return BadLength; return BadLength;
narcs /= sizeof(xArc); narcs /= sizeof(xArc);
if (narcs > 0) { if (narcs > 0) {
xArc *origArcs = calloc(narcs, sizeof(xArc)); origArcs = xallocarray(narcs, sizeof(xArc));
if (!origArcs)
return BadAlloc;
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) { FOR_NSCREENS_FORWARD(j) {
@ -1967,6 +1944,7 @@ PanoramiXGetImage(ClientPtr client)
DrawablePtr drawables[MAXSCREENS]; DrawablePtr drawables[MAXSCREENS];
DrawablePtr pDraw; DrawablePtr pDraw;
PanoramiXRes *draw; PanoramiXRes *draw;
xGetImageReply xgi;
Bool isRoot; Bool isRoot;
char *pBuf; char *pBuf;
int i, x, y, w, h, format, rc; int i, x, y, w, h, format, rc;
@ -2040,7 +2018,12 @@ PanoramiXGetImage(ClientPtr client)
IncludeInferiors); IncludeInferiors);
} }
xgi = (xGetImageReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.visual = wVisual(((WindowPtr) pDraw)),
.depth = pDraw->depth
};
if (format == ZPixmap) { if (format == ZPixmap) {
widthBytesLine = PixmapBytePad(w, pDraw->depth); widthBytesLine = PixmapBytePad(w, pDraw->depth);
length = widthBytesLine * h; length = widthBytesLine * h;
@ -2054,13 +2037,7 @@ PanoramiXGetImage(ClientPtr client)
} }
xGetImageReply rep = { xgi.length = bytes_to_int32(length);
.type = X_Reply,
.sequenceNumber = client->sequence,
.visual = wVisual(((WindowPtr) pDraw)),
.depth = pDraw->depth,
.length = bytes_to_int32(length),
};
if (widthBytesLine == 0 || h == 0) if (widthBytesLine == 0 || h == 0)
linesPerBuf = 0; linesPerBuf = 0;
@ -2071,15 +2048,10 @@ PanoramiXGetImage(ClientPtr client)
if (linesPerBuf > h) if (linesPerBuf > h)
linesPerBuf = h; linesPerBuf = h;
} }
if (!(pBuf = calloc(linesPerBuf, widthBytesLine))) if (!(pBuf = xallocarray(linesPerBuf, widthBytesLine)))
return BadAlloc; return BadAlloc;
if (client->swapped) { WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.visual);
}
WriteToClient(client, sizeof(rep), &rep);
if (linesPerBuf == 0) { if (linesPerBuf == 0) {
/* nothing to do */ /* nothing to do */
@ -2315,7 +2287,7 @@ PanoramiXCreateColormap(ClientPtr client)
if (result != Success) if (result != Success)
return result; return result;
if (!(newCmap = calloc(1, sizeof(PanoramiXRes)))) if (!(newCmap = malloc(sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newCmap->type = XRT_COLORMAP; newCmap->type = XRT_COLORMAP;
@ -2387,7 +2359,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
if (result != Success) if (result != Success)
return result; return result;
if (!(newCmap = calloc(1, sizeof(PanoramiXRes)))) if (!(newCmap = malloc(sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newCmap->type = XRT_COLORMAP; newCmap->type = XRT_COLORMAP;

View File

@ -1,33 +1,34 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#ifndef _PANORAMIXSRV_H_ #ifndef _PANORAMIXSRV_H_
#define _PANORAMIXSRV_H_ #define _PANORAMIXSRV_H_
#include "panoramiX.h" #include "panoramiX.h"
extern int PanoramiXNumScreens; extern _X_EXPORT int PanoramiXNumScreens;
extern int PanoramiXPixWidth; extern _X_EXPORT int PanoramiXPixWidth;
extern int PanoramiXPixHeight; extern _X_EXPORT int PanoramiXPixHeight;
extern RegionRec PanoramiXScreenRegion; extern _X_EXPORT RegionRec PanoramiXScreenRegion;
// exported for nvidia extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig);
_X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig); extern _X_EXPORT void PanoramiXConsolidate(void);
extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void);
extern _X_EXPORT PanoramiXRes *PanoramiXFindIDByScrnum(RESTYPE, XID, int);
extern _X_EXPORT Bool
XineramaRegisterConnectionBlockCallback(void (*func) (void));
extern _X_EXPORT int XineramaDeleteResource(void *, XID);
void PanoramiXConsolidate(void); extern _X_EXPORT void XineramaReinitData(void);
Bool PanoramiXCreateConnectionBlock(void);
PanoramiXRes *PanoramiXFindIDByScrnum(RESTYPE, XID, int);
Bool XineramaRegisterConnectionBlockCallback(void (*func) (void));
int XineramaDeleteResource(void *, XID);
/* only exported for Nvidia legacy. This really shouldn't be used by drivers */
extern _X_EXPORT RESTYPE XRC_DRAWABLE; extern _X_EXPORT RESTYPE XRC_DRAWABLE;
extern _X_EXPORT RESTYPE XRT_WINDOW;
extern RESTYPE XRT_WINDOW; extern _X_EXPORT RESTYPE XRT_PIXMAP;
extern RESTYPE XRT_PIXMAP; extern _X_EXPORT RESTYPE XRT_GC;
extern RESTYPE XRT_GC; extern _X_EXPORT RESTYPE XRT_COLORMAP;
extern RESTYPE XRT_COLORMAP; extern _X_EXPORT RESTYPE XRT_PICTURE;
extern RESTYPE XRT_PICTURE;
/* /*
* Drivers are allowed to wrap this function. Each wrapper can decide that the * Drivers are allowed to wrap this function. Each wrapper can decide that the
@ -37,8 +38,9 @@ extern RESTYPE XRT_PICTURE;
* screen 0. * screen 0.
*/ */
typedef Bool (*XineramaVisualsEqualProcPtr) (VisualPtr, ScreenPtr, VisualPtr); typedef Bool (*XineramaVisualsEqualProcPtr) (VisualPtr, ScreenPtr, VisualPtr);
extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr;
void XineramaGetImageData(DrawablePtr *pDrawables, extern _X_EXPORT void XineramaGetImageData(DrawablePtr *pDrawables,
int left, int left,
int top, int top,
int width, int width,

View File

@ -26,23 +26,12 @@ in this Software without prior written authorization from the X Consortium.
* Author: Keith Packard, MIT X Consortium * Author: Keith Packard, MIT X Consortium
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.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 "dix/window_priv.h"
#include "miext/extinit_priv.h"
#include "os/osdep.h"
#include "os/screensaver.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "windowstr.h" #include "windowstr.h"
@ -51,27 +40,53 @@ in this Software without prior written authorization from the X Consortium.
#include "extnsionst.h" #include "extnsionst.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "resource.h" #include "resource.h"
#include "opaque.h"
#include <X11/extensions/saverproto.h>
#include "gcstruct.h" #include "gcstruct.h"
#include "cursorstr.h" #include "cursorstr.h"
#include "colormapst.h"
#include "xace.h" #include "xace.h"
#include "inputstr.h" #include "inputstr.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#ifdef DPMSExtension #ifdef DPMSExtension
#include <X11/extensions/dpmsconst.h> #include <X11/extensions/dpmsconst.h>
#include "dpmsproc.h" #include "dpmsproc.h"
#endif #endif
#include "protocol-versions.h" #include "protocol-versions.h"
Bool noScreenSaverExtension = FALSE; #include <stdio.h>
#include "extinit.h"
static int ScreenSaverEventBase = 0; static int ScreenSaverEventBase = 0;
static Bool ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force); static Bool ScreenSaverHandle(ScreenPtr /* pScreen */ ,
static Bool CreateSaverWindow(ScreenPtr pScreen); int /* xstate */ ,
static Bool DestroySaverWindow(ScreenPtr pScreen); Bool /* force */
static void UninstallSaverColormap(ScreenPtr pScreen); );
static void CheckScreenPrivate(ScreenPtr pScreen);
static void SScreenSaverNotifyEvent(xScreenSaverNotifyEvent *from, static Bool
xScreenSaverNotifyEvent *to); 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 */ static RESTYPE SuspendType; /* resource type for suspension records */
@ -178,6 +193,8 @@ static DevPrivateKeyRec ScreenPrivateKeyRec;
dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v); dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v);
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL) #define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL)
#define New(t) (malloc(sizeof (t)))
static void static void
CheckScreenPrivate(ScreenPtr pScreen) CheckScreenPrivate(ScreenPtr pScreen)
{ {
@ -200,7 +217,7 @@ MakeScreenPrivate(ScreenPtr pScreen)
if (pPriv) if (pPriv)
return pPriv; return pPriv;
pPriv = calloc(1, sizeof(ScreenSaverScreenPrivateRec)); pPriv = New(ScreenSaverScreenPrivateRec);
if (!pPriv) if (!pPriv)
return 0; return 0;
pPriv->events = 0; pPriv->events = 0;
@ -250,7 +267,7 @@ setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask)
} }
else { else {
if (!pEv) { if (!pEv) {
pEv = calloc(1, sizeof(ScreenSaverEventRec)); pEv = New(ScreenSaverEventRec);
if (!pEv) { if (!pEv) {
CheckScreenPrivate(pScreen); CheckScreenPrivate(pScreen);
return FALSE; return FALSE;
@ -271,10 +288,13 @@ setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask)
static void static void
FreeAttrs(ScreenSaverAttrPtr pAttr) FreeAttrs(ScreenSaverAttrPtr pAttr)
{ {
PixmapPtr pPixmap;
CursorPtr pCursor; CursorPtr pCursor;
dixDestroyPixmap(pAttr->pBackgroundPixmap, 0); if ((pPixmap = pAttr->pBackgroundPixmap) != 0)
dixDestroyPixmap(pAttr->pBorderPixmap, 0); (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
if ((pPixmap = pAttr->pBorderPixmap) != 0)
(*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
if ((pCursor = pAttr->pCursor) != 0) if ((pCursor = pAttr->pCursor) != 0)
FreeCursor(pCursor, (Cursor) 0); FreeCursor(pCursor, (Cursor) 0);
} }
@ -430,7 +450,7 @@ UninstallSaverColormap(ScreenPtr pScreen)
if (pPriv && pPriv->installedMap != None) { if (pPriv && pPriv->installedMap != None) {
rc = dixLookupResourceByType((void **) &pCmap, pPriv->installedMap, rc = dixLookupResourceByType((void **) &pCmap, pPriv->installedMap,
X11_RESTYPE_COLORMAP, serverClient, RT_COLORMAP, serverClient,
DixUninstallAccess); DixUninstallAccess);
if (rc == Success) if (rc == Success)
(*pCmap->pScreen->UninstallColormap) (pCmap); (*pCmap->pScreen->UninstallColormap) (pCmap);
@ -454,7 +474,7 @@ CreateSaverWindow(ScreenPtr pScreen)
pSaver = &pScreen->screensaver; pSaver = &pScreen->screensaver;
if (pSaver->pWindow) { if (pSaver->pWindow) {
pSaver->pWindow = NullWindow; pSaver->pWindow = NullWindow;
FreeResource(pSaver->wid, X11_RESTYPE_NONE); FreeResource(pSaver->wid, RT_NONE);
if (pPriv) { if (pPriv) {
UninstallSaverColormap(pScreen); UninstallSaverColormap(pScreen);
pPriv->hasWindow = FALSE; pPriv->hasWindow = FALSE;
@ -470,7 +490,7 @@ CreateSaverWindow(ScreenPtr pScreen)
if (GrabInProgress && GrabInProgress != pAttr->client->index) if (GrabInProgress && GrabInProgress != pAttr->client->index)
return FALSE; return FALSE;
pWin = dixCreateWindow(pSaver->wid, pScreen->root, pWin = CreateWindow(pSaver->wid, pScreen->root,
pAttr->x, pAttr->y, pAttr->width, pAttr->height, pAttr->x, pAttr->y, pAttr->width, pAttr->height,
pAttr->borderWidth, pAttr->class, pAttr->borderWidth, pAttr->class,
pAttr->mask, (XID *) pAttr->values, pAttr->mask, (XID *) pAttr->values,
@ -478,7 +498,7 @@ CreateSaverWindow(ScreenPtr pScreen)
if (!pWin) if (!pWin)
return FALSE; return FALSE;
if (!AddResource(pWin->drawable.id, X11_RESTYPE_WINDOW, pWin)) if (!AddResource(pWin->drawable.id, RT_WINDOW, pWin))
return FALSE; return FALSE;
mask = 0; mask = 0;
@ -495,11 +515,13 @@ CreateSaverWindow(ScreenPtr pScreen)
mask |= CWBorderPixmap; mask |= CWBorderPixmap;
} }
if (pAttr->pCursor) { if (pAttr->pCursor) {
CursorPtr cursor;
if (!pWin->optional)
if (!MakeWindowOptional(pWin)) { if (!MakeWindowOptional(pWin)) {
FreeResource(pWin->drawable.id, X11_RESTYPE_NONE); FreeResource(pWin->drawable.id, RT_NONE);
return FALSE; return FALSE;
} }
CursorPtr cursor = RefCursor(pAttr->pCursor); cursor = RefCursor(pAttr->pCursor);
if (pWin->optional->cursor) if (pWin->optional->cursor)
FreeCursor(pWin->optional->cursor, (Cursor) 0); FreeCursor(pWin->optional->cursor, (Cursor) 0);
pWin->optional->cursor = cursor; pWin->optional->cursor = cursor;
@ -524,7 +546,7 @@ CreateSaverWindow(ScreenPtr pScreen)
if (wantMap == None || IsMapInstalled(wantMap, pWin)) if (wantMap == None || IsMapInstalled(wantMap, pWin))
return TRUE; return TRUE;
result = dixLookupResourceByType((void **) &pCmap, wantMap, X11_RESTYPE_COLORMAP, result = dixLookupResourceByType((void **) &pCmap, wantMap, RT_COLORMAP,
serverClient, DixInstallAccess); serverClient, DixInstallAccess);
if (result != Success) if (result != Success)
return TRUE; return TRUE;
@ -548,7 +570,7 @@ DestroySaverWindow(ScreenPtr pScreen)
pSaver = &pScreen->screensaver; pSaver = &pScreen->screensaver;
if (pSaver->pWindow) { if (pSaver->pWindow) {
pSaver->pWindow = NullWindow; pSaver->pWindow = NullWindow;
FreeResource(pSaver->wid, X11_RESTYPE_NONE); FreeResource(pSaver->wid, RT_NONE);
} }
pPriv->hasWindow = FALSE; pPriv->hasWindow = FALSE;
CheckScreenPrivate(pScreen); CheckScreenPrivate(pScreen);
@ -579,9 +601,9 @@ ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force)
ret = TRUE; ret = TRUE;
} }
#ifdef XINERAMA #ifdef PANORAMIX
if (noPanoramiXExtension || !pScreen->myNum) if (noPanoramiXExtension || !pScreen->myNum)
#endif /* XINERAMA */ #endif
SendScreenSaverNotify(pScreen, state, force); SendScreenSaverNotify(pScreen, state, force);
return ret; return ret;
} }
@ -592,6 +614,7 @@ ProcScreenSaverQueryVersion(ClientPtr client)
xScreenSaverQueryVersionReply rep = { xScreenSaverQueryVersionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_SAVER_MAJOR_VERSION, .majorVersion = SERVER_SAVER_MAJOR_VERSION,
.minorVersion = SERVER_SAVER_MINOR_VERSION .minorVersion = SERVER_SAVER_MINOR_VERSION
}; };
@ -600,8 +623,7 @@ ProcScreenSaverQueryVersion(ClientPtr client)
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion); swapl(&rep.length);
swaps(&rep.minorVersion);
} }
WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), &rep); WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), &rep);
return Success; return Success;
@ -611,6 +633,7 @@ static int
ProcScreenSaverQueryInfo(ClientPtr client) ProcScreenSaverQueryInfo(ClientPtr client)
{ {
REQUEST(xScreenSaverQueryInfoReq); REQUEST(xScreenSaverQueryInfoReq);
xScreenSaverQueryInfoReply rep;
int rc; int rc;
ScreenSaverStuffPtr pSaver; ScreenSaverStuffPtr pSaver;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -622,7 +645,8 @@ ProcScreenSaverQueryInfo(ClientPtr client)
DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rc = XaceHookScreensaverAccess(client, pDraw->pScreen, DixGetAttrAccess); rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
@ -632,24 +656,30 @@ ProcScreenSaverQueryInfo(ClientPtr client)
UpdateCurrentTime(); UpdateCurrentTime();
lastInput = GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds; lastInput = GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds;
xScreenSaverQueryInfoReply rep = { rep = (xScreenSaverQueryInfoReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.window = pSaver->wid .window = pSaver->wid
}; };
if (screenIsSaved != SCREEN_SAVER_OFF) { if (screenIsSaved != SCREEN_SAVER_OFF) {
rep.state = ScreenSaverOn; rep.state = ScreenSaverOn;
if (ScreenSaverTime) if (ScreenSaverTime)
rep.tilOrSince = lastInput - ScreenSaverTime; rep.tilOrSince = lastInput - ScreenSaverTime;
else
rep.tilOrSince = 0;
} }
else { else {
if (ScreenSaverTime) { if (ScreenSaverTime) {
rep.state = ScreenSaverOff; rep.state = ScreenSaverOff;
if (ScreenSaverTime >= lastInput) if (ScreenSaverTime < lastInput)
rep.tilOrSince = 0;
else
rep.tilOrSince = ScreenSaverTime - lastInput; rep.tilOrSince = ScreenSaverTime - lastInput;
} }
else { else {
rep.state = ScreenSaverDisabled; rep.state = ScreenSaverDisabled;
rep.tilOrSince = 0;
} }
} }
rep.idle = lastInput; rep.idle = lastInput;
@ -662,6 +692,7 @@ ProcScreenSaverQueryInfo(ClientPtr client)
rep.kind = ScreenSaverInternal; rep.kind = ScreenSaverInternal;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window); swapl(&rep.window);
swapl(&rep.tilOrSince); swapl(&rep.tilOrSince);
swapl(&rep.idle); swapl(&rep.idle);
@ -684,7 +715,8 @@ ProcScreenSaverSelectInput(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
rc = XaceHookScreensaverAccess(client, pDraw->pScreen, DixSetAttrAccess); rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixSetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
@ -694,8 +726,9 @@ ProcScreenSaverSelectInput(ClientPtr client)
} }
static int static int
ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff) ScreenSaverSetAttributes(ClientPtr client)
{ {
REQUEST(xScreenSaverSetAttributesReq);
DrawablePtr pDraw; DrawablePtr pDraw;
WindowPtr pParent; WindowPtr pParent;
ScreenPtr pScreen; ScreenPtr pScreen;
@ -718,6 +751,7 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
Colormap cmap; Colormap cmap;
ColormapPtr pCmap; ColormapPtr pCmap;
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess); DixGetAttrAccess);
if (ret != Success) if (ret != Success)
@ -725,11 +759,11 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
pScreen = pDraw->pScreen; pScreen = pDraw->pScreen;
pParent = pScreen->root; pParent = pScreen->root;
ret = XaceHookScreensaverAccess(client, pScreen, DixSetAttrAccess); ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
if (ret != Success) if (ret != Success)
return ret; return ret;
len = client->req_len - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len) if (Ones(stuff->mask) != len)
return BadLength; return BadLength;
if (!stuff->width || !stuff->height) { if (!stuff->width || !stuff->height) {
@ -749,7 +783,7 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
depth = stuff->depth; depth = stuff->depth;
visual = stuff->visualID; visual = stuff->visualID;
/* copied directly from dixCreateWindow */ /* copied directly from CreateWindow */
if (class == CopyFromParent) if (class == CopyFromParent)
class = pParent->drawable.class; class = pParent->drawable.class;
@ -802,7 +836,7 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
return BadMatch; return BadMatch;
} }
/* end of errors from dixCreateWindow */ /* end of errors from CreateWindow */
pPriv = GetScreenPrivate(pScreen); pPriv = GetScreenPrivate(pScreen);
if (pPriv && pPriv->attr) { if (pPriv && pPriv->attr) {
@ -814,13 +848,13 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
if (!pPriv) if (!pPriv)
return FALSE; return FALSE;
} }
pAttr = calloc(1, sizeof(ScreenSaverAttrRec)); pAttr = New(ScreenSaverAttrRec);
if (!pAttr) { if (!pAttr) {
ret = BadAlloc; ret = BadAlloc;
goto bail; goto bail;
} }
/* over allocate for override redirect */ /* over allocate for override redirect */
pAttr->values = values = calloc(len + 1, sizeof(unsigned long)); pAttr->values = values = xallocarray(len + 1, sizeof(unsigned long));
if (!values) { if (!values) {
ret = BadAlloc; ret = BadAlloc;
goto bail; goto bail;
@ -865,7 +899,7 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
else { else {
ret = ret =
dixLookupResourceByType((void **) &pPixmap, pixID, dixLookupResourceByType((void **) &pPixmap, pixID,
X11_RESTYPE_PIXMAP, client, DixReadAccess); RT_PIXMAP, client, DixReadAccess);
if (ret == Success) { if (ret == Success) {
if ((pPixmap->drawable.depth != depth) || if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) { (pPixmap->drawable.pScreen != pScreen)) {
@ -897,7 +931,7 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
else { else {
ret = ret =
dixLookupResourceByType((void **) &pPixmap, pixID, dixLookupResourceByType((void **) &pPixmap, pixID,
X11_RESTYPE_PIXMAP, client, DixReadAccess); RT_PIXMAP, client, DixReadAccess);
if (ret == Success) { if (ret == Success) {
if ((pPixmap->drawable.depth != depth) || if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) { (pPixmap->drawable.pScreen != pScreen)) {
@ -980,7 +1014,7 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
break; break;
case CWColormap: case CWColormap:
cmap = (Colormap) * pVlist; cmap = (Colormap) * pVlist;
ret = dixLookupResourceByType((void **) &pCmap, cmap, X11_RESTYPE_COLORMAP, ret = dixLookupResourceByType((void **) &pCmap, cmap, RT_COLORMAP,
client, DixUseAccess); client, DixUseAccess);
if (ret != Success) { if (ret != Success) {
client->errorValue = cmap; client->errorValue = cmap;
@ -1000,7 +1034,7 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
} }
else { else {
ret = dixLookupResourceByType((void **) &pCursor, cursorID, ret = dixLookupResourceByType((void **) &pCursor, cursorID,
X11_RESTYPE_CURSOR, client, DixUseAccess); RT_CURSOR, client, DixUseAccess);
if (ret != Success) { if (ret != Success) {
client->errorValue = cursorID; client->errorValue = cursorID;
goto PatchUp; goto PatchUp;
@ -1034,13 +1068,16 @@ ScreenSaverSetAttributes(ClientPtr client, xScreenSaverSetAttributesReq *stuff)
} }
static int static int
ScreenSaverUnsetAttributes(ClientPtr client, Drawable drawable) ScreenSaverUnsetAttributes(ClientPtr client)
{ {
REQUEST(xScreenSaverSetAttributesReq);
DrawablePtr pDraw; DrawablePtr pDraw;
ScreenSaverScreenPrivatePtr pPriv; ScreenSaverScreenPrivatePtr pPriv;
int rc; int rc;
rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixGetAttrAccess); REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
pPriv = GetScreenPrivate(pDraw->pScreen); pPriv = GetScreenPrivate(pDraw->pScreen);
@ -1056,11 +1093,9 @@ ScreenSaverUnsetAttributes(ClientPtr client, Drawable drawable)
static int static int
ProcScreenSaverSetAttributes(ClientPtr client) ProcScreenSaverSetAttributes(ClientPtr client)
{ {
REQUEST(xScreenSaverSetAttributesReq); #ifdef PANORAMIX
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
#ifdef XINERAMA
if (!noPanoramiXExtension) { if (!noPanoramiXExtension) {
REQUEST(xScreenSaverSetAttributesReq);
PanoramiXRes *draw; PanoramiXRes *draw;
PanoramiXRes *backPix = NULL; PanoramiXRes *backPix = NULL;
PanoramiXRes *bordPix = NULL; PanoramiXRes *bordPix = NULL;
@ -1069,13 +1104,15 @@ ProcScreenSaverSetAttributes(ClientPtr client)
int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
XID orig_visual, tmp; XID orig_visual, tmp;
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
status = dixLookupResourceByClass((void **) &draw, stuff->drawable, status = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess); XRC_DRAWABLE, client, DixWriteAccess);
if (status != Success) if (status != Success)
return (status == BadValue) ? BadDrawable : status; return (status == BadValue) ? BadDrawable : status;
len = len =
client->req_len - stuff->length -
bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len) if (Ones(stuff->mask) != len)
return BadLength; return BadLength;
@ -1130,27 +1167,26 @@ ProcScreenSaverSetAttributes(ClientPtr client)
if (orig_visual != CopyFromParent) if (orig_visual != CopyFromParent)
stuff->visualID = PanoramiXTranslateVisualID(i, orig_visual); stuff->visualID = PanoramiXTranslateVisualID(i, orig_visual);
status = ScreenSaverSetAttributes(client, stuff); status = ScreenSaverSetAttributes(client);
} }
return status; return status;
} }
#endif /* XINERAMA */ #endif
return ScreenSaverSetAttributes(client, stuff); return ScreenSaverSetAttributes(client);
} }
static int static int
ProcScreenSaverUnsetAttributes(ClientPtr client) ProcScreenSaverUnsetAttributes(ClientPtr client)
{ {
REQUEST(xScreenSaverUnsetAttributesReq); #ifdef PANORAMIX
REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
#ifdef XINERAMA
if (!noPanoramiXExtension) { if (!noPanoramiXExtension) {
REQUEST(xScreenSaverUnsetAttributesReq);
PanoramiXRes *draw; PanoramiXRes *draw;
int rc, i; int rc, i;
REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable, rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess); XRC_DRAWABLE, client, DixWriteAccess);
@ -1158,14 +1194,15 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
return (rc == BadValue) ? BadDrawable : rc; return (rc == BadValue) ? BadDrawable : rc;
for (i = PanoramiXNumScreens - 1; i > 0; i--) { for (i = PanoramiXNumScreens - 1; i > 0; i--) {
ScreenSaverUnsetAttributes(client, draw->info[i].id); stuff->drawable = draw->info[i].id;
ScreenSaverUnsetAttributes(client);
} }
stuff->drawable = draw->info[0].id; stuff->drawable = draw->info[0].id;
} }
#endif /* XINERAMA */ #endif
return ScreenSaverUnsetAttributes(client, stuff->drawable); return ScreenSaverUnsetAttributes(client);
} }
static int static int
@ -1194,7 +1231,7 @@ ProcScreenSaverSuspend(ClientPtr client)
if (suspend == TRUE) if (suspend == TRUE)
this->count++; this->count++;
else if (--this->count == 0) else if (--this->count == 0)
FreeResource(this->clientResource, X11_RESTYPE_NONE); FreeResource(this->clientResource, RT_NONE);
return Success; return Success;
} }
@ -1209,7 +1246,7 @@ ProcScreenSaverSuspend(ClientPtr client)
* to the record, so the screensaver will be re-enabled and the record freed * to the record, so the screensaver will be re-enabled and the record freed
* if the client disconnects without reenabling it first. * if the client disconnects without reenabling it first.
*/ */
this = calloc(1, sizeof(ScreenSaverSuspensionRec)); this = malloc(sizeof(ScreenSaverSuspensionRec));
if (!this) if (!this)
return BadAlloc; return BadAlloc;
@ -1233,32 +1270,37 @@ ProcScreenSaverSuspend(ClientPtr client)
return Success; return Success;
} }
static int (*NormalVector[]) (ClientPtr /* client */ ) = {
ProcScreenSaverQueryVersion,
ProcScreenSaverQueryInfo,
ProcScreenSaverSelectInput,
ProcScreenSaverSetAttributes,
ProcScreenSaverUnsetAttributes, ProcScreenSaverSuspend,};
static int static int
ProcScreenSaverDispatch(ClientPtr client) ProcScreenSaverDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) {
case X_ScreenSaverQueryVersion: if (stuff->data < ARRAY_SIZE(NormalVector))
return ProcScreenSaverQueryVersion(client); return (*NormalVector[stuff->data]) (client);
case X_ScreenSaverQueryInfo:
return ProcScreenSaverQueryInfo(client);
case X_ScreenSaverSelectInput:
return ProcScreenSaverSelectInput(client);
case X_ScreenSaverSetAttributes:
return ProcScreenSaverSetAttributes(client);
case X_ScreenSaverUnsetAttributes:
return ProcScreenSaverUnsetAttributes(client);
case X_ScreenSaverSuspend:
return ProcScreenSaverSuspend(client);
default:
return BadRequest; return BadRequest;
} }
static int _X_COLD
SProcScreenSaverQueryVersion(ClientPtr client)
{
REQUEST(xScreenSaverQueryVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
return ProcScreenSaverQueryVersion(client);
} }
static int _X_COLD static int _X_COLD
SProcScreenSaverQueryInfo(ClientPtr client) SProcScreenSaverQueryInfo(ClientPtr client)
{ {
REQUEST(xScreenSaverQueryInfoReq); REQUEST(xScreenSaverQueryInfoReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq); REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
swapl(&stuff->drawable); swapl(&stuff->drawable);
return ProcScreenSaverQueryInfo(client); return ProcScreenSaverQueryInfo(client);
@ -1268,6 +1310,7 @@ static int _X_COLD
SProcScreenSaverSelectInput(ClientPtr client) SProcScreenSaverSelectInput(ClientPtr client)
{ {
REQUEST(xScreenSaverSelectInputReq); REQUEST(xScreenSaverSelectInputReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq); REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->eventMask); swapl(&stuff->eventMask);
@ -1278,6 +1321,7 @@ static int _X_COLD
SProcScreenSaverSetAttributes(ClientPtr client) SProcScreenSaverSetAttributes(ClientPtr client)
{ {
REQUEST(xScreenSaverSetAttributesReq); REQUEST(xScreenSaverSetAttributesReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swaps(&stuff->x); swaps(&stuff->x);
@ -1295,6 +1339,7 @@ static int _X_COLD
SProcScreenSaverUnsetAttributes(ClientPtr client) SProcScreenSaverUnsetAttributes(ClientPtr client)
{ {
REQUEST(xScreenSaverUnsetAttributesReq); REQUEST(xScreenSaverUnsetAttributesReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
swapl(&stuff->drawable); swapl(&stuff->drawable);
return ProcScreenSaverUnsetAttributes(client); return ProcScreenSaverUnsetAttributes(client);
@ -1304,31 +1349,28 @@ static int _X_COLD
SProcScreenSaverSuspend(ClientPtr client) SProcScreenSaverSuspend(ClientPtr client)
{ {
REQUEST(xScreenSaverSuspendReq); REQUEST(xScreenSaverSuspendReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq); REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
swapl(&stuff->suspend); swapl(&stuff->suspend);
return ProcScreenSaverSuspend(client); return ProcScreenSaverSuspend(client);
} }
static int (*SwappedVector[]) (ClientPtr /* client */ ) = {
SProcScreenSaverQueryVersion,
SProcScreenSaverQueryInfo,
SProcScreenSaverSelectInput,
SProcScreenSaverSetAttributes,
SProcScreenSaverUnsetAttributes, SProcScreenSaverSuspend,};
static int _X_COLD static int _X_COLD
SProcScreenSaverDispatch(ClientPtr client) SProcScreenSaverDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) {
case X_ScreenSaverQueryVersion: if (stuff->data < ARRAY_SIZE(NormalVector))
return ProcScreenSaverQueryVersion(client); return (*SwappedVector[stuff->data]) (client);
case X_ScreenSaverQueryInfo:
return SProcScreenSaverQueryInfo(client);
case X_ScreenSaverSelectInput:
return SProcScreenSaverSelectInput(client);
case X_ScreenSaverSetAttributes:
return SProcScreenSaverSetAttributes(client);
case X_ScreenSaverUnsetAttributes:
return SProcScreenSaverUnsetAttributes(client);
case X_ScreenSaverSuspend:
return SProcScreenSaverSuspend(client);
default:
return BadRequest; return BadRequest;
}
} }
void void

View File

@ -24,32 +24,23 @@ in this Software without prior written authorization from The Open Group.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <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 "dix/resource_priv.h"
#include "miext/extinit_priv.h"
#include "os/audit.h"
#include "os/auth.h"
#include "os/client_priv.h"
#include "os/osdep.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "inputstr.h" #include "inputstr.h"
#include "windowstr.h" #include "windowstr.h"
#include "propertyst.h" #include "propertyst.h"
#include "colormapst.h"
#include "privates.h" #include "privates.h"
#include "registry.h"
#include "xacestr.h" #include "xacestr.h"
#include "securitysrv.h" #include "securitysrv.h"
#include <X11/extensions/securproto.h>
#include "extinit.h"
#include "protocol-versions.h" #include "protocol-versions.h"
Bool noSecurityExtension = FALSE;
/* Extension stuff */ /* Extension stuff */
static int SecurityErrorBase; /* first Security error number */ static int SecurityErrorBase; /* first Security error number */
static int SecurityEventBase; /* first Security event number */ static int SecurityEventBase; /* first Security event number */
@ -206,8 +197,8 @@ SecurityDeleteAuthorization(void *value, XID id)
.type = SecurityEventBase + XSecurityAuthorizationRevoked, .type = SecurityEventBase + XSecurityAuthorizationRevoked,
.authId = pAuth->id .authId = pAuth->id
}; };
WriteEventsToClient(dixClientForOtherClients(pEventClient), 1, (xEvent *) &are); WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are);
FreeResource(pEventClient->resource, X11_RESTYPE_NONE); FreeResource(pEventClient->resource, RT_NONE);
} }
/* kill all clients using this auth */ /* kill all clients using this auth */
@ -313,7 +304,7 @@ SecurityAuthorizationExpired(OsTimerPtr timer, CARD32 time, void *pval)
pAuth->secondsRemaining); pAuth->secondsRemaining);
} }
else { else {
FreeResource(pAuth->id, X11_RESTYPE_NONE); FreeResource(pAuth->id, RT_NONE);
return 0; return 0;
} }
} /* SecurityAuthorizationExpired */ } /* SecurityAuthorizationExpired */
@ -377,14 +368,14 @@ SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
pEventClient; pEventClient = pEventClient->next) { pEventClient; pEventClient = pEventClient->next) {
if (SameClient(pEventClient, client)) { if (SameClient(pEventClient, client)) {
if (mask == 0) if (mask == 0)
FreeResource(pEventClient->resource, X11_RESTYPE_NONE); FreeResource(pEventClient->resource, RT_NONE);
else else
pEventClient->mask = mask; pEventClient->mask = mask;
return Success; return Success;
} }
} }
pEventClient = calloc(1, sizeof(OtherClients)); pEventClient = malloc(sizeof(OtherClients));
if (!pEventClient) if (!pEventClient)
return BadAlloc; return BadAlloc;
pEventClient->mask = mask; pEventClient->mask = mask;
@ -405,6 +396,7 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
REQUEST(xSecurityGenerateAuthorizationReq); REQUEST(xSecurityGenerateAuthorizationReq);
int len; /* request length in CARD32s */ int len; /* request length in CARD32s */
Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */ Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */
SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */
int err; /* error to return from this function */ int err; /* error to return from this function */
XID authId; /* authorization ID assigned by os layer */ XID authId; /* authorization ID assigned by os layer */
xSecurityGenerateAuthorizationReply rep; /* reply struct */ xSecurityGenerateAuthorizationReply rep; /* reply struct */
@ -490,8 +482,9 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
authId = GenerateAuthorization(stuff->nbytesAuthProto, protoname, authId = GenerateAuthorization(stuff->nbytesAuthProto, protoname,
stuff->nbytesAuthData, protodata, stuff->nbytesAuthData, protodata,
&authdata_len, &pAuthdata); &authdata_len, &pAuthdata);
if (!authId) { if ((XID) ~0L == authId) {
return SecurityErrorBase + XSecurityBadAuthorizationProtocol; err = SecurityErrorBase + XSecurityBadAuthorizationProtocol;
goto bailout;
} }
/* now that we've added the auth, remember to remove it if we have to /* now that we've added the auth, remember to remove it if we have to
@ -501,7 +494,7 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* associate additional information with this auth ID */ /* associate additional information with this auth ID */
SecurityAuthorizationPtr pAuth = calloc(1, sizeof(SecurityAuthorizationRec)); pAuth = malloc(sizeof(SecurityAuthorizationRec));
if (!pAuth) { if (!pAuth) {
err = BadAlloc; err = BadAlloc;
goto bailout; goto bailout;
@ -587,7 +580,7 @@ ProcSecurityRevokeAuthorization(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
FreeResource(stuff->authId, X11_RESTYPE_NONE); FreeResource(stuff->authId, RT_NONE);
return Success; return Success;
} /* ProcSecurityRevokeAuthorization */ } /* ProcSecurityRevokeAuthorization */
@ -612,6 +605,8 @@ static int _X_COLD
SProcSecurityQueryVersion(ClientPtr client) SProcSecurityQueryVersion(ClientPtr client)
{ {
REQUEST(xSecurityQueryVersionReq); REQUEST(xSecurityQueryVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSecurityQueryVersionReq); REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
swaps(&stuff->majorVersion); swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion);
@ -625,6 +620,8 @@ SProcSecurityGenerateAuthorization(ClientPtr client)
CARD32 *values; CARD32 *values;
unsigned long nvalues; unsigned long nvalues;
int values_offset; int values_offset;
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq); REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
swaps(&stuff->nbytesAuthProto); swaps(&stuff->nbytesAuthProto);
swaps(&stuff->nbytesAuthData); swaps(&stuff->nbytesAuthData);
@ -632,10 +629,10 @@ SProcSecurityGenerateAuthorization(ClientPtr client)
values_offset = bytes_to_int32(stuff->nbytesAuthProto) + values_offset = bytes_to_int32(stuff->nbytesAuthProto) +
bytes_to_int32(stuff->nbytesAuthData); bytes_to_int32(stuff->nbytesAuthData);
if (values_offset > if (values_offset >
client->req_len - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq)) stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq))
return BadLength; return BadLength;
values = (CARD32 *) (&stuff[1]) + values_offset; values = (CARD32 *) (&stuff[1]) + values_offset;
nvalues = (((CARD32 *) stuff) + client->req_len) - values; nvalues = (((CARD32 *) stuff) + stuff->length) - values;
SwapLongs(values, nvalues); SwapLongs(values, nvalues);
return ProcSecurityGenerateAuthorization(client); return ProcSecurityGenerateAuthorization(client);
} /* SProcSecurityGenerateAuthorization */ } /* SProcSecurityGenerateAuthorization */
@ -644,6 +641,8 @@ static int _X_COLD
SProcSecurityRevokeAuthorization(ClientPtr client) SProcSecurityRevokeAuthorization(ClientPtr client)
{ {
REQUEST(xSecurityRevokeAuthorizationReq); REQUEST(xSecurityRevokeAuthorizationReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
swapl(&stuff->authId); swapl(&stuff->authId);
return ProcSecurityRevokeAuthorization(client); return ProcSecurityRevokeAuthorization(client);
@ -741,31 +740,28 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
{ {
XaceResourceAccessRec *rec = calldata; XaceResourceAccessRec *rec = calldata;
SecurityStateRec *subj, *obj; SecurityStateRec *subj, *obj;
int cid = CLIENT_ID(rec->id);
Mask requested = rec->access_mode; Mask requested = rec->access_mode;
Mask allowed = SecurityResourceMask; Mask allowed = SecurityResourceMask;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
/* disable background None for untrusted windows */ /* disable background None for untrusted windows */
if ((requested & DixCreateAccess) && (rec->rtype == X11_RESTYPE_WINDOW)) if ((requested & DixCreateAccess) && (rec->rtype == RT_WINDOW))
if (subj->haveState && subj->trustLevel != XSecurityClientTrusted) if (subj->haveState && subj->trustLevel != XSecurityClientTrusted)
((WindowPtr) rec->res)->forcedBG = TRUE; ((WindowPtr) rec->res)->forcedBG = TRUE;
/* additional permissions for specific resource types */ /* additional permissions for specific resource types */
if (rec->rtype == X11_RESTYPE_WINDOW) if (rec->rtype == RT_WINDOW)
allowed |= SecurityWindowExtraMask; allowed |= SecurityWindowExtraMask;
ClientPtr owner = dixClientForXID(rec->id);
if (!owner)
goto denied;
/* special checks for server-owned resources */ /* special checks for server-owned resources */
if (dixResouceIsServerOwned(rec->id)) { if (cid == 0) {
if (rec->rtype & RC_DRAWABLE) if (rec->rtype & RC_DRAWABLE)
/* additional operations allowed on root windows */ /* additional operations allowed on root windows */
allowed |= SecurityRootWindowExtraMask; allowed |= SecurityRootWindowExtraMask;
else if (rec->rtype == X11_RESTYPE_COLORMAP) else if (rec->rtype == RT_COLORMAP)
/* allow access to default colormaps */ /* allow access to default colormaps */
allowed = requested; allowed = requested;
@ -774,15 +770,15 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
allowed |= DixReadAccess; allowed |= DixReadAccess;
} }
obj = dixLookupPrivate(&owner->devPrivates, stateKey); if (clients[cid] != NULL) {
obj = dixLookupPrivate(&clients[cid]->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, requested, allowed) == Success) if (SecurityDoCheck(subj, obj, requested, allowed) == Success)
return; return;
}
denied:
SecurityAudit("Security: denied client %d access %lx to resource 0x%lx " SecurityAudit("Security: denied client %d access %lx to resource 0x%lx "
"of client %d on request %s\n", rec->client->index, "of client %d on request %s\n", rec->client->index,
(unsigned long)requested, (unsigned long)rec->id, (unsigned long)requested, (unsigned long)rec->id, cid,
dixClientIdForXID(rec->id),
SecurityLookupRequestName(rec->client)); SecurityLookupRequestName(rec->client));
rec->status = BadAccess; /* deny access */ rec->status = BadAccess; /* deny access */
} }
@ -858,13 +854,13 @@ SecurityProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
Mask allowed = SecurityResourceMask | DixReadAccess; Mask allowed = SecurityResourceMask | DixReadAccess;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey); obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, requested, allowed) != Success) { if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
SecurityAudit("Security: denied client %d access to property %s " SecurityAudit("Security: denied client %d access to property %s "
"(atom 0x%x) window 0x%lx of client %d on request %s\n", "(atom 0x%x) window 0x%lx of client %d on request %s\n",
rec->client->index, NameForAtom(name), name, rec->client->index, NameForAtom(name), name,
(unsigned long)rec->pWin->drawable.id, dixClientForWindow(rec->pWin)->index, (unsigned long)rec->pWin->drawable.id, wClient(rec->pWin)->index,
SecurityLookupRequestName(rec->client)); SecurityLookupRequestName(rec->client));
rec->status = BadAccess; rec->status = BadAccess;
} }
@ -880,7 +876,7 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
int i; int i;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey); obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, DixSendAccess, 0) == Success) if (SecurityDoCheck(subj, obj, DixSendAccess, 0) == Success)
return; return;
@ -895,7 +891,7 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
rec->client->index, rec->client->index,
LookupEventName(rec->events[i].u.u.type), LookupEventName(rec->events[i].u.u.type),
(unsigned long)rec->pWin->drawable.id, (unsigned long)rec->pWin->drawable.id,
dixClientForWindow(rec->pWin)->index); wClient(rec->pWin)->index);
rec->status = BadAccess; rec->status = BadAccess;
return; return;
} }
@ -909,7 +905,7 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityStateRec *subj, *obj; SecurityStateRec *subj, *obj;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey); obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, DixReceiveAccess, 0) == Success) if (SecurityDoCheck(subj, obj, DixReceiveAccess, 0) == Success)
return; return;
@ -917,7 +913,7 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityAudit("Security: denied client %d from receiving an event " SecurityAudit("Security: denied client %d from receiving an event "
"sent to window 0x%lx of client %d\n", "sent to window 0x%lx of client %d\n",
rec->client->index, (unsigned long)rec->pWin->drawable.id, rec->client->index, (unsigned long)rec->pWin->drawable.id,
dixClientForWindow(rec->pWin)->index); wClient(rec->pWin)->index);
rec->status = BadAccess; rec->status = BadAccess;
} }

View File

@ -30,9 +30,29 @@ from The Open Group.
#ifndef _SECURITY_SRV_H #ifndef _SECURITY_SRV_H
#define _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> #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 "input.h" /* for DeviceIntPtr */
#include "property.h" /* for PropertyPtr */
#include "pixmap.h" /* for DrawablePtr */ #include "pixmap.h" /* for DrawablePtr */
#include "resource.h" /* for RESTYPE */ #include "resource.h" /* for RESTYPE */

View File

@ -24,20 +24,14 @@ in this Software without prior written authorization from The Open Group.
********************************************************/ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/shapeproto.h>
#include "dix/dix_priv.h"
#include "dix/gc_priv.h"
#include "dix/window_priv.h"
#include "miext/extinit_priv.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "windowstr.h" #include "windowstr.h"
@ -47,12 +41,12 @@ in this Software without prior written authorization from The Open Group.
#include "dixstruct.h" #include "dixstruct.h"
#include "resource.h" #include "resource.h"
#include "opaque.h" #include "opaque.h"
#include <X11/extensions/shapeproto.h>
#include "regionstr.h" #include "regionstr.h"
#include "gcstruct.h" #include "gcstruct.h"
#include "extinit.h"
#include "protocol-versions.h" #include "protocol-versions.h"
Bool noShapeExtension = FALSE;
typedef RegionPtr (*CreateDftPtr) (WindowPtr /* pWin */ typedef RegionPtr (*CreateDftPtr) (WindowPtr /* pWin */
); );
@ -70,6 +64,11 @@ static void SShapeNotifyEvent(xShapeNotifyEvent * /* from */ ,
* externally by the Xfixes extension and are now defined in window.h * externally by the Xfixes extension and are now defined in window.h
*/ */
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
static int ShapeEventBase = 0; static int ShapeEventBase = 0;
static RESTYPE ClientType, ShapeEventType; /* resource types for event masks */ static RESTYPE ClientType, ShapeEventType; /* resource types for event masks */
@ -225,16 +224,24 @@ ProcShapeQueryVersion(ClientPtr client)
return Success; return Success;
} }
/*****************
* ProcShapeRectangles
*
*****************/
static int static int
ShapeRectangles(ClientPtr client, xShapeRectanglesReq *stuff) ProcShapeRectangles(ClientPtr client)
{ {
WindowPtr pWin; WindowPtr pWin;
REQUEST(xShapeRectanglesReq);
xRectangle *prects; xRectangle *prects;
int nrects, ctype, rc; int nrects, ctype, rc;
RegionPtr srcRgn; RegionPtr srcRgn;
RegionPtr *destRgn; RegionPtr *destRgn;
CreateDftPtr createDefault; CreateDftPtr createDefault;
REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq);
UpdateCurrentTime(); UpdateCurrentTime();
rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess); rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success) if (rc != Success)
@ -258,7 +265,7 @@ ShapeRectangles(ClientPtr client, xShapeRectanglesReq *stuff)
client->errorValue = stuff->ordering; client->errorValue = stuff->ordering;
return BadValue; return BadValue;
} }
nrects = ((client->req_len << 2) - sizeof(xShapeRectanglesReq)); nrects = ((stuff->length << 2) - sizeof(xShapeRectanglesReq));
if (nrects & 4) if (nrects & 4)
return BadLength; return BadLength;
nrects >>= 3; nrects >>= 3;
@ -268,9 +275,8 @@ ShapeRectangles(ClientPtr client, xShapeRectanglesReq *stuff)
return BadMatch; return BadMatch;
srcRgn = RegionFromRects(nrects, prects, ctype); srcRgn = RegionFromRects(nrects, prects, ctype);
if (!MakeWindowOptional(pWin)) if (!pWin->optional)
return BadAlloc; MakeWindowOptional(pWin);
switch (stuff->destKind) { switch (stuff->destKind) {
case ShapeBounding: case ShapeBounding:
destRgn = &pWin->optional->boundingShape; destRgn = &pWin->optional->boundingShape;
@ -290,47 +296,49 @@ ShapeRectangles(ClientPtr client, xShapeRectanglesReq *stuff)
stuff->xOff, stuff->yOff, createDefault); stuff->xOff, stuff->yOff, createDefault);
} }
#ifdef PANORAMIX
static int static int
ProcShapeRectangles(ClientPtr client) ProcPanoramiXShapeRectangles(ClientPtr client)
{ {
REQUEST(xShapeRectanglesReq); REQUEST(xShapeRectanglesReq);
REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq);
#ifdef XINERAMA
if (noPanoramiXExtension)
return ShapeRectangles(client, stuff);
PanoramiXRes *win; PanoramiXRes *win;
int j, result; int j, result;
REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess); client, DixWriteAccess);
if (result != Success) if (result != Success)
return result; return result;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
stuff->dest = win->info[j].id; stuff->dest = win->info[j].id;
result = ShapeRectangles(client, stuff); result = ProcShapeRectangles(client);
if (result != Success) if (result != Success)
break; break;
} }
return result; return result;
#else
return ShapeRectangles(client);
#endif
} }
#endif
/**************
* ProcShapeMask
**************/
static int static int
ShapeMask(ClientPtr client, xShapeMaskReq *stuff) ProcShapeMask(ClientPtr client)
{ {
WindowPtr pWin; WindowPtr pWin;
ScreenPtr pScreen; ScreenPtr pScreen;
REQUEST(xShapeMaskReq);
RegionPtr srcRgn; RegionPtr srcRgn;
RegionPtr *destRgn; RegionPtr *destRgn;
PixmapPtr pPixmap; PixmapPtr pPixmap;
CreateDftPtr createDefault; CreateDftPtr createDefault;
int rc; int rc;
REQUEST_SIZE_MATCH(xShapeMaskReq);
UpdateCurrentTime(); UpdateCurrentTime();
rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess); rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success) if (rc != Success)
@ -354,7 +362,7 @@ ShapeMask(ClientPtr client, xShapeMaskReq *stuff)
srcRgn = 0; srcRgn = 0;
else { else {
rc = dixLookupResourceByType((void **) &pPixmap, stuff->src, rc = dixLookupResourceByType((void **) &pPixmap, stuff->src,
X11_RESTYPE_PIXMAP, client, DixReadAccess); RT_PIXMAP, client, DixReadAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (pPixmap->drawable.pScreen != pScreen || if (pPixmap->drawable.pScreen != pScreen ||
@ -365,9 +373,8 @@ ShapeMask(ClientPtr client, xShapeMaskReq *stuff)
return BadAlloc; return BadAlloc;
} }
if (!MakeWindowOptional(pWin)) if (!pWin->optional)
return BadAlloc; MakeWindowOptional(pWin);
switch (stuff->destKind) { switch (stuff->destKind) {
case ShapeBounding: case ShapeBounding:
destRgn = &pWin->optional->boundingShape; destRgn = &pWin->optional->boundingShape;
@ -387,19 +394,16 @@ ShapeMask(ClientPtr client, xShapeMaskReq *stuff)
stuff->xOff, stuff->yOff, createDefault); stuff->xOff, stuff->yOff, createDefault);
} }
#ifdef PANORAMIX
static int static int
ProcShapeMask(ClientPtr client) ProcPanoramiXShapeMask(ClientPtr client)
{ {
REQUEST(xShapeMaskReq); REQUEST(xShapeMaskReq);
REQUEST_SIZE_MATCH(xShapeMaskReq);
#ifdef XINERAMA
if (noPanoramiXExtension)
return ShapeMask(client, stuff);
PanoramiXRes *win, *pmap; PanoramiXRes *win, *pmap;
int j, result; int j, result;
REQUEST_SIZE_MATCH(xShapeMaskReq);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess); client, DixWriteAccess);
if (result != Success) if (result != Success)
@ -414,24 +418,28 @@ ProcShapeMask(ClientPtr client)
else else
pmap = NULL; pmap = NULL;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
stuff->dest = win->info[j].id; stuff->dest = win->info[j].id;
if (pmap) if (pmap)
stuff->src = pmap->info[j].id; stuff->src = pmap->info[j].id;
result = ShapeMask(client, stuff); result = ProcShapeMask(client);
if (result != Success) if (result != Success)
break; break;
} }
return result; return result;
#else
return ShapeMask(client, stuff);
#endif
} }
#endif
/************
* ProcShapeCombine
************/
static int static int
ShapeCombine(ClientPtr client, xShapeCombineReq *stuff) ProcShapeCombine(ClientPtr client)
{ {
WindowPtr pSrcWin, pDestWin; WindowPtr pSrcWin, pDestWin;
REQUEST(xShapeCombineReq);
RegionPtr srcRgn; RegionPtr srcRgn;
RegionPtr *destRgn; RegionPtr *destRgn;
CreateDftPtr createDefault; CreateDftPtr createDefault;
@ -439,13 +447,13 @@ ShapeCombine(ClientPtr client, xShapeCombineReq *stuff)
RegionPtr tmp; RegionPtr tmp;
int rc; int rc;
REQUEST_SIZE_MATCH(xShapeCombineReq);
UpdateCurrentTime(); UpdateCurrentTime();
rc = dixLookupWindow(&pDestWin, stuff->dest, client, DixSetAttrAccess); rc = dixLookupWindow(&pDestWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
if (!MakeWindowOptional(pDestWin)) if (!pDestWin->optional)
return BadAlloc; MakeWindowOptional(pDestWin);
switch (stuff->destKind) { switch (stuff->destKind) {
case ShapeBounding: case ShapeBounding:
createDefault = CreateBoundingShape; createDefault = CreateBoundingShape;
@ -493,9 +501,8 @@ ShapeCombine(ClientPtr client, xShapeCombineReq *stuff)
else else
srcRgn = (*createSrc) (pSrcWin); srcRgn = (*createSrc) (pSrcWin);
if (!MakeWindowOptional(pDestWin)) if (!pDestWin->optional)
return BadAlloc; MakeWindowOptional(pDestWin);
switch (stuff->destKind) { switch (stuff->destKind) {
case ShapeBounding: case ShapeBounding:
destRgn = &pDestWin->optional->boundingShape; destRgn = &pDestWin->optional->boundingShape;
@ -515,19 +522,16 @@ ShapeCombine(ClientPtr client, xShapeCombineReq *stuff)
stuff->xOff, stuff->yOff, createDefault); stuff->xOff, stuff->yOff, createDefault);
} }
#ifdef PANORAMIX
static int static int
ProcShapeCombine(ClientPtr client) ProcPanoramiXShapeCombine(ClientPtr client)
{ {
REQUEST(xShapeCombineReq); REQUEST(xShapeCombineReq);
REQUEST_AT_LEAST_SIZE(xShapeCombineReq);
#ifdef XINERAMA
if (noPanoramiXExtension)
return ShapeCombine(client, stuff);
PanoramiXRes *win, *win2; PanoramiXRes *win, *win2;
int j, result; int j, result;
REQUEST_AT_LEAST_SIZE(xShapeCombineReq);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess); client, DixWriteAccess);
if (result != Success) if (result != Success)
@ -538,26 +542,31 @@ ProcShapeCombine(ClientPtr client)
if (result != Success) if (result != Success)
return result; return result;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
stuff->dest = win->info[j].id; stuff->dest = win->info[j].id;
stuff->src = win2->info[j].id; stuff->src = win2->info[j].id;
result = ShapeCombine(client, stuff); result = ProcShapeCombine(client);
if (result != Success) if (result != Success)
break; break;
} }
return result; return result;
#else
return ShapeCombine(client, stuff);
#endif
} }
#endif
/*************
* ProcShapeOffset
*************/
static int static int
ShapeOffset(ClientPtr client, xShapeOffsetReq *stuff) ProcShapeOffset(ClientPtr client)
{ {
WindowPtr pWin; WindowPtr pWin;
REQUEST(xShapeOffsetReq);
RegionPtr srcRgn; RegionPtr srcRgn;
int rc; int rc;
REQUEST_SIZE_MATCH(xShapeOffsetReq);
UpdateCurrentTime(); UpdateCurrentTime();
rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess); rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success) if (rc != Success)
@ -584,35 +593,30 @@ ShapeOffset(ClientPtr client, xShapeOffsetReq *stuff)
return Success; return Success;
} }
#ifdef PANORAMIX
static int static int
ProcShapeOffset(ClientPtr client) ProcPanoramiXShapeOffset(ClientPtr client)
{ {
REQUEST(xShapeOffsetReq); REQUEST(xShapeOffsetReq);
REQUEST_AT_LEAST_SIZE(xShapeOffsetReq);
#ifdef XINERAMA
PanoramiXRes *win; PanoramiXRes *win;
int j, result; int j, result;
if (noPanoramiXExtension) REQUEST_AT_LEAST_SIZE(xShapeOffsetReq);
return ShapeOffset(client, stuff);
result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW, result = dixLookupResourceByType((void **) &win, stuff->dest, XRT_WINDOW,
client, DixWriteAccess); client, DixWriteAccess);
if (result != Success) if (result != Success)
return result; return result;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
stuff->dest = win->info[j].id; stuff->dest = win->info[j].id;
result = ShapeOffset(client, stuff); result = ProcShapeOffset(client);
if (result != Success) if (result != Success)
break; break;
} }
return result; return result;
#else
return ShapeOffset(client, stuff);
#endif
} }
#endif
static int static int
ProcShapeQueryExtents(ClientPtr client) ProcShapeQueryExtents(ClientPtr client)
@ -754,7 +758,7 @@ ProcShapeSelectInput(ClientPtr client)
} }
/* build the entry */ /* build the entry */
pNewShapeEvent = calloc(1, sizeof(ShapeEventRec)); pNewShapeEvent = malloc(sizeof(ShapeEventRec));
if (!pNewShapeEvent) if (!pNewShapeEvent)
return BadAlloc; return BadAlloc;
pNewShapeEvent->next = 0; pNewShapeEvent->next = 0;
@ -775,11 +779,11 @@ ProcShapeSelectInput(ClientPtr client)
* done through the resource database. * done through the resource database.
*/ */
if (!pHead) { if (!pHead) {
pHead = calloc(1, sizeof(ShapeEventPtr)); pHead = malloc(sizeof(ShapeEventPtr));
if (!pHead || if (!pHead ||
!AddResource(pWin->drawable.id, ShapeEventType, !AddResource(pWin->drawable.id, ShapeEventType,
(void *) pHead)) { (void *) pHead)) {
FreeResource(clientResource, X11_RESTYPE_NONE); FreeResource(clientResource, RT_NONE);
return BadAlloc; return BadAlloc;
} }
*pHead = 0; *pHead = 0;
@ -940,7 +944,7 @@ ProcShapeGetRectangles(ClientPtr client)
REQUEST(xShapeGetRectanglesReq); REQUEST(xShapeGetRectanglesReq);
WindowPtr pWin; WindowPtr pWin;
xShapeGetRectanglesReply rep; xShapeGetRectanglesReply rep;
xRectangle *rects = NULL; xRectangle *rects;
int nrects, i, rc; int nrects, i, rc;
RegionPtr region; RegionPtr region;
@ -964,7 +968,7 @@ ProcShapeGetRectangles(ClientPtr client)
} }
if (!region) { if (!region) {
nrects = 1; nrects = 1;
rects = calloc(1, sizeof(xRectangle)); rects = malloc(sizeof(xRectangle));
if (!rects) if (!rects)
return BadAlloc; return BadAlloc;
switch (stuff->kind) { switch (stuff->kind) {
@ -993,9 +997,8 @@ ProcShapeGetRectangles(ClientPtr client)
nrects = RegionNumRects(region); nrects = RegionNumRects(region);
box = RegionRects(region); box = RegionRects(region);
if (nrects) { rects = xallocarray(nrects, sizeof(xRectangle));
rects = calloc(nrects, sizeof(xRectangle)); if (!rects && nrects)
if (!rects)
return BadAlloc; return BadAlloc;
for (i = 0; i < nrects; i++, box++) { for (i = 0; i < nrects; i++, box++) {
rects[i].x = box->x1; rects[i].x = box->x1;
@ -1004,7 +1007,6 @@ ProcShapeGetRectangles(ClientPtr client)
rects[i].height = box->y2 - box->y1; rects[i].height = box->y2 - box->y1;
} }
} }
}
rep = (xShapeGetRectanglesReply) { rep = (xShapeGetRectanglesReply) {
.type = X_Reply, .type = X_Reply,
.ordering = YXBanded, .ordering = YXBanded,
@ -1032,12 +1034,32 @@ ProcShapeDispatch(ClientPtr client)
case X_ShapeQueryVersion: case X_ShapeQueryVersion:
return ProcShapeQueryVersion(client); return ProcShapeQueryVersion(client);
case X_ShapeRectangles: case X_ShapeRectangles:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShapeRectangles(client);
else
#endif
return ProcShapeRectangles(client); return ProcShapeRectangles(client);
case X_ShapeMask: case X_ShapeMask:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShapeMask(client);
else
#endif
return ProcShapeMask(client); return ProcShapeMask(client);
case X_ShapeCombine: case X_ShapeCombine:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShapeCombine(client);
else
#endif
return ProcShapeCombine(client); return ProcShapeCombine(client);
case X_ShapeOffset: case X_ShapeOffset:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShapeOffset(client);
else
#endif
return ProcShapeOffset(client); return ProcShapeOffset(client);
case X_ShapeQueryExtents: case X_ShapeQueryExtents:
return ProcShapeQueryExtents(client); return ProcShapeQueryExtents(client);
@ -1067,10 +1089,21 @@ SShapeNotifyEvent(xShapeNotifyEvent * from, xShapeNotifyEvent * to)
to->shaped = from->shaped; to->shaped = from->shaped;
} }
static int _X_COLD
SProcShapeQueryVersion(ClientPtr client)
{
REQUEST(xShapeQueryVersionReq);
swaps(&stuff->length);
return ProcShapeQueryVersion(client);
}
static int _X_COLD static int _X_COLD
SProcShapeRectangles(ClientPtr client) SProcShapeRectangles(ClientPtr client)
{ {
REQUEST(xShapeRectanglesReq); REQUEST(xShapeRectanglesReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq); REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq);
swapl(&stuff->dest); swapl(&stuff->dest);
swaps(&stuff->xOff); swaps(&stuff->xOff);
@ -1083,6 +1116,8 @@ static int _X_COLD
SProcShapeMask(ClientPtr client) SProcShapeMask(ClientPtr client)
{ {
REQUEST(xShapeMaskReq); REQUEST(xShapeMaskReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShapeMaskReq); REQUEST_SIZE_MATCH(xShapeMaskReq);
swapl(&stuff->dest); swapl(&stuff->dest);
swaps(&stuff->xOff); swaps(&stuff->xOff);
@ -1095,6 +1130,8 @@ static int _X_COLD
SProcShapeCombine(ClientPtr client) SProcShapeCombine(ClientPtr client)
{ {
REQUEST(xShapeCombineReq); REQUEST(xShapeCombineReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShapeCombineReq); REQUEST_SIZE_MATCH(xShapeCombineReq);
swapl(&stuff->dest); swapl(&stuff->dest);
swaps(&stuff->xOff); swaps(&stuff->xOff);
@ -1107,6 +1144,8 @@ static int _X_COLD
SProcShapeOffset(ClientPtr client) SProcShapeOffset(ClientPtr client)
{ {
REQUEST(xShapeOffsetReq); REQUEST(xShapeOffsetReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShapeOffsetReq); REQUEST_SIZE_MATCH(xShapeOffsetReq);
swapl(&stuff->dest); swapl(&stuff->dest);
swaps(&stuff->xOff); swaps(&stuff->xOff);
@ -1118,6 +1157,8 @@ static int _X_COLD
SProcShapeQueryExtents(ClientPtr client) SProcShapeQueryExtents(ClientPtr client)
{ {
REQUEST(xShapeQueryExtentsReq); REQUEST(xShapeQueryExtentsReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShapeQueryExtentsReq); REQUEST_SIZE_MATCH(xShapeQueryExtentsReq);
swapl(&stuff->window); swapl(&stuff->window);
return ProcShapeQueryExtents(client); return ProcShapeQueryExtents(client);
@ -1127,6 +1168,8 @@ static int _X_COLD
SProcShapeSelectInput(ClientPtr client) SProcShapeSelectInput(ClientPtr client)
{ {
REQUEST(xShapeSelectInputReq); REQUEST(xShapeSelectInputReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShapeSelectInputReq); REQUEST_SIZE_MATCH(xShapeSelectInputReq);
swapl(&stuff->window); swapl(&stuff->window);
return ProcShapeSelectInput(client); return ProcShapeSelectInput(client);
@ -1136,6 +1179,8 @@ static int _X_COLD
SProcShapeInputSelected(ClientPtr client) SProcShapeInputSelected(ClientPtr client)
{ {
REQUEST(xShapeInputSelectedReq); REQUEST(xShapeInputSelectedReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShapeInputSelectedReq); REQUEST_SIZE_MATCH(xShapeInputSelectedReq);
swapl(&stuff->window); swapl(&stuff->window);
return ProcShapeInputSelected(client); return ProcShapeInputSelected(client);
@ -1145,6 +1190,7 @@ static int _X_COLD
SProcShapeGetRectangles(ClientPtr client) SProcShapeGetRectangles(ClientPtr client)
{ {
REQUEST(xShapeGetRectanglesReq); REQUEST(xShapeGetRectanglesReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShapeGetRectanglesReq); REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
swapl(&stuff->window); swapl(&stuff->window);
return ProcShapeGetRectangles(client); return ProcShapeGetRectangles(client);
@ -1156,7 +1202,7 @@ SProcShapeDispatch(ClientPtr client)
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { switch (stuff->data) {
case X_ShapeQueryVersion: case X_ShapeQueryVersion:
return ProcShapeQueryVersion(client); return SProcShapeQueryVersion(client);
case X_ShapeRectangles: case X_ShapeRectangles:
return SProcShapeRectangles(client); return SProcShapeRectangles(client);
case X_ShapeMask: case X_ShapeMask:

View File

@ -28,34 +28,24 @@ in this Software without prior written authorization from The Open Group.
#define SHM #define SHM
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#ifdef HAVE_MEMFD_CREATE
#include <sys/mman.h> #include <sys/mman.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/shmproto.h>
#include <X11/Xfuncproto.h>
#include "dix/dix_priv.h"
#include "dix/screen_hooks_priv.h"
#include "miext/extinit_priv.h"
#include "os/auth.h"
#include "os/busfault.h"
#include "os/client_priv.h"
#include "os/log_priv.h"
#include "os/osdep.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct_priv.h" #include "dixstruct.h"
#include "resource.h" #include "resource.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "windowstr.h" #include "windowstr.h"
@ -65,7 +55,11 @@ in this Software without prior written authorization from The Open Group.
#include "servermd.h" #include "servermd.h"
#include "shmint.h" #include "shmint.h"
#include "xace.h" #include "xace.h"
#include <X11/extensions/shmproto.h>
#include <X11/Xfuncproto.h>
#include <sys/mman.h>
#include "protocol-versions.h" #include "protocol-versions.h"
#include "busfault.h"
/* Needed for Solaris cross-zone shared memory extension */ /* Needed for Solaris cross-zone shared memory extension */
#ifdef HAVE_SHMCTL64 #ifdef HAVE_SHMCTL64
@ -94,20 +88,26 @@ in this Software without prior written authorization from The Open Group.
#define SHMPERM_MODE(p) p->mode #define SHMPERM_MODE(p) p->mode
#endif #endif
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#include "extinit.h"
typedef struct _ShmScrPrivateRec { typedef struct _ShmScrPrivateRec {
CloseScreenProcPtr CloseScreen;
ShmFuncsPtr shmFuncs; ShmFuncsPtr shmFuncs;
DestroyPixmapProcPtr destroyPixmap;
} ShmScrPrivateRec; } ShmScrPrivateRec;
Bool noMITShmExtension = FALSE;
static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS); static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS);
static int ShmDetachSegment(void *value, XID shmseg); static int ShmDetachSegment(void *value, XID shmseg);
static void ShmResetProc(ExtensionEntry *extEntry); static void ShmResetProc(ExtensionEntry *extEntry);
static void SShmCompletionEvent(xShmCompletionEvent *from, static void SShmCompletionEvent(xShmCompletionEvent *from,
xShmCompletionEvent *to); xShmCompletionEvent *to);
static int ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff); static Bool ShmDestroyPixmap(PixmapPtr pPixmap);
static unsigned char ShmReqCode; static unsigned char ShmReqCode;
int ShmCompletionCode; int ShmCompletionCode;
@ -155,7 +155,7 @@ static ShmFuncs fbFuncs = { fbShmCreatePixmap, NULL };
} \ } \
} }
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
static Bool badSysCall = FALSE; static Bool badSysCall = FALSE;
@ -193,13 +193,15 @@ CheckForShmSyscall(void)
#endif #endif
static void static Bool
ShmScreenClose(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused) ShmCloseScreen(ScreenPtr pScreen)
{ {
ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
pScreen->CloseScreen = screen_priv->CloseScreen;
dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, NULL); dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, NULL);
free(screen_priv); free(screen_priv);
return (*pScreen->CloseScreen) (pScreen);
} }
static ShmScrPrivateRec * static ShmScrPrivateRec *
@ -209,8 +211,9 @@ ShmInitScreenPriv(ScreenPtr pScreen)
if (!screen_priv) { if (!screen_priv) {
screen_priv = calloc(1, sizeof(ShmScrPrivateRec)); screen_priv = calloc(1, sizeof(ShmScrPrivateRec));
screen_priv->CloseScreen = pScreen->CloseScreen;
dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, screen_priv); dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, screen_priv);
dixScreenHookClose(pScreen, ShmScreenClose); pScreen->CloseScreen = ShmCloseScreen;
} }
return screen_priv; return screen_priv;
} }
@ -242,6 +245,27 @@ ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs)
ShmInitScreenPriv(pScreen)->shmFuncs = funcs; ShmInitScreenPriv(pScreen)->shmFuncs = funcs;
} }
static Bool
ShmDestroyPixmap(PixmapPtr pPixmap)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
void *shmdesc = NULL;
Bool ret;
if (pPixmap->refcnt == 1)
shmdesc = dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey);
pScreen->DestroyPixmap = screen_priv->destroyPixmap;
ret = (*pScreen->DestroyPixmap) (pPixmap);
screen_priv->destroyPixmap = pScreen->DestroyPixmap;
pScreen->DestroyPixmap = ShmDestroyPixmap;
if (shmdesc)
ShmDetachSegment(shmdesc, 0);
return ret;
}
void void
ShmRegisterFbFuncs(ScreenPtr pScreen) ShmRegisterFbFuncs(ScreenPtr pScreen)
@ -347,15 +371,12 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
static int static int
ProcShmAttach(ClientPtr client) ProcShmAttach(ClientPtr client)
{ {
REQUEST(xShmAttachReq);
REQUEST_SIZE_MATCH(xShmAttachReq);
if (!client->local)
return BadRequest;
SHMSTAT_TYPE buf; SHMSTAT_TYPE buf;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
REQUEST(xShmAttachReq);
REQUEST_SIZE_MATCH(xShmAttachReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client); LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) { if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
client->errorValue = stuff->readOnly; client->errorValue = stuff->readOnly;
@ -371,7 +392,7 @@ ProcShmAttach(ClientPtr client)
shmdesc->refcnt++; shmdesc->refcnt++;
} }
else { else {
shmdesc = calloc(1, sizeof(ShmDescRec)); shmdesc = malloc(sizeof(ShmDescRec));
if (!shmdesc) if (!shmdesc)
return BadAlloc; return BadAlloc;
#ifdef SHM_FD_PASSING #ifdef SHM_FD_PASSING
@ -413,9 +434,6 @@ ShmDetachSegment(void *value, /* must conform to DeleteType */
ShmDescPtr shmdesc = (ShmDescPtr) value; ShmDescPtr shmdesc = (ShmDescPtr) value;
ShmDescPtr *prev; ShmDescPtr *prev;
if (!shmdesc)
return Success;
if (--shmdesc->refcnt) if (--shmdesc->refcnt)
return TRUE; return TRUE;
#if SHM_FD_PASSING #if SHM_FD_PASSING
@ -435,16 +453,13 @@ ShmDetachSegment(void *value, /* must conform to DeleteType */
static int static int
ProcShmDetach(ClientPtr client) ProcShmDetach(ClientPtr client)
{ {
REQUEST(xShmDetachReq);
REQUEST_SIZE_MATCH(xShmDetachReq);
if (!client->local)
return BadRequest;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
REQUEST(xShmDetachReq);
REQUEST_SIZE_MATCH(xShmDetachReq);
VERIFY_SHMSEG(stuff->shmseg, shmdesc, client); VERIFY_SHMSEG(stuff->shmseg, shmdesc, client);
FreeResource(stuff->shmseg, X11_RESTYPE_NONE); FreeResource(stuff->shmseg, RT_NONE);
return Success; return Success;
} }
@ -466,8 +481,8 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
PixmapBytePad(w, depth), data); PixmapBytePad(w, depth), data);
if (!pPixmap) if (!pPixmap)
return; return;
(void) pGC->ops->CopyArea((DrawablePtr) pPixmap, dst, pGC, pGC->ops->CopyArea((DrawablePtr) pPixmap, dst, pGC, sx, sy, sw, sh, dx,
sx, sy, sw, sh, dx, dy); dy);
FreeScratchPixmapHeader(pPixmap); FreeScratchPixmapHeader(pPixmap);
} }
else { else {
@ -494,18 +509,21 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
else else
(void) (*pGC->ops->CopyArea) (&pPixmap->drawable, dst, pGC, 0, 0, (void) (*pGC->ops->CopyArea) (&pPixmap->drawable, dst, pGC, 0, 0,
sw, sh, dx, dy); sw, sh, dx, dy);
dixDestroyPixmap(pPixmap, 0); (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
} }
} }
static int static int
ShmPutImage(ClientPtr client, xShmPutImageReq *stuff) ProcShmPutImage(ClientPtr client)
{ {
GCPtr pGC; GCPtr pGC;
DrawablePtr pDraw; DrawablePtr pDraw;
long length; long length;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client); VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse)) if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
@ -595,7 +613,7 @@ ShmPutImage(ClientPtr client, xShmPutImageReq *stuff)
} }
static int static int
ShmGetImage(ClientPtr client, xShmGetImageReq *stuff) ProcShmGetImage(ClientPtr client)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
long lenPer = 0, length; long lenPer = 0, length;
@ -606,6 +624,9 @@ ShmGetImage(ClientPtr client, xShmGetImageReq *stuff)
RegionPtr pVisibleRegion = NULL; RegionPtr pVisibleRegion = NULL;
int rc; int rc;
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format; client->errorValue = stuff->format;
return BadValue; return BadValue;
@ -710,22 +731,16 @@ ShmGetImage(ClientPtr client, xShmGetImageReq *stuff)
return Success; return Success;
} }
#ifdef PANORAMIX
static int static int
ProcShmPutImage(ClientPtr client) ProcPanoramiXShmPutImage(ClientPtr client)
{ {
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
if (!client->local)
return BadRequest;
#ifdef XINERAMA
int j, result, orig_x, orig_y; int j, result, orig_x, orig_y;
PanoramiXRes *draw, *gc; PanoramiXRes *draw, *gc;
Bool sendEvent, isRoot; Bool sendEvent, isRoot;
if (noPanoramiXExtension) REQUEST(xShmPutImageReq);
return ShmPutImage(client, stuff); REQUEST_SIZE_MATCH(xShmPutImageReq);
result = dixLookupResourceByClass((void **) &draw, stuff->drawable, result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess); XRC_DRAWABLE, client, DixWriteAccess);
@ -743,7 +758,7 @@ ProcShmPutImage(ClientPtr client)
orig_y = stuff->dstY; orig_y = stuff->dstY;
sendEvent = stuff->sendEvent; sendEvent = stuff->sendEvent;
stuff->sendEvent = 0; stuff->sendEvent = 0;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
if (!j) if (!j)
stuff->sendEvent = sendEvent; stuff->sendEvent = sendEvent;
stuff->drawable = draw->info[j].id; stuff->drawable = draw->info[j].id;
@ -752,27 +767,18 @@ ProcShmPutImage(ClientPtr client)
stuff->dstX = orig_x - screenInfo.screens[j]->x; stuff->dstX = orig_x - screenInfo.screens[j]->x;
stuff->dstY = orig_y - screenInfo.screens[j]->y; stuff->dstY = orig_y - screenInfo.screens[j]->y;
} }
result = ShmPutImage(client, stuff); result = ProcShmPutImage(client);
if (result != Success) if (result != Success)
break; break;
} }
return result; return result;
#else
return ShmPutImage(client, stuff);
#endif /* XINERAMA */
} }
static int static int
ProcShmGetImage(ClientPtr client) ProcPanoramiXShmGetImage(ClientPtr client)
{ {
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if (!client->local)
return BadRequest;
#ifdef XINERAMA
PanoramiXRes *draw; PanoramiXRes *draw;
DrawablePtr *drawables;
DrawablePtr pDraw; DrawablePtr pDraw;
xShmGetImageReply xgi; xShmGetImageReply xgi;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
@ -781,8 +787,9 @@ ProcShmGetImage(ClientPtr client)
long lenPer = 0, length, widthBytesLine; long lenPer = 0, length, widthBytesLine;
Bool isRoot; Bool isRoot;
if (noPanoramiXExtension) REQUEST(xShmGetImageReq);
return ShmGetImage(client, stuff);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format; client->errorValue = stuff->format;
@ -795,7 +802,7 @@ ProcShmGetImage(ClientPtr client)
return (rc == BadValue) ? BadDrawable : rc; return (rc == BadValue) ? BadDrawable : rc;
if (draw->type == XRT_PIXMAP) if (draw->type == XRT_PIXMAP)
return ShmGetImage(client, stuff); return ProcShmGetImage(client);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess); rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess);
if (rc != Success) if (rc != Success)
@ -846,7 +853,7 @@ ProcShmGetImage(ClientPtr client)
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
DrawablePtr *drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr)); drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr));
if (!drawables) if (!drawables)
return BadAlloc; return BadAlloc;
@ -906,34 +913,24 @@ ProcShmGetImage(ClientPtr client)
WriteToClient(client, sizeof(xShmGetImageReply), &xgi); WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
return Success; return Success;
#else
return ShmGetImage(client, stuff);
#endif /* XINERAMA */
} }
static int static int
ProcShmCreatePixmap(ClientPtr client) ProcPanoramiXShmCreatePixmap(ClientPtr client)
{ {
REQUEST(xShmCreatePixmapReq);
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
if (!client->local)
return BadRequest;
#ifdef XINERAMA
if (noPanoramiXExtension)
return ShmCreatePixmap(client, stuff);
ScreenPtr pScreen = NULL; ScreenPtr pScreen = NULL;
PixmapPtr pMap = NULL; PixmapPtr pMap = NULL;
DrawablePtr pDraw; DrawablePtr pDraw;
DepthPtr pDepth; DepthPtr pDepth;
int i, j, result, rc; int i, j, result, rc;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
REQUEST(xShmCreatePixmapReq);
unsigned int width, height, depth; unsigned int width, height, depth;
unsigned long size; unsigned long size;
PanoramiXRes *newPix; PanoramiXRes *newPix;
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid; client->errorValue = stuff->pid;
if (!sharedPixmaps) if (!sharedPixmaps)
return BadImplementation; return BadImplementation;
@ -976,7 +973,7 @@ ProcShmCreatePixmap(ClientPtr client)
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
if (!(newPix = calloc(1, sizeof(PanoramiXRes)))) if (!(newPix = malloc(sizeof(PanoramiXRes))))
return BadAlloc; return BadAlloc;
newPix->type = XRT_PIXMAP; newPix->type = XRT_PIXMAP;
@ -985,7 +982,7 @@ ProcShmCreatePixmap(ClientPtr client)
result = Success; result = Success;
FOR_NSCREENS_BACKWARD(j) { FOR_NSCREENS(j) {
ShmScrPrivateRec *screen_priv; ShmScrPrivateRec *screen_priv;
pScreen = screenInfo.screens[j]; pScreen = screenInfo.screens[j];
@ -999,17 +996,17 @@ ProcShmCreatePixmap(ClientPtr client)
stuff->offset); stuff->offset);
if (pMap) { if (pMap) {
result = XaceHookResourceAccess(client, stuff->pid, result = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid,
X11_RESTYPE_PIXMAP, pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess);
if (result != Success) { if (result != Success) {
dixDestroyPixmap(pMap, 0); pDraw->pScreen->DestroyPixmap(pMap);
break; break;
} }
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++; shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id; pMap->drawable.id = newPix->info[j].id;
if (!AddResource(newPix->info[j].id, X11_RESTYPE_PIXMAP, (void *) pMap)) { if (!AddResource(newPix->info[j].id, RT_PIXMAP, (void *) pMap)) {
result = BadAlloc; result = BadAlloc;
break; break;
} }
@ -1022,17 +1019,15 @@ ProcShmCreatePixmap(ClientPtr client)
if (result != Success) { if (result != Success) {
while (j--) while (j--)
FreeResource(newPix->info[j].id, X11_RESTYPE_NONE); FreeResource(newPix->info[j].id, RT_NONE);
free(newPix); free(newPix);
} }
else else
AddResource(stuff->pid, XRT_PIXMAP, newPix); AddResource(stuff->pid, XRT_PIXMAP, newPix);
return result; return result;
#else
return ShmCreatePixmap(client, stuff);
#endif /* XINERAMA */
} }
#endif
static PixmapPtr static PixmapPtr
fbShmCreatePixmap(ScreenPtr pScreen, fbShmCreatePixmap(ScreenPtr pScreen,
@ -1048,14 +1043,14 @@ fbShmCreatePixmap(ScreenPtr pScreen,
BitsPerPixel(depth), BitsPerPixel(depth),
PixmapBytePad(width, depth), PixmapBytePad(width, depth),
(void *) addr)) { (void *) addr)) {
dixDestroyPixmap(pPixmap, 0); (*pScreen->DestroyPixmap) (pPixmap);
return NullPixmap; return NullPixmap;
} }
return pPixmap; return pPixmap;
} }
static int static int
ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff) ProcShmCreatePixmap(ClientPtr client)
{ {
PixmapPtr pMap; PixmapPtr pMap;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -1063,9 +1058,12 @@ ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff)
int i, rc; int i, rc;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
ShmScrPrivateRec *screen_priv; ShmScrPrivateRec *screen_priv;
REQUEST(xShmCreatePixmapReq);
unsigned int width, height, depth; unsigned int width, height, depth;
unsigned long size; unsigned long size;
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid; client->errorValue = stuff->pid;
if (!sharedPixmaps) if (!sharedPixmaps)
return BadImplementation; return BadImplementation;
@ -1113,17 +1111,17 @@ ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff)
shmdesc->addr + shmdesc->addr +
stuff->offset); stuff->offset);
if (pMap) { if (pMap) {
rc = XaceHookResourceAccess(client, stuff->pid, X11_RESTYPE_PIXMAP, rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
pMap, X11_RESTYPE_NONE, NULL, DixCreateAccess); pMap, RT_NONE, NULL, DixCreateAccess);
if (rc != Success) { if (rc != Success) {
dixDestroyPixmap(pMap, 0); pDraw->pScreen->DestroyPixmap(pMap);
return rc; return rc;
} }
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++; shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid; pMap->drawable.id = stuff->pid;
if (AddResource(stuff->pid, X11_RESTYPE_PIXMAP, (void *) pMap)) { if (AddResource(stuff->pid, RT_PIXMAP, (void *) pMap)) {
return Success; return Success;
} }
} }
@ -1141,23 +1139,19 @@ ShmBusfaultNotify(void *context)
(unsigned int) shmdesc->resource); (unsigned int) shmdesc->resource);
busfault_unregister(shmdesc->busfault); busfault_unregister(shmdesc->busfault);
shmdesc->busfault = NULL; shmdesc->busfault = NULL;
FreeResource (shmdesc->resource, X11_RESTYPE_NONE); FreeResource (shmdesc->resource, RT_NONE);
} }
static int static int
ProcShmAttachFd(ClientPtr client) ProcShmAttachFd(ClientPtr client)
{ {
REQUEST(xShmAttachFdReq);
REQUEST_SIZE_MATCH(xShmAttachFdReq);
if (!client->local)
return BadRequest;
int fd; int fd;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
REQUEST(xShmAttachFdReq);
struct stat statb; struct stat statb;
SetReqFds(client, 1); SetReqFds(client, 1);
REQUEST_SIZE_MATCH(xShmAttachFdReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client); LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) { if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
client->errorValue = stuff->readOnly; client->errorValue = stuff->readOnly;
@ -1172,7 +1166,7 @@ ProcShmAttachFd(ClientPtr client)
return BadMatch; return BadMatch;
} }
shmdesc = calloc(1, sizeof(ShmDescRec)); shmdesc = malloc(sizeof(ShmDescRec));
if (!shmdesc) { if (!shmdesc) {
close(fd); close(fd);
return BadAlloc; return BadAlloc;
@ -1266,14 +1260,9 @@ shm_tmpfile(void)
static int static int
ProcShmCreateSegment(ClientPtr client) ProcShmCreateSegment(ClientPtr client)
{ {
REQUEST(xShmCreateSegmentReq);
REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
if (!client->local)
return BadRequest;
int fd; int fd;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
REQUEST(xShmCreateSegmentReq);
xShmCreateSegmentReply rep = { xShmCreateSegmentReply rep = {
.type = X_Reply, .type = X_Reply,
.nfd = 1, .nfd = 1,
@ -1281,6 +1270,7 @@ ProcShmCreateSegment(ClientPtr client)
.length = 0, .length = 0,
}; };
REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client); LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) { if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
client->errorValue = stuff->readOnly; client->errorValue = stuff->readOnly;
@ -1293,7 +1283,7 @@ ProcShmCreateSegment(ClientPtr client)
close(fd); close(fd);
return BadAlloc; return BadAlloc;
} }
shmdesc = calloc(1, sizeof(ShmDescRec)); shmdesc = malloc(sizeof(ShmDescRec));
if (!shmdesc) { if (!shmdesc) {
close(fd); close(fd);
return BadAlloc; return BadAlloc;
@ -1331,7 +1321,7 @@ ProcShmCreateSegment(ClientPtr client)
} }
if (WriteFdToClient(client, fd, TRUE) < 0) { if (WriteFdToClient(client, fd, TRUE) < 0) {
FreeResource(stuff->shmseg, X11_RESTYPE_NONE); FreeResource(stuff->shmseg, RT_NONE);
close(fd); close(fd);
return BadAlloc; return BadAlloc;
} }
@ -1345,18 +1335,34 @@ ProcShmDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data) { if (stuff->data == X_ShmQueryVersion)
case X_ShmQueryVersion:
return ProcShmQueryVersion(client); return ProcShmQueryVersion(client);
if (!client->local)
return BadRequest;
switch (stuff->data) {
case X_ShmAttach: case X_ShmAttach:
return ProcShmAttach(client); return ProcShmAttach(client);
case X_ShmDetach: case X_ShmDetach:
return ProcShmDetach(client); return ProcShmDetach(client);
case X_ShmPutImage: case X_ShmPutImage:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShmPutImage(client);
#endif
return ProcShmPutImage(client); return ProcShmPutImage(client);
case X_ShmGetImage: case X_ShmGetImage:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShmGetImage(client);
#endif
return ProcShmGetImage(client); return ProcShmGetImage(client);
case X_ShmCreatePixmap: case X_ShmCreatePixmap:
#ifdef PANORAMIX
if (!noPanoramiXExtension)
return ProcPanoramiXShmCreatePixmap(client);
#endif
return ProcShmCreatePixmap(client); return ProcShmCreatePixmap(client);
#ifdef SHM_FD_PASSING #ifdef SHM_FD_PASSING
case X_ShmAttachFd: case X_ShmAttachFd:
@ -1381,10 +1387,20 @@ SShmCompletionEvent(xShmCompletionEvent * from, xShmCompletionEvent * to)
cpswapl(from->offset, to->offset); cpswapl(from->offset, to->offset);
} }
static int _X_COLD
SProcShmQueryVersion(ClientPtr client)
{
REQUEST(xShmQueryVersionReq);
swaps(&stuff->length);
return ProcShmQueryVersion(client);
}
static int _X_COLD static int _X_COLD
SProcShmAttach(ClientPtr client) SProcShmAttach(ClientPtr client)
{ {
REQUEST(xShmAttachReq); REQUEST(xShmAttachReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmAttachReq); REQUEST_SIZE_MATCH(xShmAttachReq);
swapl(&stuff->shmseg); swapl(&stuff->shmseg);
swapl(&stuff->shmid); swapl(&stuff->shmid);
@ -1395,6 +1411,7 @@ static int _X_COLD
SProcShmDetach(ClientPtr client) SProcShmDetach(ClientPtr client)
{ {
REQUEST(xShmDetachReq); REQUEST(xShmDetachReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmDetachReq); REQUEST_SIZE_MATCH(xShmDetachReq);
swapl(&stuff->shmseg); swapl(&stuff->shmseg);
return ProcShmDetach(client); return ProcShmDetach(client);
@ -1404,6 +1421,7 @@ static int _X_COLD
SProcShmPutImage(ClientPtr client) SProcShmPutImage(ClientPtr client)
{ {
REQUEST(xShmPutImageReq); REQUEST(xShmPutImageReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmPutImageReq); REQUEST_SIZE_MATCH(xShmPutImageReq);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->gc); swapl(&stuff->gc);
@ -1424,6 +1442,7 @@ static int _X_COLD
SProcShmGetImage(ClientPtr client) SProcShmGetImage(ClientPtr client)
{ {
REQUEST(xShmGetImageReq); REQUEST(xShmGetImageReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmGetImageReq); REQUEST_SIZE_MATCH(xShmGetImageReq);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swaps(&stuff->x); swaps(&stuff->x);
@ -1440,6 +1459,7 @@ static int _X_COLD
SProcShmCreatePixmap(ClientPtr client) SProcShmCreatePixmap(ClientPtr client)
{ {
REQUEST(xShmCreatePixmapReq); REQUEST(xShmCreatePixmapReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
swapl(&stuff->pid); swapl(&stuff->pid);
swapl(&stuff->drawable); swapl(&stuff->drawable);
@ -1456,6 +1476,7 @@ SProcShmAttachFd(ClientPtr client)
{ {
REQUEST(xShmAttachFdReq); REQUEST(xShmAttachFdReq);
SetReqFds(client, 1); SetReqFds(client, 1);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmAttachFdReq); REQUEST_SIZE_MATCH(xShmAttachFdReq);
swapl(&stuff->shmseg); swapl(&stuff->shmseg);
return ProcShmAttachFd(client); return ProcShmAttachFd(client);
@ -1465,6 +1486,7 @@ static int _X_COLD
SProcShmCreateSegment(ClientPtr client) SProcShmCreateSegment(ClientPtr client)
{ {
REQUEST(xShmCreateSegmentReq); REQUEST(xShmCreateSegmentReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xShmCreateSegmentReq); REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
swapl(&stuff->shmseg); swapl(&stuff->shmseg);
swapl(&stuff->size); swapl(&stuff->size);
@ -1477,9 +1499,13 @@ SProcShmDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
if (stuff->data == X_ShmQueryVersion)
return SProcShmQueryVersion(client);
if (!client->local)
return BadRequest;
switch (stuff->data) { switch (stuff->data) {
case X_ShmQueryVersion:
return ProcShmQueryVersion(client);
case X_ShmAttach: case X_ShmAttach:
return SProcShmAttach(client); return SProcShmAttach(client);
case X_ShmDetach: case X_ShmDetach:
@ -1501,14 +1527,6 @@ SProcShmDispatch(ClientPtr client)
} }
} }
static void ShmPixmapDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap)
{
ShmDetachSegment(
dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey),
0);
dixSetPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey, NULL);
}
void void
ShmExtensionInit(void) ShmExtensionInit(void)
{ {
@ -1531,16 +1549,19 @@ ShmExtensionInit(void)
for (i = 0; i < screenInfo.numScreens; i++) { for (i = 0; i < screenInfo.numScreens; i++) {
ShmScrPrivateRec *screen_priv = ShmScrPrivateRec *screen_priv =
ShmInitScreenPriv(screenInfo.screens[i]); ShmInitScreenPriv(screenInfo.screens[i]);
if (!screen_priv)
continue;
if (!screen_priv->shmFuncs) if (!screen_priv->shmFuncs)
screen_priv->shmFuncs = &miFuncs; screen_priv->shmFuncs = &miFuncs;
if (!screen_priv->shmFuncs->CreatePixmap) if (!screen_priv->shmFuncs->CreatePixmap)
sharedPixmaps = xFalse; sharedPixmaps = xFalse;
} }
if (sharedPixmaps) if (sharedPixmaps)
for (i = 0; i < screenInfo.numScreens; i++) for (i = 0; i < screenInfo.numScreens; i++) {
dixScreenHookPixmapDestroy(screenInfo.screens[i], ShmPixmapDestroy); ShmScrPrivateRec *screen_priv =
ShmGetScreenPriv(screenInfo.screens[i]);
screen_priv->destroyPixmap =
screenInfo.screens[i]->DestroyPixmap;
screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
}
} }
ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg"); ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
if (ShmSegType && if (ShmSegType &&

View File

@ -27,7 +27,9 @@ in this Software without prior written authorization from The Open Group.
/* dixsleep.c - implement millisecond timeouts for X clients */ /* dixsleep.c - implement millisecond timeouts for X clients */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "sleepuntil.h" #include "sleepuntil.h"
#include <X11/X.h> #include <X11/X.h>
@ -72,7 +74,7 @@ ClientSleepUntil(ClientPtr client,
TimeStamp *revive, TimeStamp *revive,
void (*notifyFunc) (ClientPtr, void *), void *closure) void (*notifyFunc) (ClientPtr, void *), void *closure)
{ {
SertafiedPtr pReq, pPrev; SertafiedPtr pRequest, pReq, pPrev;
if (SertafiedGeneration != serverGeneration) { if (SertafiedGeneration != serverGeneration) {
SertafiedResType = CreateNewResourceType(SertafiedDelete, SertafiedResType = CreateNewResourceType(SertafiedDelete,
@ -82,8 +84,7 @@ ClientSleepUntil(ClientPtr client,
SertafiedGeneration = serverGeneration; SertafiedGeneration = serverGeneration;
BlockHandlerRegistered = FALSE; BlockHandlerRegistered = FALSE;
} }
pRequest = malloc(sizeof(SertafiedRec));
SertafiedPtr pRequest = calloc(1, sizeof(SertafiedRec));
if (!pRequest) if (!pRequest)
return FALSE; return FALSE;
pRequest->pClient = client; pRequest->pClient = client;
@ -165,7 +166,7 @@ SertafiedBlockHandler(void *data, void *wt)
pNext = pReq->next; pNext = pReq->next;
if (CompareTimeStamps(pReq->revive, now) == LATER) if (CompareTimeStamps(pReq->revive, now) == LATER)
break; break;
FreeResource(pReq->id, X11_RESTYPE_NONE); FreeResource(pReq->id, RT_NONE);
/* AttendClient() may have been called via the resource delete /* AttendClient() may have been called via the resource delete
* function so a client may have input to be processed and so * function so a client may have input to be processed and so
@ -194,7 +195,7 @@ SertafiedWakeupHandler(void *data, int i)
pNext = pReq->next; pNext = pReq->next;
if (CompareTimeStamps(pReq->revive, now) == LATER) if (CompareTimeStamps(pReq->revive, now) == LATER)
break; break;
FreeResource(pReq->id, X11_RESTYPE_NONE); FreeResource(pReq->id, RT_NONE);
} }
if (!pPending) { if (!pPending) {
RemoveBlockAndWakeupHandlers(SertafiedBlockHandler, RemoveBlockAndWakeupHandlers(SertafiedBlockHandler,

View File

@ -24,7 +24,9 @@
* XFree86 Project. * XFree86 Project.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#ifndef _SLEEPUNTIL_H_ #ifndef _SLEEPUNTIL_H_
#define _SLEEPUNTIL_H_ 1 #define _SLEEPUNTIL_H_ 1

View File

@ -49,36 +49,36 @@ PERFORMANCE OF THIS SOFTWARE.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <string.h> #include <string.h>
#include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/Xmd.h> #include <X11/Xmd.h>
#include <X11/extensions/syncproto.h>
#include "dix/dix_priv.h"
#include "miext/extinit_priv.h"
#include "os/bug_priv.h"
#include "os/osdep.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "os.h" #include "os.h"
#include "bug.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "pixmapstr.h" #include "pixmapstr.h"
#include "resource.h" #include "resource.h"
#include "opaque.h"
#include <X11/extensions/syncproto.h>
#include "syncsrv.h" #include "syncsrv.h"
#include "syncsdk.h" #include "syncsdk.h"
#include "protocol-versions.h" #include "protocol-versions.h"
#include "inputstr.h" #include "inputstr.h"
#include "misync_priv.h"
#include <stdio.h>
#if !defined(WIN32) #if !defined(WIN32)
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include "extinit.h"
/* /*
* Local Global Variables * Local Global Variables
*/ */
@ -200,8 +200,8 @@ SyncAddTriggerToSyncObject(SyncTrigger * pTrigger)
return Success; return Success;
} }
/* Failure is not an option, it's succeed or burst! */ if (!(pCur = malloc(sizeof(SyncTriggerList))))
pCur = XNFalloc(sizeof(SyncTriggerList)); return BadAlloc;
pCur->pTrigger = pTrigger; pCur->pTrigger = pTrigger;
pCur->next = pTrigger->pSync->pTriglist; pCur->next = pTrigger->pSync->pTriglist;
@ -311,35 +311,6 @@ SyncCheckTriggerFence(SyncTrigger * pTrigger, int64_t unused)
return (pFence == NULL || pFence->funcs.CheckTriggered(pFence)); return (pFence == NULL || pFence->funcs.CheckTriggered(pFence));
} }
static inline Bool
checked_int64_add(int64_t *out, int64_t a, int64_t b)
{
/* Do the potentially overflowing math as uint64_t, as signed
* integers in C are undefined on overflow (and the compiler may
* optimize out our overflow check below, otherwise)
*/
int64_t result = (uint64_t)a + (uint64_t)b;
/* signed addition overflows if operands have the same sign, and
* the sign of the result doesn't match the sign of the inputs.
*/
Bool overflow = (a < 0) == (b < 0) && (a < 0) != (result < 0);
*out = result;
return overflow;
}
static inline Bool
checked_int64_subtract(int64_t *out, int64_t a, int64_t b)
{
int64_t result = (uint64_t)a - (uint64_t)b;
Bool overflow = (a < 0) != (b < 0) && (a < 0) != (result < 0);
*out = result;
return overflow;
}
static int static int
SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject, SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject,
RESTYPE resType, Mask changes) RESTYPE resType, Mask changes)
@ -359,6 +330,11 @@ SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject,
client->errorValue = syncObject; client->errorValue = syncObject;
return rc; 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 */ /* if system counter, ask it what the current value is */
@ -380,24 +356,6 @@ 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 (changes & XSyncCATestType) {
if (pSync && SYNC_FENCE == pSync->type) { if (pSync && SYNC_FENCE == pSync->type) {
@ -426,11 +384,21 @@ SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject,
} }
} }
if (changes & XSyncCACounter) { if (changes & (XSyncCAValueType | XSyncCAValue)) {
if (pSync != pTrigger->pSync) { /* new counter for trigger */ if (pTrigger->value_type == XSyncAbsolute)
SyncDeleteTriggerFromSyncObject(pTrigger); pTrigger->test_value = pTrigger->wait_value;
pTrigger->pSync = pSync; else { /* relative */
newSyncObject = TRUE; 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;
}
} }
} }
@ -438,7 +406,8 @@ SyncInitTrigger(ClientPtr client, SyncTrigger * pTrigger, XID syncObject,
* a new counter on a trigger * a new counter on a trigger
*/ */
if (newSyncObject) { if (newSyncObject) {
SyncAddTriggerToSyncObject(pTrigger); if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success)
return rc;
} }
else if (pCounter && IsSystemCounter(pCounter)) { else if (pCounter && IsSystemCounter(pCounter)) {
SyncComputeBracketValues(pCounter); SyncComputeBracketValues(pCounter);
@ -649,7 +618,7 @@ SyncAwaitTriggerFired(SyncTrigger * pTrigger)
pAwaitUnion = (SyncAwaitUnion *) pAwait->pHeader; pAwaitUnion = (SyncAwaitUnion *) pAwait->pHeader;
numwaits = pAwaitUnion->header.num_waitconditions; numwaits = pAwaitUnion->header.num_waitconditions;
ppAwait = calloc(numwaits, sizeof(SyncAwait *)); ppAwait = xallocarray(numwaits, sizeof(SyncAwait *));
if (!ppAwait) if (!ppAwait)
goto bail; goto bail;
@ -725,7 +694,7 @@ SyncAwaitTriggerFired(SyncTrigger * pTrigger)
/* unblock the client */ /* unblock the client */
AttendClient(pAwaitUnion->header.client); AttendClient(pAwaitUnion->header.client);
/* delete the await */ /* delete the await */
FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE); FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
} }
static int64_t static int64_t
@ -763,6 +732,8 @@ SyncChangeCounter(SyncCounter * pCounter, int64_t newval)
static Bool static Bool
SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents) SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
{ {
SyncAlarmClientList *pClients;
if (client == pAlarm->client) { /* alarm owner */ if (client == pAlarm->client) { /* alarm owner */
pAlarm->events = wantevents; pAlarm->events = wantevents;
return Success; return Success;
@ -770,8 +741,7 @@ SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
/* see if the client is already on the list (has events selected) */ /* see if the client is already on the list (has events selected) */
for (SyncAlarmClientList *pClients = pClients = pAlarm->pEventClients; for (pClients = pAlarm->pEventClients; pClients; pClients = pClients->next) {
pClients; pClients = pClients->next) {
if (pClients->client == client) { if (pClients->client == client) {
/* client's presence on the list indicates desire for /* client's presence on the list indicates desire for
* events. If the client doesn't want events, remove it * events. If the client doesn't want events, remove it
@ -779,7 +749,7 @@ SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
* nothing, since it's already got them. * nothing, since it's already got them.
*/ */
if (!wantevents) { if (!wantevents) {
FreeResource(pClients->delete_id, X11_RESTYPE_NONE); FreeResource(pClients->delete_id, RT_NONE);
} }
return Success; return Success;
} }
@ -797,7 +767,7 @@ SyncEventSelectForAlarm(SyncAlarm * pAlarm, ClientPtr client, Bool wantevents)
/* add new client to pAlarm->pEventClients */ /* add new client to pAlarm->pEventClients */
SyncAlarmClientList *pClients = calloc(1, sizeof(SyncAlarmClientList)); pClients = malloc(sizeof(SyncAlarmClientList));
if (!pClients) if (!pClients)
return BadAlloc; return BadAlloc;
@ -828,14 +798,8 @@ SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm * pAlarm, Mask mask,
int status; int status;
XSyncCounter counter; XSyncCounter counter;
Mask origmask = mask; Mask origmask = mask;
SyncTrigger trigger;
Bool select_events_changed = FALSE;
Bool select_events_value = FALSE;
int64_t delta;
trigger = pAlarm->trigger; counter = pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None;
delta = pAlarm->delta;
counter = trigger.pSync ? trigger.pSync->id : None;
while (mask) { while (mask) {
int index2 = lowbit(mask); int index2 = lowbit(mask);
@ -851,24 +815,24 @@ SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm * pAlarm, Mask mask,
case XSyncCAValueType: case XSyncCAValueType:
mask &= ~XSyncCAValueType; mask &= ~XSyncCAValueType;
/* sanity check in SyncInitTrigger */ /* sanity check in SyncInitTrigger */
trigger.value_type = *values++; pAlarm->trigger.value_type = *values++;
break; break;
case XSyncCAValue: case XSyncCAValue:
mask &= ~XSyncCAValue; mask &= ~XSyncCAValue;
trigger.wait_value = ((int64_t)values[0] << 32) | values[1]; pAlarm->trigger.wait_value = ((int64_t)values[0] << 32) | values[1];
values += 2; values += 2;
break; break;
case XSyncCATestType: case XSyncCATestType:
mask &= ~XSyncCATestType; mask &= ~XSyncCATestType;
/* sanity check in SyncInitTrigger */ /* sanity check in SyncInitTrigger */
trigger.test_type = *values++; pAlarm->trigger.test_type = *values++;
break; break;
case XSyncCADelta: case XSyncCADelta:
mask &= ~XSyncCADelta; mask &= ~XSyncCADelta;
delta = ((int64_t)values[0] << 32) | values[1]; pAlarm->delta = ((int64_t)values[0] << 32) | values[1];
values += 2; values += 2;
break; break;
@ -878,8 +842,10 @@ SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm * pAlarm, Mask mask,
client->errorValue = *values; client->errorValue = *values;
return BadValue; return BadValue;
} }
select_events_value = (Bool) (*values++); status = SyncEventSelectForAlarm(pAlarm, client,
select_events_changed = TRUE; (Bool) (*values++));
if (status != Success)
return status;
break; break;
default: default:
@ -888,33 +854,25 @@ 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 /* "If the test-type is PositiveComparison or PositiveTransition
* and delta is less than zero, or if the test-type is * and delta is less than zero, or if the test-type is
* NegativeComparison or NegativeTransition and delta is * NegativeComparison or NegativeTransition and delta is
* greater than zero, a Match error is generated." * greater than zero, a Match error is generated."
*/ */
if (origmask & (XSyncCADelta | XSyncCATestType)) { if (origmask & (XSyncCADelta | XSyncCATestType)) {
if ((((trigger.test_type == XSyncPositiveComparison) || if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) ||
(trigger.test_type == XSyncPositiveTransition)) (pAlarm->trigger.test_type == XSyncPositiveTransition))
&& delta < 0) && pAlarm->delta < 0)
|| ||
(((trigger.test_type == XSyncNegativeComparison) || (((pAlarm->trigger.test_type == XSyncNegativeComparison) ||
(trigger.test_type == XSyncNegativeTransition)) (pAlarm->trigger.test_type == XSyncNegativeTransition))
&& delta > 0) && pAlarm->delta > 0)
) { ) {
return BadMatch; return BadMatch;
} }
} }
/* postpone this until now, when we're sure nothing else can go wrong */ /* 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, if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter,
origmask & XSyncCAAllTrigger)) != Success) origmask & XSyncCAAllTrigger)) != Success)
return status; return status;
@ -932,7 +890,7 @@ SyncCreate(ClientPtr client, XID id, unsigned char type)
switch (type) { switch (type) {
case SYNC_COUNTER: case SYNC_COUNTER:
pSync = calloc(1, sizeof(SyncCounter)); pSync = malloc(sizeof(SyncCounter));
resType = RTCounter; resType = RTCounter;
break; break;
case SYNC_FENCE: case SYNC_FENCE:
@ -974,7 +932,7 @@ SyncCreateFenceFromFD(ClientPtr client, DrawablePtr pDraw, XID id, int fd, BOOL
status = miSyncInitFenceFromFD(pDraw, pFence, fd, initially_triggered); status = miSyncInitFenceFromFD(pDraw, pFence, fd, initially_triggered);
if (status != Success) { if (status != Success) {
FreeResource(pFence->sync.id, X11_RESTYPE_NONE); FreeResource(pFence->sync.id, RT_NONE);
return status; return status;
} }
@ -1025,12 +983,14 @@ SyncCreateSystemCounter(const char *name,
SyncSystemCounterBracketValues BracketValues SyncSystemCounterBracketValues BracketValues
) )
{ {
SyncCounter *pCounter = SyncCreateCounter(NULL, dixAllocServerXID(), initial); SyncCounter *pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial);
if (pCounter) { if (pCounter) {
SysCounterInfo *psci = calloc(1, sizeof(SysCounterInfo)); SysCounterInfo *psci;
psci = malloc(sizeof(SysCounterInfo));
if (!psci) { if (!psci) {
FreeResource(pCounter->sync.id, X11_RESTYPE_NONE); FreeResource(pCounter->sync.id, RT_NONE);
return pCounter; return pCounter;
} }
pCounter->pSysCounterInfo = psci; pCounter->pSysCounterInfo = psci;
@ -1053,7 +1013,7 @@ SyncDestroySystemCounter(void *pSysCounter)
{ {
SyncCounter *pCounter = (SyncCounter *) pSysCounter; SyncCounter *pCounter = (SyncCounter *) pSysCounter;
FreeResource(pCounter->sync.id, X11_RESTYPE_NONE); FreeResource(pCounter->sync.id, RT_NONE);
} }
static void static void
@ -1166,7 +1126,7 @@ FreeAlarm(void *addr, XID id)
/* delete event selections */ /* delete event selections */
while (pAlarm->pEventClients) while (pAlarm->pEventClients)
FreeResource(pAlarm->pEventClients->delete_id, X11_RESTYPE_NONE); FreeResource(pAlarm->pEventClients->delete_id, RT_NONE);
SyncDeleteTriggerFromSyncObject(&pAlarm->trigger); SyncDeleteTriggerFromSyncObject(&pAlarm->trigger);
@ -1307,7 +1267,7 @@ ProcSyncListSystemCounters(ClientPtr client)
} }
if (len) { if (len) {
walklist = list = calloc(1, len); walklist = list = malloc(len);
if (!list) if (!list)
return BadAlloc; return BadAlloc;
} }
@ -1354,8 +1314,7 @@ ProcSyncListSystemCounters(ClientPtr client)
} }
/* /*
* Set the priority of the client owning given resource. * ** Set client Priority
* If the resource ID is None then set the priority of calling client.
*/ */
static int static int
ProcSyncSetPriority(ClientPtr client) ProcSyncSetPriority(ClientPtr client)
@ -1369,7 +1328,7 @@ ProcSyncSetPriority(ClientPtr client)
if (stuff->id == None) if (stuff->id == None)
priorityclient = client; priorityclient = client;
else { else {
rc = dixLookupResourceOwner(&priorityclient, stuff->id, client, rc = dixLookupClient(&priorityclient, stuff->id, client,
DixSetAttrAccess); DixSetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
@ -1389,8 +1348,7 @@ ProcSyncSetPriority(ClientPtr client)
} }
/* /*
* Retrieve the priority of the client owning given resource. * ** Get client Priority
* If the resource ID is None then retrieve the priority of calling client.
*/ */
static int static int
ProcSyncGetPriority(ClientPtr client) ProcSyncGetPriority(ClientPtr client)
@ -1405,7 +1363,7 @@ ProcSyncGetPriority(ClientPtr client)
if (stuff->id == None) if (stuff->id == None)
priorityclient = client; priorityclient = client;
else { else {
rc = dixLookupResourceOwner(&priorityclient, stuff->id, client, rc = dixLookupClient(&priorityclient, stuff->id, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
@ -1533,7 +1491,7 @@ ProcSyncDestroyCounter(ClientPtr client)
client->errorValue = stuff->counter; client->errorValue = stuff->counter;
return BadAccess; return BadAccess;
} }
FreeResource(pCounter->sync.id, X11_RESTYPE_NONE); FreeResource(pCounter->sync.id, RT_NONE);
return Success; return Success;
} }
@ -1545,7 +1503,7 @@ SyncAwaitPrologue(ClientPtr client, int items)
/* all the memory for the entire await list is allocated /* all the memory for the entire await list is allocated
* here in one chunk * here in one chunk
*/ */
pAwaitUnion = calloc(items + 1, sizeof(SyncAwaitUnion)); pAwaitUnion = xallocarray(items + 1, sizeof(SyncAwaitUnion));
if (!pAwaitUnion) if (!pAwaitUnion)
return NULL; return NULL;
@ -1634,7 +1592,7 @@ ProcSyncAwait(ClientPtr client)
/* this should take care of removing any triggers created by /* this should take care of removing any triggers created by
* this request that have already been registered on sync objects * this request that have already been registered on sync objects
*/ */
FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE); FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
client->errorValue = pProtocolWaitConds->counter; client->errorValue = pProtocolWaitConds->counter;
return SyncErrorBase + XSyncBadCounter; return SyncErrorBase + XSyncBadCounter;
} }
@ -1654,7 +1612,7 @@ ProcSyncAwait(ClientPtr client)
/* this should take care of removing any triggers created by /* this should take care of removing any triggers created by
* this request that have already been registered on sync objects * this request that have already been registered on sync objects
*/ */
FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE); FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
return status; return status;
} }
/* this is not a mistake -- same function works for both cases */ /* this is not a mistake -- same function works for both cases */
@ -1737,7 +1695,7 @@ ProcSyncCreateAlarm(ClientPtr client)
if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue | XSyncCADelta)))) if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue | XSyncCADelta))))
return BadLength; return BadLength;
if (!(pAlarm = calloc(1, sizeof(SyncAlarm)))) { if (!(pAlarm = malloc(sizeof(SyncAlarm)))) {
return BadAlloc; return BadAlloc;
} }
@ -1785,7 +1743,7 @@ ProcSyncCreateAlarm(ClientPtr client)
if (!SyncCheckWarnIsCounter(pTrigger->pSync, if (!SyncCheckWarnIsCounter(pTrigger->pSync,
WARN_INVALID_COUNTER_ALARM)) { WARN_INVALID_COUNTER_ALARM)) {
FreeResource(stuff->id, X11_RESTYPE_NONE); FreeResource(stuff->id, RT_NONE);
return BadAlloc; return BadAlloc;
} }
@ -1916,7 +1874,7 @@ ProcSyncDestroyAlarm(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
FreeResource(stuff->alarm, X11_RESTYPE_NONE); FreeResource(stuff->alarm, RT_NONE);
return Success; return Success;
} }
@ -2021,7 +1979,7 @@ ProcSyncDestroyFence(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
FreeResource(stuff->fid, X11_RESTYPE_NONE); FreeResource(stuff->fid, RT_NONE);
return Success; return Success;
} }
@ -2099,7 +2057,7 @@ ProcSyncAwaitFence(ClientPtr client)
/* this should take care of removing any triggers created by /* this should take care of removing any triggers created by
* this request that have already been registered on sync objects * this request that have already been registered on sync objects
*/ */
FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE); FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
client->errorValue = *pProtocolFences; client->errorValue = *pProtocolFences;
return SyncErrorBase + XSyncBadFence; return SyncErrorBase + XSyncBadFence;
} }
@ -2118,7 +2076,7 @@ ProcSyncAwaitFence(ClientPtr client)
/* this should take care of removing any triggers created by /* this should take care of removing any triggers created by
* this request that have already been registered on sync objects * this request that have already been registered on sync objects
*/ */
FreeResource(pAwaitUnion->header.delete_id, X11_RESTYPE_NONE); FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
return status; return status;
} }
/* this is not a mistake -- same function works for both cases */ /* this is not a mistake -- same function works for both cases */
@ -2193,10 +2151,31 @@ ProcSyncDispatch(ClientPtr client)
* Boring Swapping stuff ... * Boring Swapping stuff ...
*/ */
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 static int _X_COLD
SProcSyncCreateCounter(ClientPtr client) SProcSyncCreateCounter(ClientPtr client)
{ {
REQUEST(xSyncCreateCounterReq); REQUEST(xSyncCreateCounterReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncCreateCounterReq); REQUEST_SIZE_MATCH(xSyncCreateCounterReq);
swapl(&stuff->cid); swapl(&stuff->cid);
swapl(&stuff->initial_value_lo); swapl(&stuff->initial_value_lo);
@ -2209,6 +2188,7 @@ static int _X_COLD
SProcSyncSetCounter(ClientPtr client) SProcSyncSetCounter(ClientPtr client)
{ {
REQUEST(xSyncSetCounterReq); REQUEST(xSyncSetCounterReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncSetCounterReq); REQUEST_SIZE_MATCH(xSyncSetCounterReq);
swapl(&stuff->cid); swapl(&stuff->cid);
swapl(&stuff->value_lo); swapl(&stuff->value_lo);
@ -2221,6 +2201,7 @@ static int _X_COLD
SProcSyncChangeCounter(ClientPtr client) SProcSyncChangeCounter(ClientPtr client)
{ {
REQUEST(xSyncChangeCounterReq); REQUEST(xSyncChangeCounterReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncChangeCounterReq); REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
swapl(&stuff->cid); swapl(&stuff->cid);
swapl(&stuff->value_lo); swapl(&stuff->value_lo);
@ -2233,6 +2214,7 @@ static int _X_COLD
SProcSyncQueryCounter(ClientPtr client) SProcSyncQueryCounter(ClientPtr client)
{ {
REQUEST(xSyncQueryCounterReq); REQUEST(xSyncQueryCounterReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncQueryCounterReq); REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
swapl(&stuff->counter); swapl(&stuff->counter);
@ -2243,6 +2225,7 @@ static int _X_COLD
SProcSyncDestroyCounter(ClientPtr client) SProcSyncDestroyCounter(ClientPtr client)
{ {
REQUEST(xSyncDestroyCounterReq); REQUEST(xSyncDestroyCounterReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
swapl(&stuff->counter); swapl(&stuff->counter);
@ -2253,6 +2236,7 @@ static int _X_COLD
SProcSyncAwait(ClientPtr client) SProcSyncAwait(ClientPtr client)
{ {
REQUEST(xSyncAwaitReq); REQUEST(xSyncAwaitReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
SwapRestL(stuff); SwapRestL(stuff);
@ -2263,6 +2247,7 @@ static int _X_COLD
SProcSyncCreateAlarm(ClientPtr client) SProcSyncCreateAlarm(ClientPtr client)
{ {
REQUEST(xSyncCreateAlarmReq); REQUEST(xSyncCreateAlarmReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
swapl(&stuff->id); swapl(&stuff->id);
swapl(&stuff->valueMask); swapl(&stuff->valueMask);
@ -2275,6 +2260,7 @@ static int _X_COLD
SProcSyncChangeAlarm(ClientPtr client) SProcSyncChangeAlarm(ClientPtr client)
{ {
REQUEST(xSyncChangeAlarmReq); REQUEST(xSyncChangeAlarmReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
swapl(&stuff->alarm); swapl(&stuff->alarm);
swapl(&stuff->valueMask); swapl(&stuff->valueMask);
@ -2286,6 +2272,7 @@ static int _X_COLD
SProcSyncQueryAlarm(ClientPtr client) SProcSyncQueryAlarm(ClientPtr client)
{ {
REQUEST(xSyncQueryAlarmReq); REQUEST(xSyncQueryAlarmReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
swapl(&stuff->alarm); swapl(&stuff->alarm);
@ -2296,6 +2283,7 @@ static int _X_COLD
SProcSyncDestroyAlarm(ClientPtr client) SProcSyncDestroyAlarm(ClientPtr client)
{ {
REQUEST(xSyncDestroyAlarmReq); REQUEST(xSyncDestroyAlarmReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
swapl(&stuff->alarm); swapl(&stuff->alarm);
@ -2306,6 +2294,7 @@ static int _X_COLD
SProcSyncSetPriority(ClientPtr client) SProcSyncSetPriority(ClientPtr client)
{ {
REQUEST(xSyncSetPriorityReq); REQUEST(xSyncSetPriorityReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncSetPriorityReq); REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
swapl(&stuff->id); swapl(&stuff->id);
swapl(&stuff->priority); swapl(&stuff->priority);
@ -2317,6 +2306,7 @@ static int _X_COLD
SProcSyncGetPriority(ClientPtr client) SProcSyncGetPriority(ClientPtr client)
{ {
REQUEST(xSyncGetPriorityReq); REQUEST(xSyncGetPriorityReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncGetPriorityReq); REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
swapl(&stuff->id); swapl(&stuff->id);
@ -2327,8 +2317,8 @@ static int _X_COLD
SProcSyncCreateFence(ClientPtr client) SProcSyncCreateFence(ClientPtr client)
{ {
REQUEST(xSyncCreateFenceReq); REQUEST(xSyncCreateFenceReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncCreateFenceReq); REQUEST_SIZE_MATCH(xSyncCreateFenceReq);
swapl(&stuff->d);
swapl(&stuff->fid); swapl(&stuff->fid);
return ProcSyncCreateFence(client); return ProcSyncCreateFence(client);
@ -2338,6 +2328,7 @@ static int _X_COLD
SProcSyncTriggerFence(ClientPtr client) SProcSyncTriggerFence(ClientPtr client)
{ {
REQUEST(xSyncTriggerFenceReq); REQUEST(xSyncTriggerFenceReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncTriggerFenceReq); REQUEST_SIZE_MATCH(xSyncTriggerFenceReq);
swapl(&stuff->fid); swapl(&stuff->fid);
@ -2348,6 +2339,7 @@ static int _X_COLD
SProcSyncResetFence(ClientPtr client) SProcSyncResetFence(ClientPtr client)
{ {
REQUEST(xSyncResetFenceReq); REQUEST(xSyncResetFenceReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncResetFenceReq); REQUEST_SIZE_MATCH(xSyncResetFenceReq);
swapl(&stuff->fid); swapl(&stuff->fid);
@ -2358,6 +2350,7 @@ static int _X_COLD
SProcSyncDestroyFence(ClientPtr client) SProcSyncDestroyFence(ClientPtr client)
{ {
REQUEST(xSyncDestroyFenceReq); REQUEST(xSyncDestroyFenceReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncDestroyFenceReq); REQUEST_SIZE_MATCH(xSyncDestroyFenceReq);
swapl(&stuff->fid); swapl(&stuff->fid);
@ -2368,6 +2361,7 @@ static int _X_COLD
SProcSyncQueryFence(ClientPtr client) SProcSyncQueryFence(ClientPtr client)
{ {
REQUEST(xSyncQueryFenceReq); REQUEST(xSyncQueryFenceReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xSyncQueryFenceReq); REQUEST_SIZE_MATCH(xSyncQueryFenceReq);
swapl(&stuff->fid); swapl(&stuff->fid);
@ -2378,6 +2372,7 @@ static int _X_COLD
SProcSyncAwaitFence(ClientPtr client) SProcSyncAwaitFence(ClientPtr client)
{ {
REQUEST(xSyncAwaitFenceReq); REQUEST(xSyncAwaitFenceReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
SwapRestL(stuff); SwapRestL(stuff);
@ -2391,9 +2386,9 @@ SProcSyncDispatch(ClientPtr client)
switch (stuff->data) { switch (stuff->data) {
case X_SyncInitialize: case X_SyncInitialize:
return ProcSyncInitialize(client); return SProcSyncInitialize(client);
case X_SyncListSystemCounters: case X_SyncListSystemCounters:
return ProcSyncListSystemCounters(client); return SProcSyncListSystemCounters(client);
case X_SyncCreateCounter: case X_SyncCreateCounter:
return SProcSyncCreateCounter(client); return SProcSyncCreateCounter(client);
case X_SyncSetCounter: case X_SyncSetCounter:
@ -2645,15 +2640,16 @@ typedef struct {
static void static void
IdleTimeQueryValue(void *pCounter, int64_t *pValue_return) IdleTimeQueryValue(void *pCounter, int64_t *pValue_return)
{ {
int deviceid = XIAllDevices; int deviceid;
CARD32 idle; CARD32 idle;
if (pCounter) { if (pCounter) {
SyncCounter *counter = pCounter; SyncCounter *counter = pCounter;
IdleCounterPriv *priv = SysCounterGetPrivate(counter); IdleCounterPriv *priv = SysCounterGetPrivate(counter);
if (priv)
deviceid = priv->deviceid; deviceid = priv->deviceid;
} }
else
deviceid = XIAllDevices;
idle = GetTimeInMillis() - LastEventTime(deviceid).milliseconds; idle = GetTimeInMillis() - LastEventTime(deviceid).milliseconds;
*pValue_return = idle; *pValue_return = idle;
} }
@ -2663,8 +2659,6 @@ IdleTimeBlockHandler(void *pCounter, void *wt)
{ {
SyncCounter *counter = pCounter; SyncCounter *counter = pCounter;
IdleCounterPriv *priv = SysCounterGetPrivate(counter); IdleCounterPriv *priv = SysCounterGetPrivate(counter);
if (!priv)
return;
int64_t *less = priv->value_less; int64_t *less = priv->value_less;
int64_t *greater = priv->value_greater; int64_t *greater = priv->value_greater;
int64_t idle, old_idle; int64_t idle, old_idle;
@ -2755,8 +2749,6 @@ IdleTimeWakeupHandler(void *pCounter, int rc)
{ {
SyncCounter *counter = pCounter; SyncCounter *counter = pCounter;
IdleCounterPriv *priv = SysCounterGetPrivate(counter); IdleCounterPriv *priv = SysCounterGetPrivate(counter);
if (!priv)
return;
int64_t *less = priv->value_less; int64_t *less = priv->value_less;
int64_t *greater = priv->value_greater; int64_t *greater = priv->value_greater;
int64_t idle; int64_t idle;
@ -2790,8 +2782,6 @@ IdleTimeBracketValues(void *pCounter, int64_t *pbracket_less,
{ {
SyncCounter *counter = pCounter; SyncCounter *counter = pCounter;
IdleCounterPriv *priv = SysCounterGetPrivate(counter); IdleCounterPriv *priv = SysCounterGetPrivate(counter);
if (!priv)
return;
int64_t *less = priv->value_less; int64_t *less = priv->value_less;
int64_t *greater = priv->value_greater; int64_t *greater = priv->value_greater;
Bool registered = (less || greater); Bool registered = (less || greater);
@ -2821,24 +2811,20 @@ init_system_idle_counter(const char *name, int deviceid)
IdleTimeQueryValue(NULL, &idle); IdleTimeQueryValue(NULL, &idle);
IdleCounterPriv *priv = calloc(1, sizeof(IdleCounterPriv));
if (!priv)
return NULL;
idle_time_counter = SyncCreateSystemCounter(name, idle, resolution, idle_time_counter = SyncCreateSystemCounter(name, idle, resolution,
XSyncCounterUnrestricted, XSyncCounterUnrestricted,
IdleTimeQueryValue, IdleTimeQueryValue,
IdleTimeBracketValues); IdleTimeBracketValues);
if (!idle_time_counter) { if (idle_time_counter != NULL) {
free(priv); IdleCounterPriv *priv = malloc(sizeof(IdleCounterPriv));
return NULL;
}
priv->value_less = priv->value_greater = NULL; priv->value_less = priv->value_greater = NULL;
priv->deviceid = deviceid; priv->deviceid = deviceid;
idle_time_counter->pSysCounterInfo->private = priv; idle_time_counter->pSysCounterInfo->private = priv;
}
return idle_time_counter; return idle_time_counter;
} }

File diff suppressed because it is too large Load Diff

View File

@ -17,12 +17,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************/ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdarg.h> #include <stdarg.h>
#include "os/client_priv.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "pixmapstr.h" #include "pixmapstr.h"
@ -30,12 +29,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "gcstruct.h" #include "gcstruct.h"
#include "xacestr.h" #include "xacestr.h"
CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = { 0 }; _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = { 0 };
/* Special-cased hook functions. Called by Xserver. /* Special-cased hook functions. Called by Xserver.
*/ */
#undef XaceHookDispatch
int int
XaceHookDispatch0(ClientPtr client, int major) XaceHookDispatch(ClientPtr client, int major)
{ {
/* Call the extension dispatch hook */ /* Call the extension dispatch hook */
ExtensionEntry *ext = GetExtensionEntry(major); ExtensionEntry *ext = GetExtensionEntry(major);
@ -63,85 +63,130 @@ XaceHookSelectionAccess(ClientPtr client, Selection ** ppSel, Mask access_mode)
return rec.status; return rec.status;
} }
int XaceHookResourceAccess(ClientPtr client, XID id, RESTYPE rtype, void *res, /* Entry point for hook functions. Called by Xserver.
RESTYPE ptype, void *parent, Mask access_mode) */
int
XaceHook(int hook, ...)
{ {
XaceResourceAccessRec rec = { client, id, rtype, res, ptype, parent, union {
access_mode, Success }; XaceResourceAccessRec res;
CallCallbacks(&XaceHooks[XACE_RESOURCE_ACCESS], &rec); XaceDeviceAccessRec dev;
return rec.status; 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 */
int XaceHookDeviceAccess(ClientPtr client, DeviceIntPtr dev, Mask access_mode) if (!XaceHooks[hook])
{
XaceDeviceAccessRec rec = { client, dev, access_mode, Success };
CallCallbacks(&XaceHooks[XACE_DEVICE_ACCESS], &rec);
return rec.status;
}
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; return Success;
}
int XaceHookKeyAvail(xEventPtr ev, DeviceIntPtr dev, int count) va_start(ap, hook);
{
XaceKeyAvailRec rec = { ev, dev, count }; /* Marshal arguments for passing to callback.
CallCallbacks(&XaceHooks[XACE_KEY_AVAIL], &rec); * Each callback has its own case, which sets up a structure to hold
return Success; * 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);
/* call callbacks and return result, if any. */
CallCallbacks(&XaceHooks[hook], &u);
return prv ? *prv : Success;
} }
/* XaceHookIsSet /* XaceHookIsSet
@ -204,6 +249,7 @@ XaceCensorImage(ClientPtr client,
if (nRects > 0) { /* we have something to censor */ if (nRects > 0) { /* we have something to censor */
GCPtr pScratchGC = NULL; GCPtr pScratchGC = NULL;
PixmapPtr pPix = NULL; PixmapPtr pPix = NULL;
xRectangle *pRects = NULL;
Bool failed = FALSE; Bool failed = FALSE;
int depth = 1; int depth = 1;
int bitsPerPixel = 1; int bitsPerPixel = 1;
@ -212,7 +258,7 @@ XaceCensorImage(ClientPtr client,
/* convert region to list-of-rectangles for PolyFillRect */ /* convert region to list-of-rectangles for PolyFillRect */
xRectangle *pRects = calloc(1, nRects * sizeof(xRectangle)); pRects = malloc(nRects * sizeof(xRectangle));
if (!pRects) { if (!pRects) {
failed = TRUE; failed = TRUE;
goto failSafe; goto failSafe;
@ -280,15 +326,3 @@ XaceIsLocal(ClientPtr client)
{ {
return ClientIsLocal(client); return ClientIsLocal(client);
} }
Bool
XaceRegisterCallback(int hook, CallbackProcPtr callback, void *data)
{
return AddCallback(XaceHooks+(hook), callback, data);
}
Bool
XaceDeleteCallback(int hook, CallbackProcPtr callback, void *data)
{
return DeleteCallback(XaceHooks+(hook), callback, data);
}

View File

@ -25,13 +25,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XACE_MAJOR_VERSION 2 #define XACE_MAJOR_VERSION 2
#define XACE_MINOR_VERSION 0 #define XACE_MINOR_VERSION 0
#include "dix/selection_priv.h"
#include "extnsionst.h"
#include "pixmap.h" #include "pixmap.h"
#include "region.h" #include "region.h"
#include "window.h" #include "window.h"
#include "property.h" #include "property.h"
#include "selection.h"
/* Default window background */ /* Default window background */
#define XaceBackgroundNoneState(w) ((w)->forcedBG ? BackgroundPixel : None) #define XaceBackgroundNoneState(w) ((w)->forcedBG ? BackgroundPixel : None)
@ -39,6 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* security hooks */ /* security hooks */
/* Constants used to identify the available security hooks /* Constants used to identify the available security hooks
*/ */
#define XACE_CORE_DISPATCH 0
#define XACE_EXT_DISPATCH 1 #define XACE_EXT_DISPATCH 1
#define XACE_RESOURCE_ACCESS 2 #define XACE_RESOURCE_ACCESS 2
#define XACE_DEVICE_ACCESS 3 #define XACE_DEVICE_ACCESS 3
@ -55,57 +54,51 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XACE_KEY_AVAIL 14 #define XACE_KEY_AVAIL 14
#define XACE_NUM_HOOKS 15 #define XACE_NUM_HOOKS 15
extern CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; extern _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS];
/* Entry point for hook functions. Called by Xserver. /* Entry point for hook functions. Called by Xserver.
* Required by several modules * Required by libdbe and libextmod
*/ */
_X_EXPORT Bool XaceRegisterCallback(int hook, CallbackProcPtr callback, void *data); extern _X_EXPORT int XaceHook(int /*hook */ ,
_X_EXPORT Bool XaceDeleteCallback(int hook, CallbackProcPtr callback, void *data); ... /*appropriate args for hook */
);
/* determine whether any callbacks are present for the XACE hook */ /* determine whether any callbacks are present for the XACE hook */
int XaceHookIsSet(int hook); extern _X_EXPORT int XaceHookIsSet(int hook);
/* Special-cased hook functions /* Special-cased hook functions
*/ */
int XaceHookDispatch0(ClientPtr ptr, int major); extern _X_EXPORT int XaceHookDispatch(ClientPtr ptr, int major);
#define XaceHookDispatch(c, m) \ #define XaceHookDispatch(c, m) \
((XaceHooks[XACE_EXT_DISPATCH] && (m) >= EXTENSION_BASE) ? \ ((XaceHooks[XACE_EXT_DISPATCH] && (m) >= EXTENSION_BASE) ? \
XaceHookDispatch0((c), (m)) : \ XaceHookDispatch((c), (m)) : \
Success) Success)
int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin, PropertyPtr *ppProp, 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); Mask access_mode);
int XaceHookSelectionAccess(ClientPtr ptr, Selection ** ppSel, Mask access_mode);
/* needs to be exported for in-tree modesetting, but not part of public API */ /* Register a callback for a given hook.
_X_EXPORT int XaceHookResourceAccess(ClientPtr client, XID id, RESTYPE rtype, void *res, */
RESTYPE ptype, void *parent, Mask access_mode); #define XaceRegisterCallback(hook,callback,data) \
AddCallback(XaceHooks+(hook), callback, data)
int XaceHookDeviceAccess(ClientPtr client, DeviceIntPtr dev, Mask access_mode); /* Unregister an existing callback for a given hook.
*/
int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win, #define XaceDeleteCallback(hook,callback,data) \
xEventPtr ev, int count); DeleteCallback(XaceHooks+(hook), callback, data)
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 / unregister a callback for a given hook. */
/* XTrans wrappers for use by security modules /* XTrans wrappers for use by security modules
*/ */
int XaceGetConnectionNumber(ClientPtr ptr); extern _X_EXPORT int XaceGetConnectionNumber(ClientPtr ptr);
int XaceIsLocal(ClientPtr ptr); extern _X_EXPORT int XaceIsLocal(ClientPtr ptr);
/* From the original Security extension... /* From the original Security extension...
*/ */
void XaceCensorImage(ClientPtr client, extern _X_EXPORT void XaceCensorImage(ClientPtr client,
RegionPtr pVisibleRegion, RegionPtr pVisibleRegion,
long widthBytesLine, long widthBytesLine,
DrawablePtr pDraw, DrawablePtr pDraw,
@ -120,12 +113,14 @@ void XaceCensorImage(ClientPtr client,
/* Define calls away when XACE is not being built. */ /* Define calls away when XACE is not being built. */
#ifdef __GNUC__ #ifdef __GNUC__
#define XaceHook(args...) Success
#define XaceHookIsSet(args...) 0 #define XaceHookIsSet(args...) 0
#define XaceHookDispatch(args...) Success #define XaceHookDispatch(args...) Success
#define XaceHookPropertyAccess(args...) Success #define XaceHookPropertyAccess(args...) Success
#define XaceHookSelectionAccess(args...) Success #define XaceHookSelectionAccess(args...) Success
#define XaceCensorImage(args...) { ; } #define XaceCensorImage(args...) { ; }
#else #else
#define XaceHook(...) Success
#define XaceHookIsSet(...) 0 #define XaceHookIsSet(...) 0
#define XaceHookDispatch(...) Success #define XaceHookDispatch(...) Success
#define XaceHookPropertyAccess(...) Success #define XaceHookPropertyAccess(...) Success

View File

@ -20,16 +20,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _XACESTR_H #ifndef _XACESTR_H
#define _XACESTR_H #define _XACESTR_H
#include "dix/selection_priv.h"
#include "dix.h" #include "dix.h"
#include "resource.h" #include "resource.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "window.h" #include "window.h"
#include "input.h" #include "input.h"
#include "property.h" #include "property.h"
#include "selection.h"
#include "xace.h" #include "xace.h"
/* XACE_CORE_DISPATCH */
typedef struct {
ClientPtr client;
int status;
} XaceCoreDispatchRec;
/* XACE_RESOURCE_ACCESS */ /* XACE_RESOURCE_ACCESS */
typedef struct { typedef struct {
ClientPtr client; ClientPtr client;

View File

@ -26,21 +26,21 @@ from The Open Group.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <stdint.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/xcmiscproto.h>
#include "dix/resource_priv.h"
#include "miext/extinit_priv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "swaprep.h" #include "swaprep.h"
#include <X11/extensions/xcmiscproto.h>
#include "extinit.h"
#include <stdint.h>
static int static int
ProcXCMiscGetVersion(ClientPtr client) ProcXCMiscGetVersion(ClientPtr client)
@ -101,7 +101,7 @@ ProcXCMiscGetXIDList(ClientPtr client)
if (stuff->count > UINT32_MAX / sizeof(XID)) if (stuff->count > UINT32_MAX / sizeof(XID))
return BadAlloc; return BadAlloc;
pids = calloc(stuff->count, sizeof(XID)); pids = xallocarray(stuff->count, sizeof(XID));
if (!pids) { if (!pids) {
return BadAlloc; return BadAlloc;
} }
@ -146,18 +146,30 @@ static int _X_COLD
SProcXCMiscGetVersion(ClientPtr client) SProcXCMiscGetVersion(ClientPtr client)
{ {
REQUEST(xXCMiscGetVersionReq); REQUEST(xXCMiscGetVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq); REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
swaps(&stuff->majorVersion); swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion);
return ProcXCMiscGetVersion(client); return ProcXCMiscGetVersion(client);
} }
static int _X_COLD
SProcXCMiscGetXIDRange(ClientPtr client)
{
REQUEST(xReq);
swaps(&stuff->length);
return ProcXCMiscGetXIDRange(client);
}
static int _X_COLD static int _X_COLD
SProcXCMiscGetXIDList(ClientPtr client) SProcXCMiscGetXIDList(ClientPtr client)
{ {
REQUEST(xXCMiscGetXIDListReq); REQUEST(xXCMiscGetXIDListReq);
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq); REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
swaps(&stuff->length);
swapl(&stuff->count); swapl(&stuff->count);
return ProcXCMiscGetXIDList(client); return ProcXCMiscGetXIDList(client);
} }
@ -170,7 +182,7 @@ SProcXCMiscDispatch(ClientPtr client)
case X_XCMiscGetVersion: case X_XCMiscGetVersion:
return SProcXCMiscGetVersion(client); return SProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange: case X_XCMiscGetXIDRange:
return ProcXCMiscGetXIDRange(client); return SProcXCMiscGetXIDRange(client);
case X_XCMiscGetXIDList: case X_XCMiscGetXIDList:
return SProcXCMiscGetXIDList(client); return SProcXCMiscGetXIDList(client);
default: default:

View File

@ -34,13 +34,19 @@
* XLoadQueryFont). * XLoadQueryFont).
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#ifdef MITSHM #ifdef HAS_SHM
#ifdef SVR4 #ifdef SVR4
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#endif #endif
#if defined(__CYGWIN__)
#include <sys/param.h>
#include <sys/sysmacros.h>
#endif
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -52,27 +58,22 @@
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/xf86bigfproto.h>
#include <X11/fonts/fontstruct.h>
#include <X11/fonts/libxfont2.h>
#include "miext/extinit_priv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "gcstruct.h" #include "gcstruct.h"
#include "dixfontstr.h" #include "dixfontstr.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "extinit.h"
#include "protocol-versions.h" #include "protocol-versions.h"
#include <X11/extensions/xf86bigfproto.h>
#include "xf86bigfontsrv.h" #include "xf86bigfontsrv.h"
Bool noXFree86BigfontExtension = FALSE; static void XF86BigfontResetProc(ExtensionEntry * /* extEntry */
);
static void XF86BigfontResetProc(ExtensionEntry *extEntry ); #ifdef HAS_SHM
#ifdef MITSHM
/* A random signature, transmitted to the clients so they can verify that the /* A random signature, transmitted to the clients so they can verify that the
shared memory segment they are attaching to was really established by the shared memory segment they are attaching to was really established by the
@ -86,7 +87,7 @@ static unsigned int pagesize;
static Bool badSysCall = FALSE; static Bool badSysCall = FALSE;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
static void static void
SigSysHandler(int signo) SigSysHandler(int signo)
@ -125,7 +126,7 @@ CheckForShmSyscall(void)
/* ========== Management of shared memory segments ========== */ /* ========== Management of shared memory segments ========== */
#ifdef MITSHM #ifdef HAS_SHM
#ifdef __linux__ #ifdef __linux__
/* On Linux, shared memory marked as "removed" can still be attached. /* On Linux, shared memory marked as "removed" can still be attached.
@ -146,6 +147,7 @@ static ShmDescPtr ShmList = (ShmDescPtr) NULL;
static ShmDescPtr static ShmDescPtr
shmalloc(unsigned int size) shmalloc(unsigned int size)
{ {
ShmDescPtr pDesc;
int shmid; int shmid;
char *addr; char *addr;
@ -163,7 +165,7 @@ shmalloc(unsigned int size)
if (size < 3500) if (size < 3500)
return (ShmDescPtr) NULL; return (ShmDescPtr) NULL;
ShmDescPtr pDesc = calloc(1, sizeof(ShmDescRec)); pDesc = malloc(sizeof(ShmDescRec));
if (!pDesc) if (!pDesc)
return (ShmDescPtr) NULL; return (ShmDescPtr) NULL;
@ -219,7 +221,7 @@ shmdealloc(ShmDescPtr pDesc)
void void
XF86BigfontFreeFontShm(FontPtr pFont) XF86BigfontFreeFontShm(FontPtr pFont)
{ {
#ifdef MITSHM #ifdef HAS_SHM
ShmDescPtr pDesc; ShmDescPtr pDesc;
/* If during shutdown of the server, XF86BigfontCleanup() has already /* If during shutdown of the server, XF86BigfontCleanup() has already
@ -238,7 +240,7 @@ XF86BigfontFreeFontShm(FontPtr pFont)
void void
XF86BigfontCleanup(void) XF86BigfontCleanup(void)
{ {
#ifdef MITSHM #ifdef HAS_SHM
while (ShmList) while (ShmList)
shmdealloc(ShmList); shmdealloc(ShmList);
#endif #endif
@ -264,19 +266,24 @@ XF86BigfontResetProc(ExtensionEntry * extEntry)
static int static int
ProcXF86BigfontQueryVersion(ClientPtr client) ProcXF86BigfontQueryVersion(ClientPtr client)
{ {
REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq); xXF86BigfontQueryVersionReply reply;
xXF86BigfontQueryVersionReply reply = { REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
reply = (xXF86BigfontQueryVersionReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION, .majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION,
.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION, .minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION,
.uid = geteuid(), .uid = geteuid(),
.gid = getegid(), .gid = getegid(),
#ifdef MITSHM #ifdef HAS_SHM
.signature = signature, .signature = signature,
.capabilities = (client->local && !client->swapped) .capabilities = (client->local && !client->swapped)
? XF86Bigfont_CAP_LocalShm : 0 ? XF86Bigfont_CAP_LocalShm : 0
#else
.signature = 0,
.capabilities = 0
#endif #endif
}; };
if (client->swapped) { if (client->swapped) {
@ -322,7 +329,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
int nCharInfos; int nCharInfos;
int shmid; int shmid;
#ifdef MITSHM #ifdef HAS_SHM
ShmDescPtr pDesc = NULL; ShmDescPtr pDesc = NULL;
#else #else
#define pDesc 0 #define pDesc 0
@ -332,7 +339,9 @@ ProcXF86BigfontQueryFont(ClientPtr client)
CARD16 *pUniqIndex2Index; CARD16 *pUniqIndex2Index;
CARD32 nUniqCharInfos; CARD32 nUniqCharInfos;
/* protocol version is decided based on request packet size */ #if 0
REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
#else
switch (client->req_len) { switch (client->req_len) {
case 2: /* client with version 1.0 libX11 */ case 2: /* client with version 1.0 libX11 */
stuff_flags = (client->local && stuff_flags = (client->local &&
@ -344,7 +353,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
default: default:
return BadLength; return BadLength;
} }
#endif
if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) !=
Success) Success)
return BadFont; /* procotol spec says only error is BadFont */ return BadFont; /* procotol spec says only error is BadFont */
@ -365,7 +374,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
nUniqCharInfos = 0; nUniqCharInfos = 0;
if (nCharInfos > 0) { if (nCharInfos > 0) {
#ifdef MITSHM #ifdef HAS_SHM
if (!badSysCall) if (!badSysCall)
pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex); pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
if (pDesc) { if (pDesc) {
@ -383,10 +392,10 @@ ProcXF86BigfontQueryFont(ClientPtr client)
} }
else { else {
#endif #endif
pCI = calloc(nCharInfos, sizeof(xCharInfo)); pCI = xallocarray(nCharInfos, sizeof(xCharInfo));
if (!pCI) if (!pCI)
return BadAlloc; return BadAlloc;
#ifdef MITSHM #ifdef HAS_SHM
} }
#endif #endif
/* Fill nCharInfos starting at pCI. */ /* Fill nCharInfos starting at pCI. */
@ -418,7 +427,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
} }
} }
} }
#ifdef MITSHM #ifdef HAS_SHM
if (pDesc && !badSysCall) { if (pDesc && !badSysCall) {
*(CARD32 *) (pCI + nCharInfos) = signature; *(CARD32 *) (pCI + nCharInfos) = signature;
if (!xfont2_font_set_private(pFont, FontShmdescIndex, pDesc)) { if (!xfont2_font_set_private(pFont, FontShmdescIndex, pDesc)) {
@ -445,7 +454,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
if (hashModulus > nCharInfos + 1) if (hashModulus > nCharInfos + 1)
hashModulus = nCharInfos + 1; hashModulus = nCharInfos + 1;
tmp = calloc(4 * nCharInfos + 1, sizeof(CARD16)); tmp = xallocarray(4 * nCharInfos + 1, sizeof(CARD16));
if (!tmp) { if (!tmp) {
if (!pDesc) if (!pDesc)
free(pCI); free(pCI);
@ -525,60 +534,60 @@ ProcXF86BigfontQueryFont(ClientPtr client)
{ {
int nfontprops = pFont->info.nprops; int nfontprops = pFont->info.nprops;
int rlength = nfontprops * sizeof(xFontProp) int rlength = sizeof(xXF86BigfontQueryFontReply)
+ nfontprops * sizeof(xFontProp)
+ (nCharInfos > 0 && shmid == -1 + (nCharInfos > 0 && shmid == -1
? nUniqCharInfos * sizeof(xCharInfo) ? nUniqCharInfos * sizeof(xCharInfo)
+ (nCharInfos + 1) / 2 * 2 * sizeof(CARD16) + (nCharInfos + 1) / 2 * 2 * sizeof(CARD16)
: 0); : 0);
xXF86BigfontQueryFontReply *reply = calloc(1, rlength);
char *p;
xXF86BigfontQueryFontReply rep = { if (!reply) {
.type = X_Reply, if (nCharInfos > 0) {
.length = bytes_to_int32(sizeof(xXF86BigfontQueryFontReply) if (shmid == -1)
- sizeof(xGenericReply) + rlength), free(pIndex2UniqIndex);
.sequenceNumber = client->sequence, if (!pDesc)
.minBounds = pFont->info.ink_minbounds, free(pCI);
.maxBounds = pFont->info.ink_maxbounds, }
.minCharOrByte2 = pFont->info.firstCol, return BadAlloc;
.maxCharOrByte2 = pFont->info.lastCol, }
.defaultChar = pFont->info.defaultCh, reply->type = X_Reply;
.nFontProps = pFont->info.nprops, reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
.drawDirection = pFont->info.drawDirection, reply->sequenceNumber = client->sequence;
.minByte1 = pFont->info.firstRow, reply->minBounds = pFont->info.ink_minbounds;
.maxByte1 = pFont->info.lastRow, reply->maxBounds = pFont->info.ink_maxbounds;
.allCharsExist = pFont->info.allExist, reply->minCharOrByte2 = pFont->info.firstCol;
.fontAscent = pFont->info.fontAscent, reply->maxCharOrByte2 = pFont->info.lastCol;
.fontDescent = pFont->info.fontDescent, reply->defaultChar = pFont->info.defaultCh;
.nCharInfos = nCharInfos, reply->nFontProps = pFont->info.nprops;
.nUniqCharInfos = nUniqCharInfos, reply->drawDirection = pFont->info.drawDirection;
.shmid = shmid, 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;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&reply->sequenceNumber);
swapl(&rep.length); swapl(&reply->length);
swapCharInfo(&rep.minBounds); swapCharInfo(&reply->minBounds);
swapCharInfo(&rep.maxBounds); swapCharInfo(&reply->maxBounds);
swaps(&rep.minCharOrByte2); swaps(&reply->minCharOrByte2);
swaps(&rep.maxCharOrByte2); swaps(&reply->maxCharOrByte2);
swaps(&rep.defaultChar); swaps(&reply->defaultChar);
swaps(&rep.nFontProps); swaps(&reply->nFontProps);
swaps(&rep.fontAscent); swaps(&reply->fontAscent);
swaps(&rep.fontDescent); swaps(&reply->fontDescent);
swapl(&rep.nCharInfos); swapl(&reply->nCharInfos);
swapl(&rep.nUniqCharInfos); swapl(&reply->nUniqCharInfos);
swapl(&rep.shmid); swapl(&reply->shmid);
swapl(&rep.shmsegoffset); swapl(&reply->shmsegoffset);
} }
p = (char *) &reply[1];
int rc = Success;
char *buf = calloc(1, rlength);
if (!buf) {
rc = BadAlloc;
goto out;
}
char *p = buf;
{ {
FontPropPtr pFP; FontPropPtr pFP;
xFontProp *prFP; xFontProp *prFP;
@ -614,18 +623,15 @@ ProcXF86BigfontQueryFont(ClientPtr client)
} }
} }
} }
WriteToClient(client, rlength, reply);
WriteToClient(client, sizeof(xXF86BigfontQueryFontReply), &rep); free(reply);
WriteToClient(client, rlength, buf);
free(buf);
out:
if (nCharInfos > 0) { if (nCharInfos > 0) {
if (shmid == -1) if (shmid == -1)
free(pIndex2UniqIndex); free(pIndex2UniqIndex);
if (!pDesc) if (!pDesc)
free(pCI); free(pCI);
} }
return rc; return Success;
} }
} }
@ -647,6 +653,9 @@ ProcXF86BigfontDispatch(ClientPtr client)
static int _X_COLD static int _X_COLD
SProcXF86BigfontQueryVersion(ClientPtr client) SProcXF86BigfontQueryVersion(ClientPtr client)
{ {
REQUEST(xXF86BigfontQueryVersionReq);
swaps(&stuff->length);
return ProcXF86BigfontQueryVersion(client); return ProcXF86BigfontQueryVersion(client);
} }
@ -654,6 +663,8 @@ static int _X_COLD
SProcXF86BigfontQueryFont(ClientPtr client) SProcXF86BigfontQueryFont(ClientPtr client)
{ {
REQUEST(xXF86BigfontQueryFontReq); REQUEST(xXF86BigfontQueryFontReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq); REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
swapl(&stuff->id); swapl(&stuff->id);
return ProcXF86BigfontQueryFont(client); return ProcXF86BigfontQueryFont(client);
@ -683,7 +694,7 @@ XFree86BigfontExtensionInit(void)
ProcXF86BigfontDispatch, ProcXF86BigfontDispatch,
SProcXF86BigfontDispatch, SProcXF86BigfontDispatch,
XF86BigfontResetProc, StandardMinorOpcode)) { XF86BigfontResetProc, StandardMinorOpcode)) {
#ifdef MITSHM #ifdef HAS_SHM
#ifdef MUST_CHECK_FOR_SHM_SYSCALL #ifdef MUST_CHECK_FOR_SHM_SYSCALL
/* /*
* Note: Local-clients will not be optimized without shared memory * Note: Local-clients will not be optimized without shared memory
@ -705,7 +716,7 @@ XFree86BigfontExtensionInit(void)
FontShmdescIndex = xfont2_allocate_font_private_index(); FontShmdescIndex = xfont2_allocate_font_private_index();
#if !defined(CSRG_BASED) #if !defined(CSRG_BASED) && !defined(__CYGWIN__)
pagesize = SHMLBA; pagesize = SHMLBA;
#else #else
#ifdef _SC_PAGESIZE #ifdef _SC_PAGESIZE

View File

@ -2,37 +2,37 @@
Copyright (c) 2002 XFree86 Inc Copyright (c) 2002 XFree86 Inc
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/XResproto.h> #include <assert.h>
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "os/client_priv.h"
#include "miext/extinit_priv.h"
#include "Xext/xace.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "swaprep.h" #include "swaprep.h"
#include "registry.h"
#include <X11/extensions/XResproto.h>
#include "pixmapstr.h" #include "pixmapstr.h"
#include "windowstr.h" #include "windowstr.h"
#include "gcstruct.h" #include "gcstruct.h"
#include "extinit.h"
#include "protocol-versions.h" #include "protocol-versions.h"
#include "client.h"
#include "list.h" #include "list.h"
#include "misc.h" #include "misc.h"
#include <string.h>
#include "hashtable.h" #include "hashtable.h"
#include "picturestr.h" #include "picturestr.h"
#include "compint.h"
Bool noResExtension = FALSE; #ifdef COMPOSITE
#include "compint.h"
#endif
/** @brief Holds fragments of responses for ConstructClientIds. /** @brief Holds fragments of responses for ConstructClientIds.
* *
@ -101,7 +101,7 @@ typedef struct {
static void * static void *
AddFragment(struct xorg_list *frags, int bytes) AddFragment(struct xorg_list *frags, int bytes)
{ {
FragmentList *f = calloc(1, sizeof(FragmentList) + bytes); FragmentList *f = malloc(sizeof(FragmentList) + bytes);
if (!f) { if (!f) {
return NULL; return NULL;
} else { } else {
@ -111,6 +111,21 @@ AddFragment(struct xorg_list *frags, int bytes)
} }
} }
/** @brief Sends all fragments in the list to the client. Does not
free anything.
@param client The client to send the fragments to
@param frags The head of the list of fragments
*/
static void
WriteFragmentsToClient(ClientPtr client, struct xorg_list *frags)
{
FragmentList *it;
xorg_list_for_each_entry(it, frags, l) {
WriteToClient(client, it->bytes, (char*) it + sizeof(*it));
}
}
/** @brief Frees a list of fragments. Does not free() root node. /** @brief Frees a list of fragments. Does not free() root node.
@param frags The head of the list of fragments @param frags The head of the list of fragments
@ -119,12 +134,10 @@ static void
DestroyFragments(struct xorg_list *frags) DestroyFragments(struct xorg_list *frags)
{ {
FragmentList *it, *tmp; FragmentList *it, *tmp;
if (!xorg_list_is_empty(frags)) {
xorg_list_for_each_entry_safe(it, tmp, frags, l) { xorg_list_for_each_entry_safe(it, tmp, frags, l) {
xorg_list_del(&it->l); xorg_list_del(&it->l);
free(it); free(it);
} }
}
} }
/** @brief Constructs a context record for ConstructClientId* functions /** @brief Constructs a context record for ConstructClientId* functions
@ -180,15 +193,16 @@ DestroyConstructResourceBytesCtx(ConstructResourceBytesCtx *ctx)
static int static int
ProcXResQueryVersion(ClientPtr client) ProcXResQueryVersion(ClientPtr client)
{ {
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
xXResQueryVersionReply rep = { xXResQueryVersionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.server_major = SERVER_XRES_MAJOR_VERSION, .server_major = SERVER_XRES_MAJOR_VERSION,
.server_minor = SERVER_XRES_MINOR_VERSION .server_minor = SERVER_XRES_MINOR_VERSION
}; };
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
swapl(&rep.length); swapl(&rep.length);
@ -202,23 +216,24 @@ ProcXResQueryVersion(ClientPtr client)
static int static int
ProcXResQueryClients(ClientPtr client) ProcXResQueryClients(ClientPtr client)
{ {
/* REQUEST(xXResQueryClientsReq); */
xXResQueryClientsReply rep;
int *current_clients;
int i, num_clients;
REQUEST_SIZE_MATCH(xXResQueryClientsReq); REQUEST_SIZE_MATCH(xXResQueryClientsReq);
int *current_clients = calloc(currentMaxClients, sizeof(int)); current_clients = xallocarray(currentMaxClients, sizeof(int));
if (!current_clients)
return BadAlloc;
int num_clients = 0; num_clients = 0;
for (int i = 0; i < currentMaxClients; i++) { for (i = 0; i < currentMaxClients; i++) {
if (clients[i]) { if (clients[i]) {
if (XaceHookClientAccess(client, clients[i], DixReadAccess) == Success) {
current_clients[num_clients] = i; current_clients[num_clients] = i;
num_clients++; num_clients++;
} }
} }
}
xXResQueryClientsReply rep = { rep = (xXResQueryClientsReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(num_clients * sz_xXResClient), .length = bytes_to_int32(num_clients * sz_xXResClient),
@ -229,31 +244,25 @@ ProcXResQueryClients(ClientPtr client)
swapl(&rep.length); swapl(&rep.length);
swapl(&rep.num_clients); swapl(&rep.num_clients);
} }
WriteToClient(client, sizeof(xXResQueryClientsReply), &rep);
xXResClient *scratch = NULL;
if (num_clients) { if (num_clients) {
scratch = calloc(sizeof(xXResClient), num_clients); xXResClient scratch;
if (!scratch) {
free(current_clients);
return BadAlloc;
}
for (int i = 0; i < num_clients; i++) { for (i = 0; i < num_clients; i++) {
scratch[i].resource_base = clients[current_clients[i]]->clientAsMask; scratch.resource_base = clients[current_clients[i]]->clientAsMask;
scratch[i].resource_mask = RESOURCE_ID_MASK; scratch.resource_mask = RESOURCE_ID_MASK;
if (client->swapped) { if (client->swapped) {
swapl(&scratch[i].resource_base); swapl(&scratch.resource_base);
swapl(&scratch[i].resource_mask); swapl(&scratch.resource_mask);
} }
WriteToClient(client, sz_xXResClient, &scratch);
} }
} }
WriteToClient(client, sizeof(xXResQueryClientsReply), &rep);
WriteToClient(client, sizeof(xXResClient) * num_clients, scratch);
free(current_clients); free(current_clients);
free(scratch);
return Success; return Success;
} }
@ -287,30 +296,31 @@ static int
ProcXResQueryClientResources(ClientPtr client) ProcXResQueryClientResources(ClientPtr client)
{ {
REQUEST(xXResQueryClientResourcesReq); REQUEST(xXResQueryClientResourcesReq);
xXResQueryClientResourcesReply rep;
int i, clientID, num_types;
int *counts;
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq); REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
ClientPtr resClient = dixClientForXID(stuff->xid); clientID = CLIENT_ID(stuff->xid);
if ((!resClient) || if ((clientID >= currentMaxClients) || !clients[clientID]) {
(XaceHookClientAccess(client, resClient, DixReadAccess)
!= Success)) {
client->errorValue = stuff->xid; client->errorValue = stuff->xid;
return BadValue; return BadValue;
} }
int *counts = calloc(lastResourceType + 1, sizeof(int)); counts = calloc(lastResourceType + 1, sizeof(int));
if (!counts)
return BadAlloc;
FindAllClientResources(resClient, ResFindAllRes, counts); FindAllClientResources(clients[clientID], ResFindAllRes, counts);
int num_types = 0; num_types = 0;
for (int i = 0; i <= lastResourceType; i++) {
for (i = 0; i <= lastResourceType; i++) {
if (counts[i]) if (counts[i])
num_types++; num_types++;
} }
xXResQueryClientResourcesReply rep = { rep = (xXResQueryClientResourcesReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(num_types * sz_xXResType), .length = bytes_to_int32(num_types * sz_xXResType),
@ -322,27 +332,28 @@ ProcXResQueryClientResources(ClientPtr client)
swapl(&rep.num_types); swapl(&rep.num_types);
} }
xXResType *scratch = calloc(sizeof(xXResType), num_types); WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
if (!scratch) {
free(counts);
return BadAlloc;
}
for (int i = 0; i < num_types; i++) { if (num_types) {
scratch[i].resource_type = resourceTypeAtom(i + 1); xXResType scratch;
scratch[i].count = counts[i];
for (i = 0; i < lastResourceType; i++) {
if (!counts[i])
continue;
scratch.resource_type = resourceTypeAtom(i + 1);
scratch.count = counts[i];
if (client->swapped) { if (client->swapped) {
swapl(&scratch[i].resource_type); swapl(&scratch.resource_type);
swapl(&scratch[i].count); swapl(&scratch.count);
}
WriteToClient(client, sz_xXResType, &scratch);
} }
} }
free(counts); free(counts);
WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
WriteToClient(client, num_types * sizeof(xXResType), scratch);
free(scratch);
return Success; return Success;
} }
@ -361,26 +372,33 @@ static int
ProcXResQueryClientPixmapBytes(ClientPtr client) ProcXResQueryClientPixmapBytes(ClientPtr client)
{ {
REQUEST(xXResQueryClientPixmapBytesReq); REQUEST(xXResQueryClientPixmapBytesReq);
xXResQueryClientPixmapBytesReply rep;
int clientID;
unsigned long bytes;
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq); REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
ClientPtr owner = dixClientForXID(stuff->xid); clientID = CLIENT_ID(stuff->xid);
if ((!owner) ||
(XaceHookClientAccess(client, owner, DixReadAccess) if ((clientID >= currentMaxClients) || !clients[clientID]) {
!= Success)) {
client->errorValue = stuff->xid; client->errorValue = stuff->xid;
return BadValue; return BadValue;
} }
unsigned long bytes = 0; bytes = 0;
FindAllClientResources(owner, ResFindResourcePixmaps,
FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
(void *) (&bytes)); (void *) (&bytes));
xXResQueryClientPixmapBytesReply rep = { rep = (xXResQueryClientPixmapBytesReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.bytes = bytes, .bytes = bytes,
#ifdef _XSERVER64 #ifdef _XSERVER64
.bytes_overflow = bytes >> 32 .bytes_overflow = bytes >> 32
#else
.bytes_overflow = 0
#endif #endif
}; };
if (client->swapped) { if (client->swapped) {
@ -439,10 +457,9 @@ static Bool
ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask, ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
ConstructClientIdCtx *ctx) ConstructClientIdCtx *ctx)
{ {
xXResClientIdValue rep = { xXResClientIdValue rep;
.spec.client = client->clientAsMask,
};
rep.spec.client = client->clientAsMask;
if (client->swapped) { if (client->swapped) {
swapl (&rep.spec.client); swapl (&rep.spec.client);
} }
@ -454,6 +471,7 @@ ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
} }
rep.spec.mask = X_XResClientXIDMask; rep.spec.mask = X_XResClientXIDMask;
rep.length = 0;
if (sendClient->swapped) { if (sendClient->swapped) {
swapl (&rep.spec.mask); swapl (&rep.spec.mask);
/* swapl (&rep.length, n); - not required for rep.length = 0 */ /* swapl (&rep.length, n); - not required for rep.length = 0 */
@ -482,6 +500,9 @@ ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
if (sendClient->swapped) { if (sendClient->swapped) {
swapl (&rep.spec.mask); swapl (&rep.spec.mask);
swapl (&rep.length); swapl (&rep.length);
}
if (sendClient->swapped) {
swapl (value); swapl (value);
} }
memcpy(ptr, &rep, sizeof(rep)); memcpy(ptr, &rep, sizeof(rep));
@ -510,13 +531,13 @@ ConstructClientIds(ClientPtr client,
int numSpecs, xXResClientIdSpec* specs, int numSpecs, xXResClientIdSpec* specs,
ConstructClientIdCtx *ctx) ConstructClientIdCtx *ctx)
{ {
for (int specIdx = 0; specIdx < numSpecs; ++specIdx) { int specIdx;
for (specIdx = 0; specIdx < numSpecs; ++specIdx) {
if (specs[specIdx].client == 0) { if (specs[specIdx].client == 0) {
int c; int c;
for (c = 0; c < currentMaxClients; ++c) { for (c = 0; c < currentMaxClients; ++c) {
if (clients[c] && if (clients[c]) {
(XaceHookClientAccess(client, clients[c], DixReadAccess)
== Success)) {
if (!ConstructClientIdValue(client, clients[c], if (!ConstructClientIdValue(client, clients[c],
specs[specIdx].mask, ctx)) { specs[specIdx].mask, ctx)) {
return BadAlloc; return BadAlloc;
@ -524,11 +545,10 @@ ConstructClientIds(ClientPtr client,
} }
} }
} else { } else {
ClientPtr owner = dixClientForXID(specs[specIdx].client); int clientID = CLIENT_ID(specs[specIdx].client);
if (owner &&
(XaceHookClientAccess(client, owner, DixReadAccess) if ((clientID < currentMaxClients) && clients[clientID]) {
== Success)) { if (!ConstructClientIdValue(client, clients[clientID],
if (!ConstructClientIdValue(client, owner,
specs[specIdx].mask, ctx)) { specs[specIdx].mask, ctx)) {
return BadAlloc; return BadAlloc;
} }
@ -553,6 +573,7 @@ ProcXResQueryClientIds (ClientPtr client)
REQUEST(xXResQueryClientIdsReq); REQUEST(xXResQueryClientIdsReq);
xXResClientIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff)); xXResClientIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
int rc;
ConstructClientIdCtx ctx; ConstructClientIdCtx ctx;
InitConstructClientIdCtx(&ctx); InitConstructClientIdCtx(&ctx);
@ -561,22 +582,9 @@ ProcXResQueryClientIds (ClientPtr client)
REQUEST_FIXED_SIZE(xXResQueryClientIdsReq, REQUEST_FIXED_SIZE(xXResQueryClientIdsReq,
stuff->numSpecs * sizeof(specs[0])); stuff->numSpecs * sizeof(specs[0]));
int rc = ConstructClientIds(client, stuff->numSpecs, specs, &ctx); rc = ConstructClientIds(client, stuff->numSpecs, specs, &ctx);
if (rc == Success) { if (rc == Success) {
char *buf = calloc(1, ctx.resultBytes);
if (!buf) {
rc = BadAlloc;
goto out;
}
char *walk = buf;
FragmentList *it;
xorg_list_for_each_entry(it, &ctx.response, l) {
memcpy(walk, FRAGMENT_DATA(it), it->bytes);
walk += it->bytes;
}
xXResQueryClientIdsReply rep = { xXResQueryClientIdsReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
@ -584,6 +592,8 @@ ProcXResQueryClientIds (ClientPtr client)
.numIds = ctx.numIds .numIds = ctx.numIds
}; };
assert((ctx.resultBytes & 3) == 0);
if (client->swapped) { if (client->swapped) {
swaps (&rep.sequenceNumber); swaps (&rep.sequenceNumber);
swapl (&rep.length); swapl (&rep.length);
@ -591,11 +601,9 @@ ProcXResQueryClientIds (ClientPtr client)
} }
WriteToClient(client, sizeof(rep), &rep); WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, ctx.resultBytes, buf); WriteFragmentsToClient(client, &ctx.response);
free(buf);
} }
out:
DestroyConstructClientIdCtx(&ctx); DestroyConstructClientIdCtx(&ctx);
return rc; return rc;
@ -632,11 +640,12 @@ static void
SwapXResQueryResourceBytes(struct xorg_list *response) SwapXResQueryResourceBytes(struct xorg_list *response)
{ {
struct xorg_list *it = response->next; struct xorg_list *it = response->next;
int c;
while (it != response) { while (it != response) {
xXResResourceSizeValue *value = FRAGMENT_DATA(it); xXResResourceSizeValue *value = FRAGMENT_DATA(it);
it = it->next; it = it->next;
for (int c = 0; c < value->numCrossReferences; ++c) { for (c = 0; c < value->numCrossReferences; ++c) {
xXResResourceSizeSpec *spec = FRAGMENT_DATA(it); xXResResourceSizeSpec *spec = FRAGMENT_DATA(it);
SwapXResResourceSizeSpec(spec); SwapXResResourceSizeSpec(spec);
it = it->next; it = it->next;
@ -839,7 +848,8 @@ static void
ConstructClientResourceBytes(ClientPtr aboutClient, ConstructClientResourceBytes(ClientPtr aboutClient,
ConstructResourceBytesCtx *ctx) ConstructResourceBytesCtx *ctx)
{ {
for (int specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) { int specIdx;
for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
xXResResourceIdSpec* spec = ctx->specs + specIdx; xXResResourceIdSpec* spec = ctx->specs + specIdx;
if (spec->resource) { if (spec->resource) {
/* these specs are handled elsewhere */ /* these specs are handled elsewhere */
@ -871,11 +881,15 @@ ConstructClientResourceBytes(ClientPtr aboutClient,
static void static void
ConstructResourceBytesByResource(XID aboutClient, ConstructResourceBytesCtx *ctx) ConstructResourceBytesByResource(XID aboutClient, ConstructResourceBytesCtx *ctx)
{ {
for (int specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) { int specIdx;
for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
xXResResourceIdSpec *spec = ctx->specs + specIdx; xXResResourceIdSpec *spec = ctx->specs + specIdx;
if (spec->resource) { if (spec->resource) {
ClientPtr client = dixClientForXID(spec->resource); int cid = CLIENT_ID(spec->resource);
if (client && (aboutClient == None || aboutClient == client->index)) { if (cid < currentMaxClients &&
(aboutClient == None || cid == aboutClient)) {
ClientPtr client = clients[cid];
if (client) {
ctx->curSpec = spec; ctx->curSpec = spec;
FindAllClientResources(client, FindAllClientResources(client,
AddResourceSizeValueByResource, AddResourceSizeValueByResource,
@ -883,6 +897,7 @@ ConstructResourceBytesByResource(XID aboutClient, ConstructResourceBytesCtx *ctx
} }
} }
} }
}
} }
/** @brief Build the resource size response for the given client /** @brief Build the resource size response for the given client
@ -898,12 +913,16 @@ ConstructResourceBytes(XID aboutClient,
ConstructResourceBytesCtx *ctx) ConstructResourceBytesCtx *ctx)
{ {
if (aboutClient) { if (aboutClient) {
ClientPtr client = dixClientForXID(aboutClient); int clientIdx = CLIENT_ID(aboutClient);
if (!client) { ClientPtr client = NullClient;
if ((clientIdx >= currentMaxClients) || !clients[clientIdx]) {
ctx->sendClient->errorValue = aboutClient; ctx->sendClient->errorValue = aboutClient;
return BadValue; return BadValue;
} }
client = clients[clientIdx];
ConstructClientResourceBytes(client, ctx); ConstructClientResourceBytes(client, ctx);
ConstructResourceBytesByResource(aboutClient, ctx); ConstructResourceBytesByResource(aboutClient, ctx);
} else { } else {
@ -931,9 +950,11 @@ static int
ProcXResQueryResourceBytes (ClientPtr client) ProcXResQueryResourceBytes (ClientPtr client)
{ {
REQUEST(xXResQueryResourceBytesReq); REQUEST(xXResQueryResourceBytesReq);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
int rc;
ConstructResourceBytesCtx ctx; ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0])) if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
return BadLength; return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq, REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
@ -946,7 +967,7 @@ ProcXResQueryResourceBytes (ClientPtr client)
return BadAlloc; return BadAlloc;
} }
int rc = ConstructResourceBytes(stuff->client, &ctx); rc = ConstructResourceBytes(stuff->client, &ctx);
if (rc == Success) { if (rc == Success) {
xXResQueryResourceBytesReply rep = { xXResQueryResourceBytesReply rep = {
@ -964,24 +985,10 @@ ProcXResQueryResourceBytes (ClientPtr client)
SwapXResQueryResourceBytes(&ctx.response); SwapXResQueryResourceBytes(&ctx.response);
} }
char *buf = calloc(1, ctx.resultBytes);
if (!buf) {
rc = BadAlloc;
goto out;
}
char *walk = buf;
FragmentList *it;
xorg_list_for_each_entry(it, &ctx.response, l) {
memcpy(walk, FRAGMENT_DATA(it), it->bytes);
walk += it->bytes;
}
WriteToClient(client, sizeof(rep), &rep); WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, ctx.resultBytes, buf); WriteFragmentsToClient(client, &ctx.response);
free(buf);
} }
out:
DestroyConstructResourceBytesCtx(&ctx); DestroyConstructResourceBytesCtx(&ctx);
return rc; return rc;
@ -1071,6 +1078,7 @@ static int _X_COLD
SProcResDispatch (ClientPtr client) SProcResDispatch (ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
swaps(&stuff->length);
switch (stuff->data) { switch (stuff->data) {
case X_XResQueryVersion: case X_XResQueryVersion:

View File

@ -136,12 +136,4 @@ typedef struct {
CARD32 pad6; CARD32 pad6;
} SELinuxListItemsReply; } SELinuxListItemsReply;
#ifdef XSELINUX
#define SELINUX_MODE_DEFAULT 0
#define SELINUX_MODE_DISABLED 1
#define SELINUX_MODE_PERMISSIVE 2
#define SELINUX_MODE_ENFORCING 3
extern int selinuxEnforcingState;
#endif
#endif /* _XSELINUX_H */ #endif /* _XSELINUX_H */

View File

@ -17,17 +17,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************/ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "dix/dix_priv.h" #include "selection.h"
#include "dix/property_priv.h"
#include "dix/selection_priv.h"
#include "miext/extinit_priv.h"
#include "inputstr.h" #include "inputstr.h"
#include "windowstr.h" #include "windowstr.h"
#include "propertyst.h" #include "propertyst.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "extinit.h"
#include "xselinuxint.h" #include "xselinuxint.h"
#define CTX_DEV offsetof(SELinuxSubjectRec, dev_create_sid) #define CTX_DEV offsetof(SELinuxSubjectRec, dev_create_sid)
@ -45,9 +44,6 @@ typedef struct {
CARD32 id; CARD32 id;
} SELinuxListItemRec; } SELinuxListItemRec;
Bool noSELinuxExtension = FALSE;
int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
/* /*
* Extension Dispatch * Extension Dispatch
*/ */
@ -55,7 +51,7 @@ int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
static char * static char *
SELinuxCopyContext(char *ptr, unsigned len) SELinuxCopyContext(char *ptr, unsigned len)
{ {
char *copy = calloc(1, len + 1); char *copy = malloc(len + 1);
if (!copy) if (!copy)
return NULL; return NULL;
@ -70,6 +66,7 @@ ProcSELinuxQueryVersion(ClientPtr client)
SELinuxQueryVersionReply rep = { SELinuxQueryVersionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.server_major = SELINUX_MAJOR_VERSION, .server_major = SELINUX_MAJOR_VERSION,
.server_minor = SELINUX_MINOR_VERSION .server_minor = SELINUX_MINOR_VERSION
}; };
@ -86,6 +83,7 @@ ProcSELinuxQueryVersion(ClientPtr client)
static int static int
SELinuxSendContextReply(ClientPtr client, security_id_t sid) SELinuxSendContextReply(ClientPtr client, security_id_t sid)
{ {
SELinuxGetContextReply rep;
char *ctx = NULL; char *ctx = NULL;
int len = 0; int len = 0;
@ -95,7 +93,7 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
len = strlen(ctx) + 1; len = strlen(ctx) + 1;
} }
SELinuxGetContextReply rep = { rep = (SELinuxGetContextReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(len), .length = bytes_to_int32(len),
@ -298,7 +296,7 @@ ProcSELinuxGetClientContext(ClientPtr client)
REQUEST(SELinuxGetContextReq); REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq); REQUEST_SIZE_MATCH(SELinuxGetContextReq);
rc = dixLookupResourceOwner(&target, stuff->id, client, DixGetAttrAccess); rc = dixLookupClient(&target, stuff->id, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
@ -313,8 +311,6 @@ SELinuxPopulateItem(SELinuxListItemRec * i, PrivateRec ** privPtr, CARD32 id,
SELinuxObjectRec *obj = dixLookupPrivate(privPtr, objectKey); SELinuxObjectRec *obj = dixLookupPrivate(privPtr, objectKey);
SELinuxObjectRec *data = dixLookupPrivate(privPtr, dataKey); SELinuxObjectRec *data = dixLookupPrivate(privPtr, dataKey);
if (!i)
return BadValue;
if (avc_sid_to_context_raw(obj->sid, &i->octx) < 0) if (avc_sid_to_context_raw(obj->sid, &i->octx) < 0)
return BadValue; return BadValue;
if (avc_sid_to_context_raw(data->sid, &i->dctx) < 0) if (avc_sid_to_context_raw(data->sid, &i->dctx) < 0)
@ -333,9 +329,6 @@ SELinuxFreeItems(SELinuxListItemRec * items, int count)
{ {
int k; int k;
if (!items)
return;
for (k = 0; k < count; k++) { for (k = 0; k < count; k++) {
freecon(items[k].octx); freecon(items[k].octx);
freecon(items[k].dctx); freecon(items[k].dctx);
@ -347,15 +340,16 @@ static int
SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items, SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
int size, int count) int size, int count)
{ {
int rc = BadAlloc, k, pos = 0; int rc, k, pos = 0;
CARD32 *buf = calloc(size, sizeof(CARD32)); SELinuxListItemsReply rep;
CARD32 *buf;
buf = calloc(size, sizeof(CARD32));
if (size && !buf) { if (size && !buf) {
rc = BadAlloc;
goto out; goto out;
} }
if (!buf) // silence analyzer warning
goto sendreply;
/* Fill in the buffer */ /* Fill in the buffer */
for (k = 0; k < count; k++) { for (k = 0; k < count; k++) {
buf[pos] = items[k].id; buf[pos] = items[k].id;
@ -379,9 +373,8 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
pos += items[k].dctx_len; pos += items[k].dctx_len;
} }
sendreply: ;
/* Send reply to client */ /* Send reply to client */
SELinuxListItemsReply rep = { rep = (SELinuxListItemsReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = size, .length = size,
@ -423,7 +416,7 @@ ProcSELinuxListProperties(ClientPtr client)
/* Count the number of properties and allocate items */ /* Count the number of properties and allocate items */
count = 0; count = 0;
for (pProp = pWin->properties; pProp; pProp = pProp->next) for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
count++; count++;
items = calloc(count, sizeof(SELinuxListItemRec)); items = calloc(count, sizeof(SELinuxListItemRec));
if (count && !items) if (count && !items)
@ -432,7 +425,7 @@ ProcSELinuxListProperties(ClientPtr client)
/* Fill in the items and calculate size */ /* Fill in the items and calculate size */
i = 0; i = 0;
size = 0; size = 0;
for (pProp = pWin->properties; pProp; pProp = pProp->next) { for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) {
id = pProp->propertyName; id = pProp->propertyName;
rc = SELinuxPopulateItem(items + i, &pProp->devPrivates, id, &size); rc = SELinuxPopulateItem(items + i, &pProp->devPrivates, id, &size);
if (rc != Success) { if (rc != Success) {
@ -628,6 +621,8 @@ SProcSELinuxDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
swaps(&stuff->length);
switch (stuff->data) { switch (stuff->data) {
case X_SELinuxQueryVersion: case X_SELinuxQueryVersion:
return SProcSELinuxQueryVersion(client); return SProcSELinuxQueryVersion(client);

View File

@ -22,28 +22,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* All rights reserved. * All rights reserved.
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <libaudit.h> #include <libaudit.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xfuncproto.h> #include "selection.h"
#include "dix/input_priv.h"
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "dix/selection_priv.h"
#include "os/client_priv.h"
#include "inputstr.h" #include "inputstr.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "windowstr.h" #include "windowstr.h"
#include "propertyst.h" #include "propertyst.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "xacestr.h" #include "xacestr.h"
#include "client.h"
#define _XSELINUX_NEED_FLASK_MAP #define _XSELINUX_NEED_FLASK_MAP
#include "xselinuxint.h" #include "xselinuxint.h"
@ -202,7 +199,7 @@ SELinuxLabelInitial(void)
/* Do the default colormap */ /* Do the default colormap */
dixLookupResourceByType(&unused, screenInfo.screens[i]->defColormap, dixLookupResourceByType(&unused, screenInfo.screens[i]->defColormap,
X11_RESTYPE_COLORMAP, serverClient, DixCreateAccess); RT_COLORMAP, serverClient, DixCreateAccess);
} }
} }
@ -632,10 +629,7 @@ SELinuxResource(CallbackListPtr *pcbl, void *unused, void *calldata)
if (offset < 0) { if (offset < 0) {
/* No: use the SID of the owning client */ /* No: use the SID of the owning client */
class = SECCLASS_X_RESOURCE; class = SECCLASS_X_RESOURCE;
ClientPtr owner = dixClientForXID(rec->id); privatePtr = &clients[CLIENT_ID(rec->id)]->devPrivates;
if (!owner)
return;
privatePtr = &owner->devPrivates;
obj = dixLookupPrivate(privatePtr, objectKey); obj = dixLookupPrivate(privatePtr, objectKey);
} }
else { else {
@ -668,7 +662,7 @@ SELinuxResource(CallbackListPtr *pcbl, void *unused, void *calldata)
rec->status = rc; rec->status = rc;
/* Perform the background none check on windows */ /* Perform the background none check on windows */
if (access_mode & DixCreateAccess && rec->rtype == X11_RESTYPE_WINDOW) { if (access_mode & DixCreateAccess && rec->rtype == RT_WINDOW) {
rc = SELinuxDoCheck(subj, obj, class, DixBlendAccess, &auditdata); rc = SELinuxDoCheck(subj, obj, class, DixBlendAccess, &auditdata);
if (rc != Success) if (rc != Success)
((WindowPtr) rec->res)->forcedBG = TRUE; ((WindowPtr) rec->res)->forcedBG = TRUE;
@ -770,13 +764,13 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
SELinuxObjectRec *obj; SELinuxObjectRec *obj;
WindowPtr pWin; WindowPtr pWin;
if (rec->type != X11_RESTYPE_WINDOW) if (rec->type != RT_WINDOW)
return; return;
if (rec->state != ResourceStateAdding) if (rec->state != ResourceStateAdding)
return; return;
pWin = (WindowPtr) rec->value; pWin = (WindowPtr) rec->value;
subj = dixLookupPrivate(&dixClientForWindow(pWin)->devPrivates, subjectKey); subj = dixLookupPrivate(&wClient(pWin)->devPrivates, subjectKey);
if (subj->sid) { if (subj->sid) {
char *ctx; char *ctx;

View File

@ -17,12 +17,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************/ ********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <selinux/label.h> #include <selinux/label.h>
#include "dix/registry_priv.h" #include "registry.h"
#include "xselinuxint.h" #include "xselinuxint.h"
/* selection and property atom cache */ /* selection and property atom cache */
@ -321,13 +322,13 @@ SELinuxTypeToClass(RESTYPE type)
if (type & RC_DRAWABLE) if (type & RC_DRAWABLE)
class = SECCLASS_X_DRAWABLE; class = SECCLASS_X_DRAWABLE;
else if (type == X11_RESTYPE_GC) else if (type == RT_GC)
class = SECCLASS_X_GC; class = SECCLASS_X_GC;
else if (type == X11_RESTYPE_FONT) else if (type == RT_FONT)
class = SECCLASS_X_FONT; class = SECCLASS_X_FONT;
else if (type == X11_RESTYPE_CURSOR) else if (type == RT_CURSOR)
class = SECCLASS_X_CURSOR; class = SECCLASS_X_CURSOR;
else if (type == X11_RESTYPE_COLORMAP) else if (type == RT_COLORMAP)
class = SECCLASS_X_COLORMAP; class = SECCLASS_X_COLORMAP;
else { else {
/* Need to do a string lookup */ /* Need to do a string lookup */

View File

@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dixstruct.h" #include "dixstruct.h"
#include "privates.h" #include "privates.h"
#include "resource.h" #include "resource.h"
#include "registry.h"
#include "inputstr.h" #include "inputstr.h"
#include "xselinux.h" #include "xselinux.h"

View File

@ -26,26 +26,13 @@
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/extensions/xtestproto.h>
#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 "miext/extinit_priv.h"
#include "os/client_priv.h"
#include "os/osdep.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
@ -53,16 +40,22 @@
#include "windowstr.h" #include "windowstr.h"
#include "inputstr.h" #include "inputstr.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "dixevents.h"
#include "sleepuntil.h" #include "sleepuntil.h"
#include "mi.h"
#include "xkbsrv.h" #include "xkbsrv.h"
#include "xkbstr.h" #include "xkbstr.h"
#include <X11/extensions/xtestproto.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exglobals.h" #include "exglobals.h"
#include "mipointer.h" #include "mipointer.h"
#include "xserver-properties.h" #include "xserver-properties.h"
#include "exevents.h"
#include "eventstr.h" #include "eventstr.h"
#include "inpututils.h" #include "inpututils.h"
Bool noTestExtensions = FALSE; #include "extinit.h"
/* XTest events are sent during request processing and may be interrupted by /* XTest events are sent during request processing and may be interrupted by
* a SIGIO. We need a separate event list to avoid events overwriting each * a SIGIO. We need a separate event list to avoid events overwriting each
@ -82,6 +75,11 @@ static InternalEvent *xtest_evlist;
*/ */
DeviceIntPtr xtestpointer, xtestkeyboard; DeviceIntPtr xtestpointer, xtestkeyboard;
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
static int XTestSwapFakeInput(ClientPtr /* client */ , static int XTestSwapFakeInput(ClientPtr /* client */ ,
xReq * /* req */ xReq * /* req */
); );
@ -128,10 +126,10 @@ ProcXTestCompareCursor(ClientPtr client)
if (stuff->cursor == None) if (stuff->cursor == None)
pCursor = NullCursor; pCursor = NullCursor;
else if (stuff->cursor == XTestCurrentCursor) else if (stuff->cursor == XTestCurrentCursor)
pCursor = InputDevGetSpriteCursor(ptr); pCursor = GetSpriteCursor(ptr);
else { else {
rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor, rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor,
X11_RESTYPE_CURSOR, client, DixReadAccess); RT_CURSOR, client, DixReadAccess);
if (rc != Success) { if (rc != Success) {
client->errorValue = stuff->cursor; client->errorValue = stuff->cursor;
return rc; return rc;
@ -196,7 +194,7 @@ ProcXTestFakeInput(ClientPtr client)
int flags = 0; int flags = 0;
int need_ptr_update = 1; int need_ptr_update = 1;
nev = (client->req_len << 2) - sizeof(xReq); nev = (stuff->length << 2) - sizeof(xReq);
if ((nev % sizeof(xEvent)) || !nev) if ((nev % sizeof(xEvent)) || !nev)
return BadLength; return BadLength;
nev /= sizeof(xEvent); nev /= sizeof(xEvent);
@ -372,6 +370,7 @@ ProcXTestFakeInput(ClientPtr client)
/* swap the request back so we can simply re-execute it */ /* swap the request back so we can simply re-execute it */
if (client->swapped) { if (client->swapped) {
(void) XTestSwapFakeInput(client, (xReq *) stuff); (void) XTestSwapFakeInput(client, (xReq *) stuff);
swaps(&stuff->length);
} }
ResetCurrentRequest(client); ResetCurrentRequest(client);
client->sequence--; client->sequence--;
@ -381,7 +380,7 @@ ProcXTestFakeInput(ClientPtr client)
switch (type) { switch (type) {
case KeyPress: case KeyPress:
case KeyRelease: case KeyRelease:
if ((!dev) || (!dev->key)) if (!dev->key)
return BadDevice; return BadDevice;
if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code || if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code ||
@ -393,7 +392,7 @@ ProcXTestFakeInput(ClientPtr client)
need_ptr_update = 0; need_ptr_update = 0;
break; break;
case MotionNotify: case MotionNotify:
if (!dev || !dev->valuator) if (!dev->valuator)
return BadDevice; return BadDevice;
if (!(extension || ev->u.keyButtonPointer.root == None)) { if (!(extension || ev->u.keyButtonPointer.root == None)) {
@ -424,7 +423,7 @@ ProcXTestFakeInput(ClientPtr client)
break; break;
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
if (!dev || !dev->button) if (!dev->button)
return BadDevice; return BadDevice;
if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) { if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) {
@ -438,7 +437,7 @@ ProcXTestFakeInput(ClientPtr client)
valuator_mask_set_range(&mask, firstValuator, numValuators, valuators); valuator_mask_set_range(&mask, firstValuator, numValuators, valuators);
if (dev && dev->sendEventsProc) if (dev->sendEventsProc)
(*dev->sendEventsProc) (dev, type, ev->u.u.detail, flags, &mask); (*dev->sendEventsProc) (dev, type, ev->u.u.detail, flags, &mask);
if (need_ptr_update) if (need_ptr_update)
@ -485,6 +484,8 @@ static int _X_COLD
SProcXTestGetVersion(ClientPtr client) SProcXTestGetVersion(ClientPtr client)
{ {
REQUEST(xXTestGetVersionReq); REQUEST(xXTestGetVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestGetVersionReq); REQUEST_SIZE_MATCH(xXTestGetVersionReq);
swaps(&stuff->minorVersion); swaps(&stuff->minorVersion);
return ProcXTestGetVersion(client); return ProcXTestGetVersion(client);
@ -494,6 +495,8 @@ static int _X_COLD
SProcXTestCompareCursor(ClientPtr client) SProcXTestCompareCursor(ClientPtr client)
{ {
REQUEST(xXTestCompareCursorReq); REQUEST(xXTestCompareCursorReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq); REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
swapl(&stuff->window); swapl(&stuff->window);
swapl(&stuff->cursor); swapl(&stuff->cursor);
@ -508,7 +511,7 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
xEvent sev; xEvent sev;
EventSwapPtr proc; EventSwapPtr proc;
nev = ((client->req_len << 2) - sizeof(xReq)) / sizeof(xEvent); nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) { for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) {
int evtype = ev->u.u.type & 0177; int evtype = ev->u.u.type & 0177;
/* Swap event */ /* Swap event */
@ -531,12 +534,23 @@ SProcXTestFakeInput(ClientPtr client)
REQUEST(xReq); REQUEST(xReq);
swaps(&stuff->length);
n = XTestSwapFakeInput(client, stuff); n = XTestSwapFakeInput(client, stuff);
if (n != Success) if (n != Success)
return n; return n;
return ProcXTestFakeInput(client); return ProcXTestFakeInput(client);
} }
static int _X_COLD
SProcXTestGrabControl(ClientPtr client)
{
REQUEST(xXTestGrabControlReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
return ProcXTestGrabControl(client);
}
static int _X_COLD static int _X_COLD
SProcXTestDispatch(ClientPtr client) SProcXTestDispatch(ClientPtr client)
{ {
@ -549,7 +563,7 @@ SProcXTestDispatch(ClientPtr client)
case X_XTestFakeInput: case X_XTestFakeInput:
return SProcXTestFakeInput(client); return SProcXTestFakeInput(client);
case X_XTestGrabControl: case X_XTestGrabControl:
return ProcXTestGrabControl(client); return SProcXTestGrabControl(client);
default: default:
return BadRequest; return BadRequest;
} }
@ -647,7 +661,7 @@ AllocXTestDevice(ClientPtr client, const char *name,
BOOL BOOL
IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master) IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master)
{ {
if (InputDevIsMaster(dev)) if (IsMaster(dev))
return FALSE; return FALSE;
/* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest /* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest

View File

@ -21,20 +21,14 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE. SOFTWARE.
******************************************************************/ ******************************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <string.h> #include <string.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
#include "dix/dix_priv.h"
#include "Xext/xvdix_priv.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h" #include "misc.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "windowstr.h" #include "windowstr.h"
@ -43,6 +37,10 @@ SOFTWARE.
#include "dixstruct.h" #include "dixstruct.h"
#include "resource.h" #include "resource.h"
#include "opaque.h" #include "opaque.h"
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
#include "xvdix.h"
#ifdef MITSHM #ifdef MITSHM
#include <X11/extensions/shmproto.h> #include <X11/extensions/shmproto.h>
#include "shmint.h" #include "shmint.h"
@ -50,9 +48,12 @@ SOFTWARE.
#include "xvdisp.h" #include "xvdisp.h"
#ifdef XINERAMA #ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
unsigned long XvXRTPort; unsigned long XvXRTPort;
#endif /* XINERAMA */ #endif
static int static int
SWriteQueryExtensionReply(ClientPtr client, xvQueryExtensionReply * rep) SWriteQueryExtensionReply(ClientPtr client, xvQueryExtensionReply * rep)
@ -320,6 +321,7 @@ ProcXvQueryAdaptors(ClientPtr client)
{ {
xvFormat format; xvFormat format;
xvAdaptorInfo ainfo; xvAdaptorInfo ainfo;
xvQueryAdaptorsReply rep;
int totalSize, na, nf, rc; int totalSize, na, nf, rc;
int nameSize; int nameSize;
XvAdaptorPtr pa; XvAdaptorPtr pa;
@ -335,20 +337,27 @@ ProcXvQueryAdaptors(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
xvQueryAdaptorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
};
pScreen = pWin->drawable.pScreen; pScreen = pWin->drawable.pScreen;
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
XvGetScreenKey()); XvGetScreenKey());
if (!pxvs) { if (!pxvs) {
rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.num_adaptors = 0
};
_WriteQueryAdaptorsReply(client, &rep); _WriteQueryAdaptorsReply(client, &rep);
return Success; return Success;
} }
rep.num_adaptors = pxvs->nAdaptors; rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_adaptors = pxvs->nAdaptors
};
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */ /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
@ -402,6 +411,7 @@ static int
ProcXvQueryEncodings(ClientPtr client) ProcXvQueryEncodings(ClientPtr client)
{ {
xvEncodingInfo einfo; xvEncodingInfo einfo;
xvQueryEncodingsReply rep;
int totalSize; int totalSize;
int nameSize; int nameSize;
XvPortPtr pPort; XvPortPtr pPort;
@ -413,6 +423,12 @@ ProcXvQueryEncodings(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
rep = (xvQueryEncodingsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings
};
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */ /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
ne = pPort->pAdaptor->nEncodings; ne = pPort->pAdaptor->nEncodings;
@ -423,12 +439,7 @@ ProcXvQueryEncodings(ClientPtr client)
pe++; pe++;
} }
xvQueryEncodingsReply rep = { rep.length = bytes_to_int32(totalSize);
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings,
.length = bytes_to_int32(totalSize),
};
_WriteQueryEncodingsReply(client, &rep); _WriteQueryEncodingsReply(client, &rep);
@ -450,7 +461,7 @@ ProcXvQueryEncodings(ClientPtr client)
} }
static int static int
SingleXvPutVideo(ClientPtr client) ProcXvPutVideo(ClientPtr client)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
XvPortPtr pPort; XvPortPtr pPort;
@ -479,20 +490,8 @@ SingleXvPutVideo(ClientPtr client)
stuff->drw_w, stuff->drw_h); stuff->drw_w, stuff->drw_h);
} }
static int XineramaXvPutVideo(ClientPtr client);
static int static int
ProcXvPutVideo(ClientPtr client) ProcXvPutStill(ClientPtr client)
{
#ifdef XINERAMA
if (xvUseXinerama)
return XineramaXvPutVideo(client);
#endif
return SingleXvPutVideo(client);
}
static int
SingleXvPutStill(ClientPtr client)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
XvPortPtr pPort; XvPortPtr pPort;
@ -521,18 +520,6 @@ SingleXvPutStill(ClientPtr client)
stuff->drw_w, stuff->drw_h); stuff->drw_w, stuff->drw_h);
} }
static int XineramaXvPutStill(ClientPtr client);
static int
ProcXvPutStill(ClientPtr client)
{
#ifdef XINERAMA
if (xvUseXinerama)
return XineramaXvPutStill(client);
#endif
return SingleXvPutStill(client);
}
static int static int
ProcXvGetVideo(ClientPtr client) ProcXvGetVideo(ClientPtr client)
{ {
@ -628,6 +615,7 @@ ProcXvGrabPort(ClientPtr client)
{ {
int result, status; int result, status;
XvPortPtr pPort; XvPortPtr pPort;
xvGrabPortReply rep;
REQUEST(xvGrabPortReq); REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq);
@ -639,9 +627,10 @@ ProcXvGrabPort(ClientPtr client)
if (status != Success) { if (status != Success) {
return status; return status;
} }
xvGrabPortReply rep = { rep = (xvGrabPortReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.result = result .result = result
}; };
@ -664,7 +653,7 @@ ProcXvUngrabPort(ClientPtr client)
} }
static int static int
SingleXvStopVideo(ClientPtr client) ProcXvStopVideo(ClientPtr client)
{ {
int ret; int ret;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -682,20 +671,8 @@ SingleXvStopVideo(ClientPtr client)
return XvdiStopVideo(client, pPort, pDraw); return XvdiStopVideo(client, pPort, pDraw);
} }
static int XineramaXvStopVideo(ClientPtr client);
static int static int
ProcXvStopVideo(ClientPtr client) ProcXvSetPortAttribute(ClientPtr client)
{
#ifdef XINERAMA
if (xvUseXinerama)
return XineramaXvStopVideo(client);
#endif
return SingleXvStopVideo(client);
}
static int
SingleXvSetPortAttribute(ClientPtr client)
{ {
int status; int status;
XvPortPtr pPort; XvPortPtr pPort;
@ -721,24 +698,13 @@ SingleXvSetPortAttribute(ClientPtr client)
return status; return status;
} }
static int XineramaXvSetPortAttribute(ClientPtr client);
static int
ProcXvSetPortAttribute(ClientPtr client)
{
#ifdef XINERAMA
if (xvUseXinerama)
return XineramaXvSetPortAttribute(client);
#endif
return SingleXvSetPortAttribute(client);
}
static int static int
ProcXvGetPortAttribute(ClientPtr client) ProcXvGetPortAttribute(ClientPtr client)
{ {
INT32 value; INT32 value;
int status; int status;
XvPortPtr pPort; XvPortPtr pPort;
xvGetPortAttributeReply rep;
REQUEST(xvGetPortAttributeReq); REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq); REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
@ -756,9 +722,10 @@ ProcXvGetPortAttribute(ClientPtr client)
return status; return status;
} }
xvGetPortAttributeReply rep = { rep = (xvGetPortAttributeReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.value = value .value = value
}; };
@ -772,6 +739,7 @@ ProcXvQueryBestSize(ClientPtr client)
{ {
unsigned int actual_width, actual_height; unsigned int actual_width, actual_height;
XvPortPtr pPort; XvPortPtr pPort;
xvQueryBestSizeReply rep;
REQUEST(xvQueryBestSizeReq); REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq); REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
@ -783,9 +751,10 @@ ProcXvQueryBestSize(ClientPtr client)
stuff->drw_w, stuff->drw_h, stuff->drw_w, stuff->drw_h,
&actual_width, &actual_height); &actual_width, &actual_height);
xvQueryBestSizeReply rep = { rep = (xvQueryBestSizeReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.actual_width = actual_width, .actual_width = actual_width,
.actual_height = actual_height .actual_height = actual_height
}; };
@ -801,6 +770,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
int size, i; int size, i;
XvPortPtr pPort; XvPortPtr pPort;
XvAttributePtr pAtt; XvAttributePtr pAtt;
xvQueryPortAttributesReply rep;
xvAttributeInfo Info; xvAttributeInfo Info;
REQUEST(xvQueryPortAttributesReq); REQUEST(xvQueryPortAttributesReq);
@ -808,10 +778,11 @@ ProcXvQueryPortAttributes(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
xvQueryPortAttributesReply rep = { rep = (xvQueryPortAttributesReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.num_attributes = pPort->pAdaptor->nAttributes, .num_attributes = pPort->pAdaptor->nAttributes,
.text_size = 0
}; };
for (i = 0, pAtt = pPort->pAdaptor->pAttributes; for (i = 0, pAtt = pPort->pAdaptor->pAttributes;
@ -842,7 +813,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
} }
static int static int
SingleXvPutImage(ClientPtr client) ProcXvPutImage(ClientPtr client)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
XvPortPtr pPort; XvPortPtr pPort;
@ -898,23 +869,10 @@ SingleXvPutImage(ClientPtr client)
stuff->width, stuff->height); stuff->width, stuff->height);
} }
static int
XineramaXvPutImage(ClientPtr client);
static int
ProcXvPutImage(ClientPtr client)
{
#ifdef XINERAMA
if (xvUseXinerama)
return XineramaXvPutImage(client);
#endif
return SingleXvPutImage(client);
}
#ifdef MITSHM #ifdef MITSHM
static int static int
SingleXvShmPutImage(ClientPtr client) ProcXvShmPutImage(ClientPtr client)
{ {
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -987,24 +945,13 @@ SingleXvShmPutImage(ClientPtr client)
return status; return status;
} }
#else /* !MITSHM */
static int XineramaXvShmPutImage(ClientPtr client);
#endif /* MITSHM */
static int static int
ProcXvShmPutImage(ClientPtr client) ProcXvShmPutImage(ClientPtr client)
{ {
#ifdef MITSHM
#ifdef XINERAMA
if (xvUseXinerama)
return XineramaXvShmPutImage(client);
#endif
return SingleXvShmPutImage(client);
#else
return BadImplementation; return BadImplementation;
#endif
} }
#endif
#ifdef XvMCExtension #ifdef XvMCExtension
#include "xvmcext.h" #include "xvmcext.h"
@ -1018,8 +965,9 @@ ProcXvQueryImageAttributes(ClientPtr client)
CARD16 width, height; CARD16 width, height;
XvImagePtr pImage = NULL; XvImagePtr pImage = NULL;
XvPortPtr pPort; XvPortPtr pPort;
int32_t *offsets; int *offsets;
int32_t *pitches; int *pitches;
int planeLength;
REQUEST(xvQueryImageAttributesReq); REQUEST(xvQueryImageAttributesReq);
@ -1044,9 +992,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
num_planes = pImage->num_planes; num_planes = pImage->num_planes;
// allocating for `offsets` as well as `pitches` in one block if (!(offsets = malloc(num_planes << 3)))
// both having CARD32 * num_planes (actually int32_t put into CARD32)
if (!(offsets = calloc(num_planes*2, sizeof(CARD32))))
return BadAlloc; return BadAlloc;
pitches = offsets + num_planes; pitches = offsets + num_planes;
@ -1060,7 +1006,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
rep = (xvQueryImageAttributesReply) { rep = (xvQueryImageAttributesReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = num_planes * 2, // in 32bit units .length = planeLength = num_planes << 1,
.num_planes = num_planes, .num_planes = num_planes,
.width = width, .width = width,
.height = height, .height = height,
@ -1069,8 +1015,8 @@ ProcXvQueryImageAttributes(ClientPtr client)
_WriteQueryImageAttributesReply(client, &rep); _WriteQueryImageAttributesReply(client, &rep);
if (client->swapped) if (client->swapped)
SwapLongs((CARD32 *) offsets, rep.length); SwapLongs((CARD32 *) offsets, planeLength);
WriteToClient(client, rep.length * sizeof(CARD32), offsets); WriteToClient(client, planeLength << 2, offsets);
free(offsets); free(offsets);
@ -1083,6 +1029,7 @@ ProcXvListImageFormats(ClientPtr client)
XvPortPtr pPort; XvPortPtr pPort;
XvImagePtr pImage; XvImagePtr pImage;
int i; int i;
xvListImageFormatsReply rep;
xvImageFormatInfo info; xvImageFormatInfo info;
REQUEST(xvListImageFormatsReq); REQUEST(xvListImageFormatsReq);
@ -1091,7 +1038,7 @@ ProcXvListImageFormats(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
xvListImageFormatsReply rep = { rep = (xvListImageFormatsReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.num_formats = pPort->pAdaptor->nImages, .num_formats = pPort->pAdaptor->nImages,
@ -1132,6 +1079,26 @@ ProcXvListImageFormats(ClientPtr client)
return Success; return Success;
} }
static int (*XvProcVector[xvNumRequests]) (ClientPtr) = {
ProcXvQueryExtension,
ProcXvQueryAdaptors,
ProcXvQueryEncodings,
ProcXvGrabPort,
ProcXvUngrabPort,
ProcXvPutVideo,
ProcXvPutStill,
ProcXvGetVideo,
ProcXvGetStill,
ProcXvStopVideo,
ProcXvSelectVideoNotify,
ProcXvSelectPortNotify,
ProcXvQueryBestSize,
ProcXvSetPortAttribute,
ProcXvGetPortAttribute,
ProcXvQueryPortAttributes,
ProcXvListImageFormats,
ProcXvQueryImageAttributes, ProcXvPutImage, ProcXvShmPutImage,};
int int
ProcXvDispatch(ClientPtr client) ProcXvDispatch(ClientPtr client)
{ {
@ -1139,61 +1106,32 @@ ProcXvDispatch(ClientPtr client)
UpdateCurrentTime(); UpdateCurrentTime();
switch (stuff->data) { if (stuff->data >= xvNumRequests) {
case xv_QueryExtension:
return ProcXvQueryExtension(client);
case xv_QueryAdaptors:
return ProcXvQueryAdaptors(client);
case xv_QueryEncodings:
return ProcXvQueryEncodings(client);
case xv_GrabPort:
return ProcXvGrabPort(client);
case xv_UngrabPort:
return ProcXvUngrabPort(client);
case xv_PutVideo:
return ProcXvPutVideo(client);
case xv_PutStill:
return ProcXvPutStill(client);
case xv_GetVideo:
return ProcXvGetVideo(client);
case xv_GetStill:
return ProcXvGetStill(client);
case xv_StopVideo:
return ProcXvStopVideo(client);
case xv_SelectVideoNotify:
return ProcXvSelectVideoNotify(client);
case xv_SelectPortNotify:
return ProcXvSelectPortNotify(client);
case xv_QueryBestSize:
return ProcXvQueryBestSize(client);
case xv_SetPortAttribute:
return ProcXvSetPortAttribute(client);
case xv_GetPortAttribute:
return ProcXvGetPortAttribute(client);
case xv_QueryPortAttributes:
return ProcXvQueryPortAttributes(client);
case xv_ListImageFormats:
return ProcXvListImageFormats(client);
case xv_QueryImageAttributes:
return ProcXvQueryImageAttributes(client);
case xv_PutImage:
return ProcXvPutImage(client);
case xv_ShmPutImage:
return ProcXvShmPutImage(client);
default:
return BadRequest; return BadRequest;
} }
return XvProcVector[stuff->data] (client);
} }
/* Swapped Procs */ /* 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 static int _X_COLD
SProcXvQueryAdaptors(ClientPtr client) SProcXvQueryAdaptors(ClientPtr client)
{ {
REQUEST(xvQueryAdaptorsReq); REQUEST(xvQueryAdaptorsReq);
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
swaps(&stuff->length);
swapl(&stuff->window); swapl(&stuff->window);
return ProcXvQueryAdaptors(client); return XvProcVector[xv_QueryAdaptors] (client);
} }
static int _X_COLD static int _X_COLD
@ -1201,8 +1139,9 @@ SProcXvQueryEncodings(ClientPtr client)
{ {
REQUEST(xvQueryEncodingsReq); REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq); REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
return ProcXvQueryEncodings(client); return XvProcVector[xv_QueryEncodings] (client);
} }
static int _X_COLD static int _X_COLD
@ -1210,9 +1149,10 @@ SProcXvGrabPort(ClientPtr client)
{ {
REQUEST(xvGrabPortReq); REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->time); swapl(&stuff->time);
return ProcXvGrabPort(client); return XvProcVector[xv_GrabPort] (client);
} }
static int _X_COLD static int _X_COLD
@ -1220,9 +1160,10 @@ SProcXvUngrabPort(ClientPtr client)
{ {
REQUEST(xvUngrabPortReq); REQUEST(xvUngrabPortReq);
REQUEST_SIZE_MATCH(xvUngrabPortReq); REQUEST_SIZE_MATCH(xvUngrabPortReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->time); swapl(&stuff->time);
return ProcXvUngrabPort(client); return XvProcVector[xv_UngrabPort] (client);
} }
static int _X_COLD static int _X_COLD
@ -1230,6 +1171,7 @@ SProcXvPutVideo(ClientPtr client)
{ {
REQUEST(xvPutVideoReq); REQUEST(xvPutVideoReq);
REQUEST_SIZE_MATCH(xvPutVideoReq); REQUEST_SIZE_MATCH(xvPutVideoReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->gc); swapl(&stuff->gc);
@ -1241,7 +1183,7 @@ SProcXvPutVideo(ClientPtr client)
swaps(&stuff->drw_y); swaps(&stuff->drw_y);
swaps(&stuff->drw_w); swaps(&stuff->drw_w);
swaps(&stuff->drw_h); swaps(&stuff->drw_h);
return ProcXvPutVideo(client); return XvProcVector[xv_PutVideo] (client);
} }
static int _X_COLD static int _X_COLD
@ -1249,6 +1191,7 @@ SProcXvPutStill(ClientPtr client)
{ {
REQUEST(xvPutStillReq); REQUEST(xvPutStillReq);
REQUEST_SIZE_MATCH(xvPutStillReq); REQUEST_SIZE_MATCH(xvPutStillReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->gc); swapl(&stuff->gc);
@ -1260,7 +1203,7 @@ SProcXvPutStill(ClientPtr client)
swaps(&stuff->drw_y); swaps(&stuff->drw_y);
swaps(&stuff->drw_w); swaps(&stuff->drw_w);
swaps(&stuff->drw_h); swaps(&stuff->drw_h);
return ProcXvPutStill(client); return XvProcVector[xv_PutStill] (client);
} }
static int _X_COLD static int _X_COLD
@ -1268,6 +1211,7 @@ SProcXvGetVideo(ClientPtr client)
{ {
REQUEST(xvGetVideoReq); REQUEST(xvGetVideoReq);
REQUEST_SIZE_MATCH(xvGetVideoReq); REQUEST_SIZE_MATCH(xvGetVideoReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->gc); swapl(&stuff->gc);
@ -1279,7 +1223,7 @@ SProcXvGetVideo(ClientPtr client)
swaps(&stuff->drw_y); swaps(&stuff->drw_y);
swaps(&stuff->drw_w); swaps(&stuff->drw_w);
swaps(&stuff->drw_h); swaps(&stuff->drw_h);
return ProcXvGetVideo(client); return XvProcVector[xv_GetVideo] (client);
} }
static int _X_COLD static int _X_COLD
@ -1287,6 +1231,7 @@ SProcXvGetStill(ClientPtr client)
{ {
REQUEST(xvGetStillReq); REQUEST(xvGetStillReq);
REQUEST_SIZE_MATCH(xvGetStillReq); REQUEST_SIZE_MATCH(xvGetStillReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->gc); swapl(&stuff->gc);
@ -1298,7 +1243,7 @@ SProcXvGetStill(ClientPtr client)
swaps(&stuff->drw_y); swaps(&stuff->drw_y);
swaps(&stuff->drw_w); swaps(&stuff->drw_w);
swaps(&stuff->drw_h); swaps(&stuff->drw_h);
return ProcXvGetStill(client); return XvProcVector[xv_GetStill] (client);
} }
static int _X_COLD static int _X_COLD
@ -1306,6 +1251,7 @@ SProcXvPutImage(ClientPtr client)
{ {
REQUEST(xvPutImageReq); REQUEST(xvPutImageReq);
REQUEST_AT_LEAST_SIZE(xvPutImageReq); REQUEST_AT_LEAST_SIZE(xvPutImageReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->gc); swapl(&stuff->gc);
@ -1320,7 +1266,7 @@ SProcXvPutImage(ClientPtr client)
swaps(&stuff->drw_h); swaps(&stuff->drw_h);
swaps(&stuff->width); swaps(&stuff->width);
swaps(&stuff->height); swaps(&stuff->height);
return ProcXvPutImage(client); return XvProcVector[xv_PutImage] (client);
} }
#ifdef MITSHM #ifdef MITSHM
@ -1329,6 +1275,7 @@ SProcXvShmPutImage(ClientPtr client)
{ {
REQUEST(xvShmPutImageReq); REQUEST(xvShmPutImageReq);
REQUEST_SIZE_MATCH(xvShmPutImageReq); REQUEST_SIZE_MATCH(xvShmPutImageReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->drawable); swapl(&stuff->drawable);
swapl(&stuff->gc); swapl(&stuff->gc);
@ -1345,7 +1292,7 @@ SProcXvShmPutImage(ClientPtr client)
swaps(&stuff->drw_h); swaps(&stuff->drw_h);
swaps(&stuff->width); swaps(&stuff->width);
swaps(&stuff->height); swaps(&stuff->height);
return ProcXvShmPutImage(client); return XvProcVector[xv_ShmPutImage] (client);
} }
#else /* MITSHM */ #else /* MITSHM */
#define SProcXvShmPutImage ProcXvShmPutImage #define SProcXvShmPutImage ProcXvShmPutImage
@ -1356,8 +1303,9 @@ SProcXvSelectVideoNotify(ClientPtr client)
{ {
REQUEST(xvSelectVideoNotifyReq); REQUEST(xvSelectVideoNotifyReq);
REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
swaps(&stuff->length);
swapl(&stuff->drawable); swapl(&stuff->drawable);
return ProcXvSelectVideoNotify(client); return XvProcVector[xv_SelectVideoNotify] (client);
} }
static int _X_COLD static int _X_COLD
@ -1365,8 +1313,9 @@ SProcXvSelectPortNotify(ClientPtr client)
{ {
REQUEST(xvSelectPortNotifyReq); REQUEST(xvSelectPortNotifyReq);
REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
return ProcXvSelectPortNotify(client); return XvProcVector[xv_SelectPortNotify] (client);
} }
static int _X_COLD static int _X_COLD
@ -1374,9 +1323,10 @@ SProcXvStopVideo(ClientPtr client)
{ {
REQUEST(xvStopVideoReq); REQUEST(xvStopVideoReq);
REQUEST_SIZE_MATCH(xvStopVideoReq); REQUEST_SIZE_MATCH(xvStopVideoReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->drawable); swapl(&stuff->drawable);
return ProcXvStopVideo(client); return XvProcVector[xv_StopVideo] (client);
} }
static int _X_COLD static int _X_COLD
@ -1384,10 +1334,11 @@ SProcXvSetPortAttribute(ClientPtr client)
{ {
REQUEST(xvSetPortAttributeReq); REQUEST(xvSetPortAttributeReq);
REQUEST_SIZE_MATCH(xvSetPortAttributeReq); REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->attribute); swapl(&stuff->attribute);
swapl(&stuff->value); swapl(&stuff->value);
return ProcXvSetPortAttribute(client); return XvProcVector[xv_SetPortAttribute] (client);
} }
static int _X_COLD static int _X_COLD
@ -1395,9 +1346,10 @@ SProcXvGetPortAttribute(ClientPtr client)
{ {
REQUEST(xvGetPortAttributeReq); REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq); REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->attribute); swapl(&stuff->attribute);
return ProcXvGetPortAttribute(client); return XvProcVector[xv_GetPortAttribute] (client);
} }
static int _X_COLD static int _X_COLD
@ -1405,12 +1357,13 @@ SProcXvQueryBestSize(ClientPtr client)
{ {
REQUEST(xvQueryBestSizeReq); REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq); REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swaps(&stuff->vid_w); swaps(&stuff->vid_w);
swaps(&stuff->vid_h); swaps(&stuff->vid_h);
swaps(&stuff->drw_w); swaps(&stuff->drw_w);
swaps(&stuff->drw_h); swaps(&stuff->drw_h);
return ProcXvQueryBestSize(client); return XvProcVector[xv_QueryBestSize] (client);
} }
static int _X_COLD static int _X_COLD
@ -1418,8 +1371,9 @@ SProcXvQueryPortAttributes(ClientPtr client)
{ {
REQUEST(xvQueryPortAttributesReq); REQUEST(xvQueryPortAttributesReq);
REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
return ProcXvQueryPortAttributes(client); return XvProcVector[xv_QueryPortAttributes] (client);
} }
static int _X_COLD static int _X_COLD
@ -1427,11 +1381,12 @@ SProcXvQueryImageAttributes(ClientPtr client)
{ {
REQUEST(xvQueryImageAttributesReq); REQUEST(xvQueryImageAttributesReq);
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
swapl(&stuff->id); swapl(&stuff->id);
swaps(&stuff->width); swaps(&stuff->width);
swaps(&stuff->height); swaps(&stuff->height);
return ProcXvQueryImageAttributes(client); return XvProcVector[xv_QueryImageAttributes] (client);
} }
static int _X_COLD static int _X_COLD
@ -1439,10 +1394,31 @@ SProcXvListImageFormats(ClientPtr client)
{ {
REQUEST(xvListImageFormatsReq); REQUEST(xvListImageFormatsReq);
REQUEST_SIZE_MATCH(xvListImageFormatsReq); REQUEST_SIZE_MATCH(xvListImageFormatsReq);
swaps(&stuff->length);
swapl(&stuff->port); swapl(&stuff->port);
return ProcXvListImageFormats(client); return XvProcVector[xv_ListImageFormats] (client);
} }
static int (*SXvProcVector[xvNumRequests]) (ClientPtr) = {
SProcXvQueryExtension,
SProcXvQueryAdaptors,
SProcXvQueryEncodings,
SProcXvGrabPort,
SProcXvUngrabPort,
SProcXvPutVideo,
SProcXvPutStill,
SProcXvGetVideo,
SProcXvGetStill,
SProcXvStopVideo,
SProcXvSelectVideoNotify,
SProcXvSelectPortNotify,
SProcXvQueryBestSize,
SProcXvSetPortAttribute,
SProcXvGetPortAttribute,
SProcXvQueryPortAttributes,
SProcXvListImageFormats,
SProcXvQueryImageAttributes, SProcXvPutImage, SProcXvShmPutImage,};
int _X_COLD int _X_COLD
SProcXvDispatch(ClientPtr client) SProcXvDispatch(ClientPtr client)
{ {
@ -1450,53 +1426,14 @@ SProcXvDispatch(ClientPtr client)
UpdateCurrentTime(); UpdateCurrentTime();
switch (stuff->data) { if (stuff->data >= xvNumRequests) {
case xv_QueryExtension:
return ProcXvQueryExtension(client);
case xv_QueryAdaptors:
return SProcXvQueryAdaptors(client);
case xv_QueryEncodings:
return SProcXvQueryEncodings(client);
case xv_GrabPort:
return SProcXvGrabPort(client);
case xv_UngrabPort:
return SProcXvUngrabPort(client);
case xv_PutVideo:
return SProcXvPutVideo(client);
case xv_PutStill:
return SProcXvPutStill(client);
case xv_GetVideo:
return SProcXvGetVideo(client);
case xv_GetStill:
return SProcXvGetStill(client);
case xv_StopVideo:
return SProcXvStopVideo(client);
case xv_SelectVideoNotify:
return SProcXvSelectVideoNotify(client);
case xv_SelectPortNotify:
return SProcXvSelectPortNotify(client);
case xv_QueryBestSize:
return SProcXvQueryBestSize(client);
case xv_SetPortAttribute:
return SProcXvSetPortAttribute(client);
case xv_GetPortAttribute:
return SProcXvGetPortAttribute(client);
case xv_QueryPortAttributes:
return SProcXvQueryPortAttributes(client);
case xv_ListImageFormats:
return SProcXvListImageFormats(client);
case xv_QueryImageAttributes:
return SProcXvQueryImageAttributes(client);
case xv_PutImage:
return SProcXvPutImage(client);
case xv_ShmPutImage:
return SProcXvShmPutImage(client);
default:
return BadRequest; return BadRequest;
} }
return SXvProcVector[stuff->data] (client);
} }
#ifdef XINERAMA #ifdef PANORAMIX
static int static int
XineramaXvStopVideo(ClientPtr client) XineramaXvStopVideo(ClientPtr client)
{ {
@ -1520,7 +1457,7 @@ XineramaXvStopVideo(ClientPtr client)
if (port->info[i].id) { if (port->info[i].id) {
stuff->drawable = draw->info[i].id; stuff->drawable = draw->info[i].id;
stuff->port = port->info[i].id; stuff->port = port->info[i].id;
result = SingleXvStopVideo(client); result = ProcXvStopVideo(client);
} }
} }
@ -1544,7 +1481,7 @@ XineramaXvSetPortAttribute(ClientPtr client)
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS_BACKWARD(i) {
if (port->info[i].id) { if (port->info[i].id) {
stuff->port = port->info[i].id; stuff->port = port->info[i].id;
result = SingleXvSetPortAttribute(client); result = ProcXvSetPortAttribute(client);
} }
} }
return result; return result;
@ -1597,14 +1534,14 @@ XineramaXvShmPutImage(ClientPtr client)
} }
stuff->send_event = (send_event && !i) ? 1 : 0; stuff->send_event = (send_event && !i) ? 1 : 0;
result = SingleXvShmPutImage(client); result = ProcXvShmPutImage(client);
} }
} }
return result; return result;
} }
#else #else
#define XineramaXvShmPutImage ProcXvShmPutImage #define XineramaXvShmPutImage ProcXvShmPutImage
#endif /* MITSHM */ #endif
static int static int
XineramaXvPutImage(ClientPtr client) XineramaXvPutImage(ClientPtr client)
@ -1648,7 +1585,7 @@ XineramaXvPutImage(ClientPtr client)
stuff->drw_y -= screenInfo.screens[i]->y; stuff->drw_y -= screenInfo.screens[i]->y;
} }
result = SingleXvPutImage(client); result = ProcXvPutImage(client);
} }
} }
return result; return result;
@ -1696,7 +1633,7 @@ XineramaXvPutVideo(ClientPtr client)
stuff->drw_y -= screenInfo.screens[i]->y; stuff->drw_y -= screenInfo.screens[i]->y;
} }
result = SingleXvPutVideo(client); result = ProcXvPutVideo(client);
} }
} }
return result; return result;
@ -1744,7 +1681,7 @@ XineramaXvPutStill(ClientPtr client)
stuff->drw_y -= screenInfo.screens[i]->y; stuff->drw_y -= screenInfo.screens[i]->y;
} }
result = SingleXvPutStill(client); result = ProcXvPutStill(client);
} }
} }
return result; return result;
@ -1836,12 +1773,12 @@ XineramifyXv(void)
/* now create a resource for each port */ /* now create a resource for each port */
for (j = 0; j < refAdapt->nPorts; j++) { for (j = 0; j < refAdapt->nPorts; j++) {
PanoramiXRes *port = calloc(1, sizeof(PanoramiXRes)); PanoramiXRes *port = malloc(sizeof(PanoramiXRes));
if (!port) if (!port)
break; break;
FOR_NSCREENS_BACKWARD(k) { FOR_NSCREENS(k) {
if (MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j)) if (MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
port->info[k].id = MatchingAdaptors[k]->base_id + j; port->info[k].id = MatchingAdaptors[k]->base_id + j;
else else
@ -1851,6 +1788,25 @@ XineramifyXv(void)
} }
} }
xvUseXinerama = 1; /* munge the dispatch vector */
XvProcVector[xv_PutVideo] = XineramaXvPutVideo;
XvProcVector[xv_PutStill] = XineramaXvPutStill;
XvProcVector[xv_StopVideo] = XineramaXvStopVideo;
XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute;
XvProcVector[xv_PutImage] = XineramaXvPutImage;
XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage;
}
#endif /* PANORAMIX */
void
XvResetProcVector(void)
{
#ifdef PANORAMIX
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 */

View File

@ -1,7 +1,2 @@
#ifndef XSERVER_XVDISP_H
#define XSERVER_XVDISP_H
extern void XineramifyXv(void); extern void XineramifyXv(void);
extern int xvUseXinerama; extern void XvResetProcVector(void);
#endif /* XSERVER_XVDISP_H */

View File

@ -55,6 +55,21 @@ SOFTWARE.
#include "scrnintstr.h" #include "scrnintstr.h"
#include <X11/extensions/Xvproto.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 { typedef struct {
int numerator; int numerator;
int denominator; int denominator;
@ -70,7 +85,18 @@ typedef struct {
ClientPtr client; ClientPtr client;
} XvGrabRec, *XvGrabPtr; } XvGrabRec, *XvGrabPtr;
typedef struct _XvPortNotifyRec *XvPortNotifyPtr; 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 { typedef struct {
int id; int id;
@ -169,17 +195,68 @@ typedef struct _XvPortRec {
DevUnion devPriv; DevUnion devPriv;
} XvPortRec, *XvPortPtr; } 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 { typedef struct {
int version, revision; int version, revision;
int nAdaptors; int nAdaptors;
XvAdaptorPtr pAdaptors; XvAdaptorPtr pAdaptors;
void *_dummy1; // required in place of a removed field for ABI compatibility DestroyWindowProcPtr DestroyWindow;
void *_dummy2; // required in place of a removed field for ABI compatibility DestroyPixmapProcPtr DestroyPixmap;
void *_dummy3; // required in place of a removed field for ABI compatibility CloseScreenProcPtr CloseScreen;
} XvScreenRec, *XvScreenPtr; } 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 int XvScreenInit(ScreenPtr);
extern _X_EXPORT DevPrivateKey XvGetScreenKey(void); extern _X_EXPORT DevPrivateKey XvGetScreenKey(void);
extern _X_EXPORT unsigned long XvGetRTPort(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 */ #endif /* XVDIX_H */

View File

@ -1,86 +0,0 @@
/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#ifndef _XORG_XVDIX_PRIV_H
#define _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 */

View File

@ -73,20 +73,14 @@ SOFTWARE.
** **
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <string.h> #include <string.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
#include "dix/screen_hooks_priv.h"
#include "miext/extinit_priv.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "Xext/xvdix_priv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "scrnintstr.h" #include "scrnintstr.h"
@ -94,46 +88,41 @@ SOFTWARE.
#include "pixmapstr.h" #include "pixmapstr.h"
#include "gcstruct.h" #include "gcstruct.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "extinit.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "resource.h" #include "resource.h"
#include "opaque.h" #include "opaque.h"
#include "input.h" #include "input.h"
#define GLOBAL
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
#include "xvdix.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#include "xvdisp.h" #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; static DevPrivateKeyRec XvScreenKeyRec;
Bool noXvExtension = FALSE;
#define XvScreenKey (&XvScreenKeyRec) #define XvScreenKey (&XvScreenKeyRec)
static unsigned long XvExtensionGeneration = 0; unsigned long XvExtensionGeneration = 0;
static unsigned long XvScreenGeneration = 0; unsigned long XvScreenGeneration = 0;
static unsigned long XvResourceGeneration = 0; unsigned long XvResourceGeneration = 0;
int XvReqCode; int XvReqCode;
static int XvEventBase; int XvEventBase;
int XvErrorBase; int XvErrorBase;
int xvUseXinerama = 0;
RESTYPE XvRTPort; RESTYPE XvRTPort;
static RESTYPE XvRTEncoding; RESTYPE XvRTEncoding;
static RESTYPE XvRTGrab; RESTYPE XvRTGrab;
static RESTYPE XvRTVideoNotify; RESTYPE XvRTVideoNotify;
static RESTYPE XvRTVideoNotifyList; RESTYPE XvRTVideoNotifyList;
static RESTYPE XvRTPortNotify; RESTYPE XvRTPortNotify;
/* EXTERNAL */ /* EXTERNAL */
@ -141,7 +130,9 @@ static void WriteSwappedVideoNotifyEvent(xvEvent *, xvEvent *);
static void WriteSwappedPortNotifyEvent(xvEvent *, xvEvent *); static void WriteSwappedPortNotifyEvent(xvEvent *, xvEvent *);
static Bool CreateResourceTypes(void); static Bool CreateResourceTypes(void);
static void XvScreenClose(CallbackListPtr *pcbl, ScreenPtr, void *arg); static Bool XvCloseScreen(ScreenPtr);
static Bool XvDestroyPixmap(PixmapPtr);
static Bool XvDestroyWindow(WindowPtr);
static void XvResetProc(ExtensionEntry *); static void XvResetProc(ExtensionEntry *);
static int XvdiDestroyGrab(void *, XID); static int XvdiDestroyGrab(void *, XID);
static int XvdiDestroyEncoding(void *, XID); static int XvdiDestroyEncoding(void *, XID);
@ -150,7 +141,6 @@ static int XvdiDestroyPortNotify(void *, XID);
static int XvdiDestroyVideoNotifyList(void *, XID); static int XvdiDestroyVideoNotifyList(void *, XID);
static int XvdiDestroyPort(void *, XID); static int XvdiDestroyPort(void *, XID);
static int XvdiSendVideoNotify(XvPortPtr, DrawablePtr, int); static int XvdiSendVideoNotify(XvPortPtr, DrawablePtr, int);
static void XvStopAdaptors(DrawablePtr pDrawable);
/* /*
** XvExtensionInit ** XvExtensionInit
@ -173,9 +163,9 @@ XvExtensionInit(void)
ErrorF("XvExtensionInit: Unable to allocate resource types\n"); ErrorF("XvExtensionInit: Unable to allocate resource types\n");
return; return;
} }
#ifdef XINERAMA #ifdef PANORAMIX
XineramaRegisterConnectionBlockCallback(XineramifyXv); XineramaRegisterConnectionBlockCallback(XineramifyXv);
#endif /* XINERAMA */ #endif
XvScreenGeneration = serverGeneration; XvScreenGeneration = serverGeneration;
} }
@ -256,27 +246,19 @@ CreateResourceTypes(void)
} }
static void XvWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin)
{
XvStopAdaptors(&pWin->drawable);
}
static void XvPixmapDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap)
{
XvStopAdaptors(&pPixmap->drawable);
}
int int
XvScreenInit(ScreenPtr pScreen) XvScreenInit(ScreenPtr pScreen)
{ {
XvScreenPtr pxvs;
if (XvScreenGeneration != serverGeneration) { if (XvScreenGeneration != serverGeneration) {
if (!CreateResourceTypes()) { if (!CreateResourceTypes()) {
ErrorF("XvScreenInit: Unable to allocate resource types\n"); ErrorF("XvScreenInit: Unable to allocate resource types\n");
return BadAlloc; return BadAlloc;
} }
#ifdef XINERAMA #ifdef PANORAMIX
XineramaRegisterConnectionBlockCallback(XineramifyXv); XineramaRegisterConnectionBlockCallback(XineramifyXv);
#endif /* XINERAMA */ #endif
XvScreenGeneration = serverGeneration; XvScreenGeneration = serverGeneration;
} }
@ -289,7 +271,7 @@ XvScreenInit(ScreenPtr pScreen)
/* ALLOCATE SCREEN PRIVATE RECORD */ /* ALLOCATE SCREEN PRIVATE RECORD */
XvScreenPtr pxvs = calloc(1, sizeof(XvScreenRec)); pxvs = malloc(sizeof(XvScreenRec));
if (!pxvs) { if (!pxvs) {
ErrorF("XvScreenInit: Unable to allocate screen private structure\n"); ErrorF("XvScreenInit: Unable to allocate screen private structure\n");
return BadAlloc; return BadAlloc;
@ -297,32 +279,40 @@ XvScreenInit(ScreenPtr pScreen)
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs); dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
dixScreenHookWindowDestroy(pScreen, XvWindowDestroy); pxvs->DestroyPixmap = pScreen->DestroyPixmap;
dixScreenHookClose(pScreen, XvScreenClose); pxvs->DestroyWindow = pScreen->DestroyWindow;
dixScreenHookPixmapDestroy(pScreen, XvPixmapDestroy); pxvs->CloseScreen = pScreen->CloseScreen;
pScreen->DestroyPixmap = XvDestroyPixmap;
pScreen->DestroyWindow = XvDestroyWindow;
pScreen->CloseScreen = XvCloseScreen;
return Success; return Success;
} }
static void XvScreenClose(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused) static Bool
XvCloseScreen(ScreenPtr pScreen)
{ {
XvScreenPtr pxvs; XvScreenPtr pxvs;
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey); pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
dixScreenUnhookWindowDestroy(pScreen, XvWindowDestroy); pScreen->DestroyPixmap = pxvs->DestroyPixmap;
dixScreenUnhookClose(pScreen, XvScreenClose); pScreen->DestroyWindow = pxvs->DestroyWindow;
dixScreenUnhookPixmapDestroy(pScreen, XvPixmapDestroy); pScreen->CloseScreen = pxvs->CloseScreen;
free(pxvs); free(pxvs);
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL); dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
return (*pScreen->CloseScreen) (pScreen);
} }
static void static void
XvResetProc(ExtensionEntry * extEntry) XvResetProc(ExtensionEntry * extEntry)
{ {
xvUseXinerama = 0; XvResetProcVector();
} }
DevPrivateKey DevPrivateKey
@ -350,7 +340,7 @@ XvStopAdaptors(DrawablePtr pDrawable)
XvPortPtr pp = pa->pPorts; XvPortPtr pp = pa->pPorts;
int np = pa->nPorts; int np = pa->nPorts;
while ((np--) && (pp)) { while (np--) {
if (pp->pDraw == pDrawable) { if (pp->pDraw == pDrawable) {
XvdiSendVideoNotify(pp, pDrawable, XvPreempted); XvdiSendVideoNotify(pp, pDrawable, XvPreempted);
@ -366,6 +356,39 @@ XvStopAdaptors(DrawablePtr pDrawable)
} }
} }
static Bool
XvDestroyPixmap(PixmapPtr pPix)
{
ScreenPtr pScreen = pPix->drawable.pScreen;
Bool status;
if (pPix->refcnt == 1)
XvStopAdaptors(&pPix->drawable);
SCREEN_PROLOGUE(pScreen, DestroyPixmap);
status = (*pScreen->DestroyPixmap) (pPix);
SCREEN_EPILOGUE(pScreen, DestroyPixmap, XvDestroyPixmap);
return status;
}
static Bool
XvDestroyWindow(WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
Bool status;
XvStopAdaptors(&pWin->drawable);
SCREEN_PROLOGUE(pScreen, DestroyWindow);
status = (*pScreen->DestroyWindow) (pWin);
SCREEN_EPILOGUE(pScreen, DestroyWindow, XvDestroyWindow);
return status;
}
static int static int
XvdiDestroyPort(void *pPort, XID id) XvdiDestroyPort(void *pPort, XID id)
{ {
@ -446,7 +469,7 @@ XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
} }
static int int
XvdiSendPortNotify(XvPortPtr pPort, Atom attribute, INT32 value) XvdiSendPortNotify(XvPortPtr pPort, Atom attribute, INT32 value)
{ {
XvPortNotifyPtr pn; XvPortNotifyPtr pn;
@ -774,7 +797,7 @@ XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
WILL BE DELETED WHEN THE DRAWABLE IS DESTROYED */ WILL BE DELETED WHEN THE DRAWABLE IS DESTROYED */
if (!pn) { if (!pn) {
if (!(tpn = calloc(1, sizeof(XvVideoNotifyRec)))) if (!(tpn = malloc(sizeof(XvVideoNotifyRec))))
return BadAlloc; return BadAlloc;
tpn->next = NULL; tpn->next = NULL;
tpn->client = NULL; tpn->client = NULL;
@ -810,7 +833,7 @@ XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
tpn = fpn; tpn = fpn;
} }
else { else {
if (!(tpn = calloc(1, sizeof(XvVideoNotifyRec)))) if (!(tpn = malloc(sizeof(XvVideoNotifyRec))))
return BadAlloc; return BadAlloc;
tpn->next = pn->next; tpn->next = pn->next;
pn->next = tpn; pn->next = tpn;
@ -864,7 +887,7 @@ XvdiSelectPortNotify(ClientPtr client, XvPortPtr pPort, BOOL onoff)
CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */ CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */
if (!tpn) { if (!tpn) {
if (!(tpn = calloc(1, sizeof(XvPortNotifyRec)))) if (!(tpn = malloc(sizeof(XvPortNotifyRec))))
return BadAlloc; return BadAlloc;
tpn->next = pPort->pNotify; tpn->next = pPort->pNotify;
pPort->pNotify = tpn; pPort->pNotify = tpn;
@ -1048,7 +1071,7 @@ XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval); (void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
ValidateGC(pDraw, gc); ValidateGC(pDraw, gc);
rects = calloc(nbox, sizeof(xRectangle)); rects = xallocarray(nbox, sizeof(xRectangle));
if (rects) { if (rects) {
for (i = 0; i < nbox; i++, pbox++) { for (i = 0; i < nbox; i++, pbox++) {
rects[i].x = pbox->x1 - pDraw->x; rects[i].x = pbox->x1 - pDraw->x;

View File

@ -1,26 +1,27 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include <string.h> #include <string.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xfuncproto.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/extensions/XvMC.h>
#include <X11/extensions/Xvproto.h>
#include <X11/extensions/XvMCproto.h>
#include "dix/screen_hooks_priv.h"
#include "miext/extinit_priv.h"
#include "Xext/xvdix_priv.h"
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#include "dixstruct.h" #include "dixstruct.h"
#include "resource.h" #include "resource.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "extinit.h"
#include "servermd.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>
#include "xvmcext.h" #include "xvmcext.h"
#include "protocol-versions.h"
#ifdef HAS_XVMCSHM #ifdef HAS_XVMCSHM
#include <sys/ipc.h> #include <sys/ipc.h>
@ -28,9 +29,6 @@
#include <sys/shm.h> #include <sys/shm.h>
#endif /* HAS_XVMCSHM */ #endif /* HAS_XVMCSHM */
#define SERVER_XVMC_MAJOR_VERSION 1
#define SERVER_XVMC_MINOR_VERSION 1
#define DR_CLIENT_DRIVER_NAME_SIZE 48 #define DR_CLIENT_DRIVER_NAME_SIZE 48
#define DR_BUSID_SIZE 48 #define DR_BUSID_SIZE 48
@ -46,9 +44,12 @@ static RESTYPE XvMCRTContext;
static RESTYPE XvMCRTSurface; static RESTYPE XvMCRTSurface;
static RESTYPE XvMCRTSubpicture; static RESTYPE XvMCRTSubpicture;
int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr) = NULL;
typedef struct { typedef struct {
int num_adaptors; int num_adaptors;
XvMCAdaptorPtr adaptors; XvMCAdaptorPtr adaptors;
CloseScreenProcPtr CloseScreen;
char clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE]; char clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE];
char busID[DR_BUSID_SIZE]; char busID[DR_BUSID_SIZE];
int major; int major;
@ -112,6 +113,7 @@ ProcXvMCQueryVersion(ClientPtr client)
xvmcQueryVersionReply rep = { xvmcQueryVersionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.major = SERVER_XVMC_MAJOR_VERSION, .major = SERVER_XVMC_MAJOR_VERSION,
.minor = SERVER_XVMC_MINOR_VERSION .minor = SERVER_XVMC_MINOR_VERSION
}; };
@ -127,8 +129,13 @@ static int
ProcXvMCListSurfaceTypes(ClientPtr client) ProcXvMCListSurfaceTypes(ClientPtr client)
{ {
XvPortPtr pPort; XvPortPtr pPort;
int i;
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
xvmcListSurfaceTypesReply rep;
xvmcSurfaceInfo info;
XvMCAdaptorPtr adaptor = NULL; XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface;
int num_surfaces;
REQUEST(xvmcListSurfaceTypesReq); REQUEST(xvmcListSurfaceTypesReq);
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq); REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
@ -139,7 +146,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
ScreenPtr pScreen = pPort->pAdaptor->pScreen; ScreenPtr pScreen = pPort->pAdaptor->pScreen;
if ((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */ if ((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
for (int i = 0; i < pScreenPriv->num_adaptors; i++) { for (i = 0; i < pScreenPriv->num_adaptors; i++) {
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) { if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
adaptor = &(pScreenPriv->adaptors[i]); adaptor = &(pScreenPriv->adaptors[i]);
break; break;
@ -148,36 +155,28 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
} }
} }
int num_surfaces = (adaptor) ? adaptor->num_surfaces : 0; num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
xvmcSurfaceInfo *info = NULL; rep = (xvmcListSurfaceTypesReply) {
if (num_surfaces) {
info = calloc(sizeof(xvmcSurfaceInfo), num_surfaces);
if (!info)
return BadAlloc;
for (int i = 0; i < num_surfaces; i++) {
XvMCSurfaceInfoPtr surface = adaptor->surfaces[i];
info[i].surface_type_id = surface->surface_type_id;
info[i].chroma_format = surface->chroma_format;
info[i].max_width = surface->max_width;
info[i].max_height = surface->max_height;
info[i].subpicture_max_width = surface->subpicture_max_width;
info[i].subpicture_max_height = surface->subpicture_max_height;
info[i].mc_type = surface->mc_type;
info[i].flags = surface->flags;
}
}
xvmcListSurfaceTypesReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.num = num_surfaces, .num = num_surfaces,
.length = bytes_to_int32(sizeof(xvmcSurfaceInfo) * num_surfaces), .length = bytes_to_int32(num_surfaces * sizeof(xvmcSurfaceInfo)),
}; };
WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), &rep); WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), &rep);
WriteToClient(client, sizeof(xvmcSurfaceInfo) * num_surfaces, info);
free(info); for (i = 0; i < num_surfaces; i++) {
surface = adaptor->surfaces[i];
info.surface_type_id = surface->surface_type_id;
info.chroma_format = surface->chroma_format;
info.max_width = surface->max_width;
info.max_height = surface->max_height;
info.subpicture_max_width = surface->subpicture_max_width;
info.subpicture_max_height = surface->subpicture_max_height;
info.mc_type = surface->mc_type;
info.flags = surface->flags;
WriteToClient(client, sizeof(xvmcSurfaceInfo), &info);
}
return Success; return Success;
} }
@ -188,12 +187,13 @@ ProcXvMCCreateContext(ClientPtr client)
XvPortPtr pPort; XvPortPtr pPort;
CARD32 *data = NULL; CARD32 *data = NULL;
int dwords = 0; int dwords = 0;
int result, adapt_num = -1; int i, result, adapt_num = -1;
ScreenPtr pScreen; ScreenPtr pScreen;
XvMCContextPtr pContext; XvMCContextPtr pContext;
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
XvMCAdaptorPtr adaptor = NULL; XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface = NULL; XvMCSurfaceInfoPtr surface = NULL;
xvmcCreateContextReply rep;
REQUEST(xvmcCreateContextReq); REQUEST(xvmcCreateContextReq);
REQUEST_SIZE_MATCH(xvmcCreateContextReq); REQUEST_SIZE_MATCH(xvmcCreateContextReq);
@ -208,7 +208,7 @@ ProcXvMCCreateContext(ClientPtr client)
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */ if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
return BadMatch; return BadMatch;
for (int i = 0; i < pScreenPriv->num_adaptors; i++) { for (i = 0; i < pScreenPriv->num_adaptors; i++) {
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) { if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
adaptor = &(pScreenPriv->adaptors[i]); adaptor = &(pScreenPriv->adaptors[i]);
adapt_num = i; adapt_num = i;
@ -219,7 +219,7 @@ ProcXvMCCreateContext(ClientPtr client)
if (adapt_num < 0) /* none this port */ if (adapt_num < 0) /* none this port */
return BadMatch; return BadMatch;
for (int i = 0; i < adaptor->num_surfaces; i++) { for (i = 0; i < adaptor->num_surfaces; i++) {
if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) { if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
surface = adaptor->surfaces[i]; surface = adaptor->surfaces[i];
break; break;
@ -234,7 +234,7 @@ ProcXvMCCreateContext(ClientPtr client)
(stuff->height > surface->max_height)) (stuff->height > surface->max_height))
return BadValue; return BadValue;
if (!(pContext = calloc(1, sizeof(XvMCContextRec)))) { if (!(pContext = malloc(sizeof(XvMCContextRec)))) {
return BadAlloc; return BadAlloc;
} }
@ -258,7 +258,7 @@ ProcXvMCCreateContext(ClientPtr client)
return BadAlloc; return BadAlloc;
} }
xvmcCreateContextReply rep = { rep = (xvmcCreateContextReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = dwords, .length = dwords,
@ -290,7 +290,7 @@ ProcXvMCDestroyContext(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
FreeResource(stuff->context_id, X11_RESTYPE_NONE); FreeResource(stuff->context_id, RT_NONE);
return Success; return Success;
} }
@ -304,6 +304,7 @@ ProcXvMCCreateSurface(ClientPtr client)
XvMCContextPtr pContext; XvMCContextPtr pContext;
XvMCSurfacePtr pSurface; XvMCSurfacePtr pSurface;
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
xvmcCreateSurfaceReply rep;
REQUEST(xvmcCreateSurfaceReq); REQUEST(xvmcCreateSurfaceReq);
REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq); REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
@ -315,7 +316,7 @@ ProcXvMCCreateSurface(ClientPtr client)
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen); pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
if (!(pSurface = calloc(1, sizeof(XvMCSurfaceRec)))) if (!(pSurface = malloc(sizeof(XvMCSurfaceRec))))
return BadAlloc; return BadAlloc;
pSurface->surface_id = stuff->surface_id; pSurface->surface_id = stuff->surface_id;
@ -336,7 +337,7 @@ ProcXvMCCreateSurface(ClientPtr client)
return BadAlloc; return BadAlloc;
} }
xvmcCreateSurfaceReply rep = { rep = (xvmcCreateSurfaceReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = dwords .length = dwords
@ -367,7 +368,7 @@ ProcXvMCDestroySurface(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
FreeResource(stuff->surface_id, X11_RESTYPE_NONE); FreeResource(stuff->surface_id, RT_NONE);
return Success; return Success;
} }
@ -377,10 +378,11 @@ ProcXvMCCreateSubpicture(ClientPtr client)
{ {
Bool image_supported = FALSE; Bool image_supported = FALSE;
CARD32 *data = NULL; CARD32 *data = NULL;
int result, dwords = 0; int i, result, dwords = 0;
XvMCContextPtr pContext; XvMCContextPtr pContext;
XvMCSubpicturePtr pSubpicture; XvMCSubpicturePtr pSubpicture;
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
xvmcCreateSubpictureReply rep;
XvMCAdaptorPtr adaptor; XvMCAdaptorPtr adaptor;
XvMCSurfaceInfoPtr surface = NULL; XvMCSurfaceInfoPtr surface = NULL;
@ -397,7 +399,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
adaptor = &(pScreenPriv->adaptors[pContext->adapt_num]); adaptor = &(pScreenPriv->adaptors[pContext->adapt_num]);
/* find which surface this context supports */ /* find which surface this context supports */
for (int i = 0; i < adaptor->num_surfaces; i++) { for (i = 0; i < adaptor->num_surfaces; i++) {
if (adaptor->surfaces[i]->surface_type_id == pContext->surface_type_id) { if (adaptor->surfaces[i]->surface_type_id == pContext->surface_type_id) {
surface = adaptor->surfaces[i]; surface = adaptor->surfaces[i];
break; break;
@ -411,7 +413,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
if (!surface->compatible_subpictures) if (!surface->compatible_subpictures)
return BadMatch; return BadMatch;
for (int i = 0; i < surface->compatible_subpictures->num_xvimages; i++) { for (i = 0; i < surface->compatible_subpictures->num_xvimages; i++) {
if (surface->compatible_subpictures->xvimage_ids[i] == if (surface->compatible_subpictures->xvimage_ids[i] ==
stuff->xvimage_id) { stuff->xvimage_id) {
image_supported = TRUE; image_supported = TRUE;
@ -427,7 +429,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
(stuff->height > surface->subpicture_max_height)) (stuff->height > surface->subpicture_max_height))
return BadValue; return BadValue;
if (!(pSubpicture = calloc(1, sizeof(XvMCSubpictureRec)))) if (!(pSubpicture = malloc(sizeof(XvMCSubpictureRec))))
return BadAlloc; return BadAlloc;
pSubpicture->subpicture_id = stuff->subpicture_id; pSubpicture->subpicture_id = stuff->subpicture_id;
@ -455,7 +457,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
return BadAlloc; return BadAlloc;
} }
xvmcCreateSubpictureReply rep = { rep = (xvmcCreateSubpictureReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = dwords, .length = dwords,
@ -494,7 +496,7 @@ ProcXvMCDestroySubpicture(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
FreeResource(stuff->subpicture_id, X11_RESTYPE_NONE); FreeResource(stuff->subpicture_id, RT_NONE);
return Success; return Success;
} }
@ -503,11 +505,14 @@ static int
ProcXvMCListSubpictureTypes(ClientPtr client) ProcXvMCListSubpictureTypes(ClientPtr client)
{ {
XvPortPtr pPort; XvPortPtr pPort;
xvmcListSubpictureTypesReply rep;
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
ScreenPtr pScreen; ScreenPtr pScreen;
XvMCAdaptorPtr adaptor = NULL; XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface = NULL; XvMCSurfaceInfoPtr surface = NULL;
xvImageFormatInfo info;
XvImagePtr pImage; XvImagePtr pImage;
int i, j;
REQUEST(xvmcListSubpictureTypesReq); REQUEST(xvmcListSubpictureTypesReq);
REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq); REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
@ -522,7 +527,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
return BadMatch; /* None this screen */ return BadMatch; /* None this screen */
for (int i = 0; i < pScreenPriv->num_adaptors; i++) { for (i = 0; i < pScreenPriv->num_adaptors; i++) {
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) { if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
adaptor = &(pScreenPriv->adaptors[i]); adaptor = &(pScreenPriv->adaptors[i]);
break; break;
@ -532,7 +537,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if (!adaptor) if (!adaptor)
return BadMatch; return BadMatch;
for (int i = 0; i < adaptor->num_surfaces; i++) { for (i = 0; i < adaptor->num_surfaces; i++) {
if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) { if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
surface = adaptor->surfaces[i]; surface = adaptor->surfaces[i];
break; break;
@ -542,70 +547,62 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if (!surface) if (!surface)
return BadMatch; return BadMatch;
int num = (surface->compatible_subpictures ? rep = (xvmcListSubpictureTypesReply) {
surface->compatible_subpictures->num_xvimages : 0); .type = X_Reply,
.sequenceNumber = client->sequence,
.num = 0
};
if (surface->compatible_subpictures)
rep.num = surface->compatible_subpictures->num_xvimages;
xvImageFormatInfo *info = NULL; rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo));
if (num) {
info = calloc(sizeof(xvImageFormatInfo), num);
if (!info)
return BadAlloc;
for (int i = 0; i < num; i++) { WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), &rep);
for (i = 0; i < rep.num; i++) {
pImage = NULL; pImage = NULL;
for (int j = 0; j < adaptor->num_subpictures; j++) { for (j = 0; j < adaptor->num_subpictures; j++) {
if (surface->compatible_subpictures->xvimage_ids[i] == if (surface->compatible_subpictures->xvimage_ids[i] ==
adaptor->subpictures[j]->id) { adaptor->subpictures[j]->id) {
pImage = adaptor->subpictures[j]; pImage = adaptor->subpictures[j];
break; break;
} }
} }
if (!pImage) { if (!pImage)
free(info);
return BadImplementation; return BadImplementation;
info.id = pImage->id;
info.type = pImage->type;
info.byte_order = pImage->byte_order;
memcpy(&info.guid, pImage->guid, 16);
info.bpp = pImage->bits_per_pixel;
info.num_planes = pImage->num_planes;
info.depth = pImage->depth;
info.red_mask = pImage->red_mask;
info.green_mask = pImage->green_mask;
info.blue_mask = pImage->blue_mask;
info.format = pImage->format;
info.y_sample_bits = pImage->y_sample_bits;
info.u_sample_bits = pImage->u_sample_bits;
info.v_sample_bits = pImage->v_sample_bits;
info.horz_y_period = pImage->horz_y_period;
info.horz_u_period = pImage->horz_u_period;
info.horz_v_period = pImage->horz_v_period;
info.vert_y_period = pImage->vert_y_period;
info.vert_u_period = pImage->vert_u_period;
info.vert_v_period = pImage->vert_v_period;
memcpy(&info.comp_order, pImage->component_order, 32);
info.scanline_order = pImage->scanline_order;
WriteToClient(client, sizeof(xvImageFormatInfo), &info);
} }
info[i].id = pImage->id;
info[i].type = pImage->type;
info[i].byte_order = pImage->byte_order;
memcpy(&info[i].guid, pImage->guid, 16);
info[i].bpp = pImage->bits_per_pixel;
info[i].num_planes = pImage->num_planes;
info[i].depth = pImage->depth;
info[i].red_mask = pImage->red_mask;
info[i].green_mask = pImage->green_mask;
info[i].blue_mask = pImage->blue_mask;
info[i].format = pImage->format;
info[i].y_sample_bits = pImage->y_sample_bits;
info[i].u_sample_bits = pImage->u_sample_bits;
info[i].v_sample_bits = pImage->v_sample_bits;
info[i].horz_y_period = pImage->horz_y_period;
info[i].horz_u_period = pImage->horz_u_period;
info[i].horz_v_period = pImage->horz_v_period;
info[i].vert_y_period = pImage->vert_y_period;
info[i].vert_u_period = pImage->vert_u_period;
info[i].vert_v_period = pImage->vert_v_period;
memcpy(&info[i].comp_order, pImage->component_order, 32);
info[i].scanline_order = pImage->scanline_order;
}
}
xvmcListSubpictureTypesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num = num,
.length = bytes_to_int32(num * sizeof(xvImageFormatInfo)),
};
WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), &rep);
WriteToClient(client, sizeof(xvImageFormatInfo) * num, info);
free(info);
return Success; return Success;
} }
static int static int
ProcXvMCGetDRInfo(ClientPtr client) ProcXvMCGetDRInfo(ClientPtr client)
{ {
xvmcGetDRInfoReply rep;
XvPortPtr pPort; XvPortPtr pPort;
ScreenPtr pScreen; ScreenPtr pScreen;
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
@ -622,30 +619,21 @@ ProcXvMCGetDRInfo(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen; pScreen = pPort->pAdaptor->pScreen;
pScreenPriv = XVMC_GET_PRIVATE(pScreen); pScreenPriv = XVMC_GET_PRIVATE(pScreen);
int nameLen = strlen(pScreenPriv->clientDriverName) + 1; rep = (xvmcGetDRInfoReply) {
int busIDLen = strlen(pScreenPriv->busID) + 1;
// buffer holds two zero-terminated strings, padded to 4-byte ints
const size_t buflen = pad_to_int32(nameLen+busIDLen);
char *buf = calloc(1, buflen);
if (!buf)
return BadAlloc;
memcpy(buf, pScreenPriv->clientDriverName, nameLen);
memcpy(buf+nameLen, pScreenPriv->busID, busIDLen);
xvmcGetDRInfoReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.major = pScreenPriv->major, .major = pScreenPriv->major,
.minor = pScreenPriv->minor, .minor = pScreenPriv->minor,
.patchLevel = pScreenPriv->patchLevel, .patchLevel = pScreenPriv->patchLevel,
.nameLen = nameLen, .nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1),
.busIDLen = busIDLen, .busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1),
.length = bytes_to_int32(sizeof(buf)),
.isLocal = 1 .isLocal = 1
}; };
rep.length = rep.nameLen + rep.busIDLen;
rep.nameLen <<= 2;
rep.busIDLen <<= 2;
/* /*
* Read back to the client what she has put in the shared memory * Read back to the client what she has put in the shared memory
* segment she prepared for us. * segment she prepared for us.
@ -673,40 +661,33 @@ ProcXvMCGetDRInfo(ClientPtr client)
#endif /* HAS_XVMCSHM */ #endif /* HAS_XVMCSHM */
WriteToClient(client, sizeof(xvmcGetDRInfoReply), &rep); WriteToClient(client, sizeof(xvmcGetDRInfoReply), &rep);
WriteToClient(client, buflen, buf); if (rep.length) {
free(buf); WriteToClient(client, rep.nameLen, pScreenPriv->clientDriverName);
WriteToClient(client, rep.busIDLen, pScreenPriv->busID);
}
return Success; return Success;
} }
int (*ProcXvMCVector[xvmcNumRequest]) (ClientPtr) = {
ProcXvMCQueryVersion,
ProcXvMCListSurfaceTypes,
ProcXvMCCreateContext,
ProcXvMCDestroyContext,
ProcXvMCCreateSurface,
ProcXvMCDestroySurface,
ProcXvMCCreateSubpicture,
ProcXvMCDestroySubpicture,
ProcXvMCListSubpictureTypes, ProcXvMCGetDRInfo};
static int static int
ProcXvMCDispatch(ClientPtr client) ProcXvMCDispatch(ClientPtr client)
{ {
REQUEST(xReq); REQUEST(xReq);
switch (stuff->data)
{ if (stuff->data < xvmcNumRequest)
case xvmc_QueryVersion: return (*ProcXvMCVector[stuff->data]) (client);
return ProcXvMCQueryVersion(client); else
case xvmc_ListSurfaceTypes:
return ProcXvMCListSurfaceTypes(client);
case xvmc_CreateContext:
return ProcXvMCCreateContext(client);
case xvmc_DestroyContext:
return ProcXvMCDestroyContext(client);
case xvmc_CreateSurface:
return ProcXvMCCreateSurface(client);
case xvmc_DestroySurface:
return ProcXvMCDestroySurface(client);
case xvmc_CreateSubpicture:
return ProcXvMCCreateSubpicture(client);
case xvmc_DestroySubpicture:
return ProcXvMCDestroySubpicture(client);
case xvmc_ListSubpictureTypes:
return ProcXvMCListSubpictureTypes(client);
case xvmc_GetDRInfo:
return ProcXvMCGetDRInfo(client);
default:
return BadRequest; return BadRequest;
}
} }
static int _X_COLD static int _X_COLD
@ -753,12 +734,16 @@ XvMCExtensionInit(void)
extEntry->errorBase + XvMCBadSubpicture); extEntry->errorBase + XvMCBadSubpicture);
} }
static void XvMCScreenClose(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused) static Bool
XvMCCloseScreen(ScreenPtr pScreen)
{ {
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen); XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
free(pScreenPriv); free(pScreenPriv);
dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, NULL);
dixScreenUnhookClose(pScreen, XvMCScreenClose); return (*pScreen->CloseScreen) (pScreen);
} }
int int
@ -769,12 +754,13 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0)) if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
return BadAlloc; return BadAlloc;
if (!(pScreenPriv = calloc(1, sizeof(XvMCScreenRec)))) if (!(pScreenPriv = malloc(sizeof(XvMCScreenRec))))
return BadAlloc; return BadAlloc;
dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv); dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv);
dixScreenHookClose(pScreen, XvMCScreenClose); pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = XvMCCloseScreen;
pScreenPriv->num_adaptors = num; pScreenPriv->num_adaptors = num;
pScreenPriv->adaptors = pAdapt; pScreenPriv->adaptors = pAdapt;
@ -796,6 +782,7 @@ XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
ScreenPtr pScreen = pPort->pAdaptor->pScreen; ScreenPtr pScreen = pPort->pAdaptor->pScreen;
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
XvMCAdaptorPtr adaptor = NULL; XvMCAdaptorPtr adaptor = NULL;
int i;
if (!dixPrivateKeyRegistered(XvMCScreenKey)) if (!dixPrivateKeyRegistered(XvMCScreenKey))
return NULL; return NULL;
@ -803,7 +790,7 @@ XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
return NULL; return NULL;
for (int i = 0; i < pScreenPriv->num_adaptors; i++) { for (i = 0; i < pScreenPriv->num_adaptors; i++) {
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) { if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
adaptor = &(pScreenPriv->adaptors[i]); adaptor = &(pScreenPriv->adaptors[i]);
break; break;
@ -813,7 +800,7 @@ XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
if (!adaptor) if (!adaptor)
return NULL; return NULL;
for (int i = 0; i < adaptor->num_subpictures; i++) { for (i = 0; i < adaptor->num_subpictures; i++) {
if (adaptor->subpictures[i]->id == id) { if (adaptor->subpictures[i]->id == id) {
pImage = adaptor->subpictures[i]; pImage = adaptor->subpictures[i];
break; break;

View File

@ -84,9 +84,13 @@ typedef struct {
XvMCDestroySubpictureProcPtr DestroySubpicture; XvMCDestroySubpictureProcPtr DestroySubpicture;
} XvMCAdaptorRec, *XvMCAdaptorPtr; } XvMCAdaptorRec, *XvMCAdaptorPtr;
extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr);
extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen, extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen,
int num, XvMCAdaptorPtr adapt); int num, XvMCAdaptorPtr adapt);
extern _X_EXPORT XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id);
extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name, extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name,
const char *busID, int major, int minor, const char *busID, int major, int minor,
int patchLevel); int patchLevel);

View File

@ -50,17 +50,18 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> #include <X11/extensions/XIproto.h>
#include "dix/dix_priv.h"
#include "dix/input_priv.h"
#include "exglobals.h" #include "exglobals.h"
#include "allowev.h" #include "allowev.h"
#include "dixevents.h"
/*********************************************************************** /***********************************************************************
* *
@ -72,6 +73,7 @@ int _X_COLD
SProcXAllowDeviceEvents(ClientPtr client) SProcXAllowDeviceEvents(ClientPtr client)
{ {
REQUEST(xAllowDeviceEventsReq); REQUEST(xAllowDeviceEventsReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq); REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
swapl(&stuff->time); swapl(&stuff->time);
return (ProcXAllowDeviceEvents(client)); return (ProcXAllowDeviceEvents(client));
@ -100,22 +102,22 @@ ProcXAllowDeviceEvents(ClientPtr client)
switch (stuff->mode) { switch (stuff->mode) {
case ReplayThisDevice: case ReplayThisDevice:
AllowSome(client, time, thisdev, GRAB_STATE_NOT_GRABBED); AllowSome(client, time, thisdev, NOT_GRABBED);
break; break;
case SyncThisDevice: case SyncThisDevice:
AllowSome(client, time, thisdev, GRAB_STATE_FREEZE_NEXT_EVENT); AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT);
break; break;
case AsyncThisDevice: case AsyncThisDevice:
AllowSome(client, time, thisdev, GRAB_STATE_THAWED); AllowSome(client, time, thisdev, THAWED);
break; break;
case AsyncOtherDevices: case AsyncOtherDevices:
AllowSome(client, time, thisdev, GRAB_STATE_THAW_OTHERS); AllowSome(client, time, thisdev, THAW_OTHERS);
break; break;
case SyncAll: case SyncAll:
AllowSome(client, time, thisdev, GRAB_STATE_FREEZE_BOTH_NEXT_EVENT); AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT);
break; break;
case AsyncAll: case AsyncAll:
AllowSome(client, time, thisdev, GRAB_STATE_THAWED_BOTH); AllowSome(client, time, thisdev, THAWED_BOTH);
break; break;
default: default:
client->errorValue = stuff->mode; client->errorValue = stuff->mode;

View File

@ -50,18 +50,18 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <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 "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* control constants */
#include "XIstubs.h" #include "XIstubs.h"
#include "exglobals.h" #include "exglobals.h"
#include "exevents.h"
#include "chgdctl.h" #include "chgdctl.h"
/*********************************************************************** /***********************************************************************
@ -77,6 +77,7 @@ SProcXChangeDeviceControl(ClientPtr client)
xDeviceCtl *ctl; xDeviceCtl *ctl;
REQUEST(xChangeDeviceControlReq); REQUEST(xChangeDeviceControlReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl)); REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
swaps(&stuff->control); swaps(&stuff->control);
ctl = (xDeviceCtl *) &stuff[1]; ctl = (xDeviceCtl *) &stuff[1];
@ -108,6 +109,7 @@ ProcXChangeDeviceControl(ClientPtr client)
int i, status, ret = BadValue; int i, status, ret = BadValue;
DeviceIntPtr dev; DeviceIntPtr dev;
xDeviceResolutionCtl *r; xDeviceResolutionCtl *r;
xChangeDeviceControlReply rep;
AxisInfoPtr a; AxisInfoPtr a;
CARD32 *resolution; CARD32 *resolution;
xDeviceEnableCtl *e; xDeviceEnableCtl *e;
@ -115,7 +117,7 @@ ProcXChangeDeviceControl(ClientPtr client)
REQUEST(xChangeDeviceControlReq); REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl)); REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
len = client->req_len - bytes_to_int32(sizeof(xChangeDeviceControlReq)); len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceControlReq));
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success) if (ret != Success)
goto out; goto out;
@ -126,9 +128,11 @@ ProcXChangeDeviceControl(ClientPtr client)
goto out; goto out;
} }
xChangeDeviceControlReply rep = { rep = (xChangeDeviceControlReply) {
.repType = X_Reply,
.RepType = X_ChangeDeviceControl, .RepType = X_ChangeDeviceControl,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.status = Success, .status = Success,
}; };
@ -230,11 +234,24 @@ ProcXChangeDeviceControl(ClientPtr client)
SendEventToAllWindows(dev, DevicePresenceNotifyMask, SendEventToAllWindows(dev, DevicePresenceNotifyMask,
(xEvent *) &dpn, 1); (xEvent *) &dpn, 1);
if (client->swapped) { WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xChangeDeviceControlReply), &rep);
} }
return ret; return ret;
} }
/***********************************************************************
*
* This procedure writes the reply for the xChangeDeviceControl function,
* if the client and server have a different byte ordering.
*
*/
void _X_COLD
SRepXChangeDeviceControl(ClientPtr client, int size,
xChangeDeviceControlReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
}

View File

@ -36,4 +36,9 @@ int SProcXChangeDeviceControl(ClientPtr /* client */
int ProcXChangeDeviceControl(ClientPtr /* client */ int ProcXChangeDeviceControl(ClientPtr /* client */
); );
void SRepXChangeDeviceControl(ClientPtr /* client */ ,
int /* size */ ,
xChangeDeviceControlReply * /* rep */
);
#endif /* CHGDCTL_H */ #endif /* CHGDCTL_H */

View File

@ -50,7 +50,9 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
@ -73,6 +75,7 @@ int _X_COLD
SProcXChangeFeedbackControl(ClientPtr client) SProcXChangeFeedbackControl(ClientPtr client)
{ {
REQUEST(xChangeFeedbackControlReq); REQUEST(xChangeFeedbackControlReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
swapl(&stuff->mask); swapl(&stuff->mask);
return (ProcXChangeFeedbackControl(client)); return (ProcXChangeFeedbackControl(client));
@ -435,7 +438,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
REQUEST(xChangeFeedbackControlReq); REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
len = client->req_len - bytes_to_int32(sizeof(xChangeFeedbackControlReq)); len = stuff->length - bytes_to_int32(sizeof(xChangeFeedbackControlReq));
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;

View File

@ -50,7 +50,9 @@ SOFTWARE.
* *
*/ */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif
#include "inputstr.h" /* DeviceIntPtr */ #include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h> #include <X11/extensions/XI.h>
@ -69,6 +71,23 @@ SOFTWARE.
* This procedure changes the keyboard device. * 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 int
ProcXChangeKeyboardDevice(ClientPtr client) ProcXChangeKeyboardDevice(ClientPtr client)
{ {

View File

@ -30,6 +30,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGKBD_H #ifndef CHGKBD_H
#define CHGKBD_H 1 #define CHGKBD_H 1
int SProcXChangeKeyboardDevice(ClientPtr /* client */
);
int ProcXChangeKeyboardDevice(ClientPtr /* client */ int ProcXChangeKeyboardDevice(ClientPtr /* client */
); );

Some files were not shown because too many files have changed in this diff Show More