[Xquartz-changes] xserver: Branch 'master' - 31 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Fri Apr 9 11:47:05 PDT 2010


Rebased ref, commits from common ancestor:
commit 1ac34213137cbcbdfcf4a07708e9af6ce0dbfb4a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Apr 5 16:54:22 2010 -0700

    XQuartz: Blacklist some oddball legacy Mac keycodes that break wine
    
    http://xquartz.macosforge.org/trac/ticket/295
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index a4a0b08..db4df89 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -39,6 +39,7 @@
 
 #define HACK_MISSING 1
 #define HACK_KEYPAD 1
+#define HACK_BLACKLIST 1
 
 #include <unistd.h>
 #include <stdio.h>
@@ -83,6 +84,7 @@ enum {
 
 #define UKEYSYM(u) ((u) | 0x01000000)
 
+#if HACK_MISSING
 /* Table of keycode->keysym mappings we use to fallback on for important
    keys that are often not in the Unicode mapping. */
 
@@ -117,7 +119,9 @@ const static struct {
     {107, XK_F14},
     {113, XK_F15},
 };
+#endif
 
+#if HACK_KEYPAD
 /* Table of keycode->old,new-keysym mappings we use to fixup the numeric
    keypad entries. */
 
@@ -143,6 +147,17 @@ const static struct {
     {91, XK_8, XK_KP_8},
     {92, XK_9, XK_KP_9},
 };
+#endif
+
+#if HACK_BLACKLIST
+/* <rdar://problem/7824370> wine notepad produces wrong characters on shift+arrow
+ * http://xquartz.macosforge.org/trac/ticket/295
+ * http://developer.apple.com/legacy/mac/library/documentation/mac/Text/Text-579.html
+ *
+ * legacy Mac keycodes for arrow keys that shift-modify to math symbols
+ */
+const static unsigned short keycode_blacklist[] = {66, 70, 72, 77};
+#endif
 
 /* Table mapping normal keysyms to their dead equivalents.
    FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
@@ -772,32 +787,38 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
         if (k[3] == k[2]) k[3] = NoSymbol;
         if (k[1] == k[0]) k[1] = NoSymbol;
         if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+        if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = NoSymbol;
     }
 
+#if HACK_MISSING
     /* Fix up some things that are normally missing.. */
-
-    if (HACK_MISSING) {
-        for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
-            k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
-
-            if    (k[0] == NoSymbol && k[1] == NoSymbol
-                && k[2] == NoSymbol && k[3] == NoSymbol)
-	      k[0] = known_keys[i].keysym;
-        }
+    
+    for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
+        k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
+        
+        if (   k[0] == NoSymbol && k[1] == NoSymbol
+            && k[2] == NoSymbol && k[3] == NoSymbol)
+            k[0] = known_keys[i].keysym;
     }
-
+#endif
+    
+#if HACK_KEYPAD
     /* And some more things. We find the right symbols for the numeric
-       keypad, but not the KP_ keysyms. So try to convert known keycodes. */
-
-    if (HACK_KEYPAD) {
-        for (i = 0; i < sizeof (known_numeric_keys)
-                        / sizeof (known_numeric_keys[0]); i++) {
-            k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
-
-            if (k[0] == known_numeric_keys[i].normal)
-                k[0] = known_numeric_keys[i].keypad;
-        }
+     keypad, but not the KP_ keysyms. So try to convert known keycodes. */
+    for (i = 0; i < sizeof (known_numeric_keys) / sizeof (known_numeric_keys[0]); i++) {
+        k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
+        
+        if (k[0] == known_numeric_keys[i].normal)
+            k[0] = known_numeric_keys[i].keypad;
     }
+#endif
+    
+#if HACK_BLACKLIST
+    for (i = 0; i < sizeof (keycode_blacklist) / sizeof (keycode_blacklist[0]); i++) {
+        k = info->keyMap + keycode_blacklist[i] * GLYPHS_PER_KEY;
+        k[0] = k[1] = k[2] = k[3] = NoSymbol;
+    }
+#endif
 
     DarwinBuildModifierMaps(info);
 
commit d7c98c1c81ae272f66edb05fde20f4c616604add
Merge: 82cf3a4... 03ccbd2...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 7 22:25:51 2010 -0700

    Merge remote branch 'whot/for-keith'

commit 03ccbd2579948d11e5f16f88cdf68a55f57c9d26
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 8 13:47:26 2010 +1000

    xfree86: remove dead input drivers from xorg.conf man page.
    
    These drivers have been deactivated for over a year now, let's not refer
    potential users to them.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 4782d61..f7ff6f6 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -2405,25 +2405,16 @@ Display drivers:
 .PP
 Input drivers:
 .BR acecad (__drivermansuffix__),
-.BR calcomp (__drivermansuffix__),
 .BR citron (__drivermansuffix__),
-.BR dmc (__drivermansuffix__),
-.BR dynapro (__drivermansuffix__),
 .BR elographics (__drivermansuffix__),
 .BR evdev (__drivermansuffix__),
 .BR fpit (__drivermansuffix__),
-.BR js_x (__drivermansuffix__),
 .BR joystick (__drivermansuffix__),
 .BR kbd (__drivermansuffix__),
-.BR magictouch (__drivermansuffix__),
-.BR microtouch (__drivermansuffix__),
 .BR mousedrv (__drivermansuffix__),
 .BR mutouch (__drivermansuffix__),
-.BR palmax (__drivermansuffix__),
 .BR penmount (__drivermansuffix__),
 .BR synaptics (__drivermansuffix__),
-.BR tek4957 (__drivermansuffix__),
-.BR ur98 (__drivermansuffix__),
 .BR vmmouse (__drivermansuffix__),
 .BR void (__drivermansuffix__),
 .BR wacom (__drivermansuffix__).
commit d4dd3d0085f8eaca8c989aaeace1a1a24c5ebf49
Author: Dan Nicholson <dbn.lists at gmail.com>
Date:   Sat Apr 3 09:33:51 2010 -0700

    Move 10-evdev.conf to system config dir $datadir/X11/xorg.conf.d
    
    Since the server searches in a vendor specific path now, we can install
    the evdev catchall there without disturbing local administration files.
    
    Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/config/Makefile.am b/config/Makefile.am
index eed7454..675a3b2 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -9,7 +9,7 @@ AM_CFLAGS += $(UDEV_CFLAGS)
 libconfig_la_SOURCES += udev.c
 libconfig_la_LIBADD = $(UDEV_LIBS)
 
-xorgconfddir = $(prefix)/etc/X11/$(XF86CONFIGDIR)
+xorgconfddir = $(datadir)/X11/$(XF86CONFIGDIR)
 xorgconfd_DATA = 10-evdev.conf
 
 else
commit 95f01bdfee8241371675f0089170fa6b2908d815
Author: Dan Nicholson <dbn.lists at gmail.com>
Date:   Sat Apr 3 10:08:25 2010 -0700

    xfree86: Search for a system xorg.conf.d
    
    In addition to the conf files found in /etc/X11 or $sysconfdir/X11 used
    for local administration, we also reserve a system directory for vendor
    and package usage. The simple search path is:
    
    	/usr/share/X11/xorg.conf.d
    	$datadir/X11/xorg.conf.d
    
    Files from these directories will have the lowest config priority. The
    directory $datadir/X11/xorg.conf.d is exported from xorg-server.pc in
    the variable "sysconfigdir". Packages should install their .conf files
    to the directory specified by:
    
    	`pkg-config --variable=sysconfigdir xorg-server`
    
    Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/configure.ac b/configure.ac
index 591d2b4..0d0dffd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1792,8 +1792,10 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([driverdir])
 	sdkdir="$includedir/xorg"
 	extdir="$includedir/X11/extensions"
+	sysconfigdir="$datadir/X11/$XF86CONFIGDIR"
 	AC_SUBST([sdkdir])
 	AC_SUBST([extdir])
+	AC_SUBST([sysconfigdir])
 	AC_SUBST([logdir])
 
 	# stuff the ABI versions into the pc file too
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index d02c22a..1e9543f 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -104,6 +104,9 @@ extern DeviceAssocRec mouse_assoc;
 #define USER_CONFIGDIRPATH	"/etc/X11/%R," "%C/X11/%R," \
 				"/etc/X11/%X," "%C/X11/%X"
 #endif
+#ifndef SYS_CONFIGDIRPATH
+#define SYS_CONFIGDIRPATH	"/usr/share/X11/%X," "%D/X11/%X"
+#endif
 #ifndef PROJECTROOT
 #define PROJECTROOT	"/usr/X11R6"
 #endif
@@ -2421,7 +2424,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
 ConfigStatus
 xf86HandleConfigFile(Bool autoconfig)
 {
-    const char *filename, *dirname;
+    const char *filename, *dirname, *sysdirname;
     char *filesearch, *dirsearch;
     MessageType filefrom = X_DEFAULT;
     MessageType dirfrom = X_DEFAULT;
@@ -2444,6 +2447,8 @@ xf86HandleConfigFile(Bool autoconfig)
 	    dirfrom = X_CMDLINE;
 
 	xf86initConfigFiles();
+	sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH, NULL,
+					    PROJECTROOT);
 	dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
 	filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
 	if (filename) {
@@ -2464,7 +2469,10 @@ xf86HandleConfigFile(Bool autoconfig)
 			"Unable to locate/open config directory: \"%s\"\n",
 			xf86ConfigDir);
 	}
