[Xquartz-changes] xserver: Branch 'for-keith' - 26 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Mon Oct 17 21:21:18 PDT 2011


Rebased ref, commits from common ancestor:
commit 44c6b000a7a1ba18fe7ab4a49f01c1b119c84122
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Oct 30 14:55:06 2010 -0700

    configure.ac: Add -fno-strict-aliasing to CFLAGS
    
    This should force the server to have -fno-strict-aliasing even once it
    is removed from the warning flags.
    
    See: https://bugs.freedesktop.org/show_bug.cgi?id=31238
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/configure.ac b/configure.ac
index 67a6836..2918435 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,6 +87,12 @@ XORG_PROG_RAWCPP
 # easier overrides at build time.
 XSERVER_CFLAGS='$(CWARNFLAGS)'
 
+dnl Explicitly add -fno-strict-aliasing since this option should disappear
+dnl from util-macros CWARNFLAGS
+if  test "x$GCC" = xyes ; then
+    XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
+fi
+
 dnl Check for dtrace program (needed to build Xserver dtrace probes)
 dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
 dnl ISDN trace program named dtrace
commit 1442718dc274dcf367cf4ac4a1f0baa33ece9e77
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Oct 12 09:59:38 2011 +0100

    test: fix input test
    
    The test was memsetting the wrong thing, this fixes make check in my tinderbox.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/test/input.c b/test/input.c
index 64673d2..bc41c22 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1309,17 +1309,17 @@ static void dix_get_master(void)
     SpriteInfoRec ptr_sprite, kbd_sprite;
     SpriteInfoRec floating_sprite;
 
-    memset(&vcp, 0, sizeof(DeviceIntRec));
-    memset(&vck, 0, sizeof(DeviceIntRec));
-    memset(&ptr, 0, sizeof(DeviceIntRec));
-    memset(&kbd, 0, sizeof(DeviceIntRec));
-    memset(&floating, 0, sizeof(DeviceIntRec));
-
-    memset(&vcp_sprite, 0, sizeof(DeviceIntRec));
-    memset(&vck_sprite, 0, sizeof(DeviceIntRec));
-    memset(&ptr_sprite, 0, sizeof(DeviceIntRec));
-    memset(&kbd_sprite, 0, sizeof(DeviceIntRec));
-    memset(&floating_sprite, 0, sizeof(DeviceIntRec));
+    memset(&vcp, 0, sizeof(vcp));
+    memset(&vck, 0, sizeof(vck));
+    memset(&ptr, 0, sizeof(ptr));
+    memset(&kbd, 0, sizeof(kbd));
+    memset(&floating, 0, sizeof(floating));
+
+    memset(&vcp_sprite, 0, sizeof(vcp_sprite));
+    memset(&vck_sprite, 0, sizeof(vck_sprite));
+    memset(&ptr_sprite, 0, sizeof(ptr_sprite));
+    memset(&kbd_sprite, 0, sizeof(kbd_sprite));
+    memset(&floating_sprite, 0, sizeof(floating_sprite));
 
     vcp.type = MASTER_POINTER;
     vck.type = MASTER_KEYBOARD;
commit d034d35cf795c87fa40015ecc0e985022d07041a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Oct 5 15:02:52 2011 -0700

    dix: add utility functions for double to/fro FP1616/FP3232 conversion
    
    Co-authored-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Mark Kettenis <kettenis at openbsd.org>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index eeae2a7..5c76361 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -767,3 +767,66 @@ input_option_set_value(InputOption *opt, const char *value)
     if (value)
         opt->value = strdup(value);
 }
+
+
+/* FP1616/FP3232 conversion functions.
+ * Fixed point types are encoded as signed integral and unsigned frac. So any
+ * negative number -n.m is encoded as floor(n) + (1 - 0.m).
+ */
+double
+fp1616_to_double(FP1616 in)
+{
+    double ret;
+
+    ret  = (double)(in >> 16);
+    ret += (double)(in & 0xffff) * (1.0 / (1UL << 16)); /* Optimized: ldexp((double)(in & 0xffff), -16); */
+    return ret;
+}
+
+double
+fp3232_to_double(FP3232 in)
+{
+    double ret;
+    ret  = (double)in.integral;
+    ret += (double)in.frac * (1.0 / (1ULL << 32)); /* Optimized: ldexp((double)in.frac, -32); */
+    return ret;
+}
+
+
+FP1616
+double_to_fp1616(double in)
+{
+    FP1616 ret;
+    int32_t integral;
+    double tmp;
+    uint32_t frac_d;
+
+    tmp = floor(in);
+    integral = (int32_t)tmp;
+
+    tmp = (in - integral) * (1UL << 16); /* Optimized: ldexp(in - integral, 16) */
+    frac_d = (uint16_t)tmp;
+
+    ret = integral << 16;
+    ret |= frac_d & 0xffff;
+    return ret;
+}
+
+FP3232
+double_to_fp3232(double in)
+{
+    FP3232 ret;
+    int32_t integral;
+    double tmp;
+    uint32_t frac_d;
+
+    tmp = floor(in);
+    integral = (int32_t)tmp;
+
+    tmp = (in - integral) * (1ULL << 32); /* Optimized: ldexp(in - integral, 32) */
+    frac_d = (uint32_t)tmp;
+
+    ret.integral = integral;
+    ret.frac = frac_d;
+    return ret;
+}
diff --git a/include/inpututils.h b/include/inpututils.h
index 47e242d..2832ed5 100644
--- a/include/inpututils.h
+++ b/include/inpututils.h
@@ -30,6 +30,7 @@
 #define INPUTUTILS_H
 
 #include "input.h"
+#include <X11/extensions/XI2proto.h>
 
 struct _ValuatorMask {
     int8_t      last_bit; /* highest bit set in mask */
@@ -40,4 +41,9 @@ struct _ValuatorMask {
 extern void verify_internal_event(const InternalEvent *ev);
 extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms);
 
+FP3232 double_to_fp3232(double in);
+FP1616 double_to_fp1616(double in);
+double fp1616_to_double(FP1616 in);
+double fp3232_to_double(FP3232 in);
+
 #endif
diff --git a/test/input.c b/test/input.c
index afc4d4d..64673d2 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1462,9 +1462,137 @@ static void input_option_test(void)
     assert(list == NULL);
 }
 
