Index: /trunk/dports/x11/xorg-server-devel/Portfile
===================================================================
--- /trunk/dports/x11/xorg-server-devel/Portfile	(revision 97970)
+++ /trunk/dports/x11/xorg-server-devel/Portfile	(revision 97971)
@@ -6,6 +6,5 @@
 conflicts       xorg-server
 set my_name	xorg-server
-version		1.12.99.905
-revision        1
+version		1.13.99.0
 categories	x11 devel
 maintainers	jeremyhu openmaintainer
@@ -17,5 +16,5 @@
 fetch.type      git
 git.url         git://anongit.freedesktop.org/xorg/xserver
-git.branch      a557edca6152ad09c685a00e01534c35a1f00f2e
+git.branch      d01921ec18c21f21d377b60626cc2d3418b84a7c
 
 use_parallel_build yes
@@ -75,5 +74,6 @@
 
 patchfiles \
-        1001-list-Use-offsetof-to-determine-member-offsets-within.patch \
+        0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch \
+        0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch \
         5000-sdksyms.sh-Use-CPPFLAGS-not-CFLAGS.patch \
         5001-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch \
Index: /trunk/dports/x11/xorg-server-devel/files/0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch
===================================================================
--- /trunk/dports/x11/xorg-server-devel/files/0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch	(revision 97971)
+++ /trunk/dports/x11/xorg-server-devel/files/0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch	(revision 97971)
@@ -0,0 +1,41 @@
+From b6b4287a1db26f75e88f53486c91bfefeb7726fd Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+Date: Thu, 20 Sep 2012 21:49:40 -0700
+Subject: [PATCH 1/2] XQuartz: Avoid a possible deadlock with DRI on OS X
+ 10.7.5 and OS X 10.8.2
+
+<rdar://problem/12338921>
+http://bugs.winehq.org/show_bug.cgi?id=31751
+
+Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+---
+ hw/xquartz/xpr/dri.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
+index 03af163..4fa4aa8 100644
+--- a/hw/xquartz/xpr/dri.c
++++ b/hw/xquartz/xpr/dri.c
+@@ -64,6 +64,7 @@
+ #include "mi.h"
+ #include "mipointer.h"
+ #include "rootless.h"
++#include "rootlessCommon.h"
+ #include "x-hash.h"
+ #include "x-hook.h"
+ #include "driWrap.h"
+@@ -385,6 +386,11 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
+ 
+         if (NULL == pDRIDrawablePriv)
+             return FALSE;  /*error*/
++
++        /* <rdar://problem/12338921>
++         * http://bugs.winehq.org/show_bug.cgi?id=31751
++         */
++        RootlessStopDrawing((WindowPtr)pDrawable, FALSE);
+     }
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+     else if (pDrawable->type == DRAWABLE_PIXMAP) {
+-- 
+1.7.11.5
+
Index: /trunk/dports/x11/xorg-server-devel/files/0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch
===================================================================
--- /trunk/dports/x11/xorg-server-devel/files/0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch	(revision 97971)
+++ /trunk/dports/x11/xorg-server-devel/files/0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch	(revision 97971)
@@ -0,0 +1,67 @@
+From a55ccb7e8f80992e985694a5ec40b5aa72526d39 Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+Date: Thu, 20 Sep 2012 21:11:21 -0700
+Subject: [PATCH 2/2] XQuartz: Add some verbose logging to debug
+ xp_lock_window being unbalanced
+
+Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+---
+ hw/xquartz/xpr/xprFrame.c | 28 ++++++++++++++++++++++++++++
+ 1 file changed, 28 insertions(+)
+
+diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
+index 01f1def..aad375b 100644
+--- a/hw/xquartz/xpr/xprFrame.c
++++ b/hw/xquartz/xpr/xprFrame.c
+@@ -49,6 +49,10 @@
+ #include <pthread.h>
+ #endif
+ 
++#ifdef DEBUG_XP_LOCK_WINDOW
++#include <execinfo.h>
++#endif
++
+ #define DEFINE_ATOM_HELPER(func, atom_name)                      \
+     static Atom func(void) {                                       \
+         static int generation;                                      \
+@@ -376,6 +380,18 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+     unsigned int rowbytes[2];
+     xp_error err;
+ 
++#ifdef DEBUG_XP_LOCK_WINDOW
++    void* callstack[128];
++    int i, frames = backtrace(callstack, 128);
++    char** strs = backtrace_symbols(callstack, frames);
++
++    ErrorF("=== LOCK %d ===\n", (int)x_cvt_vptr_to_uint(wid));
++    for (i = 0; i < frames; ++i) {
++        ErrorF("    %s\n", strs[i]);
++    }
++    free(strs);
++#endif
++
+     err = xp_lock_window(x_cvt_vptr_to_uint(
+                              wid), NULL, NULL, data, rowbytes, NULL);
+     if (err != Success)
+@@ -395,6 +411,18 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
+ {
+     xp_error err;
+ 
++#ifdef DEBUG_XP_LOCK_WINDOW
++    void* callstack[128];
++    int i, frames = backtrace(callstack, 128);
++    char** strs = backtrace_symbols(callstack, frames);
++
++    ErrorF("=== UNLOCK %d ===\n", (int)x_cvt_vptr_to_uint(wid));
++    for (i = 0; i < frames; ++i) {
++        ErrorF("    %s\n", strs[i]);
++    }
++    free(strs);
++#endif
++
+     err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
+     /* This should be a FatalError, but we started tripping over it.  Make it a
+      * FatalError after http://xquartz.macosforge.org/trac/ticket/482 is fixed.
+-- 
+1.7.11.5
+
Index: unk/dports/x11/xorg-server-devel/files/1001-list-Use-offsetof-to-determine-member-offsets-within.patch
===================================================================
--- /trunk/dports/x11/xorg-server-devel/files/1001-list-Use-offsetof-to-determine-member-offsets-within.patch	(revision 97970)
+++ 	(revision )
@@ -1,55 +1,0 @@
-From 4939530bb86b9356156ac83d720e2b157e37deae Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Date: Tue, 28 Aug 2012 10:06:51 -0700
-Subject: [PATCH] list: Use offsetof() to determine member offsets within a
- structure
-
-Some compilers have difficulty with the previous implementation which
-relies on undefined behavior according to the C standard.  Using
-offsetof() from <stddef.h> (which most likely just uses
-__builtin_offsetof on modern compilers) allows us to accomplish this
-without ambiguity.
-
-Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
----
- include/list.h | 10 ++++++----
- 1 file changed, 6 insertions(+), 4 deletions(-)
-
-diff --git a/include/list.h b/include/list.h
-index d54a207..ae5431c 100644
---- a/include/list.h
-+++ b/include/list.h
-@@ -26,6 +26,8 @@
- #ifndef _XORG_LIST_H_
- #define _XORG_LIST_H_
- 
-+#include <stddef.h> /* offsetof() */
-+
- /**
-  * @file Classic doubly-link circular list implementation.
-  * For real usage examples of the linked list, see the file test/list.c
-@@ -232,7 +234,7 @@ xorg_list_is_empty(struct xorg_list *head)
-  */
- #ifndef container_of
- #define container_of(ptr, type, member) \
--    (type *)((char *)(ptr) - (char *) &((type *)0)->member)
-+    (type *)((char *)(ptr) - (char *) offsetof(type, member))
- #endif
- 
- /**
-@@ -271,9 +273,9 @@ xorg_list_is_empty(struct xorg_list *head)
- #define xorg_list_last_entry(ptr, type, member) \
-     xorg_list_entry((ptr)->prev, type, member)
- 
--#define __container_of(ptr, sample, member)				\
--    (void *)((char *)(ptr)						\
--	     - ((char *)&(sample)->member - (char *)(sample)))
-+#define __container_of(ptr, sample, member)			\
-+    container_of(ptr, typeof(*sample), member)
-+
- /**
-  * Loop through the list given by head and set pos to struct in the list.
-  *
--- 
-1.7.11.5
-
Index: /trunk/dports/x11/xorg-server/Portfile
===================================================================
--- /trunk/dports/x11/xorg-server/Portfile	(revision 97970)
+++ /trunk/dports/x11/xorg-server/Portfile	(revision 97971)
@@ -7,4 +7,5 @@
 set my_name	xorg-server
 version		1.13.0
+revision        1
 categories	x11 devel
 license		X11 BSD
@@ -83,4 +84,6 @@
 
 patchfiles \
+        0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch \
+        0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch \
 	5000-sdksyms.sh-Use-CPPFLAGS-not-CFLAGS.patch \
 	5001-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch \
Index: /trunk/dports/x11/xorg-server/files/0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch
===================================================================
--- /trunk/dports/x11/xorg-server/files/0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch	(revision 97971)
+++ /trunk/dports/x11/xorg-server/files/0001-XQuartz-Avoid-a-possible-deadlock-with-DRI-on-OS-X-1.patch	(revision 97971)
@@ -0,0 +1,41 @@
+From b6b4287a1db26f75e88f53486c91bfefeb7726fd Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+Date: Thu, 20 Sep 2012 21:49:40 -0700
+Subject: [PATCH 1/2] XQuartz: Avoid a possible deadlock with DRI on OS X
+ 10.7.5 and OS X 10.8.2
+
+<rdar://problem/12338921>
+http://bugs.winehq.org/show_bug.cgi?id=31751
+
+Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+---
+ hw/xquartz/xpr/dri.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
+index 03af163..4fa4aa8 100644
+--- a/hw/xquartz/xpr/dri.c
++++ b/hw/xquartz/xpr/dri.c
+@@ -64,6 +64,7 @@
+ #include "mi.h"
+ #include "mipointer.h"
+ #include "rootless.h"
++#include "rootlessCommon.h"
+ #include "x-hash.h"
+ #include "x-hook.h"
+ #include "driWrap.h"
+@@ -385,6 +386,11 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
+ 
+         if (NULL == pDRIDrawablePriv)
+             return FALSE;  /*error*/
++
++        /* <rdar://problem/12338921>
++         * http://bugs.winehq.org/show_bug.cgi?id=31751
++         */
++        RootlessStopDrawing((WindowPtr)pDrawable, FALSE);
+     }
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+     else if (pDrawable->type == DRAWABLE_PIXMAP) {
+-- 
+1.7.11.5
+
Index: /trunk/dports/x11/xorg-server/files/0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch
===================================================================
--- /trunk/dports/x11/xorg-server/files/0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch	(revision 97971)
+++ /trunk/dports/x11/xorg-server/files/0002-XQuartz-Add-some-verbose-logging-to-debug-xp_lock_wi.patch	(revision 97971)
@@ -0,0 +1,67 @@
+From a55ccb7e8f80992e985694a5ec40b5aa72526d39 Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+Date: Thu, 20 Sep 2012 21:11:21 -0700
+Subject: [PATCH 2/2] XQuartz: Add some verbose logging to debug
+ xp_lock_window being unbalanced
+
+Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
+---
+ hw/xquartz/xpr/xprFrame.c | 28 ++++++++++++++++++++++++++++
+ 1 file changed, 28 insertions(+)
+
+diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
+index 01f1def..aad375b 100644
+--- a/hw/xquartz/xpr/xprFrame.c
++++ b/hw/xquartz/xpr/xprFrame.c
+@@ -49,6 +49,10 @@
+ #include <pthread.h>
+ #endif
+ 
++#ifdef DEBUG_XP_LOCK_WINDOW
++#include <execinfo.h>
++#endif
++
+ #define DEFINE_ATOM_HELPER(func, atom_name)                      \
+     static Atom func(void) {                                       \
+         static int generation;                                      \
+@@ -376,6 +380,18 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+     unsigned int rowbytes[2];
+     xp_error err;
+ 
++#ifdef DEBUG_XP_LOCK_WINDOW
++    void* callstack[128];
++    int i, frames = backtrace(callstack, 128);
++    char** strs = backtrace_symbols(callstack, frames);
++
++    ErrorF("=== LOCK %d ===\n", (int)x_cvt_vptr_to_uint(wid));
++    for (i = 0; i < frames; ++i) {
++        ErrorF("    %s\n", strs[i]);
++    }
++    free(strs);
++#endif
++
+     err = xp_lock_window(x_cvt_vptr_to_uint(
+                              wid), NULL, NULL, data, rowbytes, NULL);
+     if (err != Success)
+@@ -395,6 +411,18 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
+ {
+     xp_error err;
+ 
++#ifdef DEBUG_XP_LOCK_WINDOW
++    void* callstack[128];
++    int i, frames = backtrace(callstack, 128);
++    char** strs = backtrace_symbols(callstack, frames);
++
++    ErrorF("=== UNLOCK %d ===\n", (int)x_cvt_vptr_to_uint(wid));
++    for (i = 0; i < frames; ++i) {
++        ErrorF("    %s\n", strs[i]);
++    }
++    free(strs);
++#endif
++
+     err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
+     /* This should be a FatalError, but we started tripping over it.  Make it a
+      * FatalError after http://xquartz.macosforge.org/trac/ticket/482 is fixed.
+-- 
+1.7.11.5
+