-	if (!filename && !dirname)
+	if (sysdirname)
+	    xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
+			sysdirname);
+	if (!filename && !dirname && !sysdirname)
 	    return CONFIG_NOFILE;
     }
 
diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index acfa1ca..4782d61 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -138,6 +138,18 @@ is the path specified with the
 .B \-configdir
 command line option (which may be absolute or relative).
 .PP
+Finally, configuration files will also be searched for in directories
+reserved for system use. These are to separate configuration files from
+the vendor or 3rd party packages from those of local administration.
+These files are found in the following directories:
+.PP
+.RS 4
+.nf
+.I /usr/share/X11/__xconfigdir__
+.I __datadir__/X11/__xconfigdir__
+.fi
+.RE
+.PP
 The
 .I __xconfigfile__
 and
diff --git a/xorg-server.pc.in b/xorg-server.pc.in
index 3d58dab..376cb93 100644
--- a/xorg-server.pc.in
+++ b/xorg-server.pc.in
@@ -2,8 +2,10 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
 includedir=@includedir@
+datarootdir=@datarootdir@
 moduledir=@moduledir@
 sdkdir=@sdkdir@
+sysconfigdir=@sysconfigdir@
 
 abi_ansic=@abi_ansic@
 abi_videodrv=@abi_videodrv@
commit a1bae63dc634a5a79861eab128c63506081f7ed9
Author: Dan Nicholson <dbn.lists at gmail.com>
Date:   Sat Apr 3 09:33:49 2010 -0700

    xfree86: Set a saner search path for xorg.conf.d
    
    There's no reason to carry all the oddities from xorg.conf like appended
    hostname to the search path for xorg.conf.d. This changes it to something
    very simple:
    
    	/etc/X11/<cmdline>
    	$sysconfdir/X11/<cmdline>
    	/etc/X11/xorg.conf.d
    	$sysconfdir/X11/xorg.conf.d
    
    Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/cpprules.in b/cpprules.in
index 301305e..6e43578 100644
--- a/cpprules.in
+++ b/cpprules.in
@@ -34,6 +34,7 @@ MANDEFS = \
 	-D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \
 	-D__mandir__=$(mandir) \
 	-D__projectroot__=$(prefix) \
+	-D__sysconfdir__=$(sysconfdir) \
 	-D__datadir__=$(datadir) \
 	-D__xconfigfile__=$(__XCONFIGFILE__) \
 	-D__xconfigdir__=$(__XCONFIGDIR__) \
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 718a078..d02c22a 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -97,20 +97,12 @@ extern DeviceAssocRec mouse_assoc;
 #endif
 #ifndef ROOT_CONFIGDIRPATH
 #define ROOT_CONFIGDIRPATH	"%A," "%R," \
-				"/etc/X11/%R," "%P/etc/X11/%R," \
-				"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
-				"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
-				"%P/etc/X11/%X," \
-				"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
-				"%P/lib/X11/%X"
+				"/etc/X11/%R," "%C/X11/%R," \
+				"/etc/X11/%X," "%C/X11/%X"
 #endif
 #ifndef USER_CONFIGDIRPATH
-#define USER_CONFIGDIRPATH	"/etc/X11/%S," "%P/etc/X11/%S," \
-				"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
-				"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
-				"%P/etc/X11/%X," \
-				"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
-				"%P/lib/X11/%X"
+#define USER_CONFIGDIRPATH	"/etc/X11/%R," "%C/X11/%R," \
+				"/etc/X11/%X," "%C/X11/%X"
 #endif
 #ifndef PROJECTROOT
 #define PROJECTROOT	"/usr/X11R6"
diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 9a40ce3..acfa1ca 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -107,16 +107,9 @@ directories when the server is started as a normal user:
 .RS 4
 .nf
 .IR /etc/X11/ <cmdline>
-.IR __projectroot__/etc/X11/ <cmdline>
-.I /etc/X11/__xconfigdir__\-4
+.IR __sysconfdir__/X11/ <cmdline>
 .I /etc/X11/__xconfigdir__
-.I /etc/__xconfigdir__
-.IR __projectroot__/etc/X11/__xconfigdir__. <hostname>
-.I __projectroot__/etc/X11/__xconfigdir__\-4
-.I __projectroot__/etc/X11/__xconfigdir__
-.IR __projectroot__/lib/X11/__xconfigdir__. <hostname>
-.I __projectroot__/lib/X11/__xconfigdir__\-4
-.I __projectroot__/lib/X11/__xconfigdir__
+.I __sysconfdir__/X11/__xconfigdir__
 .fi
 .RE
 .PP
@@ -133,16 +126,9 @@ config directory search locations are as follows:
 .nf
 <cmdline>
 .IR /etc/X11/ <cmdline>
-.IR __projectroot__/etc/X11/ <cmdline>
-.I /etc/X11/__xconfigdir__\-4
+.IR __sysconfdir__/X11/ <cmdline>
 .I /etc/X11/__xconfigdir__
-.I /etc/__xconfigdir__
-.IR __projectroot__/etc/X11/__xconfigdir__. <hostname>
-.I __projectroot__/etc/X11/__xconfigdir__\-4
-.I __projectroot__/etc/X11/__xconfigdir__
-.IR __projectroot__/lib/X11/__xconfigdir__. <hostname>
-.I __projectroot__/lib/X11/__xconfigdir__\-4
-.I __projectroot__/lib/X11/__xconfigdir__
+.I __sysconfdir__/X11/__xconfigdir__
 .fi
 .RE
 .PP