+static void
+_test_double_fp16_values(double orig_d)
+{
+    FP1616 first_fp16, final_fp16;
+    double final_d;
+    char first_fp16_s[64];
+    char final_fp16_s[64];
+
+    if (orig_d > 0x7FFF) {
+        printf("Test out of range\n");
+        assert(0);
+    }
+
+    first_fp16 = double_to_fp1616(orig_d);
+    final_d = fp1616_to_double(first_fp16);
+    final_fp16 = double_to_fp1616(final_d);
+
+    snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff);
+    snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff);
+
+    printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
+
+    /* since we lose precision, we only do rough range testing */
+    assert(final_d > orig_d - 0.1);
+    assert(final_d < orig_d + 0.1);
+
+    assert(memcmp(&first_fp16, &final_fp16, sizeof(FP1616)) == 0);
+
+    if (orig_d > 0)
+        _test_double_fp16_values(-orig_d);
+}
+
+static void
+_test_double_fp32_values(double orig_d)
+{
+    FP3232 first_fp32, final_fp32;
+    double final_d;
+
+    if (orig_d > 0x7FFFFFFF) {
+        printf("Test out of range\n");
+        assert(0);
+    }
+
+    first_fp32 = double_to_fp3232(orig_d);
+    final_d = fp3232_to_double(first_fp32);
+    final_fp32 = double_to_fp3232(final_d);
+
+    /* {
+     *     char first_fp32_s[64];
+     *     char final_fp32_s[64];
+     *     snprintf(first_fp32_s, sizeof(first_fp32_s), "%d + %u * 2^-32", first_fp32.integral, first_fp32.frac);
+     *     snprintf(final_fp32_s, sizeof(final_fp32_s), "%d + %u * 2^-32", first_fp32.integral, final_fp32.frac);
+     *
+     *     printf("FP32: original double: %f first fp32: %s, re-encoded double: %f, final fp32: %s\n", orig_d, first_fp32_s, final_d, final_fp32_s);
+     * }
+     */
+
+    /* since we lose precision, we only do rough range testing */
+    assert(final_d > orig_d - 0.1);
+    assert(final_d < orig_d + 0.1);
+
+    assert(memcmp(&first_fp32, &final_fp32, sizeof(FP3232)) == 0);
+
+    if (orig_d > 0)
+        _test_double_fp32_values(-orig_d);
+}
+
+static void
+dix_double_fp_conversion(void)
+{
+    uint32_t i;
+    printf("Testing double to FP1616/FP3232 conversions\n");
+
+    _test_double_fp16_values(0);
+    for (i = 1; i < 0x7FFF; i <<= 1) {
+        double val;
+
+        val = i;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        /* and some pseudo-random floating points */
+        val = i - 0.00382;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        val = i + 0.00382;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        val = i + 0.05234;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        val = i + 0.12342;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        val = i + 0.27583;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        val = i + 0.50535;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        val = i + 0.72342;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+
+        val = i + 0.80408;
+        _test_double_fp16_values(val);
+        _test_double_fp32_values(val);
+    }
+
+    for (i = 0x7FFFF; i < 0x7FFFFFFF; i <<= 1) {
+        _test_double_fp32_values(i);
+        /* and a few more random floating points, obtained
+         * by faceplanting into the numpad repeatedly */
+        _test_double_fp32_values(i + 0.010177);
+        _test_double_fp32_values(i + 0.213841);
+        _test_double_fp32_values(i + 0.348720);
+        _test_double_fp32_values(i + 0.472020);
+        _test_double_fp32_values(i + 0.572020);
+        _test_double_fp32_values(i + 0.892929);
+    }
+}
 
 int main(int argc, char** argv)
 {
+    dix_double_fp_conversion();
     dix_input_valuator_masks();
     dix_input_attributes();
     dix_init_valuators();
commit b9dcb84b8dc0e956b16b93b8190b86f618e4fd1e
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Oct 11 17:37:44 2011 -0700

    os: Remove Error()
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml
index 37fd2b2..2bf4fb3 100644
--- a/doc/Xserver-spec.xml
+++ b/doc/Xserver-spec.xml
@@ -1324,10 +1324,6 @@ This re-enables X request processing for the specified client.
 
 	void
 	FatalError(char *f, ...)
-
-	void
-	Error(str)
-	    char *str;
 </programlisting></blockquote>
 You should write these three routines to provide for diagnostic output
 from the dix and ddx layers, although implementing them to produce no
@@ -1335,11 +1331,7 @@ output will not affect the correctness of your server.  ErrorF() and
 FatalError() take a printf() type of format specification in the first
 argument and an implementation-dependent number of arguments following
 that.  Normally, the formats passed to ErrorF() and FatalError()
-should be terminated with a newline.  Error() provides an os interface
-for printing out the string passed as an argument followed by a
-meaningful explanation of the last system error.  Normally the string
-does not contain a newline, and it is only called by the ddx layer.
-In the sample implementation, Error() uses the perror() function.
+should be terminated with a newline.
 </para>
 <para>
 After printing the message arguments, FatalError() must be implemented
diff --git a/hw/xfree86/utils/cvt/cvt.c b/hw/xfree86/utils/cvt/cvt.c
index fff500b..0de5ffe 100644
--- a/hw/xfree86/utils/cvt/cvt.c
+++ b/hw/xfree86/utils/cvt/cvt.c
@@ -25,13 +25,6 @@
 
 #include "xf86.h"
 
-/* Error implementation used by the server code we built in */
-void
-Error(const char *str)
-{
-    perror(str);
-}
-
 /* FatalError implementation used by the server code we built in */
 void
 FatalError(const char *f, ...)
diff --git a/include/os.h b/include/os.h
index 5401ea4..b489211 100644
--- a/include/os.h
+++ b/include/os.h
@@ -551,7 +551,6 @@ extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X
 
 extern _X_EXPORT void VErrorF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1,0);
 extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
-extern _X_EXPORT void Error(const char *str);
 extern _X_EXPORT void LogPrintMarkers(void);
 
 extern _X_EXPORT void xorg_backtrace(void);
