From c40a217db5f63be3aa88a32ad77ec93efb40d95c Mon Sep 17 00:00:00 2001 From: root Date: Tue, 31 May 2011 22:46:59 +0000 Subject: Tue May 31 22:46:59 UTC 2011 --- testing/xorg-server/10-quirks.conf | 10 + testing/xorg-server/PKGBUILD | 196 ++++ testing/xorg-server/autoconfig-nvidia.patch | 104 ++ testing/xorg-server/bg-none-revert.patch | 58 ++ testing/xorg-server/git-fixes.patch | 318 ++++++ .../xorg-redhat-die-ugly-pattern-die-die-die.patch | 16 + .../xserver-1.10-pointer-barriers.patch | 1054 ++++++++++++++++++++ testing/xorg-server/xvfb-run | 180 ++++ testing/xorg-server/xvfb-run.1 | 282 ++++++ 9 files changed, 2218 insertions(+) create mode 100644 testing/xorg-server/10-quirks.conf create mode 100644 testing/xorg-server/PKGBUILD create mode 100644 testing/xorg-server/autoconfig-nvidia.patch create mode 100644 testing/xorg-server/bg-none-revert.patch create mode 100644 testing/xorg-server/git-fixes.patch create mode 100644 testing/xorg-server/xorg-redhat-die-ugly-pattern-die-die-die.patch create mode 100644 testing/xorg-server/xserver-1.10-pointer-barriers.patch create mode 100644 testing/xorg-server/xvfb-run create mode 100644 testing/xorg-server/xvfb-run.1 (limited to 'testing/xorg-server') diff --git a/testing/xorg-server/10-quirks.conf b/testing/xorg-server/10-quirks.conf new file mode 100644 index 000000000..7afad22dc --- /dev/null +++ b/testing/xorg-server/10-quirks.conf @@ -0,0 +1,10 @@ +# Collection of quirks and blacklist/whitelists for specific devices. + + +# Accelerometer device, posts data through ABS_X/ABS_Y, making X unusable +# http://bugs.freedesktop.org/show_bug.cgi?id=22442 +Section "InputClass" + Identifier "ThinkPad HDAPS accelerometer blacklist" + MatchProduct "ThinkPad HDAPS accelerometer data" + Option "Ignore" "on" +EndSection diff --git a/testing/xorg-server/PKGBUILD b/testing/xorg-server/PKGBUILD new file mode 100644 index 000000000..274da6f98 --- /dev/null +++ b/testing/xorg-server/PKGBUILD @@ -0,0 +1,196 @@ +# $Id: PKGBUILD 125811 2011-05-30 08:49:25Z jgc $ +# Maintainer: Jan de Groot + +pkgbase=xorg-server +pkgname=('xorg-server' 'xorg-server-xephyr' 'xorg-server-xdmx' 'xorg-server-xvfb' 'xorg-server-xnest' 'xorg-server-common' 'xorg-server-devel') +pkgver=1.10.2 +pkgrel=2 +arch=('i686' 'x86_64') +license=('custom') +url="http://xorg.freedesktop.org" +makedepends=('pixman' 'libx11' 'mesa' 'libgl' 'xf86driproto' 'xcmiscproto' 'xtrans' 'bigreqsproto' 'randrproto' 'inputproto' 'fontsproto' 'videoproto' 'compositeproto' 'recordproto' 'scrnsaverproto' 'resourceproto' 'xineramaproto' 'libxkbfile' 'libxfont' 'renderproto' 'libpciaccess' 'libxv' 'xf86dgaproto' 'libxmu' 'libxrender' 'libxi' 'dmxproto' 'libxaw' 'libdmx' 'libxtst' 'libxres' 'xorg-xkbcomp' 'xorg-util-macros' 'xorg-font-util') +options=('!libtool') +source=(${url}/releases/individual/xserver/${pkgbase}-${pkgver}.tar.bz2 + git-fixes.patch + bg-none-revert.patch + xserver-1.10-pointer-barriers.patch + xorg-redhat-die-ugly-pattern-die-die-die.patch + autoconfig-nvidia.patch + xvfb-run + xvfb-run.1 + 10-quirks.conf) +sha1sums=('fd831b3c6297d1a68830c602d767752d87b9ca54' + '6dd2bcd9d8b17d1a50ed8c15eb1cba480558e695' + '629c6d8d52126eab81ee1b72a9e4209535f8cb81' + '1b95e91384a57d966428c7db98ed06f4cc562f91' + '0efcdf61bde3c0cd813072b94e2b30ab922775b9' + 'f9328fd7bc931bb02c8909ecfcef35403de33782' + 'c94f742d3f9cabf958ae58e4015d9dd185aabedc' + '6838fc00ef4618c924a77e0fb03c05346080908a' + '993798f3d22ad672d769dae5f48d1fa068d5578f') + +build() { + cd "${srcdir}/${pkgbase}-${pkgver}" + # Get rid of the ugly pattern + patch -Np3 -i "${srcdir}/xorg-redhat-die-ugly-pattern-die-die-die.patch" + + # Add pointer barrier support, patch from Fedora + patch -Np1 -i "${srcdir}/xserver-1.10-pointer-barriers.patch" + + # Patches from ~ajax/xserver xserver-next branch + patch -Np1 -i "${srcdir}/bg-none-revert.patch" + + # Upstream fixes from 1.10 branch + patch -Np1 -i "${srcdir}/git-fixes.patch" + + # Use nouveau/nv/nvidia drivers for nvidia devices + patch -Np1 -i "${srcdir}/autoconfig-nvidia.patch" + + autoreconf + ./configure --prefix=/usr \ + --enable-ipv6 \ + --enable-dri \ + --enable-dmx \ + --enable-xvfb \ + --enable-xnest \ + --enable-composite \ + --enable-xcsecurity \ + --enable-xorg \ + --enable-xephyr \ + --enable-glx-tls \ + --enable-kdrive \ + --enable-install-setuid \ + --enable-config-udev \ + --disable-config-dbus \ + --enable-record \ + --disable-xfbdev \ + --disable-xfake \ + --disable-static \ + --sysconfdir=/etc/X11 \ + --localstatedir=/var \ + --with-xkb-path=/usr/share/X11/xkb \ + --with-xkb-output=/var/lib/xkb \ + --with-fontrootdir=/usr/share/fonts + make + + sed -e 's/^DMX_SUBDIRS =.*/DMX_SUBDIRS =/' \ + -e 's/^XVFB_SUBDIRS =.*/XVFB_SUBDIRS =/' \ + -e 's/^XNEST_SUBDIRS =.*/XNEST_SUBDIRS = /' \ + -e 's/^KDRIVE_SUBDIRS =.*/KDRIVE_SUBDIRS =/' \ + -i hw/Makefile +} + +package_xorg-server-common() { + pkgdesc="Xorg server common files" + depends=('xkeyboard-config' 'xorg-xkbcomp' 'xorg-setxkbmap' 'xorg-fonts-misc') + + cd "${srcdir}/${pkgbase}-${pkgver}" + install -m755 -d "${pkgdir}/usr/share/licenses/xorg-server-common" + install -m644 COPYING "${pkgdir}/usr/share/licenses/xorg-server-common" + + make -C xkb DESTDIR="${pkgdir}" install-data + + install -m755 -d "${pkgdir}/usr/share/man/man1" + install -m644 doc/man/Xserver.1 "${pkgdir}/usr/share/man/man1/" + + install -m755 -d "${pkgdir}/usr/lib/xorg" + install -m644 dix/protocol.txt "${pkgdir}/usr/lib/xorg/" +} + +package_xorg-server() { + pkgdesc="Xorg X server" + depends=(libxdmcp libxfont udev libpciaccess libdrm pixman libgcrypt libxau xorg-server-common xf86-input-evdev) + backup=('etc/X11/xorg.conf.d/10-evdev.conf' 'etc/X11/xorg.conf.d/10-quirks.conf') + provides=('x-server') + groups=('xorg') + + cd "${srcdir}/${pkgbase}-${pkgver}" + make DESTDIR="${pkgdir}" install + + install -m755 -d "${pkgdir}/etc/X11" + mv "${pkgdir}/usr/share/X11/xorg.conf.d" "${pkgdir}/etc/X11/" + install -m644 "${srcdir}/10-quirks.conf" "${pkgdir}/etc/X11/xorg.conf.d/" + + rmdir "${pkgdir}/usr/share/X11" + + # Needed for non-mesa drivers, libgl will restore it + mv "${pkgdir}/usr/lib/xorg/modules/extensions/libglx.so" \ + "${pkgdir}/usr/lib/xorg/modules/extensions/libglx.xorg" + + rm -rf "${pkgdir}/var" + + rm -f "${pkgdir}/usr/share/man/man1/Xserver.1" + rm -f "${pkgdir}/usr/lib/xorg/protocol.txt" + + install -m755 -d "${pkgdir}/usr/share/licenses/xorg-server" + ln -sf ../xorg-server-common/COPYING "${pkgdir}/usr/share/licenses/xorg-server/COPYING" + + rm -rf "${pkgdir}/usr/lib/pkgconfig" + rm -rf "${pkgdir}/usr/include" + rm -rf "${pkgdir}/usr/share/aclocal" +} + +package_xorg-server-xephyr() { + pkgdesc="A nested X server that runs as an X application" + depends=(libxfont libgl libgcrypt libxv pixman xorg-server-common) + + cd "${srcdir}/${pkgbase}-${pkgver}/hw/kdrive" + make DESTDIR="${pkgdir}" install + + install -m755 -d "${pkgdir}/usr/share/licenses/xorg-server-xephyr" + ln -sf ../xorg-server-common/COPYING "${pkgdir}/usr/share/licenses/xorg-server-xephyr/COPYING" +} + +package_xorg-server-xvfb() { + pkgdesc="Virtual framebuffer X server" + depends=(libxfont libxdmcp libxau libgcrypt pixman xorg-server-common) + + cd "${srcdir}/${pkgbase}-${pkgver}/hw/vfb" + make DESTDIR="${pkgdir}" install + + install -m755 "${srcdir}/xvfb-run" "${pkgdir}/usr/bin/" + install -m644 "${srcdir}/xvfb-run.1" "${pkgdir}/usr/share/man/man1/" + + install -m755 -d "${pkgdir}/usr/share/licenses/xorg-server-xvfb" + ln -sf ../xorg-server-common/COPYING "${pkgdir}/usr/share/licenses/xorg-server-xvfb/COPYING" +} + +package_xorg-server-xnest() { + pkgdesc="A nested X server that runs as an X application" + depends=(libxfont libxext libgcrypt pixman xorg-server-common) + + cd "${srcdir}/${pkgbase}-${pkgver}/hw/xnest" + make DESTDIR="${pkgdir}" install + + install -m755 -d "${pkgdir}/usr/share/licenses/xorg-server-xnest" + ln -sf ../xorg-server-common/COPYING "${pkgdir}/usr/share/licenses/xorg-server-xnest/COPYING" +} + +package_xorg-server-xdmx() { + pkgdesc="Distributed Multihead X Server and utilities" + depends=(libxfont libxi libgcrypt libxaw libxrender libdmx libxfixes pixman xorg-server-common) + + cd "${srcdir}/${pkgbase}-${pkgver}/hw/dmx" + make DESTDIR="${pkgdir}" install + + install -m755 -d "${pkgdir}/usr/share/licenses/xorg-server-xdmx" + ln -sf ../xorg-server-common/COPYING "${pkgdir}/usr/share/licenses/xorg-server-xdmx/COPYING" +} + +package_xorg-server-devel() { + pkgdesc="Development files for the X.Org X server" + depends=(xproto randrproto renderproto xextproto inputproto kbproto fontsproto videoproto dri2proto xineramaproto xorg-util-macros pixman libpciaccess) + + cd "${srcdir}/${pkgbase}-${pkgver}" + make DESTDIR="${pkgdir}" install + + rm -rf "${pkgdir}/usr/bin" + rm -rf "${pkgdir}/usr/share/man" + rm -rf "${pkgdir}/usr/share/doc" + rm -rf "${pkgdir}/usr/share/X11" + rm -rf "${pkgdir}/usr/lib/xorg" + rm -rf "${pkgdir}/var" + + install -m755 -d "${pkgdir}/usr/share/licenses/xorg-server-devel" + ln -sf ../xorg-server-common/COPYING "${pkgdir}/usr/share/licenses/xorg-server-devel/COPYING" +} diff --git a/testing/xorg-server/autoconfig-nvidia.patch b/testing/xorg-server/autoconfig-nvidia.patch new file mode 100644 index 000000000..c56586d54 --- /dev/null +++ b/testing/xorg-server/autoconfig-nvidia.patch @@ -0,0 +1,104 @@ +From a685b5cf34532cef96fc9b05f735088ac0c0c7ad Mon Sep 17 00:00:00 2001 +From: Fedora X Ninjas +Date: Tue, 16 Feb 2010 11:38:17 +1000 +Subject: [PATCH 08/17] autoconfig: select nouveau by default for NVIDIA GPUs + +Also, don't treat DRI setup failure as an error for nouveau. + +Modified by Archlinux: +Append nvidia driver to the list of prefered drivers +--- + glx/glxdri.c | 7 +++++-- + glx/glxdri2.c | 7 +++++-- + hw/xfree86/common/xf86AutoConfig.c | 19 ++++++++++++++++++- + 3 files changed, 28 insertions(+), 5 deletions(-) + +--- a/glx/glxdri.c ++++ b/glx/glxdri.c +@@ -978,6 +978,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) + const __DRIconfig **driConfigs; + const __DRIextension **extensions; + int i; ++ int from = X_ERROR; + + if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") || + !DRIQueryDirectRenderingCapable(pScreen, &isCapable) || +@@ -1057,7 +1058,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen) + + screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); + if (screen->driver == NULL) { +- LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n", ++ if (!strcmp(driverName, "nouveau")) ++ from = X_INFO; ++ LogMessage(from, "AIGLX error: dlopen of %s failed (%s)\n", + filename, dlerror()); + goto handle_error; + } +@@ -1193,7 +1196,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) + + free(screen); + +- LogMessage(X_ERROR, "AIGLX: reverting to software rendering\n"); ++ LogMessage(from, "AIGLX: reverting to software rendering\n"); + + return NULL; + } +--- a/glx/glxdri2.c ++++ b/glx/glxdri2.c +@@ -708,6 +708,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) + const __DRIextension **extensions; + const __DRIconfig **driConfigs; + int i; ++ int from = X_ERROR; + + screen = calloc(1, sizeof *screen); + if (screen == NULL) +@@ -734,7 +735,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen) + + screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); + if (screen->driver == NULL) { +- LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n", ++ if (!strcmp(driverName, "nouveau")) ++ from = X_INFO; ++ LogMessage(from, "AIGLX error: dlopen of %s failed (%s)\n", + filename, dlerror()); + goto handle_error; + } +@@ -826,7 +829,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) + + free(screen); + +- LogMessage(X_ERROR, "AIGLX: reverting to software rendering\n"); ++ LogMessage(from, "AIGLX: reverting to software rendering\n"); + + return NULL; + } +--- a/hw/xfree86/common/xf86pciBus.c ++++ b/hw/xfree86/common/xf86pciBus.c +@@ -1123,7 +1123,25 @@ videoPtrToDriverList(struct pci_device * + break; + case 0x102b: driverList[0] = "mga"; break; + case 0x10c8: driverList[0] = "neomagic"; break; +- case 0x10de: case 0x12d2: driverList[0] = "nv"; break; ++ case 0x10de: case 0x12d2: ++ switch (dev->device_id) { ++ /* NV1 */ ++ case 0x0008: ++ case 0x0009: ++ driverList[0] = "vesa"; ++ break; ++ /* NV3 */ ++ case 0x0018: ++ case 0x0019: ++ driverList[0] = "nv"; ++ break; ++ default: ++ driverList[0] = "nouveau"; ++ driverList[1] = "nv"; ++ driverList[2] = "nvidia"; ++ break; ++ } ++ break; + case 0x1106: driverList[0] = "openchrome"; break; + case 0x1b36: driverList[0] = "qxl"; break; + case 0x1163: driverList[0] = "rendition"; break; diff --git a/testing/xorg-server/bg-none-revert.patch b/testing/xorg-server/bg-none-revert.patch new file mode 100644 index 000000000..1a38f1f41 --- /dev/null +++ b/testing/xorg-server/bg-none-revert.patch @@ -0,0 +1,58 @@ +From 3bc6ed2d8c9028ec28015d05b60af67a194f3694 Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 29 Mar 2011 14:09:46 +0000 +Subject: Revert "composite: Don't backfill non-bg-None windows" + +This reverts commit 6dd775f57d2f94f0ddaee324aeec33b9b66ed5bc. + +Bugzilla: https://bugs.freedesktop.org/34427 + +Acked-by: Alex Deucher +Signed-off-by: Adam Jackson +--- +diff --git a/composite/compalloc.c b/composite/compalloc.c +index e4064f6..7164c0d 100644 +--- a/composite/compalloc.c ++++ b/composite/compalloc.c +@@ -508,17 +508,6 @@ compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin) + return Success; + } + +-static int +-bgNoneVisitWindow(WindowPtr pWin, void *null) +-{ +- if (pWin->backgroundState != BackgroundPixmap) +- return WT_WALKCHILDREN; +- if (pWin->background.pixmap != None) +- return WT_WALKCHILDREN; +- +- return WT_STOPWALKING; +-} +- + static PixmapPtr + compNewPixmap (WindowPtr pWin, int x, int y, int w, int h, Bool map) + { +@@ -539,21 +528,6 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h, Bool map) + if (!map) + return pPixmap; + +- /* +- * If there's no bg=None in the tree, we're done. +- * +- * We could optimize this more by collection the regions of all the +- * bg=None subwindows and feeding that in as the clip for the +- * CopyArea below, but since window trees are shallow these days it +- * might not be worth the effort. +- */ +- if (TraverseTree(pWin, bgNoneVisitWindow, NULL) == WT_NOMATCH) +- return pPixmap; +- +- /* +- * Copy bits from the parent into the new pixmap so that it will +- * have "reasonable" contents in case for background None areas. +- */ + if (pParent->drawable.depth == pWin->drawable.depth) + { + GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen); +-- +cgit v0.8.3-6-g21f6 diff --git a/testing/xorg-server/git-fixes.patch b/testing/xorg-server/git-fixes.patch new file mode 100644 index 000000000..3eadd81ba --- /dev/null +++ b/testing/xorg-server/git-fixes.patch @@ -0,0 +1,318 @@ +From 613e0e9ef74c4542ed458200165adbcdfdf3cd17 Mon Sep 17 00:00:00 2001 +From: Jeremy Huddleston +Date: Wed, 13 Apr 2011 18:51:30 +0000 +Subject: Send events that were missing from RRSelectInput + +The RANDR spec (randrproto.txt) specifies that RRSelectInput will send out +events corresponding to the event mask, if there have been changes to +CRTCs or outputs. Only screen events were being generated, however. + +Fixes http://bugs.freedesktop.org/21760 + +Signed-off-by: Federico Mena Quintero +Reviewd-by: Keith Packard +Signed-off-by: Keith Packard +(cherry picked from commit b2997431fd426ab318bc5dfd2cd43956d733ebec) +--- +diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c +index ac4d2ac..2135504 100644 +--- a/randr/rrdispatch.c ++++ b/randr/rrdispatch.c +@@ -146,7 +146,7 @@ ProcRRSelectInput (ClientPtr client) + /* + * Now see if the client needs an event + */ +- if (pScrPriv && (pRREvent->mask & RRScreenChangeNotifyMask)) ++ if (pScrPriv) + { + pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum]; + if (CompareTimeStamps (pTimes->setTime, +@@ -154,7 +154,35 @@ ProcRRSelectInput (ClientPtr client) + CompareTimeStamps (pTimes->configTime, + pScrPriv->lastConfigTime) != 0) + { +- RRDeliverScreenEvent (client, pWin, pScreen); ++ if (pRREvent->mask & RRScreenChangeNotifyMask) ++ { ++ RRDeliverScreenEvent (client, pWin, pScreen); ++ } ++ ++ if (pRREvent->mask & RRCrtcChangeNotifyMask) ++ { ++ int i; ++ ++ for (i = 0; i < pScrPriv->numCrtcs; i++) ++ { ++ RRDeliverCrtcEvent (client, pWin, pScrPriv->crtcs[i]); ++ } ++ } ++ ++ if (pRREvent->mask & RROutputChangeNotifyMask) ++ { ++ int i; ++ ++ for (i = 0; i < pScrPriv->numOutputs; i++) ++ { ++ RRDeliverOutputEvent (client, pWin, pScrPriv->outputs[i]); ++ } ++ } ++ ++ /* We don't check for RROutputPropertyNotifyMask, as randrproto.txt doesn't ++ * say if there ought to be notifications of changes to output properties ++ * if those changes occurred before the time RRSelectInput is called. ++ */ + } + } + } +-- +cgit v0.8.3-6-g21f6 +From 50b9d3142ff90af2f7fa35b7b1bf9e5a07723dbd Mon Sep 17 00:00:00 2001 +From: Aaron Plattner +Date: Tue, 24 May 2011 23:02:42 +0000 +Subject: randr: check rotated virtual size limits correctly + +Commit d1107918d4626268803b54033a07405122278e7f introduced checks to +the RandR path that cause RRSetScreenConfig requests to fail if the +size is too large. Unfortunately, when RandR 1.1 rotation is enabled +it compares the rotated screen dimensions to the unrotated limits, +which causes 90- and 270-degree rotation to fail unless your screen +happens to be square: + + X Error of failed request: BadValue (integer parameter out of range for operation) + Major opcode of failed request: 153 (RANDR) + Minor opcode of failed request: 2 (RRSetScreenConfig) + Value in failed request: 0x780 + Serial number of failed request: 14 + Current serial number in output stream: 14 + +Fix this by moving the check above the code that swaps the dimensions +based on the rotation. + +Signed-off-by: Aaron Plattner +Reviewed-by: Jeremy Huddleston +Tested-by: Robert Hooker +Tested-by: Kent Baxley +Signed-off-by: Keith Packard +(cherry picked from commit b6c7b9b2f39e970cedb6bc1e073f901e28cb0fa3) +--- +diff --git a/randr/rrscreen.c b/randr/rrscreen.c +index 1bc1a9e..da6d48d 100644 +--- a/randr/rrscreen.c ++++ b/randr/rrscreen.c +@@ -910,12 +910,6 @@ ProcRRSetScreenConfig (ClientPtr client) + */ + width = mode->mode.width; + height = mode->mode.height; +- if (rotation & (RR_Rotate_90|RR_Rotate_270)) +- { +- width = mode->mode.height; +- height = mode->mode.width; +- } +- + if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) { + client->errorValue = width; + free(pData); +@@ -927,6 +921,12 @@ ProcRRSetScreenConfig (ClientPtr client) + return BadValue; + } + ++ if (rotation & (RR_Rotate_90|RR_Rotate_270)) ++ { ++ width = mode->mode.height; ++ height = mode->mode.width; ++ } ++ + if (width != pScreen->width || height != pScreen->height) + { + int c; +-- +cgit v0.8.3-6-g21f6 +From 4bfb22e7667c4cd55da5e7a31af29ce5769ecc65 Mon Sep 17 00:00:00 2001 +From: Aaron Plattner +Date: Mon, 18 Apr 2011 15:23:48 +0000 +Subject: linux: Retry VT ioctls while errno == EINTR + +When the smart scheduler is enabled, the VT ioctls (particularly +VT_WAITACTIVE) can be interrupted by the smart scheduler's SIGALRMs. +Previously, this caused the server to immediately continue on to +ScreenInit, almost certainly causing a crash or failure because the X +server that owned the VT hadn't finished cleaning up. As of commit +7ee965a300c9eddcc1acacf9414cfe3e589222a8, it causes a FatalError +instead. + +Retrying the ioctl as long as it fails with errno == EINTR fixes the +problem and allows server regenerations to trigger VT switches that +actually succeed. + +Signed-off-by: Aaron Plattner +Reviewed-by: Peter Hutterer +Reviewed-by: Cyril Brulebois +Signed-off-by: Keith Packard +(cherry picked from commit 88c4622b594a1725d0cee86bc82ad640d241c520) +--- +diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c +index 9c71a42..77dfb2f 100644 +--- a/hw/xfree86/os-support/linux/lnx_init.c ++++ b/hw/xfree86/os-support/linux/lnx_init.c +@@ -62,17 +62,21 @@ drain_console(int fd, void *closure) + static void + switch_to(int vt, const char *from) + { +- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt) < 0) +- FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno)); ++ int ret; + +- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt) < 0) +- FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno)); ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt)); ++ if (ret < 0) ++ FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno)); ++ ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt)); ++ if (ret < 0) ++ FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno)); + } + + void + xf86OpenConsole(void) + { +- int i, fd = -1; ++ int i, fd = -1, ret; + struct vt_mode VT; + struct vt_stat vts; + MessageType from = X_PROBED; +@@ -107,17 +111,19 @@ xf86OpenConsole(void) + + if (ShareVTs) + { +- if (ioctl(fd, VT_GETSTATE, &vts) == 0) +- xf86Info.vtno = vts.v_active; +- else +- FatalError("xf86OpenConsole: Cannot find the current" +- " VT (%s)\n", strerror(errno)); ++ SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts)); ++ if (ret < 0) ++ FatalError("xf86OpenConsole: Cannot find the current" ++ " VT (%s)\n", strerror(errno)); ++ xf86Info.vtno = vts.v_active; + } else { +- if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || +- (xf86Info.vtno == -1)) +- FatalError("xf86OpenConsole: Cannot find a free VT: %s\n", +- strerror(errno)); +- } ++ SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno)); ++ if (ret < 0) ++ FatalError("xf86OpenConsole: Cannot find a free VT: " ++ "%s\n", strerror(errno)); ++ if (xf86Info.vtno == -1) ++ FatalError("xf86OpenConsole: Cannot find a free VT\n"); ++ } + close(fd); + } + +@@ -159,7 +165,8 @@ xf86OpenConsole(void) + * Linux doesn't switch to an active vt after the last close of a vt, + * so we do this ourselves by remembering which is active now. + */ +- if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0) ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts)); ++ if (ret < 0) + xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n", + strerror(errno)); + else +@@ -171,7 +178,7 @@ xf86OpenConsole(void) + * Detach from the controlling tty to avoid char loss + */ + if ((i = open("/dev/tty",O_RDWR)) >= 0) { +- ioctl(i, TIOCNOTTY, 0); ++ SYSCALL(ioctl(i, TIOCNOTTY, 0)); + close(i); + } + } +@@ -186,9 +193,10 @@ xf86OpenConsole(void) + */ + switch_to(xf86Info.vtno, "xf86OpenConsole"); + +- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) +- FatalError("xf86OpenConsole: VT_GETMODE failed %s\n", +- strerror(errno)); ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT)); ++ if (ret < 0) ++ FatalError("xf86OpenConsole: VT_GETMODE failed %s\n", ++ strerror(errno)); + + signal(SIGUSR1, xf86VTRequest); + +@@ -196,20 +204,23 @@ xf86OpenConsole(void) + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + +- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) +- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n", ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT)); ++ if (ret < 0) ++ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n", + strerror(errno)); +- +- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) +- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n", +- strerror(errno)); ++ ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS)); ++ if (ret < 0) ++ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n", ++ strerror(errno)); + + tcgetattr(xf86Info.consoleFd, &tty_attr); +- ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode); ++ SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode)); + +- if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0) +- FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n", +- strerror(errno)); ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW)); ++ if (ret < 0) ++ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n", ++ strerror(errno)); + + nTty = tty_attr; + nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); +@@ -241,6 +252,7 @@ void + xf86CloseConsole(void) + { + struct vt_mode VT; ++ int ret; + + if (ShareVTs) { + close(xf86Info.consoleFd); +@@ -253,20 +265,23 @@ xf86CloseConsole(void) + }; + + /* Back to text mode ... */ +- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0) ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT)); ++ if (ret < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n", + strerror(errno)); + +- ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode); ++ SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode)); + tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr); + +- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT)); ++ if (ret < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n", + strerror(errno)); + else { + /* set dflt vt handling */ + VT.mode = VT_AUTO; +- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) ++ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT)); ++ if (ret < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n", + strerror(errno)); + } +-- +cgit v0.8.3-6-g21f6 diff --git a/testing/xorg-server/xorg-redhat-die-ugly-pattern-die-die-die.patch b/testing/xorg-server/xorg-redhat-die-ugly-pattern-die-die-die.patch new file mode 100644 index 000000000..4e782f1c6 --- /dev/null +++ b/testing/xorg-server/xorg-redhat-die-ugly-pattern-die-die-die.patch @@ -0,0 +1,16 @@ +Remove the default root window grey stipple pattern, replacing it with +blackness. + +--- xc/programs/Xserver/dix/window.c.die-ugly-pattern-die-die-die Tue Feb 12 16:33:04 2002 ++++ xc/programs/Xserver/dix/window.c Tue Feb 12 16:45:32 2002 +@@ -119,8 +119,8 @@ + * + ******/ + +-static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11}; +-static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88}; ++static unsigned char _back_lsb[4] = {0x00, 0x00, 0x00, 0x00}; ++static unsigned char _back_msb[4] = {0x00, 0x00, 0x00, 0x00}; + + int screenIsSaved = SCREEN_SAVER_OFF; + diff --git a/testing/xorg-server/xserver-1.10-pointer-barriers.patch b/testing/xorg-server/xserver-1.10-pointer-barriers.patch new file mode 100644 index 000000000..099565436 --- /dev/null +++ b/testing/xorg-server/xserver-1.10-pointer-barriers.patch @@ -0,0 +1,1054 @@ +From 14f1112bec18ccece8e732fe6c200a56546230c7 Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Thu, 17 Mar 2011 13:56:17 -0400 +Subject: [PATCH] CRTC confine and pointer barriers + +--- + dix/events.c | 7 + + dix/getevents.c | 12 +- + include/dix.h | 1 + + include/protocol-versions.h | 2 +- + mi/mipointer.c | 16 ++- + mi/mipointer.h | 6 + + randr/randr.c | 2 + + randr/randrstr.h | 4 + + randr/rrcrtc.c | 155 ++++++++++++++++ + test/Makefile.am | 4 +- + xfixes/cursor.c | 408 ++++++++++++++++++++++++++++++++++++++++++- + xfixes/xfixes.c | 24 ++- + xfixes/xfixes.h | 17 ++ + xfixes/xfixesint.h | 16 ++ + 14 files changed, 658 insertions(+), 16 deletions(-) + +diff --git a/dix/events.c b/dix/events.c +index 07f8b05..d2be84f 100644 +--- a/dix/events.c ++++ b/dix/events.c +@@ -328,6 +328,13 @@ IsMaster(DeviceIntPtr dev) + return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD; + } + ++Bool ++IsFloating(DeviceIntPtr dev) ++{ ++ return GetMaster(dev, MASTER_KEYBOARD) == NULL; ++} ++ ++ + /** + * Max event opcode. + */ +diff --git a/dix/getevents.c b/dix/getevents.c +index 794df42..c66e516 100644 +--- a/dix/getevents.c ++++ b/dix/getevents.c +@@ -812,7 +812,11 @@ accelPointer(DeviceIntPtr dev, int first, int num, int *valuators, CARD32 ms) + * miPointerSetPosition() and then scale back into device coordinates (if + * needed). miPSP will change x/y if the screen was crossed. + * ++ * The coordinates provided are always absolute. The parameter mode whether ++ * it was relative or absolute movement that landed us at those coordinates. ++ * + * @param dev The device to be moved. ++ * @param mode Movement mode (Absolute or Relative) + * @param x Pointer to current x-axis value, may be modified. + * @param y Pointer to current y-axis value, may be modified. + * @param x_frac Fractional part of current x-axis value, may be modified. +@@ -824,7 +828,8 @@ accelPointer(DeviceIntPtr dev, int first, int num, int *valuators, CARD32 ms) + * @param screeny_frac Fractional part of screen y coordinate, as above. + */ + static void +-positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac, ++positionSprite(DeviceIntPtr dev, int mode, ++ int *x, int *y, float x_frac, float y_frac, + ScreenPtr scr, int *screenx, int *screeny, float *screenx_frac, float *screeny_frac) + { + int old_screenx, old_screeny; +@@ -863,7 +868,7 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac, + old_screeny = *screeny; + /* This takes care of crossing screens for us, as well as clipping + * to the current screen. */ +- miPointerSetPosition(dev, screenx, screeny); ++ _miPointerSetPosition(dev, mode, screenx, screeny); + + if (dev->u.master) { + dev->u.master->last.valuators[0] = *screenx; +@@ -1193,7 +1198,8 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons, + + set_raw_valuators(raw, &mask, raw->valuators.data); + +- positionSprite(pDev, &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac); ++ positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, ++ &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac); + updateHistory(pDev, &mask, ms); + + /* Update the valuators with the true value sent to the client*/ +diff --git a/include/dix.h b/include/dix.h +index 12e4b59..3f99098 100644 +--- a/include/dix.h ++++ b/include/dix.h +@@ -570,6 +570,7 @@ extern Bool _X_EXPORT IsPointerDevice( DeviceIntPtr dev); + extern Bool _X_EXPORT IsKeyboardDevice(DeviceIntPtr dev); + extern Bool IsPointerEvent(InternalEvent *event); + extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev); ++extern _X_EXPORT Bool IsFloating(DeviceIntPtr dev); + + extern _X_HIDDEN void CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master); + extern _X_HIDDEN int CorePointerProc(DeviceIntPtr dev, int what); +diff --git a/include/protocol-versions.h b/include/protocol-versions.h +index 1d33bdd..1dc66ad 100644 +--- a/include/protocol-versions.h ++++ b/include/protocol-versions.h +@@ -126,7 +126,7 @@ + #define SERVER_XF86VIDMODE_MINOR_VERSION 2 + + /* Fixes */ +-#define SERVER_XFIXES_MAJOR_VERSION 4 ++#define SERVER_XFIXES_MAJOR_VERSION 5 + #define SERVER_XFIXES_MINOR_VERSION 0 + + /* X Input */ +diff --git a/mi/mipointer.c b/mi/mipointer.c +index 554397a..85f1949 100644 +--- a/mi/mipointer.c ++++ b/mi/mipointer.c +@@ -229,6 +229,10 @@ miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen, + SetupScreen (pScreen); + + GenerateEvent = generateEvent; ++ ++ if (pScreen->ConstrainCursorHarder) ++ pScreen->ConstrainCursorHarder(pDev, pScreen, Absolute, &x, &y); ++ + /* device dependent - must pend signal and call miPointerWarpCursor */ + (*pScreenPriv->screenFuncs->WarpCursor) (pDev, pScreen, x, y); + if (!generateEvent) +@@ -484,7 +488,7 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, + } + + void +-miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y) ++_miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) + { + miPointerScreenPtr pScreenPriv; + ScreenPtr pScreen; +@@ -529,6 +533,9 @@ miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y) + if (*y >= pPointer->limits.y2) + *y = pPointer->limits.y2 - 1; + ++ if (pScreen->ConstrainCursorHarder) ++ pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y); ++ + if (pPointer->x == *x && pPointer->y == *y && + pPointer->pScreen == pScreen) + return; +@@ -536,6 +543,13 @@ miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y) + miPointerMoveNoEvent(pDev, pScreen, *x, *y); + } + ++/* ABI hack */ ++void ++miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y) ++{ ++ _miPointerSetPosition(pDev, Absolute, x, y); ++} ++ + void + miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y) + { +diff --git a/mi/mipointer.h b/mi/mipointer.h +index 3c86110..6b6010c 100644 +--- a/mi/mipointer.h ++++ b/mi/mipointer.h +@@ -131,6 +131,12 @@ extern _X_EXPORT void miPointerGetPosition( + + /* Moves the cursor to the specified position. May clip the co-ordinates: + * x and y are modified in-place. */ ++extern _X_EXPORT void _miPointerSetPosition( ++ DeviceIntPtr pDev, ++ int mode, ++ int *x, ++ int *y); ++ + extern _X_EXPORT void miPointerSetPosition( + DeviceIntPtr pDev, + int *x, +diff --git a/randr/randr.c b/randr/randr.c +index 6077705..d337129 100644 +--- a/randr/randr.c ++++ b/randr/randr.c +@@ -270,6 +270,8 @@ Bool RRScreenInit(ScreenPtr pScreen) + + wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen); + ++ pScreen->ConstrainCursorHarder = RRConstrainCursorHarder; ++ + pScrPriv->numOutputs = 0; + pScrPriv->outputs = NULL; + pScrPriv->numCrtcs = 0; +diff --git a/randr/randrstr.h b/randr/randrstr.h +index 7ea6080..d8dd37d 100644 +--- a/randr/randrstr.h ++++ b/randr/randrstr.h +@@ -297,6 +297,7 @@ typedef struct _rrScrPriv { + int rate; + int size; + #endif ++ Bool discontiguous; + } rrScrPrivRec, *rrScrPrivPtr; + + extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec; +@@ -700,6 +701,9 @@ ProcRRGetPanning (ClientPtr client); + int + ProcRRSetPanning (ClientPtr client); + ++void ++RRConstrainCursorHarder (DeviceIntPtr, ScreenPtr, int, int *, int *); ++ + /* rrdispatch.c */ + extern _X_EXPORT Bool + RRClientKnowsRates (ClientPtr pClient); +diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c +index 98206a2..d4d8f2a 100644 +--- a/randr/rrcrtc.c ++++ b/randr/rrcrtc.c +@@ -1,5 +1,6 @@ + /* + * Copyright © 2006 Keith Packard ++ * Copyright 2010 Red Hat, Inc + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that +@@ -22,6 +23,7 @@ + + #include "randrstr.h" + #include "swaprep.h" ++#include "mipointer.h" + + RESTYPE RRCrtcType; + +@@ -292,6 +294,92 @@ RRCrtcPendingProperties (RRCrtcPtr crtc) + return FALSE; + } + ++static void ++crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom) ++{ ++ *left = crtc->x; ++ *top = crtc->y; ++ ++ switch (crtc->rotation) { ++ case RR_Rotate_0: ++ case RR_Rotate_180: ++ default: ++ *right = crtc->x + crtc->mode->mode.width; ++ *bottom = crtc->y + crtc->mode->mode.height; ++ return; ++ case RR_Rotate_90: ++ case RR_Rotate_270: ++ *right = crtc->x + crtc->mode->mode.height; ++ *bottom = crtc->y + crtc->mode->mode.width; ++ return; ++ } ++} ++ ++/* overlapping counts as adjacent */ ++static Bool ++crtcs_adjacent(const RRCrtcPtr a, const RRCrtcPtr b) ++{ ++ /* left, right, top, bottom... */ ++ int al, ar, at, ab; ++ int bl, br, bt, bb; ++ int cl, cr, ct, cb; /* the overlap, if any */ ++ ++ crtc_bounds(a, &al, &ar, &at, &ab); ++ crtc_bounds(b, &bl, &br, &bt, &bb); ++ ++ cl = max(al, bl); ++ cr = min(ar, br); ++ ct = max(at, bt); ++ cb = min(ab, bb); ++ ++ return (cl <= cr) && (ct <= cb); ++} ++ ++/* Depth-first search and mark all CRTCs reachable from cur */ ++static void ++mark_crtcs (rrScrPrivPtr pScrPriv, int *reachable, int cur) ++{ ++ int i; ++ reachable[cur] = TRUE; ++ for (i = 0; i < pScrPriv->numCrtcs; ++i) { ++ if (reachable[i] || !pScrPriv->crtcs[i]->mode) ++ continue; ++ if (crtcs_adjacent(pScrPriv->crtcs[cur], pScrPriv->crtcs[i])) ++ mark_crtcs(pScrPriv, reachable, i); ++ } ++} ++ ++static void ++RRComputeContiguity (ScreenPtr pScreen) ++{ ++ rrScrPriv(pScreen); ++ Bool discontiguous = TRUE; ++ int i, n = pScrPriv->numCrtcs; ++ ++ int *reachable = calloc(n, sizeof(int)); ++ if (!reachable) ++ goto out; ++ ++ /* Find first enabled CRTC and start search for reachable CRTCs from it */ ++ for (i = 0; i < n; ++i) { ++ if (pScrPriv->crtcs[i]->mode) { ++ mark_crtcs(pScrPriv, reachable, i); ++ break; ++ } ++ } ++ ++ /* Check that all enabled CRTCs were marked as reachable */ ++ for (i = 0; i < n; ++i) ++ if (pScrPriv->crtcs[i]->mode && !reachable[i]) ++ goto out; ++ ++ discontiguous = FALSE; ++ ++out: ++ free(reachable); ++ pScrPriv->discontiguous = discontiguous; ++} ++ + /* + * Request that the Crtc be reconfigured + */ +@@ -306,6 +394,7 @@ RRCrtcSet (RRCrtcPtr crtc, + { + ScreenPtr pScreen = crtc->pScreen; + Bool ret = FALSE; ++ Bool recompute = TRUE; + rrScrPriv(pScreen); + + /* See if nothing changed */ +@@ -318,6 +407,7 @@ RRCrtcSet (RRCrtcPtr crtc, + !RRCrtcPendingProperties (crtc) && + !RRCrtcPendingTransform (crtc)) + { ++ recompute = FALSE; + ret = TRUE; + } + else +@@ -381,6 +471,10 @@ RRCrtcSet (RRCrtcPtr crtc, + RRPostPendingProperties (outputs[o]); + } + } ++ ++ if (recompute) ++ RRComputeContiguity(pScreen); ++ + return ret; + } + +@@ -1349,3 +1443,64 @@ ProcRRGetCrtcTransform (ClientPtr client) + free(reply); + return Success; + } ++ ++void ++RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, int *y) ++{ ++ rrScrPriv (pScreen); ++ int i; ++ ++ /* intentional dead space -> let it float */ ++ if (pScrPriv->discontiguous) ++ return; ++ ++ /* if we're moving inside a crtc, we're fine */ ++ for (i = 0; i < pScrPriv->numCrtcs; i++) { ++ RRCrtcPtr crtc = pScrPriv->crtcs[i]; ++ ++ int left, right, top, bottom; ++ ++ if (!crtc->mode) ++ continue; ++ ++ crtc_bounds(crtc, &left, &right, &top, &bottom); ++ ++ if ((*x >= left) && (*x <= right) && (*y >= top) && (*y <= bottom)) ++ return; ++ } ++ ++ /* if we're trying to escape, clamp to the CRTC we're coming from */ ++ for (i = 0; i < pScrPriv->numCrtcs; i++) { ++ RRCrtcPtr crtc = pScrPriv->crtcs[i]; ++ int nx, ny; ++ int left, right, top, bottom; ++ ++ if (!crtc->mode) ++ continue; ++ ++ crtc_bounds(crtc, &left, &right, &top, &bottom); ++ miPointerGetPosition(pDev, &nx, &ny); ++ ++ if ((nx >= left) && (nx <= right) && (ny >= top) && (ny <= bottom)) { ++ if ((*x <= left) || (*x >= right)) { ++ int dx = *x - nx; ++ ++ if (dx > 0) ++ *x = right; ++ else if (dx < 0) ++ *x = left; ++ } ++ ++ if ((*y <= top) || (*y >= bottom)) { ++ int dy = *y - ny; ++ ++ if (dy > 0) ++ *y = bottom; ++ else if (dy < 0) ++ *y = top; ++ } ++ ++ return; ++ } ++ } ++} +diff --git a/test/Makefile.am b/test/Makefile.am +index 456221e..ccdb859 100644 +--- a/test/Makefile.am ++++ b/test/Makefile.am +@@ -1,6 +1,6 @@ + if UNITTESTS + SUBDIRS= . xi2 +-check_PROGRAMS = xkb input xtest ++check_PROGRAMS = xkb input xtest list fixes + check_LTLIBRARIES = libxservertest.la + + TESTS=$(check_PROGRAMS) +@@ -16,6 +16,8 @@ endif + xkb_LDADD=$(TEST_LDADD) + input_LDADD=$(TEST_LDADD) + xtest_LDADD=$(TEST_LDADD) ++list_LDADD=$(TEST_LDADD) ++fixes_LDADD=$(TEST_LDADD) + + libxservertest_la_LIBADD = \ + $(XSERVER_LIBS) \ +diff --git a/xfixes/cursor.c b/xfixes/cursor.c +index fb608f6..5c55c95 100644 +--- a/xfixes/cursor.c ++++ b/xfixes/cursor.c +@@ -1,5 +1,6 @@ + /* + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. ++ * Copyright 2010 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), +@@ -50,13 +51,16 @@ + #include "cursorstr.h" + #include "dixevents.h" + #include "servermd.h" ++#include "mipointer.h" + #include "inputstr.h" + #include "windowstr.h" + #include "xace.h" ++#include "list.h" + + static RESTYPE CursorClientType; + static RESTYPE CursorHideCountType; + static RESTYPE CursorWindowType; ++RESTYPE PointerBarrierType; + static CursorPtr CursorCurrent[MAXDEVICES]; + + static DevPrivateKeyRec CursorScreenPrivateKeyRec; +@@ -107,6 +111,14 @@ typedef struct _CursorHideCountRec { + XID resource; + } CursorHideCountRec; + ++typedef struct PointerBarrierClient *PointerBarrierClientPtr; ++ ++struct PointerBarrierClient { ++ ScreenPtr screen; ++ struct PointerBarrier barrier; ++ struct list entry; ++}; ++ + /* + * Wrap DisplayCursor to catch cursor change events + */ +@@ -114,7 +126,9 @@ typedef struct _CursorHideCountRec { + typedef struct _CursorScreen { + DisplayCursorProcPtr DisplayCursor; + CloseScreenProcPtr CloseScreen; ++ ConstrainCursorHarderProcPtr ConstrainCursorHarder; + CursorHideCountPtr pCursorHideCounts; ++ struct list barriers; + } CursorScreenRec, *CursorScreenPtr; + + #define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey)) +@@ -184,9 +198,11 @@ CursorCloseScreen (int index, ScreenPtr pScreen) + Bool ret; + CloseScreenProcPtr close_proc; + DisplayCursorProcPtr display_proc; ++ ConstrainCursorHarderProcPtr constrain_proc; + + Unwrap (cs, pScreen, CloseScreen, close_proc); + Unwrap (cs, pScreen, DisplayCursor, display_proc); ++ Unwrap (cs, pScreen, ConstrainCursorHarder, constrain_proc); + deleteCursorHideCountsForScreen(pScreen); + ret = (*pScreen->CloseScreen) (index, pScreen); + free(cs); +@@ -1029,6 +1045,391 @@ CursorFreeWindow (pointer data, XID id) + return 1; + } + ++static BOOL ++barrier_is_horizontal(const struct PointerBarrier *barrier) ++{ ++ return barrier->y1 == barrier->y2; ++} ++ ++static BOOL ++barrier_is_vertical(const struct PointerBarrier *barrier) ++{ ++ return barrier->x1 == barrier->x2; ++} ++ ++/** ++ * @return The set of barrier movement directions the movement vector ++ * x1/y1 → x2/y2 represents. ++ */ ++int ++barrier_get_direction(int x1, int y1, int x2, int y2) ++{ ++ int direction = 0; ++ ++ /* which way are we trying to go */ ++ if (x2 > x1) ++ direction |= BarrierPositiveX; ++ if (x2 < x1) ++ direction |= BarrierNegativeX; ++ if (y2 > y1) ++ direction |= BarrierPositiveY; ++ if (y2 < y1) ++ direction |= BarrierNegativeY; ++ ++ return direction; ++} ++ ++/** ++ * Test if the barrier may block movement in the direction defined by ++ * x1/y1 → x2/y2. This function only tests whether the directions could be ++ * blocked, it does not test if the barrier actually blocks the movement. ++ * ++ * @return TRUE if the barrier blocks the direction of movement or FALSE ++ * otherwise. ++ */ ++BOOL ++barrier_is_blocking_direction(const struct PointerBarrier *barrier, int direction) ++{ ++ /* Barriers define which way is ok, not which way is blocking */ ++ return (barrier->directions & direction) != direction; ++} ++ ++/** ++ * Test if the movement vector x1/y1 → x2/y2 is intersecting with the ++ * barrier. A movement vector with the startpoint or endpoint on the barrier ++ * itself counts as intersecting. ++ * ++ * @param x1 X start coordinate of movement vector ++ * @param y1 Y start coordinate of movement vector ++ * @param x2 X end coordinate of movement vector ++ * @param y2 Y end coordinate of movement vector ++ * @param[out] distance The distance between the start point and the ++ * intersection with the barrier (if applicable). ++ * @return TRUE if the barrier intersects with the given vector ++ */ ++BOOL ++barrier_is_blocking(const struct PointerBarrier *barrier, ++ int x1, int y1, int x2, int y2, ++ double *distance) ++{ ++ BOOL rc = FALSE; ++ float ua, ub, ud; ++ int dir = barrier_get_direction(x1, y1, x2, y2); ++ ++ /* Algorithm below doesn't handle edge cases well, hence the extra ++ * checks. */ ++ if (barrier_is_vertical(barrier)) { ++ /* handle immediate barrier adjacency, moving away */ ++ if (dir & BarrierPositiveX && x1 == barrier->x1) ++ return FALSE; ++ if (dir & BarrierNegativeX && x1 == (barrier->x1 - 1)) ++ return FALSE; ++ /* startpoint on barrier */ ++ if (x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) { ++ *distance = 0; ++ return TRUE; ++ } ++ /* endpoint on barrier */ ++ if (x2 == barrier->x1 && y2 >= barrier->y1 && y2 <= barrier->y2) { ++ *distance = abs(x2 - x1); ++ return TRUE; ++ } ++ } else { ++ /* handle immediate barrier adjacency, moving away */ ++ if (dir & BarrierPositiveY && y1 == barrier->y1) ++ return FALSE; ++ if (dir & BarrierNegativeY && y1 == (barrier->y1 - 1)) ++ return FALSE; ++ /* startpoint on barrier */ ++ if (y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) { ++ *distance = 0; ++ return TRUE; ++ } ++ /* endpoint on barrier */ ++ if (y2 == barrier->y1 && x2 >= barrier->x1 && x2 <= barrier->x2) { ++ *distance = abs(y2 - y1); ++ return TRUE; ++ } ++ } ++ ++ /* not an edge case, compute distance */ ++ ua = 0; ++ ud = (barrier->y2 - barrier->y1) * (x2 - x1) - (barrier->x2 - barrier->x1) * (y2 - y1); ++ if (ud != 0) { ++ ua = ((barrier->x2 - barrier->x1) * (y1 - barrier->y1) - ++ (barrier->y2 - barrier->y1) * (x1 - barrier->x1)) / ud; ++ ub = ((x2 - x1) * (y1 - barrier->y1) - ++ (y2 - y1) * (x1 - barrier->x1)) / ud; ++ if (ua < 0 || ua > 1 || ub < 0 || ub > 1) ++ ua = 0; ++ } ++ ++ if (ua > 0 && ua <= 1) ++ { ++ double ix = barrier->x1 + ua * (barrier->x2 - barrier->x1); ++ double iy = barrier->y1 + ua * (barrier->y2 - barrier->y1); ++ ++ *distance = sqrt(pow(x1 - ix, 2) + pow(y1 - iy, 2)); ++ rc = TRUE; ++ } ++ ++ return rc; ++} ++ ++/** ++ * Find the nearest barrier that is blocking movement from x1/y1 to x2/y2. ++ * ++ * @param dir Only barriers blocking movement in direction dir are checked ++ * @param x1 X start coordinate of movement vector ++ * @param y1 Y start coordinate of movement vector ++ * @param x2 X end coordinate of movement vector ++ * @param y2 Y end coordinate of movement vector ++ * @return The barrier nearest to the movement origin that blocks this movement. ++ */ ++static struct PointerBarrier* ++barrier_find_nearest(CursorScreenPtr cs, int dir, ++ int x1, int y1, int x2, int y2) ++{ ++ struct PointerBarrierClient *c; ++ struct PointerBarrier *nearest = NULL; ++ double min_distance = INT_MAX; /* can't get higher than that in X anyway */ ++ ++ list_for_each_entry(c, &cs->barriers, entry) { ++ struct PointerBarrier *b = &c->barrier; ++ double distance; ++ ++ if (!barrier_is_blocking_direction(b, dir)) ++ continue; ++ ++ if (barrier_is_blocking(b, x1, y1, x2, y2, &distance)) ++ { ++ if (min_distance > distance) ++ { ++ min_distance = distance; ++ nearest = b; ++ } ++ } ++ } ++ ++ return nearest; ++} ++ ++/** ++ * Clamp to the given barrier given the movement direction specified in dir. ++ * ++ * @param barrier The barrier to clamp to ++ * @param dir The movement direction ++ * @param[out] x The clamped x coordinate. ++ * @param[out] y The clamped x coordinate. ++ */ ++void ++barrier_clamp_to_barrier(struct PointerBarrier *barrier, int dir, int *x, int *y) ++{ ++ if (barrier_is_vertical(barrier)) { ++ if ((dir & BarrierNegativeX) & ~barrier->directions) ++ *x = barrier->x1; ++ if ((dir & BarrierPositiveX) & ~barrier->directions) ++ *x = barrier->x1 - 1; ++ } ++ if (barrier_is_horizontal(barrier)) ++ { ++ if ((dir & BarrierNegativeY) & ~barrier->directions) ++ *y = barrier->y1; ++ if ((dir & BarrierPositiveY) & ~barrier->directions) ++ *y = barrier->y1 - 1; ++ } ++} ++ ++static void ++CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, int *x, int *y) ++{ ++ CursorScreenPtr cs = GetCursorScreen(screen); ++ ++ if (!list_is_empty(&cs->barriers) && !IsFloating(dev) && mode == Relative) { ++ int ox, oy; ++ int dir; ++ struct PointerBarrier *nearest = NULL; ++ ++ /* where are we coming from */ ++ miPointerGetPosition(dev, &ox, &oy); ++ ++ /* How this works: ++ * Given the origin and the movement vector, get the nearest barrier ++ * to the origin that is blocking the movement. ++ * Clamp to that barrier. ++ * Then, check from the clamped position to the original ++ * destination, again finding the nearest barrier and clamping. ++ */ ++ dir = barrier_get_direction(ox, oy, *x, *y); ++ ++ nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y); ++ if (nearest) { ++ barrier_clamp_to_barrier(nearest, dir, x, y); ++ ++ if (barrier_is_vertical(nearest)) { ++ dir &= ~(BarrierNegativeX | BarrierPositiveX); ++ ox = *x; ++ } else if (barrier_is_horizontal(nearest)) { ++ dir &= ~(BarrierNegativeY | BarrierPositiveY); ++ oy = *y; ++ } ++ ++ nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y); ++ if (nearest) { ++ barrier_clamp_to_barrier(nearest, dir, x, y); ++ } ++ } ++ } ++ ++ if (cs->ConstrainCursorHarder) { ++ screen->ConstrainCursorHarder = cs->ConstrainCursorHarder; ++ screen->ConstrainCursorHarder(dev, screen, mode, x, y); ++ screen->ConstrainCursorHarder = CursorConstrainCursorHarder; ++ } ++} ++ ++static struct PointerBarrierClient * ++CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client, ++ xXFixesCreatePointerBarrierReq *stuff) ++{ ++ CursorScreenPtr cs = GetCursorScreen(screen); ++ struct PointerBarrierClient *ret = malloc(sizeof(*ret)); ++ ++ if (ret) { ++ ret->screen = screen; ++ ret->barrier.x1 = min(stuff->x1, stuff->x2); ++ ret->barrier.x2 = max(stuff->x1, stuff->x2); ++ ret->barrier.y1 = min(stuff->y1, stuff->y2); ++ ret->barrier.y2 = max(stuff->y1, stuff->y2); ++ ret->barrier.directions = stuff->directions & 0x0f; ++ if (barrier_is_horizontal(&ret->barrier)) ++ ret->barrier.directions &= ~(BarrierPositiveX | BarrierNegativeX); ++ if (barrier_is_vertical(&ret->barrier)) ++ ret->barrier.directions &= ~(BarrierPositiveY | BarrierNegativeY); ++ list_add(&ret->entry, &cs->barriers); ++ } ++ ++ return ret; ++} ++ ++int ++ProcXFixesCreatePointerBarrier (ClientPtr client) ++{ ++ int err; ++ WindowPtr pWin; ++ struct PointerBarrierClient *barrier; ++ struct PointerBarrier b; ++ REQUEST (xXFixesCreatePointerBarrierReq); ++ ++ REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq); ++ LEGAL_NEW_RESOURCE(stuff->barrier, client); ++ ++ err = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess); ++ if (err != Success) { ++ client->errorValue = stuff->window; ++ return err; ++ } ++ ++ /* This sure does need fixing. */ ++ if (stuff->num_devices) ++ return BadImplementation; ++ ++ b.x1 = stuff->x1; ++ b.x2 = stuff->x2; ++ b.y1 = stuff->y1; ++ b.y2 = stuff->y2; ++ ++ if (!barrier_is_horizontal(&b) && !barrier_is_vertical(&b)) ++ return BadValue; ++ ++ /* no 0-sized barriers */ ++ if (barrier_is_horizontal(&b) && barrier_is_vertical(&b)) ++ return BadValue; ++ ++ if (!(barrier = CreatePointerBarrierClient(pWin->drawable.pScreen, ++ client, stuff))) ++ return BadAlloc; ++ ++ if (!AddResource(stuff->barrier, PointerBarrierType, &barrier->barrier)) ++ return BadAlloc; ++ ++ return Success; ++} ++ ++int ++SProcXFixesCreatePointerBarrier (ClientPtr client) ++{ ++ int n; ++ REQUEST(xXFixesCreatePointerBarrierReq); ++ ++ swaps(&stuff->length, n); ++ REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq); ++ swapl(&stuff->barrier, n); ++ swapl(&stuff->window, n); ++ swaps(&stuff->x1, n); ++ swaps(&stuff->y1, n); ++ swaps(&stuff->x2, n); ++ swaps(&stuff->y2, n); ++ swapl(&stuff->directions, n); ++ return ProcXFixesVector[stuff->xfixesReqType](client); ++} ++ ++static int ++CursorFreeBarrier(void *data, XID id) ++{ ++ struct PointerBarrierClient *b = NULL, *barrier; ++ ScreenPtr screen; ++ CursorScreenPtr cs; ++ ++ barrier = container_of(data, struct PointerBarrierClient, barrier); ++ screen = barrier->screen; ++ cs = GetCursorScreen(screen); ++ ++ /* find and unlink from the screen private */ ++ list_for_each_entry(b, &cs->barriers, entry) { ++ if (b == barrier) { ++ list_del(&b->entry); ++ break; ++ } ++ } ++ ++ free(barrier); ++ return Success; ++} ++ ++int ++ProcXFixesDestroyPointerBarrier (ClientPtr client) ++{ ++ int err; ++ void *barrier; ++ REQUEST (xXFixesDestroyPointerBarrierReq); ++ ++ REQUEST_SIZE_MATCH(xXFixesDestroyPointerBarrierReq); ++ ++ err = dixLookupResourceByType((void **)&barrier, stuff->barrier, ++ PointerBarrierType, client, ++ DixDestroyAccess); ++ if (err != Success) { ++ client->errorValue = stuff->barrier; ++ return err; ++ } ++ ++ FreeResource(stuff->barrier, RT_NONE); ++ return Success; ++} ++ ++int ++SProcXFixesDestroyPointerBarrier (ClientPtr client) ++{ ++ int n; ++ REQUEST(xXFixesDestroyPointerBarrierReq); ++ ++ swaps(&stuff->length, n); ++ REQUEST_SIZE_MATCH(xXFixesDestroyPointerBarrierReq); ++ swapl(&stuff->barrier, n); ++ return ProcXFixesVector[stuff->xfixesReqType](client); ++} ++ + Bool + XFixesCursorInit (void) + { +@@ -1048,8 +1449,10 @@ XFixesCursorInit (void) + cs = (CursorScreenPtr) calloc(1, sizeof (CursorScreenRec)); + if (!cs) + return FALSE; ++ list_init(&cs->barriers); + Wrap (cs, pScreen, CloseScreen, CursorCloseScreen); + Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor); ++ Wrap (cs, pScreen, ConstrainCursorHarder, CursorConstrainCursorHarder); + cs->pCursorHideCounts = NULL; + SetCursorScreen (pScreen, cs); + } +@@ -1059,7 +1462,10 @@ XFixesCursorInit (void) + "XFixesCursorHideCount"); + CursorWindowType = CreateNewResourceType(CursorFreeWindow, + "XFixesCursorWindow"); ++ PointerBarrierType = CreateNewResourceType(CursorFreeBarrier, ++ "XFixesPointerBarrier"); + +- return CursorClientType && CursorHideCountType && CursorWindowType; ++ return CursorClientType && CursorHideCountType && CursorWindowType && ++ PointerBarrierType; + } + +diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c +index e8c7bf1..a57884b 100644 +--- a/xfixes/xfixes.c ++++ b/xfixes/xfixes.c +@@ -1,5 +1,6 @@ + /* + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. ++ * Copyright 2010 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), +@@ -47,10 +48,6 @@ + + #include "xfixesint.h" + #include "protocol-versions.h" +-/* +- * Must use these instead of the constants from xfixeswire.h. They advertise +- * what we implement, not what the protocol headers define. +- */ + + static unsigned char XFixesReqCode; + int XFixesEventBase; +@@ -97,11 +94,12 @@ ProcXFixesQueryVersion(ClientPtr client) + + /* Major version controls available requests */ + static const int version_requests[] = { +- X_XFixesQueryVersion, /* before client sends QueryVersion */ +- X_XFixesGetCursorImage, /* Version 1 */ +- X_XFixesChangeCursorByName, /* Version 2 */ +- X_XFixesExpandRegion, /* Version 3 */ +- X_XFixesShowCursor, /* Version 4 */ ++ X_XFixesQueryVersion, /* before client sends QueryVersion */ ++ X_XFixesGetCursorImage, /* Version 1 */ ++ X_XFixesChangeCursorByName, /* Version 2 */ ++ X_XFixesExpandRegion, /* Version 3 */ ++ X_XFixesShowCursor, /* Version 4 */ ++ X_XFixesDestroyPointerBarrier, /* Version 5 */ + }; + + #define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0])) +@@ -142,6 +140,9 @@ int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr) = { + /*************** Version 4 ****************/ + ProcXFixesHideCursor, + ProcXFixesShowCursor, ++/*************** Version 5 ****************/ ++ ProcXFixesCreatePointerBarrier, ++ ProcXFixesDestroyPointerBarrier, + }; + + static int +@@ -205,6 +206,9 @@ static int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = { + /*************** Version 4 ****************/ + SProcXFixesHideCursor, + SProcXFixesShowCursor, ++/*************** Version 5 ****************/ ++ SProcXFixesCreatePointerBarrier, ++ SProcXFixesDestroyPointerBarrier, + }; + + static int +@@ -260,6 +264,8 @@ XFixesExtensionInit(void) + EventSwapVector[XFixesEventBase + XFixesCursorNotify] = + (EventSwapPtr) SXFixesCursorNotifyEvent; + SetResourceTypeErrorValue(RegionResType, XFixesErrorBase + BadRegion); ++ SetResourceTypeErrorValue(PointerBarrierType, ++ XFixesErrorBase + BadBarrier); + } + } + +diff --git a/xfixes/xfixes.h b/xfixes/xfixes.h +index 1638350..5765e64 100644 +--- a/xfixes/xfixes.h ++++ b/xfixes/xfixes.h +@@ -30,6 +30,7 @@ + #include "resource.h" + + extern _X_EXPORT RESTYPE RegionResType; ++extern _X_EXPORT RESTYPE PointerBarrierType; + extern _X_EXPORT int XFixesErrorBase; + + #define VERIFY_REGION(pRegion, rid, client, mode) \ +@@ -51,5 +52,21 @@ extern _X_EXPORT int XFixesErrorBase; + extern _X_EXPORT RegionPtr + XFixesRegionCopy (RegionPtr pRegion); + ++struct PointerBarrier { ++ CARD16 x1, x2, y1, y2; ++ CARD32 directions; ++}; ++ ++ ++extern int ++barrier_get_direction(int, int, int, int); ++extern BOOL ++barrier_is_blocking(const struct PointerBarrier*, int, int, int, int, double*); ++extern BOOL ++barrier_is_blocking_direction(const struct PointerBarrier*, int); ++extern void ++barrier_clamp_to_barrier(struct PointerBarrier *barrier, int dir, int *x, int *y); ++ ++ + + #endif /* _XFIXES_H_ */ +diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h +index d005369..6ba276e 100644 +--- a/xfixes/xfixesint.h ++++ b/xfixes/xfixesint.h +@@ -1,5 +1,6 @@ + /* + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. ++ * Copyright 2010 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), +@@ -278,6 +279,21 @@ ProcXFixesShowCursor (ClientPtr client); + int + SProcXFixesShowCursor (ClientPtr client); + ++/* Version 5 */ ++ ++int ++ProcXFixesCreatePointerBarrier (ClientPtr client); ++ ++int ++SProcXFixesCreatePointerBarrier (ClientPtr client); ++ ++int ++ProcXFixesDestroyPointerBarrier (ClientPtr client); ++ ++int ++SProcXFixesDestroyPointerBarrier (ClientPtr client); ++ ++/* Xinerama */ + extern int (*PanoramiXSaveXFixesVector[XFixesNumberRequests])(ClientPtr); + void PanoramiXFixesInit (void); + void PanoramiXFixesReset (void); +-- +1.7.4 + diff --git a/testing/xorg-server/xvfb-run b/testing/xorg-server/xvfb-run new file mode 100644 index 000000000..4c2f4e0d3 --- /dev/null +++ b/testing/xorg-server/xvfb-run @@ -0,0 +1,180 @@ +#!/bin/sh + +# $Id: xvfb-run 2027 2004-11-16 14:54:16Z branden $ + +# This script starts an instance of Xvfb, the "fake" X server, runs a command +# with that server available, and kills the X server when done. The return +# value of the command becomes the return value of this script. +# +# If anyone is using this to build a Debian package, make sure the package +# Build-Depends on xvfb, xbase-clients, and xfonts-base. + +set -e + +PROGNAME=xvfb-run +SERVERNUM=99 +AUTHFILE= +ERRORFILE=/dev/null +STARTWAIT=3 +XVFBARGS="-screen 0 640x480x8" +LISTENTCP="-nolisten tcp" +XAUTHPROTO=. + +# Query the terminal to establish a default number of columns to use for +# displaying messages to the user. This is used only as a fallback in the event +# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the +# script is running, and this cannot, only being calculated once.) +DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true +if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then + DEFCOLUMNS=80 +fi + +# Display a message, wrapping lines at the terminal width. +message () { + echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} +} + +# Display an error message. +error () { + message "error: $*" >&2 +} + +# Display a usage message. +usage () { + if [ -n "$*" ]; then + message "usage error: $*" + fi + cat <>"$ERRORFILE" 2>&1 + fi + if [ -n "$XVFB_RUN_TMPDIR" ]; then + if ! rm -r "$XVFB_RUN_TMPDIR"; then + error "problem while cleaning up temporary directory" + exit 5 + fi + fi +} + +# Parse the command line. +ARGS=$(getopt --options +ae:f:hn:lp:s:w: \ + --long auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \ + --name "$PROGNAME" -- "$@") +GETOPT_STATUS=$? + +if [ $GETOPT_STATUS -ne 0 ]; then + error "internal error; getopt exited with status $GETOPT_STATUS" + exit 6 +fi + +eval set -- "$ARGS" + +while :; do + case "$1" in + -a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;; + -e|--error-file) ERRORFILE="$2"; shift ;; + -f|--auth-file) AUTHFILE="$2"; shift ;; + -h|--help) SHOWHELP="yes" ;; + -n|--server-num) SERVERNUM="$2"; shift ;; + -l|--listen-tcp) LISTENTCP="" ;; + -p|--xauth-protocol) XAUTHPROTO="$2"; shift ;; + -s|--server-args) XVFBARGS="$2"; shift ;; + -w|--wait) STARTWAIT="$2"; shift ;; + --) shift; break ;; + *) error "internal error; getopt permitted \"$1\" unexpectedly" + exit 6 + ;; + esac + shift +done + +if [ "$SHOWHELP" ]; then + usage + exit 0 +fi + +if [ -z "$*" ]; then + usage "need a command to run" >&2 + exit 2 +fi + +if ! which xauth >/dev/null; then + error "xauth command not found" + exit 3 +fi + +# tidy up after ourselves +trap clean_up EXIT + +# If the user did not specify an X authorization file to use, set up a temporary +# directory to house one. +if [ -z "$AUTHFILE" ]; then + XVFB_RUN_TMPDIR="$(mktemp -d -t $PROGNAME.XXXXXX)" + AUTHFILE="$XVFB_RUN_TMPDIR/Xauthority" +fi + +# Start Xvfb. +MCOOKIE=$(mcookie) +XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1 +add :$SERVERNUM $XAUTHPROTO $MCOOKIE +EOF +XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" \ + 2>&1 & +XVFBPID=$! +sleep "$STARTWAIT" +if ! kill -0 $XVFBPID 2>/dev/null; then + echo "Xvfb failed to start" >&2 + exit 1 +fi + +# Start the command and save its exit status. +set +e +DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 +RETVAL=$? +set -e + +# Kill Xvfb now that the command has exited. +kill $XVFBPID + +# Return the executed command's exit status. +exit $RETVAL + +# vim:set ai et sts=4 sw=4 tw=80: diff --git a/testing/xorg-server/xvfb-run.1 b/testing/xorg-server/xvfb-run.1 new file mode 100644 index 000000000..137d3a196 --- /dev/null +++ b/testing/xorg-server/xvfb-run.1 @@ -0,0 +1,282 @@ +.\" $Id: xvfb-run.1 2138 2005-01-17 23:40:27Z branden $ +.\" +.\" Copyright 1998-2004 Branden Robinson . +.\" +.\" This is free software; you may redistribute it and/or modify +.\" it under the terms of the GNU General Public License as +.\" published by the Free Software Foundation; either version 2, +.\" or (at your option) any later version. +.\" +.\" This is distributed in the hope that it will be useful, but +.\" WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License with +.\" the Debian operating system, in /usr/share/common-licenses/GPL; if +.\" not, write to the Free Software Foundation, Inc., 59 Temple Place, +.\" Suite 330, Boston, MA 02111-1307 USA +.\" +.\" We need the URL macro from groff's www macro package, but also want +.\" things to work all right for people who don't have it. So we define +.\" our own URL macro and let the www macro package override it if it's +.\" available. +.de URL +\\$2 \(laURL: \\$1 \(ra\\$3 +.. +.if \n[.g] .mso www.tmac +.TH xvfb\-run 1 "2004\-11\-12" "Debian Project" +.SH NAME +xvfb\-run \- run specified X client or command in a virtual X server environment +.SH SYNOPSIS +.B xvfb\-run +[ +.I options +] +.I command +.SH DESCRIPTION +.B xvfb\-run +is a wrapper for the +.BR Xvfb (1x) +command which simplifies the task of running commands (typically an X +client, or a script containing a list of clients to be run) within a virtual +X server environment. +.PP +.B xvfb\-run +sets up an X authority file (or uses an existing user\-specified one), +writes a cookie to it (see +.BR xauth (1x)) +and then starts the +.B Xvfb +X server as a background process. +The process ID of +.B Xvfb +is stored for later use. +The specified +.I command +is then run using the X display corresponding to the +.B Xvfb +server +just started and the X authority file created earlier. +.PP +When the +.I command +exits, its status is saved, the +.B Xvfb +server is killed (using the process ID stored earlier), the X authority +cookie removed, and the authority file deleted (if the user did not specify +one to use). +.B xvfb\-run +then exits with the exit status of +.IR command . +.PP +.B xvfb\-run +requires the +.B xauth +command to function. +.SH OPTIONS +.TP +.B \-a\fR,\fB \-\-auto\-servernum +Try to get a free server number, starting at 99, or the argument to +.BR \-\-server\-num . +.TP +.BI \-e\ file \fR,\fB\ \-\-error\-file= file +Store output from +.B xauth +and +.B Xvfb +in +.IR file . +The default is +.IR /dev/null . +.TP +.BI \-f\ file \fR,\fB\ \-\-auth\-file= file +Store X authentication data in +.IR file . +By default, a temporary directory called +.IR xvfb\-run. PID +(where PID is the process ID of +.B xvfb\-run +itself) is created in the directory specified by the environment variable +.B TMPDIR +(or +.I /tmp +if that variable is null or unset), and the +.BR tempfile (1) +command is used to create a file in that temporary directory called +.IR Xauthority . +.TP +.B \-h\fR,\fB \-\-help +Display a usage message and exit. +.TP +.BI \-n\ servernumber \fR,\fB\ \-\-server\-num= servernumber +Use +.I servernumber +as the server number (but see the +.B \-a\fR,\fB \-\-auto\-servernum +option above). +The default is 99. +.TP +.B \-l\fR,\fB \-\-listen\-tcp +Enable TCP port listening in the X server. +For security reasons (to avoid denial\-of\-service attacks or exploits), +TCP port listening is disabled by default. +.TP +.BI \-p\ protocolname \fR,\fB\ \-\-xauth\-protocol= protocolname +Use +.I protocolname +as the X authority protocol to use. +The default is \(oq.\(cq, which +.B xauth +interprets as its own default protocol, which is MIT\-MAGIC\-COOKIE\-1. +.TP +.BI \-s\ arguments \fR,\fB\ \-\-server\-args= arguments +Pass +.I arguments +to the +.B Xvfb +server. +Be careful to quote any whitespace characters that may occur within +.I arguments +to prevent them from regarded as separators for +.BR xvfb\-run 's +own arguments. +Also, note that specification of \(oq\-nolisten tcp\(cq in +.I arguments +may override the function of +.BR xvfb\-run 's +own +.B \-l\fR,\fB \-\-listen\-tcp +option, and that specification of the server number (e.g., \(oq:1\(cq) may +be ignored because of the way the X server parses its argument list. +Use the +.B xvfb\-run +option +.BI \-n\ servernumber \fR,\fB\ \-\-server\-num= servernumber +to achieve the latter function. +The default is \(oq\-screen 0 640x480x8\(cq. +.TP +.BI \-w\ delay \fR,\fB\ \-\-wait= delay +Wait +.I delay +seconds after launching +.B Xvfb +before attempting to start the specified command. +The default is 3. +.SH ENVIRONMENT +.TP +.B COLUMNS +indicates the width of the terminal device in character cells. +This value is used for formatting diagnostic messages. +If not set, the terminal is queried using +.BR stty (1) +to determine its width. +If that fails, a value of \(oq80\(cq is assumed. +.TP +.B TMPDIR +specifies the directory in which to place +.BR xvfb\-run 's +temporary directory for storage of the X authority file; only used if the +.B \-f +or +.B \-\-auth\-file +options are not specified. +.SH "OUTPUT FILES" +.PP +Unless the +.B \-f +or +.B \-\-auth\-file +options are specified, a temporary +directory and file within it are created (and deleted) to store the X +authority cookies used by the +.B Xvfb +server and client(s) run under it. +See +.BR tempfile (1). +If \-f or \-\-auth\-file are used, then the specified X authority file is +only written to, not created or deleted (though +.B xauth +creates an authority file itself if told to use use that does not already +exist). +.PP +An error file with a user\-specified name is also created if the +.B \-e +or +.B \-\-error\-file +options are specifed; see above. +.SH "EXIT STATUS" +.B xvfb\-run +uses its exit status as well as output to standard error to communicate +diagnostics. +The exit status of \(oq1\(cq is not used, and should be interpreted as failure +of the specified command. +.TP +0 +.B xvfb\-run +only uses this exit status if the +.B \-h\fR,\fB \-\-help +option is given. +In all other situations, this may be interpreted as success of the specified +command. +.TP +2 +No command to run was specified. +.TP +3 +The +.B xauth +command is not available. +.TP +4 +The temporary directory that was going to be used already exists; since +.B xvfb\-run +produces a uniquely named directory, this may indicate an attempt by another +process on the system to exploit a temporary file race condition. +.TP +5 +A problem was encountered while cleaning up the temporary directory. +.TP +6 +A problem was encountered while using +.BR getopt (1) +to parse the command\-line arguments. +.SH EXAMPLES +.TP +.B xvfb\-run \-\-auto\-servernum \-\-server\-num=1 xlogo +runs the +.BR xlogo (1x) +demonstration client inside the +.B Xvfb +X server on the first available server number greater than or equal to 1. +.TP +.B xvfb\-run \-\-server\-args="\-screen 0 1024x768x24" ico \-faces +runs the +.BR ico (1x) +demonstration client (and passes it the +.B \-faces +argument) inside the +.B Xvfb +X server, configured with a root window of 1024 by 768 pixels and a color +depth of 24 bits. +.PP +Note that the demo X clients used in the above examples will not exit on +their own, so they will have to be killed before +.B xvfb\-run +will exit. +.SH BUGS +See +.URL "http://bugs.debian.org/xvfb" "the Debian Bug Tracking System" . +If you wish to report a bug in +.BR xvfb\-run , +please use the +.BR reportbug (1) +command. +.SH AUTHOR +.B xfvb\-run +was written by Branden Robinson and Jeff Licquia with sponsorship from +Progeny Linux Systems. +.SH "SEE ALSO" +.BR Xvfb (1x), +.BR xauth (1x) +.\" vim:set et tw=80: -- cgit v1.2.3-54-g00ecf