commit 2ac33888a9a5766aaf88bc92a8bd1d489873524c
Author: Dan Nicholson <dbn.lists at gmail.com>
Date:   Sat Apr 3 09:33:48 2010 -0700

    xfree86: Document how -configdir affects the xorg.conf.d search path
    
    Explain the "safe" path dance for -configdir, too.
    
    Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 93c8ac4..9a40ce3 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -102,10 +102,12 @@ is the machine's hostname as reported by
 .BR gethostname (__libmansuffix__).
 .PP
 Additional configuration files are searched for in the following
-directories:
+directories when the server is started as a normal user:
 .PP
 .RS 4
 .nf
+.IR /etc/X11/ <cmdline>
+.IR __projectroot__/etc/X11/ <cmdline>
 .I /etc/X11/__xconfigdir__\-4
 .I /etc/X11/__xconfigdir__
 .I /etc/__xconfigdir__
@@ -118,6 +120,38 @@ directories:
 .fi
 .RE
 .PP
+where
+.I <cmdline>
+is a relative path (with no \(lq..\(rq components) specified with the
+.B \-configdir
+command line option.
+.PP
+When the __xservername__ server is started by the \(lqroot\(rq user, the
+config directory search locations are as follows:
+.PP
+.RS 4
+.nf
+<cmdline>
+.IR /etc/X11/ <cmdline>
+.IR __projectroot__/etc/X11/ <cmdline>
+.I /etc/X11/__xconfigdir__\-4
+.I /etc/X11/__xconfigdir__
+.I /etc/__xconfigdir__
+.IR __projectroot__/etc/X11/__xconfigdir__. <hostname>
+.I __projectroot__/etc/X11/__xconfigdir__\-4
+.I __projectroot__/etc/X11/__xconfigdir__
+.IR __projectroot__/lib/X11/__xconfigdir__. <hostname>
+.I __projectroot__/lib/X11/__xconfigdir__\-4
+.I __projectroot__/lib/X11/__xconfigdir__
+.fi
+.RE
+.PP
+where
+.I <cmdline>
+is the path specified with the
+.B \-configdir
+command line option (which may be absolute or relative).
+.PP
 The
 .I __xconfigfile__
 and
commit 2460e921d18fd264e6f6374be0908f4100442650
Author: Dan Nicholson <dbn.lists at gmail.com>
Date:   Sat Apr 3 09:33:47 2010 -0700

    xfree86: Allow adding sysconfdir and datadir to config search paths
    
    We could just use $projectroot/etc and $projectroot/share, but the user
    might have other plans for them.
    
    Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am
index 49c191f..caf7079 100644
--- a/hw/xfree86/parser/Makefile.am
+++ b/hw/xfree86/parser/Makefile.am
@@ -34,7 +34,9 @@ libxf86config_a_SOURCES = \
 	$(INTERNAL_SOURCES)
 libxf86config_a_CFLAGS = $(AM_CFLAGS)
 
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) \
+	-DSYSCONFDIR=\"$(sysconfdir)\" \
+	-DDATADIR=\"$(datadir)\"
 
 EXTRA_DIST = \
 	Configint.h \
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index cdca9ca..8aab0cf 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -599,6 +599,8 @@ xf86pathIsSafe(const char *path)
  *    %F    config file environment ($XORGCONFIG) as a relative path
  *    %G    config file environment ($XORGCONFIG) as a safe path
  *    %P    projroot
+ *    %C    sysconfdir
+ *    %D    datadir
  *    %M    major version number
  *    %%    %
  */
@@ -615,6 +617,12 @@ xf86pathIsSafe(const char *path)
 #ifndef PROJECTROOT
 #define PROJECTROOT	"/usr/X11R6"
 #endif
+#ifndef SYSCONFDIR
+#define SYSCONFDIR	PROJECTROOT "/etc"
+#endif
+#ifndef DATADIR
+#define DATADIR		PROJECTROOT "/share"
+#endif
 #ifndef XCONFENV
 #define XCONFENV	"XORGCONFIG"
 #endif
@@ -755,6 +763,12 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
 				else
 					BAIL_OUT;
 				break;
+			case 'C':
+				APPEND_STR(SYSCONFDIR);
+				break;
+			case 'D':
+				APPEND_STR(DATADIR);
+				break;
 			case 'M':
 				if (!majorvers[0]) {
 					if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) {
commit c8a608cb6ce8f9c86258c1ab49084f691fa9cc51
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 7 10:04:38 2010 +1000

    config: only match sane devices in 10-evdev.conf
    
    Having a generic catchall also adds devices like accelerometers. These
    devices make X unusable, hence restrict matching to "known sane" devices
    like pointers, touchpads, keyboards, tablets and touchscreens.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Julien Cristau <jcristau at debian.org>
    Acked-by: Dan Nicholson <dbn.lists at gmail.com>
    Acked-by: James Cloos <cloos at jhcloos.com>

diff --git a/config/10-evdev.conf b/config/10-evdev.conf
index 7406f4e..cc83ab2 100644
--- a/config/10-evdev.conf
+++ b/config/10-evdev.conf
@@ -1,8 +1,40 @@
 #
 # Catch-all evdev loader for udev-based systems
-#
+# We don't simply match on any device since that also adds accelerometers
+# and other devices that we don't really want to use. The list below
+# matches everything but joysticks.
+
 Section "InputClass"
-        Identifier "evdev-catchall"
+        Identifier "evdev pointer catchall"
+        MatchIsPointer "on"
+        MatchDevicePath "/dev/input/event*"
         Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev keyboard catchall"
+        MatchIsKeyboard "on"
         MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev touchpad catchall"
+        MatchIsTouchpad "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev tablet catchall"
+        MatchIsTablet "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev touchscreen catchall"
+        MatchIsTouchscreen "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
 EndSection
commit 6b09f66d8c6ebcee70382b5cca1ba82b68f20afa
Author: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
Date:   Fri Apr 2 12:48:21 2010 -0700

    Don't keep a pointer to a possibly freed cursor when changing screens, preventing a crash in xf86CursorEnableDisableFBAccess() trying to restore it.
    
    Signed-off-by: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 7f23d9e..f5f0873 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -312,6 +312,7 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
             xf86SetCursor(pScreen, NullCursor, x, y);
             ScreenPriv->isUp = FALSE;
         }
+        ScreenPriv->CurrentCursor = NullCursor;
         return;
     }
 
commit 82cf3a4ae01811917f7903d6f62ba9b7132adf7e
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Tue Apr 6 15:52:18 2010 -0700

    Convert x86emu fixed size int typedefs to use stdint types
    
    Fixes x86emu builds when using non-gnu compilers now that u64 is required
    
    Before this fix, the u64 type would not be defined, causing
    x86emu/sys.c to fail to build:
    "sys.c", line 102: syntax error before or at: ldq_u
    "sys.c", line 102: syntax error before or at: *
    
    Since Keith requested using <stdint.h>, converted all the x86emu
    typedefs to use the stdint types.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Acked-by: Matt Turner <mattst88 at gmail.com>
    Acked-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/x86emu/x86emu/types.h b/hw/xfree86/x86emu/x86emu/types.h
index c18e11c..fa23800 100644
--- a/hw/xfree86/x86emu/x86emu/types.h
+++ b/hw/xfree86/x86emu/x86emu/types.h
@@ -61,45 +61,21 @@
 
 /*---------------------- Macros and type definitions ----------------------*/
 
-/* Currently only for Linux/32bit */
-#undef  __HAS_LONG_LONG__
-#if defined(__GNUC__) && !defined(NO_LONG_LONG)
-#define __HAS_LONG_LONG__
-#endif
-
-/* Taken from Xmd.h */
-#undef NUM32
-#if defined (_LP64) || \
-    defined(__alpha) || defined(__alpha__) || \
-    defined(__ia64__) || defined(ia64) || \
-    defined(__sparc64__) || \
-    defined(__s390x__) || \
-    defined(__hppa__) && defined(__LP64) || \
-    defined(__amd64__) || defined(amd64) 
-#define NUM32 int
-#else
-#define NUM32 long
-#endif
+#include <stdint.h>
 
-typedef unsigned char 		u8;
-typedef unsigned short 		u16;
-typedef unsigned NUM32 		u32;
-#ifdef __HAS_LONG_LONG__
-typedef unsigned long long 	u64;
-#endif
+typedef uint8_t				u8;
+typedef uint16_t			u16;
+typedef uint32_t			u32;
+typedef uint64_t	 		u64;
 
-typedef char 				s8;
-typedef short 				s16;
-typedef NUM32 				s32;
-#ifdef __HAS_LONG_LONG__
-typedef long long 			s64;
-#endif
+typedef int8_t 				s8;
+typedef int16_t				s16;
+typedef int32_t				s32;
+typedef int64_t				s64;
 
 typedef unsigned int			uint;
 typedef int 				sint;
 
 typedef u16 X86EMU_pioAddr;
 
-#undef NUM32
-
 #endif	/* __X86EMU_TYPES_H */
commit a9fe7cfa77ccee64d68732dc3f37d35cbfc27a65
Author: Paulo Ricardo Zanoni <pzanoni at mandriva.com>
Date:   Thu Mar 11 14:28:18 2010 -0300

    dix: be more verbose when we run out of opcodes
    
    If we run out of opcodes, nothing is print on the log, making the
    problem hard to debug. In the current Xserver, if you enable some
    extensions like multibuffer (+2 events) and use nvidia binary driver (+5
    events) you can run out of opcode numbers.
    
    Signed-off-by: Paulo Ricardo Zanoni <pzanoni at mandriva.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/extension.c b/dix/extension.c
index fb83af1..f348665 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -83,8 +83,11 @@ AddExtension(char *name, int NumEvents, int NumErrors,
     if (!MainProc || !SwappedMainProc || !MinorOpcodeProc)
         return((ExtensionEntry *) NULL);
     if ((lastEvent + NumEvents > LAST_EVENT) || 
-	        (unsigned)(lastError + NumErrors > LAST_ERROR))
+	        (unsigned)(lastError + NumErrors > LAST_ERROR)) {
+        LogMessage(X_ERROR, "Not enabling extension %s: maximum number of "
+                   "events or errors exceeded.\n", name);
         return((ExtensionEntry *) NULL);
+    }
 
     ext = xalloc(sizeof(ExtensionEntry));
     if (!ext)
commit 6150595bdbacde13bb4f9aba81b15435089bee94
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Mon Apr 5 19:12:22 2010 -0400

    doc: specify 1.6.1 as the minimum version for doxygen.
    
    Older versions generate filenames that are different from
    the ones listed in the Makefile.
    
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index f41b051..cdde2ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,10 +34,10 @@ AM_MAINTAINER_MODE
 
 # Require xorg-macros: XORG_DEFAULT_OPTIONS
 m4_ifndef([XORG_MACROS_VERSION],
-          [m4_fatal([must install xorg-macros 1.5 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.5)
+          [m4_fatal([must install xorg-macros 1.6 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.6)
 XORG_DEFAULT_OPTIONS
-XORG_WITH_DOXYGEN
+XORG_WITH_DOXYGEN(1.6.1)
 
 m4_ifndef([XORG_FONT_MACROS_VERSION], [m4_fatal([must install fontutil 1.1 or later before running autoconf/autogen])])
 XORG_FONT_MACROS_VERSION(1.1)
commit cbda58c963af5bb9c4643e9017dd4eec589ceff3
Merge: a7698a6... c983f40...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 7 15:51:38 2010 -0700

    Merge remote branch 'yselkowitz/master'

commit a7698a677682a32960b885c22fdba2add70f4658
Merge: 495cec7... 165a4a9...
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Apr 6 12:36:15 2010 -0700

    Merge remote branch 'jbarnes/master'

commit c983f40fe4f30311f31a9df699cdc888709251d0
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Wed Feb 24 15:17:42 2010 -0600

    Cygwin/X: Add configure option for WindowsWM
    
    WindowsWM support is still experimental, and uses the Rootless extension
    which currently breaks the simultaneous build of the other DDXs (see
    commit b3415187e92960cbff784108b5a3a8d130dc34c5).  So we disable it by
    default for now; once the latter issue is fixed we can make this 'auto'.
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>

diff --git a/configure.ac b/configure.ac
index 2d261db..f41b051 100644
--- a/configure.ac
+++ b/configure.ac
@@ -644,6 +644,7 @@ AC_ARG_ENABLE(xaa,               AS_HELP_STRING([--enable-xaa], [Build XAA (defa
 AC_ARG_ENABLE(vgahw,          AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), [VGAHW=$enableval], [VGAHW=yes])
 AC_ARG_ENABLE(vbe,            AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
 AC_ARG_ENABLE(int10-module,     AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
+AC_ARG_ENABLE(windowswm,      AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -1843,26 +1844,30 @@ fi
 AC_MSG_RESULT([$XWIN])
 
 if test "x$XWIN" = xyes; then
-	PKG_CHECK_EXISTS($WINDOWSWMPROTO, [WINDOWSWM=yes], [WINDOWSWM=no])
 	AC_DEFINE_DIR(SYSCONFDIR, sysconfdir, [Location of system.XWinrc])
 	AC_DEFINE_DIR(DEFAULT_LOGDIR, logdir, [Default log location])
 	AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
 	AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
 	AC_CHECK_TOOL(WINDRES, windres)
+
+	PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
+
+	if test "x$WINDOWSWM" = xauto; then
+		PKG_CHECK_EXISTS($WINDOWSWMPROTO, [WINDOWSWM=yes], [WINDOWSWM=no])
+	fi
+	if test "x$WINDOWSWM" = xyes ; then
+		PKG_CHECK_MODULES(WINDOWSWM, $WINDOWSWMPROTO)
+		XWINMODULES_CFLAGS="$XWINMODULES_CFLAGS $WINDOWSWM_CFLAGS"
+		AC_DEFINE(ROOTLESS,1,[Build Rootless code])
+	fi
+
 	case $host_os in
 		cygwin*)
 			XWIN_SERVER_NAME=XWin
-			PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
 			AC_DEFINE(HAS_DEVWINDOWS,1,[Cygwin has /dev/windows for signaling new win32 messages])
-
-			dnl if we have windowswmproto, build rootless extension for multwindowextwm mode
-			if test "x$WINDOWSWM" = xyes ; then
-			       AC_DEFINE(ROOTLESS,1,[Build Rootless code])
-			fi
 			;;
 		mingw*)
 			XWIN_SERVER_NAME=Xming
-			PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
 			AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
 			AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
 			XWIN_SYS_LIBS=-lwinsock2
commit 20701522be803fe47e921fcf059dadf64c7f287d
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Feb 18 14:19:21 2010 -0600

    Don't enable ROOTLESS_WORKAROUND, it breaks composite
    
    This possibly brings back whatever the bug is in
    http://bugs.freedesktop.org/show_bug.cgi?id=1168 for
    -rootless mode, but since we don't have reproduction
    steps for that, I can't test that...
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Tested-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>

diff --git a/configure.ac b/configure.ac
index 54056ba..2d261db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1858,7 +1858,6 @@ if test "x$XWIN" = xyes; then
 			dnl if we have windowswmproto, build rootless extension for multwindowextwm mode
 			if test "x$WINDOWSWM" = xyes ; then
 			       AC_DEFINE(ROOTLESS,1,[Build Rootless code])
-			       CFLAGS="$CFLAGS -DROOTLESS_WORKAROUND"
 			fi
 			;;
 		mingw*)
commit 95c9947f6244d37592958b70760bd1ac885b625a
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Wed Mar 24 00:08:23 2010 -0500

    Cygwin/X: Disable unsupported extensions in configure
    
    Several extensions are not supported by XWin, some of which are enabled
    by default in configure.  We forcefully disable these early on so that
    configure will succeed without arguments and without the corresponding
    proto installed.
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>

diff --git a/configure.ac b/configure.ac
index 9dcd6bd..54056ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -724,8 +724,16 @@ XORG_CHECK_LINUXDOC
 dnl Handle installing libxf86config
 AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])
 
-dnl XQuartz DDX Detection... Yes, it's ugly to have it here... but we need to handle this early on
+dnl DDX Detection... Yes, it's ugly to have it here... but we need to
+dnl handle this early on so that we don't require unsupported extensions
 case $host_os in
+	cygwin*)
+		DGA=no
+		DRI2=no
+		XF86VIDMODE=no
+		XSELINUX=no
+		XV=no
+		;;
 	darwin*)
 		DRI2=no
 
@@ -1875,10 +1883,6 @@ if test "x$XWIN" = xyes; then
 
 	AC_DEFINE(DDXOSVERRORF, 1, [Use OsVendorVErrorF])
 	AC_DEFINE(DDXBEFORERESET, 1, [Use ddxBeforeReset ])
-	if test "x$XF86VIDMODE" = xyes; then
-		AC_MSG_NOTICE([Disabling XF86VidMode extension])
-		XF86VIDMODE=no
-	fi
 fi
 AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
commit 24c9d48cd6999f1e90f9f0e2bbfebd8e95d314d8
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Mon Mar 22 12:47:52 2010 -0500

    Disable setuid configure test on Cygwin
    
    Only Xorg is installed setuid, so there is no need to run this configure
    test on Cygwin.
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>

diff --git a/configure.ac b/configure.ac
index 591d2b4..9dcd6bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -673,6 +673,7 @@ AC_ARG_ENABLE(install-setuid,
 AC_MSG_CHECKING([to see if we can install the Xorg server as root])
 if test "x$SETUID" = "xauto" ; then
 	case $host_os in
+	    cygwin*)		SETUID="no"  ;;
 	    darwin*)		SETUID="no"  ;;
 	    *)
 	   	case $host_cpu in
commit 165a4a9c7de0fcc6ef6a6421736b412ccb35965e
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Tue Mar 23 09:47:08 2010 -0700

    GLX/DRI2: expose swap control extensions if DDX support is present
    
    Export DDX swap control status from the DRI2 module and check for it in
    GLX when initializing extensions.
    
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index edd29b0..e791bf6 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -616,6 +616,7 @@ glxDRILeaveVT (int index, int flags)
 static void
 initializeExtensions(__GLXDRIscreen *screen)
 {
+    ScreenPtr pScreen = screen->base.pScreen;
     const __DRIextension **extensions;
     int i;
 
@@ -625,10 +626,17 @@ initializeExtensions(__GLXDRIscreen *screen)
 			 "GLX_MESA_copy_sub_buffer");
     LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
 
-    /* FIXME: only if DDX supports it */
     __glXEnableExtension(screen->glx_enable_bits, "GLX_INTEL_swap_event");
     LogMessage(X_INFO, "AIGLX: enabled GLX_INTEL_swap_event\n");
 
+    if (DRI2HasSwapControl(pScreen)) {
+	__glXEnableExtension(screen->glx_enable_bits,
+			     "GLX_SGI_swap_control");
+	__glXEnableExtension(screen->glx_enable_bits,
+			     "GLX_MESA_swap_control");
+	LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n");
+    }
+
     for (i = 0; extensions[i]; i++) {
 #ifdef __DRI_READ_DRAWABLE
 	if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
@@ -639,19 +647,6 @@ initializeExtensions(__GLXDRIscreen *screen)
 	}
 #endif
 
-#ifdef __DRI_SWAP_CONTROL
-	if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
-	    screen->swapControl =
-		(const __DRIswapControlExtension *) extensions[i];
-	    __glXEnableExtension(screen->glx_enable_bits,
-				 "GLX_SGI_swap_control");
-	    __glXEnableExtension(screen->glx_enable_bits,
-				 "GLX_MESA_swap_control");
-	    
-	    LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n");
-	}
-#endif
-
 #ifdef __DRI_TEX_BUFFER
 	if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
 	    screen->texBuffer =
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 8b4c36f..2bdb733 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -831,6 +831,14 @@ DRI2DestroyDrawable(DrawablePtr pDraw)
 }
 
 Bool
+DRI2HasSwapControl(ScreenPtr pScreen)
+{
+    DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+    return (ds->ScheduleSwap && ds->GetMSC);
+}
+
+Bool
 DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
 	    const char **driverName, const char **deviceName)
 {
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index e1881ba..ce8a5df 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -188,6 +188,8 @@ extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr	pScreen,
 
 extern _X_EXPORT void DRI2CloseScreen(ScreenPtr pScreen);
 
+extern _X_EXPORT Bool DRI2HasSwapControl(ScreenPtr pScreen);
+
 extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen,
 		 unsigned int driverType,
 		 int *fd,
commit 5933b0abc6a76aaea84aa534df89900cd795c888
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Mon Mar 8 15:10:47 2010 -0800

    DRI2: prevent swap wakes from waking MSC waiters
    
    If a few swaps were queued leading to a throttle related block on the
    client, and then the client submitted an MSC wait, one of the previous
    swap wakeups could have caused the MSC wait to complete early.  Add a
    flag for this to prevent a swap wake from prematurely waking an MSC
    waiter.
    
    Reported-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 8a67122..8b4c36f 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -63,6 +63,7 @@ typedef struct _DRI2Drawable {
     int			 bufferCount;
     unsigned int	 swapsPending;
     ClientPtr		 blockedClient;
+    Bool		 blockedOnMsc;
     int			 swap_interval;
     CARD64		 swap_count;
     int64_t		 target_sbc; /* -1 means no SBC wait outstanding */
@@ -145,6 +146,7 @@ DRI2CreateDrawable(DrawablePtr pDraw)
     pPriv->bufferCount = 0;
     pPriv->swapsPending = 0;
     pPriv->blockedClient = NULL;
+    pPriv->blockedOnMsc = FALSE;
     pPriv->swap_count = 0;
     pPriv->target_sbc = -1;
     pPriv->swap_interval = 1;
@@ -402,6 +404,15 @@ DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
     return FALSE;
 }
 
+static void
+__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
+{
+    if (pPriv->blockedClient == NULL) {
+	IgnoreClient(client);
+	pPriv->blockedClient = client;
+    }
+}
+
 void
 DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
 {
@@ -411,10 +422,8 @@ DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
     if (pPriv == NULL)
 	return;
 
-    if (pPriv->blockedClient == NULL) {
-	IgnoreClient(client);
-	pPriv->blockedClient = client;
-    }
+    __DRI2BlockClient(client, pPriv);
+    pPriv->blockedOnMsc = TRUE;
 }
 
 int
@@ -495,6 +504,7 @@ DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
 	AttendClient(pPriv->blockedClient);
 
     pPriv->blockedClient = NULL;
+    pPriv->blockedOnMsc = FALSE;
 
     /* If there's still a swap pending, let DRI2SwapComplete free it */
     if (pPriv->refCount == 0 && pPriv->swapsPending == 0)
@@ -516,8 +526,12 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
     }
 
     /*
-     * Swap completed.  Either wake up an SBC waiter or a client that was
-     * blocked due to GLX activity during a swap.
+     * Swap completed.
+     * Wake the client iff:
+     *   - it was waiting on SBC
+     *   - was blocked due to GLX make current
+     *   - was blocked due to swap throttling
+     *   - is not blocked due to an MSC wait
      */
     if (pPriv->target_sbc != -1 &&
 	pPriv->target_sbc <= pPriv->swap_count) {
@@ -527,10 +541,11 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
 
 	AttendClient(pPriv->blockedClient);
 	pPriv->blockedClient = NULL;
-    } else if (pPriv->target_sbc == -1) {
-	if (pPriv->blockedClient)
+    } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
+	if (pPriv->blockedClient) {
 	    AttendClient(pPriv->blockedClient);
-	pPriv->blockedClient = NULL;
+	    pPriv->blockedClient = NULL;
+	}
     }
 }
 