diff --git a/os/backtrace.c b/os/backtrace.c
index 7ca6dab..58b4b1f 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -27,6 +27,8 @@
 
 #include "os.h"
 #include "misc.h"
+#include <errno.h>
+#include <string.h>
 
 #ifdef HAVE_BACKTRACE
 #ifndef _GNU_SOURCE
@@ -199,9 +201,8 @@ void xorg_backtrace(void) {
 	    walkcontext(&u, xorg_backtrace_frame, &depth);
 	else
 #  endif
-	    Error("Failed to get backtrace info");
+	    ErrorF("Failed to get backtrace info: %s\n", strerror(errno));
     }
-    ErrorF("\n");	
 }
 
 # else
diff --git a/os/log.c b/os/log.c
index 2eddf06..9ee32c9 100644
--- a/os/log.c
+++ b/os/log.c
@@ -87,7 +87,6 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #include <sys/stat.h>
 #include <stdarg.h>
 #include <stdlib.h>	/* for malloc() */
-#include <errno.h>
 
 #include "input.h"
 #include "site.h"
@@ -638,19 +637,6 @@ ErrorF(const char * f, ...)
     va_end(args);
 }
 
-/* A perror() workalike. */
-
-void
-Error(const char *str)
-{
-    const char *err = strerror(errno);
-
-    if (str)
-	LogWrite(-1, "%s: %s", str, err);
-    else
-	LogWrite(-1, "%s", err);
-}
-
 void
 LogPrintMarkers(void)
 {
diff --git a/os/xprintf.c b/os/xprintf.c
index 254b737..3b4bb41 100644
--- a/os/xprintf.c
+++ b/os/xprintf.c
@@ -64,6 +64,8 @@
 #include "os.h"
 #include <stdarg.h>
 #include <stdio.h>
+#include <errno.h>
+#include <string.h>
 
 #ifdef asprintf
 # undef asprintf
@@ -154,8 +156,7 @@ XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
 {
     int size = vasprintf(ret, format, va);
     if ((size == -1) || (*ret == NULL)) {
-	Error("XNFvasprintf");
-	FatalError("XNFvasprintf failed");
+	FatalError("XNFvasprintf failed: %s", strerror(errno));
     }
     return size;
 }
commit e1ad5adf07bd4340e5bb95997cc79296ff16d701
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Oct 10 12:16:31 2011 -0700

    Xephyr: Remove socket and its lock file on exit
    
    https://bugs.freedesktop.org/show_bug.cgi?id=11484
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 4caf451..47a6681 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -45,6 +45,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h> 		/* for memset */
+#include <errno.h>
 #include <time.h>
 
 #include <sys/ipc.h>
@@ -331,6 +332,14 @@ hostx_set_title (char *title)
   ephyrTitle = title;
 }
 
+static int _X_NORETURN
+x_io_error_handler (Display *dpy) {
+    ErrorF("Lost connection to X server: %s\n", strerror(errno));
+    CloseWellKnownConnections();
+    OsCleanup(1);
+    exit(1);
+}
+
 int
 hostx_init (void)
 {
@@ -358,6 +367,8 @@ hostx_init (void)
       exit(1);
     }
 
+  XSetIOErrorHandler(x_io_error_handler);
+
   HostX.screen  = DefaultScreen(HostX.dpy);
   HostX.winroot = RootWindow(HostX.dpy, HostX.screen);
   HostX.gc      = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL);
commit b170b5bb775d3bda5a77f8a0a7d3ac9cc7ed70bc
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Oct 10 12:09:39 2011 -0700

    Xnest: Remove socket and its lock file on exit
    
    https://bugs.freedesktop.org/show_bug.cgi?id=11484
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c
index b78aff5..7acad75 100644
--- a/hw/xnest/Display.c
+++ b/hw/xnest/Display.c
@@ -17,6 +17,9 @@ is" without express or implied warranty.
 #include <xnest-config.h>
 #endif
 
+#include <string.h>
+#include <errno.h>
+
 #include <X11/X.h>
 #include <X11/Xproto.h>
 #include "screenint.h"
@@ -52,6 +55,14 @@ Pixmap xnestScreenSaverPixmap;
 XlibGC xnestBitmapGC;
 unsigned long xnestEventMask;
 
+static int _X_NORETURN
+x_io_error_handler (Display *dpy) {
+    ErrorF("Lost connection to X server: %s\n", strerror(errno));
+    CloseWellKnownConnections();
+    OsCleanup(1);
+    exit(1);
+}
+
 void
 xnestOpenDisplay(int argc, char *argv[])
 {
@@ -60,7 +71,9 @@ xnestOpenDisplay(int argc, char *argv[])
   int i, j;
 
   if (!xnestDoFullGeneration) return;
-  
+
+  XSetIOErrorHandler(x_io_error_handler);
+
   xnestCloseDisplay();
 
   xnestDisplay = XOpenDisplay(xnestDisplayName);
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index 619427d..2399313 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -198,6 +198,8 @@ xnestCollectEvents(void)
     case DestroyNotify:
       if (xnestParentWindow != (Window) 0 &&
 	  X.xdestroywindow.window == xnestParentWindow)
+	CloseWellKnownConnections();
+	OsCleanup(1);
 	exit (0);
       break;
 
commit d1a70024f84dab17e821366d6b8daaf8e8936c72
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun Oct 9 04:00:41 2011 -0700

    loader: when creating sdksyms.c only include shmint.h if MITSHM is enabled #29109
    
    https://bugs.freedesktop.org/show_bug.cgi?id=29109
    
    When configured with --disable-mitshm the symbols declared in shmint.h
    do not exist. By guarding the include with '#ifdef MITSHM' these
    symbols are skipped when generating sdksyms.c with --disable-mitshm.
    
    Signed-off-by: Michael Olbrich <m.olbrich at pengutronix.de>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index 18bb735..1755f02 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -52,7 +52,9 @@ cat > sdksyms.c << EOF
  */
 #include "geext.h"
 #include "geint.h"
+#ifdef MITSHM
 #include "shmint.h"
+#endif
 #include "syncsdk.h"
 #if XINERAMA
 # include "panoramiXsrv.h"
commit d2339803756508d1c9d0fe2d9c81c4f50d8855f8
Author: Julien Cristau <jcristau at debian.org>
Date:   Sun Oct 9 17:06:14 2011 -0700

    xfree86: fix build with xv disabled
    
    https://bugs.freedesktop.org/show_bug.cgi?id=29111
    
    Signed-off-by: Julien Cristau <jcristau at debian.org>
    Tested-by: Cyril Brulebois <kibi at debian.org>
    Reviewed-by: Cyril Brulebois <kibi at debian.org>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 3fae039..cbe0b5c 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3090,6 +3090,7 @@ xf86_crtc_box_area(BoxPtr box)
     return (int) (box->x2 - box->x1) * (int) (box->y2 - box->y1);
 }
 