@@ -582,7 +597,7 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
 	pPriv->blockedClient == NULL) {
 	ResetCurrentRequest(client);
 	client->sequence--;
-	DRI2BlockClient(client, pDrawable);
+	__DRI2BlockClient(client, pPriv);
 	return TRUE;
     }
 
@@ -780,7 +795,7 @@ DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
     }
 
     pPriv->target_sbc = target_sbc;
-    DRI2BlockClient(client, pDraw);
+    __DRI2BlockClient(client, pPriv);
 
     return Success;
 }
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 066cc39..e1881ba 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -257,6 +257,7 @@ extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw);
 
 extern _X_EXPORT Bool DRI2CanExchange(DrawablePtr pDraw);
 
+/* Note: use *only* for MSC related waits */
 extern _X_EXPORT void DRI2BlockClient(ClientPtr client, DrawablePtr pDraw);
 
 extern _X_EXPORT void DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw,
commit b00d435ddf2e9817e33bfd5f7e9b905442dc23c7
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Mon Mar 8 12:41:25 2010 -0800

    DRI2: handle swapsPending better
    
    Avoid a potential swapsPending underflow by incrementing it before
    ScheduleSwap, which may complete it immediately.  And be sure to
    decrement it again in case the schedule failed.
    
    Reported-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 3fc7f4e..8a67122 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -654,15 +654,16 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
 	*swap_target = target_msc;
     }
 
+    pPriv->swapsPending++;
     ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
 			      swap_target, divisor, remainder, func, data);
     if (!ret) {
+	pPriv->swapsPending--; /* didn't schedule */
         xf86DrvMsg(pScreen->myNum, X_ERROR,
 		   "[DRI2] %s: driver failed to schedule swap\n", __func__);
 	return BadDrawable;
     }
 
-    pPriv->swapsPending++;
     pPriv->last_swap_target = *swap_target;
 
     /* According to spec, return expected swapbuffers count SBC after this swap
commit 0294ff2a5cadddc8fcc77ba9a851f979f0b91fc3
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Mon Mar 8 12:39:54 2010 -0800

    DRI2: throttle swaps at submission time too
    
    We need to throttle swaps here in addition to when the context is made
    current to avoid causing problems with clients that just swap.
    Throttling here also ensures our swaps get ordered as long as we block
    the client occasionally.
    
    Reported-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 7a9f8ca..094d54d 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -384,6 +384,13 @@ ProcDRI2SwapBuffers(ClientPtr client)
 		       DixReadAccess | DixWriteAccess, &pDrawable, &status))
 	return status;
 
+    /*
+     * Ensures an out of control client can't exhaust our swap queue, and
+     * also orders swaps.
+     */
+    if (DRI2ThrottleClient(client, pDrawable))
+	return client->noClientException;
+
     target_msc = vals_to_card64(stuff->target_msc_lo, stuff->target_msc_hi);
     divisor = vals_to_card64(stuff->divisor_lo, stuff->divisor_hi);
     remainder = vals_to_card64(stuff->remainder_lo, stuff->remainder_hi);