+#ifdef XV
 /*
  * Return the crtc covering 'box'. If two crtcs cover a portion of
  * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
@@ -3178,6 +3179,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
 
     return ret;
 }
+#endif
 
 xf86_crtc_notify_proc_ptr
 xf86_wrap_crtc_notify (ScreenPtr screen, xf86_crtc_notify_proc_ptr new)
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index ffb2eff..716499f 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -956,6 +956,7 @@ xf86_cursors_fini (ScreenPtr screen);
 extern _X_EXPORT void
 xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y);
 
+#ifdef XV
 /*
  * For overlay video, compute the relevant CRTC and
  * clip video to that.
@@ -974,6 +975,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
 			    RegionPtr   reg,
 			    INT32	width,
 			    INT32	height);
+#endif
     
 extern _X_EXPORT xf86_crtc_notify_proc_ptr
 xf86_wrap_crtc_notify (ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);
commit 44036435c1b59fee28c329f89e258afb0b50bdd1
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sun Mar 6 10:18:30 2011 +0200

    Man page syntax and spelling fixes.
    
    Signed-off-by: Ville Skyttä <ville.skytta at iki.fi>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/kdrive/ephyr/man/Xephyr.man b/hw/kdrive/ephyr/man/Xephyr.man
index 12c9f58..ca88ab2 100644
--- a/hw/kdrive/ephyr/man/Xephyr.man
+++ b/hw/kdrive/ephyr/man/Xephyr.man
@@ -1,18 +1,18 @@
-."
-." Copyright (c) Matthieu Herrb <matthieu at herrb.eu>
-."
-." Permission to use, copy, modify, and distribute this software for any
-." purpose with or without fee is hereby granted, provided that the above
-." copyright notice and this permission notice appear in all copies.
-."
-." THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-." WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-." MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-." ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-." WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-." ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-." OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-."
+.\"
+.\" Copyright (c) Matthieu Herrb <matthieu at herrb.eu>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
 .TH Xephyr __appmansuffix__ __vendorversion__
 .SH NAME
 Xephyr - X server outputting to a window on a pre-existing X display
@@ -81,7 +81,7 @@ build flags are causing this. I haven't figured as yet how to work
 round it. It doesn't appear to break anything however.
 .IP \(bu 2
 Keyboard handling is basic but works.
-.TP \(bu 2
+.IP \(bu 2
 Mouse button 5 probably won't work.
 .SH "SEE ALSO"
 X(__miscmansuffix__), Xserver(__appmansuffix__)
diff --git a/man/Xserver.man b/man/Xserver.man
index 1a36b09..02cca52 100644
--- a/man/Xserver.man
+++ b/man/Xserver.man
@@ -143,12 +143,12 @@ is platform and configuration specific.
 disables named extension.   If an unknown extension name is specified,
 a list of accepted extension names is printed.
 .TP 8
-.BI \+extension extensionName
+.BI +extension extensionName
 enables named extension.   If an unknown extension name is specified,
 a list of accepted extension names is printed.
 .TP 8
 .B \-f \fIvolume\fP
-sets feep (bell) volume (allowable range: 0-100).
+sets beep (bell) volume (allowable range: 0-100).
 .TP 8
 .B \-fc \fIcursorFont\fP
 sets default cursor font.
@@ -524,8 +524,8 @@ An example configuration:
 .fi
 
 This will add /usr/share/X11/fonts/misc as the first FPE with the attribute
-'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with
-the attribute unscaled etc. This is functionally equivalent to setting
+\N'39'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with
+the attribute 'unscaled' etc. This is functionally equivalent to setting
 the following font path:
 
 .nf
commit fb84be47db7cdaff406792c08e34670e8e0cbda9
Merge: fae7ed6 32b289e
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Oct 17 13:50:25 2011 -0700

    Merge remote-tracking branch 'whot/next'

commit 32b289e46cc2d5ec32ff0c4ba5bbfbf602afb388
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Oct 3 13:58:01 2011 +1000

    dix: move MD last.valuator update into fill_pointer_events
    
    Don't update the MD where it's not expected, positionSprite should really
    just do that - position the sprite.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index ade3ca1..874189f 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -844,12 +844,6 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
         y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
                                 scr->height);
 
-    /* Update the MD's co-ordinates, which are always in screen space. */
-    if (!IsMaster(dev) || !IsFloating(dev)) {
-        DeviceIntPtr master = GetMaster(dev, MASTER_POINTER);
-        master->last.valuators[0] = *screenx;
-        master->last.valuators[1] = *screeny;
-    }
 
     if (valuator_mask_isset(mask, 0))
         valuator_mask_set_double(mask, 0, x);
@@ -1189,6 +1183,13 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
             pDev->last.valuators[i] = valuator_mask_get_double(&mask, i);
     }
 
+    /* Update the MD's co-ordinates, which are always in screen space. */
+    if (!IsMaster(pDev) || !IsFloating(pDev)) {
+        DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER);
+        master->last.valuators[0] = screenx;
+        master->last.valuators[1] = screeny;
+    }
+
     event = &events->device_event;
     init_device_event(event, pDev, ms);
 