commit db1c7cb604167baf49e61be4c09ccf7b592c4af3
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Mon Mar 8 12:38:37 2010 -0800

    DRI2: advertise lowest supported DRI2 protocol version
    
    Update our supported DRI2 protocol version as each driver does
    DRI2ScreenInit, since depending on available kernel features, each DDX
    may support different callbacks and therefore protocol.
    
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 9825a55..3fc7f4e 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -45,6 +45,9 @@
 
 #include "xf86.h"
 
+CARD8 dri2_major; /* version of DRI2 supported by DDX */
+CARD8 dri2_minor;
+
 static int dri2ScreenPrivateKeyIndex;
 static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex;
 static int dri2WindowPrivateKeyIndex;
@@ -848,6 +851,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 	"VDPAU", /* DRI2DriverVDPAU */
     };
     unsigned int i;
+    CARD8 cur_minor;
 
     if (info->version < 3)
 	return FALSE;
@@ -864,6 +868,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 
     ds->fd	       = info->fd;
     ds->deviceName     = info->deviceName;
+    dri2_major         = 1;
 
     ds->CreateBuffer   = info->CreateBuffer;
     ds->DestroyBuffer  = info->DestroyBuffer;
@@ -873,8 +878,15 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 	ds->ScheduleSwap = info->ScheduleSwap;
 	ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
 	ds->GetMSC = info->GetMSC;
+	cur_minor = 2;
+    } else {
+	cur_minor = 1;
     }
 
+    /* Initialize minor if needed and set to minimum provied by DDX */
+    if (!dri2_minor || dri2_minor > cur_minor)
+	dri2_minor = cur_minor;
+
     if (info->version == 3 || info->numDrivers == 0) {
 	/* Driver too old: use the old-style driverName field */
 	ds->numDrivers = 1;
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 1c8626b..066cc39 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -46,6 +46,9 @@ typedef struct {
     void *driverPrivate;
 } DRI2BufferRec, *DRI2BufferPtr;
 
+extern CARD8 dri2_major; /* version of DRI2 supported by DDX */
+extern CARD8 dri2_minor;
+
 typedef DRI2BufferRec DRI2Buffer2Rec, *DRI2Buffer2Ptr;
 typedef void (*DRI2SwapEventPtr)(ClientPtr client, void *data, int type,
 				 CARD64 ust, CARD64 msc, CARD64 sbc);
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index bd92fd3..7a9f8ca 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -80,8 +80,8 @@ ProcDRI2QueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = SERVER_DRI2_MAJOR_VERSION;
-    rep.minorVersion = SERVER_DRI2_MINOR_VERSION;
+    rep.majorVersion = dri2_major;
+    rep.minorVersion = dri2_minor;
 
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
diff --git a/include/protocol-versions.h b/include/protocol-versions.h
index c74b7fa..97ef5da 100644
--- a/include/protocol-versions.h
+++ b/include/protocol-versions.h
@@ -51,10 +51,6 @@
 #define SERVER_DMX_MINOR_VERSION		2
 #define SERVER_DMX_PATCH_VERSION		20040604
 
-/* DRI2 */
-#define SERVER_DRI2_MAJOR_VERSION		1
-#define SERVER_DRI2_MINOR_VERSION		2
-
 /* Generic event extension */
 #define SERVER_GE_MAJOR_VERSION                 1
 #define SERVER_GE_MINOR_VERSION                 0
commit 87ca6320f26eb3129e3c19056e1d8fa5c1784723
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Fri Mar 5 09:49:03 2010 -0800

    DRI2: handle swap_interval of 0 correctly
    
    A 0 swap interval means that swaps shouldn't be sync'd to vblank, so
    just complete the swap immediately in that case.
    
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 58f478f..9825a55 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -616,8 +616,8 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
 	return BadDrawable;
     }
 
-    /* Old DDX, just blit */
-    if (!ds->ScheduleSwap) {
+    /* Old DDX or no swap interval, just blit */
+    if (!ds->ScheduleSwap || !pPriv->swap_interval) {
 	BoxRec box;
 	RegionRec region;
 
commit 8476d99231cb725c090305d60f1c1c889d25c8dc
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Fri Mar 5 09:15:24 2010 -0800

    DRI2: drawable lifetime fixes
    
    Handle drawable destruction and lifetime correctly.
    
    Check whether the drawable priv is valid in DRI2SwapInterval(),
    DRI2WaitSBC() and DRI2WaitMSC(); it may have gone away, so be sure to
    check it before using it.
    
    If more than 1 outstanding swap is queued, we may complete several after
    an app has exited.  If we free it after the first one completes and the
    refcount reaches 0, we'll crash the server on subsequent completions.
    So delay freeing until all swaps complete and remove the error message
    as this is a normal occurence.  To do this properly, we must also avoid
    destroying drawables in DRI2DestroyDrawable() if a swap or wait event is
    pending.
    
    And finally, make sure we free drawables in DRI2WaitMSCComplete() if
    necessary (i.e. if the refcount has reached 0 and this MSC was the last
    pending event on the object).
    
    Reported-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 354b724..58f478f 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -492,6 +492,10 @@ DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
 	AttendClient(pPriv->blockedClient);
 
     pPriv->blockedClient = NULL;
+
+    /* If there's still a swap pending, let DRI2SwapComplete free it */
+    if (pPriv->refCount == 0 && pPriv->swapsPending == 0)
+	DRI2FreeDrawable(pDraw);
 }
 
 static void
@@ -543,13 +547,6 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
 	return;
     }
 
-    if (pPriv->refCount == 0) {
-        xf86DrvMsg(pScreen->myNum, X_ERROR,
-		   "[DRI2] %s: bad drawable refcount\n", __func__);
-	DRI2FreeDrawable(pDraw);
-	return;
-    }
-
     pPriv->swapsPending--;
     pPriv->swap_count++;
 
@@ -561,6 +558,13 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
     pPriv->last_swap_ust = ust;
 
     DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
+
+    /*
+     * It's normal for the app to have exited with a swap outstanding, but
+     * don't free the drawable until they're all complete.
+     */
+    if (pPriv->swapsPending == 0 && pPriv->refCount == 0)
+	DRI2FreeDrawable(pDraw);
 }
 
 Bool
@@ -669,10 +673,16 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
 void
 DRI2SwapInterval(DrawablePtr pDrawable, int interval)
 {
+    ScreenPtr       pScreen = pDrawable->pScreen;
     DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
 
-    /* fixme: check against arbitrary max? */
+    if (pPriv == NULL) {
+        xf86DrvMsg(pScreen->myNum, X_ERROR,
+		   "[DRI2] %s: bad drawable\n", __func__);
+	return;
+    }
 
+    /* fixme: check against arbitrary max? */
     pPriv->swap_interval = interval;
 }
 
@@ -721,7 +731,7 @@ DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
     Bool ret;
 
     pPriv = DRI2GetDrawable(pDraw);
-    if (pPriv == NULL)
+    if (pPriv == NULL || pPriv->refCount == 0)
 	return BadDrawable;
 
     /* Old DDX just completes immediately */
@@ -745,7 +755,7 @@ DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
     DRI2DrawablePtr pPriv;
 
     pPriv = DRI2GetDrawable(pDraw);
-    if (pPriv == NULL)
+    if (pPriv == NULL || pPriv->refCount == 0)
 	return BadDrawable;
 
     /* target_sbc == 0 means to block until all pending swaps are
@@ -794,10 +804,10 @@ DRI2DestroyDrawable(DrawablePtr pDraw)
 	xfree(pPriv->buffers);
     }
 
-    /* If the window is destroyed while we have a swap pending, don't
+    /* If the window is destroyed while we have a swap or wait pending, don't
      * actually free the priv yet.  We'll need it in the DRI2SwapComplete()
      * callback and we'll free it there once we're done. */
-    if (!pPriv->swapsPending)
+    if (!pPriv->swapsPending && !pPriv->blockedClient)
 	DRI2FreeDrawable(pDraw);
 }
 
commit b180e43977710b56ccfd6780f204ddcc952987a1
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Thu Mar 4 10:31:59 2010 -0800

    DRI2: fix swapbuffers handling of SBC and target MSC
    
    Returns expected SBC after completion of swap to caller, as required by
    OML_sync_control spec, instead of the last_swap_target value.
    
    Passes target_msc, divisor, remainder, correctly for
    glXSwapBuffersMscOML() call, while retaining old behaviour for simple
    glXSwapBuffers() call.
    
    An OML swap can have a 0 target_msc, which just means it needs to
    satisfy the divisor/remainder equation.  Pass this down to the driver as
    needed so we can support it.
    
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
    Signed-off-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index ef838ff..354b724 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -632,11 +632,20 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
     }
 
     /*
-     * Swap target for this swap is last swap target + swap interval since
-     * we have to account for the current swap count, interval, and the
-     * number of pending swaps.
+     * In the simple glXSwapBuffers case, all params will be 0, and we just
+     * need to schedule a swap for the last swap target + the swap interval.
      */
-    *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+    if (target_msc == 0 && divisor == 0 && remainder == 0) {
+	/*
+	 * Swap target for this swap is last swap target + swap interval since
+	 * we have to account for the current swap count, interval, and the
+	 * number of pending swaps.
+	 */
+	*swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+    } else {
+	/* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
+	*swap_target = target_msc;
+    }
 
     ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
 			      swap_target, divisor, remainder, func, data);
@@ -649,6 +658,11 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
     pPriv->swapsPending++;
     pPriv->last_swap_target = *swap_target;
 
+    /* According to spec, return expected swapbuffers count SBC after this swap
+     * will complete.
+     */
+    *swap_target = pPriv->swap_count + pPriv->swapsPending;
+
     return Success;
 }
 