commit 3b36fd1b49030ead44358945f62e5abe7f4609ce
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Oct 3 13:10:53 2011 +1000

    mi: switch miPointerSetPosition to take doubles
    
    Don't switch between doubles and ints in the caller, instead take doubles in
    miPointerSetPosition and do the conversion there. For full feature we should
    change everything down from here for doubles too.
    
    Functional change: previously we'd restore the remainder regardless of
    screen switching/confinement (despite what the comment said). Now,
    screen changing or cursor constraints will cause the remainder be clipped
    off. This should happen for cursor constraints but arguably not for screen
    crossing.
    
    This also corrects a currently wrong comment about miPointerSetPosition's
    input coordinates.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index bb1f5c9..ade3ca1 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -805,8 +805,8 @@ static ScreenPtr
 positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
                double *screenx, double *screeny)
 {
-    int isx, isy; /* screen {x, y}, in int */
     double x, y;
+    double tmpx, tmpy;
     ScreenPtr scr = miPointerGetScreen(dev);
 
     if (!dev->valuator || dev->valuator->numAxes < 2)
@@ -827,25 +827,22 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
     *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
                                    scr->height);
 
+    tmpx = *screenx;
+    tmpy = *screeny;
     /* miPointerSetPosition takes care of crossing screens for us, as well as
-     * clipping to the current screen.  In the event we actually change screen,
-     * we just drop the float component on the floor, then convert from
-     * screenx back into device co-ordinates. */
-    isx = trunc(*screenx);
-    isy = trunc(*screeny);
-    scr = miPointerSetPosition(dev, mode, &isx, &isy);
-    if (isx != trunc(*screenx))
-    {
-        *screenx -= trunc(*screenx) - isx;
+     * clipping to the current screen. */
+    scr = miPointerSetPosition(dev, mode, screenx, screeny);
+
+    /* If we were constrained, rescale x/y from the screen coordinates so
+     * the device valuators reflect the correct position. For screen
+     * crossing this doesn't matter much, the coords would be 0 or max.
+     */
+    if (tmpx != *screenx)
         x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
                                 scr->width);
-    }
-    if (isy != trunc(*screeny))
-    {
-        *screeny -= trunc(*screeny) - isy;
+    if (tmpy != *screeny)
         y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
                                 scr->height);
-    }
 
     /* Update the MD's co-ordinates, which are always in screen space. */
     if (!IsMaster(dev) || !IsFloating(dev)) {
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 4901d13..55e4081 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -569,17 +569,16 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen,
  *
  * @param pDev The device to move
  * @param mode Movement mode (Absolute or Relative)
- * @param[in,out] x The x coordinate in screen coordinates (in regards to total
- * desktop size)
- * @param[in,out] y The y coordinate in screen coordinates (in regards to total
- * desktop size)
+ * @param[in,out] screenx The x coordinate in screen coordinates
+ * @param[in,out] screeny The y coordinate in screen coordinates
  */
 ScreenPtr
-miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
+miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *screeny)
 {
     miPointerScreenPtr	pScreenPriv;
     ScreenPtr		pScreen;
     ScreenPtr		newScreen;
+    int			x, y;
 
     miPointerPtr        pPointer; 
 
@@ -591,13 +590,16 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
     if (!pScreen)
 	return NULL;    /* called before ready */
 
-    if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height)
+    x = trunc(*screenx);
+    y = trunc(*screeny);
+
+    if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height)
     {
 	pScreenPriv = GetScreenPrivate (pScreen);
 	if (!pPointer->confined)
 	{
 	    newScreen = pScreen;
-	    (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, x, y);
+	    (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y);
 	    if (newScreen != pScreen)
 	    {
 		pScreen = newScreen;
@@ -610,21 +612,30 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
 	}
     }
     /* Constrain the sprite to the current limits. */
-    if (*x < pPointer->limits.x1)
-	*x = pPointer->limits.x1;
-    if (*x >= pPointer->limits.x2)
-	*x = pPointer->limits.x2 - 1;
-    if (*y < pPointer->limits.y1)
-	*y = pPointer->limits.y1;
-    if (*y >= pPointer->limits.y2)
-	*y = pPointer->limits.y2 - 1;
+    if (x < pPointer->limits.x1)
+	x = pPointer->limits.x1;
+    if (x >= pPointer->limits.x2)
+	x = pPointer->limits.x2 - 1;
+    if (y < pPointer->limits.y1)
+	y = pPointer->limits.y1;
+    if (y >= pPointer->limits.y2)
+	y = pPointer->limits.y2 - 1;
 
     if (pScreen->ConstrainCursorHarder)
-       pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y);
+       pScreen->ConstrainCursorHarder(pDev, pScreen, mode, &x, &y);
 
-    if (pPointer->x != *x || pPointer->y != *y ||
+    if (pPointer->x != x || pPointer->y != y ||
             pPointer->pScreen != pScreen)
-        miPointerMoveNoEvent(pDev, pScreen, *x, *y);
+        miPointerMoveNoEvent(pDev, pScreen, x, y);
+
+    /* In the event we actually change screen or we get confined, we just
+     * drop the float component on the floor
+     * FIXME: only drop remainder for ConstrainCursorHarder, not for screen
+     * crossings */
+    if (x != trunc(*screenx))
+        *screenx = x;
+    if (y != trunc(*screeny))
+        *screeny = y;
 
     return pScreen;
 }
diff --git a/mi/mipointer.h b/mi/mipointer.h
index 35428df..45abb5b 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -134,8 +134,8 @@ extern _X_EXPORT void miPointerGetPosition(
 extern _X_EXPORT ScreenPtr miPointerSetPosition(
     DeviceIntPtr pDev,
     int mode,
-    int *x,
-    int *y);
+    double *x,
+    double *y);
 
 extern _X_EXPORT void miPointerUpdateSprite(
     DeviceIntPtr pDev);
commit 81cfe44b1ed0de84ad1941fe2ca74bebef3fc58d
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Oct 3 12:49:49 2011 +1000

    mi: return the screen from miPointerSetPosition
    
    miPointerSetPosition may switch screens. Always return the screen the sprite
    is on instead of relying on callers to call miPointerGetScreen().
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 4206ca9..bb1f5c9 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -833,8 +833,7 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
      * screenx back into device co-ordinates. */
     isx = trunc(*screenx);
     isy = trunc(*screeny);