commit 751e8c09d34df4b41e8d8384a3ec1bf5cb8ca028
Author: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
Date:   Sun Feb 21 05:26:00 2010 +0100

    DRI2WaitSbc(): Fixes for correct semantic of glXWaitForSbcOML()
    
    Added implementation for case target_sbc == 0. In that case, the
    function shall schedule a wait until all pending swaps for the drawable
    have completed.
    
    Fix for non-blocking case. Old implementation returned random,
    uninitialized values for (ust,msc,sbc) if it returned immediately
    without scheduling a wait due to sbc >= target_sbc.
    
    Now if function doesn't schedule a wait, but returns immediately,
    it returns the (ust,msc,sbc) of the most recently completed swap,
    i.e., the UST and MSC corresponding to the time when the returned
    current SBC was reached.
    
    Signed-off-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index cb227be..ef838ff 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -64,6 +64,8 @@ typedef struct _DRI2Drawable {
     CARD64		 swap_count;
     int64_t		 target_sbc; /* -1 means no SBC wait outstanding */
     CARD64		 last_swap_target; /* most recently queued swap target */
+    CARD64		 last_swap_msc; /* msc at completion of most recent swap */
+    CARD64		 last_swap_ust; /* ust at completion of most recent swap */
     int			 swap_limit; /* for N-buffering */
 } DRI2DrawableRec, *DRI2DrawablePtr;
 
@@ -148,6 +150,8 @@ DRI2CreateDrawable(DrawablePtr pDraw)
 	pPriv->last_swap_target = 0;
 
     pPriv->swap_limit = 1; /* default to double buffering */
+    pPriv->last_swap_msc = 0;
+    pPriv->last_swap_ust = 0;
 
     if (pDraw->type == DRAWABLE_WINDOW)
     {
@@ -553,6 +557,9 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
     if (swap_complete)
 	swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
 
+    pPriv->last_swap_msc = frame;
+    pPriv->last_swap_ust = ust;
+
     DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
 }
 
@@ -727,8 +734,22 @@ DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
     if (pPriv == NULL)
 	return BadDrawable;
 
-    if (pPriv->swap_count >= target_sbc)
-	return Success;
+    /* target_sbc == 0 means to block until all pending swaps are
+     * finished. Recalculate target_sbc to get that behaviour.
+     */
+    if (target_sbc == 0)
+        target_sbc = pPriv->swap_count + pPriv->swapsPending;
+
+    /* If current swap count already >= target_sbc,
+     * return immediately with (ust, msc, sbc) triplet of
+     * most recent completed swap.
+     */
+    if (pPriv->swap_count >= target_sbc) {
+        *sbc = pPriv->swap_count;
+        *msc = pPriv->last_swap_msc;
+        *ust = pPriv->last_swap_ust;
+        return Success;
+    }
 
     pPriv->target_sbc = target_sbc;
     DRI2BlockClient(client, pDraw);
commit 0de4974b90b10fa6a447cdf980b4a114c6c9e5a8
Author: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
Date:   Sun Feb 21 05:25:59 2010 +0100

    DRI2: Fix glitches in DRI2SwapComplete() and DRI2WakeupClient()
    
    DRI2SwapComplete(): Increment pPriv->swap_count++; before calling
    into callback for INTEL_swap_events extension, so the swap event
    contains the current SBC after swap completion instead of the
    previous one.
    
    DRI2WakeupClient: Check for pPriv->target_sbc <= pPriv->swap_count,
    had wrong comparison pPriv->target_sbc >= pPriv->swap_count for
    unblocking of clients of DRI2WaitSBC().
    
    Signed-off-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index ec4f982..cb227be 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -509,7 +509,7 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
      * blocked due to GLX activity during a swap.
      */
     if (pPriv->target_sbc != -1 &&
-	pPriv->target_sbc >= pPriv->swap_count) {
+	pPriv->target_sbc <= pPriv->swap_count) {
 	ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
 			     frame, pPriv->swap_count);
 	pPriv->target_sbc = -1;
@@ -546,13 +546,13 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
 	return;
     }
 
+    pPriv->swapsPending--;
+    pPriv->swap_count++;
+
     ust = ((CARD64)tv_sec * 1000000) + tv_usec;
     if (swap_complete)
 	swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
 
-    pPriv->swapsPending--;
-    pPriv->swap_count++;
-
     DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
 }
 
commit 4c8ec49826a46eb3b36c69d2ad3f82320c179c38
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Thu Mar 4 09:54:15 2010 -0800

    DRI2: make target_sbc signed
    
    We need to track invalid targets as well as 0 targets, so just make it
    signed so our comparisons work like they should.
    
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Reported-by: Kristian Høgsberg <krh at bitplanet.net>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d60bd5e..ec4f982 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -62,7 +62,7 @@ typedef struct _DRI2Drawable {
     ClientPtr		 blockedClient;
     int			 swap_interval;
     CARD64		 swap_count;
-    CARD64		 target_sbc; /* -1 means no SBC wait outstanding */
+    int64_t		 target_sbc; /* -1 means no SBC wait outstanding */
     CARD64		 last_swap_target; /* most recently queued swap target */
     int			 swap_limit; /* for N-buffering */
 } DRI2DrawableRec, *DRI2DrawablePtr;
commit c4d54816f2ee4883d8f9bcf4595474fb58c95146
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Thu Mar 4 09:19:13 2010 -0800

    DRI2: fixup handling of last_swap_target
    
    We need to initialize the swap target, which is passed to the driver to
    schedule events.  Rather than using -1 to indicate that the field is
    uninitialized, just make sure we initialize it at drawable creation
    time.
    
    Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 48618e1..d60bd5e 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -116,9 +116,11 @@ DRI2GetDrawable(DrawablePtr pDraw)
 int
 DRI2CreateDrawable(DrawablePtr pDraw)
 {
+    DRI2ScreenPtr   ds = DRI2GetScreen(pDraw->pScreen);
     WindowPtr	    pWin;
     PixmapPtr	    pPixmap;
     DRI2DrawablePtr pPriv;
+    CARD64          ust;
 
     pPriv = DRI2GetDrawable(pDraw);
     if (pPriv != NULL)
@@ -141,7 +143,10 @@ DRI2CreateDrawable(DrawablePtr pDraw)
     pPriv->swap_count = 0;
     pPriv->target_sbc = -1;
     pPriv->swap_interval = 1;
-    pPriv->last_swap_target = -1;
+    /* Initialize last swap target from DDX if possible */
+    if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
+	pPriv->last_swap_target = 0;
+
     pPriv->swap_limit = 1; /* default to double buffering */
 
     if (pDraw->type == DRAWABLE_WINDOW)
@@ -579,7 +584,6 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
     DRI2ScreenPtr   ds = DRI2GetScreen(pDraw->pScreen);
     DRI2DrawablePtr pPriv;
     DRI2BufferPtr   pDestBuffer = NULL, pSrcBuffer = NULL;
-    CARD64          ust;
     int             ret, i;
 
     pPriv = DRI2GetDrawable(pDraw);
@@ -621,27 +625,6 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
     }
 
     /*
-     * In the simple glXSwapBuffers case, all params will be 0, and we just
-     * need to schedule a swap for the last swap target + the swap interval.
-     * If the last swap target hasn't been set yet, call into the driver
-     * to get the current count.
-     */
-    if (target_msc == 0 && divisor == 0 && remainder == 0 &&
-	pPriv->last_swap_target < 0) {
-	ret = (*ds->GetMSC)(pDraw, &ust, &target_msc);
-	if (!ret) {
-	    xf86DrvMsg(pScreen->myNum, X_ERROR,
-		       "[DRI2] %s: driver failed to return current MSC\n",
-		       __func__);
-	    return BadDrawable;
-	}
-    }
-
-    /* First swap needs to initialize last_swap_target */
-    if (pPriv->last_swap_target < 0)
-	pPriv->last_swap_target = target_msc;
-
-    /*
      * Swap target for this swap is last swap target + swap interval since
      * we have to account for the current swap count, interval, and the
      * number of pending swaps.


More information about the Xquartz-changes mailing list