-    miPointerSetPosition(dev, mode, &isx, &isy);
-    scr = miPointerGetScreen(dev);
+    scr = miPointerSetPosition(dev, mode, &isx, &isy);
     if (isx != trunc(*screenx))
     {
         *screenx -= trunc(*screenx) - isx;
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 670f63b..4901d13 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -574,7 +574,7 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen,
  * @param[in,out] y The y coordinate in screen coordinates (in regards to total
  * desktop size)
  */
-void
+ScreenPtr
 miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
 {
     miPointerScreenPtr	pScreenPriv;
@@ -584,12 +584,12 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
     miPointerPtr        pPointer; 
 
     if (!pDev || !pDev->coreEvents)
-        return;
+        return NULL;
 
     pPointer = MIPOINTER(pDev);
     pScreen = pPointer->pScreen;
     if (!pScreen)
-	return;	    /* called before ready */
+	return NULL;    /* called before ready */
 
     if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height)
     {
@@ -622,11 +622,11 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
     if (pScreen->ConstrainCursorHarder)
        pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y);
 
-    if (pPointer->x == *x && pPointer->y == *y &&
-            pPointer->pScreen == pScreen)
-        return;
+    if (pPointer->x != *x || pPointer->y != *y ||
+            pPointer->pScreen != pScreen)
+        miPointerMoveNoEvent(pDev, pScreen, *x, *y);
 
-    miPointerMoveNoEvent(pDev, pScreen, *x, *y);
+    return pScreen;
 }
 
 /**
diff --git a/mi/mipointer.h b/mi/mipointer.h
index c4265f9..35428df 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -131,7 +131,7 @@ 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(
+extern _X_EXPORT ScreenPtr miPointerSetPosition(
     DeviceIntPtr pDev,
     int mode,
     int *x,
commit 88dfe5366d9855e0ebf8bbff74967b793ede57d1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Oct 3 12:37:28 2011 +1000

    dix: drop screen argument from positionSprite
    
    We can just get this in the function, no effective functional changes.
    
    Also return the screen to the caller. Though we don't use it yet, we will in
    a follow-up patch.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 3ef7a5c..4206ca9 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -797,20 +797,20 @@ scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
  *
  * @param dev The device to be moved.
  * @param mode Movement mode (Absolute or Relative)
- * @param scr Screen the device's sprite is currently on.
  * @param mask Mask of axis values for this event
  * @param screenx Screen x coordinate the sprite is on after the update.
  * @param screeny Screen y coordinate the sprite is on after the update.
  */
-static void
-positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask,
+static ScreenPtr
+positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
                double *screenx, double *screeny)
 {
     int isx, isy; /* screen {x, y}, in int */
     double x, y;
+    ScreenPtr scr = miPointerGetScreen(dev);
 
     if (!dev->valuator || dev->valuator->numAxes < 2)
-        return;
+        return scr;
 
     if (valuator_mask_isset(mask, 0))
         x = valuator_mask_get_double(mask, 0);
@@ -859,6 +859,8 @@ positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask,
         valuator_mask_set_double(mask, 0, x);
     if (valuator_mask_isset(mask, 1))
         valuator_mask_set_double(mask, 1, y);
+
+    return scr;
 }
 
 /**
@@ -1124,7 +1126,6 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     DeviceEvent *event;
     RawDeviceEvent *raw;
     double screenx = 0.0, screeny = 0.0;
-    ScreenPtr scr = miPointerGetScreen(pDev);
     ValuatorMask mask;
 
     switch (type)
@@ -1180,7 +1181,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     if ((flags & POINTER_NORAW) == 0)
         set_raw_valuators(raw, &mask, raw->valuators.data);
 
-    positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, scr,
+    positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
                    &mask, &screenx, &screeny);
     updateHistory(pDev, &mask, ms);
 
commit 967bc25da221a69c8fc390253465145ce534fcb9
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Oct 3 11:42:08 2011 +1000

    dix: move screen- to device coordinate scaling to separate function
    
    No functional changes.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 98d8cf0..3ef7a5c 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -753,6 +753,37 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms)
 }
 
 /**
+ * Scale from absolute screen coordinates to absolute coordinates in the
+ * device's coordinate range.
+ *
+ * @param dev The device to scale for.
+ * @param[in, out] mask The mask in sceen coordinates, modified in place to
+ * contain device coordinate range.
+ */
+static void
+scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
+{
+    double scaled;
+    ScreenPtr scr = miPointerGetScreen(dev);
+
+    if (valuator_mask_isset(mask, 0))
+    {
+        scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 0),
+                                     NULL, dev->valuator->axes + 0,
+                                     scr->width);
+        valuator_mask_set_double(mask, 0, scaled);
+    }
+    if (valuator_mask_isset(mask, 1))
+    {
+        scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 1),
+                                     NULL, dev->valuator->axes + 1,
+                                     scr->height);
+        valuator_mask_set_double(mask, 1, scaled);
+    }
+}
+
+
+/**
  * If we have HW cursors, this actually moves the visible sprite. If not, we
  * just do all the screen crossing, etc.
  *
@@ -1136,24 +1167,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     if (flags & POINTER_ABSOLUTE)
     {
         if (flags & POINTER_SCREEN) /* valuators are in screen coords */
-        {
-            double scaled;
-
-            if (valuator_mask_isset(&mask, 0))
-            {
-                scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 0),
-                                             NULL, pDev->valuator->axes + 0,
-                                             scr->width);
-                valuator_mask_set_double(&mask, 0, scaled);
-            }
-            if (valuator_mask_isset(&mask, 1))
-            {
-                scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 1),
-                                             NULL, pDev->valuator->axes + 1,
-                                             scr->height);
-                valuator_mask_set_double(&mask, 1, scaled);
-            }
-        }
+            scale_from_screen(pDev, &mask);
 
         transformAbsolute(pDev, &mask);
         clipAbsolute(pDev, &mask);
commit b059e06e19ac9417ceeb8be58c1c91b159291865
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Aug 29 12:36:26 2011 +1000

    dix: don't allow keyboard devices to submit motion or button events.
    
    GPE unconditionally dereferences pDev->valuator if a mask is present. This
    shouldn't really happen but if it does, don't crash, just ignore the events
    with an error.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 9926693..98d8cf0 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1099,6 +1099,11 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     switch (type)
     {
         case MotionNotify:
+            if (!pDev->valuator)
+            {
+                ErrorF("[dix] motion events from device %d without valuators\n", pDev->id);
+                return 0;
+            }
             if (!mask_in || valuator_mask_num_valuators(mask_in) <= 0)
                 return 0;
             break;
@@ -1106,6 +1111,11 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
         case ButtonRelease:
             if (!pDev->button || !buttons)
                 return 0;
+            if (mask_in && valuator_mask_size(mask_in) > 0 && !pDev->valuator)
+            {
+                ErrorF("[dix] button event with valuator from device %d without valuators\n", pDev->id);
+                return 0;
+            }
             break;
         default:
             return 0;
commit bccff533184a051b614a26304ce77ad30bede5e0
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Oct 3 12:19:21 2011 +1000

    dix: moveRelative modifies parameter in-place, say so.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 6a812fb..9926693 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -713,7 +713,7 @@ clipAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
  * Move the device's pointer by the values given in @valuators.
  *
  * @param dev The device whose pointer is to be moved.
- * @param mask Valuator data for this event.
+ * @param[in,out] mask Valuator data for this event, modified in-place.
  */
 static void
 moveRelative(DeviceIntPtr dev, ValuatorMask *mask)
commit b966362ccf0fe6fdd44f4d778d47e3677f55f11b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Oct 3 12:18:20 2011 +1000

    dix: rename moveAbsolute to clipAbsolute
    
    Let's be honest about what it does.
    
    moveRelative accumulates delta _and_ clips in some cases, so that one can
    keep it's name.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index cf82cbf..6a812fb 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -693,7 +693,7 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve
  * @param mask Valuator data for this event.
  */
 static void
-moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
+clipAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
 {
     int i;
 
@@ -1146,7 +1146,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
         }
 
         transformAbsolute(pDev, &mask);
-        moveAbsolute(pDev, &mask);
+        clipAbsolute(pDev, &mask);
     } else {
         if (flags & POINTER_ACCELERATE)
             accelPointer(pDev, &mask, ms);
commit 959d18c3765e447897a8cfd358e9ee645df595d9
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Sep 30 10:50:51 2011 +1000

    dix: fix missing verb in comment
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index e478355..cf82cbf 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -760,8 +760,9 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* 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.
+ * The coordinates provided are always absolute. The parameter mode
+ * specifies 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)
commit 7074ec87bdf81699df172619aea7aae1ad4ec3c6
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Sep 30 10:47:00 2011 +1000

    dix: document transformAbsolute
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 97c3937..e478355 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1020,6 +1020,14 @@ transform(struct pixman_f_transform *m, double *x, double *y)
     *y = p.v[1];
 }
 
+/**
+ * Apply the device's transformation matrix to the valuator mask and replace
+ * the scaled values in mask. This transformation only applies to valuators
+ * 0 and 1, others will be untouched.
+ *
+ * @param dev The device the valuators came from
+ * @param[in,out] mask The valuator mask.
+ */
 static void
 transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
 {
commit f4ca19ce3ab91a9c8ad9de60f7dc95466f21f589
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Jul 29 10:56:44 2011 +1000

    dix: copy the source ID into the RawEvent (#34240)
    
    X.Org Bug 34240 <http://bugs.freedesktop.org/show_bug.cgi?id=34240>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index f9aafa5..189cb85 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -667,6 +667,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
     raw->length         = bytes_to_int32(len - sizeof(xEvent));
     raw->detail         = ev->detail.button;
     raw->deviceid       = ev->deviceid;
+    raw->sourceid       = ev->sourceid;
     raw->valuators_len  = vallen;
     raw->flags          = ev->flags;
 
commit 765ef69295ddc473640c96f1b4f54e0b8bfc670e
Author: Max Schwarz <max.schwarz at online.de>
Date:   Tue Oct 4 22:06:08 2011 +0200

    dix: fix inverted handling of legacy scroll button events
    
    This bug led to inverted scrolling axes with drivers that support smooth
    scrolling axes but send legacy button events.
    
    Signed-off-by: Max Schwarz <Max at x-quadraht.de>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index ebf2653..97c3937 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1330,21 +1330,22 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
         double val, adj;
         int axis;
 
+        /* Up is negative on valuators, down positive */
         switch (buttons) {
         case 4:
-            adj = 1.0;
+            adj = -1.0;
             axis = v_scroll_axis;
             break;
         case 5:
-            adj = -1.0;
+            adj = 1.0;
             axis = v_scroll_axis;
             break;
         case 6:
-            adj = 1.0;
+            adj = -1.0;
             axis = h_scroll_axis;
             break;
         case 7:
-            adj = -1.0;
+            adj = 1.0;
             axis = h_scroll_axis;
             break;
         default:
commit 911e7368bf9c00d327e994a6f7a1d8d8f9b83c72
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Aug 30 16:58:04 2011 -0400

    Move pointOnScreen to inpututils.c
    
    We need this from other files too.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/events.c b/dix/events.c
index 0f5b042..f87d2bb 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -525,13 +525,6 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) {
 static void PostNewCursor(DeviceIntPtr pDev);
 
 static Bool
-pointOnScreen(ScreenPtr pScreen, int x, int y)
-{
-    return x >= pScreen->x && x < pScreen->x + pScreen->width &&
-           y >= pScreen->y && y < pScreen->y + pScreen->height;
-}
-
-static Bool
 XineramaSetCursorPosition(
     DeviceIntPtr pDev,
     int x,
@@ -550,13 +543,13 @@ XineramaSetCursorPosition(
     x += screenInfo.screens[0]->x;
     y += screenInfo.screens[0]->y;
 
-    if(!pointOnScreen(pScreen, x, y))
+    if(!point_on_screen(pScreen, x, y))
     {
 	FOR_NSCREENS(i)
 	{
 	    if(i == pScreen->myNum)
 		continue;
-	    if(pointOnScreen(screenInfo.screens[i], x, y))
+	    if(point_on_screen(screenInfo.screens[i], x, y))
 	    {
 		pScreen = screenInfo.screens[i];
 		break;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 0a3d3d8..eeae2a7 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -37,6 +37,7 @@
 #include "xkbstr.h"
 #include "inpututils.h"
 #include "eventstr.h"
+#include "scrnintstr.h"
 
 /* Check if a button map change is okay with the device.
  * Returns -1 for BadValue, as it collides with MappingBusy. */
@@ -619,6 +620,13 @@ void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms)
     event->sourceid = dev->id;
 }
 
+Bool
+point_on_screen(ScreenPtr pScreen, int x, int y)
+{
+    return x >= pScreen->x && x < pScreen->x + pScreen->width &&
+           y >= pScreen->y && y < pScreen->y + pScreen->height;
+}
+
 /**
  * Delete the element with the key from the list, freeing all memory
  * associated with the element..
diff --git a/include/input.h b/include/input.h
index 6ba1ab2..b7de5ca 100644
--- a/include/input.h
+++ b/include/input.h
@@ -608,4 +608,6 @@ extern _X_EXPORT const char* input_option_get_value(const InputOption *opt);
 extern _X_EXPORT void input_option_set_key(InputOption *opt, const char* key);
 extern _X_EXPORT void input_option_set_value(InputOption *opt, const char* value);
 
+extern _X_HIDDEN Bool point_on_screen(ScreenPtr pScreen, int x, int y);
+
 #endif /* INPUT_H */
commit d0a7cd759d4741a1ae118d579c90704410cde244
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Sep 2 09:53:02 2011 +1000

    dix: NewCurrentScreen must work on pointers where possible
    
    When a screen switch is triggered by PointerKeys, the device for
    NewCurrentScreen is the keyboard. Submitting pointer events for this
    keyboard (without valuators) has no effect as GPE ignores the event.
    
    Force the dequeuing through the XTest device attached to this device.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/events.c b/dix/events.c
index 4e21c2d..0f5b042 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3360,7 +3360,11 @@ WindowHasNewCursor(WindowPtr pWin)
 void
 NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
 {
-    SpritePtr pSprite = pDev->spriteInfo->sprite;
+    DeviceIntPtr ptr;
+    SpritePtr pSprite;
+
+    ptr = IsFloating(pDev) ? pDev : GetXTestDevice(GetMaster(pDev, MASTER_POINTER));
+    pSprite = ptr->spriteInfo->sprite;
 
     pSprite->hotPhys.x = x;
     pSprite->hotPhys.y = y;
@@ -3372,15 +3376,15 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
 	    pSprite->screen = newScreen;
 	    /* Make sure we tell the DDX to update its copy of the screen */
 	    if(pSprite->confineWin)
-		XineramaConfineCursorToWindow(pDev,
+		XineramaConfineCursorToWindow(ptr,
                         pSprite->confineWin, TRUE);
 	    else
-		XineramaConfineCursorToWindow(pDev, screenInfo.screens[0]->root, TRUE);
+		XineramaConfineCursorToWindow(ptr, screenInfo.screens[0]->root, TRUE);
 	    /* if the pointer wasn't confined, the DDX won't get
 	       told of the pointer warp so we reposition it here */
 	    if(!syncEvents.playingEvents)
 		(*pSprite->screen->SetCursorPosition)(
-                                                      pDev,
+                                                      ptr,
                                                       pSprite->screen,
 		    pSprite->hotPhys.x + screenInfo.screens[0]->x -
 			pSprite->screen->x,
@@ -3390,7 +3394,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
     } else
 #endif
     if (newScreen != pSprite->hotPhys.pScreen)
-	ConfineCursorToWindow(pDev, newScreen->root, TRUE, FALSE);
+	ConfineCursorToWindow(ptr, newScreen->root, TRUE, FALSE);
 }
 
 #ifdef PANORAMIX
commit 535b3789be3a7b43b5d9026e2b5150521d91e32b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Aug 31 14:15:02 2011 +1000

    dix: warn about keyboard events with valuator masks
    
    We don't actually handle the mask correctly. They're clipped and dropped
    into the event but that's about it. I don't think we did since 1.4, let's
    warn the user if this happens.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index b81562a..ebf2653 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -919,6 +919,11 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
        (key_code < 8 || key_code > 255))
         return 0;
 
+    if (mask_in && valuator_mask_size(mask_in) > 1) {
+        ErrorF("[dix] the server does not handle valuator masks with "
+                "keyboard events. This is a bug. You may fix it.\n");
+    }
+
     num_events = 1;
 
     events = UpdateFromMaster(events, pDev, DEVCHANGE_KEYBOARD_EVENT, &num_events);
commit 9537afb13f2750d22350b7441570332ae60e4860
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Aug 30 13:37:31 2011 +1000

    dix: fill out root_x/y for keyboard events
    
    Switching screens relies on rootx/y to be set to the correct value. Note:
    though we technically take a mask for GetKeyboardEvents we don't actually
    handle it properly to move the pointer as required (and generate motion
    events if needed).
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index c429715..b81562a 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -859,6 +859,15 @@ queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents)
         mieqEnqueue(device, &events[i]);
 }
 
+static void
+event_set_root_coordinates(DeviceEvent* event, double x, double y)
+{
+    event->root_x = trunc(x);
+    event->root_y = trunc(y);
+    event->root_x_frac = x - trunc(x);
+    event->root_y_frac = y - trunc(y);
+}
+
 /**
  * Generate internal events representing this keyboard event and enqueue
  * them on the event queue.
@@ -956,6 +965,13 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
 
     set_valuators(pDev, event, &mask);
 
+    if (!IsFloating(pDev)) {
+            DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER);
+            event_set_root_coordinates(event,
+                                       master->last.valuators[0],
+                                       master->last.valuators[1]);
+    }
+
     return num_events;
 }
 
@@ -1158,10 +1174,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     }
 
     /* root_x and root_y must be in screen co-ordinates */
-    event->root_x = trunc(screenx);
-    event->root_y = trunc(screeny);
-    event->root_x_frac = screenx - trunc(screenx);
-    event->root_y_frac = screeny - trunc(screeny);
+    event_set_root_coordinates(event, screenx, screeny);
 
     if (flags & POINTER_EMULATED) {
         raw->flags = XIPointerEmulated;


More information about the Xquartz-changes mailing list