Merge branch 'upreqs' of https://github.com/CendioOssman/tigervnc

Conflicts:
	contrib/packages/rpm/el5/SPECS/tigervnc.spec
	vncviewer/Viewport.cxx
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f732f2f..b5f3029 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,15 @@
 set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -UNDEBUG")
 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -UNDEBUG")
 
+# Tell the compiler to be stringent
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wformat=2")
+# Make sure we catch these issues whilst developing
+IF(CMAKE_BUILD_TYPE MATCHES Debug)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+ENDIF()
+
 if(NOT DEFINED BUILD_WINVNC)
   set(BUILD_WINVNC 1)
 endif()
@@ -219,6 +228,9 @@
   if(X11_Xcursor_FOUND)
     set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB})
   endif()
+  if(X11_Xrender_FOUND)
+    set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xrender_LIB})
+  endif()
 endif()
 
 # Check for GNUTLS library
diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake
index bac2202..cc03487 100644
--- a/cmake/StaticBuild.cmake
+++ b/cmake/StaticBuild.cmake
@@ -47,14 +47,18 @@
 
     set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -Wl,-Bdynamic")
 
-    # GnuTLS uses various crypto-api stuff
     if (WIN32)
+      # GnuTLS uses various crypto-api stuff
       set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lcrypt32")
+      # And sockets
+      set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lws2_32")
     endif()
 
-    # nanosleep() lives here on Solaris
     if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+      # nanosleep() lives here on Solaris
       set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lrt")
+      # and socket functions are hidden here
+      set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lsocket")
     endif()
 
     # GnuTLS uses gettext and zlib, so make sure those are always
@@ -75,12 +79,12 @@
     elseif(APPLE)
       set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -framework Cocoa")
     else()
-      set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lm")
+      set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lm -ldl")
     endif()
 
     if(X11_FOUND AND NOT APPLE)
       if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
-        set(FLTK_LIBRARIES "${FLTK_LIBRARIES} ${X11_Xcursor_LIB} ${X11_Xfixes_LIB} -Wl,-Bstatic -lXft -Wl,-Bdynamic -lfontconfig -lXext -R/usr/sfw/lib")
+        set(FLTK_LIBRARIES "${FLTK_LIBRARIES} ${X11_Xcursor_LIB} ${X11_Xfixes_LIB} -Wl,-Bstatic -lXft -Wl,-Bdynamic -lfontconfig -lXrender -lXext -R/usr/sfw/lib -L=/usr/sfw/lib -lfreetype -lsocket -lnsl")
       else()
         set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -Wl,-Bstatic -lXcursor -lXfixes -lXft -lfontconfig -lexpat -lfreetype -lbz2 -lXrender -lXext -lXinerama -Wl,-Bdynamic")
       endif()
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index f2d76bf..e19f52b 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -45,6 +45,7 @@
 #include <network/TcpSocket.h>
 #include <rfb/util.h>
 #include <rfb/LogWriter.h>
+#include <rfb/Configuration.h>
 
 #ifndef INADDR_NONE
 #define INADDR_NONE ((unsigned long)-1)
@@ -73,6 +74,11 @@
 
 static rfb::LogWriter vlog("TcpSocket");
 
+static rfb::BoolParameter UseIPv4("UseIPv4", "Use IPv4 for incoming and outgoing connections.", true);
+#ifdef HAVE_GETADDRINFO
+static rfb::BoolParameter UseIPv6("UseIPv6", "Use IPv6 for incoming and outgoing connections.", true);
+#endif
+
 /* Tunnelling support. */
 int network::findFreeTcpPort (void)
 {
@@ -149,10 +155,25 @@
 		    gai_strerror(result));
   }
 
+  // This logic is too complex for the compiler to determine if
+  // sock is properly assigned or not.
+  sock = -1;
+
   for (current = ai; current != NULL; current = current->ai_next) {
     family = current->ai_family;
-    if (family != AF_INET && family != AF_INET6)
+
+    switch (family) {
+    case AF_INET:
+      if (!UseIPv4)
+        continue;
+      break;
+    case AF_INET6:
+      if (!UseIPv6)
+        continue;
+      break;
+    default:
       continue;
+    }
 
     salen = current->ai_addrlen;
     memcpy(&sa, current->ai_addr, salen);
@@ -163,6 +184,9 @@
       sa.u.sin6.sin6_port = htons(port);
 
 #else /* HAVE_GETADDRINFO */
+    if (!UseIPv4)
+      throw Exception("Only IPv4 available but it is disabled");
+
     family = AF_INET;
     salen = sizeof(struct sockaddr_in);
 
@@ -210,6 +234,9 @@
   }
 
   freeaddrinfo(ai);
+
+  if (current == NULL)
+    throw Exception("No useful address for host");
 #endif /* HAVE_GETADDRINFO */
 
   if (result == -1)
@@ -408,6 +435,9 @@
   socklen_t sa_len;
   int fd;
 
+  if (!UseIPv6)
+    return -1;
+
   if ((fd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
     return -1;
 
@@ -458,6 +488,9 @@
   socklen_t sa_len;
   int fd;
 
+  if (!UseIPv4)
+    return -1;
+
   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
     return -1;
 
@@ -565,7 +598,6 @@
 
 void TcpListener::getMyAddresses(std::list<char*>* result) {
 #if defined(HAVE_GETADDRINFO) && defined(HAVE_INET_PTON)
-  vnc_sockaddr_t sa;
   struct addrinfo *ai, *current, hints;
 
   memset(&hints, 0, sizeof(struct addrinfo));
diff --git a/common/os/winerrno.h b/common/os/winerrno.h
new file mode 100644
index 0000000..aebbdbe
--- /dev/null
+++ b/common/os/winerrno.h
@@ -0,0 +1,101 @@
+
+/* Generated with:
+cat /usr/i686-pc-mingw32/sys-root/mingw/include/winerror.h \
+ | awk '/#define WSAE.*WSABASE/{gsub("WSA", ""); print "#undef " $2 "\n#define " $2 " WSA" $2}' \
+ | egrep -v '_QOS|PROVIDER|PROCTABLE'
+*/
+
+#undef EINTR
+#define EINTR WSAEINTR
+#undef EBADF
+#define EBADF WSAEBADF
+#undef EACCES
+#define EACCES WSAEACCES
+#undef EFAULT
+#define EFAULT WSAEFAULT
+#undef EINVAL
+#define EINVAL WSAEINVAL
+#undef EMFILE
+#define EMFILE WSAEMFILE
+#undef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#undef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
+#undef EALREADY
+#define EALREADY WSAEALREADY
+#undef ENOTSOCK
+#define ENOTSOCK WSAENOTSOCK
+#undef EDESTADDRREQ
+#define EDESTADDRREQ WSAEDESTADDRREQ
+#undef EMSGSIZE
+#define EMSGSIZE WSAEMSGSIZE
+#undef EPROTOTYPE
+#define EPROTOTYPE WSAEPROTOTYPE
+#undef ENOPROTOOPT
+#define ENOPROTOOPT WSAENOPROTOOPT
+#undef EPROTONOSUPPORT
+#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+#undef ESOCKTNOSUPPORT
+#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
+#undef EOPNOTSUPP
+#define EOPNOTSUPP WSAEOPNOTSUPP
+#undef EPFNOSUPPORT
+#define EPFNOSUPPORT WSAEPFNOSUPPORT
+#undef EAFNOSUPPORT
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
+#undef EADDRINUSE
+#define EADDRINUSE WSAEADDRINUSE
+#undef EADDRNOTAVAIL
+#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
+#undef ENETDOWN
+#define ENETDOWN WSAENETDOWN
+#undef ENETUNREACH
+#define ENETUNREACH WSAENETUNREACH
+#undef ENETRESET
+#define ENETRESET WSAENETRESET
+#undef ECONNABORTED
+#define ECONNABORTED WSAECONNABORTED
+#undef ECONNRESET
+#define ECONNRESET WSAECONNRESET
+#undef ENOBUFS
+#define ENOBUFS WSAENOBUFS
+#undef EISCONN
+#define EISCONN WSAEISCONN
+#undef ENOTCONN
+#define ENOTCONN WSAENOTCONN
+#undef ESHUTDOWN
+#define ESHUTDOWN WSAESHUTDOWN
+#undef ETOOMANYREFS
+#define ETOOMANYREFS WSAETOOMANYREFS
+#undef ETIMEDOUT
+#define ETIMEDOUT WSAETIMEDOUT
+#undef ECONNREFUSED
+#define ECONNREFUSED WSAECONNREFUSED
+#undef ELOOP
+#define ELOOP WSAELOOP
+#undef ENAMETOOLONG
+#define ENAMETOOLONG WSAENAMETOOLONG
+#undef EHOSTDOWN
+#define EHOSTDOWN WSAEHOSTDOWN
+#undef EHOSTUNREACH
+#define EHOSTUNREACH WSAEHOSTUNREACH
+#undef ENOTEMPTY
+#define ENOTEMPTY WSAENOTEMPTY
+#undef EPROCLIM
+#define EPROCLIM WSAEPROCLIM
+#undef EUSERS
+#define EUSERS WSAEUSERS
+#undef EDQUOT
+#define EDQUOT WSAEDQUOT
+#undef ESTALE
+#define ESTALE WSAESTALE
+#undef EREMOTE
+#define EREMOTE WSAEREMOTE
+#undef EDISCON
+#define EDISCON WSAEDISCON
+#undef ENOMORE
+#define ENOMORE WSAENOMORE
+#undef ECANCELLED
+#define ECANCELLED WSAECANCELLED
+#undef EREFUSED
+#define EREFUSED WSAEREFUSED
diff --git a/common/rdr/CMakeLists.txt b/common/rdr/CMakeLists.txt
index cc45f91..989ba2f 100644
--- a/common/rdr/CMakeLists.txt
+++ b/common/rdr/CMakeLists.txt
@@ -4,6 +4,7 @@
   Exception.cxx
   FdInStream.cxx
   FdOutStream.cxx
+  FileInStream.cxx
   HexInStream.cxx
   HexOutStream.cxx
   InStream.cxx
diff --git a/common/rdr/Exception.h b/common/rdr/Exception.h
index ea10f9d..62f452b 100644
--- a/common/rdr/Exception.h
+++ b/common/rdr/Exception.h
@@ -21,12 +21,18 @@
 #ifndef __RDR_EXCEPTION_H__
 #define __RDR_EXCEPTION_H__
 
+#ifdef __GNUC__
+#  define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b)))
+#else
+#  define __printf_attr(a, b)
+#endif // __GNUC__
+
 namespace rdr {
 
   struct Exception {
     enum { len = 256 };
     char str_[len];
-    Exception(const char *format = 0, ...);
+    Exception(const char *format = 0, ...) __printf_attr(2, 3);
     virtual ~Exception() {}
     virtual const char* str() const { return str_; }
   };
@@ -37,15 +43,15 @@
   }; 
 
   struct TimedOut : public Exception {
-    TimedOut(const char* s="Timed out") : Exception(s) {}
+    TimedOut(const char* s="Timed out") : Exception("%s", s) {}
   };
  
   struct EndOfStream : public Exception {
-    EndOfStream(const char* s="End of stream") : Exception(s) {}
+    EndOfStream(const char* s="End of stream") : Exception("%s", s) {}
   };
 
   struct FrameException : public Exception {
-    FrameException(const char* s="Frame exception") : Exception(s) {}
+    FrameException(const char* s="Frame exception") : Exception("%s", s) {}
   };
 
 }
diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx
index adb14c5..22433a1 100644
--- a/common/rdr/FdInStream.cxx
+++ b/common/rdr/FdInStream.cxx
@@ -31,8 +31,7 @@
 #define close closesocket
 #undef errno
 #define errno WSAGetLastError()
-#undef EINTR
-#define EINTR WSAEINTR
+#include <os/winerrno.h>
 #else
 #include <sys/types.h>
 #include <errno.h>
diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx
index 533faa3..83360d6 100644
--- a/common/rdr/FdOutStream.cxx
+++ b/common/rdr/FdOutStream.cxx
@@ -26,11 +26,9 @@
 #ifdef _WIN32
 #include <winsock2.h>
 #define write(s,b,l) send(s,(const char*)b,l,0)
-#define EWOULDBLOCK WSAEWOULDBLOCK
 #undef errno
 #define errno WSAGetLastError()
-#undef EINTR
-#define EINTR WSAEINTR
+#include <os/winerrno.h>
 #else
 #include <sys/types.h>
 #include <errno.h>
diff --git a/common/rdr/FileInStream.cxx b/common/rdr/FileInStream.cxx
new file mode 100644
index 0000000..8d5c22e
--- /dev/null
+++ b/common/rdr/FileInStream.cxx
@@ -0,0 +1,87 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * Copyright (C) 2013 D. R. Commander.  All Rights Reserved.
+ * Copyright 2015 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#include <errno.h>
+
+#include <rdr/Exception.h>
+#include <rdr/FileInStream.h>
+
+using namespace rdr;
+
+FileInStream::FileInStream(const char *fileName)
+{
+  file = fopen(fileName, "rb");
+  if (!file)
+    throw SystemException("fopen", errno);
+  ptr = end = b;
+}
+
+FileInStream::~FileInStream(void) {
+  if (file) {
+    fclose(file);
+    file = NULL;
+  }
+}
+
+void FileInStream::reset(void) {
+  if (!file)
+    throw Exception("File is not open");
+  if (fseek(file, 0, SEEK_SET) != 0)
+    throw SystemException("fseek", errno);
+  ptr = end = b;
+}
+
+int FileInStream::pos()
+{
+  if (!file)
+    throw Exception("File is not open");
+
+  return ftell(file) + ptr - b;
+}
+
+int FileInStream::overrun(int itemSize, int nItems, bool wait)
+{
+  if (itemSize > (int)sizeof(b))
+    throw Exception("FileInStream overrun: max itemSize exceeded");
+
+  if (end - ptr != 0)
+    memmove(b, ptr, end - ptr);
+
+  end -= ptr - b;
+  ptr = b;
+
+
+  while (end < b + itemSize) {
+    size_t n = fread((U8 *)end, b + sizeof(b) - end, 1, file);
+    if (n < 1) {
+      if (n < 0 || ferror(file))
+        throw SystemException("fread", errno);
+      if (feof(file))
+        throw EndOfStream();
+      if (n == 0) { return 0; }
+    }
+    end += b + sizeof(b) - end;
+  }
+
+  if (itemSize * nItems > end - ptr)
+    nItems = (end - ptr) / itemSize;
+
+  return nItems;
+}
diff --git a/common/rdr/FileInStream.h b/common/rdr/FileInStream.h
new file mode 100644
index 0000000..ace04f3
--- /dev/null
+++ b/common/rdr/FileInStream.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 2013 D. R. Commander.  All Rights Reserved.
+ * Copyright 2015 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#ifndef __RDR_FILEINSTREAM_H__
+#define __RDR_FILEINSTREAM_H__
+
+#include <stdio.h>
+
+#include <rdr/InStream.h>
+
+namespace rdr {
+
+  class FileInStream : public InStream {
+
+  public:
+
+    FileInStream(const char *fileName);
+    ~FileInStream(void);
+
+    void reset(void);
+
+    int pos();
+
+  protected:
+    int overrun(int itemSize, int nItems, bool wait = true);
+
+  private:
+    U8 b[131072];
+    FILE *file;
+  };
+
+} // end of namespace rdr
+
+#endif
diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx
index 7056c2c..3fde18d 100644
--- a/common/rdr/RandomStream.cxx
+++ b/common/rdr/RandomStream.cxx
@@ -44,7 +44,7 @@
 #ifdef RFB_HAVE_WINCRYPT
   provider = 0;
   if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) {
-    if (GetLastError() == NTE_BAD_KEYSET) {
+    if (GetLastError() == (DWORD)NTE_BAD_KEYSET) {
       if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
         fprintf(stderr, "RandomStream: unable to create keyset\n");
         provider = 0;
diff --git a/common/rdr/TLSException.cxx b/common/rdr/TLSException.cxx
index 3d39d79..bf8e97a 100644
--- a/common/rdr/TLSException.cxx
+++ b/common/rdr/TLSException.cxx
@@ -34,15 +34,8 @@
 
 #ifdef HAVE_GNUTLS
 TLSException::TLSException(const char* s, int err_)
-  : Exception(s), err(err_)
+  : Exception("%s: %s (%d)", s, gnutls_strerror(err), err), err(err_)
 {
-  strncat(str_, ": ", len-1-strlen(str_));
-  strncat(str_, gnutls_strerror(err), len-1-strlen(str_));
-  strncat(str_, " (", len-1-strlen(str_));
-  char buf[20];
-  sprintf(buf,"%d",err);
-  strncat(str_, buf, len-1-strlen(str_));
-  strncat(str_, ")", len-1-strlen(str_));
 }
 #endif /* HAVE_GNUTLS */
 
diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index ef030c1..77b1672 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -43,7 +43,7 @@
       return -1;
     }
 
-    if (in->getend() - in->getptr() < size)
+    if (in->getend() - in->getptr() < (ptrdiff_t)size)
       size = in->getend() - in->getptr();
   
     in->readBytes(data, size);
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index e0a23b5..8ccd948 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -97,12 +97,11 @@
 
   // The only official RFB protocol versions are currently 3.3, 3.7 and 3.8
   if (cp.beforeVersion(3,3)) {
-    char msg[256];
-    sprintf(msg,"Server gave unsupported RFB protocol version %d.%d",
-            cp.majorVersion, cp.minorVersion);
-    vlog.error("%s", msg);
+    vlog.error("Server gave unsupported RFB protocol version %d.%d",
+               cp.majorVersion, cp.minorVersion);
     state_ = RFBSTATE_INVALID;
-    throw Exception(msg);
+    throw Exception("Server gave unsupported RFB protocol version %d.%d",
+                    cp.majorVersion, cp.minorVersion);
   } else if (useProtocol3_3 || cp.beforeVersion(3,7)) {
     cp.setVersion(3,3);
   } else if (cp.afterVersion(3,8)) {
diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h
index 8bd886a..0109fe8 100644
--- a/common/rfb/CConnection.h
+++ b/common/rfb/CConnection.h
@@ -136,6 +136,9 @@
   protected:
     void setState(stateEnum s) { state_ = s; }
 
+    void setReader(CMsgReader *r) { reader_ = r; }
+    void setWriter(CMsgWriter *w) { writer_ = w; }
+
   private:
     // This is a default implementation of fences that automatically
     // responds to requests, stating no support for synchronisation.
diff --git a/common/rfb/CMakeLists.txt b/common/rfb/CMakeLists.txt
index 6cd321e..e9b027a 100644
--- a/common/rfb/CMakeLists.txt
+++ b/common/rfb/CMakeLists.txt
@@ -67,7 +67,7 @@
   set(RFB_SOURCES ${RFB_SOURCES} WinPasswdValidator.cxx)
 endif(WIN32)
 
-set(RFB_LIBRARIES ${JPEG_LIBRARIES} os rdr)
+set(RFB_LIBRARIES ${JPEG_LIBRARIES} os rdr Xregion)
 
 if(HAVE_PAM)
   set(RFB_SOURCES ${RFB_SOURCES} UnixPasswordValidator.cxx
diff --git a/common/rfb/CMsgHandler.cxx b/common/rfb/CMsgHandler.cxx
index eff4776..11c979a 100644
--- a/common/rfb/CMsgHandler.cxx
+++ b/common/rfb/CMsgHandler.cxx
@@ -38,13 +38,13 @@
   cp.height = height;
 }
 
-void CMsgHandler::setExtendedDesktopSize(int reason, int result,
+void CMsgHandler::setExtendedDesktopSize(unsigned reason, unsigned result,
                                          int width, int height,
                                          const ScreenSet& layout)
 {
   cp.supportsSetDesktopSize = true;
 
-  if ((reason == (signed)reasonClient) && (result != (signed)resultSuccess))
+  if ((reason == reasonClient) && (result != resultSuccess))
     return;
 
   if (!layout.validate(width, height))
@@ -74,3 +74,11 @@
 {
   cp.supportsContinuousUpdates = true;
 }
+
+void CMsgHandler::framebufferUpdateStart()
+{
+}
+
+void CMsgHandler::framebufferUpdateEnd()
+{
+}
diff --git a/common/rfb/CMsgHandler.h b/common/rfb/CMsgHandler.h
index 8e3c84e..7d2cdc2 100644
--- a/common/rfb/CMsgHandler.h
+++ b/common/rfb/CMsgHandler.h
@@ -46,7 +46,7 @@
     // methods to set the members of cp appropriately.
 
     virtual void setDesktopSize(int w, int h);
-    virtual void setExtendedDesktopSize(int reason, int result,
+    virtual void setExtendedDesktopSize(unsigned reason, unsigned result,
                                         int w, int h,
                                         const ScreenSet& layout);
     virtual void setCursor(int width, int height, const Point& hotspot,
@@ -57,8 +57,8 @@
     virtual void endOfContinuousUpdates();
     virtual void serverInit() = 0;
 
-    virtual void framebufferUpdateStart() = 0;
-    virtual void framebufferUpdateEnd() = 0;
+    virtual void framebufferUpdateStart();
+    virtual void framebufferUpdateEnd();
     virtual void dataRect(const Rect& r, int encoding) = 0;
 
     virtual void setColourMapEntries(int firstColour, int nColours,
diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx
index ca60da4..9122cd7 100644
--- a/common/rfb/EncodeManager.cxx
+++ b/common/rfb/EncodeManager.cxx
@@ -23,6 +23,7 @@
 #include <rfb/SConnection.h>
 #include <rfb/SMsgWriter.h>
 #include <rfb/UpdateTracker.h>
+#include <rfb/LogWriter.h>
 
 #include <rfb/RawEncoder.h>
 #include <rfb/RREEncoder.h>
@@ -33,6 +34,8 @@
 
 using namespace rfb;
 
+static LogWriter vlog("EncodeManager");
+
 // Split each rectangle into smaller ones no larger than this area,
 // and no wider than this width.
 static const int SubRectMaxArea = 65536;
@@ -73,8 +76,54 @@
 
 };
 
+static const char *encoderClassName(EncoderClass klass)
+{
+  switch (klass) {
+  case encoderRaw:
+    return "Raw";
+  case encoderRRE:
+    return "RRE";
+  case encoderHextile:
+    return "Hextile";
+  case encoderTight:
+    return "Tight";
+  case encoderTightJPEG:
+    return "Tight (JPEG)";
+  case encoderZRLE:
+    return "ZRLE";
+  case encoderClassMax:
+    break;
+  }
+
+  return "Unknown Encoder Class";
+}
+
+static const char *encoderTypeName(EncoderType type)
+{
+  switch (type) {
+  case encoderSolid:
+    return "Solid";
+  case encoderBitmap:
+    return "Bitmap";
+  case encoderBitmapRLE:
+    return "Bitmap RLE";
+  case encoderIndexed:
+    return "Indexed";
+  case encoderIndexedRLE:
+    return "Indexed RLE";
+  case encoderFullColour:
+    return "Full Colour";
+  case encoderTypeMax:
+    break;
+  }
+
+  return "Unknown Encoder Type";
+}
+
 EncodeManager::EncodeManager(SConnection* conn_) : conn(conn_)
 {
+  StatsVector::iterator iter;
+
   encoders.resize(encoderClassMax, NULL);
   activeEncoders.resize(encoderTypeMax, encoderRaw);
 
@@ -84,16 +133,84 @@
   encoders[encoderTight] = new TightEncoder(conn);
   encoders[encoderTightJPEG] = new TightJPEGEncoder(conn);
   encoders[encoderZRLE] = new ZRLEEncoder(conn);
+
+  updates = 0;
+  stats.resize(encoderClassMax);
+  for (iter = stats.begin();iter != stats.end();++iter) {
+    StatsVector::value_type::iterator iter2;
+    iter->resize(encoderTypeMax);
+    for (iter2 = iter->begin();iter2 != iter->end();++iter2)
+      memset(&*iter2, 0, sizeof(EncoderStats));
+  }
 }
 
 EncodeManager::~EncodeManager()
 {
   std::vector<Encoder*>::iterator iter;
 
+  logStats();
+
   for (iter = encoders.begin();iter != encoders.end();iter++)
     delete *iter;
 }
 
+void EncodeManager::logStats()
+{
+  size_t i, j;
+
+  unsigned rects;
+  unsigned long long pixels, bytes, equivalent;
+
+  double ratio;
+
+  char a[1024], b[1024];
+
+  rects = 0;
+  pixels = bytes = equivalent = 0;
+
+  vlog.info("Framebuffer updates: %u", updates);
+
+  for (i = 0;i < stats.size();i++) {
+    // Did this class do anything at all?
+    for (j = 0;j < stats[i].size();j++) {
+      if (stats[i][j].rects != 0)
+        break;
+    }
+    if (j == stats[i].size())
+      continue;
+
+    vlog.info("  %s:", encoderClassName((EncoderClass)i));
+
+    for (j = 0;j < stats[i].size();j++) {
+      if (stats[i][j].rects == 0)
+        continue;
+
+      rects += stats[i][j].rects;
+      pixels += stats[i][j].pixels;
+      bytes += stats[i][j].bytes;
+      equivalent += stats[i][j].equivalent;
+
+      ratio = (double)stats[i][j].equivalent / stats[i][j].bytes;
+
+      siPrefix(stats[i][j].rects, "rects", a, sizeof(a));
+      siPrefix(stats[i][j].pixels, "pixels", b, sizeof(b));
+      vlog.info("    %s: %s, %s", encoderTypeName((EncoderType)j), a, b);
+      iecPrefix(stats[i][j].bytes, "B", a, sizeof(a));
+      vlog.info("    %*s  %s (1:%g ratio)",
+                (int)strlen(encoderTypeName((EncoderType)j)), "",
+                a, ratio);
+    }
+  }
+
+  ratio = (double)equivalent / bytes;
+
+  siPrefix(rects, "rects", a, sizeof(a));
+  siPrefix(pixels, "pixels", b, sizeof(b));
+  vlog.info("  Total: %s, %s", a, b);
+  iecPrefix(bytes, "B", a, sizeof(a));
+  vlog.info("         %s (1:%g ratio)", a, ratio);
+}
+
 bool EncodeManager::supported(int encoding)
 {
   switch (encoding) {
@@ -114,6 +231,8 @@
     int nRects;
     Region changed;
 
+    updates++;
+
     prepareEncoders();
 
     if (conn->cp.supportsLastRect)
@@ -292,6 +411,40 @@
   return numRects;
 }
 
+Encoder *EncodeManager::startRect(const Rect& rect, int type)
+{
+  Encoder *encoder;
+  int klass, equiv;
+
+  activeType = type;
+  klass = activeEncoders[activeType];
+
+  beforeLength = conn->getOutStream()->length();
+
+  stats[klass][activeType].rects++;
+  stats[klass][activeType].pixels += rect.area();
+  equiv = 12 + rect.area() * conn->cp.pf().bpp/8;
+  stats[klass][activeType].equivalent += equiv;
+
+  encoder = encoders[klass];
+  conn->writer()->startRect(rect, encoder->encoding);
+
+  return encoder;
+}
+
+void EncodeManager::endRect()
+{
+  int klass;
+  int length;
+
+  conn->writer()->endRect();
+
+  length = conn->getOutStream()->length() - beforeLength;
+
+  klass = activeEncoders[activeType];
+  stats[klass][activeType].bytes += length;
+}
+
 void EncodeManager::writeCopyRects(const UpdateInfo& ui)
 {
   std::vector<Rect> rects;
@@ -309,84 +462,104 @@
   std::vector<Rect> rects;
   std::vector<Rect>::const_iterator rect;
 
-  // FIXME: This gives up after the first rect it finds. A large update
-  //        (like a whole screen refresh) might have lots of large solid
-  //        areas.
-
   changed->get_rects(&rects);
-  for (rect = rects.begin(); rect != rects.end(); ++rect) {
-    Rect sr;
-    int dx, dy, dw, dh;
+  for (rect = rects.begin(); rect != rects.end(); ++rect)
+    findSolidRect(*rect, changed, pb);
+}
 
-    // We start by finding a solid 16x16 block
-    for (dy = rect->tl.y; dy < rect->br.y; dy += SolidSearchBlock) {
+void EncodeManager::findSolidRect(const Rect& rect, Region *changed,
+                                  const PixelBuffer* pb)
+{
+  Rect sr;
+  int dx, dy, dw, dh;
 
-      dh = SolidSearchBlock;
-      if (dy + dh > rect->br.y)
-        dh = rect->br.y - dy;
+  // We start by finding a solid 16x16 block
+  for (dy = rect.tl.y; dy < rect.br.y; dy += SolidSearchBlock) {
 
-      for (dx = rect->tl.x; dx < rect->br.x; dx += SolidSearchBlock) {
-        // We define it like this to guarantee alignment
-        rdr::U32 _buffer;
-        rdr::U8* colourValue = (rdr::U8*)&_buffer;
+    dh = SolidSearchBlock;
+    if (dy + dh > rect.br.y)
+      dh = rect.br.y - dy;
 
-        dw = SolidSearchBlock;
-        if (dx + dw > rect->br.x)
-          dw = rect->br.x - dx;
+    for (dx = rect.tl.x; dx < rect.br.x; dx += SolidSearchBlock) {
+      // We define it like this to guarantee alignment
+      rdr::U32 _buffer;
+      rdr::U8* colourValue = (rdr::U8*)&_buffer;
 
-        pb->getImage(colourValue, Rect(dx, dy, dx+1, dy+1));
+      dw = SolidSearchBlock;
+      if (dx + dw > rect.br.x)
+        dw = rect.br.x - dx;
 
-        sr.setXYWH(dx, dy, dw, dh);
-        if (checkSolidTile(sr, colourValue, pb)) {
-          Rect erb, erp;
+      pb->getImage(colourValue, Rect(dx, dy, dx+1, dy+1));
 
-          Encoder *encoder;
+      sr.setXYWH(dx, dy, dw, dh);
+      if (checkSolidTile(sr, colourValue, pb)) {
+        Rect erb, erp;
 
-          // We then try extending the area by adding more blocks
-          // in both directions and pick the combination that gives
-          // the largest area.
-          sr.setXYWH(dx, dy, rect->br.x - dx, rect->br.y - dy);
-          extendSolidAreaByBlock(sr, colourValue, pb, &erb);
+        Encoder *encoder;
 
-          // Did we end up getting the entire rectangle?
-          if (erb.equals(*rect))
-            erp = erb;
-          else {
-            // Don't bother with sending tiny rectangles
-            if (erb.area() < SolidBlockMinArea)
-              continue;
+        // We then try extending the area by adding more blocks
+        // in both directions and pick the combination that gives
+        // the largest area.
+        sr.setXYWH(dx, dy, rect.br.x - dx, rect.br.y - dy);
+        extendSolidAreaByBlock(sr, colourValue, pb, &erb);
 
-            // Extend the area again, but this time one pixel
-            // row/column at a time.
-            extendSolidAreaByPixel(*rect, erb, colourValue, pb, &erp);
-          }
+        // Did we end up getting the entire rectangle?
+        if (erb.equals(rect))
+          erp = erb;
+        else {
+          // Don't bother with sending tiny rectangles
+          if (erb.area() < SolidBlockMinArea)
+            continue;
 
-          // Send solid-color rectangle.
-          encoder = encoders[activeEncoders[encoderSolid]];
-          conn->writer()->startRect(erp, encoder->encoding);
-          if (encoder->flags & EncoderUseNativePF) {
-            encoder->writeSolidRect(erp.width(), erp.height(),
-                                    pb->getPF(), colourValue);
-          } else {
-            rdr::U32 _buffer2;
-            rdr::U8* converted = (rdr::U8*)&_buffer2;
-
-            conn->cp.pf().bufferFromBuffer(converted, pb->getPF(),
-                                           colourValue, 1);
-
-            encoder->writeSolidRect(erp.width(), erp.height(),
-                                    conn->cp.pf(), converted);
-          }
-          conn->writer()->endRect();
-
-          changed->assign_subtract(Region(erp));
-
-          break;
+          // Extend the area again, but this time one pixel
+          // row/column at a time.
+          extendSolidAreaByPixel(rect, erb, colourValue, pb, &erp);
         }
-      }
 
-      if (dx < rect->br.x)
-        break;
+        // Send solid-color rectangle.
+        encoder = startRect(erp, encoderSolid);
+        if (encoder->flags & EncoderUseNativePF) {
+          encoder->writeSolidRect(erp.width(), erp.height(),
+                                  pb->getPF(), colourValue);
+        } else {
+          rdr::U32 _buffer2;
+          rdr::U8* converted = (rdr::U8*)&_buffer2;
+
+          conn->cp.pf().bufferFromBuffer(converted, pb->getPF(),
+                                         colourValue, 1);
+
+          encoder->writeSolidRect(erp.width(), erp.height(),
+                                  conn->cp.pf(), converted);
+        }
+        endRect();
+
+        changed->assign_subtract(Region(erp));
+
+        // Search remaining areas by recursion
+        // FIXME: Is this the best way to divide things up?
+
+        // Left? (Note that we've already searched a SolidSearchBlock
+        //        pixels high strip here)
+        if ((erp.tl.x != rect.tl.x) && (erp.height() > SolidSearchBlock)) {
+          sr.setXYWH(rect.tl.x, erp.tl.y + SolidSearchBlock,
+                     erp.tl.x - rect.tl.x, erp.height() - SolidSearchBlock);
+          findSolidRect(sr, changed, pb);
+        }
+
+        // Right?
+        if (erp.br.x != rect.br.x) {
+          sr.setXYWH(erp.br.x, erp.tl.y, rect.br.x - erp.br.x, erp.height());
+          findSolidRect(sr, changed, pb);
+        }
+
+        // Below?
+        if (erp.br.y != rect.br.y) {
+          sr.setXYWH(rect.tl.x, erp.br.y, rect.width(), rect.br.y - erp.br.y);
+          findSolidRect(sr, changed, pb);
+        }
+
+        return;
+      }
     }
   }
 }
@@ -440,7 +613,7 @@
   Encoder *encoder;
 
   struct RectInfo info;
-  int divisor, maxColours;
+  unsigned int divisor, maxColours;
 
   bool useRLE;
   EncoderType type;
@@ -461,7 +634,7 @@
 
   // Special exception inherited from the Tight encoder
   if (activeEncoders[encoderFullColour] == encoderTightJPEG) {
-    if (conn->cp.compressLevel < 2)
+    if ((conn->cp.compressLevel != -1) && (conn->cp.compressLevel < 2))
       maxColours = 24;
     else
       maxColours = 96;
@@ -507,14 +680,14 @@
       type = encoderIndexed;
   }
 
-  encoder = encoders[activeEncoders[type]];
+  encoder = startRect(rect, type);
 
   if (encoder->flags & EncoderUseNativePF)
     ppb = preparePixelBuffer(rect, pb, false);
 
-  conn->writer()->startRect(rect, encoder->encoding);
   encoder->writeRect(ppb, info.palette);
-  conn->writer()->endRect();
+
+  endRect();
 }
 
 bool EncodeManager::checkSolidTile(const Rect& r, const rdr::U8* colourValue,
diff --git a/common/rfb/EncodeManager.h b/common/rfb/EncodeManager.h
index df0275c..a3df8f7 100644
--- a/common/rfb/EncodeManager.h
+++ b/common/rfb/EncodeManager.h
@@ -41,6 +41,8 @@
     EncodeManager(SConnection* conn);
     ~EncodeManager();
 
+    void logStats();
+
     // Hack to let ConnParams calculate the client's preferred encoding
     static bool supported(int encoding);
 
@@ -52,8 +54,12 @@
 
     int computeNumRects(const Region& changed);
 
+    Encoder *startRect(const Rect& rect, int type);
+    void endRect();
+
     void writeCopyRects(const UpdateInfo& ui);
     void writeSolidRects(Region *changed, const PixelBuffer* pb);
+    void findSolidRect(const Rect& rect, Region *changed, const PixelBuffer* pb);
     void writeRects(const Region& changed, const PixelBuffer* pb);
 
     void writeSubRect(const Rect& rect, const PixelBuffer *pb);
@@ -97,6 +103,19 @@
     std::vector<Encoder*> encoders;
     std::vector<int> activeEncoders;
 
+    struct EncoderStats {
+      unsigned rects;
+      unsigned long long bytes;
+      unsigned long long pixels;
+      unsigned long long equivalent;
+    };
+    typedef std::vector< std::vector<struct EncoderStats> > StatsVector;
+
+    unsigned updates;
+    StatsVector stats;
+    int activeType;
+    int beforeLength;
+
     class OffsetPixelBuffer : public FullFramePixelBuffer {
     public:
       OffsetPixelBuffer() {}
diff --git a/common/rfb/EncodeManagerBPP.cxx b/common/rfb/EncodeManagerBPP.cxx
index f58466c..0361291 100644
--- a/common/rfb/EncodeManagerBPP.cxx
+++ b/common/rfb/EncodeManagerBPP.cxx
@@ -59,9 +59,6 @@
   rdr::UBPP colour;
   int count;
 
-  rdr::UBPP c0, c1, ci = 0;
-  int i, n0, n1, ni;
-
   info->rleRuns = 0;
   info->palette.clear();
 
diff --git a/common/rfb/Encoder.cxx b/common/rfb/Encoder.cxx
index 16f7081..56b5f38 100644
--- a/common/rfb/Encoder.cxx
+++ b/common/rfb/Encoder.cxx
@@ -25,8 +25,8 @@
 
 Encoder::Encoder(SConnection *conn_, int encoding_,
                  enum EncoderFlags flags_, unsigned int maxPaletteSize_) :
-  conn(conn_), encoding(encoding_), flags(flags_),
-  maxPaletteSize(maxPaletteSize_)
+  encoding(encoding_), flags(flags_),
+  maxPaletteSize(maxPaletteSize_), conn(conn_)
 {
 }
 
diff --git a/common/rfb/Exception.h b/common/rfb/Exception.h
index 7c2cbca..5f47fcf 100644
--- a/common/rfb/Exception.h
+++ b/common/rfb/Exception.h
@@ -24,14 +24,15 @@
   typedef rdr::Exception Exception;
   struct AuthFailureException : public Exception {
     AuthFailureException(const char* s="Authentication failure")
-      : Exception(s) {}
+      : Exception("%s", s) {}
   };
   struct AuthCancelledException : public rfb::Exception {
     AuthCancelledException(const char* s="Authentication cancelled")
-      : Exception(s) {}
+      : Exception("%s", s) {}
   };
   struct ConnFailedException : public Exception {
-    ConnFailedException(const char* s="Connection failed") : Exception(s) {}
+    ConnFailedException(const char* s="Connection failed")
+      : Exception("%s", s) {}
   };
 }
 #endif
diff --git a/common/rfb/JpegCompressor.cxx b/common/rfb/JpegCompressor.cxx
index c19af34..5df0039 100644
--- a/common/rfb/JpegCompressor.cxx
+++ b/common/rfb/JpegCompressor.cxx
@@ -123,7 +123,7 @@
 
   if(setjmp(err->jmpBuffer)) {
     // this will execute if libjpeg has an error
-    throw rdr::Exception(err->lastError);
+    throw rdr::Exception("%s", err->lastError);
   }
 
   jpeg_create_compress(cinfo);
@@ -166,7 +166,7 @@
     jpeg_abort_compress(cinfo);
     if (srcBufIsTemp && srcBuf) delete[] srcBuf;
     if (rowPointer) delete[] rowPointer;
-    throw rdr::Exception(err->lastError);
+    throw rdr::Exception("%s", err->lastError);
   }
 
   cinfo->image_width = w;
diff --git a/common/rfb/JpegDecompressor.cxx b/common/rfb/JpegDecompressor.cxx
index ca1ad22..70a4276 100644
--- a/common/rfb/JpegDecompressor.cxx
+++ b/common/rfb/JpegDecompressor.cxx
@@ -116,7 +116,7 @@
 
   if(setjmp(err->jmpBuffer)) {
     // this will execute if libjpeg has an error
-    throw rdr::Exception(err->lastError);
+    throw rdr::Exception("%s", err->lastError);
   }
 
   jpeg_create_decompress(dinfo);
@@ -162,7 +162,7 @@
     jpeg_abort_decompress(dinfo);
     if (dstBufIsTemp && dstBuf) delete[] dstBuf;
     if (rowPointer) delete[] rowPointer;
-    throw rdr::Exception(err->lastError);
+    throw rdr::Exception("%s", err->lastError);
   }
 
   src->pub.next_input_byte = jpegBuf;
diff --git a/common/rfb/KeyRemapper.cxx b/common/rfb/KeyRemapper.cxx
index 05f0763..d33f0a4 100644
--- a/common/rfb/KeyRemapper.cxx
+++ b/common/rfb/KeyRemapper.cxx
@@ -50,7 +50,7 @@
       if (bidi == '<')
         mapping[to] = from;
     } else {
-      vlog.error("warning: bad mapping %.*s", nextComma-m, m);
+      vlog.error("warning: bad mapping %.*s", (int)(nextComma-m), m);
     }
     m = nextComma;
     if (nextComma[0])
diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h
index 6b85a85..c3bb2b0 100644
--- a/common/rfb/LogWriter.h
+++ b/common/rfb/LogWriter.h
@@ -36,7 +36,7 @@
 // is assigned a particular log level.
 
 #define DEF_LOGFUNCTION(name, level) \
-  inline void name(const char* fmt, va_list ap) { \
+  inline void v##name(const char* fmt, va_list ap) { \
     if (m_log && (level <= m_level))       \
       m_log->write(level, m_name, fmt, ap);\
   } \
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index b1359c2..b03af1a 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -99,23 +99,43 @@
 void ModifiablePixelBuffer::fillRect(const Rect& r, Pixel pix)
 {
   int stride;
-  U8 *buf, pixbuf[4];
+  U8 *buf;
   int w, h, b;
 
-  buf = getBufferRW(r, &stride);
   w = r.width();
   h = r.height();
   b = format.bpp/8;
 
-  format.bufferFromPixel(pixbuf, pix);
+  if (h == 0)
+    return;
 
-  while (h--) {
-    int w_ = w;
-    while (w_--) {
+  buf = getBufferRW(r, &stride);
+
+  if (b == 1) {
+    while (h--) {
+      memset(buf, pix, w);
+      buf += stride * b;
+    }
+  } else {
+    U8 pixbuf[4], *start;
+    int w1;
+
+    start = buf;
+
+    format.bufferFromPixel(pixbuf, pix);
+
+    w1 = w;
+    while (w1--) {
       memcpy(buf, pixbuf, b);
       buf += b;
     }
     buf += (stride - w) * b;
+    h--;
+
+    while (h--) {
+      memcpy(buf, start, w * b);
+      buf += stride * b;
+    }
   }
 
   commitBufferRW(r);
diff --git a/common/rfb/Rect.h b/common/rfb/Rect.h
index 52e92b5..b5ae254 100644
--- a/common/rfb/Rect.h
+++ b/common/rfb/Rect.h
@@ -102,7 +102,7 @@
     inline bool overlaps(const Rect &r) const {
       return tl.x < r.br.x && tl.y < r.br.y && br.x > r.tl.x && br.y > r.tl.y;
     }
-    inline unsigned int area() const {return is_empty() ? 0 : (br.x-tl.x)*(br.y-tl.y);}
+    inline int area() const {return is_empty() ? 0 : (br.x-tl.x)*(br.y-tl.y);}
     inline Point dimensions() const {return Point(width(), height());}
     inline int width() const {return br.x-tl.x;}
     inline int height() const {return br.y-tl.y;}
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index 99a4850..bfff70c 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -48,11 +48,10 @@
 const SConnection::AccessRights SConnection::AccessFull           = 0xffff;
 
 
-SConnection::SConnection(bool reverseConnection_)
+SConnection::SConnection()
   : readyForSetColourMapEntries(false),
     is(0), os(0), reader_(0), writer_(0),
     security(0), ssecurity(0), state_(RFBSTATE_UNINITIALISED),
-    reverseConnection(reverseConnection_),
     preferredEncoding(encodingRaw)
 {
   defaultMajorVersion = 3;
@@ -271,7 +270,7 @@
   os->flush();
 }
 
-void SConnection::setEncodings(int nEncodings, rdr::S32* encodings)
+void SConnection::setEncodings(int nEncodings, const rdr::S32* encodings)
 {
   int i;
 
diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h
index 005a7a8..ef1de2b 100644
--- a/common/rfb/SConnection.h
+++ b/common/rfb/SConnection.h
@@ -38,7 +38,7 @@
   class SConnection : public SMsgHandler {
   public:
 
-    SConnection(bool reverseConnection_);
+    SConnection();
     virtual ~SConnection();
 
     // Methods to initialise the connection
@@ -71,7 +71,7 @@
 
     // Overridden from SMsgHandler
 
-    virtual void setEncodings(int nEncodings, rdr::S32* encodings);
+    virtual void setEncodings(int nEncodings, const rdr::S32* encodings);
 
 
     // Methods to be overridden in a derived class
@@ -183,6 +183,11 @@
 
   protected:
     void setState(stateEnum s) { state_ = s; }
+
+    void setReader(SMsgReader *r) { reader_ = r; }
+    void setWriter(SMsgWriter *w) { writer_ = w; }
+
+  private:
     void writeFakeColourMap(void);
 
     bool readyForSetColourMapEntries;
@@ -201,7 +206,6 @@
     SecurityServer *security;
     SSecurity* ssecurity;
     stateEnum state_;
-    bool reverseConnection;
     rdr::S32 preferredEncoding;
   };
 }
diff --git a/common/rfb/SMsgHandler.cxx b/common/rfb/SMsgHandler.cxx
index d4046b1..388b21f 100644
--- a/common/rfb/SMsgHandler.cxx
+++ b/common/rfb/SMsgHandler.cxx
@@ -39,7 +39,7 @@
   cp.setPF(pf);
 }
 
-void SMsgHandler::setEncodings(int nEncodings, rdr::S32* encodings)
+void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings)
 {
   bool firstFence, firstContinuousUpdates;
 
diff --git a/common/rfb/SMsgHandler.h b/common/rfb/SMsgHandler.h
index c21cf52..74509e0 100644
--- a/common/rfb/SMsgHandler.h
+++ b/common/rfb/SMsgHandler.h
@@ -46,7 +46,7 @@
     virtual void clientInit(bool shared);
 
     virtual void setPixelFormat(const PixelFormat& pf);
-    virtual void setEncodings(int nEncodings, rdr::S32* encodings);
+    virtual void setEncodings(int nEncodings, const rdr::S32* encodings);
     virtual void framebufferUpdateRequest(const Rect& r, bool incremental) = 0;
     virtual void setDesktopSize(int fb_width, int fb_height,
                                 const ScreenSet& layout) = 0;
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index 0d61292..e421508 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -33,31 +33,15 @@
 static LogWriter vlog("SMsgWriter");
 
 SMsgWriter::SMsgWriter(ConnParams* cp_, rdr::OutStream* os_)
-  : cp(cp_), os(os_), currentEncoding(0),
+  : cp(cp_), os(os_),
     nRectsInUpdate(0), nRectsInHeader(0),
     needSetDesktopSize(false), needExtendedDesktopSize(false),
-    needSetDesktopName(false), needSetCursor(false), needSetXCursor(false),
-    lenBeforeRect(0), updatesSent(0), rawBytesEquivalent(0)
+    needSetDesktopName(false), needSetCursor(false), needSetXCursor(false)
 {
-  for (int i = 0; i <= encodingMax; i++) {
-    bytesSent[i] = 0;
-    rectsSent[i] = 0;
-  }
 }
 
 SMsgWriter::~SMsgWriter()
 {
-  vlog.info("framebuffer updates %d",updatesSent);
-  int bytes = 0;
-  for (int i = 0; i <= encodingMax; i++) {
-    if (i != encodingCopyRect)
-      bytes += bytesSent[i];
-    if (rectsSent[i])
-      vlog.info("  %s rects %d, bytes %d",
-                encodingName(i), rectsSent[i], bytesSent[i]);
-  }
-  vlog.info("  raw bytes equivalent %llu, compression ratio %f",
-          rawBytesEquivalent, (double)rawBytesEquivalent / bytes);
 }
 
 void SMsgWriter::writeServerInit()
@@ -276,7 +260,6 @@
     os->writeU32(pseudoEncodingLastRect);
   }
 
-  updatesSent++;
   endMsg();
 }
 
@@ -293,11 +276,6 @@
   if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
     throw Exception("SMsgWriter::startRect: nRects out of sync");
 
-  currentEncoding = encoding;
-  lenBeforeRect = os->length();
-  if (encoding != encodingCopyRect)
-    rawBytesEquivalent += 12 + r.width() * r.height() * (cp->pf().bpp/8);
-
   os->writeS16(r.tl.x);
   os->writeS16(r.tl.y);
   os->writeU16(r.width());
@@ -307,10 +285,6 @@
 
 void SMsgWriter::endRect()
 {
-  if (currentEncoding <= encodingMax) {
-    bytesSent[currentEncoding] += os->length() - lenBeforeRect;
-    rectsSent[currentEncoding]++;
-  }
 }
 
 void SMsgWriter::startMsg(int type)
@@ -327,7 +301,6 @@
 {
   if (needSetCursor) {
     rdr::U8* data;
-    int stride;
 
     const Cursor& cursor = cp->cursor();
 
diff --git a/common/rfb/SMsgWriter.h b/common/rfb/SMsgWriter.h
index deddd3c..917b933 100644
--- a/common/rfb/SMsgWriter.h
+++ b/common/rfb/SMsgWriter.h
@@ -109,11 +109,6 @@
     void startRect(const Rect& r, int enc);
     void endRect();
 
-    int getUpdatesSent()           { return updatesSent; }
-    int getRectsSent(int encoding) { return rectsSent[encoding]; }
-    int getBytesSent(int encoding) { return bytesSent[encoding]; }
-    rdr::U64 getRawBytesEquivalent()    { return rawBytesEquivalent; }
-
   protected:
     void startMsg(int type);
     void endMsg();
@@ -137,8 +132,6 @@
     ConnParams* cp;
     rdr::OutStream* os;
 
-    int currentEncoding;
-
     int nRectsInUpdate;
     int nRectsInHeader;
 
@@ -149,12 +142,6 @@
     bool needSetCursor;
     bool needSetXCursor;
 
-    int lenBeforeRect;
-    int updatesSent;
-    int bytesSent[encodingMax+1];
-    int rectsSent[encodingMax+1];
-    rdr::U64 rawBytesEquivalent;
-
     typedef struct {
       rdr::U16 reason, result;
       int fb_width, fb_height;
diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx
index 3846ae0..fe2470b 100644
--- a/common/rfb/TightEncoder.cxx
+++ b/common/rfb/TightEncoder.cxx
@@ -163,7 +163,7 @@
   int length;
 
   const rdr::U8* buffer;
-  int stride, w, h;
+  int stride, h;
 
   os = conn->getOutStream();
 
@@ -201,7 +201,7 @@
   }
 
   while (count) {
-    int iter_count;
+    unsigned int iter_count;
 
     iter_count = sizeof(rgb)/3;
     if (iter_count > count)
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 746bb90..932abc0 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -66,12 +66,13 @@
 
 VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
                                    bool reverse)
-  : SConnection(reverse), sock(s),
+  : sock(s), reverseConnection(reverse),
     queryConnectTimer(this), inProcessMessages(false),
     pendingSyncFence(false), syncFence(false), fenceFlags(0),
     fenceDataLen(0), fenceData(NULL),
-    baseRTT(-1), minRTT(-1), seenCongestion(false), pingCounter(0),
-    ackedOffset(0), sentOffset(0), congWindow(0), congestionTimer(this),
+    baseRTT(-1), congWindow(0), ackedOffset(0), sentOffset(0),
+    minRTT(-1), seenCongestion(false),
+    pingCounter(0), congestionTimer(this),
     server(server_), updates(false),
     drawRenderedCursor(false), removeRenderedCursor(false),
     continuousUpdates(false), encodeManager(this),
@@ -760,7 +761,6 @@
 void VNCSConnectionST::handleRTTPong(const struct RTTInfo &rttInfo)
 {
   unsigned rtt, delay;
-  int bdp;
 
   pingCounter--;
 
@@ -1131,7 +1131,7 @@
     accessRights = accessRights | AccessPtrEvents | AccessKeyEvents | AccessView;
     break;
   case 1:
-    accessRights = accessRights & ~(AccessPtrEvents | AccessKeyEvents) | AccessView;
+    accessRights = (accessRights & ~(AccessPtrEvents | AccessKeyEvents)) | AccessView;
     break;
   case 2:
     accessRights = accessRights & ~(AccessPtrEvents | AccessKeyEvents | AccessView);
diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h
index 7b25570..978879f 100644
--- a/common/rfb/VNCSConnectionST.h
+++ b/common/rfb/VNCSConnectionST.h
@@ -173,6 +173,7 @@
 
     network::Socket* sock;
     CharArray peerEndpoint;
+    bool reverseConnection;
 
     Timer queryConnectTimer;
 
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index 51cb86c..199524e 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -544,7 +544,7 @@
   if (!deferPending)
     return true;
 
-  if (msSince(&deferStart) >= deferUpdateTime)
+  if (msSince(&deferStart) >= (unsigned)deferUpdateTime)
     return true;
 
   return false;
diff --git a/common/rfb/WinPasswdValidator.cxx b/common/rfb/WinPasswdValidator.cxx
index 7f8fbf2..22efcc0 100644
--- a/common/rfb/WinPasswdValidator.cxx
+++ b/common/rfb/WinPasswdValidator.cxx
@@ -45,7 +45,5 @@
 		return true;
 	}
 
-	int err = GetLastError();
-
 	return false;
 }
diff --git a/common/rfb/pam.c b/common/rfb/pam.c
index 67b243c..cb067fd 100644
--- a/common/rfb/pam.c
+++ b/common/rfb/pam.c
@@ -38,8 +38,13 @@
   const char *password;
 } AuthData;
 
+#if defined(__sun)
+static int pam_callback(int count, struct pam_message **in,
+                        struct pam_response **out, void *ptr)
+#else
 static int pam_callback(int count, const struct pam_message **in,
-			struct pam_response **out, void *ptr)
+                        struct pam_response **out, void *ptr)
+#endif
 {
   int i;
   AuthData *auth = (AuthData *) ptr;
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index a41ad96..aec45f6 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -34,12 +34,37 @@
 #include <config.h>
 #endif
 
+#include <stdarg.h>
+#include <stdio.h>
 #include <sys/time.h>
 
 #include <rfb/util.h>
 
 namespace rfb {
 
+  void CharArray::format(const char *fmt, ...) {
+    va_list ap;
+    size_t len;
+
+    va_start(ap, fmt);
+    len = vsnprintf(NULL, 0, fmt, ap);
+    va_end(ap);
+
+    delete [] buf;
+
+    if (len < 0) {
+      buf = new char[1];
+      buf[0] = '\0';
+      return;
+    }
+
+    buf = new char[len+1];
+
+    va_start(ap, fmt);
+    vsnprintf(buf, len+1, fmt, ap);
+    va_end(ap);
+  }
+
   char* strDup(const char* s) {
     if (!s) return 0;
     int l = strlen(s);
@@ -110,4 +135,44 @@
 
     return diff;
   }
+
+  static size_t doPrefix(long long value, const char *unit,
+                         char *buffer, size_t maxlen,
+                         unsigned divisor, const char **prefixes,
+                         size_t prefixCount) {
+    double newValue;
+    size_t prefix, len;
+
+    newValue = value;
+    prefix = 0;
+    while (newValue >= divisor) {
+      if (prefix >= prefixCount)
+        break;
+      newValue /= divisor;
+      prefix++;
+    }
+
+    len = snprintf(buffer, maxlen, "%g %s%s", newValue,
+                   (prefix == 0) ? "" : prefixes[prefix-1], unit);
+    buffer[maxlen-1] = '\0';
+
+    return len;
+  }
+
+  static const char *siPrefixes[] =
+    { "k", "M", "G", "T", "P", "E", "Z", "Y" };
+  static const char *iecPrefixes[] =
+    { "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" };
+
+  size_t siPrefix(long long value, const char *unit,
+                  char *buffer, size_t maxlen) {
+    return doPrefix(value, unit, buffer, maxlen, 1000, siPrefixes,
+                    sizeof(siPrefixes)/sizeof(*siPrefixes));
+  }
+
+  size_t iecPrefix(long long value, const char *unit,
+                   char *buffer, size_t maxlen) {
+    return doPrefix(value, unit, buffer, maxlen, 1024, iecPrefixes,
+                    sizeof(iecPrefixes)/sizeof(*iecPrefixes));
+  }
 };
diff --git a/common/rfb/util.h b/common/rfb/util.h
index 13dbe68..9ad1772 100644
--- a/common/rfb/util.h
+++ b/common/rfb/util.h
@@ -32,6 +32,12 @@
 
 struct timeval;
 
+#ifdef __GNUC__
+#  define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b)))
+#else
+#  define __printf_attr(a, b)
+#endif // __GNUC__
+
 namespace rfb {
 
   // -=- Class to handle cleanup of arrays of characters
@@ -45,6 +51,7 @@
     ~CharArray() {
       delete [] buf;
     }
+    void format(const char *fmt, ...) __printf_attr(2, 3);
     // Get the buffer pointer & clear it (i.e. caller takes ownership)
     char* takeBuf() {char* tmp = buf; buf = 0; return tmp;}
     void replaceBuf(char* b) {delete [] buf; buf = b;}
@@ -90,6 +97,11 @@
 
   // Returns time elapsed since given moment in milliseconds.
   unsigned msSince(const struct timeval *then);
+
+  size_t siPrefix(long long value, const char *unit,
+                  char *buffer, size_t maxlen);
+  size_t iecPrefix(long long value, const char *unit,
+                   char *buffer, size_t maxlen);
 }
 
 // Some platforms (e.g. Windows) include max() and min() macros in their
diff --git a/contrib/packages/deb/ubuntu-precise/debian/patches/100_rethrow_signals.patch b/contrib/packages/deb/ubuntu-precise/debian/patches/100_rethrow_signals.patch
index 7c2e6d0..b40b148 100644
--- a/contrib/packages/deb/ubuntu-precise/debian/patches/100_rethrow_signals.patch
+++ b/contrib/packages/deb/ubuntu-precise/debian/patches/100_rethrow_signals.patch
@@ -1,5 +1,5 @@
---- a/unix/xserver/hw/vnc/xvnc.cc	2013-07-14 14:05:29.963390223 -0400
-+++ b/unix/xserver/hw/vnc/xvnc.cc	2013-07-14 14:04:12.840357191 -0400
+--- a/unix/xserver/hw/vnc/xvnc.c	2013-07-14 14:05:29.963390223 -0400
++++ b/unix/xserver/hw/vnc/xvnc.c	2013-07-14 14:04:12.840357191 -0400
 @@ -250,7 +250,7 @@
  #if XORG < 111
  AbortDDX()
diff --git a/contrib/packages/deb/ubuntu-precise/debian/patches/510_tigervnc11-ldnow.patch b/contrib/packages/deb/ubuntu-precise/debian/patches/510_tigervnc11-ldnow.patch
deleted file mode 100644
index e8e99b5..0000000
--- a/contrib/packages/deb/ubuntu-precise/debian/patches/510_tigervnc11-ldnow.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/unix/xserver/hw/vnc/Makefile.am	2011-10-31 09:14:40.000000000 +0100
-+++ b/unix/xserver/hw/vnc/Makefile.am	2012-08-22 15:51:47.013241342 +0200
-@@ -53,7 +53,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
- 	-I$(top_srcdir)/include \
- 	${XSERVERLIBS_CFLAGS} -I$(includedir)
- 
--libvnc_la_LDFLAGS = -module -avoid-version
-+libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
- 
- libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS)
- 
diff --git a/contrib/packages/deb/ubuntu-precise/debian/patches/511_tigervnc11-gethomedir.patch b/contrib/packages/deb/ubuntu-precise/debian/patches/511_tigervnc11-gethomedir.patch
index 208608c..ac1a85f 100644
--- a/contrib/packages/deb/ubuntu-precise/debian/patches/511_tigervnc11-gethomedir.patch
+++ b/contrib/packages/deb/ubuntu-precise/debian/patches/511_tigervnc11-gethomedir.patch
@@ -8,7 +8,7 @@
  COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(XREGION_LIB)
  
  noinst_LTLIBRARIES = libvnccommon.la
-@@ -55,7 +56,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
+@@ -55,6 +56,6 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
  
  libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
  
@@ -16,4 +16,3 @@
 +libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS) $(OS_LIB)
  
  EXTRA_DIST = Xvnc.man
- 
diff --git a/contrib/packages/deb/ubuntu-precise/debian/patches/series b/contrib/packages/deb/ubuntu-precise/debian/patches/series
index b9635cf..51c53e8 100644
--- a/contrib/packages/deb/ubuntu-precise/debian/patches/series
+++ b/contrib/packages/deb/ubuntu-precise/debian/patches/series
@@ -6,6 +6,5 @@
 
 # Upstream patches
 504_tigervnc-cookie.patch
-510_tigervnc11-ldnow.patch
 511_tigervnc11-gethomedir.patch
 516_tigervnc-xorg-manpages.patch
diff --git a/contrib/packages/deb/ubuntu-precise/debian/rules b/contrib/packages/deb/ubuntu-precise/debian/rules
index 29f5632..286c1ad 100755
--- a/contrib/packages/deb/ubuntu-precise/debian/rules
+++ b/contrib/packages/deb/ubuntu-precise/debian/rules
@@ -53,8 +53,8 @@
 	cmake -G"Unix Makefiles" \
     -DBUILD_STATIC=off \
   	-DCMAKE_INSTALL_PREFIX=/usr \
-  	-DFLTK_LIBRARIES="$(CURDIR)/fltk-1.3.2/lib/libfltk.a;$(CURDIR)/fltk-1.3.2/lib/libfltk_images.a;-lpng" \
-  	-DFLTK_INCLUDE_DIR=$(CURDIR)/fltk-1.3.2
+  	-DFLTK_LIBRARIES="$(CURDIR)/fltk-1.3.3/lib/libfltk.a;$(CURDIR)/fltk-1.3.3/lib/libfltk_images.a;-lpng" \
+  	-DFLTK_INCLUDE_DIR=$(CURDIR)/fltk-1.3.3
 	(cd unix/xserver; \
 	export PIXMANINCDIR=/usr/include/pixman-1; \
 	autoreconf -fiv; \
@@ -105,7 +105,7 @@
 		--enable-xdm-auth-1 \
 		--enable-glx \
 		--disable-dri --enable-dri2 \
-		--disable-xinerama \
+		--enable-xinerama \
 		--enable-xf86vidmode \
 		--enable-xace \
 		--disable-selinux \
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/patches/100_rethrow_signals.patch b/contrib/packages/deb/ubuntu-trusty/debian/patches/100_rethrow_signals.patch
index 7c2e6d0..b40b148 100644
--- a/contrib/packages/deb/ubuntu-trusty/debian/patches/100_rethrow_signals.patch
+++ b/contrib/packages/deb/ubuntu-trusty/debian/patches/100_rethrow_signals.patch
@@ -1,5 +1,5 @@
---- a/unix/xserver/hw/vnc/xvnc.cc	2013-07-14 14:05:29.963390223 -0400
-+++ b/unix/xserver/hw/vnc/xvnc.cc	2013-07-14 14:04:12.840357191 -0400
+--- a/unix/xserver/hw/vnc/xvnc.c	2013-07-14 14:05:29.963390223 -0400
++++ b/unix/xserver/hw/vnc/xvnc.c	2013-07-14 14:04:12.840357191 -0400
 @@ -250,7 +250,7 @@
  #if XORG < 111
  AbortDDX()
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/patches/510_tigervnc11-ldnow.patch b/contrib/packages/deb/ubuntu-trusty/debian/patches/510_tigervnc11-ldnow.patch
deleted file mode 100644
index e8e99b5..0000000
--- a/contrib/packages/deb/ubuntu-trusty/debian/patches/510_tigervnc11-ldnow.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/unix/xserver/hw/vnc/Makefile.am	2011-10-31 09:14:40.000000000 +0100
-+++ b/unix/xserver/hw/vnc/Makefile.am	2012-08-22 15:51:47.013241342 +0200
-@@ -53,7 +53,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
- 	-I$(top_srcdir)/include \
- 	${XSERVERLIBS_CFLAGS} -I$(includedir)
- 
--libvnc_la_LDFLAGS = -module -avoid-version
-+libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
- 
- libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS)
- 
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/patches/511_tigervnc11-gethomedir.patch b/contrib/packages/deb/ubuntu-trusty/debian/patches/511_tigervnc11-gethomedir.patch
index 208608c..ac1a85f 100644
--- a/contrib/packages/deb/ubuntu-trusty/debian/patches/511_tigervnc11-gethomedir.patch
+++ b/contrib/packages/deb/ubuntu-trusty/debian/patches/511_tigervnc11-gethomedir.patch
@@ -8,7 +8,7 @@
  COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(XREGION_LIB)
  
  noinst_LTLIBRARIES = libvnccommon.la
-@@ -55,7 +56,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
+@@ -55,6 +56,6 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
  
  libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
  
@@ -16,4 +16,3 @@
 +libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS) $(OS_LIB)
  
  EXTRA_DIST = Xvnc.man
- 
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/patches/517_tigervnc-format-security.patch b/contrib/packages/deb/ubuntu-trusty/debian/patches/517_tigervnc-format-security.patch
deleted file mode 100644
index 36f3fc8..0000000
--- a/contrib/packages/deb/ubuntu-trusty/debian/patches/517_tigervnc-format-security.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up tigervnc-1.3.0/vncviewer/vncviewer.cxx.format-security tigervnc-1.3.0/vncviewer/vncviewer.cxx
---- tigervnc-1.3.0/vncviewer/vncviewer.cxx.format-security	2013-12-03 16:47:04.802800182 +0000
-+++ tigervnc-1.3.0/vncviewer/vncviewer.cxx	2013-12-03 16:47:08.680820024 +0000
-@@ -309,7 +309,7 @@ interpretViaParam(char *remoteHost, int
- 
-   snprintf(vncServerName, VNCSERVERNAMELEN, "localhost::%d", localPort);
-   vncServerName[VNCSERVERNAMELEN - 1] = '\0';
--  vlog.error(vncServerName);
-+  vlog.error("%s", vncServerName);
- 
-   return 0;
- }
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/patches/series b/contrib/packages/deb/ubuntu-trusty/debian/patches/series
index ced87cc..51c53e8 100644
--- a/contrib/packages/deb/ubuntu-trusty/debian/patches/series
+++ b/contrib/packages/deb/ubuntu-trusty/debian/patches/series
@@ -6,7 +6,5 @@
 
 # Upstream patches
 504_tigervnc-cookie.patch
-510_tigervnc11-ldnow.patch
 511_tigervnc11-gethomedir.patch
 516_tigervnc-xorg-manpages.patch
-517_tigervnc-format-security.patch
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/rules b/contrib/packages/deb/ubuntu-trusty/debian/rules
index 515cf2f..09d2896 100755
--- a/contrib/packages/deb/ubuntu-trusty/debian/rules
+++ b/contrib/packages/deb/ubuntu-trusty/debian/rules
@@ -60,8 +60,8 @@
 	cmake -G"Unix Makefiles" \
     -DBUILD_STATIC=off \
   	-DCMAKE_INSTALL_PREFIX=/usr \
-  	-DFLTK_LIBRARIES="$(CURDIR)/fltk-1.3.2/lib/libfltk.a;$(CURDIR)/fltk-1.3.2/lib/libfltk_images.a;-lpng" \
-  	-DFLTK_INCLUDE_DIR=$(CURDIR)/fltk-1.3.2
+  	-DFLTK_LIBRARIES="$(CURDIR)/fltk-1.3.3/lib/libfltk.a;$(CURDIR)/fltk-1.3.3/lib/libfltk_images.a;-lpng" \
+  	-DFLTK_INCLUDE_DIR=$(CURDIR)/fltk-1.3.3
 	(cd unix/xserver; \
 	export PIXMANINCDIR=/usr/include/pixman-1; \
 	autoreconf -fiv; \
@@ -112,7 +112,7 @@
 		--enable-xdm-auth-1 \
 		--enable-glx \
 		--disable-dri --enable-dri2 --enable-dri3 \
-		--disable-xinerama \
+		--enable-xinerama \
 		--enable-xf86vidmode \
 		--enable-xace \
 		--disable-selinux \
diff --git a/contrib/packages/rpm/el5/SOURCES/16_CVE-2014-mult.diff b/contrib/packages/rpm/el5/SOURCES/16_CVE-2014-mult.diff
new file mode 100644
index 0000000..2a75420
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/16_CVE-2014-mult.diff
@@ -0,0 +1,3387 @@
+diff -Naur xorg-server-1.12.4.orig/dbe/dbe.c xorg-server-1.12.4/dbe/dbe.c
+--- xorg-server-1.12.4.orig/dbe/dbe.c	2012-05-17 19:09:01.000000000 +0200
++++ xorg-server-1.12.4/dbe/dbe.c	2014-11-28 09:50:59.185807584 +0100
+@@ -453,18 +453,20 @@
+     DbeSwapInfoPtr swapInfo;
+     xDbeSwapInfo *dbeSwapInfo;
+     int error;
+-    register int i, j;
+-    int nStuff;
++    unsigned int i, j;
++    unsigned int nStuff;
+ 
+     REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
+     nStuff = stuff->n;          /* use local variable for performance. */
+ 
+     if (nStuff == 0) {
++        REQUEST_SIZE_MATCH(xDbeSwapBuffersReq);
+         return Success;
+     }
+ 
+     if (nStuff > UINT32_MAX / sizeof(DbeSwapInfoRec))
+         return BadAlloc;
++    REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, nStuff * sizeof(xDbeSwapInfo));
+ 
+     /* Get to the swap info appended to the end of the request. */
+     dbeSwapInfo = (xDbeSwapInfo *) &stuff[1];
+@@ -955,13 +957,16 @@
+ SProcDbeSwapBuffers(ClientPtr client)
+ {
+     REQUEST(xDbeSwapBuffersReq);
+-    register int i;
++    unsigned int i;
+     xDbeSwapInfo *pSwapInfo;
+ 
+     swaps(&stuff->length);
+     REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
+ 
+     swapl(&stuff->n);
++    if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec))
++        return BadAlloc;
++    REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo));
+ 
+     if (stuff->n != 0) {
+         pSwapInfo = (xDbeSwapInfo *) stuff + 1;
+diff -Naur xorg-server-1.12.4.orig/dix/dispatch.c xorg-server-1.12.4/dix/dispatch.c
+--- xorg-server-1.12.4.orig/dix/dispatch.c	2012-05-17 19:09:01.000000000 +0200
++++ xorg-server-1.12.4/dix/dispatch.c	2014-11-28 09:50:37.761568914 +0100
+@@ -1952,6 +1952,9 @@
+     tmpImage = (char *) &stuff[1];
+     lengthProto = length;
+ 
++    if (lengthProto >= (INT32_MAX / stuff->height))
++        return BadLength;
++
+     if ((bytes_to_int32(lengthProto * stuff->height) +
+          bytes_to_int32(sizeof(xPutImageReq))) != client->req_len)
+         return BadLength;
+diff -Naur xorg-server-1.12.4.orig/dix/region.c xorg-server-1.12.4/dix/region.c
+--- xorg-server-1.12.4.orig/dix/region.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/dix/region.c	2014-11-28 09:50:45.169651442 +0100
+@@ -169,7 +169,6 @@
+         ((r1)->y1 <= (r2)->y1) && \
+         ((r1)->y2 >= (r2)->y2) )
+ 
+-#define xallocData(n) malloc(RegionSizeof(n))
+ #define xfreeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data)
+ 
+ #define RECTALLOC_BAIL(pReg,n,bail) \
+@@ -205,8 +204,9 @@
+ #define DOWNSIZE(reg,numRects)						 \
+ if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
+ {									 \
+-    RegDataPtr NewData;							 \
+-    NewData = (RegDataPtr)realloc((reg)->data, RegionSizeof(numRects));	 \
++    size_t NewSize = RegionSizeof(numRects);				 \
++    RegDataPtr NewData =						 \
++        (NewSize > 0) ? realloc((reg)->data, NewSize) : NULL ;		 \
+     if (NewData)							 \
+     {									 \
+ 	NewData->size = (numRects);					 \
+@@ -330,17 +330,20 @@
+ RegionRectAlloc(RegionPtr pRgn, int n)
+ {
+     RegDataPtr data;
++    size_t rgnSize;
+ 
+     if (!pRgn->data) {
+         n++;
+-        pRgn->data = xallocData(n);
++        rgnSize = RegionSizeof(n);
++        pRgn->data = (rgnSize > 0) ? malloc(rgnSize) : NULL;
+         if (!pRgn->data)
+             return RegionBreak(pRgn);
+         pRgn->data->numRects = 1;
+         *RegionBoxptr(pRgn) = pRgn->extents;
+     }
+     else if (!pRgn->data->size) {
+-        pRgn->data = xallocData(n);
++        rgnSize = RegionSizeof(n);
++        pRgn->data = (rgnSize > 0) ? malloc(rgnSize) : NULL;
+         if (!pRgn->data)
+             return RegionBreak(pRgn);
+         pRgn->data->numRects = 0;
+@@ -352,7 +355,8 @@
+                 n = 250;
+         }
+         n += pRgn->data->numRects;
+-        data = (RegDataPtr) realloc(pRgn->data, RegionSizeof(n));
++        rgnSize = RegionSizeof(n);
++        data = (rgnSize > 0) ? realloc(pRgn->data, rgnSize) : NULL;
+         if (!data)
+             return RegionBreak(pRgn);
+         pRgn->data = data;
+@@ -1297,6 +1301,7 @@
+ {
+ 
+     RegionPtr pRgn;
++    size_t rgnSize;
+     RegDataPtr pData;
+     BoxPtr pBox;
+     int i;
+@@ -1323,7 +1328,8 @@
+         }
+         return pRgn;
+     }
+-    pData = xallocData(nrects);
++    rgnSize = RegionSizeof(nrects);
++    pData = (rgnSize > 0) ? malloc(rgnSize) : NULL;
+     if (!pData) {
+         RegionBreak(pRgn);
+         return pRgn;
+diff -Naur xorg-server-1.12.4.orig/glx/glxcmds.c xorg-server-1.12.4/glx/glxcmds.c
+--- xorg-server-1.12.4.orig/glx/glxcmds.c	2012-08-02 02:59:23.000000000 +0200
++++ xorg-server-1.12.4/glx/glxcmds.c	2014-11-28 09:51:59.834483171 +0100
+@@ -1948,7 +1948,7 @@
+     left = (req->length << 2) - sz_xGLXRenderReq;
+     while (left > 0) {
+         __GLXrenderSizeData entry;
+-        int extra;
++        int extra = 0;
+         __GLXdispatchRenderProcPtr proc;
+         int err;
+ 
+@@ -1967,6 +1967,9 @@
+         cmdlen = hdr->length;
+         opcode = hdr->opcode;
+ 
++        if (left < cmdlen)
++            return BadLength;
++
+         /*
+          ** Check for core opcodes and grab entry data.
+          */
+@@ -1980,24 +1983,20 @@
+             return __glXError(GLXBadRenderRequest);
+         }
+ 
++        if (cmdlen < entry.bytes) {
++            return BadLength;
++        }
++
+         if (entry.varsize) {
+             /* variable size command */
+             extra = (*entry.varsize) (pc + __GLX_RENDER_HDR_SIZE,
+                                       client->swapped);
+             if (extra < 0) {
+-                extra = 0;
+-            }
+-            if (cmdlen != __GLX_PAD(entry.bytes + extra)) {
+-                return BadLength;
+-            }
+-        }
+-        else {
+-            /* constant size command */
+-            if (cmdlen != __GLX_PAD(entry.bytes)) {
+                 return BadLength;
+             }
+         }
+-        if (left < cmdlen) {
++
++        if (cmdlen != safe_pad(safe_add(entry.bytes, extra))) {
+             return BadLength;
+         }
+ 
+@@ -2102,7 +2101,7 @@
+             extra = (*entry.varsize) (pc + __GLX_RENDER_LARGE_HDR_SIZE,
+                                       client->swapped);
+             if (extra < 0) {
+-                extra = 0;
++                return BadLength;
+             }
+             /* large command's header is 4 bytes longer, so add 4 */
+             if (cmdlen != __GLX_PAD(entry.bytes + 4 + extra)) {
+diff -Naur xorg-server-1.12.4.orig/glx/glxcmdsswap.c xorg-server-1.12.4/glx/glxcmdsswap.c
+--- xorg-server-1.12.4.orig/glx/glxcmdsswap.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/glxcmdsswap.c	2014-11-28 09:52:11.210609886 +0100
+@@ -962,11 +962,13 @@
+ int
+ __glXDispSwap_VendorPrivate(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     xGLXVendorPrivateReq *req;
+     GLint vendorcode;
+     __GLXdispatchVendorPrivProcPtr proc;
+ 
+     __GLX_DECLARE_SWAP_VARIABLES;
++    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
+ 
+     req = (xGLXVendorPrivateReq *) pc;
+     __GLX_SWAP_SHORT(&req->length);
+@@ -989,11 +991,13 @@
+ int
+ __glXDispSwap_VendorPrivateWithReply(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     xGLXVendorPrivateWithReplyReq *req;
+     GLint vendorcode;
+     __GLXdispatchVendorPrivProcPtr proc;
+ 
+     __GLX_DECLARE_SWAP_VARIABLES;
++    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateWithReplyReq);
+ 
+     req = (xGLXVendorPrivateWithReplyReq *) pc;
+     __GLX_SWAP_SHORT(&req->length);
+diff -Naur xorg-server-1.12.4.orig/glx/glxserver.h xorg-server-1.12.4/glx/glxserver.h
+--- xorg-server-1.12.4.orig/glx/glxserver.h	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/glxserver.h	2014-11-28 09:51:56.474445744 +0100
+@@ -218,6 +218,47 @@
+  * Routines for computing the size of variably-sized rendering commands.
+  */
+ 
++static _X_INLINE int
++safe_add(int a, int b)
++{
++    if (a < 0 || b < 0)
++        return -1;
++
++    if (INT_MAX - a < b)
++        return -1;
++
++    return a + b;
++}
++
++static _X_INLINE int
++safe_mul(int a, int b)
++{
++    if (a < 0 || b < 0)
++        return -1;
++
++    if (a == 0 || b == 0)
++        return 0;
++
++    if (a > INT_MAX / b)
++        return -1;
++
++    return a * b;
++}
++
++static _X_INLINE int
++safe_pad(int a)
++{
++    int ret;
++
++    if (a < 0)
++        return -1;
++
++    if ((ret = safe_add(a, 3)) < 0)
++        return -1;
++
++    return ret & (GLuint)~3;
++}
++
+ extern int __glXTypeSize(GLenum enm);
+ extern int __glXImageSize(GLenum format, GLenum type,
+                           GLenum target, GLsizei w, GLsizei h, GLsizei d,
+diff -Naur xorg-server-1.12.4.orig/glx/indirect_program.c xorg-server-1.12.4/glx/indirect_program.c
+--- xorg-server-1.12.4.orig/glx/indirect_program.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/indirect_program.c	2014-11-28 09:52:15.138653638 +0100
+@@ -69,6 +69,8 @@
+     __GLXcontext *const cx = __glXForceCurrent(cl, req->contextTag, &error);
+     ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateWithReplyReq, 8);
++
+     pc += __GLX_VENDPRIV_HDR_SIZE;
+     if (cx != NULL) {
+         GLenum target;
+diff -Naur xorg-server-1.12.4.orig/glx/indirect_util.c xorg-server-1.12.4/glx/indirect_util.c
+--- xorg-server-1.12.4.orig/glx/indirect_util.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/indirect_util.c	2014-11-28 09:52:18.662692891 +0100
+@@ -78,12 +78,17 @@
+                      void *local_buffer, size_t local_size, unsigned alignment)
+ {
+     void *buffer = local_buffer;
+-    const unsigned mask = alignment - 1;
++    const intptr_t mask = alignment - 1;
+ 
+     if (local_size < required_size) {
+-        const size_t worst_case_size = required_size + alignment;
++        size_t worst_case_size;
+         intptr_t temp_buf;
+ 
++        if (required_size < SIZE_MAX - alignment)
++            worst_case_size = required_size + alignment;
++        else
++            return NULL;
++
+         if (cl->returnBufSize < worst_case_size) {
+             void *temp = realloc(cl->returnBuf, worst_case_size);
+ 
+diff -Naur xorg-server-1.12.4.orig/glx/rensize.c xorg-server-1.12.4/glx/rensize.c
+--- xorg-server-1.12.4.orig/glx/rensize.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/rensize.c	2014-11-28 09:52:04.398534008 +0100
+@@ -43,19 +43,11 @@
+   (((a & 0xff000000U)>>24) | ((a & 0xff0000U)>>8) | \
+    ((a & 0xff00U)<<8) | ((a & 0xffU)<<24))
+ 
+-static int
+-Map1Size(GLint k, GLint order)
+-{
+-    if (order <= 0 || k < 0)
+-        return -1;
+-    return k * order;
+-}
+-
+ int
+ __glXMap1dReqSize(const GLbyte * pc, Bool swap)
+ {
+     GLenum target;
+-    GLint order, k;
++    GLint order;
+ 
+     target = *(GLenum *) (pc + 16);
+     order = *(GLint *) (pc + 20);
+@@ -63,15 +55,16 @@
+         target = SWAPL(target);
+         order = SWAPL(order);
+     }
+-    k = __glMap1d_size(target);
+-    return 8 * Map1Size(k, order);
++    if (order < 1)
++        return -1;
++    return safe_mul(8, safe_mul(__glMap1d_size(target), order));
+ }
+ 
+ int
+ __glXMap1fReqSize(const GLbyte * pc, Bool swap)
+ {
+     GLenum target;
+-    GLint order, k;
++    GLint order;
+ 
+     target = *(GLenum *) (pc + 0);
+     order = *(GLint *) (pc + 12);
+@@ -79,23 +72,24 @@
+         target = SWAPL(target);
+         order = SWAPL(order);
+     }
+-    k = __glMap1f_size(target);
+-    return 4 * Map1Size(k, order);
++    if (order < 1)
++        return -1;
++    return safe_mul(4, safe_mul(__glMap1f_size(target), order));
+ }
+ 
+ static int
+ Map2Size(int k, int majorOrder, int minorOrder)
+ {
+-    if (majorOrder <= 0 || minorOrder <= 0 || k < 0)
++    if (majorOrder < 1 || minorOrder < 1)
+         return -1;
+-    return k * majorOrder * minorOrder;
++    return safe_mul(k, safe_mul(majorOrder, minorOrder));
+ }
+ 
+ int
+ __glXMap2dReqSize(const GLbyte * pc, Bool swap)
+ {
+     GLenum target;
+-    GLint uorder, vorder, k;
++    GLint uorder, vorder;
+ 
+     target = *(GLenum *) (pc + 32);
+     uorder = *(GLint *) (pc + 36);
+@@ -105,15 +99,14 @@
+         uorder = SWAPL(uorder);
+         vorder = SWAPL(vorder);
+     }
+-    k = __glMap2d_size(target);
+-    return 8 * Map2Size(k, uorder, vorder);
++    return safe_mul(8, Map2Size(__glMap2d_size(target), uorder, vorder));
+ }
+ 
+ int
+ __glXMap2fReqSize(const GLbyte * pc, Bool swap)
+ {
+     GLenum target;
+-    GLint uorder, vorder, k;
++    GLint uorder, vorder;
+ 
+     target = *(GLenum *) (pc + 0);
+     uorder = *(GLint *) (pc + 12);
+@@ -123,8 +116,7 @@
+         uorder = SWAPL(uorder);
+         vorder = SWAPL(vorder);
+     }
+-    k = __glMap2f_size(target);
+-    return 4 * Map2Size(k, uorder, vorder);
++    return safe_mul(4, Map2Size(__glMap2f_size(target), uorder, vorder));
+ }
+ 
+ /**
+@@ -175,14 +167,16 @@
+     GLint bytesPerElement, elementsPerGroup, groupsPerRow;
+     GLint groupSize, rowSize, padding, imageSize;
+ 
++    if (w == 0 || h == 0 || d == 0)
++        return 0;
++
+     if (w < 0 || h < 0 || d < 0 ||
+         (type == GL_BITMAP &&
+          (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX))) {
+         return -1;
+     }
+-    if (w == 0 || h == 0 || d == 0)
+-        return 0;
+ 
++    /* proxy targets have no data */
+     switch (target) {
+     case GL_PROXY_TEXTURE_1D:
+     case GL_PROXY_TEXTURE_2D:
+@@ -199,6 +193,12 @@
+         return 0;
+     }
+ 
++    /* real data has to have real sizes */
++    if (imageHeight < 0 || rowLength < 0 || skipImages < 0 || skipRows < 0)
++        return -1;
++    if (alignment != 1 && alignment != 2 && alignment != 4 && alignment != 8)
++        return -1;
++
+     if (type == GL_BITMAP) {
+         if (rowLength > 0) {
+             groupsPerRow = rowLength;
+@@ -207,11 +207,14 @@
+             groupsPerRow = w;
+         }
+         rowSize = bits_to_bytes(groupsPerRow);
++        if (rowSize < 0)
++            return -1;
+         padding = (rowSize % alignment);
+         if (padding) {
+             rowSize += alignment - padding;
+         }
+-        return ((h + skipRows) * rowSize);
++
++        return safe_mul(safe_add(h, skipRows), rowSize);
+     }
+     else {
+         switch (format) {
+@@ -224,6 +227,11 @@
+         case GL_ALPHA:
+         case GL_LUMINANCE:
+         case GL_INTENSITY:
++        case GL_RED_INTEGER_EXT:
++        case GL_GREEN_INTEGER_EXT:
++        case GL_BLUE_INTEGER_EXT:
++        case GL_ALPHA_INTEGER_EXT:
++        case GL_LUMINANCE_INTEGER_EXT:
+             elementsPerGroup = 1;
+             break;
+         case GL_422_EXT:
+@@ -234,14 +242,19 @@
+         case GL_DEPTH_STENCIL_MESA:
+         case GL_YCBCR_MESA:
+         case GL_LUMINANCE_ALPHA:
++        case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+             elementsPerGroup = 2;
+             break;
+         case GL_RGB:
+         case GL_BGR:
++        case GL_RGB_INTEGER_EXT:
++        case GL_BGR_INTEGER_EXT:
+             elementsPerGroup = 3;
+             break;
+         case GL_RGBA:
+         case GL_BGRA:
++        case GL_RGBA_INTEGER_EXT:
++        case GL_BGRA_INTEGER_EXT:
+         case GL_ABGR_EXT:
+             elementsPerGroup = 4;
+             break;
+@@ -293,6 +306,7 @@
+         default:
+             return -1;
+         }
++        /* known safe by the switches above, not checked */
+         groupSize = bytesPerElement * elementsPerGroup;
+         if (rowLength > 0) {
+             groupsPerRow = rowLength;
+@@ -300,18 +314,21 @@
+         else {
+             groupsPerRow = w;
+         }
+-        rowSize = groupsPerRow * groupSize;
++
++        if ((rowSize = safe_mul(groupsPerRow, groupSize)) < 0)
++            return -1;
+         padding = (rowSize % alignment);
+         if (padding) {
+             rowSize += alignment - padding;
+         }
+-        if (imageHeight > 0) {
+-            imageSize = (imageHeight + skipRows) * rowSize;
+-        }
+-        else {
+-            imageSize = (h + skipRows) * rowSize;
+-        }
+-        return ((d + skipImages) * imageSize);
++
++        if (imageHeight > 0)
++            h = imageHeight;
++        h = safe_add(h, skipRows);
++
++        imageSize = safe_mul(h, rowSize);
++
++        return safe_mul(safe_add(d, skipImages), imageSize);
+     }
+ }
+ 
+@@ -435,9 +452,7 @@
+     /* XXX Should rowLength be used for either or both image? */
+     image1size = __glXImageSize(format, type, 0, w, 1, 1,
+                                 0, rowLength, 0, 0, alignment);
+-    image1size = __GLX_PAD(image1size);
+     image2size = __glXImageSize(format, type, 0, h, 1, 1,
+                                 0, rowLength, 0, 0, alignment);
+-    return image1size + image2size;
+-
++    return safe_add(safe_pad(image1size), image2size);
+ }
+diff -Naur xorg-server-1.12.4.orig/glx/singlepix.c xorg-server-1.12.4/glx/singlepix.c
+--- xorg-server-1.12.4.orig/glx/singlepix.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/singlepix.c	2014-11-28 09:51:46.254331903 +0100
+@@ -69,7 +69,7 @@
+     lsbFirst = *(GLboolean *) (pc + 25);
+     compsize = __glReadPixels_size(format, type, width, height);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, swapBytes));
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_LSB_FIRST, lsbFirst));
+@@ -134,7 +134,7 @@
+     compsize =
+         __glGetTexImage_size(target, level, format, type, width, height, depth);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -232,9 +232,9 @@
+     compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
+ 
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+     if (compsize2 < 0)
+-        compsize2 = 0;
++        return BadLength;
+     compsize = __GLX_PAD(compsize);
+     compsize2 = __GLX_PAD(compsize2);
+ 
+@@ -315,7 +315,7 @@
+      */
+     compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -386,7 +386,7 @@
+      */
+     compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -447,7 +447,7 @@
+ 
+     compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -513,7 +513,7 @@
+      */
+     compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+diff -Naur xorg-server-1.12.4.orig/glx/singlepixswap.c xorg-server-1.12.4/glx/singlepixswap.c
+--- xorg-server-1.12.4.orig/glx/singlepixswap.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/singlepixswap.c	2014-11-28 09:51:46.254331903 +0100
+@@ -79,7 +79,7 @@
+     lsbFirst = *(GLboolean *) (pc + 25);
+     compsize = __glReadPixels_size(format, type, width, height);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes));
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_LSB_FIRST, lsbFirst));
+@@ -155,7 +155,7 @@
+     compsize =
+         __glGetTexImage_size(target, level, format, type, width, height, depth);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -267,9 +267,9 @@
+     compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
+ 
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+     if (compsize2 < 0)
+-        compsize2 = 0;
++        return BadLength;
+     compsize = __GLX_PAD(compsize);
+     compsize2 = __GLX_PAD(compsize2);
+ 
+@@ -358,7 +358,7 @@
+      */
+     compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -437,7 +437,7 @@
+      */
+     compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -505,7 +505,7 @@
+ 
+     compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+@@ -577,7 +577,7 @@
+      */
+     compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
+     if (compsize < 0)
+-        compsize = 0;
++        return BadLength;
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes));
+     __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
+diff -Naur xorg-server-1.12.4.orig/glx/swap_interval.c xorg-server-1.12.4/glx/swap_interval.c
+--- xorg-server-1.12.4.orig/glx/swap_interval.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/swap_interval.c	2014-11-28 09:52:15.138653638 +0100
+@@ -50,6 +50,8 @@
+     __GLXcontext *cx;
+     GLint interval;
+ 
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 4);
++
+     cx = __glXLookupContextByTag(cl, tag);
+ 
+     if ((cx == NULL) || (cx->pGlxScreen == NULL)) {
+diff -Naur xorg-server-1.12.4.orig/glx/unpack.h xorg-server-1.12.4/glx/unpack.h
+--- xorg-server-1.12.4.orig/glx/unpack.h	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/unpack.h	2014-11-28 09:51:49.594369108 +0100
+@@ -83,7 +83,8 @@
+ ** pointer.
+ */
+ #define __GLX_GET_ANSWER_BUFFER(res,cl,size,align)			 \
+-    if ((size) > sizeof(answerBuffer)) {				 \
++    if (size < 0) return BadLength;                                      \
++    else if ((size) > sizeof(answerBuffer)) {				 \
+ 	int bump;							 \
+ 	if ((cl)->returnBufSize < (size)+(align)) {			 \
+ 	    (cl)->returnBuf = (GLbyte*)realloc((cl)->returnBuf,	 	 \
+diff -Naur xorg-server-1.12.4.orig/hw/xfree86/dri2/dri2ext.c xorg-server-1.12.4/hw/xfree86/dri2/dri2ext.c
+--- xorg-server-1.12.4.orig/hw/xfree86/dri2/dri2ext.c	2012-05-17 19:09:03.000000000 +0200
++++ xorg-server-1.12.4/hw/xfree86/dri2/dri2ext.c	2014-11-28 09:50:54.413754423 +0100
+@@ -263,6 +263,9 @@
+     unsigned int *attachments;
+ 
+     REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4);
++    if (stuff->count > (INT_MAX / 4))
++        return BadLength;
++
+     if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess,
+                        &pDrawable, &status))
+         return status;
+diff -Naur xorg-server-1.12.4.orig/include/dix.h xorg-server-1.12.4/include/dix.h
+--- xorg-server-1.12.4.orig/include/dix.h	2012-05-17 19:09:04.000000000 +0200
++++ xorg-server-1.12.4/include/dix.h	2014-11-28 09:50:49.805703089 +0100
+@@ -74,7 +74,8 @@
+ 
+ #define REQUEST_FIXED_SIZE(req, n)\
+     if (((sizeof(req) >> 2) > client->req_len) || \
+-        (((sizeof(req) + (n) + 3) >> 2) != client->req_len)) \
++        ((n >> 2) >= client->req_len) || \
++        ((((uint64_t) sizeof(req) + (n) + 3) >> 2) != (uint64_t) client->req_len))  \
+          return(BadLength)
+ 
+ #define LEGAL_NEW_RESOURCE(id,client)\
+diff -Naur xorg-server-1.12.4.orig/include/regionstr.h xorg-server-1.12.4/include/regionstr.h
+--- xorg-server-1.12.4.orig/include/regionstr.h	2012-05-17 19:09:04.000000000 +0200
++++ xorg-server-1.12.4/include/regionstr.h	2014-11-28 09:50:45.169651442 +0100
+@@ -127,7 +127,10 @@
+ static inline size_t
+ RegionSizeof(int n)
+ {
+-    return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
++    if (n < ((INT_MAX - sizeof(RegDataRec)) / sizeof(BoxRec)))
++        return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
++    else
++        return 0;
+ }
+ 
+ static inline void
+@@ -138,9 +141,10 @@
+         (_pReg)->data = (RegDataPtr) NULL;
+     }
+     else {
++        size_t rgnSize;
+         (_pReg)->extents = RegionEmptyBox;
+-        if (((_size) > 1) && ((_pReg)->data =
+-                              (RegDataPtr) malloc(RegionSizeof(_size)))) {
++        if (((_size) > 1) && ((rgnSize = RegionSizeof(_size)) > 0) &&
++            (((_pReg)->data = malloc(rgnSize)) != NULL)) {
+             (_pReg)->data->size = (_size);
+             (_pReg)->data->numRects = 0;
+         }
+diff -Naur xorg-server-1.12.4.orig/os/access.c xorg-server-1.12.4/os/access.c
+--- xorg-server-1.12.4.orig/os/access.c	2012-05-17 19:09:04.000000000 +0200
++++ xorg-server-1.12.4/os/access.c	2014-11-28 09:50:41.409609554 +0100
+@@ -1331,6 +1331,10 @@
+     for (host = validhosts; host; host = host->next) {
+         nHosts++;
+         n += pad_to_int32(host->len) + sizeof(xHostEntry);
++        /* Could check for INT_MAX, but in reality having more than 1mb of
++           hostnames in the access list is ridiculous */
++        if (n >= 1048576)
++            break;
+     }
+     if (n) {
+         *data = ptr = malloc(n);
+@@ -1339,6 +1343,8 @@
+         }
+         for (host = validhosts; host; host = host->next) {
+             len = host->len;
++            if ((ptr + sizeof(xHostEntry) + len) > (data + n))
++                break;
+             ((xHostEntry *) ptr)->family = host->family;
+             ((xHostEntry *) ptr)->length = len;
+             ptr += sizeof(xHostEntry);
+diff -Naur xorg-server-1.12.4.orig/os/rpcauth.c xorg-server-1.12.4/os/rpcauth.c
+--- xorg-server-1.12.4.orig/os/rpcauth.c	2012-05-17 19:09:04.000000000 +0200
++++ xorg-server-1.12.4/os/rpcauth.c	2014-11-28 09:50:32.861514326 +0100
+@@ -66,6 +66,10 @@
+     SVCXPRT xprt;
+ 
+     temp_inmsg = malloc(len);
++    if (temp_inmsg == NULL) {
++        why = AUTH_FAILED; /* generic error, since there is no AUTH_BADALLOC */
++        return NULL;
++    }
+     memmove(temp_inmsg, inmsg, len);
+ 
+     memset((char *) &msg, 0, sizeof(msg));
+diff -Naur xorg-server-1.12.4.orig/randr/rrsdispatch.c xorg-server-1.12.4/randr/rrsdispatch.c
+--- xorg-server-1.12.4.orig/randr/rrsdispatch.c	2012-05-17 19:09:05.000000000 +0200
++++ xorg-server-1.12.4/randr/rrsdispatch.c	2014-11-28 09:51:10.885937921 +0100
+@@ -27,6 +27,7 @@
+ {
+     REQUEST(xRRQueryVersionReq);
+ 
++    REQUEST_SIZE_MATCH(xRRQueryVersionReq);
+     swaps(&stuff->length);
+     swapl(&stuff->majorVersion);
+     swapl(&stuff->minorVersion);
+@@ -38,6 +39,7 @@
+ {
+     REQUEST(xRRGetScreenInfoReq);
+ 
++    REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
+     swaps(&stuff->length);
+     swapl(&stuff->window);
+     return (*ProcRandrVector[stuff->randrReqType]) (client);
+@@ -69,6 +71,7 @@
+ {
+     REQUEST(xRRSelectInputReq);
+ 
++    REQUEST_SIZE_MATCH(xRRSelectInputReq);
+     swaps(&stuff->length);
+     swapl(&stuff->window);
+     swaps(&stuff->enable);
+@@ -152,6 +155,7 @@
+ {
+     REQUEST(xRRConfigureOutputPropertyReq);
+ 
++    REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq);
+     swaps(&stuff->length);
+     swapl(&stuff->output);
+     swapl(&stuff->property);
+diff -Naur xorg-server-1.12.4.orig/render/render.c xorg-server-1.12.4/render/render.c
+--- xorg-server-1.12.4.orig/render/render.c	2012-08-02 02:59:23.000000000 +0200
++++ xorg-server-1.12.4/render/render.c	2014-11-28 09:51:16.878004670 +0100
+@@ -1994,7 +1994,7 @@
+ SProcRenderQueryVersion(ClientPtr client)
+ {
+     REQUEST(xRenderQueryVersionReq);
+-
++    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
+     swaps(&stuff->length);
+     swapl(&stuff->majorVersion);
+     swapl(&stuff->minorVersion);
+@@ -2005,6 +2005,7 @@
+ SProcRenderQueryPictFormats(ClientPtr client)
+ {
+     REQUEST(xRenderQueryPictFormatsReq);
++    REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
+     swaps(&stuff->length);
+     return (*ProcRenderVector[stuff->renderReqType]) (client);
+ }
+@@ -2013,6 +2014,7 @@
+ SProcRenderQueryPictIndexValues(ClientPtr client)
+ {
+     REQUEST(xRenderQueryPictIndexValuesReq);
++    REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
+     swaps(&stuff->length);
+     swapl(&stuff->format);
+     return (*ProcRenderVector[stuff->renderReqType]) (client);
+@@ -2028,6 +2030,7 @@
+ SProcRenderCreatePicture(ClientPtr client)
+ {
+     REQUEST(xRenderCreatePictureReq);
++    REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
+     swaps(&stuff->length);
+     swapl(&stuff->pid);
+     swapl(&stuff->drawable);
+@@ -2041,6 +2044,7 @@
+ SProcRenderChangePicture(ClientPtr client)
+ {
+     REQUEST(xRenderChangePictureReq);
++    REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
+     swaps(&stuff->length);
+     swapl(&stuff->picture);
+     swapl(&stuff->mask);
+@@ -2052,6 +2056,7 @@
+ SProcRenderSetPictureClipRectangles(ClientPtr client)
+ {
+     REQUEST(xRenderSetPictureClipRectanglesReq);
++    REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
+     swaps(&stuff->length);
+     swapl(&stuff->picture);
+     swaps(&stuff->xOrigin);
+@@ -2064,6 +2069,7 @@
+ SProcRenderFreePicture(ClientPtr client)
+ {
+     REQUEST(xRenderFreePictureReq);
++    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
+     swaps(&stuff->length);
+     swapl(&stuff->picture);
+     return (*ProcRenderVector[stuff->renderReqType]) (client);
+@@ -2073,6 +2079,7 @@
+ SProcRenderComposite(ClientPtr client)
+ {
+     REQUEST(xRenderCompositeReq);
++    REQUEST_SIZE_MATCH(xRenderCompositeReq);
+     swaps(&stuff->length);
+     swapl(&stuff->src);
+     swapl(&stuff->mask);
+@@ -2092,6 +2099,7 @@
+ SProcRenderScale(ClientPtr client)
+ {
+     REQUEST(xRenderScaleReq);
++    REQUEST_SIZE_MATCH(xRenderScaleReq);
+     swaps(&stuff->length);
+     swapl(&stuff->src);
+     swapl(&stuff->dst);
+@@ -2192,6 +2200,7 @@
+ SProcRenderCreateGlyphSet(ClientPtr client)
+ {
+     REQUEST(xRenderCreateGlyphSetReq);
++    REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
+     swaps(&stuff->length);
+     swapl(&stuff->gsid);
+     swapl(&stuff->format);
+@@ -2202,6 +2211,7 @@
+ SProcRenderReferenceGlyphSet(ClientPtr client)
+ {
+     REQUEST(xRenderReferenceGlyphSetReq);
++    REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
+     swaps(&stuff->length);
+     swapl(&stuff->gsid);
+     swapl(&stuff->existing);
+@@ -2212,6 +2222,7 @@
+ SProcRenderFreeGlyphSet(ClientPtr client)
+ {
+     REQUEST(xRenderFreeGlyphSetReq);
++    REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
+     swaps(&stuff->length);
+     swapl(&stuff->glyphset);
+     return (*ProcRenderVector[stuff->renderReqType]) (client);
+@@ -2226,6 +2237,7 @@
+     xGlyphInfo *gi;
+ 
+     REQUEST(xRenderAddGlyphsReq);
++    REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
+     swaps(&stuff->length);
+     swapl(&stuff->glyphset);
+     swapl(&stuff->nglyphs);
+@@ -2260,6 +2272,7 @@
+ SProcRenderFreeGlyphs(ClientPtr client)
+ {
+     REQUEST(xRenderFreeGlyphsReq);
++    REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
+     swaps(&stuff->length);
+     swapl(&stuff->glyphset);
+     SwapRestL(stuff);
+@@ -2277,6 +2290,7 @@
+     int size;
+ 
+     REQUEST(xRenderCompositeGlyphsReq);
++    REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
+ 
+     switch (stuff->renderReqType) {
+     default:
+diff -Naur xorg-server-1.12.4.orig/test/misc.c xorg-server-1.12.4/test/misc.c
+--- xorg-server-1.12.4.orig/test/misc.c	2012-05-17 19:09:05.000000000 +0200
++++ xorg-server-1.12.4/test/misc.c	2014-11-28 09:51:33.354188205 +0100
+@@ -28,6 +28,8 @@
+ #include <stdint.h>
+ #include "misc.h"
+ #include "scrnintstr.h"
++#include "dix.h"
++#include "dixstruct.h"
+ 
+ ScreenInfo screenInfo;
+ 
+@@ -155,11 +157,46 @@
+     assert_dimensions(-w2, -h2, w2, h2);
+ }
+ 
++static int
++dix_request_fixed_size_overflow(ClientRec *client)
++{
++    xReq req = { 0 };
++
++    client->req_len = req.length = 1;
++    REQUEST_FIXED_SIZE(req, SIZE_MAX);
++    return Success;
++}
++
++static int
++dix_request_fixed_size_match(ClientRec *client)
++{
++    xReq req = { 0 };
++
++    client->req_len = req.length = 9;
++    REQUEST_FIXED_SIZE(req, 30);
++    return Success;
++}
++
++static void
++dix_request_size_checks(void)
++{
++    ClientRec client = { 0 };
++    int rc;
++
++    rc = dix_request_fixed_size_overflow(&client);
++    assert(rc == BadLength);
++
++    rc = dix_request_fixed_size_match(&client);
++    assert(rc == Success);
++}
++
++
+ int
+ main(int argc, char **argv)
+ {
+     dix_version_compare();
+     dix_update_desktop_dimensions();
++    dix_request_size_checks();
+ 
+     return 0;
+ }
+diff -Naur xorg-server-1.12.4.orig/test/xi2/protocol-xigetclientpointer.c xorg-server-1.12.4/test/xi2/protocol-xigetclientpointer.c
+--- xorg-server-1.12.4.orig/test/xi2/protocol-xigetclientpointer.c	2012-05-17 19:09:05.000000000 +0200
++++ xorg-server-1.12.4/test/xi2/protocol-xigetclientpointer.c	2014-11-28 09:51:28.970139371 +0100
+@@ -124,6 +124,11 @@
+     request.win = INVALID_WINDOW_ID;
+     request_XIGetClientPointer(&client_request, &request, BadWindow);
+ 
++    printf("Testing invalid length\n");
++    client_request.req_len -= 4;
++    request_XIGetClientPointer(&client_request, &request, BadLength);
++    client_request.req_len += 4;
++
+     test_data.cp_is_set = FALSE;
+ 
+     printf("Testing window None, unset ClientPointer.\n");
+diff -Naur xorg-server-1.12.4.orig/test/xi2/protocol-xipassivegrabdevice.c xorg-server-1.12.4/test/xi2/protocol-xipassivegrabdevice.c
+--- xorg-server-1.12.4.orig/test/xi2/protocol-xipassivegrabdevice.c	2012-05-17 19:09:05.000000000 +0200
++++ xorg-server-1.12.4/test/xi2/protocol-xipassivegrabdevice.c	2014-11-28 09:51:28.970139371 +0100
+@@ -137,6 +137,7 @@
+     int rc;
+     int modifiers;
+ 
++    client_request.req_len = req->length;
+     rc = ProcXIPassiveGrabDevice(&client_request);
+     assert(rc == error);
+ 
+@@ -187,6 +188,13 @@
+     request_XIPassiveGrabDevice(&client_request, request, BadDevice,
+                                 request->deviceid);
+ 
++    printf("Testing invalid length\n");
++    request->length -= 2;
++    request_XIPassiveGrabDevice(&client_request, request, BadLength,
++                                client_request.errorValue);
++    /* re-init request since swapped length test leaves some values swapped */
++    request_init(request, XIPassiveGrabDevice);
++    request->grab_window = CLIENT_WINDOW_ID;
+     request->deviceid = XIAllMasterDevices;
+ 
+     printf("Testing invalid grab types\n");
+diff -Naur xorg-server-1.12.4.orig/test/xi2/protocol-xiquerypointer.c xorg-server-1.12.4/test/xi2/protocol-xiquerypointer.c
+--- xorg-server-1.12.4.orig/test/xi2/protocol-xiquerypointer.c	2012-05-17 19:09:05.000000000 +0200
++++ xorg-server-1.12.4/test/xi2/protocol-xiquerypointer.c	2014-11-28 09:51:28.970139371 +0100
+@@ -200,6 +200,10 @@
+     test_data.dev = devices.mouse;
+     request.deviceid = devices.mouse->id;
+     request_XIQueryPointer(&client_request, &request, Success);
++
++    /* test REQUEST_SIZE_MATCH */
++    client_request.req_len -= 4;
++    request_XIQueryPointer(&client_request, &request, BadLength);
+ }
+ 
+ int
+diff -Naur xorg-server-1.12.4.orig/test/xi2/protocol-xiwarppointer.c xorg-server-1.12.4/test/xi2/protocol-xiwarppointer.c
+--- xorg-server-1.12.4.orig/test/xi2/protocol-xiwarppointer.c	2012-05-17 19:09:05.000000000 +0200
++++ xorg-server-1.12.4/test/xi2/protocol-xiwarppointer.c	2014-11-28 09:51:28.974139415 +0100
+@@ -197,6 +197,9 @@
+     request_XIWarpPointer(&client_request, &request, Success);
+ 
+     /* FIXME: src_x/y checks */
++
++    client_request.req_len -= 2; /* invalid length */
++    request_XIWarpPointer(&client_request, &request, BadLength);
+ }
+ 
+ int
+diff -Naur xorg-server-1.12.4.orig/Xext/xcmisc.c xorg-server-1.12.4/Xext/xcmisc.c
+--- xorg-server-1.12.4.orig/Xext/xcmisc.c	2012-05-17 19:09:01.000000000 +0200
++++ xorg-server-1.12.4/Xext/xcmisc.c	2014-11-28 09:51:03.837859407 +0100
+@@ -161,6 +161,7 @@
+ SProcXCMiscGetXIDList(ClientPtr client)
+ {
+     REQUEST(xXCMiscGetXIDListReq);
++    REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
+ 
+     swaps(&stuff->length);
+     swapl(&stuff->count);
+diff -Naur xorg-server-1.12.4.orig/Xext/xvdisp.c xorg-server-1.12.4/Xext/xvdisp.c
+--- xorg-server-1.12.4.orig/Xext/xvdisp.c	2012-05-17 19:09:01.000000000 +0200
++++ xorg-server-1.12.4/Xext/xvdisp.c	2014-11-28 09:51:07.413899243 +0100
+@@ -1202,6 +1202,7 @@
+ SProcXvQueryExtension(ClientPtr client)
+ {
+     REQUEST(xvQueryExtensionReq);
++    REQUEST_SIZE_MATCH(xvQueryExtensionReq);
+     swaps(&stuff->length);
+     return XvProcVector[xv_QueryExtension] (client);
+ }
+@@ -1210,6 +1211,7 @@
+ SProcXvQueryAdaptors(ClientPtr client)
+ {
+     REQUEST(xvQueryAdaptorsReq);
++    REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
+     swaps(&stuff->length);
+     swapl(&stuff->window);
+     return XvProcVector[xv_QueryAdaptors] (client);
+@@ -1219,6 +1221,7 @@
+ SProcXvQueryEncodings(ClientPtr client)
+ {
+     REQUEST(xvQueryEncodingsReq);
++    REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     return XvProcVector[xv_QueryEncodings] (client);
+@@ -1228,6 +1231,7 @@
+ SProcXvGrabPort(ClientPtr client)
+ {
+     REQUEST(xvGrabPortReq);
++    REQUEST_SIZE_MATCH(xvGrabPortReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->time);
+@@ -1238,6 +1242,7 @@
+ SProcXvUngrabPort(ClientPtr client)
+ {
+     REQUEST(xvUngrabPortReq);
++    REQUEST_SIZE_MATCH(xvUngrabPortReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->time);
+@@ -1248,6 +1253,7 @@
+ SProcXvPutVideo(ClientPtr client)
+ {
+     REQUEST(xvPutVideoReq);
++    REQUEST_SIZE_MATCH(xvPutVideoReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->drawable);
+@@ -1267,6 +1273,7 @@
+ SProcXvPutStill(ClientPtr client)
+ {
+     REQUEST(xvPutStillReq);
++    REQUEST_SIZE_MATCH(xvPutStillReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->drawable);
+@@ -1286,6 +1293,7 @@
+ SProcXvGetVideo(ClientPtr client)
+ {
+     REQUEST(xvGetVideoReq);
++    REQUEST_SIZE_MATCH(xvGetVideoReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->drawable);
+@@ -1305,6 +1313,7 @@
+ SProcXvGetStill(ClientPtr client)
+ {
+     REQUEST(xvGetStillReq);
++    REQUEST_SIZE_MATCH(xvGetStillReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->drawable);
+@@ -1324,6 +1333,7 @@
+ SProcXvPutImage(ClientPtr client)
+ {
+     REQUEST(xvPutImageReq);
++    REQUEST_AT_LEAST_SIZE(xvPutImageReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->drawable);
+@@ -1347,6 +1357,7 @@
+ SProcXvShmPutImage(ClientPtr client)
+ {
+     REQUEST(xvShmPutImageReq);
++    REQUEST_SIZE_MATCH(xvShmPutImageReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->drawable);
+@@ -1374,6 +1385,7 @@
+ SProcXvSelectVideoNotify(ClientPtr client)
+ {
+     REQUEST(xvSelectVideoNotifyReq);
++    REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
+     swaps(&stuff->length);
+     swapl(&stuff->drawable);
+     return XvProcVector[xv_SelectVideoNotify] (client);
+@@ -1383,6 +1395,7 @@
+ SProcXvSelectPortNotify(ClientPtr client)
+ {
+     REQUEST(xvSelectPortNotifyReq);
++    REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     return XvProcVector[xv_SelectPortNotify] (client);
+@@ -1392,6 +1405,7 @@
+ SProcXvStopVideo(ClientPtr client)
+ {
+     REQUEST(xvStopVideoReq);
++    REQUEST_SIZE_MATCH(xvStopVideoReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->drawable);
+@@ -1402,6 +1416,7 @@
+ SProcXvSetPortAttribute(ClientPtr client)
+ {
+     REQUEST(xvSetPortAttributeReq);
++    REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->attribute);
+@@ -1413,6 +1428,7 @@
+ SProcXvGetPortAttribute(ClientPtr client)
+ {
+     REQUEST(xvGetPortAttributeReq);
++    REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->attribute);
+@@ -1423,6 +1439,7 @@
+ SProcXvQueryBestSize(ClientPtr client)
+ {
+     REQUEST(xvQueryBestSizeReq);
++    REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swaps(&stuff->vid_w);
+@@ -1436,6 +1453,7 @@
+ SProcXvQueryPortAttributes(ClientPtr client)
+ {
+     REQUEST(xvQueryPortAttributesReq);
++    REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     return XvProcVector[xv_QueryPortAttributes] (client);
+@@ -1445,6 +1463,7 @@
+ SProcXvQueryImageAttributes(ClientPtr client)
+ {
+     REQUEST(xvQueryImageAttributesReq);
++    REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     swapl(&stuff->id);
+@@ -1457,6 +1476,7 @@
+ SProcXvListImageFormats(ClientPtr client)
+ {
+     REQUEST(xvListImageFormatsReq);
++    REQUEST_SIZE_MATCH(xvListImageFormatsReq);
+     swaps(&stuff->length);
+     swapl(&stuff->port);
+     return XvProcVector[xv_ListImageFormats] (client);
+diff -Naur xorg-server-1.12.4.orig/xfixes/select.c xorg-server-1.12.4/xfixes/select.c
+--- xorg-server-1.12.4.orig/xfixes/select.c	2012-05-17 19:09:05.000000000 +0200
++++ xorg-server-1.12.4/xfixes/select.c	2014-11-28 09:51:22.470066963 +0100
+@@ -204,6 +204,7 @@
+ {
+     REQUEST(xXFixesSelectSelectionInputReq);
+ 
++    REQUEST_SIZE_MATCH(xXFixesSelectSelectionInputReq);
+     swaps(&stuff->length);
+     swapl(&stuff->window);
+     swapl(&stuff->selection);
+diff -aur xorg-server-1.12.4.orig/render/render.c xorg-server-1.12.4/render/render.c
+--- xorg-server-1.12.4.orig/render/render.c	2014-11-28 09:51:16.878004670 +0100
++++ xorg-server-1.12.4/render/render.c	2014-11-28 10:00:10.899950898 +0100
+@@ -271,10 +271,11 @@
+ 
+     REQUEST(xRenderQueryVersionReq);
+ 
++    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
++
+     pRenderClient->major_version = stuff->majorVersion;
+     pRenderClient->minor_version = stuff->minorVersion;
+ 
+-    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
+     memset(&rep, 0, sizeof(xRenderQueryVersionReply));
+     rep.type = X_Reply;
+     rep.length = 0;
+diff -Naur xorg-server-1.12.4.orig/glx/glxcmds.c xorg-server-1.12.4/glx/glxcmds.c
+--- xorg-server-1.12.4.orig/glx/glxcmds.c	2014-11-28 10:01:44.068987817 +0100
++++ xorg-server-1.12.4/glx/glxcmds.c	2014-11-28 10:05:07.515246883 +0100
+@@ -2032,6 +2032,8 @@
+ 
+     __GLX_DECLARE_SWAP_VARIABLES;
+ 
++    REQUEST_AT_LEAST_SIZE(xGLXRenderLargeReq);
++
+     req = (xGLXRenderLargeReq *) pc;
+     if (client->swapped) {
+         __GLX_SWAP_SHORT(&req->length);
+@@ -2047,12 +2049,14 @@
+         __glXResetLargeCommandStatus(cl);
+         return error;
+     }
++    if (safe_pad(req->dataBytes) < 0)
++        return BadLength;
+     dataBytes = req->dataBytes;
+ 
+     /*
+      ** Check the request length.
+      */
+-    if ((req->length << 2) != __GLX_PAD(dataBytes) + sz_xGLXRenderLargeReq) {
++    if ((req->length << 2) != safe_pad(dataBytes) + sz_xGLXRenderLargeReq) {
+         client->errorValue = req->length;
+         /* Reset in case this isn't 1st request. */
+         __glXResetLargeCommandStatus(cl);
+@@ -2062,7 +2066,7 @@
+ 
+     if (cl->largeCmdRequestsSoFar == 0) {
+         __GLXrenderSizeData entry;
+-        int extra;
++        int extra = 0;
+         size_t cmdlen;
+         int err;
+ 
+@@ -2075,13 +2079,17 @@
+             return __glXError(GLXBadLargeRequest);
+         }
+ 
++        if (dataBytes < __GLX_RENDER_LARGE_HDR_SIZE)
++            return BadLength;
++
+         hdr = (__GLXrenderLargeHeader *) pc;
+         if (client->swapped) {
+             __GLX_SWAP_INT(&hdr->length);
+             __GLX_SWAP_INT(&hdr->opcode);
+         }
+-        cmdlen = hdr->length;
+         opcode = hdr->opcode;
++        if ((cmdlen = safe_pad(hdr->length)) < 0)
++            return BadLength;
+ 
+         /*
+          ** Check for core opcodes and grab entry data.
+@@ -2103,17 +2111,13 @@
+             if (extra < 0) {
+                 return BadLength;
+             }
+-            /* large command's header is 4 bytes longer, so add 4 */
+-            if (cmdlen != __GLX_PAD(entry.bytes + 4 + extra)) {
+-                return BadLength;
+-            }
+         }
+-        else {
+-            /* constant size command */
+-            if (cmdlen != __GLX_PAD(entry.bytes + 4)) {
+-                return BadLength;
+-            }
++
++        /* the +4 is safe because we know entry.bytes is small */
++        if (cmdlen != safe_pad(safe_add(entry.bytes + 4, extra))) {
++            return BadLength;
+         }
++
+         /*
+          ** Make enough space in the buffer, then copy the entire request.
+          */
+@@ -2143,6 +2147,7 @@
+          ** We are receiving subsequent (i.e. not the first) requests of a
+          ** multi request command.
+          */
++        int bytesSoFar; /* including this packet */
+ 
+         /*
+          ** Check the request number and the total request count.
+@@ -2161,11 +2166,18 @@
+         /*
+          ** Check that we didn't get too much data.
+          */
+-        if ((cl->largeCmdBytesSoFar + dataBytes) > cl->largeCmdBytesTotal) {
++        if ((bytesSoFar = safe_add(cl->largeCmdBytesSoFar, dataBytes)) < 0) {
+             client->errorValue = dataBytes;
+             __glXResetLargeCommandStatus(cl);
+             return __glXError(GLXBadLargeRequest);
+         }
++
++        if (bytesSoFar > cl->largeCmdBytesTotal) {
++            client->errorValue = dataBytes;
++            __glXResetLargeCommandStatus(cl);
++            return __glXError(GLXBadLargeRequest);
++        }
++
+         memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes);
+         cl->largeCmdBytesSoFar += dataBytes;
+         cl->largeCmdRequestsSoFar++;
+@@ -2186,8 +2198,7 @@
+              ** the padding done below fixes a bug that did not allow
+              ** large commands of odd sizes to be accepted by the server.
+              */
+-            if (__GLX_PAD(cl->largeCmdBytesSoFar) !=
+-                __GLX_PAD(cl->largeCmdBytesTotal)) {
++            if (safe_pad(cl->largeCmdBytesSoFar) != cl->largeCmdBytesTotal) {
+                 client->errorValue = dataBytes;
+                 __glXResetLargeCommandStatus(cl);
+                 return __glXError(GLXBadLargeRequest);
+diff -Naur xorg-server-1.12.4.orig/glx/indirect_texture_compression.c xorg-server-1.12.4/glx/indirect_texture_compression.c
+--- xorg-server-1.12.4.orig/glx/indirect_texture_compression.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/indirect_texture_compression.c	2014-11-28 10:26:39.461548117 +0100
+@@ -47,6 +47,8 @@
+     __GLXcontext *const cx = __glXForceCurrent(cl, req->contextTag, &error);
+     ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 8);
++
+     pc += __GLX_SINGLE_HDR_SIZE;
+     if (cx != NULL) {
+         const GLenum target = *(GLenum *) (pc + 0);
+@@ -93,6 +95,8 @@
+         __glXForceCurrent(cl, bswap_32(req->contextTag), &error);
+     ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 8);
++
+     pc += __GLX_SINGLE_HDR_SIZE;
+     if (cx != NULL) {
+         const GLenum target = (GLenum) bswap_32(*(int *) (pc + 0));
+diff -Naur xorg-server-1.12.4.orig/glx/single2.c xorg-server-1.12.4/glx/single2.c
+--- xorg-server-1.12.4.orig/glx/single2.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/single2.c	2014-11-28 10:26:39.461548117 +0100
+@@ -49,11 +49,14 @@
+ int
+ __glXDisp_FeedbackBuffer(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     GLsizei size;
+     GLenum type;
+     __GLXcontext *cx;
+     int error;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 8);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -80,10 +83,13 @@
+ int
+ __glXDisp_SelectBuffer(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+     GLsizei size;
+     int error;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -108,7 +114,7 @@
+ int
+ __glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc)
+ {
+-    ClientPtr client;
++    ClientPtr client = cl->client;
+     xGLXRenderModeReply reply;
+     __GLXcontext *cx;
+     GLint nitems = 0, retBytes = 0, retval, newModeCheck;
+@@ -116,6 +122,8 @@
+     GLenum newMode;
+     int error;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -192,7 +200,6 @@
+      ** selection array, as per the API for glRenderMode itself.
+      */
+  noChangeAllowed:;
+-    client = cl->client;
+     reply.length = nitems;
+     reply.type = X_Reply;
+     reply.sequenceNumber = client->sequence;
+@@ -209,9 +216,12 @@
+ int
+ __glXDisp_Flush(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+     int error;
+ 
++    REQUEST_SIZE_MATCH(xGLXSingleReq);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -225,10 +235,12 @@
+ int
+ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+-    ClientPtr client;
+     int error;
+ 
++    REQUEST_SIZE_MATCH(xGLXSingleReq);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -319,7 +331,7 @@
+ int
+ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap)
+ {
+-    ClientPtr client;
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+     GLenum name;
+     const char *string;
+@@ -329,6 +341,8 @@
+     char *buf = NULL, *buf1 = NULL;
+     GLint length = 0;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
++
+     /* If the client has the opposite byte order, swap the contextTag and
+      * the name.
+      */
+@@ -345,7 +359,6 @@
+     pc += __GLX_SINGLE_HDR_SIZE;
+     name = *(GLenum *) (pc + 0);
+     string = (const char *) CALL_GetString(GET_DISPATCH(), (name));
+-    client = cl->client;
+ 
+     if (string == NULL)
+         string = "";
+diff -Naur xorg-server-1.12.4.orig/glx/single2swap.c xorg-server-1.12.4/glx/single2swap.c
+--- xorg-server-1.12.4.orig/glx/single2swap.c	2012-05-17 19:09:02.000000000 +0200
++++ xorg-server-1.12.4/glx/single2swap.c	2014-11-28 10:26:39.465548161 +0100
+@@ -45,6 +45,7 @@
+ int
+ __glXDispSwap_FeedbackBuffer(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     GLsizei size;
+     GLenum type;
+ 
+@@ -52,6 +53,8 @@
+     __GLXcontext *cx;
+     int error;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 8);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -81,12 +84,15 @@
+ int
+ __glXDispSwap_SelectBuffer(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+     GLsizei size;
+ 
+     __GLX_DECLARE_SWAP_VARIABLES;
+     int error;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -113,7 +119,7 @@
+ int
+ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc)
+ {
+-    ClientPtr client;
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+     xGLXRenderModeReply reply;
+     GLint nitems = 0, retBytes = 0, retval, newModeCheck;
+@@ -124,6 +130,8 @@
+     __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+     int error;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -204,7 +212,6 @@
+      ** selection array, as per the API for glRenderMode itself.
+      */
+  noChangeAllowed:;
+-    client = cl->client;
+     reply.length = nitems;
+     reply.type = X_Reply;
+     reply.sequenceNumber = client->sequence;
+@@ -226,11 +233,14 @@
+ int
+ __glXDispSwap_Flush(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+     int error;
+ 
+     __GLX_DECLARE_SWAP_VARIABLES;
+ 
++    REQUEST_SIZE_MATCH(xGLXSingleReq);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -245,12 +255,14 @@
+ int
+ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc)
+ {
++    ClientPtr client = cl->client;
+     __GLXcontext *cx;
+-    ClientPtr client;
+     int error;
+ 
+     __GLX_DECLARE_SWAP_VARIABLES;
+ 
++    REQUEST_SIZE_MATCH(xGLXSingleReq);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -262,7 +274,6 @@
+     cx->hasUnflushedCommands = GL_FALSE;
+ 
+     /* Send empty reply packet to indicate finish is finished */
+-    client = cl->client;
+     __GLX_BEGIN_REPLY(0);
+     __GLX_PUT_RETVAL(0);
+     __GLX_SWAP_REPLY_HEADER();
+diff -Naur xorg-server-1.12.4.orig/glx/singlepix.c xorg-server-1.12.4/glx/singlepix.c
+--- xorg-server-1.12.4.orig/glx/singlepix.c	2014-11-28 10:06:28.116140360 +0100
++++ xorg-server-1.12.4/glx/singlepix.c	2014-11-28 10:26:39.465548161 +0100
+@@ -55,6 +55,8 @@
+     int error;
+     char *answer, answerBuffer[200];
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 28);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -107,6 +109,8 @@
+     char *answer, answerBuffer[200];
+     GLint width = 0, height = 0, depth = 1;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 20);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -169,6 +173,8 @@
+     GLubyte answerBuffer[200];
+     char *answer;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
++
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+         return error;
+@@ -231,15 +237,15 @@
+     compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
+     compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
+ 
+-    if (compsize < 0)
++    if ((compsize = safe_pad(compsize)) < 0)
+         return BadLength;
+-    if (compsize2 < 0)
++
++    if ((compsize2 = safe_pad(compsize2)) < 0)
+         return BadLength;
+-    compsize = __GLX_PAD(compsize);
+-    compsize2 = __GLX_PAD(compsize2);
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, swapBytes));
+-    __GLX_GET_ANSWER_BUFFER(answer, cl, compsize + compsize2, 1);
++    __GLX_GET_ANSWER_BUFFER(answer, cl, safe_add(compsize, compsize2), 1);
++
+     __glXClearErrorOccured();
+     CALL_GetSeparableFilter(GET_DISPATCH(), (*(GLenum *) (pc + 0),
+                                              *(GLenum *) (pc + 4),
+@@ -265,7 +271,8 @@
+ __glXDisp_GetSeparableFilter(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetSeparableFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -273,7 +280,8 @@
+ __glXDisp_GetSeparableFilterEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetSeparableFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -343,7 +351,8 @@
+ __glXDisp_GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetConvolutionFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -351,7 +360,8 @@
+ __glXDisp_GetConvolutionFilterEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetConvolutionFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -411,7 +421,8 @@
+ __glXDisp_GetHistogram(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetHistogram(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -419,7 +430,8 @@
+ __glXDisp_GetHistogramEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetHistogram(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -471,7 +483,8 @@
+ __glXDisp_GetMinmax(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetMinmax(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -479,7 +492,8 @@
+ __glXDisp_GetMinmaxEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetMinmax(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -540,7 +554,8 @@
+ __glXDisp_GetColorTable(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetColorTable(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -548,6 +563,7 @@
+ __glXDisp_GetColorTableSGI(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
+-
++    ClientPtr client = cl->client;
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetColorTable(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+diff -Naur xorg-server-1.12.4.orig/glx/singlepixswap.c xorg-server-1.12.4/glx/singlepixswap.c
+--- xorg-server-1.12.4.orig/glx/singlepixswap.c	2014-11-28 10:06:28.116140360 +0100
++++ xorg-server-1.12.4/glx/singlepixswap.c	2014-11-28 10:26:39.465548161 +0100
+@@ -57,6 +57,8 @@
+     int error;
+     char *answer, answerBuffer[200];
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 28);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -122,6 +124,8 @@
+     char *answer, answerBuffer[200];
+     GLint width = 0, height = 0, depth = 1;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 20);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -197,6 +201,8 @@
+ 
+     __GLX_DECLARE_SWAP_VARIABLES;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
++
+     __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag);
+     cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+     if (!cx) {
+@@ -266,15 +272,13 @@
+     compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
+     compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
+ 
+-    if (compsize < 0)
++    if ((compsize = safe_pad(compsize)) < 0)
+         return BadLength;
+-    if (compsize2 < 0)
++    if ((compsize2 = safe_pad(compsize2)) < 0)
+         return BadLength;
+-    compsize = __GLX_PAD(compsize);
+-    compsize2 = __GLX_PAD(compsize2);
+ 
+     CALL_PixelStorei(GET_DISPATCH(), (GL_PACK_SWAP_BYTES, !swapBytes));
+-    __GLX_GET_ANSWER_BUFFER(answer, cl, compsize + compsize2, 1);
++    __GLX_GET_ANSWER_BUFFER(answer, cl, safe_add(compsize, compsize2), 1);
+     __glXClearErrorOccured();
+     CALL_GetSeparableFilter(GET_DISPATCH(), (*(GLenum *) (pc + 0),
+                                              *(GLenum *) (pc + 4),
+@@ -302,7 +306,9 @@
+ __glXDispSwap_GetSeparableFilter(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetSeparableFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -310,7 +316,9 @@
+ __glXDispSwap_GetSeparableFilterEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetSeparableFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -388,7 +396,9 @@
+ __glXDispSwap_GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetConvolutionFilter(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -396,7 +406,9 @@
+ __glXDispSwap_GetConvolutionFilterEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetConvolutionFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -463,7 +475,9 @@
+ __glXDispSwap_GetHistogram(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetHistogram(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -471,7 +485,9 @@
+ __glXDispSwap_GetHistogramEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetHistogram(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -529,7 +545,9 @@
+ __glXDispSwap_GetMinmax(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetMinmax(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -537,7 +555,9 @@
+ __glXDispSwap_GetMinmaxEXT(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetMinmax(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+ 
+@@ -605,7 +625,9 @@
+ __glXDispSwap_GetColorTable(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXSingleReq, 16);
+     return GetColorTable(cl, pc + __GLX_SINGLE_HDR_SIZE, tag);
+ }
+ 
+@@ -613,6 +635,8 @@
+ __glXDispSwap_GetColorTableSGI(__GLXclientState * cl, GLbyte * pc)
+ {
+     const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc);
++    ClientPtr client = cl->client;
+ 
++    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16);
+     return GetColorTable(cl, pc + __GLX_VENDPRIV_HDR_SIZE, tag);
+ }
+diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
+index ff5d69a..e87df42 100644
+--- a/Xi/chgdctl.c
++++ b/Xi/chgdctl.c
+@@ -78,7 +78,7 @@ SProcXChangeDeviceControl(ClientPtr client)
+ 
+     REQUEST(xChangeDeviceControlReq);
+     swaps(&stuff->length);
+-    REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
++    REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
+     swaps(&stuff->control);
+     ctl = (xDeviceCtl *) &stuff[1];
+     swaps(&ctl->control);
+@@ -116,7 +116,7 @@ ProcXChangeDeviceControl(ClientPtr client)
+     devicePresenceNotify dpn;
+ 
+     REQUEST(xChangeDeviceControlReq);
+-    REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
++    REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
+ 
+     len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceControlReq));
+     ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
+@@ -184,6 +184,10 @@ ProcXChangeDeviceControl(ClientPtr client)
+         break;
+     case DEVICE_ENABLE:
+         e = (xDeviceEnableCtl *) &stuff[1];
++        if ((len != bytes_to_int32(sizeof(xDeviceEnableCtl)))) {
++            ret = BadLength;
++            goto out;
++        }
+ 
+         status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e);
+ 
+diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c
+index 6dcf60c..224c2ba 100644
+--- a/Xi/chgfctl.c
++++ b/Xi/chgfctl.c
+@@ -467,6 +467,8 @@ ProcXChangeFeedbackControl(ClientPtr client)
+         xStringFeedbackCtl *f = ((xStringFeedbackCtl *) &stuff[1]);
+ 
+         if (client->swapped) {
++            if (len < bytes_to_int32(sizeof(xStringFeedbackCtl)))
++                return BadLength;
+             swaps(&f->num_keysyms);
+         }
+         if (len !=
+diff --git a/Xi/sendexev.c b/Xi/sendexev.c
+index 3c21386..183f88d 100644
+--- a/Xi/sendexev.c
++++ b/Xi/sendexev.c
+@@ -135,6 +135,9 @@ ProcXSendExtensionEvent(ClientPtr client)
+     if (ret != Success)
+         return ret;
+ 
++    if (stuff->num_events == 0)
++        return ret;
++
+     /* The client's event type must be one defined by an extension. */
+ 
+     first = ((xEvent *) &stuff[1]);
+diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
+index 62a0727..156c738 100644
+--- a/Xi/xiallowev.c
++++ b/Xi/xiallowev.c
+@@ -48,6 +48,7 @@ int
+ SProcXIAllowEvents(ClientPtr client)
+ {
+     REQUEST(xXIAllowEventsReq);
++    REQUEST_AT_LEAST_SIZE(xXIAllowEventsReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+@@ -55,6 +56,7 @@ SProcXIAllowEvents(ClientPtr client)
+     if (stuff->length > 3) {
+         xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq *) stuff;
+ 
++        REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq);
+         swapl(&req_xi22->touchid);
+         swapl(&req_xi22->grab_window);
+     }
+diff --git a/Xi/xichangecursor.c b/Xi/xichangecursor.c
+index 0be6bc0..33e9e9c 100644
+--- a/Xi/xichangecursor.c
++++ b/Xi/xichangecursor.c
+@@ -57,11 +57,11 @@ int
+ SProcXIChangeCursor(ClientPtr client)
+ {
+     REQUEST(xXIChangeCursorReq);
++    REQUEST_SIZE_MATCH(xXIChangeCursorReq);
+     swaps(&stuff->length);
+     swapl(&stuff->win);
+     swapl(&stuff->cursor);
+     swaps(&stuff->deviceid);
+-    REQUEST_SIZE_MATCH(xXIChangeCursorReq);
+     return (ProcXIChangeCursor(client));
+ }
+ 
+diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
+index 756aaac..d2244cf 100644
+--- a/Xi/xichangehierarchy.c
++++ b/Xi/xichangehierarchy.c
+@@ -407,7 +407,7 @@ int
+ ProcXIChangeHierarchy(ClientPtr client)
+ {
+     xXIAnyHierarchyChangeInfo *any;
+-    int required_len = sizeof(xXIChangeHierarchyReq);
++    size_t len;			/* length of data remaining in request */
+     int rc = Success;
+     int flags[MAXDEVICES] = { 0 };
+ 
+@@ -417,21 +417,46 @@ ProcXIChangeHierarchy(ClientPtr client)
+     if (!stuff->num_changes)
+         return rc;
+ 
++    if (stuff->length > (INT_MAX >> 2))
++        return BadAlloc;
++    len = (stuff->length << 2) - sizeof(xXIAnyHierarchyChangeInfo);
++
+     any = (xXIAnyHierarchyChangeInfo *) &stuff[1];
+     while (stuff->num_changes--) {
++        if (len < sizeof(xXIAnyHierarchyChangeInfo)) {
++            rc = BadLength;
++            goto unwind;
++        }
++
+         SWAPIF(swaps(&any->type));
+         SWAPIF(swaps(&any->length));
+ 
+-        required_len += any->length;
+-        if ((stuff->length * 4) < required_len)
++        if ((any->length > (INT_MAX >> 2)) || (len < (any->length << 2)))
+             return BadLength;
+ 
++#define CHANGE_SIZE_MATCH(type) \
++    do { \
++        if ((len < sizeof(type)) || (any->length != (sizeof(type) >> 2))) { \
++            rc = BadLength; \
++            goto unwind; \
++        } \
++    } while(0)
++
+         switch (any->type) {
+         case XIAddMaster:
+         {
+             xXIAddMasterInfo *c = (xXIAddMasterInfo *) any;
+ 
++            /* Variable length, due to appended name string */
++            if (len < sizeof(xXIAddMasterInfo)) {
++                rc = BadLength;
++                goto unwind;
++            }
+             SWAPIF(swaps(&c->name_len));
++            if (c->name_len > (len - sizeof(xXIAddMasterInfo))) {
++                rc = BadLength;
++                goto unwind;
++            }
+ 
+             rc = add_master(client, c, flags);
+             if (rc != Success)
+@@ -442,6 +467,7 @@ ProcXIChangeHierarchy(ClientPtr client)
+         {
+             xXIRemoveMasterInfo *r = (xXIRemoveMasterInfo *) any;
+ 
++            CHANGE_SIZE_MATCH(xXIRemoveMasterInfo);
+             rc = remove_master(client, r, flags);
+             if (rc != Success)
+                 goto unwind;
+@@ -451,6 +477,7 @@ ProcXIChangeHierarchy(ClientPtr client)
+         {
+             xXIDetachSlaveInfo *c = (xXIDetachSlaveInfo *) any;
+ 
++            CHANGE_SIZE_MATCH(xXIDetachSlaveInfo);
+             rc = detach_slave(client, c, flags);
+             if (rc != Success)
+                 goto unwind;
+@@ -460,6 +487,7 @@ ProcXIChangeHierarchy(ClientPtr client)
+         {
+             xXIAttachSlaveInfo *c = (xXIAttachSlaveInfo *) any;
+ 
++            CHANGE_SIZE_MATCH(xXIAttachSlaveInfo);
+             rc = attach_slave(client, c, flags);
+             if (rc != Success)
+                 goto unwind;
+@@ -467,6 +495,7 @@ ProcXIChangeHierarchy(ClientPtr client)
+             break;
+         }
+ 
++        len -= any->length * 4;
+         any = (xXIAnyHierarchyChangeInfo *) ((char *) any + any->length * 4);
+     }
+ 
+diff --git a/Xi/xigetclientpointer.c b/Xi/xigetclientpointer.c
+index 07dbf18..a066497 100644
+--- a/Xi/xigetclientpointer.c
++++ b/Xi/xigetclientpointer.c
+@@ -50,6 +50,7 @@ int
+ SProcXIGetClientPointer(ClientPtr client)
+ {
+     REQUEST(xXIGetClientPointerReq);
++    REQUEST_SIZE_MATCH(xXIGetClientPointerReq);
+ 
+     swaps(&stuff->length);
+     swapl(&stuff->win);
+diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
+index 8d2cf0b..3dafbbd 100644
+--- a/Xi/xigrabdev.c
++++ b/Xi/xigrabdev.c
+@@ -47,6 +47,11 @@ int
+ SProcXIGrabDevice(ClientPtr client)
+ {
+     REQUEST(xXIGrabDeviceReq);
++    /*
++     * Check here for at least the length of the struct we swap, then
++     * let ProcXIGrabDevice check the full size after we swap mask_len.
++     */
++    REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+@@ -69,7 +74,7 @@ ProcXIGrabDevice(ClientPtr client)
+     int mask_len;
+ 
+     REQUEST(xXIGrabDeviceReq);
+-    REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
++    REQUEST_FIXED_SIZE(xXIGrabDeviceReq, ((size_t) stuff->mask_len) * 4);
+ 
+     ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
+     if (ret != Success)
+@@ -118,6 +123,7 @@ int
+ SProcXIUngrabDevice(ClientPtr client)
+ {
+     REQUEST(xXIUngrabDeviceReq);
++    REQUEST_SIZE_MATCH(xXIUngrabDeviceReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+@@ -135,6 +141,7 @@ ProcXIUngrabDevice(ClientPtr client)
+     TimeStamp time;
+ 
+     REQUEST(xXIUngrabDeviceReq);
++    REQUEST_SIZE_MATCH(xXIUngrabDeviceReq);
+ 
+     ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
+     if (ret != Success)
+diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
+index 7130328..06f44d7 100644
+--- a/Xi/xipassivegrab.c
++++ b/Xi/xipassivegrab.c
+@@ -53,6 +53,7 @@ SProcXIPassiveGrabDevice(ClientPtr client)
+     xXIModifierInfo *mods;
+ 
+     REQUEST(xXIPassiveGrabDeviceReq);
++    REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+@@ -63,7 +64,9 @@ SProcXIPassiveGrabDevice(ClientPtr client)
+     swaps(&stuff->mask_len);
+     swaps(&stuff->num_modifiers);
+ 
+-    mods = (xXIModifierInfo *) &stuff[1];
++    REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq,
++        ((uint32_t) stuff->mask_len + stuff->num_modifiers) *4);
++    mods = (uint32_t *) &stuff[1] + stuff->mask_len;
+ 
+     for (i = 0; i < stuff->num_modifiers; i++, mods++) {
+         swapl(&mods->base_mods);
+@@ -88,7 +91,8 @@ ProcXIPassiveGrabDevice(ClientPtr client)
+     int mask_len;
+ 
+     REQUEST(xXIPassiveGrabDeviceReq);
+-    REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq);
++    REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq,
++        ((uint32_t) stuff->mask_len + stuff->num_modifiers) * 4);
+ 
+     if (stuff->deviceid == XIAllDevices)
+         dev = inputInfo.all_devices;
+@@ -250,6 +254,7 @@ SProcXIPassiveUngrabDevice(ClientPtr client)
+     uint32_t *modifiers;
+ 
+     REQUEST(xXIPassiveUngrabDeviceReq);
++    REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq);
+ 
+     swaps(&stuff->length);
+     swapl(&stuff->grab_window);
+@@ -257,6 +262,8 @@ SProcXIPassiveUngrabDevice(ClientPtr client)
+     swapl(&stuff->detail);
+     swaps(&stuff->num_modifiers);
+ 
++    REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq,
++                       ((uint32_t) stuff->num_modifiers) << 2);
+     modifiers = (uint32_t *) &stuff[1];
+ 
+     for (i = 0; i < stuff->num_modifiers; i++, modifiers++)
+@@ -275,7 +282,8 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
+     int i, rc;
+ 
+     REQUEST(xXIPassiveUngrabDeviceReq);
+-    REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq);
++    REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq,
++                       ((uint32_t) stuff->num_modifiers) << 2);
+ 
+     if (stuff->deviceid == XIAllDevices)
+         dev = inputInfo.all_devices;
+diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
+index e51aadb..37dc0c6 100644
+--- a/Xi/xiproperty.c
++++ b/Xi/xiproperty.c
+@@ -1007,10 +1007,9 @@ int
+ SProcXListDeviceProperties(ClientPtr client)
+ {
+     REQUEST(xListDevicePropertiesReq);
++    REQUEST_SIZE_MATCH(xListDevicePropertiesReq);
+ 
+     swaps(&stuff->length);
+-
+-    REQUEST_SIZE_MATCH(xListDevicePropertiesReq);
+     return (ProcXListDeviceProperties(client));
+ }
+ 
+@@ -1031,10 +1030,10 @@ int
+ SProcXDeleteDeviceProperty(ClientPtr client)
+ {
+     REQUEST(xDeleteDevicePropertyReq);
++    REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq);
+ 
+     swaps(&stuff->length);
+     swapl(&stuff->property);
+-    REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq);
+     return (ProcXDeleteDeviceProperty(client));
+ }
+ 
+@@ -1042,13 +1041,13 @@ int
+ SProcXGetDeviceProperty(ClientPtr client)
+ {
+     REQUEST(xGetDevicePropertyReq);
++    REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
+ 
+     swaps(&stuff->length);
+     swapl(&stuff->property);
+     swapl(&stuff->type);
+     swapl(&stuff->longOffset);
+     swapl(&stuff->longLength);
+-    REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
+     return (ProcXGetDeviceProperty(client));
+ }
+ 
+@@ -1243,11 +1242,10 @@ int
+ SProcXIListProperties(ClientPtr client)
+ {
+     REQUEST(xXIListPropertiesReq);
++    REQUEST_SIZE_MATCH(xXIListPropertiesReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+-
+-    REQUEST_SIZE_MATCH(xXIListPropertiesReq);
+     return (ProcXIListProperties(client));
+ }
+ 
+@@ -1269,11 +1267,11 @@ int
+ SProcXIDeleteProperty(ClientPtr client)
+ {
+     REQUEST(xXIDeletePropertyReq);
++    REQUEST_SIZE_MATCH(xXIDeletePropertyReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+     swapl(&stuff->property);
+-    REQUEST_SIZE_MATCH(xXIDeletePropertyReq);
+     return (ProcXIDeleteProperty(client));
+ }
+ 
+@@ -1281,6 +1279,7 @@ int
+ SProcXIGetProperty(ClientPtr client)
+ {
+     REQUEST(xXIGetPropertyReq);
++    REQUEST_SIZE_MATCH(xXIGetPropertyReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+@@ -1288,7 +1287,6 @@ SProcXIGetProperty(ClientPtr client)
+     swapl(&stuff->type);
+     swapl(&stuff->offset);
+     swapl(&stuff->len);
+-    REQUEST_SIZE_MATCH(xXIGetPropertyReq);
+     return (ProcXIGetProperty(client));
+ }
+ 
+diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
+index 15c8b2a..5e5c875 100644
+--- a/Xi/xiquerydevice.c
++++ b/Xi/xiquerydevice.c
+@@ -54,6 +54,7 @@ int
+ SProcXIQueryDevice(ClientPtr client)
+ {
+     REQUEST(xXIQueryDeviceReq);
++    REQUEST_SIZE_MATCH(xXIQueryDeviceReq);
+ 
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
+index 169436e..e61fa04 100644
+--- a/Xi/xiquerypointer.c
++++ b/Xi/xiquerypointer.c
+@@ -62,6 +62,8 @@ int
+ SProcXIQueryPointer(ClientPtr client)
+ {
+     REQUEST(xXIQueryPointerReq);
++    REQUEST_SIZE_MATCH(xXIQueryPointerReq);
++
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+     swapl(&stuff->win);
+diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
+index 07d3218..fc02034 100644
+--- a/Xi/xiselectev.c
++++ b/Xi/xiselectev.c
+@@ -63,6 +63,7 @@ int
+ SProcXISelectEvents(ClientPtr client)
+ {
+     int i;
++    int len;
+     xXIEventMask *evmask;
+ 
+     REQUEST(xXISelectEventsReq);
+@@ -71,10 +72,17 @@ SProcXISelectEvents(ClientPtr client)
+     swapl(&stuff->win);
+     swaps(&stuff->num_masks);
+ 
++    len = stuff->length - bytes_to_int32(sizeof(xXISelectEventsReq));
+     evmask = (xXIEventMask *) &stuff[1];
+     for (i = 0; i < stuff->num_masks; i++) {
++        if (len < bytes_to_int32(sizeof(xXIEventMask)))
++            return BadLength;
++        len -= bytes_to_int32(sizeof(xXIEventMask));
+         swaps(&evmask->deviceid);
+         swaps(&evmask->mask_len);
++        if (len < evmask->mask_len)
++            return BadLength;
++        len -= evmask->mask_len;
+         evmask =
+             (xXIEventMask *) (((char *) &evmask[1]) + evmask->mask_len * 4);
+     }
+diff --git a/Xi/xisetclientpointer.c b/Xi/xisetclientpointer.c
+index 38ff51e..24d4a53 100644
+--- a/Xi/xisetclientpointer.c
++++ b/Xi/xisetclientpointer.c
+@@ -51,10 +51,11 @@ int
+ SProcXISetClientPointer(ClientPtr client)
+ {
+     REQUEST(xXISetClientPointerReq);
++    REQUEST_SIZE_MATCH(xXISetClientPointerReq);
++
+     swaps(&stuff->length);
+     swapl(&stuff->win);
+     swaps(&stuff->deviceid);
+-    REQUEST_SIZE_MATCH(xXISetClientPointerReq);
+     return (ProcXISetClientPointer(client));
+ }
+ 
+diff --git a/Xi/xisetdevfocus.c b/Xi/xisetdevfocus.c
+index b52c9cc..a32ccb1 100644
+--- a/Xi/xisetdevfocus.c
++++ b/Xi/xisetdevfocus.c
+@@ -44,6 +44,8 @@ int
+ SProcXISetFocus(ClientPtr client)
+ {
+     REQUEST(xXISetFocusReq);
++    REQUEST_AT_LEAST_SIZE(xXISetFocusReq);
++
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+     swapl(&stuff->focus);
+@@ -56,6 +58,8 @@ int
+ SProcXIGetFocus(ClientPtr client)
+ {
+     REQUEST(xXIGetFocusReq);
++    REQUEST_AT_LEAST_SIZE(xXIGetFocusReq);
++
+     swaps(&stuff->length);
+     swaps(&stuff->deviceid);
+ 
+diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c
+index 3f051f7..780758a 100644
+--- a/Xi/xiwarppointer.c
++++ b/Xi/xiwarppointer.c
+@@ -56,6 +56,8 @@ int
+ SProcXIWarpPointer(ClientPtr client)
+ {
+     REQUEST(xXIWarpPointerReq);
++    REQUEST_SIZE_MATCH(xXIWarpPointerReq);
++
+     swaps(&stuff->length);
+     swapl(&stuff->src_win);
+     swapl(&stuff->dst_win);
+diff --git a/glx/glxcmds.c b/glx/glxcmds.c
+index badc2cf..1479634 100644
+--- a/glx/glxcmds.c
++++ b/glx/glxcmds.c
+@@ -1990,7 +1990,8 @@ __glXDisp_Render(__GLXclientState * cl, GLbyte * pc)
+         if (entry.varsize) {
+             /* variable size command */
+             extra = (*entry.varsize) (pc + __GLX_RENDER_HDR_SIZE,
+-                                      client->swapped);
++                                      client->swapped,
++                                      left - __GLX_RENDER_HDR_SIZE);
+             if (extra < 0) {
+                 return BadLength;
+             }
+@@ -2067,6 +2068,7 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
+     if (cl->largeCmdRequestsSoFar == 0) {
+         __GLXrenderSizeData entry;
+         int extra = 0;
++        int left = (req->length << 2) - sz_xGLXRenderLargeReq;
+         size_t cmdlen;
+         int err;
+ 
+@@ -2107,7 +2109,8 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
+              ** will be in the 1st request, so it's okay to do this.
+              */
+             extra = (*entry.varsize) (pc + __GLX_RENDER_LARGE_HDR_SIZE,
+-                                      client->swapped);
++                                      client->swapped,
++                                      left - __GLX_RENDER_LARGE_HDR_SIZE);
+             if (extra < 0) {
+                 return BadLength;
+             }
+diff --git a/glx/glxserver.h b/glx/glxserver.h
+index 9bffcd8..ccb895e 100644
+--- a/glx/glxserver.h
++++ b/glx/glxserver.h
+@@ -167,7 +167,7 @@ typedef int (*__GLXprocPtr) (__GLXclientState *, char *pc);
+ /*
+  * Tables for computing the size of each rendering command.
+  */
+-typedef int (*gl_proto_size_func) (const GLbyte *, Bool);
++typedef int (*gl_proto_size_func) (const GLbyte *, Bool, int);
+ 
+ typedef struct {
+     int bytes;
+diff --git a/glx/indirect_reqsize.c b/glx/indirect_reqsize.c
+index 86ea970..ce58214 100644
+--- a/glx/indirect_reqsize.c
++++ b/glx/indirect_reqsize.c
+@@ -31,24 +31,22 @@
+ #include "indirect_size.h"
+ #include "indirect_reqsize.h"
+ 
+-#define __GLX_PAD(x)  (((x) + 3) & ~3)
+-
+ #if defined(__CYGWIN__) || defined(__MINGW32__)
+ #undef HAVE_ALIAS
+ #endif
+ #ifdef HAVE_ALIAS
+ #define ALIAS2(from,to) \
+-    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \
++    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap, int reqlen ) \
+         __attribute__ ((alias( # to )));
+ #define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )
+ #else
+ #define ALIAS(from,to) \
+-    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \
+-    { return __glX ## to ## ReqSize( pc, swap ); }
++    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap, int reqlen ) \
++    { return __glX ## to ## ReqSize( pc, swap, reqlen ); }
+ #endif
+ 
+ int
+-__glXCallListsReqSize(const GLbyte * pc, Bool swap)
++__glXCallListsReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 0);
+     GLenum type = *(GLenum *) (pc + 4);
+@@ -60,11 +58,11 @@ __glXCallListsReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glCallLists_size(type);
+-    return __GLX_PAD((compsize * n));
++    return safe_pad(safe_mul(compsize, n));
+ }
+ 
+ int
+-__glXBitmapReqSize(const GLbyte * pc, Bool swap)
++__glXBitmapReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -88,7 +86,7 @@ __glXBitmapReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXFogfvReqSize(const GLbyte * pc, Bool swap)
++__glXFogfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 0);
+     GLsizei compsize;
+@@ -98,11 +96,11 @@ __glXFogfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glFogfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXLightfvReqSize(const GLbyte * pc, Bool swap)
++__glXLightfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -112,11 +110,11 @@ __glXLightfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glLightfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXLightModelfvReqSize(const GLbyte * pc, Bool swap)
++__glXLightModelfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 0);
+     GLsizei compsize;
+@@ -126,11 +124,11 @@ __glXLightModelfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glLightModelfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXMaterialfvReqSize(const GLbyte * pc, Bool swap)
++__glXMaterialfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -140,11 +138,11 @@ __glXMaterialfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glMaterialfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXPolygonStippleReqSize(const GLbyte * pc, Bool swap)
++__glXPolygonStippleReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -164,7 +162,7 @@ __glXPolygonStippleReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXTexParameterfvReqSize(const GLbyte * pc, Bool swap)
++__glXTexParameterfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -174,11 +172,11 @@ __glXTexParameterfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glTexParameterfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXTexImage1DReqSize(const GLbyte * pc, Bool swap)
++__glXTexImage1DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -206,7 +204,7 @@ __glXTexImage1DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXTexImage2DReqSize(const GLbyte * pc, Bool swap)
++__glXTexImage2DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -236,7 +234,7 @@ __glXTexImage2DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXTexEnvfvReqSize(const GLbyte * pc, Bool swap)
++__glXTexEnvfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -246,11 +244,11 @@ __glXTexEnvfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glTexEnvfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXTexGendvReqSize(const GLbyte * pc, Bool swap)
++__glXTexGendvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -260,11 +258,11 @@ __glXTexGendvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glTexGendv_size(pname);
+-    return __GLX_PAD((compsize * 8));
++    return safe_pad(safe_mul(compsize, 8));
+ }
+ 
+ int
+-__glXTexGenfvReqSize(const GLbyte * pc, Bool swap)
++__glXTexGenfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -274,11 +272,11 @@ __glXTexGenfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glTexGenfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXPixelMapfvReqSize(const GLbyte * pc, Bool swap)
++__glXPixelMapfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei mapsize = *(GLsizei *) (pc + 4);
+ 
+@@ -286,11 +284,11 @@ __glXPixelMapfvReqSize(const GLbyte * pc, Bool swap)
+         mapsize = bswap_32(mapsize);
+     }
+ 
+-    return __GLX_PAD((mapsize * 4));
++    return safe_pad(safe_mul(mapsize, 4));
+ }
+ 
+ int
+-__glXPixelMapusvReqSize(const GLbyte * pc, Bool swap)
++__glXPixelMapusvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei mapsize = *(GLsizei *) (pc + 4);
+ 
+@@ -298,11 +296,11 @@ __glXPixelMapusvReqSize(const GLbyte * pc, Bool swap)
+         mapsize = bswap_32(mapsize);
+     }
+ 
+-    return __GLX_PAD((mapsize * 2));
++    return safe_pad(safe_mul(mapsize, 2));
+ }
+ 
+ int
+-__glXDrawPixelsReqSize(const GLbyte * pc, Bool swap)
++__glXDrawPixelsReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -330,7 +328,7 @@ __glXDrawPixelsReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXPrioritizeTexturesReqSize(const GLbyte * pc, Bool swap)
++__glXPrioritizeTexturesReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 0);
+ 
+@@ -338,11 +336,11 @@ __glXPrioritizeTexturesReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 4) + (n * 4));
++    return safe_pad(safe_add(safe_mul(n, 4), safe_mul(n, 4)));
+ }
+ 
+ int
+-__glXTexSubImage1DReqSize(const GLbyte * pc, Bool swap)
++__glXTexSubImage1DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -370,7 +368,7 @@ __glXTexSubImage1DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXTexSubImage2DReqSize(const GLbyte * pc, Bool swap)
++__glXTexSubImage2DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -400,7 +398,7 @@ __glXTexSubImage2DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXColorTableReqSize(const GLbyte * pc, Bool swap)
++__glXColorTableReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -428,7 +426,7 @@ __glXColorTableReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXColorTableParameterfvReqSize(const GLbyte * pc, Bool swap)
++__glXColorTableParameterfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -438,11 +436,11 @@ __glXColorTableParameterfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glColorTableParameterfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXColorSubTableReqSize(const GLbyte * pc, Bool swap)
++__glXColorSubTableReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -470,7 +468,7 @@ __glXColorSubTableReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXConvolutionFilter1DReqSize(const GLbyte * pc, Bool swap)
++__glXConvolutionFilter1DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -498,7 +496,7 @@ __glXConvolutionFilter1DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXConvolutionFilter2DReqSize(const GLbyte * pc, Bool swap)
++__glXConvolutionFilter2DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = 0;
+@@ -528,7 +526,7 @@ __glXConvolutionFilter2DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXConvolutionParameterfvReqSize(const GLbyte * pc, Bool swap)
++__glXConvolutionParameterfvReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 4);
+     GLsizei compsize;
+@@ -538,11 +536,11 @@ __glXConvolutionParameterfvReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glConvolutionParameterfv_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXTexImage3DReqSize(const GLbyte * pc, Bool swap)
++__glXTexImage3DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = *(GLint *) (pc + 8);
+@@ -579,7 +577,7 @@ __glXTexImage3DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXTexSubImage3DReqSize(const GLbyte * pc, Bool swap)
++__glXTexSubImage3DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLint row_length = *(GLint *) (pc + 4);
+     GLint image_height = *(GLint *) (pc + 8);
+@@ -613,7 +611,7 @@ __glXTexSubImage3DReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXCompressedTexImage1DARBReqSize(const GLbyte * pc, Bool swap)
++__glXCompressedTexImage1DARBReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei imageSize = *(GLsizei *) (pc + 20);
+ 
+@@ -621,11 +619,11 @@ __glXCompressedTexImage1DARBReqSize(const GLbyte * pc, Bool swap)
+         imageSize = bswap_32(imageSize);
+     }
+ 
+-    return __GLX_PAD(imageSize);
++    return safe_pad(imageSize);
+ }
+ 
+ int
+-__glXCompressedTexImage2DARBReqSize(const GLbyte * pc, Bool swap)
++__glXCompressedTexImage2DARBReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei imageSize = *(GLsizei *) (pc + 24);
+ 
+@@ -633,11 +631,11 @@ __glXCompressedTexImage2DARBReqSize(const GLbyte * pc, Bool swap)
+         imageSize = bswap_32(imageSize);
+     }
+ 
+-    return __GLX_PAD(imageSize);
++    return safe_pad(imageSize);
+ }
+ 
+ int
+-__glXCompressedTexImage3DARBReqSize(const GLbyte * pc, Bool swap)
++__glXCompressedTexImage3DARBReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei imageSize = *(GLsizei *) (pc + 28);
+ 
+@@ -645,11 +643,11 @@ __glXCompressedTexImage3DARBReqSize(const GLbyte * pc, Bool swap)
+         imageSize = bswap_32(imageSize);
+     }
+ 
+-    return __GLX_PAD(imageSize);
++    return safe_pad(imageSize);
+ }
+ 
+ int
+-__glXCompressedTexSubImage3DARBReqSize(const GLbyte * pc, Bool swap)
++__glXCompressedTexSubImage3DARBReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei imageSize = *(GLsizei *) (pc + 36);
+ 
+@@ -657,11 +655,11 @@ __glXCompressedTexSubImage3DARBReqSize(const GLbyte * pc, Bool swap)
+         imageSize = bswap_32(imageSize);
+     }
+ 
+-    return __GLX_PAD(imageSize);
++    return safe_pad(imageSize);
+ }
+ 
+ int
+-__glXProgramStringARBReqSize(const GLbyte * pc, Bool swap)
++__glXProgramStringARBReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei len = *(GLsizei *) (pc + 8);
+ 
+@@ -669,11 +667,11 @@ __glXProgramStringARBReqSize(const GLbyte * pc, Bool swap)
+         len = bswap_32(len);
+     }
+ 
+-    return __GLX_PAD(len);
++    return safe_pad(len);
+ }
+ 
+ int
+-__glXDrawBuffersARBReqSize(const GLbyte * pc, Bool swap)
++__glXDrawBuffersARBReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 0);
+ 
+@@ -681,11 +679,11 @@ __glXDrawBuffersARBReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 4));
++    return safe_pad(safe_mul(n, 4));
+ }
+ 
+ int
+-__glXPointParameterfvEXTReqSize(const GLbyte * pc, Bool swap)
++__glXPointParameterfvEXTReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum pname = *(GLenum *) (pc + 0);
+     GLsizei compsize;
+@@ -695,11 +693,11 @@ __glXPointParameterfvEXTReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     compsize = __glPointParameterfvEXT_size(pname);
+-    return __GLX_PAD((compsize * 4));
++    return safe_pad(safe_mul(compsize, 4));
+ }
+ 
+ int
+-__glXProgramParameters4dvNVReqSize(const GLbyte * pc, Bool swap)
++__glXProgramParameters4dvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei num = *(GLsizei *) (pc + 8);
+ 
+@@ -707,11 +705,11 @@ __glXProgramParameters4dvNVReqSize(const GLbyte * pc, Bool swap)
+         num = bswap_32(num);
+     }
+ 
+-    return __GLX_PAD((num * 32));
++    return safe_pad(safe_mul(num, 32));
+ }
+ 
+ int
+-__glXProgramParameters4fvNVReqSize(const GLbyte * pc, Bool swap)
++__glXProgramParameters4fvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei num = *(GLsizei *) (pc + 8);
+ 
+@@ -719,11 +717,11 @@ __glXProgramParameters4fvNVReqSize(const GLbyte * pc, Bool swap)
+         num = bswap_32(num);
+     }
+ 
+-    return __GLX_PAD((num * 16));
++    return safe_pad(safe_mul(num, 16));
+ }
+ 
+ int
+-__glXVertexAttribs1dvNVReqSize(const GLbyte * pc, Bool swap)
++__glXVertexAttribs1dvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 4);
+ 
+@@ -731,11 +729,11 @@ __glXVertexAttribs1dvNVReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 8));
++    return safe_pad(safe_mul(n, 8));
+ }
+ 
+ int
+-__glXVertexAttribs2dvNVReqSize(const GLbyte * pc, Bool swap)
++__glXVertexAttribs2dvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 4);
+ 
+@@ -743,11 +741,11 @@ __glXVertexAttribs2dvNVReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 16));
++    return safe_pad(safe_mul(n, 16));
+ }
+ 
+ int
+-__glXVertexAttribs3dvNVReqSize(const GLbyte * pc, Bool swap)
++__glXVertexAttribs3dvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 4);
+ 
+@@ -755,11 +753,11 @@ __glXVertexAttribs3dvNVReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 24));
++    return safe_pad(safe_mul(n, 24));
+ }
+ 
+ int
+-__glXVertexAttribs3fvNVReqSize(const GLbyte * pc, Bool swap)
++__glXVertexAttribs3fvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 4);
+ 
+@@ -767,11 +765,11 @@ __glXVertexAttribs3fvNVReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 12));
++    return safe_pad(safe_mul(n, 12));
+ }
+ 
+ int
+-__glXVertexAttribs3svNVReqSize(const GLbyte * pc, Bool swap)
++__glXVertexAttribs3svNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 4);
+ 
+@@ -779,11 +777,11 @@ __glXVertexAttribs3svNVReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 6));
++    return safe_pad(safe_mul(n, 6));
+ }
+ 
+ int
+-__glXVertexAttribs4dvNVReqSize(const GLbyte * pc, Bool swap)
++__glXVertexAttribs4dvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei n = *(GLsizei *) (pc + 4);
+ 
+@@ -791,11 +789,11 @@ __glXVertexAttribs4dvNVReqSize(const GLbyte * pc, Bool swap)
+         n = bswap_32(n);
+     }
+ 
+-    return __GLX_PAD((n * 32));
++    return safe_pad(safe_mul(n, 32));
+ }
+ 
+ int
+-__glXProgramNamedParameter4fvNVReqSize(const GLbyte * pc, Bool swap)
++__glXProgramNamedParameter4fvNVReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLsizei len = *(GLsizei *) (pc + 4);
+ 
+@@ -803,7 +801,7 @@ __glXProgramNamedParameter4fvNVReqSize(const GLbyte * pc, Bool swap)
+         len = bswap_32(len);
+     }
+ 
+-    return __GLX_PAD(len);
++    return safe_pad(len);
+ }
+ 
+ ALIAS(Fogiv, Fogfv)
+diff --git a/glx/indirect_reqsize.h b/glx/indirect_reqsize.h
+index d2c1da7..22e1350 100644
+--- a/glx/indirect_reqsize.h
++++ b/glx/indirect_reqsize.h
+@@ -36,128 +36,128 @@
+ #define PURE
+ #endif
+ 
+-extern PURE _X_HIDDEN int __glXCallListsReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXBitmapReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXFogfvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXFogivReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXLightfvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXLightivReqSize(const GLbyte * pc, Bool swap);
++extern PURE _X_HIDDEN int __glXCallListsReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXBitmapReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXFogfvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXFogivReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXLightfvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXLightivReqSize(const GLbyte * pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXLightModelfvReqSize(const GLbyte * pc,
+-                                                   Bool swap);
++                                                   Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXLightModelivReqSize(const GLbyte * pc,
+-                                                   Bool swap);
+-extern PURE _X_HIDDEN int __glXMaterialfvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXMaterialivReqSize(const GLbyte * pc, Bool swap);
++                                                   Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXMaterialfvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXMaterialivReqSize(const GLbyte * pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXPolygonStippleReqSize(const GLbyte * pc,
+-                                                     Bool swap);
++                                                     Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXTexParameterfvReqSize(const GLbyte * pc,
+-                                                     Bool swap);
++                                                     Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXTexParameterivReqSize(const GLbyte * pc,
+-                                                     Bool swap);
+-extern PURE _X_HIDDEN int __glXTexImage1DReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXTexImage2DReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXTexEnvfvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXTexEnvivReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXTexGendvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXTexGenfvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXTexGenivReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXMap1dReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXMap1fReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXMap2dReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXMap2fReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXPixelMapfvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXPixelMapuivReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXPixelMapusvReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXDrawPixelsReqSize(const GLbyte * pc, Bool swap);
+-extern PURE _X_HIDDEN int __glXDrawArraysReqSize(const GLbyte * pc, Bool swap);
++                                                     Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexImage1DReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexImage2DReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexEnvfvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexEnvivReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexGendvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexGenfvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexGenivReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXMap1dReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXMap1fReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXMap2dReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXMap2fReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXPixelMapfvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXPixelMapuivReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXPixelMapusvReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXDrawPixelsReqSize(const GLbyte * pc, Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXDrawArraysReqSize(const GLbyte * pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXPrioritizeTexturesReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXTexSubImage1DReqSize(const GLbyte * pc,
+-                                                    Bool swap);
++                                                    Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXTexSubImage2DReqSize(const GLbyte * pc,
+-                                                    Bool swap);
+-extern PURE _X_HIDDEN int __glXColorTableReqSize(const GLbyte * pc, Bool swap);
++                                                    Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXColorTableReqSize(const GLbyte * pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXColorTableParameterfvReqSize(const GLbyte * pc,
+-                                                            Bool swap);
++                                                            Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXColorTableParameterivReqSize(const GLbyte * pc,
+-                                                            Bool swap);
++                                                            Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXColorSubTableReqSize(const GLbyte * pc,
+-                                                    Bool swap);
++                                                    Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXConvolutionFilter1DReqSize(const GLbyte * pc,
+-                                                          Bool swap);
++                                                          Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXConvolutionFilter2DReqSize(const GLbyte * pc,
+-                                                          Bool swap);
++                                                          Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXConvolutionParameterfvReqSize(const GLbyte * pc,
+-                                                             Bool swap);
++                                                             Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXConvolutionParameterivReqSize(const GLbyte * pc,
+-                                                             Bool swap);
++                                                             Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXSeparableFilter2DReqSize(const GLbyte * pc,
+-                                                        Bool swap);
+-extern PURE _X_HIDDEN int __glXTexImage3DReqSize(const GLbyte * pc, Bool swap);
++                                                        Bool swap, int reqlen);
++extern PURE _X_HIDDEN int __glXTexImage3DReqSize(const GLbyte * pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXTexSubImage3DReqSize(const GLbyte * pc,
+-                                                    Bool swap);
++                                                    Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXCompressedTexImage1DARBReqSize(const GLbyte * pc,
+-                                                              Bool swap);
++                                                              Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXCompressedTexImage2DARBReqSize(const GLbyte * pc,
+-                                                              Bool swap);
++                                                              Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXCompressedTexImage3DARBReqSize(const GLbyte * pc,
+-                                                              Bool swap);
++                                                              Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXCompressedTexSubImage1DARBReqSize(const GLbyte *
+-                                                                 pc, Bool swap);
++                                                                 pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXCompressedTexSubImage2DARBReqSize(const GLbyte *
+-                                                                 pc, Bool swap);
++                                                                 pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXCompressedTexSubImage3DARBReqSize(const GLbyte *
+-                                                                 pc, Bool swap);
++                                                                 pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXProgramStringARBReqSize(const GLbyte * pc,
+-                                                       Bool swap);
++                                                       Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXDrawBuffersARBReqSize(const GLbyte * pc,
+-                                                     Bool swap);
++                                                     Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXPointParameterfvEXTReqSize(const GLbyte * pc,
+-                                                          Bool swap);
++                                                          Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXLoadProgramNVReqSize(const GLbyte * pc,
+-                                                    Bool swap);
++                                                    Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXProgramParameters4dvNVReqSize(const GLbyte * pc,
+-                                                             Bool swap);
++                                                             Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXProgramParameters4fvNVReqSize(const GLbyte * pc,
+-                                                             Bool swap);
++                                                             Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXRequestResidentProgramsNVReqSize(const GLbyte *
+-                                                                pc, Bool swap);
++                                                                pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs1dvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs1fvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs1svNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs2dvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs2fvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs2svNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs3dvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs3fvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs3svNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs4dvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs4fvNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs4svNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXVertexAttribs4ubvNVReqSize(const GLbyte * pc,
+-                                                          Bool swap);
++                                                          Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXPointParameterivNVReqSize(const GLbyte * pc,
+-                                                         Bool swap);
++                                                         Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXProgramNamedParameter4dvNVReqSize(const GLbyte *
+-                                                                 pc, Bool swap);
++                                                                 pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXProgramNamedParameter4fvNVReqSize(const GLbyte *
+-                                                                 pc, Bool swap);
++                                                                 pc, Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXDeleteFramebuffersEXTReqSize(const GLbyte * pc,
+-                                                            Bool swap);
++                                                            Bool swap, int reqlen);
+ extern PURE _X_HIDDEN int __glXDeleteRenderbuffersEXTReqSize(const GLbyte * pc,
+-                                                             Bool swap);
++                                                             Bool swap, int reqlen);
+ 
+ #undef PURE
+ 
+diff --git a/glx/rensize.c b/glx/rensize.c
+index 6ee0f9c..a532467 100644
+--- a/glx/rensize.c
++++ b/glx/rensize.c
+@@ -44,7 +44,7 @@
+    ((a & 0xff00U)<<8) | ((a & 0xffU)<<24))
+ 
+ int
+-__glXMap1dReqSize(const GLbyte * pc, Bool swap)
++__glXMap1dReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum target;
+     GLint order;
+@@ -61,7 +61,7 @@ __glXMap1dReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXMap1fReqSize(const GLbyte * pc, Bool swap)
++__glXMap1fReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum target;
+     GLint order;
+@@ -86,7 +86,7 @@ Map2Size(int k, int majorOrder, int minorOrder)
+ }
+ 
+ int
+-__glXMap2dReqSize(const GLbyte * pc, Bool swap)
++__glXMap2dReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum target;
+     GLint uorder, vorder;
+@@ -103,7 +103,7 @@ __glXMap2dReqSize(const GLbyte * pc, Bool swap)
+ }
+ 
+ int
+-__glXMap2fReqSize(const GLbyte * pc, Bool swap)
++__glXMap2fReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     GLenum target;
+     GLint uorder, vorder;
+@@ -359,13 +359,14 @@ __glXTypeSize(GLenum enm)
+ }
+ 
+ int
+-__glXDrawArraysReqSize(const GLbyte * pc, Bool swap)
++__glXDrawArraysReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc;
+     __GLXdispatchDrawArraysComponentHeader *compHeader;
+     GLint numVertexes = hdr->numVertexes;
+     GLint numComponents = hdr->numComponents;
+     GLint arrayElementSize = 0;
++    GLint x, size;
+     int i;
+ 
+     if (swap) {
+@@ -374,6 +375,13 @@ __glXDrawArraysReqSize(const GLbyte * pc, Bool swap)
+     }
+ 
+     pc += sizeof(__GLXdispatchDrawArraysHeader);
++    reqlen -= sizeof(__GLXdispatchDrawArraysHeader);
++
++    size = safe_mul(sizeof(__GLXdispatchDrawArraysComponentHeader),
++                    numComponents);
++    if (size < 0 || reqlen < 0 || reqlen < size)
++        return -1;
++
+     compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
+ 
+     for (i = 0; i < numComponents; i++) {
+@@ -417,17 +425,18 @@ __glXDrawArraysReqSize(const GLbyte * pc, Bool swap)
+             return -1;
+         }
+ 
+-        arrayElementSize += __GLX_PAD(numVals * __glXTypeSize(datatype));
++        x = safe_pad(safe_mul(numVals, __glXTypeSize(datatype)));
++        if ((arrayElementSize = safe_add(arrayElementSize, x)) < 0)
++            return -1;
+ 
+         pc += sizeof(__GLXdispatchDrawArraysComponentHeader);
+     }
+ 
+-    return ((numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader)) +
+-            (numVertexes * arrayElementSize));
++    return safe_add(size, safe_mul(numVertexes, arrayElementSize));
+ }
+ 
+ int
+-__glXSeparableFilter2DReqSize(const GLbyte * pc, Bool swap)
++__glXSeparableFilter2DReqSize(const GLbyte * pc, Bool swap, int reqlen)
+ {
+     __GLXdispatchConvolutionFilterHeader *hdr =
+         (__GLXdispatchConvolutionFilterHeader *) pc;
+diff --git a/include/dix.h b/include/dix.h
+index ea9d2cc..b48d828 100644
+--- a/include/dix.h
++++ b/include/dix.h
+@@ -72,6 +72,10 @@ SOFTWARE.
+     if ((sizeof(req) >> 2) > client->req_len )\
+          return(BadLength)
+ 
++#define REQUEST_AT_LEAST_EXTRA_SIZE(req, extra)  \
++    if (((sizeof(req) + ((uint64_t) extra)) >> 2) > client->req_len ) \
++         return(BadLength)
++
+ #define REQUEST_FIXED_SIZE(req, n)\
+     if (((sizeof(req) >> 2) > client->req_len) || \
+         ((n >> 2) >= client->req_len) || \
+diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
+index ff9aec5..25eb6e9 100644
+--- a/test/xi2/protocol-xipassivegrabdevice.c
++++ b/test/xi2/protocol-xipassivegrabdevice.c
+@@ -136,6 +136,7 @@ request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req,
+ {
+     int rc;
+     int modifiers;
++    int mask_len;
+ 
+     client_request.req_len = req->length;
+     rc = ProcXIPassiveGrabDevice(&client_request);
+@@ -153,10 +154,11 @@ request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req,
+     swaps(&req->deviceid);
+     modifiers = req->num_modifiers;
+     swaps(&req->num_modifiers);
++    mask_len = req->mask_len;
+     swaps(&req->mask_len);
+ 
+     while (modifiers--) {
+-        CARD32 *mod = ((CARD32 *) (req + 1)) + modifiers;
++        CARD32 *mod = (CARD32 *) (req + 1) + mask_len + modifiers;
+ 
+         swapl(mod);
+     }
+@@ -235,6 +237,11 @@ test_XIPassiveGrabDevice(void)
+     request->detail = XIAnyButton;
+     request_XIPassiveGrabDevice(&client_request, request, Success, 0);
+ 
++    /* Set a few random masks to make sure we handle modifiers correctly */
++    SetBit(mask, XI_ButtonPress);
++    SetBit(mask, XI_KeyPress);
++    SetBit(mask, XI_Enter);
++
+     /* some modifiers */
+     request->num_modifiers = N_MODS;
+     request->length += N_MODS;
diff --git a/contrib/packages/rpm/el5/SOURCES/17_CVE-regressions.diff b/contrib/packages/rpm/el5/SOURCES/17_CVE-regressions.diff
new file mode 100644
index 0000000..c274d14
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/17_CVE-regressions.diff
@@ -0,0 +1,26 @@
+diff --git a/include/dix.h b/include/dix.h
+index 21176a8..921156b 100644
+--- a/include/dix.h
++++ b/include/dix.h
+@@ -80,7 +80,7 @@ SOFTWARE.
+ 
+ #define REQUEST_FIXED_SIZE(req, n)\
+     if (((sizeof(req) >> 2) > client->req_len) || \
+-        ((n >> 2) >= client->req_len) || \
++        (((n) >> 2) >= client->req_len) ||                              \
+         ((((uint64_t) sizeof(req) + (n) + 3) >> 2) != (uint64_t) client->req_len))  \
+          return(BadLength)
+ 
+diff --git a/os/access.c b/os/access.c
+index f393c8d..28f2d32 100644
+--- a/os/access.c
++++ b/os/access.c
+@@ -1308,7 +1308,7 @@ GetHosts(void **data, int *pnHosts, int *pLen, BOOL * pEnabled)
+         }
+         for (host = validhosts; host; host = host->next) {
+             len = host->len;
+-            if ((ptr + sizeof(xHostEntry) + len) > (data + n))
++            if ((ptr + sizeof(xHostEntry) + len) > ((unsigned char *) *data + n))
+                 break;
+             ((xHostEntry *) ptr)->family = host->family;
+             ((xHostEntry *) ptr)->length = len;
diff --git a/contrib/packages/rpm/el5/SOURCES/25-no-hint-fedora.conf b/contrib/packages/rpm/el5/SOURCES/25-no-hint-fedora.conf
deleted file mode 100644
index 9c71eb0..0000000
--- a/contrib/packages/rpm/el5/SOURCES/25-no-hint-fedora.conf
+++ /dev/null
@@ -1,243 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-
-<fontconfig>
-
-<!-- We can't hint CJK fonts well, so turn off hinting for CJK fonts. -->
-
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Kochi Mincho</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-		<edit name="embeddedbitmap" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Kochi Gothic</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-		<edit name="embeddedbitmap" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Sazanami Mincho</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-		<edit name="embeddedbitmap" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Sazanami Gothic</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-		<edit name="embeddedbitmap" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Baekmuk Batang</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Baekmuk Dotum</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Baekmuk Gulim</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Baekmuk Headline</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>AR PL Mingti2L Big5</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-        <match target="font">
-                <test name="family" compare="eq">
-                        <string>AR PL ShanHeiSun Uni</string>
-                </test>
-                <edit name="hinting" mode="assign">
-                        <bool>false</bool>
-                </edit>
-                <edit name="embeddedbitmap" mode="assign">
-                        <bool>true</bool>
-                </edit>
-        </match>
-        <match target="font">
-                <test name="family" compare="eq">
-                        <string>AR PL KaitiM Big5</string>
-                </test>
-                <edit name="hinting" mode="assign">
-                        <bool>false</bool>
-                </edit>
-        </match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>AR PL ZenKai Uni</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>AR PL SungtiL GB</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>AR PL KaitiM GB</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>ZYSong18030</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-
- <!-- 
- We also need to turn off hinting for Indic fonts with a joined baseline.
- -->
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Mukti Narrow</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Lohit Hindi</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Lohit Bengali</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Lohit Punjabi</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-
-<!--
-Gujarti fonts are distorted when hinting is enabled. Turn it off.
--->
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>Lohit Gujarati</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-
-<!--
-Disabling hinting for newly added Indic fonts (kn/or/ml/te)
--->
-        <match target="font">
-                <test name="family" compare="eq">
-                        <string>Lohit Kannada</string>
-                </test>
-                <edit name="hinting" mode="assign">
-                        <bool>false</bool>
-                </edit>
-        </match>
-
-        <match target="font">
-                <test name="family" compare="eq">
-                        <string>Lohit Oriya</string>
-                </test>
-                <edit name="hinting" mode="assign">
-                        <bool>false</bool>
-                </edit>
-        </match>
-
-        <match target="font">
-                <test name="family" compare="eq">
-                        <string>Lohit Malayalam</string>
-                </test>
-                <edit name="hinting" mode="assign">
-                        <bool>false</bool>
-                </edit>
-        </match>
-
-        <match target="font">
-                <test name="family" compare="eq">
-                        <string>Lohit Telugu</string>
-                </test>
-                <edit name="hinting" mode="assign">
-                        <bool>false</bool>
-                </edit>
-        </match>
-
-<!--
-And Sinhala
--->
-	<match target="font">
-		<test name="family" compare="eq">
-			<string>LKLUG</string>
-		</test>
-		<edit name="hinting" mode="assign">
-			<bool>false</bool>
-		</edit>
-	</match>
-
-</fontconfig>
diff --git a/contrib/packages/rpm/el5/SOURCES/30-aliases-fedora.conf b/contrib/packages/rpm/el5/SOURCES/30-aliases-fedora.conf
deleted file mode 100644
index 28cd157..0000000
--- a/contrib/packages/rpm/el5/SOURCES/30-aliases-fedora.conf
+++ /dev/null
@@ -1,180 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-<!-- conf.d/sub-pixel.conf -->
-<fontconfig>
-
-	<!-- Alias similar families from 5 sources:
-
-		PostScript fonts:
-			Helvetica
-			Times
-			Courier
-		Microsoft fonts:
-			Arial
-			Times New Roman
-			Courier New
-		URW fonts:
-			Nimbus Sans L
-			Nimbus Roman No9 L
-			Nimbus Mono L
-		StarOffice fonts:
-			Albany
-			Thorndale
-			Cumberland
-		AMT fonts:
-			Albany AMT
-			Thorndale AMT
-			Cumberland AMT
-
-	     Of these, URW fonts are metric compatible with PostScrict fonts
-	     and the StarOffice and AMT ones are compatible with Microsoft
-	     fonts.  We want for each of them to fallback to any of these
-	     available, but in an order preferring the metric-compatible ones
-	     first.  As an exception, we assume that URW fonts are always
-	     available and do not alias them.
-
-	     It seems to be really hard to do this with fontconfig.  The
-	     easiest way seems to be to list them all for each one.
-	-->
-
-	<!-- PostScript -->
-        <alias>
-	  <family>Helvetica</family>
-	  <accept>
-	  <family>Nimbus Sans L</family>
-          <family>Liberation Sans</family>
-	  <family>Arial</family>
-	  <family>Albany</family>
-	  <family>Albany AMT</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Times</family>
-	  <accept>
-	  <family>Nimbus Roman No9 L</family>
-          <family>Liberation Serif</family>
-	  <family>Times New Roman</family>
-	  <family>Thorndale</family>
-	  <family>Thorndale AMT</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Courier</family>
-	  <accept>
-	  <family>Nimbus Mono L</family>
-          <family>Liberation Mono</family>
-	  <family>Courier New</family>
-	  <family>Cumberland</family>
-	  <family>Cumberland AMT</family>
-	  </accept>
-	</alias>
-
-
-
-	<!-- Microsoft -->
-        <alias>
-	  <family>Arial</family>
-	  <accept>
-          <family>Liberation Sans</family>
-	  <family>Albany</family>
-	  <family>Albany AMT</family>
-	  <family>Helvetica</family>
-	  <family>Nimbus Sans L</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Times New Roman</family>
-	  <accept>
-          <family>Liberation Serif</family>
-	  <family>Thorndale</family>
-	  <family>Thorndale AMT</family>
-	  <family>Times</family>
-	  <family>Nimbus Roman No9 L</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Courier New</family>
-	  <accept>
-          <family>Liberation Mono</family>
-	  <family>Cumberland</family>
-	  <family>Cumberland AMT</family>
-	  <family>Courier</family>
-	  <family>Nimbus Mono L</family>
-	  </accept>
-	</alias>
-
-
-	<!-- StarOffice -->
-        <alias>
-	  <family>Albany</family>
-	  <accept>
-          <family>Liberation Sans</family>
-	  <family>Arial</family>
-	  <family>Albany AMT</family>
-	  <family>Helvetica</family>
-	  <family>Nimbus Sans L</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Thorndale</family>
-	  <accept>
-          <family>Liberation Serif</family>
-	  <family>Times New Roman</family>
-	  <family>Thorndale AMT</family>
-	  <family>Times</family>
-	  <family>Nimbus Roman No9 L</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Cumberland</family>
-	  <accept>
-          <family>Liberation Mono</family>
-	  <family>Courier New</family>
-	  <family>Cumberland AMT</family>
-	  <family>Courier</family>
-	  <family>Nimbus Mono L</family>
-	  </accept>
-	</alias>
-
-
-	<!-- AMT -->
-        <alias>
-	  <family>Albany AMT</family>
-	  <accept>
-          <family>Liberation Sans</family>
-	  <family>Arial</family>
-	  <family>Albany</family>
-	  <family>Helvetica</family>
-	  <family>Nimbus Sans L</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Thorndale AMT</family>
-	  <accept>
-          <family>Liberation Serif</family>
-	  <family>Times New Roman</family>
-	  <family>Thorndale</family>
-	  <family>Times</family>
-	  <family>Nimbus Roman No9 L</family>
-	  </accept>
-	</alias>
-
-        <alias>
-	  <family>Cumberland AMT</family>
-	  <accept>
-          <family>Liberation Mono</family>
-	  <family>Courier New</family>
-	  <family>Cumberland</family>
-	  <family>Courier</family>
-	  <family>Nimbus Mono L</family>
-	  </accept>
-	</alias>
-
-</fontconfig>
diff --git a/contrib/packages/rpm/el5/SOURCES/40-generic-fedora.conf b/contrib/packages/rpm/el5/SOURCES/40-generic-fedora.conf
deleted file mode 100644
index c0e720b..0000000
--- a/contrib/packages/rpm/el5/SOURCES/40-generic-fedora.conf
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-<fontconfig>
-<!--
-  Mark families with their generics so we'll get
-  something reasonable
--->
-
-<!--
-  Serif faces
- -->
-	<alias>
-                <family>Sazanami Mincho</family>
-                <family>AR PL ZenKai Uni</family>
-		<family>ZYSong18030</family>
-		<default><family>serif</family></default>
-	</alias>
-<!--
-  Sans-serif faces
- -->
-	<alias>
-                <family>Sazanami Gothic</family>
-                <family>AR PL ShanHeiSun Uni</family>
-		<family>ZYSong18030</family>
-		<default><family>sans-serif</family></default>
-	</alias>
-<!--
-  Monospace faces
- -->
- 	<alias>
-		<family>Cumberland</family>
-		<family>ZYSong18030</family>
-		<default><family>monospace</family></default>
-	</alias>
-</fontconfig>
diff --git a/contrib/packages/rpm/el5/SOURCES/64-nonlatin-fedora.conf b/contrib/packages/rpm/el5/SOURCES/64-nonlatin-fedora.conf
deleted file mode 100644
index be29084..0000000
--- a/contrib/packages/rpm/el5/SOURCES/64-nonlatin-fedora.conf
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-<fontconfig>
-	<alias>
-		<family>serif</family>
-		<prefer>
- 			<family>KacstQura</family>
- 			<family>Frank Ruehl CLM</family>
-			<family>Lohit Bengali</family>
- 			<family>Lohit Gujarati</family>
- 			<family>Lohit Hindi</family>
- 			<family>Lohit Punjabi</family>
- 			<family>Lohit Tamil</family>
- 			<family>Lohit Malayalam</family>
- 			<family>Lohit Kannada</family>
- 			<family>Lohit Telugu</family>
- 			<family>Lohit Oriya</family>
- 			<family>LKLUG</family>
- 			<family>Sazanami Mincho</family>
- 			<family>AR PL Zenkai Uni</family>
- 			<family>ZYSong18030</family>
-		</prefer>
-	</alias>
-	<alias>
-		<family>sans-serif</family>
-		<prefer>
- 			<family>KacstQura</family>
-			<family>Lohit Bengali</family>
- 			<family>Lohit Gujarati</family>
- 			<family>Lohit Hindi</family>
- 			<family>Lohit Punjabi</family>
- 			<family>Lohit Tamil</family>
- 			<family>Lohit Malayalam</family>
- 			<family>Lohit Kannada</family>
- 			<family>Lohit Telugu</family>
- 			<family>Lohit Oriya</family>
- 			<family>LKLUG</family>
- 			<family>Sazanami Gothic</family>
- 			<family>AR PL ShanHeiSun Uni</family>
- 			<family>AR PL SungtiL GB</family>
- 			<family>AR PL Mingti2L Big5</family>
-			<family>ZYSong18030</family>
- 			<family>Baekmuk Gulim</family>
-		</prefer>
-	</alias>
-	<alias>
-		<family>monospace</family>
-		<prefer>
-			<family>Lohit Bengali</family>
-			<family>Lohit Gujarati</family>
-			<family>Lohit Hindi</family>
-			<family>Lohit Punjabi</family>
- 			<family>Lohit Tamil</family>
- 			<family>Lohit Malayalam</family>
- 			<family>Lohit Kannada</family>
- 			<family>Lohit Telugu</family>
- 			<family>Lohit Oriya</family>
- 			<family>LKLUG</family>
-			<family>Sazanami Gothic</family>
- 			<family>AR PL ShanHeiSun Uni</family>
-			<family>AR PL SungtiL GB</family>
-			<family>AR PL Mingti2L Big5</family>
-			<family>ZYSong18030</family>
-			<family>Baekmuk Gulim</family>
-		</prefer>
-	</alias>
-</fontconfig>
diff --git a/contrib/packages/rpm/el5/SOURCES/75-blacklist-fedora.conf b/contrib/packages/rpm/el5/SOURCES/75-blacklist-fedora.conf
deleted file mode 100644
index 996c17a..0000000
--- a/contrib/packages/rpm/el5/SOURCES/75-blacklist-fedora.conf
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-
-<!-- Blacklist certain fonts that freetype can't handle -->
-
-<fontconfig>
-  <selectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Gothic-English</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Plain-Duplex-Italic</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Plain-Duplex</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Script-Simplex</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Plain-Triplex</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Plain-Triplex-Italic</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Script-Complex</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Gothic-Italian</string></patelt>
-      </pattern>
-    </rejectfont>
-    <rejectfont>
-      <pattern>
-        <patelt name="family"><string>Hershey-Gothic-German</string></patelt>
-      </pattern>
-    </rejectfont>
-  </selectfont>
-</fontconfig>
diff --git a/contrib/packages/rpm/el5/SOURCES/FindX11.cmake b/contrib/packages/rpm/el5/SOURCES/FindX11.cmake
index 86335fc..21cb732 100644
--- a/contrib/packages/rpm/el5/SOURCES/FindX11.cmake
+++ b/contrib/packages/rpm/el5/SOURCES/FindX11.cmake
@@ -60,27 +60,26 @@
   # found in tcl on the mac
   set(CMAKE_FIND_FRAMEWORK_SAVE ${CMAKE_FIND_FRAMEWORK})
   set(CMAKE_FIND_FRAMEWORK NEVER)
-  if(NOT X11_INC_SEARCH_PATH)
-    set(X11_INC_SEARCH_PATH
-      /usr/pkg/xorg/include
-      /usr/X11R6/include
-      /usr/X11R7/include
-      /usr/include/X11
-      /usr/openwin/include
-      /usr/openwin/share/include
-      /opt/graphics/OpenGL/include
-    )
-  endif()
+  set(X11_INC_SEARCH_PATH
+    @_includedir@
+    /usr/pkg/xorg/include
+    /usr/X11R6/include
+    /usr/X11R7/include
+    /usr/include/X11
+    /usr/openwin/include
+    /usr/openwin/share/include
+    /opt/graphics/OpenGL/include
+  )
 
 
-  if(NOT X11_LIB_SEARCH_PATH)
-    set(X11_LIB_SEARCH_PATH
-      /usr/pkg/xorg/lib
-      /usr/X11R6/lib
-      /usr/X11R7/lib
-      /usr/openwin/lib
-    )
-  endif()
+  set(X11_LIB_SEARCH_PATH
+    @_libdir@
+    @_libdir@/tigervnc
+    /usr/pkg/xorg/lib
+    /usr/X11R6/lib
+    /usr/X11R7/lib
+    /usr/openwin/lib
+  )
 
   find_path(X11_X11_INCLUDE_PATH X11/X.h                             ${X11_INC_SEARCH_PATH})
   find_path(X11_Xlib_INCLUDE_PATH X11/Xlib.h                         ${X11_INC_SEARCH_PATH})
@@ -122,6 +121,7 @@
   find_path(X11_Xt_INCLUDE_PATH X11/Intrinsic.h                      ${X11_INC_SEARCH_PATH})
   find_path(X11_Xv_INCLUDE_PATH X11/extensions/Xvlib.h               ${X11_INC_SEARCH_PATH})
   find_path(X11_XSync_INCLUDE_PATH X11/extensions/sync.h             ${X11_INC_SEARCH_PATH})
+  find_path(X11_xcb_INCLUDE_PATH X11/xcb.h                           ${X11_INC_SEARCH_PATH})
 
 
   find_library(X11_X11_LIB X11               ${X11_LIB_SEARCH_PATH})
@@ -152,6 +152,7 @@
   find_library(X11_Xv_LIB Xv                 ${X11_LIB_SEARCH_PATH})
   find_library(X11_Xxf86misc_LIB Xxf86misc   ${X11_LIB_SEARCH_PATH})
   find_library(X11_Xxf86vm_LIB Xxf86vm       ${X11_LIB_SEARCH_PATH})
+  find_library(X11_xcb_LIB xcb               ${X11_LIB_SEARCH_PATH})
 
   set(X11_LIBRARY_DIR "")
   if(X11_X11_LIB)
@@ -179,7 +180,7 @@
 
   set(X11_LIBRARIES) # start with empty list
   if(X11_X11_LIB)
-    set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_X11_LIB})
+    set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_X11_LIB} ${X11_xcb_LIB})
   endif()
 
   if(X11_Xext_LIB)
@@ -203,15 +204,13 @@
 
   if (X11_Xau_LIB AND X11_Xau_INCLUDE_PATH)
     set(X11_Xau_FOUND TRUE)
+    set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_Xau_LIB})
   endif ()
 
   if (X11_Xdmcp_INCLUDE_PATH AND X11_Xdmcp_LIB)
       set(X11_Xdmcp_FOUND TRUE)
       set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xdmcp_INCLUDE_PATH})
       set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_Xdmcp_LIB})
-      if (X11_Xau_FOUND)
-      	set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_Xau_LIB})
-      endif ()
   endif ()
 
   if (X11_Xaccessrules_INCLUDE_PATH AND X11_Xaccessstr_INCLUDE_PATH)
@@ -333,6 +332,10 @@
      set(X11_SM_FOUND TRUE)
   endif()
 
+  if(X11_xcb_LIB AND X11_xcb_INCLUDE_PATH)
+     set(X11_xcb_FOUND TRUE)
+  endif()
+
   # Most of the X11 headers will be in the same directories, avoid
   # creating a huge list of duplicates.
   if (X11_INCLUDE_DIR)
@@ -353,7 +356,7 @@
     if($ENV{ISC} MATCHES "^yes$")
       set(X11_X_EXTRA_LIBS -lnsl_s -linet)
     else()
-      set(X11_X_EXTRA_LIBS "")
+      set(X11_X_EXTRA_LIBS "-Wl,-Bdynamic -ldl")
 
       # See if XOpenDisplay in X11 works by itself.
       CHECK_LIBRARY_EXISTS("${X11_LIBRARIES}" "XOpenDisplay" "${X11_LIBRARY_DIR}" X11_LIB_X11_SOLO)
@@ -423,14 +426,6 @@
       endif()
     endif ()
 
-    if (X11_Xdmcp_FOUND)
-      set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} ${X11_Xdmcp_LIB})
-    endif ()
-
-    if (X11_Xau_FOUND)
-      set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} ${X11_Xau_LIB})
-    endif ()
-
     # Build the final list of libraries.
     set(X11_LIBRARIES ${X11_X_PRE_LIBS} ${X11_LIBRARIES} ${X11_X_EXTRA_LIBS})
 
@@ -506,6 +501,8 @@
     X11_ICE_INCLUDE_PATH
     X11_SM_LIB
     X11_SM_INCLUDE_PATH
+    X11_xcb_LIB
+    X11_xcb_INCLUDE_PATH
     X11_XSync_INCLUDE_PATH
   )
   set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE})
diff --git a/contrib/packages/rpm/el5/SOURCES/cve-2011-4818-extra.patch b/contrib/packages/rpm/el5/SOURCES/cve-2011-4818-extra.patch
deleted file mode 100644
index 5f81b4b..0000000
--- a/contrib/packages/rpm/el5/SOURCES/cve-2011-4818-extra.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From ef2807731903ff05a618fe2cbd532fe2472f7d0d Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 27 Sep 2011 14:56:00 -0400
-Subject: [PATCH] CVE-2011-4818: Additional coverage for swap barriers and
- hyperpipe
-
-These have since been dropped, so the straight backport does not cover
-these cases.
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- glx/glxcmds.c |   30 ++++++++++++++++++++++++------
- 1 files changed, 24 insertions(+), 6 deletions(-)
-
-diff --git a/glx/glxcmds.c b/glx/glxcmds.c
-index 922a6c1..fd0df31 100644
---- a/glx/glxcmds.c
-+++ b/glx/glxcmds.c
-@@ -2204,6 +2204,8 @@ int __glXDisp_BindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
-     int screen, rc;
-     __GLXscreen *pGlxScreen;
- 
-+    REQUEST_SIZE_MATCH(xGLXBindSwapBarrierSGIXReq);
-+
-     rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixGetAttrAccess);
-     pGlxScreen = glxGetScreen(pDraw->pScreen);
-     if (rc == Success && (pDraw->type == DRAWABLE_WINDOW)) {
-@@ -2233,9 +2235,13 @@ int __glXDisp_QueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
-                                     (xGLXQueryMaxSwapBarriersSGIXReq *) pc;
-     xGLXQueryMaxSwapBarriersSGIXReply reply;
-     int screen = req->screen;
-+    int err;
-     __GLXscreen *pGlxScreen;
- 
--    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
-+    REQUEST_SIZE_MATCH(xGLXQueryMaxSwapBarriersSGIXReq);
-+    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
-+	return err;
-+
-     if (pGlxScreen->swapBarrierFuncs)
-         reply.max = pGlxScreen->swapBarrierFuncs->queryMaxSwapBarriersFunc(screen);
-     else
-@@ -2265,14 +2271,17 @@ int __glXDisp_QueryHyperpipeNetworkSGIX(__GLXclientState *cl, GLbyte *pc)
-     xGLXQueryHyperpipeNetworkSGIXReply reply;
-     int screen = req->screen;
-     void *rdata = NULL;
--
-+    int err;
-     int length=0;
-     int npipes=0;
- 
-     int n= 0;
-     __GLXscreen *pGlxScreen;
- 
--    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
-+    REQUEST_SIZE_MATCH(xGLXQueryHyperpipeNetworkSGIXReq);
-+
-+    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
-+	return err;
-     if (pGlxScreen->hyperpipeFuncs) {
-         rdata =
-             (pGlxScreen->hyperpipeFuncs->queryHyperpipeNetworkFunc(screen, &npipes, &n));
-@@ -2308,11 +2317,14 @@ int __glXDisp_DestroyHyperpipeConfigSGIX (__GLXclientState *cl, GLbyte *pc)
-     int screen = req->screen;
-     int  success = GLX_BAD_HYPERPIPE_SGIX;
-     int hpId ;
-+    int err;
-     __GLXscreen *pGlxScreen;
- 
-     hpId = req->hpId;
- 
--    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
-+    REQUEST_SIZE_MATCH(xGLXDestroyHyperpipeConfigSGIXReq);
-+    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
-+	return err;
-     if (pGlxScreen->hyperpipeFuncs) {
-         success = pGlxScreen->hyperpipeFuncs->destroyHyperpipeConfigFunc(screen, hpId);
-     }
-@@ -2346,11 +2358,14 @@ int __glXDisp_QueryHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
-     int npipes=0;
-     int n= 0;
-     int hpId;
-+    int err;
-     __GLXscreen *pGlxScreen;
- 
-     hpId = req->hpId;
- 
--    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
-+    REQUEST_SIZE_MATCH(xGLXQueryHyperpipeConfigSGIXReq);
-+    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
-+	return err;
-     if (pGlxScreen->hyperpipeFuncs) {
-         rdata = pGlxScreen->hyperpipeFuncs->queryHyperpipeConfigFunc(screen, hpId,&npipes, &n);
-     }
-@@ -2387,12 +2402,15 @@ int __glXDisp_HyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
-     xGLXHyperpipeConfigSGIXReply reply;
-     int screen = req->screen;
-     void *rdata;
-+    int err;
- 
-     int npipes=0, networkId;
-     int hpId=-1;
-     __GLXscreen *pGlxScreen;
- 
--    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
-+    REQUEST_SIZE_MATCH(xGLXHyperpipeConfigSGIXReq);
-+    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
-+	return err;
-     networkId = (int)req->networkId;
-     npipes = (int)req->npipes;
-     rdata = (void *)(req +1);
--- 
-1.7.6
-
diff --git a/contrib/packages/rpm/el5/SOURCES/cve-2011-4818.patch b/contrib/packages/rpm/el5/SOURCES/cve-2011-4818.patch
deleted file mode 100644
index 51d3047..0000000
--- a/contrib/packages/rpm/el5/SOURCES/cve-2011-4818.patch
+++ /dev/null
@@ -1,1271 +0,0 @@
-From 39c693703e080d0f6a0fa23898ae2680af2a556b Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 27 Sep 2011 11:31:13 -0400
-Subject: [PATCH] CVE-2011-4818: Multiple input sanitization flaws in GLX and
- Render
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- glx/glxcmds.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++----
- glx/glxcmdsswap.c |  171 +++++++++++++++++++++++++++++++++++++++++++---
- glx/xfont.c       |    2 +
- render/render.c   |    8 ++
- 4 files changed, 353 insertions(+), 23 deletions(-)
-
-diff --git a/glx/glxcmds.c b/glx/glxcmds.c
-index ba4c123..922a6c1 100644
---- a/glx/glxcmds.c
-+++ b/glx/glxcmds.c
-@@ -57,7 +57,7 @@ validGlxScreen(ClientPtr client, int screen, __GLXscreen **pGlxScreen, int *err)
-     /*
-     ** Check if screen exists.
-     */
--    if (screen >= screenInfo.numScreens) {
-+    if (screen < 0 || screen >= screenInfo.numScreens) {
- 	client->errorValue = screen;
- 	*err = BadValue;
- 	return FALSE;
-@@ -311,11 +311,14 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
- 
- int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
-     __GLXconfig *config;
-     __GLXscreen *pGlxScreen;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateContextReq);
-+
-     if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
- 	return err;
-     if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err))
-@@ -327,11 +330,14 @@ int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
-     __GLXconfig *config;
-     __GLXscreen *pGlxScreen;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateNewContextReq);
-+
-     if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
- 	return err;
-     if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
-@@ -343,12 +349,15 @@ int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateContextWithConfigSGIXReq *req = 
- 	(xGLXCreateContextWithConfigSGIXReq *) pc;
-     __GLXconfig *config;
-     __GLXscreen *pGlxScreen;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq);
-+
-     if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
- 	return err;
-     if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
-@@ -359,10 +368,13 @@ int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
- }
- int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
-     __GLXcontext *glxc;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyContextReq);
-+
-     if (!validGlxContext(cl->client, req->context, DixDestroyAccess,
- 			 &glxc, &err))
- 	    return err;
-@@ -674,24 +686,33 @@ DoMakeCurrent(__GLXclientState *cl,
- 
- int __glXDisp_MakeCurrent(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXMakeCurrentReq);
-+
-     return DoMakeCurrent( cl, req->drawable, req->drawable,
- 			  req->context, req->oldContextTag );
- }
- 
- int __glXDisp_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq);
-+
-     return DoMakeCurrent( cl, req->drawable, req->readdrawable,
- 			  req->context, req->oldContextTag );
- }
- 
- int __glXDisp_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq);
-+
-     return DoMakeCurrent( cl, req->drawable, req->readable,
- 			  req->context, req->oldContextTag );
- }
-@@ -704,6 +725,8 @@ int __glXDisp_IsDirect(__GLXclientState *cl, GLbyte *pc)
-     __GLXcontext *glxc;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXIsDirectReq);
-+
-     if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
- 	return err;
- 
-@@ -728,6 +751,8 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc)
-     xGLXQueryVersionReply reply;
-     GLuint major, minor;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryVersionReq);
-+
-     major = req->majorVersion;
-     minor = req->minorVersion;
-     (void)major;
-@@ -754,11 +779,15 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc;
--    GLXContextTag tag = req->contextTag;
-+    GLXContextTag tag;
-     __GLXcontext *glxc = NULL;
-     int error;
- 
-+    REQUEST_SIZE_MATCH(xGLXWaitGLReq);
-+
-+    tag = req->contextTag;
-     if (tag) {
- 	glxc = __glXLookupContextByTag(cl, tag);
- 	if (!glxc)
-@@ -778,11 +807,15 @@ int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXWaitXReq *req = (xGLXWaitXReq *)pc;
--    GLXContextTag tag = req->contextTag;
-+    GLXContextTag tag;
-     __GLXcontext *glxc = NULL;
-     int error;
- 
-+    REQUEST_SIZE_MATCH(xGLXWaitXReq);
-+
-+    tag = req->contextTag;
-     if (tag) {
- 	glxc = __glXLookupContextByTag(cl, tag);
- 	if (!glxc)
-@@ -802,13 +835,19 @@ int __glXDisp_CopyContext(__GLXclientState *cl, GLbyte *pc)
- {
-     ClientPtr client = cl->client;
-     xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
--    GLXContextID source = req->source;
--    GLXContextID dest = req->dest;
--    GLXContextTag tag = req->contextTag;
--    unsigned long mask = req->mask;
-+    GLXContextID source;
-+    GLXContextID dest;
-+    GLXContextTag tag;
-+    unsigned long mask;
-     __GLXcontext *src, *dst;
-     int error;
- 
-+    REQUEST_SIZE_MATCH(xGLXCopyContextReq);
-+
-+    source = req->source;
-+    dest = req->dest;
-+    tag = req->contextTag;
-+    mask = req->mask;
-     if (!validGlxContext(cl->client, source, DixReadAccess, &src, &error))
- 	return error;
-     if (!validGlxContext(cl->client, dest, DixWriteAccess, &dst, &error))
-@@ -891,6 +930,8 @@ int __glXDisp_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
-     __GLX_DECLARE_SWAP_VARIABLES;
-     __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq);
-+
-     if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
- 	return err;
- 
-@@ -1070,13 +1111,18 @@ DoGetFBConfigs(__GLXclientState *cl, unsigned screen)
- 
- int __glXDisp_GetFBConfigs(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
-+    REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq);
-     return DoGetFBConfigs(cl, req->screen);
- }
- 
- int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
-+    /* work around mesa bug, don't use REQUEST_SIZE_MATCH */
-+    REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq);
-     return DoGetFBConfigs(cl, req->screen);
- }
- 
-@@ -1202,11 +1248,14 @@ determineTextureTarget(ClientPtr client, XID glxDrawableID,
- 
- int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
-     __GLXconfig *config;
-     __GLXscreen *pGlxScreen;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq);
-+
-     if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
- 	return err;
-     if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err))
-@@ -1218,11 +1267,19 @@ int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
-     __GLXconfig *config;
-     __GLXscreen *pGlxScreen;
-     int err;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq);
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3);
-+
-     if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
- 	return err;
-     if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
-@@ -1241,12 +1298,15 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateGLXPixmapWithConfigSGIXReq *req = 
- 	(xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
-     __GLXconfig *config;
-     __GLXscreen *pGlxScreen;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq);
-+
-     if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
- 	return err;
-     if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
-@@ -1273,15 +1333,23 @@ static int DoDestroyDrawable(__GLXclientState *cl, XID glxdrawable, int type)
- 
- int __glXDisp_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq);
-+
-     return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP);
- }
- 
- int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc;
- 
-+    /* should be REQUEST_SIZE_MATCH, but mesa's glXDestroyPixmap used to set
-+     * length to 3 instead of 2 */
-+    REQUEST_AT_LEAST_SIZE(xGLXDestroyPixmapReq);
-+
-     return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP);
- }
- 
-@@ -1310,10 +1378,18 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
- 
- int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreatePbufferReq	*req = (xGLXCreatePbufferReq *) pc;
-     CARD32			*attrs;
-     int				 width, height, i;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq);
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3);
-+
-     attrs = (CARD32 *) (req + 1);
-     width = 0;
-     height = 0;
-@@ -1339,23 +1415,32 @@ int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq);
-+
-     return DoCreatePbuffer(cl->client, req->screen, req->fbconfig,
- 			   req->width, req->height, req->pbuffer);
- }
- 
- int __glXDisp_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq);
-+
-     return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER);
- }
- 
- int __glXDisp_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq);
-+
-     return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER);
- }
- 
-@@ -1386,18 +1471,40 @@ DoChangeDrawableAttributes(ClientPtr client, XID glxdrawable,
- 
- int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXChangeDrawableAttributesReq *req =
- 	(xGLXChangeDrawableAttributesReq *) pc;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq);
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+#if 0
-+    /* mesa sends an additional 8 bytes */
-+    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3);
-+#else
-+    if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len)
-+	    return BadLength;
-+#endif
-+
-     return DoChangeDrawableAttributes(cl->client, req->drawable,
- 				      req->numAttribs, (CARD32 *) (req + 1));
- }
- 
- int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXChangeDrawableAttributesSGIXReq *req =
- 	(xGLXChangeDrawableAttributesSGIXReq *)pc;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq);
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3);
-+
-     return DoChangeDrawableAttributes(cl->client, req->drawable,
- 				      req->numAttribs, (CARD32 *) (req + 1));
- }
-@@ -1411,6 +1518,15 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc)
-     DrawablePtr		 pDraw;
-     int			 err;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq);
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3);
-+
-+    LEGAL_NEW_RESOURCE(req->glxwindow, client);
-+
-     if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
- 	return err;
-     if (!validGlxFBConfig(client, pGlxScreen, req->fbconfig, &config, &err))
-@@ -1431,8 +1547,12 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
- 
-+    /* mesa's glXDestroyWindow used to set length to 3 instead of 2 */
-+    REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq);
-+
-     return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW);
- }
- 
-@@ -1448,12 +1568,16 @@ int __glXDisp_SwapBuffers(__GLXclientState *cl, GLbyte *pc)
- {
-     ClientPtr client = cl->client;
-     xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
--    GLXContextTag tag = req->contextTag;
--    XID drawId = req->drawable;
-+    GLXContextTag tag;
-+    XID drawId;
-     __GLXcontext *glxc = NULL;
-     __GLXdrawable *pGlxDraw;
-     int error;
- 
-+    REQUEST_SIZE_MATCH(xGLXSwapBuffersReq);
-+
-+    tag = req->contextTag;
-+    drawId = req->drawable;
-     if (tag) {
- 	glxc = __glXLookupContextByTag(cl, tag);
- 	if (!glxc) {
-@@ -1534,15 +1658,21 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId)
- 
- int __glXDisp_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq);
-+
-     return DoQueryContext(cl, req->context);
- }
- 
- int __glXDisp_QueryContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryContextReq);
-+
-     return DoQueryContext(cl, req->context);
- }
- 
-@@ -1555,11 +1685,21 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
-     GLXDrawable		 drawId;
-     int			 buffer;
-     int			 error;
-+    CARD32		 num_attribs;
-+
-+    if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len)
-+	return BadLength;
- 
-     pc += __GLX_VENDPRIV_HDR_SIZE;
- 
-     drawId = *((CARD32 *) (pc));
-     buffer = *((INT32 *)  (pc + 4));
-+    num_attribs = *((CARD32 *) (pc + 8));
-+    if (num_attribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = num_attribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 12 + (num_attribs << 3));
- 
-     if (buffer != GLX_FRONT_LEFT_EXT)
- 	return __glXError(GLXBadPixmap);
-@@ -1590,6 +1730,8 @@ int __glXDisp_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
-     int			 buffer;
-     int			 error;
- 
-+    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8);
-+
-     pc += __GLX_VENDPRIV_HDR_SIZE;
- 
-     drawId = *((CARD32 *) (pc));
-@@ -1625,6 +1767,8 @@ int __glXDisp_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc)
-     (void) client;
-     (void) req;
- 
-+    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20);
-+
-     pc += __GLX_VENDPRIV_HDR_SIZE;
- 
-     drawId = *((CARD32 *) (pc));
-@@ -1713,16 +1857,23 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId)
- 
- int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
- 
-+    /* this should be REQUEST_SIZE_MATCH, but mesa sends an additional 4 bytes */
-+    REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq);
-+
-     return DoGetDrawableAttributes(cl, req->drawable);
- }
- 
- int __glXDisp_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetDrawableAttributesSGIXReq *req =
- 	(xGLXGetDrawableAttributesSGIXReq *)pc;
-     
-+    REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq);
-+
-     return DoGetDrawableAttributes(cl, req->drawable);
- }
- 
-@@ -1747,6 +1898,8 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc)
-     __GLXcontext *glxc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXRenderReq);
-+
-     req = (xGLXRenderReq *) pc;
-     if (client->swapped) {
- 	__GLX_SWAP_SHORT(&req->length);
-@@ -1767,6 +1920,9 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc)
- 	__GLXdispatchRenderProcPtr proc;
- 	int err;
- 
-+	if (left < sizeof(__GLXrenderHeader))
-+	    return BadLength;
-+
- 	/*
- 	** Verify that the header length and the overall length agree.
- 	** Also, each command must be word aligned.
-@@ -2277,10 +2433,12 @@ int __glXDisp_HyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
-     GLint vendorcode = req->vendorCode;
-     __GLXdispatchVendorPrivProcPtr proc;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
- 
-     proc = (__GLXdispatchVendorPrivProcPtr)
-       __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
-@@ -2296,10 +2454,12 @@ int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_VendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
-     GLint vendorcode = req->vendorCode;
-     __GLXdispatchVendorPrivProcPtr proc;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
- 
-     proc = (__GLXdispatchVendorPrivProcPtr)
-       __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
-@@ -2322,6 +2482,8 @@ int __glXDisp_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
-     char *buf;
-     int err;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq);
-+
-     if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
- 	return err;
- 
-@@ -2361,6 +2523,8 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc)
-     int err;
-     char ver_str[16];
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryServerStringReq);
-+
-     if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
- 	return err;
- 
-@@ -2408,15 +2572,20 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
-     const char *buf;
-    
-+    REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq);
-+
-+    buf = (const char *)(req+1);
-+    if (!memchr(buf, 0, (client->req_len << 2) - sizeof(xGLXClientInfoReq)))
-+	return BadLength;
-+
-     cl->GLClientmajorVersion = req->major;
-     cl->GLClientminorVersion = req->minor;
--    if (cl->GLClientextensions)
--	xfree(cl->GLClientextensions);
--    buf = (const char *)(req+1);
--    cl->GLClientextensions = xstrdup(buf);
-+    free(cl->GLClientextensions);
-+    cl->GLClientextensions = strdup(buf);
- 
-     return Success;
- }
-diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c
-index c414dc8..5947e64 100644
---- a/glx/glxcmdsswap.c
-+++ b/glx/glxcmdsswap.c
-@@ -61,9 +61,12 @@
- 
- int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateContextReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->context);
-     __GLX_SWAP_INT(&req->visual);
-@@ -75,9 +78,12 @@ int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateNewContextReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->context);
-     __GLX_SWAP_INT(&req->fbconfig);
-@@ -90,10 +96,13 @@ int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateContextWithConfigSGIXReq *req =
- 	(xGLXCreateContextWithConfigSGIXReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->context);
-     __GLX_SWAP_INT(&req->fbconfig);
-@@ -106,9 +115,12 @@ int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyContextReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->context);
- 
-@@ -117,9 +129,12 @@ int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXMakeCurrentReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->drawable);
-     __GLX_SWAP_INT(&req->context);
-@@ -130,9 +145,12 @@ int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->drawable);
-     __GLX_SWAP_INT(&req->readdrawable);
-@@ -144,9 +162,12 @@ int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->drawable);
-     __GLX_SWAP_INT(&req->readable);
-@@ -158,9 +179,12 @@ int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXIsDirectReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->context);
- 
-@@ -169,9 +193,12 @@ int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryVersionReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->majorVersion);
-     __GLX_SWAP_INT(&req->minorVersion);
-@@ -181,9 +208,12 @@ int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXWaitGLReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->contextTag);
- 
-@@ -192,9 +222,12 @@ int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXWaitXReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->contextTag);
- 
-@@ -203,9 +236,12 @@ int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXCopyContextReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->source);
-     __GLX_SWAP_INT(&req->dest);
-@@ -216,36 +252,48 @@ int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq);
-+
-     __GLX_SWAP_INT(&req->screen);
-     return __glXDisp_GetVisualConfigs(cl, pc);
- }
- 
- int __glXDispSwap_GetFBConfigs(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq);
-+
-     __GLX_SWAP_INT(&req->screen);
-     return __glXDisp_GetFBConfigs(cl, pc);
- }
- 
- int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq);
-+
-     __GLX_SWAP_INT(&req->screen);
-     return __glXDisp_GetFBConfigsSGIX(cl, pc);
- }
- 
- int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->screen);
-     __GLX_SWAP_INT(&req->visual);
-@@ -257,29 +305,41 @@ int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
-     CARD32 *attribs;
-     __GLX_DECLARE_SWAP_VARIABLES;
-     __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->screen);
-     __GLX_SWAP_INT(&req->fbconfig);
-     __GLX_SWAP_INT(&req->pixmap);
-     __GLX_SWAP_INT(&req->glxpixmap);
-     __GLX_SWAP_INT(&req->numAttribs);
-+
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3);
-     attribs = (CARD32*)(req + 1);
--    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
-+    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
- 
-     return __glXDisp_CreatePixmap(cl, pc);
- }
- 
- int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateGLXPixmapWithConfigSGIXReq *req = 
- 	(xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->screen);
-     __GLX_SWAP_INT(&req->fbconfig);
-@@ -291,9 +351,12 @@ int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc
- 
- int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->glxpixmap);
- 
-@@ -302,9 +365,12 @@ int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXDestroyGLXPixmapReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->glxpixmap);
- 
-@@ -313,9 +379,12 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;    
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryContextReq);
-+
-     __GLX_SWAP_INT(&req->context);
- 
-     return __glXDisp_QueryContext(cl, pc);
-@@ -323,26 +392,38 @@ int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc;    
-     __GLX_DECLARE_SWAP_VARIABLES;
-     __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-     CARD32 *attribs;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq);
-+
-     __GLX_SWAP_INT(&req->screen);
-     __GLX_SWAP_INT(&req->fbconfig);
-     __GLX_SWAP_INT(&req->pbuffer);
-     __GLX_SWAP_INT(&req->numAttribs);
-+
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3);
-     attribs = (CARD32*)(req + 1);
--    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
-+    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
- 
-     return __glXDisp_CreatePbuffer(cl, pc);
- }
- 
- int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc;    
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq);
-+
-     __GLX_SWAP_INT(&req->screen);
-     __GLX_SWAP_INT(&req->fbconfig);
-     __GLX_SWAP_INT(&req->pbuffer);
-@@ -354,9 +435,12 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq);
-+
-     __GLX_SWAP_INT(&req->pbuffer);
- 
-     return __glXDisp_DestroyPbuffer(cl, pc);
-@@ -364,9 +448,12 @@ int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq);
-+
-     __GLX_SWAP_INT(&req->pbuffer);
- 
-     return __glXDisp_DestroyGLXPbufferSGIX(cl, pc);
-@@ -374,16 +461,27 @@ int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXChangeDrawableAttributesReq *req =
- 	(xGLXChangeDrawableAttributesReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
-     __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-     CARD32 *attribs;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq);
-+
-     __GLX_SWAP_INT(&req->drawable);
-     __GLX_SWAP_INT(&req->numAttribs);
-+
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len)
-+	return BadLength;
-+
-     attribs = (CARD32*)(req + 1);
--    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
-+    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
- 
-     return __glXDisp_ChangeDrawableAttributes(cl, pc);
- }
-@@ -391,43 +489,64 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
- int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl,
- 					       GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXChangeDrawableAttributesSGIXReq *req =
- 	(xGLXChangeDrawableAttributesSGIXReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
-     __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-     CARD32 *attribs;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq);
-+
-     __GLX_SWAP_INT(&req->drawable);
-     __GLX_SWAP_INT(&req->numAttribs);
-+
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3);
-     attribs = (CARD32*)(req + 1);
--    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
-+    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
- 
-     return __glXDisp_ChangeDrawableAttributesSGIX(cl, pc);
- }
- 
- int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
-     __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-     CARD32 *attribs;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq);
-+
-     __GLX_SWAP_INT(&req->screen);
-     __GLX_SWAP_INT(&req->fbconfig);
-     __GLX_SWAP_INT(&req->window);
-     __GLX_SWAP_INT(&req->glxwindow);
-     __GLX_SWAP_INT(&req->numAttribs);
-+
-+    if (req->numAttribs > (UINT32_MAX >> 3)) {
-+	client->errorValue = req->numAttribs;
-+	return BadValue;
-+    }
-+    REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3);
-     attribs = (CARD32*)(req + 1);
--    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
-+    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
- 
-     return __glXDisp_CreateWindow(cl, pc);
- }
- 
- int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq);
-+
-     __GLX_SWAP_INT(&req->glxwindow);
- 
-     return __glXDisp_DestroyWindow(cl, pc);
-@@ -435,9 +554,12 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXSwapBuffersReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->contextTag);
-     __GLX_SWAP_INT(&req->drawable);
-@@ -447,9 +569,12 @@ int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXUseXFontReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->contextTag);
-     __GLX_SWAP_INT(&req->font);
-@@ -463,9 +588,12 @@ int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *)pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->screen);
- 
-@@ -474,9 +602,12 @@ int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryServerStringReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->screen);
-     __GLX_SWAP_INT(&req->name);
-@@ -486,9 +617,12 @@ int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->major);
-     __GLX_SWAP_INT(&req->minor);
-@@ -499,9 +633,12 @@ int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->context);
- 
-@@ -510,33 +647,41 @@ int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
-     GLXDrawable		 *drawId;
-     int			 *buffer;
--    
-+    CARD32		 *num_attribs;
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len)
-+	return BadLength;
-+
-     pc += __GLX_VENDPRIV_HDR_SIZE;
- 
-     drawId = ((GLXDrawable *) (pc));
-     buffer = ((int *)	      (pc + 4));
-+    num_attribs = ((CARD32 *) (pc + 8));
-     
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->contextTag);
-     __GLX_SWAP_INT(drawId);
-     __GLX_SWAP_INT(buffer);
-+    __GLX_SWAP_INT(num_attribs);
- 
-     return __glXDisp_BindTexImageEXT(cl, (GLbyte *)pc);
- }
- 
- int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
-     GLXDrawable		 *drawId;
-     int			 *buffer;
--    
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8);
-+
-     pc += __GLX_VENDPRIV_HDR_SIZE;
- 
-     drawId = ((GLXDrawable *) (pc));
-@@ -552,12 +697,14 @@ int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
-     GLXDrawable		 *drawId;
-     int			 *buffer;
--
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20);
-+
-     (void) drawId;
-     (void) buffer;
- 
-@@ -577,11 +724,13 @@ int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc;
-     CARD32 *data;
--    
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq);
-+
-     data = (CARD32 *) (req + 1);
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->contextTag);
-@@ -592,10 +741,12 @@ int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
- 
- int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
- {
-+    ClientPtr client = cl->client;
-     xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
--    
-     __GLX_DECLARE_SWAP_VARIABLES;
- 
-+    REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq);
-+
-     __GLX_SWAP_SHORT(&req->length);
-     __GLX_SWAP_INT(&req->drawable);
- 
-diff --git a/glx/xfont.c b/glx/xfont.c
-index b8b466d..5d5b4c3 100644
---- a/glx/xfont.c
-+++ b/glx/xfont.c
-@@ -160,6 +160,8 @@ int __glXDisp_UseXFont(__GLXclientState *cl, GLbyte *pc)
-     __GLXcontext *cx;
-     int error;
- 
-+    REQUEST_SIZE_MATCH(xGLXUseXFontReq);
-+
-     req = (xGLXUseXFontReq *) pc;
-     cx = __glXForceCurrent(cl, req->contextTag, &error);
-     if (!cx) {
-diff --git a/render/render.c b/render/render.c
-index 3f7edf7..b78c75b 100644
---- a/render/render.c
-+++ b/render/render.c
-@@ -1085,6 +1085,14 @@ ProcRenderAddGlyphs (ClientPtr client)
-     gi = (xGlyphInfo *) (gids + nglyphs);
-     bits = (CARD8 *) (gi + nglyphs);
-     remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs;
-+
-+    /* protect against bad nglyphs */
-+    if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) ||
-+        bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) {
-+        err = BadLength;
-+        goto bail;
-+    }
-+
-     for (i = 0; i < nglyphs; i++)
-     {
- 	size_t padded_width;
--- 
-1.7.6
-
diff --git a/contrib/packages/rpm/el5/SOURCES/dont-forward-keycode-0.patch b/contrib/packages/rpm/el5/SOURCES/dont-forward-keycode-0.patch
deleted file mode 100644
index 36d38b2..0000000
--- a/contrib/packages/rpm/el5/SOURCES/dont-forward-keycode-0.patch
+++ /dev/null
@@ -1,51 +0,0 @@
---- libX11-1.0.3/modules/im/ximcp/imDefLkup.c.dont-forward-keycode-0	2006-06-22 17:22:22.000000000 -0400
-+++ libX11-1.0.3/modules/im/ximcp/imDefLkup.c	2006-09-20 17:57:49.000000000 -0400
-@@ -332,6 +332,17 @@
-     XEvent	*ev,
-     Bool	 sync)
- {
-+    /*
-+     * Don't forward a key event which has keycode=0.
-+     * keycode=0 is reserved for special purpose to let Xmb/wcLookupString()
-+     * functions know that there is a commited string available from IM.
-+     */
-+    if (((ev->type == KeyPress) || (ev->type == KeyRelease))) {
-+        if (((XKeyEvent *)ev)->keycode == 0) {
-+            return True;
-+        }
-+    }
-+
- #ifdef EXT_FORWARD
-     if (((ev->type == KeyPress) || (ev->type == KeyRelease)))
- 	if (_XimExtForwardKeyEvent(ic, (XKeyEvent *)ev, sync))
-@@ -605,6 +616,19 @@
- 	Xfree(info->keysym);
-     ic->private.proto.commit_info = info->next;
-     Xfree(info);
-+
-+    /*
-+     * "Commit" uses fabricated flag to process a commited string
-+     * from IM engine.  
-+     * Turn off the fabricated flag here (unregister the commited
-+     * information function). Otherwise, next regular key press
-+     * event will be ignored at _XimProtoKeypressFilter() and it
-+     * will not be passed to IM engine.
-+     */
-+    if (IS_FABLICATED(ic)) {
-+        UNMARK_FABLICATED(ic);
-+    }
-+
-     return;
- }
- 
---- libX11-1.0.3/modules/im/ximcp/imDefFlt.c.dont-forward-keycode-0	2006-06-22 17:22:22.000000000 -0400
-+++ libX11-1.0.3/modules/im/ximcp/imDefFlt.c	2006-09-20 17:57:49.000000000 -0400
-@@ -147,7 +147,7 @@
-     Xim		im = (Xim)ic->core.im;
- #endif
- 
--    if (IS_FABLICATED(ic)) {
-+    if ((ev->keycode == 0) || IS_FABLICATED(ic)) {
- 	_XimPendingFilter(ic);
- 	UNMARK_FABLICATED(ic);
- 	return NOTFILTERD;
diff --git a/contrib/packages/rpm/el5/SOURCES/fc-cache.1 b/contrib/packages/rpm/el5/SOURCES/fc-cache.1
deleted file mode 100644
index 3d4eebf..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fc-cache.1
+++ /dev/null
@@ -1,75 +0,0 @@
-.\" This manpage has been automatically generated by docbook2man 
-.\" from a DocBook document.  This tool can be found at:
-.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
-.\" Please send any bug reports, improvements, comments, patches, 
-.\" etc. to Steve Cheng <steve@ggi-project.org>.
-.TH "FC-CACHE" "1" "16 January 2007" "" ""
-
-.SH NAME
-fc-cache \- build font information cache files
-.SH SYNOPSIS
-
-\fBfc-cache\fR [ \fB-fsvV?\fR ] [ \fB--force\fR ] [ \fB--system-only\fR ] [ \fB--verbose\fR ] [ \fB--version\fR ] [ \fB--help\fR ] [ \fB\fIdirs\fB\fR ]
-
-.SH "DESCRIPTION"
-.PP
-\fBfc-cache\fR scans the font directories on
-the system and builds font information cache files for
-applications using fontconfig for their font handling.
-.PP
-If directory arguments are not given,
-\fBfc-cache\fR uses each directory in the
-current font configuration. Each directory is scanned for
-font files readable by FreeType.  A cache is created which
-contains properties of each font and the associated filename.
-This cache is used to speed up application startup when using
-the fontconfig library.
-.PP
-Note that \fBfc-cache\fR must be executed
-once per architecture to generate font information customized
-for that architecture.  On a subsequent run,
-\fBfc-cache\fR will augment the cache
-information files with the information for the new
-architecture. 
-.SH "OPTIONS"
-.PP
-This program follows the usual GNU command line syntax,
-with long options starting with two dashes (`-').  A summary of
-options is included below.
-.TP
-\fB-f --force \fR
-Force re-generation of apparently up-to-date cache files,
-overriding the timestamp checking.
-.TP
-\fB-s --system-only \fR
-Only scan system-wide directories, omitting the places
-located in the user's home directory.
-.TP
-\fB-v --verbose \fR
-Display status information while busy.
-.TP
-\fB-? --help \fR
-Show summary of options.
-.TP
-\fB-V --version \fR
-Show version of the program and exit.
-.TP
-\fB\fIdirs\fB \fR
-A list of directories to scan for fonts.
-.SH "FILES"
-.TP
-\fB\fIfonts.cache-2\fB\fR
-These files are generated by \fBfc-cache\fR
-and contain maps from file names to font properties. They are
-read by the fontconfig library at application startup to locate
-appropriate fonts.
-.SH "SEE ALSO"
-.PP
-\fBfc-list\fR (1).
-.PP
-The fontconfig user's guide, in HTML format:
-\fI/usr/share/doc/fontconfig/fontconfig-user.html\fR\&.
-.SH "AUTHOR"
-.PP
-This manual page was written by Keith Packard
-<keithp@keithp.com> and Josselin Mouette <joss@debian.org>\&.
diff --git a/contrib/packages/rpm/el5/SOURCES/fc-cat.1 b/contrib/packages/rpm/el5/SOURCES/fc-cat.1
deleted file mode 100644
index f87ef56..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fc-cat.1
+++ /dev/null
@@ -1,37 +0,0 @@
-.\" This manpage has been automatically generated by docbook2man 
-.\" from a DocBook document.  This tool can be found at:
-.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
-.\" Please send any bug reports, improvements, comments, patches, 
-.\" etc. to Steve Cheng <steve@ggi-project.org>.
-.TH "FC-CAT" "1" "16 January 2007" "" ""
-
-.SH NAME
-fc-cat \- read font information cache files
-.SH SYNOPSIS
-
-\fBfc-cat < fonts-cache-2-file >\fR [ \fB-V?\fR ] [ \fB--version\fR ] [ \fB--help\fR ] [ \fB\fIdirs\fB\fR ]
-
-.SH "DESCRIPTION"
-.PP
-\fBfc-cat\fR reads a font information cache file
-and emits it in ASCII form.
-.SH "OPTIONS"
-.PP
-This program follows the usual GNU command line syntax,
-with long options starting with two dashes (`-').  A summary of
-options is included below.
-.TP
-\fB-? --help \fR
-Show summary of options.
-.TP
-\fB-V --version \fR
-Show version of the program and exit.
-.SH "SEE ALSO"
-.PP
-\fBfc-cache\fR (1).
-.PP
-The fontconfig user's guide, in HTML format:
-\fI/usr/share/doc/fontconfig/fontconfig-user.html\fR\&.
-.SH "AUTHOR"
-.PP
-This manual page was written by Patrick Lam <plam@mit.edu>\&.
diff --git a/contrib/packages/rpm/el5/SOURCES/fc-list.1 b/contrib/packages/rpm/el5/SOURCES/fc-list.1
deleted file mode 100644
index 8ccc850..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fc-list.1
+++ /dev/null
@@ -1,61 +0,0 @@
-.\" This manpage has been automatically generated by docbook2man 
-.\" from a DocBook document.  This tool can be found at:
-.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
-.\" Please send any bug reports, improvements, comments, patches, 
-.\" etc. to Steve Cheng <steve@ggi-project.org>.
-.TH "FC-LIST" "1" "16 January 2007" "" ""
-
-.SH NAME
-fc-list \- list available fonts
-.SH SYNOPSIS
-
-\fBfc-list\fR [ \fB-vV?\fR ] [ \fB--verbose\fR ] [ \fB--version\fR ] [ \fB--help\fR ] [ \fB\fIpattern\fB\fR ] [ \fB\fIelement\fB\fR ]
-
-.SH "DESCRIPTION"
-.PP
-\fBfc-list\fR lists fonts and styles
-available on the system for applications using fontconfig.
-.SH "OPTIONS"
-.PP
-This program follows the usual GNU command line syntax,
-with long options starting with two dashes (`-').  A summary of
-options is included below.
-.TP
-\fB-v --verbose \fR
-Display status information while busy.
-.TP
-\fB-? --help \fR
-Show summary of options.
-.TP
-\fB-V --version \fR
-Show version of the program and exit.
-.TP
-\fB\fIpattern\fB \fR
-If this argument is set, only fonts matching
-\fIpattern\fR are displayed.
-.TP
-\fB\fIelement\fB \fR
-If set, the \fIelement\fR property
-is displayed for matching fonts.
-.SH "EXAMPLES"
-.TP
-\fBfc-list\fR
-Lists all font faces.
-.TP
-\fBfc-list :lang=hi\fR
-Lists font faces that cover Hindi.
-.TP
-\fBfc-list : family style file spacing \fR
-Lists the filename and spacing value for each font
-face.  ``:'' is an empty pattern that matches all
-fonts.
-.SH "SEE ALSO"
-.PP
-\fBfc-cache\fR (1).
-.PP
-The fontconfig user's guide, in HTML format:
-\fI/usr/share/doc/fontconfig/fontconfig-user.html\fR\&.
-.SH "AUTHOR"
-.PP
-This manual page was written by Keith Packard
-<keithp@keithp.com> and Josselin Mouette <joss@debian.org>\&.
diff --git a/contrib/packages/rpm/el5/SOURCES/fc-match.1 b/contrib/packages/rpm/el5/SOURCES/fc-match.1
deleted file mode 100644
index 5b8a7f9..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fc-match.1
+++ /dev/null
@@ -1,51 +0,0 @@
-.\" This manpage has been automatically generated by docbook2man 
-.\" from a DocBook document.  This tool can be found at:
-.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
-.\" Please send any bug reports, improvements, comments, patches, 
-.\" etc. to Steve Cheng <steve@ggi-project.org>.
-.TH "FC-MATCH" "1" "16 January 2007" "" ""
-
-.SH NAME
-fc-match \- match available fonts
-.SH SYNOPSIS
-
-\fBfc-match\fR [ \fB-svV?\fR ] [ \fB--sort\fR ] [ \fB--verbose\fR ] [ \fB--version\fR ] [ \fB--help\fR ] [ \fB\fIfont-pattern\fB\fR ]
-
-.SH "DESCRIPTION"
-.PP
-\fBfc-match\fR matches font-pattern (empty
-pattern by default) using the normal fontconfig matching rules to find
-the best font available.  If --sort is given, the sorted list of best
-matching fonts is displayed.  With --verbose, the whole font pattern
-for each match is printed, otherwise only the file, family and style
-are printed..
-.SH "OPTIONS"
-.PP
-This program follows the usual GNU command line syntax,
-with long options starting with two dashes (`-').  A summary of
-options is included below.
-.TP
-\fB-v --verbose \fR
-Print whole font pattern for each match.
-.TP
-\fB-? --help \fR
-Show summary of options.
-.TP
-\fB-V --version \fR
-Show version of the program and exit.
-.TP
-\fB-s --sort \fR
-Displays sorted list of best matching fonts.
-.TP
-\fB\fIfont-pattern\fB \fR
-Displays fonts matching
-\fIfont-pattern\fR (uses empty pattern by default).
-.SH "SEE ALSO"
-.PP
-\fBfc-list\fR (1).
-.PP
-The fontconfig user's guide, in HTML format:
-\fI/usr/share/doc/fontconfig/fontconfig-user.html\fR\&.
-.SH "AUTHOR"
-.PP
-This manual page was updated by Patrick Lam <plam@csail.mit.edu>\&.
diff --git a/contrib/packages/rpm/el5/SOURCES/fetch_sources.sh b/contrib/packages/rpm/el5/SOURCES/fetch_sources.sh
deleted file mode 100644
index 6f6d7b0..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fetch_sources.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-SPEC=$1
-
-SOURCES=`grep -i "^SOURCE\d\+\s*:\s*\([fht]\+tp://.*\)" ${SPEC} | sed -e 's/^.*:[[:space:]]//'`  
-for URL in ${SOURCES} ; do
-  curl -OL ${URL}
-done
-
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.2-libdl.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1.3.2-libdl.patch
deleted file mode 100644
index 78c8fd4..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.2-libdl.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-Index: CMakeLists.txt
-===================================================================
-diff --git a/CMakeLists.txt b/CMakeLists.txt
---- a/CMakeLists.txt	(revision 9965)
-+++ b/CMakeLists.txt	(working copy)
-@@ -138,6 +139,7 @@
- #######################################################################
- # libraries
- find_library(LIB_CAIRO cairo)
-+find_library(LIB_dl dl)
- find_library(LIB_fontconfig fontconfig)
- find_library(LIB_freetype freetype)
- find_library(LIB_GL GL)
-@@ -146,7 +148,7 @@
- find_library(LIB_png png)
- find_library(LIB_zlib z)
- 
--mark_as_advanced(LIB_CAIRO LIB_fontconfig LIB_freetype)
-+mark_as_advanced(LIB_CAIRO LIB_dl LIB_fontconfig LIB_freetype)
- mark_as_advanced(LIB_GL LIB_MesaGL)
- mark_as_advanced(LIB_jpeg LIB_png LIB_zlib)
- 
-Index: src/CMakeLists.txt
-===================================================================
-diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
---- a/src/CMakeLists.txt	(revision 9965)
-+++ b/src/CMakeLists.txt	(working copy)
-@@ -220,7 +220,7 @@
- endif(MSVC)
- 
- if(USE_THREADS)
--   target_link_libraries(fltk ${CMAKE_THREAD_LIBS_INIT})
-+   target_link_libraries(fltk ${CMAKE_THREAD_LIBS_INIT} ${LIB_dl})
- endif(USE_THREADS)
- 
- if(USE_X11)
-@@ -334,7 +334,7 @@
- endif(MSVC)
- 
- if(USE_THREADS)
--   target_link_libraries(fltk_SHARED ${CMAKE_THREAD_LIBS_INIT})
-+   target_link_libraries(fltk_SHARED ${CMAKE_THREAD_LIBS_INIT} ${LIB_dl})
- endif(USE_THREADS)
- 
- if(USE_X11)
-@@ -384,11 +384,11 @@
- endif(MSVC)
- 
- if(USE_THREADS)
--   target_link_libraries(fltk_SHARED ${CMAKE_THREAD_LIBS_INIT})
-+   target_link_libraries(fltk_forms_SHARED ${CMAKE_THREAD_LIBS_INIT} ${LIB_dl})
- endif(USE_THREADS)
- 
- if(USE_X11)
--   target_link_libraries(fltk_SHARED ${X11_LIBRARIES})
-+   target_link_libraries(fltk_forms_SHARED ${X11_LIBRARIES})
- endif(USE_X11)
- 
- #######################################################################
-diff -Naur a/CMake/FindDL.cmake b/CMake/FindDL.cmake
---- a/CMake/FindDL.cmake	1969-12-31 19:00:00.000000000 -0500
-+++ b/CMake/FindDL.cmake	2014-10-29 23:00:18.000000000 -0400
-@@ -0,0 +1,37 @@
-+# - Find dl functions
-+# This module finds dl libraries.
-+#
-+# It sets the following variables:
-+#  DL_FOUND       - Set to false, or undefined, if dl libraries aren't found.
-+#  DL_INCLUDE_DIR - The dl include directory.
-+#  DL_LIBRARY     - The dl library to link against.
-+
-+INCLUDE(CheckFunctionExists)
-+
-+FIND_PATH(DL_INCLUDE_DIR NAMES dlfcn.h)
-+FIND_LIBRARY(DL_LIBRARY NAMES dl)
-+
-+IF (DL_LIBRARY)
-+   SET(DL_FOUND TRUE)
-+ELSE (DL_LIBRARY)
-+   # if dlopen can be found without linking in dl then,
-+   # dlopen is part of libc, so don't need to link extra libs.
-+   CHECK_FUNCTION_EXISTS(dlopen DL_FOUND)
-+   SET(DL_LIBRARY "")
-+ENDIF (DL_LIBRARY)
-+
-+IF (DL_FOUND)
-+
-+   # show which dl was found only if not quiet
-+   IF (NOT DL_FIND_QUIETLY)
-+      MESSAGE(STATUS "Found dl: ${DL_LIBRARY}")
-+   ENDIF (NOT DL_FIND_QUIETLY)
-+
-+ELSE (DL_FOUND)
-+
-+   # fatal error if dl is required but not found
-+   IF (DL_FIND_REQUIRED)
-+      MESSAGE(FATAL_ERROR "Could not find dl")
-+   ENDIF (DL_FIND_REQUIRED)
-+
-+ENDIF (DL_FOUND)
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.2-static-libs.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1.3.2-static-libs.patch
deleted file mode 100644
index 0341612..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.2-static-libs.patch
+++ /dev/null
@@ -1,74 +0,0 @@
---- fltk-1.3.2/src/CMakeLists.txt	2014-09-02 22:05:40.000000000 -0400
-+++ fltk-1.3.2/src/CMakeLists.txt	2014-09-02 22:12:35.000000000 -0400
-@@ -223,10 +223,6 @@
-    target_link_libraries(fltk ${CMAKE_THREAD_LIBS_INIT} ${LIB_dl})
- endif(USE_THREADS)
- 
--if(USE_X11)
--   target_link_libraries(fltk ${X11_LIBRARIES})
--endif(USE_X11)
--
- if(WIN32)
-    target_link_libraries(fltk comctl32)
- endif(WIN32)
-@@ -239,10 +235,6 @@
-    target_link_libraries(fltk ${X11_Xinerama_LIB})
- endif(HAVE_XINERAMA)
- 
--if(HAVE_XFIXES)
--   target_link_libraries(fltk ${X11_Xfixes_LIB})
--endif(HAVE_XFIXES)
--
- if(HAVE_XCURSOR)
-    target_link_libraries(fltk ${X11_Xcursor_LIB})
- endif(HAVE_XCURSOR)
-@@ -251,10 +243,30 @@
-    target_link_libraries(fltk ${X11_Xft_LIB})
- endif(USE_XFT)
- 
-+if(HAVE_XFIXES)
-+   target_link_libraries(fltk ${X11_Xfixes_LIB})
-+endif(HAVE_XFIXES)
-+
-+if(X11_Xrender_FOUND)
-+   target_link_libraries(fltk ${X11_Xrender_LIB})
-+endif(X11_Xrender_FOUND)
-+
-+if(USE_X11)
-+   target_link_libraries(fltk ${X11_LIBRARIES})
-+endif(USE_X11)
-+
- if(LIB_fontconfig)
-    target_link_libraries(fltk ${LIB_fontconfig})
- endif(LIB_fontconfig)
- 
-+if(LIB_EXPAT)
-+   target_link_libraries(fltk ${LIB_EXPAT})
-+endif(LIB_EXPAT)
-+
-+if(LIB_freetype)
-+   target_link_libraries(fltk ${LIB_freetype} ${LIB_dl})
-+endif(LIB_freetype)
-+
- #######################################################################
- add_library(fltk_forms STATIC ${FLCPPFILES})
- target_link_libraries(fltk_forms fltk)
---- fltk-1.3.2/CMakeLists.txt	2014-09-02 22:56:47.000000000 -0400
-+++ fltk-1.3.2/CMakeLists.txt	2014-09-02 22:57:19.000000000 -0400
-@@ -147,6 +147,7 @@
- find_library(LIB_jpeg jpeg)
- find_library(LIB_png png)
- find_library(LIB_zlib z)
-+find_library(LIB_EXPAT expat)
- 
- mark_as_advanced(LIB_CAIRO LIB_dl LIB_fontconfig LIB_freetype)
- mark_as_advanced(LIB_GL LIB_MesaGL)
-@@ -383,7 +383,7 @@
- 
- if(OPENGL_FOUND)
-    set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL)
--   set(CMAKE_REQUIRED_LIBRARIES -lGLU -lGL)
-+   set(CMAKE_REQUIRED_LIBRARIES -lGLU -lGL -lXdmcp -lXau)
-    CHECK_FUNCTION_EXISTS(glXGetProcAddressARB HAVE_GLXGETPROCADDRESSARB)
-    set(FLTK_GL_FOUND TRUE)
- else()
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.3-static-libs.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1.3.3-static-libs.patch
new file mode 100644
index 0000000..4e717e4
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/fltk-1.3.3-static-libs.patch
@@ -0,0 +1,29 @@
+--- a/configure	2015-02-22 16:20:48.000000000 -0500
++++ b/configure	2015-02-22 16:21:52.000000000 -0500
+@@ -6793,7 +6793,7 @@
+   # See if we find them without any special options.
+   # Don't add to $LIBS permanently.
+   ac_save_LIBS=$LIBS
+-  LIBS="-lX11 $LIBS"
++  LIBS="-lX11 -lXrender -lxcb -lXdmcp -lXau $LIBS"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ #include <X11/Xlib.h>
+@@ -6935,7 +6935,7 @@
+     # Martyn Johnson says this is needed for Ultrix, if the X
+     # libraries were built with DECnet support.  And Karl Berry says
+     # the Alpha needs dnet_stub (dnet does not exist).
+-    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
++    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11 -lXrender -lxcb -lXdmcp -lXau"
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -7359,7 +7359,7 @@
+ $as_echo "$as_me: WARNING: Ignoring libraries \"$X_PRE_LIBS\" requested by configure." >&2;}
+ 	fi
+ 
+-	LIBS="$LIBS -lX11 $X_EXTRA_LIBS"
++	LIBS="$LIBS -lX11 -lXrender -lxcb -lXdmcp -lXau $X_EXTRA_LIBS"
+ 	CFLAGS="$CFLAGS $X_CFLAGS"
+ 	CXXFLAGS="$CXXFLAGS $X_CFLAGS"
+ 	LDFLAGS="$X_LIBS $LDFLAGS"
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.x-clipboard.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1.3.x-clipboard.patch
deleted file mode 100644
index 3f12bc5..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.x-clipboard.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff -up fltk-1.3.x-r8659/FL/Fl.H.orig fltk-1.3.x-r8659/FL/Fl.H
---- fltk-1.3.x-r8659/FL/Fl.H.orig	2011-05-17 16:25:56.671744548 +0200
-+++ fltk-1.3.x-r8659/FL/Fl.H	2011-05-17 16:26:05.709101536 +0200
-@@ -108,6 +108,9 @@ typedef int (*Fl_Args_Handler)(int argc,
-     \see Fl::event_dispatch(Fl_Event_Dispatch) */
- typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
- 
-+/** Signature of add_clipboard_notify functions passed as parameters */
-+typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data);
-+
- /** @} */ /* group callback_functions */
- 
- 
-@@ -744,6 +747,19 @@ public:
-   */
-   static void paste(Fl_Widget &receiver, int source /*=0*/); // platform dependent
-   /**
-+  FLTK will call the registered callback whenever there is a change to the
-+  selection buffer or the clipboard. The source argument indicates which
-+  of the two has changed. Only changes by other applications are reported.
-+  \note Some systems require polling to monitor the clipboard and may
-+  therefore have some delay in detecting changes.
-+  */
-+  static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data);
-+  /**
-+  Stop calling the specified callback when there are changes to the selection
-+  buffer or the clipboard.
-+  */
-+  static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h);
-+  /**
-     Initiate a Drag And Drop operation. The selection buffer should be
-     filled with relevant data before calling this method. FLTK will
-     then initiate the system wide drag and drop handling. Dropped data
-diff -up fltk-1.3.x-r8659/src/Fl.cxx.orig fltk-1.3.x-r8659/src/Fl.cxx
---- fltk-1.3.x-r8659/src/Fl.cxx.orig	2011-05-18 15:20:26.667291459 +0200
-+++ fltk-1.3.x-r8659/src/Fl.cxx	2011-05-18 16:31:15.522026086 +0200
-@@ -430,6 +430,69 @@ static char in_idle;
- #endif
- 
- ////////////////////////////////////////////////////////////////
-+// Clipboard notifications
-+
-+struct Clipboard_Notify {
-+  Fl_Clipboard_Notify_Handler handler;
-+  void *data;
-+  struct Clipboard_Notify *next;
-+};
-+
-+static struct Clipboard_Notify *clip_notify_list = NULL;
-+
-+extern void fl_clipboard_notify_change(); // in Fl_<platform>.cxx
-+
-+void Fl::add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data) {
-+  struct Clipboard_Notify *node;
-+
-+  remove_clipboard_notify(h);
-+
-+  node = new Clipboard_Notify;
-+
-+  node->handler = h;
-+  node->data = data;
-+  node->next = clip_notify_list;
-+
-+  clip_notify_list = node;
-+
-+  fl_clipboard_notify_change();
-+}
-+
-+void Fl::remove_clipboard_notify(Fl_Clipboard_Notify_Handler h) {
-+  struct Clipboard_Notify *node, **prev;
-+
-+  node = clip_notify_list;
-+  prev = &clip_notify_list;
-+  while (node != NULL) {
-+    if (node->handler == h) {
-+      *prev = node->next;
-+      delete node;
-+
-+      fl_clipboard_notify_change();
-+
-+      return;
-+    }
-+
-+    prev = &node->next;
-+    node = node->next;
-+  }
-+}
-+
-+bool fl_clipboard_notify_empty(void) {
-+  return clip_notify_list == NULL;
-+}
-+
-+void fl_trigger_clipboard_notify(int source) {
-+  struct Clipboard_Notify *node;
-+
-+  node = clip_notify_list;
-+  while (node != NULL) {
-+    node->handler(source, node->data);
-+    node = node->next;
-+  }
-+}
-+
-+////////////////////////////////////////////////////////////////
- // wait/run/check/ready:
- 
- void (*Fl::idle)(); // see Fl::add_idle.cxx for the add/remove functions
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.x-screen_num.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1.3.x-screen_num.patch
deleted file mode 100644
index c157af6..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1.3.x-screen_num.patch
+++ /dev/null
@@ -1,131 +0,0 @@
-diff -up fltk-1.3.0r9619/FL/Fl.H.screen_num fltk-1.3.0r9619/FL/Fl.H
---- fltk-1.3.0r9619/FL/Fl.H.screen_num	2012-07-03 13:49:28.663085580 +0200
-+++ fltk-1.3.0r9619/FL/Fl.H	2012-07-03 13:49:28.731084402 +0200
-@@ -806,6 +806,8 @@ public:
-   static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
-   static void screen_xywh(int &X, int &Y, int &W, int &H, int n); 
-   static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
-+  static int screen_num(int x, int y);
-+  static int screen_num(int x, int y, int w, int h);
-   static void screen_dpi(float &h, float &v, int n=0);
-   static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
-   static void screen_work_area(int &X, int &Y, int &W, int &H, int n);
-diff -up fltk-1.3.0r9619/src/screen_xywh.cxx.screen_num fltk-1.3.0r9619/src/screen_xywh.cxx
---- fltk-1.3.0r9619/src/screen_xywh.cxx.screen_num	2012-03-23 17:47:53.000000000 +0100
-+++ fltk-1.3.0r9619/src/screen_xywh.cxx	2012-07-03 13:58:01.947195396 +0200
-@@ -215,21 +215,6 @@ int Fl::screen_count() {
-   return num_screens ? num_screens : 1;
- }
- 
--static int find_screen_with_point(int mx, int my) {
--  int screen = 0;
--  if (num_screens < 0) screen_init();
--  
--  for (int i = 0; i < num_screens; i ++) {
--    int sx, sy, sw, sh;
--    Fl::screen_xywh(sx, sy, sw, sh, i);
--    if ((mx >= sx) && (mx < (sx+sw)) && (my >= sy) && (my < (sy+sh))) {
--      screen = i;
--      break;
--    }
--  }
--  return screen;
--}
--
- /**
-   Gets the bounding box of a screen
-   that contains the specified screen position \p mx, \p my
-@@ -237,7 +222,7 @@ static int find_screen_with_point(int mx
-   \param[in] mx, my the absolute screen position
- */
- void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my) {
--  screen_xywh(X, Y, W, H, find_screen_with_point(mx, my));
-+  screen_xywh(X, Y, W, H, screen_num(mx, my));
- }
- 
- 
-@@ -248,7 +233,7 @@ void Fl::screen_xywh(int &X, int &Y, int
-  \param[in] mx, my the absolute screen position
-  */
- void Fl::screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my) {
--  screen_work_area(X, Y, W, H, find_screen_with_point(mx, my));
-+  screen_work_area(X, Y, W, H, screen_num(mx, my));
- }
- 
- /**
-@@ -321,6 +306,38 @@ void Fl::screen_xywh(int &X, int &Y, int
- #endif // WIN32
- }
- 
-+/**
-+  Gets the screen bounding rect for the screen
-+  which intersects the most with the rectangle
-+  defined by \p mx, \p my, \p mw, \p mh.
-+  \param[out]  X,Y,W,H the corresponding screen bounding box
-+  \param[in] mx, my, mw, mh the rectangle to search for intersection with
-+  \see void screen_xywh(int &X, int &Y, int &W, int &H, int n)
-+  */
-+void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh) {
-+  screen_xywh(X, Y, W, H, screen_num(mx, my, mw, mh));
-+}
-+
-+/**
-+  Gets the screen number of a screen
-+  that contains the specified screen position \p x, \p y
-+  \param[in] x, y the absolute screen position
-+*/
-+int Fl::screen_num(int x, int y) {
-+  int screen = 0;
-+  if (num_screens < 0) screen_init();
-+  
-+  for (int i = 0; i < num_screens; i ++) {
-+    int sx, sy, sw, sh;
-+    Fl::screen_xywh(sx, sy, sw, sh, i);
-+    if ((x >= sx) && (x < (sx+sw)) && (y >= sy) && (y < (sy+sh))) {
-+      screen = i;
-+      break;
-+    }
-+  }
-+  return screen;
-+}
-+
- static inline float fl_intersection(int x1, int y1, int w1, int h1,
-                         int x2, int y2, int w2, int h2) {
-   if(x1+w1 < x2 || x2+w2 < x1 || y1+h1 < y2 || y2+h2 < y1)
-@@ -333,30 +350,27 @@ static inline float fl_intersection(int
- }
- 
- /**
--  Gets the screen bounding rect for the screen
-+  Gets the screen number for the screen
-   which intersects the most with the rectangle
--  defined by \p mx, \p my, \p mw, \p mh.
--  \param[out]  X,Y,W,H the corresponding screen bounding box
--  \param[in] mx, my, mw, mh the rectangle to search for intersection with
--  \see void screen_xywh(int &X, int &Y, int &W, int &H, int n)
-+  defined by \p x, \p y, \p w, \p h.
-+  \param[in] x, y, w, h the rectangle to search for intersection with
-   */
--void Fl::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh) {
-+int Fl::screen_num(int x, int y, int w, int h) {
-   int best_screen = 0;
-   float best_intersection = 0.;
-   for(int i = 0; i < Fl::screen_count(); i++) {
-     int sx, sy, sw, sh;
-     Fl::screen_xywh(sx, sy, sw, sh, i);
--    float sintersection = fl_intersection(mx, my, mw, mh, sx, sy, sw, sh);
-+    float sintersection = fl_intersection(x, y, w, h, sx, sy, sw, sh);
-     if(sintersection > best_intersection) {
-       best_screen = i;
-       best_intersection = sintersection;
-     }
-   }
--  screen_xywh(X, Y, W, H, best_screen);
-+  return best_screen;
- }
- 
- 
--
- /**
-  Gets the screen resolution in dots-per-inch for the given screen.
-  \param[out]  h, v  horizontal and vertical resolution
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.0-modal.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.0-modal.patch
deleted file mode 100644
index 7b1b791..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.0-modal.patch
+++ /dev/null
@@ -1,75 +0,0 @@
-diff -bur fltk-1.3.0r9619.org/src/Fl_cocoa.mm fltk-1.3.0r9619/src/Fl_cocoa.mm
---- fltk-1.3.0r9619.org/src/Fl_cocoa.mm	2012-06-19 12:54:43.694231638 +0200
-+++ fltk-1.3.0r9619/src/Fl_cocoa.mm	2012-06-19 12:57:05.899048602 +0200
-@@ -697,12 +697,9 @@
-     return NO;	// prevent the caption to be redrawn as active on click
- 		//  when another modal window is currently the key win
- 
--  return !(w->tooltip_window() || w->menu_window());
-+  return !w->tooltip_window();
- }
- 
--// TODO see if we really need a canBecomeMainWindow ...
--#if 0
--
- - (BOOL)canBecomeMainWindow
- {
-   if (Fl::modal_ && (Fl::modal_ != w))
-@@ -711,7 +708,6 @@
- 
-   return !(w->tooltip_window() || w->menu_window());
- }
--#endif
- 
- @end
- 
-diff -bur fltk-1.3.0r9619.org/src/Fl_win32.cxx fltk-1.3.0r9619/src/Fl_win32.cxx
---- fltk-1.3.0r9619.org/src/Fl_win32.cxx	2012-06-19 12:54:43.696231735 +0200
-+++ fltk-1.3.0r9619/src/Fl_win32.cxx	2012-06-19 12:54:43.803236862 +0200
-@@ -1065,6 +1065,10 @@
-     break;
- 
-   case WM_SETFOCUS:
-+    if ((Fl::modal_) && (Fl::modal_ != window)) {
-+      SetFocus(fl_xid(Fl::modal_));
-+      return 0;
-+    }
-     Fl::handle(FL_FOCUS, window);
-     break;
- 
-@@ -1826,6 +1830,11 @@
-     Fl::e_number = old_event;
-     w->redraw(); // force draw to happen
-   }
-+
-+  // Needs to be done before ShowWindow() to get the correct behaviour
-+  // when we get WM_SETFOCUS.
-+  if (w->modal()) {Fl::modal_ = w; fl_fix_focus();}
-+
-   // If we've captured the mouse, we dont want to activate any
-   // other windows from the code, or we lose the capture.
-   ShowWindow(x->xid, !showit ? SW_SHOWMINNOACTIVE :
-@@ -1843,7 +1852,6 @@
-     }
-   }
- 
--  if (w->modal()) {Fl::modal_ = w; fl_fix_focus();}
-   return x;
- }
- 
-diff -bur fltk-1.3.0r9619.org/src/Fl_x.cxx fltk-1.3.0r9619/src/Fl_x.cxx
---- fltk-1.3.0r9619.org/src/Fl_x.cxx	2012-06-19 12:54:43.697231783 +0200
-+++ fltk-1.3.0r9619/src/Fl_x.cxx	2012-06-19 12:54:43.804236911 +0200
-@@ -2101,6 +2101,12 @@
-       while (wp->parent()) wp = wp->window();
-       XSetTransientForHint(fl_display, xp->xid, fl_xid(wp));
-       if (!wp->visible()) showit = 0; // guess that wm will not show it
-+      if (win->modal()) {
-+        Atom net_wm_state = XInternAtom (fl_display, "_NET_WM_STATE", 0);
-+        Atom net_wm_state_skip_taskbar = XInternAtom (fl_display, "_NET_WM_STATE_MODAL", 0);
-+        XChangeProperty (fl_display, xp->xid, net_wm_state, XA_ATOM, 32,
-+            PropModeAppend, (unsigned char*) &net_wm_state_skip_taskbar, 1);
-+      }
-     }
- 
-     // Make sure that borderless windows do not show in the task bar
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.x-clipboard-osx.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.x-clipboard-osx.patch
deleted file mode 100644
index 22e6939..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.x-clipboard-osx.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-diff -bur fltk-1.3.0r9619.org/src/Fl_cocoa.mm fltk-1.3.0r9619/src/Fl_cocoa.mm
---- fltk-1.3.0r9619.org/src/Fl_cocoa.mm	2012-06-18 19:24:30.971688769 +0200
-+++ fltk-1.3.0r9619/src/Fl_cocoa.mm	2012-06-18 19:25:25.700310375 +0200
-@@ -1319,9 +1319,13 @@
- }
- @end
- 
-+static void clipboard_check(void);
-+
- @implementation FLApplication
- + (void)sendEvent:(NSEvent *)theEvent
- {
-+  // update clipboard status
-+  clipboard_check();
-   NSEventType type = [theEvent type];  
-   if (type == NSLeftMouseDown) {
-     fl_lock_function();
-@@ -2790,6 +2794,26 @@
-     PasteboardCreate(kPasteboardClipboard, &myPasteboard);
- }
- 
-+extern void fl_trigger_clipboard_notify(int source);
-+
-+void fl_clipboard_notify_change() {
-+  // No need to do anything here...
-+}
-+
-+static void clipboard_check(void)
-+{
-+  PasteboardSyncFlags flags;
-+
-+  allocatePasteboard();
-+  flags = PasteboardSynchronize(myPasteboard);
-+
-+  if (!(flags & kPasteboardModified))
-+    return;
-+  if (flags & kPasteboardClientIsOwner)
-+    return;
-+
-+  fl_trigger_clipboard_notify(1);
-+}
- 
- /*
-  * create a selection
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.x-clipboard-win32.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.x-clipboard-win32.patch
deleted file mode 100644
index ac94779..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v2.3.x-clipboard-win32.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-diff -ur fltk-1.3.0r9110.org/src/Fl.cxx fltk-1.3.0r9110/src/Fl.cxx
---- fltk-1.3.0r9110.org/src/Fl.cxx	2012-06-17 19:47:09.988183253 +0200
-+++ fltk-1.3.0r9110/src/Fl.cxx	2012-06-17 19:47:10.127189919 +0200
-@@ -1421,6 +1421,7 @@
- // hide() destroys the X window, it does not do unmap!
- 
- #if defined(WIN32)
-+extern void fl_clipboard_notify_untarget(HWND wnd);
- extern void fl_update_clipboard(void);
- #elif USE_XFT
- extern void fl_destroy_xft_draw(Window);
-@@ -1471,6 +1472,8 @@
-   // to destroy the window that owns the selection.
-   if (GetClipboardOwner()==ip->xid)
-     fl_update_clipboard();
-+  // Make sure we unlink this window from the clipboard chain
-+  fl_clipboard_notify_untarget(ip->xid);
-   // Send a message to myself so that I'll get out of the event loop...
-   PostMessage(ip->xid, WM_APP, 0, 0);
-   if (ip->private_dc) fl_release_dc(ip->xid, ip->private_dc);
-diff -ur fltk-1.3.0r9110.org/src/Fl_win32.cxx fltk-1.3.0r9110/src/Fl_win32.cxx
---- fltk-1.3.0r9110.org/src/Fl_win32.cxx	2012-06-17 19:47:09.987183205 +0200
-+++ fltk-1.3.0r9110/src/Fl_win32.cxx	2012-06-17 19:47:19.069618739 +0200
-@@ -646,6 +646,38 @@
-   }
- }
- 
-+static HWND clipboard_wnd = 0;
-+static HWND next_clipboard_wnd = 0;
-+
-+static bool initial_clipboard = true;
-+
-+void fl_clipboard_notify_change() {
-+  // No need to do anything here...
-+}
-+
-+void fl_clipboard_notify_target(HWND wnd) {
-+  if (clipboard_wnd)
-+    return;
-+
-+  // We get one fake WM_DRAWCLIPBOARD immediately, which we therefore
-+  // need to ignore.
-+  initial_clipboard = true;
-+
-+  clipboard_wnd = wnd;
-+  next_clipboard_wnd = SetClipboardViewer(wnd);
-+}
-+
-+void fl_clipboard_notify_untarget(HWND wnd) {
-+  if (wnd != clipboard_wnd)
-+    return;
-+
-+  ChangeClipboardChain(wnd, next_clipboard_wnd);
-+  clipboard_wnd = next_clipboard_wnd = 0;
-+
-+  if (Fl::first_window())
-+    fl_clipboard_notify_target(fl_xid(Fl::first_window()));
-+}
-+
- ////////////////////////////////////////////////////////////////
- char fl_is_ime = 0;
- void fl_get_codepage()
-@@ -1327,6 +1359,27 @@
-     Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL);
-     return 0;
- 
-+  case WM_CHANGECBCHAIN:
-+    if ((hWnd == clipboard_wnd) &&
-+        (next_clipboard_wnd == (HWND)wParam)) {
-+      next_clipboard_wnd = (HWND)lParam;
-+      return 0;
-+    }
-+    break;
-+
-+  case WM_DRAWCLIPBOARD:
-+    // When the clipboard moves between two FLTK windows,
-+    // fl_i_own_selection will temporarily be false as we are
-+    // processing this message. Hence the need to use fl_find().
-+    if (!initial_clipboard && !fl_find(GetClipboardOwner()))
-+      fl_trigger_clipboard_notify(1);
-+    initial_clipboard = false;
-+
-+    if (next_clipboard_wnd)
-+      SendMessage(next_clipboard_wnd, WM_DRAWCLIPBOARD, wParam, lParam);
-+
-+    return 0;
-+
-   default:
-     if (Fl::handle(0,0)) return 0;
-     break;
-@@ -1685,6 +1738,8 @@
-   x->next = Fl_X::first;
-   Fl_X::first = x;
- 
-+  fl_clipboard_notify_target(x->xid);
-+
-   x->wait_for_expose = 1;
-   if (fl_show_iconic) {showit = 0; fl_show_iconic = 0;}
-   if (showit) {
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.0-icons.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.0-icons.patch
deleted file mode 100644
index 20b30b8..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.0-icons.patch
+++ /dev/null
@@ -1,645 +0,0 @@
-diff -ur fltk-1.3.2.org/FL/Fl_Window.H fltk-1.3.2/FL/Fl_Window.H
---- fltk-1.3.2.org/FL/Fl_Window.H	2013-01-16 10:49:40.904228200 +0100
-+++ fltk-1.3.2/FL/Fl_Window.H	2013-01-16 10:49:55.554353925 +0100
-@@ -22,6 +22,10 @@
- #ifndef Fl_Window_H
- #define Fl_Window_H
- 
-+#ifdef WIN32
-+#include <windows.h>
-+#endif
-+
- #include "Fl_Group.H"
- 
- #define FL_WINDOW 0xF0		///< window type id all subclasses have type() >= this
-@@ -73,9 +77,19 @@
-   friend class Fl_X;
-   Fl_X *i; // points at the system-specific stuff
- 
-+  struct icon_data {
-+    const void *legacy_icon;
-+    Fl_RGB_Image **icons;
-+    int count;
-+#ifdef WIN32
-+    HICON big_icon;
-+    HICON small_icon;
-+#endif
-+  };
-+
-   const char* iconlabel_;
-   char* xclass_;
--  const void* icon_;
-+  struct icon_data *icon_;
-   // size_range stuff:
-   int minw, minh, maxw, maxh;
-   int dw, dh, aspect;
-@@ -121,6 +135,8 @@
-   */
-   int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
- 
-+  void free_icons();
-+
- public:
- 
-   /**
-@@ -350,6 +366,18 @@
-   static const char *default_xclass();
-   const char* xclass() const;
-   void xclass(const char* c);
-+
-+  static void default_icon(const Fl_RGB_Image*);
-+  static void default_icons(const Fl_RGB_Image*[], int);
-+  void icon(const Fl_RGB_Image*);
-+  void icons(const Fl_RGB_Image*[], int);
-+
-+#ifdef WIN32
-+  static void default_icons(HICON big_icon, HICON small_icon);
-+  void icons(HICON big_icon, HICON small_icon);
-+#endif
-+
-+  /* for legacy compatibility */
-   const void* icon() const;
-   void icon(const void * ic);
- 
-diff -ur fltk-1.3.2.org/FL/mac.H fltk-1.3.2/FL/mac.H
---- fltk-1.3.2.org/FL/mac.H	2013-01-16 10:49:40.904228200 +0100
-+++ fltk-1.3.2/FL/mac.H	2013-01-16 10:49:55.554353925 +0100
-@@ -120,6 +120,9 @@
-   void collapse(void);
-   WindowRef window_ref(void);
-   void set_key_window(void);
-+  // OS X doesn't have per window icons
-+  static void set_default_icons(const Fl_RGB_Image*[], int) {};
-+  void set_icons() {};
-   int set_cursor(Fl_Cursor);
-   int set_cursor(const Fl_RGB_Image*, int, int);
-   static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
-diff -ur fltk-1.3.2.org/FL/win32.H fltk-1.3.2/FL/win32.H
---- fltk-1.3.2.org/FL/win32.H	2013-01-16 10:49:40.904228200 +0100
-+++ fltk-1.3.2/FL/win32.H	2013-01-16 10:49:55.555355617 +0100
-@@ -84,6 +84,9 @@
-   void flush() {w->flush();}
-   void set_minmax(LPMINMAXINFO minmax);
-   void mapraise();
-+  static void set_default_icons(const Fl_RGB_Image*[], int);
-+  static void set_default_icons(HICON, HICON);
-+  void set_icons();
-   int set_cursor(Fl_Cursor);
-   int set_cursor(const Fl_RGB_Image*, int, int);
-   static Fl_X* make(Fl_Window*);
-diff -ur fltk-1.3.2.org/FL/x.H fltk-1.3.2/FL/x.H
---- fltk-1.3.2.org/FL/x.H	2013-01-16 10:49:40.904228200 +0100
-+++ fltk-1.3.2/FL/x.H	2013-01-16 10:49:55.555355617 +0100
-@@ -154,6 +154,8 @@
-   static Fl_X* i(const Fl_Window* wi) {return wi->i;}
-   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
-   void sendxjunk();
-+  static void set_default_icons(const Fl_RGB_Image*[], int);
-+  void set_icons();
-   int set_cursor(Fl_Cursor);
-   int set_cursor(const Fl_RGB_Image*, int, int);
-   static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
-diff -ur fltk-1.3.2.org/src/Fl.cxx fltk-1.3.2/src/Fl.cxx
---- fltk-1.3.2.org/src/Fl.cxx	2013-01-16 10:49:40.895228113 +0100
-+++ fltk-1.3.2/src/Fl.cxx	2013-01-16 10:49:55.556137979 +0100
-@@ -1530,6 +1530,8 @@
-   if (xclass_) {
-     free(xclass_);
-   }
-+  free_icons();
-+  delete icon_;
- }
- 
- // FL_SHOW and FL_HIDE are called whenever the visibility of this widget
-diff -ur fltk-1.3.2.org/src/Fl_win32.cxx fltk-1.3.2/src/Fl_win32.cxx
---- fltk-1.3.2.org/src/Fl_win32.cxx	2013-01-16 10:49:40.911227539 +0100
-+++ fltk-1.3.2/src/Fl_win32.cxx	2013-01-16 10:49:55.556137979 +0100
-@@ -1804,6 +1804,8 @@
-   );
-   if (lab) free(lab);
- 
-+  x->set_icons();
-+
-   if (w->fullscreen_active()) {
-   /* We need to make sure that the fullscreen is created on the
-      default monitor, ie the desktop where the shortcut is located
-@@ -2034,71 +2036,19 @@
- 
- ////////////////////////////////////////////////////////////////
- 
--#ifndef IDC_HAND
--#  define IDC_HAND  MAKEINTRESOURCE(32649)
--#endif // !IDC_HAND
--
--int Fl_X::set_cursor(Fl_Cursor c) {
--  LPSTR n;
--  HCURSOR new_cursor;
--
--  if (c == FL_CURSOR_NONE)
--    new_cursor = NULL;
--  else {
--    switch (c) {
--    case FL_CURSOR_ARROW:   n = IDC_ARROW; break;
--    case FL_CURSOR_CROSS:   n = IDC_CROSS; break;
--    case FL_CURSOR_WAIT:    n = IDC_WAIT; break;
--    case FL_CURSOR_INSERT:  n = IDC_IBEAM; break;
--    case FL_CURSOR_HAND:    n = IDC_HAND; break;
--    case FL_CURSOR_HELP:    n = IDC_HELP; break;
--    case FL_CURSOR_MOVE:    n = IDC_SIZEALL; break;
--    case FL_CURSOR_N:
--    case FL_CURSOR_S:
--      // FIXME: Should probably have fallbacks for these instead
--    case FL_CURSOR_NS:      n = IDC_SIZENS; break;
--    case FL_CURSOR_NE:
--    case FL_CURSOR_SW:
--      // FIXME: Dito.
--    case FL_CURSOR_NESW:    n = IDC_SIZENESW; break;
--    case FL_CURSOR_E:
--    case FL_CURSOR_W:
--      // FIXME: Dito.
--    case FL_CURSOR_WE:      n = IDC_SIZEWE; break;
--    case FL_CURSOR_SE:
--    case FL_CURSOR_NW:
--      // FIXME: Dito.
--    case FL_CURSOR_NWSE:    n = IDC_SIZENWSE; break;
--    default:
--      return 0;
--    }
--
--    new_cursor = LoadCursor(NULL, n);
--    if (new_cursor == NULL)
--      return 0;
--  }
--
--  if ((cursor != NULL) && custom_cursor)
--    DestroyIcon(cursor);
--
--  cursor = new_cursor;
--  custom_cursor = 0;
--
--  SetCursor(cursor);
--
--  return 1;
--}
--
--int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
-+static HICON image_to_icon(const Fl_RGB_Image *image, bool is_icon=true,
-+                           int hotx = 0, int hoty = 0) {
-   BITMAPV5HEADER bi;
-   HBITMAP bitmap, mask;
-   DWORD *bits;
--  HCURSOR new_cursor;
-+  HICON icon;
- 
-+  if (!is_icon) {
-   if ((hotx < 0) || (hotx >= image->w()))
--    return 0;
-+      return NULL;
-   if ((hoty < 0) || (hoty >= image->h()))
--    return 0;
-+      return NULL;
-+  }
- 
-   memset(&bi, 0, sizeof(BITMAPV5HEADER));
- 
-@@ -2120,7 +2070,7 @@
-   ReleaseDC(NULL, hdc);
- 
-   if (bits == NULL)
--    return 0;
-+    return NULL;
- 
-   const uchar *i = (const uchar*)*image->data();
-   for (int y = 0;y < image->h();y++) {
-@@ -2149,22 +2099,206 @@
-   mask = CreateBitmap(image->w(),image->h(),1,1,NULL);
-   if (mask == NULL) {
-     DeleteObject(bitmap);
--    return 0;
-+    return NULL;
-   }
- 
-   ICONINFO ii;
- 
--  ii.fIcon    = FALSE;
-+  ii.fIcon    = is_icon;
-   ii.xHotspot = hotx;
-   ii.yHotspot = hoty;
-   ii.hbmMask  = mask;
-   ii.hbmColor = bitmap;
- 
--  new_cursor = CreateIconIndirect(&ii);
-+  icon = CreateIconIndirect(&ii);
- 
-   DeleteObject(bitmap);
-   DeleteObject(mask);
- 
-+  if (icon == NULL)
-+    return NULL;
-+
-+  return icon;
-+}
-+
-+////////////////////////////////////////////////////////////////
-+
-+static HICON default_big_icon = NULL;
-+static HICON default_small_icon = NULL;
-+
-+const Fl_RGB_Image *find_best_icon(int ideal_width, 
-+                                   const Fl_RGB_Image *icons[], int count) {
-+  const Fl_RGB_Image *best;
-+
-+  best = NULL;
-+
-+  for (int i = 0;i < count;i++) {
-+    if (best == NULL)
-+      best = icons[i];
-+    else {
-+      if (best->w() < ideal_width) {
-+        if (icons[i]->w() > best->w())
-+          best = icons[i];
-+      } else {
-+        if ((icons[i]->w() >= ideal_width) &&
-+            (icons[i]->w() < best->w()))
-+          best = icons[i];
-+      }
-+    }
-+  }
-+
-+  return best;
-+}
-+
-+void Fl_X::set_default_icons(const Fl_RGB_Image *icons[], int count) {
-+  const Fl_RGB_Image *best_big, *best_small;
-+
-+  if (default_big_icon != NULL)
-+    DestroyIcon(default_big_icon);
-+  if (default_small_icon != NULL)
-+    DestroyIcon(default_small_icon);
-+
-+  best_big = find_best_icon(GetSystemMetrics(SM_CXICON), icons, count);
-+  best_small = find_best_icon(GetSystemMetrics(SM_CXSMICON), icons, count);
-+
-+  if (best_big != NULL)
-+    default_big_icon = image_to_icon(best_big);
-+  else
-+    default_big_icon = NULL;
-+
-+  if (best_small != NULL)
-+    default_small_icon = image_to_icon(best_small);
-+  else
-+    default_small_icon = NULL;
-+}
-+
-+void Fl_X::set_default_icons(HICON big_icon, HICON small_icon) {
-+  if (default_big_icon != NULL)
-+    DestroyIcon(default_big_icon);
-+  if (default_small_icon != NULL)
-+    DestroyIcon(default_small_icon);
-+
-+  if (big_icon != NULL)
-+    default_big_icon = CopyIcon(big_icon);
-+  if (small_icon != NULL)
-+    default_small_icon = CopyIcon(small_icon);
-+}
-+
-+void Fl_X::set_icons() {
-+  HICON big_icon, small_icon;
-+
-+  big_icon = NULL;
-+  small_icon = NULL;
-+
-+  if (w->icon_->count) {
-+    const Fl_RGB_Image *best_big, *best_small;
-+
-+    best_big = find_best_icon(GetSystemMetrics(SM_CXICON),
-+                              (const Fl_RGB_Image **)w->icon_->icons,
-+                              w->icon_->count);
-+    best_small = find_best_icon(GetSystemMetrics(SM_CXSMICON),
-+                                (const Fl_RGB_Image **)w->icon_->icons,
-+                                w->icon_->count);
-+
-+    if (best_big != NULL)
-+      big_icon = image_to_icon(best_big);
-+    if (best_small != NULL)
-+      small_icon = image_to_icon(best_small);
-+  } else {
-+    big_icon = default_big_icon;
-+    small_icon = default_small_icon;
-+  }
-+
-+  if (big_icon != NULL)
-+    SendMessage(xid, WM_SETICON, ICON_BIG, (LPARAM)big_icon);
-+  if (small_icon != NULL)
-+    SendMessage(xid, WM_SETICON, ICON_SMALL, (LPARAM)small_icon);
-+
-+  if (w->icon_->count) {
-+    if (big_icon != NULL)
-+      DestroyIcon(big_icon);
-+    if (small_icon != NULL)
-+      DestroyIcon(small_icon);
-+  }
-+}
-+
-+void Fl_Window::default_icons(HICON big_icon, HICON small_icon) {
-+  Fl_X::set_default_icons(big_icon, small_icon);
-+}
-+
-+void Fl_Window::icons(HICON big_icon, HICON small_icon) {
-+  free_icons();
-+
-+  if (big_icon != NULL)
-+    icon_->big_icon = CopyIcon(big_icon);
-+  if (small_icon != NULL)
-+    icon_->small_icon = CopyIcon(small_icon);
-+
-+  if (i)
-+    i->set_icons();
-+}
-+
-+////////////////////////////////////////////////////////////////
-+
-+#ifndef IDC_HAND
-+#  define IDC_HAND  MAKEINTRESOURCE(32649)
-+#endif // !IDC_HAND
-+
-+int Fl_X::set_cursor(Fl_Cursor c) {
-+  LPSTR n;
-+  HCURSOR new_cursor;
-+
-+  if (c == FL_CURSOR_NONE)
-+    new_cursor = NULL;
-+  else {
-+    switch (c) {
-+    case FL_CURSOR_ARROW:   n = IDC_ARROW; break;
-+    case FL_CURSOR_CROSS:   n = IDC_CROSS; break;
-+    case FL_CURSOR_WAIT:    n = IDC_WAIT; break;
-+    case FL_CURSOR_INSERT:  n = IDC_IBEAM; break;
-+    case FL_CURSOR_HAND:    n = IDC_HAND; break;
-+    case FL_CURSOR_HELP:    n = IDC_HELP; break;
-+    case FL_CURSOR_MOVE:    n = IDC_SIZEALL; break;
-+    case FL_CURSOR_N:
-+    case FL_CURSOR_S:
-+      // FIXME: Should probably have fallbacks for these instead
-+    case FL_CURSOR_NS:      n = IDC_SIZENS; break;
-+    case FL_CURSOR_NE:
-+    case FL_CURSOR_SW:
-+      // FIXME: Dito.
-+    case FL_CURSOR_NESW:    n = IDC_SIZENESW; break;
-+    case FL_CURSOR_E:
-+    case FL_CURSOR_W:
-+      // FIXME: Dito.
-+    case FL_CURSOR_WE:      n = IDC_SIZEWE; break;
-+    case FL_CURSOR_SE:
-+    case FL_CURSOR_NW:
-+      // FIXME: Dito.
-+    case FL_CURSOR_NWSE:    n = IDC_SIZENWSE; break;
-+    default:
-+      return 0;
-+    }
-+
-+    new_cursor = LoadCursor(NULL, n);
-+    if (new_cursor == NULL)
-+      return 0;
-+  }
-+
-+  if ((cursor != NULL) && custom_cursor)
-+    DestroyIcon(cursor);
-+
-+  cursor = new_cursor;
-+  custom_cursor = 0;
-+
-+  SetCursor(cursor);
-+
-+  return 1;
-+}
-+
-+int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
-+  HCURSOR new_cursor;
-+
-+  new_cursor = image_to_icon(image, false, hotx, hoty);
-   if (new_cursor == NULL)
-     return 0;
- 
-diff -ur fltk-1.3.2.org/src/Fl_Window.cxx fltk-1.3.2/src/Fl_Window.cxx
---- fltk-1.3.2.org/src/Fl_Window.cxx	2013-01-16 10:49:40.908130903 +0100
-+++ fltk-1.3.2/src/Fl_Window.cxx	2013-01-16 10:49:55.557353865 +0100
-@@ -23,6 +23,7 @@
- #include <config.h>
- #include <FL/Fl.H>
- #include <FL/x.H>
-+#include <FL/Fl_RGB_Image.H>
- #include <FL/Fl_Window.H>
- #include <stdlib.h>
- #include "flstring.h"
-@@ -45,7 +46,8 @@
-   }
-   i = 0;
-   xclass_ = 0;
--  icon_ = 0;
-+  icon_ = new icon_data;
-+  memset(icon_, 0, sizeof(*icon_));
-   iconlabel_ = 0;
-   resizable(0);
-   size_range_set = 0;
-@@ -264,16 +266,68 @@
-   }
- }
- 
-+void Fl_Window::default_icon(const Fl_RGB_Image *icon) {
-+  default_icons(&icon, 1);
-+}
-+
-+void Fl_Window::default_icons(const Fl_RGB_Image **icons, int count) {
-+  Fl_X::set_default_icons(icons, count);
-+}
-+
-+void Fl_Window::icon(const Fl_RGB_Image *icon) {
-+  icons(&icon, 1);
-+}
-+
-+void Fl_Window::icons(const Fl_RGB_Image **icons, int count) {
-+  free_icons();
-+
-+  if (count > 0) {
-+    icon_->icons = new Fl_RGB_Image*[count];
-+    icon_->count = count;
-+    // FIXME: Fl_RGB_Image lacks const modifiers on methods
-+    for (int i = 0;i < count;i++)
-+      icon_->icons[i] = (Fl_RGB_Image*)((Fl_RGB_Image*)icons[i])->copy();
-+  }
-+
-+  if (i)
-+    i->set_icons();
-+}
-+
- /** Gets the current icon window target dependent data. */
- const void *Fl_Window::icon() const {
--  return icon_;
-+  return icon_->legacy_icon;
- }
- 
- /** Sets the current icon window target dependent data. */
- void Fl_Window::icon(const void * ic) {
--  icon_ = ic;
-+  free_icons();
-+  icon_->legacy_icon = ic;
- }
- 
-+void Fl_Window::free_icons() {
-+  int i;
-+
-+  icon_->legacy_icon = 0L;
-+
-+  if (icon_->icons) {
-+    for (i = 0;i < icon_->count;i++)
-+      delete icon_->icons[i];
-+    delete [] icon_->icons;
-+    icon_->icons = 0L;
-+  }
-+
-+  icon_->count = 0;
-+
-+#ifdef WIN32
-+  if (icon_->big_icon)
-+    DestroyIcon(icon_->big_icon);
-+  if (icon_->small_icon)
-+    DestroyIcon(icon_->small_icon);
-+
-+  icon_->big_icon = NULL;
-+  icon_->small_icon = NULL;
-+#endif
-+}
- 
- //
- // End of "$Id: Fl_Window.cxx 9706 2012-11-06 20:46:14Z matt $".
-diff -ur fltk-1.3.2.org/src/Fl_x.cxx fltk-1.3.2/src/Fl_x.cxx
---- fltk-1.3.2.org/src/Fl_x.cxx	2013-01-16 10:49:40.912227213 +0100
-+++ fltk-1.3.2/src/Fl_x.cxx	2013-01-16 10:49:55.558137113 +0100
-@@ -345,6 +345,7 @@
- Atom fl_NET_WM_STATE;
- Atom fl_NET_WM_STATE_FULLSCREEN;
- Atom fl_NET_WORKAREA;
-+Atom fl_NET_WM_ICON;
- 
- /*
-   X defines 32-bit-entities to have a format value of max. 32,
-@@ -709,6 +710,7 @@
-   fl_NET_WM_STATE       = XInternAtom(d, "_NET_WM_STATE",       0);
-   fl_NET_WM_STATE_FULLSCREEN = XInternAtom(d, "_NET_WM_STATE_FULLSCREEN", 0);
-   fl_NET_WORKAREA       = XInternAtom(d, "_NET_WORKAREA",       0);
-+  fl_NET_WM_ICON        = XInternAtom(d, "_NET_WM_ICON",        0);
- 
-   if (sizeof(Atom) < 4)
-     atom_bits = sizeof(Atom) * 8;
-@@ -2138,12 +2140,14 @@
-       fl_show_iconic = 0;
-       showit = 0;
-     }
--    if (win->icon()) {
--      hints->icon_pixmap = (Pixmap)win->icon();
-+    if (win->icon_->legacy_icon) {
-+      hints->icon_pixmap = (Pixmap)win->icon_->legacy_icon;
-       hints->flags       |= IconPixmapHint;
-     }
-     XSetWMHints(fl_display, xp->xid, hints);
-     XFree(hints);
-+
-+    xp->set_icons();
-   }
- 
-   // set the window type for menu and tooltip windows to avoid animations (compiz)
-@@ -2263,6 +2267,93 @@
- 
- ////////////////////////////////////////////////////////////////
- 
-+static unsigned long *default_net_wm_icons = 0L;
-+static size_t default_net_wm_icons_size = 0;
-+
-+void icons_to_property(const Fl_RGB_Image *icons[], int count,
-+                       unsigned long **property, size_t *len) {
-+  size_t sz;
-+  unsigned long *data;
-+
-+  sz = 0;
-+  for (int i = 0;i < count;i++)
-+    sz += 2 + icons[i]->w() * icons[i]->h();
-+
-+  // FIXME: Might want to sort the icons
-+
-+  *property = data = new unsigned long[sz];
-+  *len = sz;
-+
-+  for (int i = 0;i < count;i++) {
-+    const Fl_RGB_Image *image;
-+
-+    image = icons[i];
-+
-+    data[0] = image->w();
-+    data[1] = image->h();
-+    data += 2;
-+
-+    const uchar *in = (const uchar*)*image->data();
-+    for (int y = 0;y < image->h();y++) {
-+      for (int x = 0;x < image->w();x++) {
-+        switch (image->d()) {
-+        case 1:
-+          *data = ( 0xff<<24) | (in[0]<<16) | (in[0]<<8) | in[0];
-+          break;
-+        case 2:
-+          *data = (in[1]<<24) | (in[0]<<16) | (in[0]<<8) | in[0];
-+          break;
-+        case 3:
-+          *data = ( 0xff<<24) | (in[0]<<16) | (in[1]<<8) | in[2];
-+          break;
-+        case 4:
-+          *data = (in[3]<<24) | (in[0]<<16) | (in[1]<<8) | in[2];
-+          break;
-+        }
-+        in += image->d();
-+        data++;
-+      }
-+      in += image->ld();
-+    }
-+  }
-+}
-+
-+void Fl_X::set_default_icons(const Fl_RGB_Image *icons[], int count) {
-+  if (default_net_wm_icons) {
-+    delete [] default_net_wm_icons;
-+    default_net_wm_icons = 0L;
-+    default_net_wm_icons_size = 0;
-+  }
-+
-+  if (count > 0)
-+    icons_to_property(icons, count,
-+                      &default_net_wm_icons, &default_net_wm_icons_size);
-+}
-+
-+void Fl_X::set_icons() {
-+  unsigned long *net_wm_icons;
-+  size_t net_wm_icons_size;
-+
-+  if (w->icon_->count) {
-+    icons_to_property((const Fl_RGB_Image **)w->icon_->icons, w->icon_->count,
-+                      &net_wm_icons, &net_wm_icons_size);
-+  } else {
-+    net_wm_icons = default_net_wm_icons;
-+    net_wm_icons_size = default_net_wm_icons_size;
-+  }
-+
-+  XChangeProperty (fl_display, xid, fl_NET_WM_ICON, XA_CARDINAL, 32,
-+      PropModeReplace, (unsigned char*) net_wm_icons, net_wm_icons_size);
-+
-+  if (w->icon_->count) {
-+    delete [] net_wm_icons;
-+    net_wm_icons = 0L;
-+    net_wm_icons_size = 0;
-+  }
-+}
-+
-+////////////////////////////////////////////////////////////////
-+
- int Fl_X::set_cursor(Fl_Cursor c) {
-   unsigned int shape;
-   Cursor xc;
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch
deleted file mode 100644
index b41af79..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-diff -ur fltk-1.3.0r9110.org/src/Fl_win32.cxx fltk-1.3.0r9110/src/Fl_win32.cxx
---- fltk-1.3.0r9110.org/src/Fl_win32.cxx	2012-06-17 19:42:02.169422400 +0200
-+++ fltk-1.3.0r9110/src/Fl_win32.cxx	2012-06-17 19:43:38.286031455 +0200
-@@ -543,6 +543,37 @@
-   const char* GetValue() const { return(out); }
- };
- 
-+void fl_update_clipboard(void) {
-+  Fl_Window *w1 = Fl::first_window();
-+  if (!w1)
-+    return;
-+
-+  HWND hwnd = fl_xid(w1);
-+
-+  if (!OpenClipboard(hwnd))
-+    return;
-+
-+  EmptyClipboard();
-+
-+  int utf16_len = fl_utf8toUtf16(fl_selection_buffer[1],
-+                                 fl_selection_length[1], 0, 0);
-+
-+  HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and zero'ed mem alloc.
-+  LPVOID memLock = GlobalLock(hMem);
-+
-+  fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1],
-+                 (unsigned short*) memLock, utf16_len + 1);
-+
-+  GlobalUnlock(hMem);
-+  SetClipboardData(CF_UNICODETEXT, hMem);
-+
-+  CloseClipboard();
-+
-+  // In case Windows managed to lob of a WM_DESTROYCLIPBOARD during
-+  // the above.
-+  fl_i_own_selection[1] = 1;
-+}
-+
- // call this when you create a selection:
- void Fl::copy(const char *stuff, int len, int clipboard) {
-   if (!stuff || len<0) return;
-@@ -560,25 +591,9 @@
-   memcpy(fl_selection_buffer[clipboard], stuff, len);
-   fl_selection_buffer[clipboard][len] = 0; // needed for direct paste
-   fl_selection_length[clipboard] = len;
--  if (clipboard) {
--    // set up for "delayed rendering":
--    if (OpenClipboard(NULL)) {
--      // if the system clipboard works, use it
--      int utf16_len = fl_utf8toUtf16(fl_selection_buffer[clipboard], fl_selection_length[clipboard], 0, 0);
--      EmptyClipboard();
--      HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and zero'ed mem alloc.
--      LPVOID memLock = GlobalLock(hMem);
--      fl_utf8toUtf16(fl_selection_buffer[clipboard], fl_selection_length[clipboard], (unsigned short*) memLock, utf16_len + 1);
--      GlobalUnlock(hMem);
--      SetClipboardData(CF_UNICODETEXT, hMem);
--      CloseClipboard();
--      GlobalFree(hMem);
--      fl_i_own_selection[clipboard] = 0;
--    } else {
--      // only if it fails, instruct paste() to use the internal buffers
--      fl_i_own_selection[clipboard] = 1;
--    }
--  }
-+  fl_i_own_selection[clipboard] = 1;
-+  if (clipboard)
-+    fl_update_clipboard();
- }
- 
- // Call this when a "paste" operation happens:
-@@ -1307,33 +1322,6 @@
-     fl_i_own_selection[1] = 0;
-     return 1;
- 
--  case WM_RENDERALLFORMATS:
--    fl_i_own_selection[1] = 0;
--    // Windoze seems unhappy unless I do these two steps. Documentation
--    // seems to vary on whether opening the clipboard is necessary or
--    // is in fact wrong:
--    CloseClipboard();
--    OpenClipboard(NULL);
--    // fall through...
--  case WM_RENDERFORMAT: {
--    HANDLE h;
--
--//  int l = fl_utf_nb_char((unsigned char*)fl_selection_buffer[1], fl_selection_length[1]);
--    int l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], NULL, 0); // Pass NULL buffer to query length required
--    h = GlobalAlloc(GHND, (l+1) * sizeof(unsigned short));
--    if (h) {
--      unsigned short *g = (unsigned short*) GlobalLock(h);
--//    fl_utf2unicode((unsigned char *)fl_selection_buffer[1], fl_selection_length[1], (xchar*)g);
--      l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], g, (l+1));
--      g[l] = 0;
--      GlobalUnlock(h);
--      SetClipboardData(CF_UNICODETEXT, h);
--    }
--
--    // Windoze also seems unhappy if I don't do this. Documentation very
--    // unclear on what is correct:
--    if (fl_msg.message == WM_RENDERALLFORMATS) CloseClipboard();
--    return 1;}
-   case WM_DISPLAYCHANGE: // occurs when screen configuration (number, position) changes
-     Fl::call_screen_init();
-     Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL);
-diff -ur fltk-1.3.0r9110.org/src/Fl.cxx fltk-1.3.0r9110/src/Fl.cxx
---- fltk-1.3.0r9110.org/src/Fl.cxx	2012-06-17 19:42:02.173422595 +0200
-+++ fltk-1.3.0r9110/src/Fl.cxx	2012-06-17 19:42:02.317429497 +0200
-@@ -1420,7 +1420,9 @@
- ////////////////////////////////////////////////////////////////
- // hide() destroys the X window, it does not do unmap!
- 
--#if !defined(WIN32) && USE_XFT
-+#if defined(WIN32)
-+extern void fl_update_clipboard(void);
-+#elif USE_XFT
- extern void fl_destroy_xft_draw(Window);
- #endif
- 
-@@ -1467,14 +1469,8 @@
- #if defined(WIN32)
-   // this little trick keeps the current clipboard alive, even if we are about
-   // to destroy the window that owns the selection.
--  if (GetClipboardOwner()==ip->xid) {
--    Fl_Window *w1 = Fl::first_window();
--    if (w1 && OpenClipboard(fl_xid(w1))) {
--      EmptyClipboard();
--      SetClipboardData(CF_TEXT, NULL);
--      CloseClipboard();
--    }
--  }
-+  if (GetClipboardOwner()==ip->xid)
-+    fl_update_clipboard();
-   // Send a message to myself so that I'll get out of the event loop...
-   PostMessage(ip->xid, WM_APP, 0, 0);
-   if (ip->private_dc) fl_release_dc(ip->xid, ip->private_dc);
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-multihead.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-multihead.patch
deleted file mode 100644
index e4a010a..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-multihead.patch
+++ /dev/null
@@ -1,468 +0,0 @@
-diff -urp fltk-1.3.2.org/FL/Fl_Window.H fltk-1.3.2/FL/Fl_Window.H
---- fltk-1.3.2.org/FL/Fl_Window.H	2013-01-16 10:52:33.017228122 +0100
-+++ fltk-1.3.2/FL/Fl_Window.H	2013-01-16 10:52:47.876478968 +0100
-@@ -54,7 +54,7 @@ class Fl_RGB_Image;
- class FL_EXPORT Fl_Window : public Fl_Group {
- 
-   static char *default_xclass_;
--  // Note: we must use separate statements for each of the following 4 variables,
-+  // Note: we must use separate statements for each of the following 8 variables,
-   // with the static attribute, otherwise MS VC++ 2008/2010 complains :-(
-   // AlbrechtS 04/2012
- #if FLTK_ABI_VERSION < 10301
-@@ -73,6 +73,22 @@ class FL_EXPORT Fl_Window : public Fl_Gr
-   static // when these members are static, ABI compatibility with 1.3.0 is respected
- #endif
-   int no_fullscreen_h;
-+#if FLTK_ABI_VERSION < 10302
-+  static // when these members are static, ABI compatibility with 1.3.0 is respected
-+#endif
-+  int fullscreen_screen_top;
-+#if FLTK_ABI_VERSION < 10302
-+  static // when these members are static, ABI compatibility with 1.3.0 is respected
-+#endif
-+  int fullscreen_screen_bottom;
-+#if FLTK_ABI_VERSION < 10302
-+  static // when these members are static, ABI compatibility with 1.3.0 is respected
-+#endif
-+  int fullscreen_screen_left;
-+#if FLTK_ABI_VERSION < 10302
-+  static // when these members are static, ABI compatibility with 1.3.0 is respected
-+#endif
-+  int fullscreen_screen_right;
- 
-   friend class Fl_X;
-   Fl_X *i; // points at the system-specific stuff
-@@ -430,13 +446,15 @@ public:
-   */
-   void show(int argc, char **argv);
-   /**
--    Makes the window completely fill the screen, without any window
--    manager border visible.  You must use fullscreen_off() to undo
--    this. 
-+    Makes the window completely fill one or more screens, without any
-+    window manager border visible.  You must use fullscreen_off() to
-+    undo this. 
- 
-     \note On some platforms, this can result in the keyboard being
-     grabbed. The window may also be recreated, meaning hide() and
-     show() will be called.
-+
-+    \see void Fl_Window::fullscreen_screens()
-   */
-   void fullscreen();
-   /**
-@@ -453,6 +471,17 @@ public:
-   */
-   unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
-   /**
-+    Sets which screens should be used when this window is in fullscreen
-+    mode. The window will be resized to the top of the screen with index
-+    \p top, the bottom of the screen with index \p bottom, etc. 
-+
-+    If this method is never called, or if any argument is < 0, then the
-+    window will be resized to fill the screen it is currently on.
-+
-+    \see void Fl_Window::fullscreen()
-+    */
-+  void fullscreen_screens(int top, int bottom, int left, int right);
-+  /**
-     Iconifies the window.  If you call this when shown() is false
-     it will show() it as an icon.  If the window is already
-     iconified this does nothing.
-diff -urp fltk-1.3.2.org/FL/win32.H fltk-1.3.2/FL/win32.H
---- fltk-1.3.2.org/FL/win32.H	2013-01-16 10:52:33.017228122 +0100
-+++ fltk-1.3.2/FL/win32.H	2013-01-16 10:52:47.876478968 +0100
-@@ -80,6 +80,7 @@ public:
-   static Fl_X* i(const Fl_Window* w) {return w->i;}
-   static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
- 		                 int &bt,int &bx,int &by);
-+  void make_fullscreen(int X, int Y, int W, int H);
-   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
-   void flush() {w->flush();}
-   void set_minmax(LPMINMAXINFO minmax);
-diff -urp fltk-1.3.2.org/src/Fl_cocoa.mm fltk-1.3.2/src/Fl_cocoa.mm
---- fltk-1.3.2.org/src/Fl_cocoa.mm	2013-01-16 10:52:33.014229574 +0100
-+++ fltk-1.3.2/src/Fl_cocoa.mm	2013-01-16 10:52:47.877480606 +0100
-@@ -2438,9 +2438,32 @@ void Fl_X::make(Fl_Window* w)
- 	  
-     NSRect crect;
-     if (w->fullscreen_active()) {
--      int sx, sy, sw, sh;
--      Fl::screen_xywh(sx, sy, sw, sh, w->x(), w->y(), w->w(), w->h());
--      w->resize(sx, sy, sw, sh);
-+      int top, bottom, left, right;
-+      int sx, sy, sw, sh, X, Y, W, H;
-+
-+      top = w->fullscreen_screen_top;
-+      bottom = w->fullscreen_screen_bottom;
-+      left = w->fullscreen_screen_left;
-+      right = w->fullscreen_screen_right;
-+
-+      if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
-+        top = Fl::screen_num(w->x(), w->y(), w->w(), w->h());
-+        bottom = top;
-+        left = top;
-+        right = top;
-+      }
-+
-+      Fl::screen_xywh(sx, sy, sw, sh, top);
-+      Y = sy;
-+      Fl::screen_xywh(sx, sy, sw, sh, bottom);
-+      H = sy + sh - Y;
-+      Fl::screen_xywh(sx, sy, sw, sh, left);
-+      X = sx;
-+      Fl::screen_xywh(sx, sy, sw, sh, right);
-+      W = sx + sw - X;
-+
-+      w->resize(X, Y, W, H);
-+
-       winstyle = NSBorderlessWindowMask;
-       winlevel = NSStatusWindowLevel;
-     }
-diff -urp fltk-1.3.2.org/src/Fl_win32.cxx fltk-1.3.2/src/Fl_win32.cxx
---- fltk-1.3.2.org/src/Fl_win32.cxx	2013-01-16 10:52:33.019230734 +0100
-+++ fltk-1.3.2/src/Fl_win32.cxx	2013-01-16 10:52:47.878480504 +0100
-@@ -1493,7 +1493,6 @@ int Fl_X::fake_X_wm(const Fl_Window* w,i
-   Y+=yoff;
- 
-   if (w->fullscreen_active()) {
--    X = Y = 0;
-     bx = by = bt = 0;
-   }
- 
-@@ -1547,19 +1546,42 @@ void Fl_Window::resize(int X,int Y,int W
-   }
- }
- 
--static void make_fullscreen(Fl_Window *w, Window xid, int X, int Y, int W, int H) {
-+void Fl_X::make_fullscreen(int X, int Y, int W, int H) {
-+  int top, bottom, left, right;
-   int sx, sy, sw, sh;
--  Fl::screen_xywh(sx, sy, sw, sh, X, Y, W, H);
-+
-+  top = w->fullscreen_screen_top;
-+  bottom = w->fullscreen_screen_bottom;
-+  left = w->fullscreen_screen_left;
-+  right = w->fullscreen_screen_right;
-+
-+  if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
-+    top = Fl::screen_num(X, Y, W, H);
-+    bottom = top;
-+    left = top;
-+    right = top;
-+  }
-+
-+  Fl::screen_xywh(sx, sy, sw, sh, top);
-+  Y = sy;
-+  Fl::screen_xywh(sx, sy, sw, sh, bottom);
-+  H = sy + sh - Y;
-+  Fl::screen_xywh(sx, sy, sw, sh, left);
-+  X = sx;
-+  Fl::screen_xywh(sx, sy, sw, sh, right);
-+  W = sx + sw - X;
-+
-   DWORD flags = GetWindowLong(xid, GWL_STYLE);
-   flags = flags & ~(WS_THICKFRAME|WS_CAPTION);
-   SetWindowLong(xid, GWL_STYLE, flags);
-+
-   // SWP_NOSENDCHANGING is so that we can override size limits
--  SetWindowPos(xid, HWND_TOP, sx, sy, sw, sh, SWP_NOSENDCHANGING | SWP_FRAMECHANGED);
-+  SetWindowPos(xid, HWND_TOP, X, Y, W, H, SWP_NOSENDCHANGING | SWP_FRAMECHANGED);
- }
- 
- void Fl_Window::fullscreen_x() {
-   _set_fullscreen();
--  make_fullscreen(this, fl_xid(this), x(), y(), w(), h());
-+  i->make_fullscreen(x(), y(), w(), h());
-   Fl::handle(FL_FULLSCREEN, this);
- }
- 
-@@ -1814,8 +1836,8 @@ Fl_X* Fl_X::make(Fl_Window* w) {
-      monitor the window was placed on. */
-     RECT rect;
-     GetWindowRect(x->xid, &rect);
--    make_fullscreen(w, x->xid, rect.left, rect.top, 
--                    rect.right - rect.left, rect.bottom - rect.top);
-+    x->make_fullscreen(rect.left, rect.top, 
-+                       rect.right - rect.left, rect.bottom - rect.top);
-   }
- 
-   x->next = Fl_X::first;
-diff -urp fltk-1.3.2.org/src/Fl_Window_fullscreen.cxx fltk-1.3.2/src/Fl_Window_fullscreen.cxx
---- fltk-1.3.2.org/src/Fl_Window_fullscreen.cxx	2012-11-06 21:46:14.000000000 +0100
-+++ fltk-1.3.2/src/Fl_Window_fullscreen.cxx	2013-01-16 10:52:47.879480608 +0100
-@@ -36,6 +36,10 @@ int Fl_Window::no_fullscreen_x = 0;
- int Fl_Window::no_fullscreen_y = 0;
- int Fl_Window::no_fullscreen_w = 0;
- int Fl_Window::no_fullscreen_h = 0;
-+int Fl_Window::fullscreen_screen_top = -1;
-+int Fl_Window::fullscreen_screen_bottom = -1;
-+int Fl_Window::fullscreen_screen_left = -1;
-+int Fl_Window::fullscreen_screen_right = -1;
- #endif
- 
- void Fl_Window::border(int b) {
-@@ -95,6 +99,23 @@ void Fl_Window::fullscreen_off() {
-   fullscreen_off(no_fullscreen_x, no_fullscreen_y, no_fullscreen_w, no_fullscreen_h);
- }
- 
-+void Fl_Window::fullscreen_screens(int top, int bottom, int left, int right) {
-+  if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
-+    fullscreen_screen_top = -1;
-+    fullscreen_screen_bottom = -1;
-+    fullscreen_screen_left = -1;
-+    fullscreen_screen_right = -1;
-+  } else {
-+    fullscreen_screen_top = top;
-+    fullscreen_screen_bottom = bottom;
-+    fullscreen_screen_left = left;
-+    fullscreen_screen_right = right;
-+  }
-+
-+  if (shown() && (flags() & Fl_Widget::FULLSCREEN))
-+    fullscreen_x();
-+}
-+
- 
- //
- // End of "$Id: Fl_Window_fullscreen.cxx 9706 2012-11-06 20:46:14Z matt $".
-diff -urp fltk-1.3.2.org/src/Fl_x.cxx fltk-1.3.2/src/Fl_x.cxx
---- fltk-1.3.2.org/src/Fl_x.cxx	2013-01-16 10:52:33.020228202 +0100
-+++ fltk-1.3.2/src/Fl_x.cxx	2013-01-16 10:52:47.880480556 +0100
-@@ -344,6 +344,7 @@ Atom fl_NET_WM_ICON_NAME;		// utf8 aware
- Atom fl_NET_SUPPORTING_WM_CHECK;
- Atom fl_NET_WM_STATE;
- Atom fl_NET_WM_STATE_FULLSCREEN;
-+Atom fl_NET_WM_FULLSCREEN_MONITORS;
- Atom fl_NET_WORKAREA;
- Atom fl_NET_WM_ICON;
- 
-@@ -709,6 +710,7 @@ void fl_open_display(Display* d) {
-   fl_NET_SUPPORTING_WM_CHECK = XInternAtom(d, "_NET_SUPPORTING_WM_CHECK", 0);
-   fl_NET_WM_STATE       = XInternAtom(d, "_NET_WM_STATE",       0);
-   fl_NET_WM_STATE_FULLSCREEN = XInternAtom(d, "_NET_WM_STATE_FULLSCREEN", 0);
-+  fl_NET_WM_FULLSCREEN_MONITORS = XInternAtom(d, "_NET_WM_FULLSCREEN_MONITORS", 0);
-   fl_NET_WORKAREA       = XInternAtom(d, "_NET_WORKAREA",       0);
-   fl_NET_WM_ICON        = XInternAtom(d, "_NET_WM_ICON",        0);
- 
-@@ -1872,22 +1874,30 @@ void Fl_Window::resize(int X,int Y,int W
- #define _NET_WM_STATE_ADD           1  /* add/set property */
- #define _NET_WM_STATE_TOGGLE        2  /* toggle property  */
- 
--static void send_wm_state_event(Window wnd, int add, Atom prop) {
-+static void send_wm_event(Window wnd, Atom message,
-+                          unsigned long d0, unsigned long d1=0,
-+                          unsigned long d2=0, unsigned long d3=0,
-+                          unsigned long d4=0) {
-   XEvent e;
-   e.xany.type = ClientMessage;
-   e.xany.window = wnd;
--  e.xclient.message_type = fl_NET_WM_STATE;
-+  e.xclient.message_type = message;
-   e.xclient.format = 32;
--  e.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
--  e.xclient.data.l[1] = prop;
--  e.xclient.data.l[2] = 0;
--  e.xclient.data.l[3] = 0;
--  e.xclient.data.l[4] = 0;
-+  e.xclient.data.l[0] = d0;
-+  e.xclient.data.l[1] = d1;
-+  e.xclient.data.l[2] = d2;
-+  e.xclient.data.l[3] = d3;
-+  e.xclient.data.l[4] = d4;
-   XSendEvent(fl_display, RootWindow(fl_display, fl_screen),
-              0, SubstructureNotifyMask | SubstructureRedirectMask,
-              &e);
- }
- 
-+static void send_wm_state_event(Window wnd, int add, Atom prop) {
-+  send_wm_event(wnd, fl_NET_WM_STATE,
-+                add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, prop);
-+}
-+
- int Fl_X::ewmh_supported() {
-   static int result = -1;
- 
-@@ -1911,6 +1921,22 @@ int Fl_X::ewmh_supported() {
- /* Change an existing window to fullscreen */
- void Fl_Window::fullscreen_x() {
-   if (Fl_X::ewmh_supported()) {
-+    int top, bottom, left, right;
-+
-+    top = fullscreen_screen_top;
-+    bottom = fullscreen_screen_bottom;
-+    left = fullscreen_screen_left;
-+    right = fullscreen_screen_right;
-+
-+    if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
-+      top = Fl::screen_num(x(), y(), w(), h());
-+      bottom = top;
-+      left = top;
-+      right = top;
-+    }
-+
-+    send_wm_event(fl_xid(this), fl_NET_WM_FULLSCREEN_MONITORS,
-+                  top, bottom, left, right);
-     send_wm_state_event(fl_xid(this), 1, fl_NET_WM_STATE_FULLSCREEN);
-   } else {
-     _set_fullscreen();
-@@ -1997,7 +2023,7 @@ void Fl_X::make_xid(Fl_Window* win, XVis
-     // force the window to be on-screen.  Usually the X window manager
-     // does this, but a few don't, so we do it here for consistency:
-     int scr_x, scr_y, scr_w, scr_h;
--    Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h, X, Y);
-+    Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h, X, Y, W, H);
- 
-     if (win->border()) {
-       // ensure border is on screen:
-@@ -2026,6 +2052,23 @@ void Fl_X::make_xid(Fl_Window* win, XVis
-     return;
-   }
- 
-+  // Compute which screen(s) we should be on if we want to go fullscreen
-+  int fullscreen_top, fullscreen_bottom, fullscreen_left, fullscreen_right;
-+
-+  fullscreen_top = win->fullscreen_screen_top;
-+  fullscreen_bottom = win->fullscreen_screen_bottom;
-+  fullscreen_left = win->fullscreen_screen_left;
-+  fullscreen_right = win->fullscreen_screen_right;
-+
-+  if ((fullscreen_top < 0) || (fullscreen_bottom < 0) ||
-+      (fullscreen_left < 0) || (fullscreen_right < 0)) {
-+    fullscreen_top = Fl::screen_num(X, Y, W, H);
-+    fullscreen_bottom = fullscreen_top;
-+    fullscreen_left = fullscreen_top;
-+    fullscreen_right = fullscreen_top;
-+  }
-+
-+
-   ulong root = win->parent() ?
-     fl_xid(win->window()) : RootWindow(fl_display, fl_screen);
- 
-@@ -2049,9 +2092,17 @@ void Fl_X::make_xid(Fl_Window* win, XVis
-   // border, and cannot grab without an existing window. Besides, 
-   // there is no clear_override(). 
-   if (win->flags() & Fl_Widget::FULLSCREEN && !Fl_X::ewmh_supported()) {
-+    int sx, sy, sw, sh;
-     attr.override_redirect = 1;
-     mask |= CWOverrideRedirect;
--    Fl::screen_xywh(X, Y, W, H, X, Y, W, H);
-+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_left);
-+    X = sx;
-+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_right);
-+    W = sx + sw - X;
-+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_top);
-+    Y = sy;
-+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_bottom);
-+    H = sy + sh - Y;
-   }
- 
-   if (fl_background_pixel >= 0) {
-@@ -2122,6 +2173,13 @@ void Fl_X::make_xid(Fl_Window* win, XVis
- 
-     // If asked for, create fullscreen
-     if (win->flags() & Fl_Widget::FULLSCREEN && Fl_X::ewmh_supported()) {
-+      unsigned long data[4];
-+      data[0] = fullscreen_top;
-+      data[1] = fullscreen_bottom;
-+      data[2] = fullscreen_left;
-+      data[3] = fullscreen_right;
-+      XChangeProperty (fl_display, xp->xid, fl_NET_WM_FULLSCREEN_MONITORS, XA_ATOM, 32,
-+                       PropModeReplace, (unsigned char*) data, 4);
-       XChangeProperty (fl_display, xp->xid, fl_NET_WM_STATE, XA_ATOM, 32,
-                        PropModeAppend, (unsigned char*) &fl_NET_WM_STATE_FULLSCREEN, 1);
-     }
-diff -urp fltk-1.3.2.org/test/fullscreen.cxx fltk-1.3.2/test/fullscreen.cxx
---- fltk-1.3.2.org/test/fullscreen.cxx	2012-06-14 17:09:46.000000000 +0200
-+++ fltk-1.3.2/test/fullscreen.cxx	2013-01-16 10:52:47.881104801 +0100
-@@ -127,7 +127,7 @@ class fullscreen_window : public Fl_Sing
-   fullscreen_window(int W, int H, const char *t=0);
-   int handle (int e);
-   Fl_Toggle_Light_Button *b3;
--
-+  Fl_Toggle_Light_Button *b4;
- };
- 
- fullscreen_window::fullscreen_window(int W, int H, const char *t) : Fl_Single_Window(W, H, t) { 
-@@ -170,23 +170,54 @@ void border_cb(Fl_Widget *o, void *p) {
- #endif
- }
- 
--int px,py,pw,ph;
- Fl_Button *border_button;
- void fullscreen_cb(Fl_Widget *o, void *p) {
-   Fl_Window *w = (Fl_Window *)p;
-   int d = ((Fl_Button *)o)->value();
-   if (d) {
--    px = w->x();
--    py = w->y();
--    pw = w->w();
--    ph = w->h();
-+    if (((fullscreen_window*)w)->b4->value()) {
-+      int top, bottom, left, right;
-+      int top_y, bottom_y, left_x, right_x;
-+
-+      int sx, sy, sw, sh;
-+
-+      top = bottom = left = right = 0;
-+
-+      Fl::screen_xywh(sx, sy, sw, sh, 0);
-+      top_y = sy;
-+      bottom_y = sy + sh;
-+      left_x = sx;
-+      right_x = sx + sw;
-+
-+      for (int i = 1;i < Fl::screen_count();i++) {
-+        Fl::screen_xywh(sx, sy, sw, sh, i);
-+        if (sy < top_y) {
-+          top = i;
-+          top_y = sy;
-+        }
-+        if ((sy + sh) > bottom_y) {
-+          bottom = i;
-+          bottom_y = sy + sh;
-+        }
-+        if (sx < left_x) {
-+          left = i;
-+          left_x = sx;
-+        }
-+        if ((sx + sw) > right_x) {
-+          right = i;
-+          right_x = sx + sw;
-+        }
-+      }
-+
-+      w->fullscreen_screens(top, bottom, left, right);
-+    } else {
-+      w->fullscreen_screens(-1, -1, -1, -1);
-+    }
-     w->fullscreen();
--    w->override();
- #ifndef WIN32 // update our border state in case border was turned off
-     border_button->value(w->border());
- #endif
-   } else {
--    //w->fullscreen_off(px,py,pw,ph);
-     w->fullscreen_off();
-   }
- }
-@@ -219,7 +250,7 @@ void exit_cb(Fl_Widget *, void *) {
-   exit(0);
- }
- 
--#define NUMB 7
-+#define NUMB 8
- 
- int twowindow = 0;
- int initfull = 0;
-@@ -284,6 +315,9 @@ int main(int argc, char **argv) {
-   window.b3->callback(fullscreen_cb,w);
-   y+=30;
- 
-+  window.b4 = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"All Screens");
-+  y+=30;
-+
-   Fl_Button eb(50,y,window.w()-60,30,"Exit");
-   eb.callback(exit_cb);
-   y+=30;
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v4.3.x-keyboard-win32.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v4.3.x-keyboard-win32.patch
deleted file mode 100644
index c29d3b9..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v4.3.x-keyboard-win32.patch
+++ /dev/null
@@ -1,256 +0,0 @@
-diff -ur fltk-1.3.0r9293.org/src/Fl_win32.cxx fltk-1.3.0r9293/src/Fl_win32.cxx
---- fltk-1.3.0r9293.org/src/Fl_win32.cxx	2012-06-18 09:07:56.522314557 +0200
-+++ fltk-1.3.0r9293/src/Fl_win32.cxx	2012-06-18 09:08:07.392836285 +0200
-@@ -87,6 +87,8 @@
- static Fl_Display_Device fl_gdi_display(&fl_gdi_driver);
- Fl_Display_Device *Fl_Display_Device::_display = &fl_gdi_display; // the platform display
- 
-+bool use_simple_keyboard = false;
-+
- // dynamic wsock dll handling api:
- #if defined(__CYGWIN__) && !defined(SOCKET)
- # define SOCKET int
-@@ -120,6 +122,8 @@
-  * size and link dependencies.
-  */
- static HMODULE s_imm_module = 0;
-+typedef BOOL (WINAPI* flTypeImmAssociateContextEx)(HWND, HIMC, DWORD);
-+static flTypeImmAssociateContextEx flImmAssociateContextEx = 0;
- typedef HIMC (WINAPI* flTypeImmGetContext)(HWND);
- static flTypeImmGetContext flImmGetContext = 0;
- typedef BOOL (WINAPI* flTypeImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
-@@ -135,6 +139,7 @@
-     if (!s_imm_module)
-       Fl::fatal("FLTK Lib Error: IMM32.DLL file not found!\n\n"
-         "Please check your input method manager library accessibility.");
-+    flImmAssociateContextEx = (flTypeImmAssociateContextEx)GetProcAddress(s_imm_module, "ImmAssociateContextEx");
-     flImmGetContext = (flTypeImmGetContext)GetProcAddress(s_imm_module, "ImmGetContext");
-     flImmSetCompositionWindow = (flTypeImmSetCompositionWindow)GetProcAddress(s_imm_module, "ImmSetCompositionWindow");
-     flImmReleaseContext = (flTypeImmReleaseContext)GetProcAddress(s_imm_module, "ImmReleaseContext");
-@@ -413,7 +418,12 @@
-         }
-       }
- 
--      TranslateMessage(&fl_msg);
-+      // Don't bother with key to character translation as we do
-+      // it manually for simpley keyboard widgets. In fact, calling
-+      // TranslateMessage() just makes it more difficult as it sets
-+      // a bunch of internal state.
-+      if (!use_simple_keyboard)
-+        TranslateMessage(&fl_msg);
-       DispatchMessageW(&fl_msg);
-       have_message = PeekMessageW(&fl_msg, NULL, 0, 0, PM_REMOVE);
-     }
-@@ -638,6 +648,49 @@
-   }
- }
- 
-+void fl_update_focus(void)
-+{
-+  Fl_Widget *focus;
-+  Fl_Window *win;
-+
-+  get_imm_module();
-+
-+  focus = Fl::grab();
-+  if (!focus)
-+    focus = Fl::focus();
-+  if (!focus)
-+    return;
-+
-+  // Grabs are special in that events are sent to the first
-+  // available window
-+  if (focus == Fl::grab())
-+    win = Fl::first_window();
-+  else {
-+    win = focus->as_window();
-+    if (!win)
-+      win = focus->window();
-+  }
-+
-+  if (!win) {
-+    Fl::warning("Cannot find window for widget receiving focus");
-+    return;
-+  }
-+
-+  // No Win32 window created yet
-+  if (!Fl_X::i(win) || !fl_xid(win))
-+    return;
-+
-+  if (focus->simple_keyboard()) {
-+    use_simple_keyboard = true;
-+    if (flImmGetContext(fl_xid(win)) != 0)
-+      flImmAssociateContextEx(fl_xid(win), 0, 0);
-+  } else {
-+    use_simple_keyboard = false;
-+    if (flImmGetContext(fl_xid(win)) == 0)
-+      flImmAssociateContextEx(fl_xid(win), 0, IACE_DEFAULT);
-+  }
-+}
-+
- HWND fl_capture;
- 
- static int mouse_event(Fl_Window *window, int what, int button,
-@@ -785,6 +838,27 @@
-   return extended ? extendedlut[vk] : vklut[vk];
- }
- 
-+static xchar msdead2fltk(xchar in)
-+{
-+  switch (in) {
-+  case 0x0060:      // GRAVE ACCENT
-+    return 0x0300;  // COMBINING GRAVE ACCENT
-+  case 0x00b4:      // ACUTE ACCENT
-+    return 0x0301;  // COMBINING ACUTE ACCENT
-+  case 0x005e:      // CIRCUMFLEX ACCENT
-+    return 0x0302;  // COMBINING CIRCUMFLEX ACCENT
-+  case 0x007e:      // TILDE
-+    return 0x0303;  // COMBINING TILDE
-+  case 0x00a8:      // DIAERESIS
-+    return 0x0308;  // COMBINING DIAERESIS
-+  // FIXME: Windows dead key behaviour isn't documented and I don't have
-+  //        any more keyboards to test with...
-+  }
-+
-+  // hope that Windows gave us something proper to begin with
-+  return in;
-+}
-+
- #if USE_COLORMAP
- extern HPALETTE fl_select_palette(void); // in fl_color_win32.cxx
- #endif
-@@ -846,6 +920,8 @@
-   //fl_msg.pt = ???
-   //fl_msg.lPrivate = ???
- 
-+  MSG fl_orig_msg = fl_msg;
-+
-   Fl_Window *window = fl_find(hWnd);
- 
-   if (window) switch (uMsg) {
-@@ -1025,23 +1101,82 @@
-     if (GetKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK;
-     Fl::e_state = state;
-     static char buffer[1024];
--    if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) {
- 
-+    if (use_simple_keyboard) {
-+      BYTE keystate[256];
-+      WCHAR wbuf[8];
-+      int ret;
-+
-+      // I'm not sure if we ever get WM_CHAR (& friends) without an initial
-+      // WM_KEYDOWN (& friends), but if we do then we should not send such
-+      // side band events to simple keyboard widgets.
-+      if ((fl_orig_msg.message != WM_KEYDOWN) &&
-+          (fl_orig_msg.message != WM_SYSKEYDOWN) &&
-+          (fl_orig_msg.message != WM_KEYUP) &&
-+          (fl_orig_msg.message != WM_SYSKEYUP))
-+        break;
-+
-+      GetKeyboardState(keystate);
-+
-+      // Pressing Ctrl wreaks havoc with the symbol lookup, so turn that off.
-+      // But AltGr shows up as Ctrl+Alt in Windows, so keep Ctrl if Alt is
-+      // active.
-+      if (!(keystate[VK_MENU] & 0x80))
-+        keystate[VK_CONTROL] = keystate[VK_LCONTROL] = keystate[VK_RCONTROL] = 0;
-+
-+      // We cannot inspect or modify Windows' internal state of the keyboard
-+      // so we have to try to infer information from ToUnicode() and wedge
-+      // things into a known state.
-+      for (int i = 0;i < 2;i++) {
-+        ret = ToUnicode(fl_orig_msg.wParam, 0, keystate, wbuf,
-+                        sizeof(wbuf)/sizeof(wbuf[0]), 0);
-+
-+        // No symbol for this key (or unexpected length)
-+        if ((ret == 0) || (ret < -1)) {
-+          buffer[0] = 0;
-+          Fl::e_length = 0;
-+          break;
-+        }
-+
-+        // A dead key. Convert this to a Unicode combining character so
-+        // that the application can tell the difference between dead and
-+        // normal keys.
-+        if (ret == -1) {
-+          xchar u = (xchar) msdead2fltk(wbuf[0]);
-+          Fl::e_length = fl_utf8fromwc(buffer, 1024, &u, 1);
-+          buffer[Fl::e_length] = 0;
-+          break;
-+        }
-+
-+        // If we have two characters (or more) from ToUnicode(), that's
-+        // an invalid sequence. One character chould mean a proper symbol,
-+        // or it could mean a composed one. In both cases we need to call
-+        // ToUnicode() again to get something sane.
-+        if (i == 0)
-+          continue;
-+
-+        // We should now have something sane. Give whatever we have to the
-+        // application.
-+        Fl::e_length = fl_utf8fromwc(buffer, 1024, wbuf, ret);
-+        buffer[Fl::e_length] = 0;
-+      }
-+    } else if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) {
-       xchar u = (xchar) wParam;
- //    Fl::e_length = fl_unicode2utf(&u, 1, buffer);
-       Fl::e_length = fl_utf8fromwc(buffer, 1024, &u, 1);
-       buffer[Fl::e_length] = 0;
-+    } else {
-+      buffer[0] = 0;
-+      Fl::e_length = 0;
-+    }
- 
--
--    } else if (Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last) {
--      if (state & FL_NUM_LOCK) {
--        // Convert to regular keypress...
--	buffer[0] = Fl::e_keysym-FL_KP;
--	Fl::e_length = 1;
--      } else {
--        // Convert to special keypress...
--	buffer[0] = 0;
--	Fl::e_length = 0;
-+    // The keypad area is a bit odd in that we need to change the keysym
-+    // to properly indicate what the user meant, unlike other keys where
-+    // we normally change the text and keep keysym stable.
-+    if (Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last) {
-+      // The initial mapping tables give us a keysym that corresponds to
-+      // numlock being on, so we only do something when it is off.
-+      if (!(state & FL_NUM_LOCK)) {
- 	switch (Fl::e_keysym) {
- 	  case FL_KP + '0' :
- 	    Fl::e_keysym = FL_Insert;
-@@ -1073,30 +1208,10 @@
- 	  case FL_KP + '.' :
- 	    Fl::e_keysym = FL_Delete;
- 	    break;
--	  case FL_KP + '/' :
--	  case FL_KP + '*' :
--	  case FL_KP + '-' :
--	  case FL_KP + '+' :
--	    buffer[0] = Fl::e_keysym-FL_KP;
--	    Fl::e_length = 1;
--	    break;
- 	}
-       }
--    } else if ((lParam & (1<<31))==0) {
--#ifdef FLTK_PREVIEW_DEAD_KEYS
--      if ((lParam & (1<<24))==0) { // clear if dead key (always?)
--        xchar u = (xchar) wParam;
--        Fl::e_length = fl_utf8fromwc(buffer, 1024, &u, 1);
--        buffer[Fl::e_length] = 0;
--      } else { // set if "extended key" (never printable?)
--        buffer[0] = 0;
--        Fl::e_length = 0;
--      }
--#else
--      buffer[0] = 0;
--      Fl::e_length = 0;
--#endif
-     }
-+
-     Fl::e_text = buffer;
-     if (lParam & (1<<31)) { // key up events.
-       if (Fl::handle(FL_KEYUP, window)) return 0;
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v4.3.x-keyboard-x11.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v4.3.x-keyboard-x11.patch
deleted file mode 100644
index cabc0f1..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v4.3.x-keyboard-x11.patch
+++ /dev/null
@@ -1,286 +0,0 @@
-diff -ur fltk-1.3.0r9619.org/FL/Fl_Widget.H fltk-1.3.0r9619/FL/Fl_Widget.H
---- fltk-1.3.0r9619.org/FL/Fl_Widget.H	2012-04-23 22:12:06.000000000 +0200
-+++ fltk-1.3.0r9619/FL/Fl_Widget.H	2012-06-18 13:46:07.302320825 +0200
-@@ -171,6 +171,7 @@
-         GROUP_RELATIVE  = 1<<16,  ///< position this widget relative to the parent group, not to the window
-         COPIED_TOOLTIP  = 1<<17,  ///< the widget tooltip is internally copied, its destruction is handled by the widget
-         FULLSCREEN      = 1<<18,  ///< a fullscreen window (Fl_Window)
-+        SIMPLE_KEYBOARD = 1<<19,  ///< the widget wants simple, consistent keypresses and not advanced input (like character composition and CJK input)
-         // (space for more flags)
-         USERFLAG3       = 1<<29,  ///< reserved for 3rd party extensions
-         USERFLAG2       = 1<<30,  ///< reserved for 3rd party extensions
-@@ -776,6 +777,35 @@
-    */
-   void clear_changed() {flags_ &= ~CHANGED;}
- 
-+  /** 
-+      Returns if the widget sees a simplified keyboard model or not.
-+
-+      Normally widgets get a full-featured keyboard model that is geared
-+      towards text input. This includes support for compose sequences and
-+      advanced input methods, commonly used for asian writing system. This
-+      system however has downsides in that extra graphic can be presented
-+      to the user and that a physical key press doesn't correspond directly
-+      to a FLTK event.
-+
-+      Widgets that need a direct correspondence between actual key events
-+      and those seen by the widget can swith to the simplified keyboard
-+      model.
-+
-+     \retval 0 if the widget uses the normal keyboard model
-+     \see set_changed(), clear_changed()
-+   */
-+  unsigned int simple_keyboard() const {return flags_&SIMPLE_KEYBOARD;}
-+
-+  /** Marks a widget to use the simple keyboard model.
-+      \see changed(), clear_changed()
-+   */
-+  void set_simple_keyboard() {flags_ |= SIMPLE_KEYBOARD;}
-+
-+  /** Marks a widget to use the normal keyboard model.
-+      \see changed(), set_changed()
-+   */
-+  void set_normal_keyboard() {flags_ &= ~SIMPLE_KEYBOARD;}
-+
-   /** Gives the widget the keyboard focus.
-       Tries to make this widget be the Fl::focus() widget, by first sending 
-       it an FL_FOCUS event, and if it returns non-zero, setting 
-diff -ur fltk-1.3.0r9619.org/src/Fl.cxx fltk-1.3.0r9619/src/Fl.cxx
---- fltk-1.3.0r9619.org/src/Fl.cxx	2012-03-23 17:47:53.000000000 +0100
-+++ fltk-1.3.0r9619/src/Fl.cxx	2012-06-18 13:46:07.303320877 +0200
-@@ -70,6 +70,8 @@
- extern double fl_mac_flush_and_wait(double time_to_wait, char in_idle);
- #endif // WIN32
- 
-+extern void fl_update_focus(void);
-+
- //
- // Globals...
- //
-@@ -876,6 +878,8 @@
-       fl_oldfocus = p;
-     }
-     e_number = old_event;
-+    // let the platform code do what it needs
-+    fl_update_focus();
-   }
- }
- 
-diff -ur fltk-1.3.0r9619.org/src/Fl_grab.cxx fltk-1.3.0r9619/src/Fl_grab.cxx
---- fltk-1.3.0r9619.org/src/Fl_grab.cxx	2012-03-23 17:47:53.000000000 +0100
-+++ fltk-1.3.0r9619/src/Fl_grab.cxx	2012-06-18 13:46:07.303320877 +0200
-@@ -29,6 +29,7 @@
- // override_redirect, it does similar things on WIN32.
- 
- extern void fl_fix_focus(); // in Fl.cxx
-+void fl_update_focus(void);
- 
- #ifdef WIN32
- // We have to keep track of whether we have captured the mouse, since
-@@ -80,6 +81,7 @@
- #endif
-     }
-     grab_ = win;
-+    fl_update_focus();
-   } else {
-     if (grab_) {
- #ifdef WIN32
-@@ -98,6 +100,7 @@
-       XFlush(fl_display);
- #endif
-       grab_ = 0;
-+      fl_update_focus();
-       fl_fix_focus();
-     }
-   }
-diff -ur fltk-1.3.0r9619.org/src/Fl_x.cxx fltk-1.3.0r9619/src/Fl_x.cxx
---- fltk-1.3.0r9619.org/src/Fl_x.cxx	2012-06-18 13:46:07.205316173 +0200
-+++ fltk-1.3.0r9619/src/Fl_x.cxx	2012-06-18 13:46:18.216844629 +0200
-@@ -298,6 +298,7 @@
- Colormap fl_colormap;
- XIM fl_xim_im = 0;
- XIC fl_xim_ic = 0;
-+Window fl_xim_win = 0;
- char fl_is_over_the_spot = 0;
- static XRectangle status_area;
- 
-@@ -583,6 +584,65 @@
-   if(xim_styles) XFree(xim_styles);
- }
- 
-+void fl_xim_deactivate(void);
-+
-+void fl_xim_activate(Window xid)
-+{
-+  if (!fl_xim_im)
-+    return;
-+
-+  // If the focused window has changed, then use the brute force method
-+  // of completely recreating the input context.
-+  if (fl_xim_win != xid) {
-+    fl_xim_deactivate();
-+
-+    fl_new_ic();
-+    fl_xim_win = xid;
-+
-+    XSetICValues(fl_xim_ic,
-+                 XNFocusWindow, fl_xim_win,
-+                 XNClientWindow, fl_xim_win,
-+                 NULL);
-+  }
-+
-+  fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
-+}
-+
-+void fl_xim_deactivate(void)
-+{
-+  if (!fl_xim_ic)
-+    return;
-+
-+  XDestroyIC(fl_xim_ic);
-+  fl_xim_ic = NULL;
-+
-+  fl_xim_win = 0;
-+}
-+
-+extern Fl_Window *fl_xfocus;
-+
-+void fl_update_focus(void)
-+{
-+  Fl_Widget *focus;
-+
-+  focus = Fl::grab();
-+  if (!focus)
-+    focus = Fl::focus();
-+  if (!focus)
-+    return;
-+
-+  if (focus->simple_keyboard()) {
-+    fl_xim_deactivate();
-+  } else {
-+    // fl_xfocus should always be set if something has focus, but let's
-+    // play it safe
-+    if (!fl_xfocus || !fl_xid(fl_xfocus))
-+      return;
-+
-+    fl_xim_activate(fl_xid(fl_xfocus));
-+  }
-+}
-+
- void fl_open_display() {
-   if (fl_display) return;
- 
-@@ -917,10 +977,9 @@
-   XEvent xevent = thisevent;
-   fl_xevent = &thisevent;
-   Window xid = xevent.xany.window;
--  static Window xim_win = 0;
- 
-   if (fl_xim_ic && xevent.type == DestroyNotify &&
--        xid != xim_win && !fl_find(xid))
-+        xid != fl_xim_win && !fl_find(xid))
-   {
-     XIM xim_im;
-     xim_im = XOpenIM(fl_display, NULL, NULL, NULL);
-@@ -935,48 +994,10 @@
-     return 0;
-   }
- 
--  if (fl_xim_ic && (xevent.type == FocusIn))
--  {
--#define POOR_XIM
--#ifdef POOR_XIM
--        if (xim_win != xid)
--        {
--                xim_win  = xid;
--                XDestroyIC(fl_xim_ic);
--                fl_xim_ic = NULL;
--                fl_new_ic();
--                XSetICValues(fl_xim_ic,
--                                XNFocusWindow, xevent.xclient.window,
--                                XNClientWindow, xid,
--                                NULL);
--        }
--        fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
--#else
--    if (Fl::first_window() && Fl::first_window()->modal()) {
--      Window x  = fl_xid(Fl::first_window());
--      if (x != xim_win) {
--        xim_win  = x;
--        XSetICValues(fl_xim_ic,
--                        XNFocusWindow, xim_win,
--                        XNClientWindow, xim_win,
--                        NULL);
--        fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
--      }
--    } else if (xim_win != xid && xid) {
--      xim_win = xid;
--      XSetICValues(fl_xim_ic,
--                        XNFocusWindow, xevent.xclient.window,
--                        XNClientWindow, xid,
--                        //XNFocusWindow, xim_win,
--                        //XNClientWindow, xim_win,
--                        NULL);
--      fl_set_spot(spotf, spots, spot.x, spot.y, spot.width, spot.height);
--    }
--#endif
-+  if (fl_xim_ic) {
-+    if (XFilterEvent((XEvent *)&xevent, 0))
-+      return 1;
-   }
--
--  if ( XFilterEvent((XEvent *)&xevent, 0) )
--      return(1);
-   
- #if USE_XRANDR  
-   if( XRRUpdateConfiguration_f && xevent.type == randrEventBase + RRScreenChangeNotify) {
-@@ -1326,15 +1347,15 @@
-         //static XComposeStatus compose;
-         len = XLookupString((XKeyEvent*)&(xevent.xkey),
-                              buffer, buffer_len, &keysym, 0/*&compose*/);
--        if (keysym && keysym < 0x400) { // a character in latin-1,2,3,4 sets
--          // force it to type a character (not sure if this ever is needed):
--          // if (!len) {buffer[0] = char(keysym); len = 1;}
--          len = fl_utf8encode(XKeysymToUcs(keysym), buffer);
--          if (len < 1) len = 1;
--          // ignore all effects of shift on the keysyms, which makes it a lot
--          // easier to program shortcuts and is Windoze-compatible:
--          keysym = XKeycodeToKeysym(fl_display, keycode, 0);
--        }
-+        // XLookupString() is only defined to return Latin-1 (although it
-+        // often gives you more). To be safe, use our own lookups based on
-+        // keysym.
-+        len = fl_utf8encode(XKeysymToUcs(keysym), buffer);
-+        if (len < 1)
-+          len = 1;
-+        // ignore all effects of shift on the keysyms, which makes it a lot
-+        // easier to program shortcuts and is Windoze-compatable:
-+        keysym = XKeycodeToKeysym(fl_display, keycode, 0);
-       }
-       // MRS: Can't use Fl::event_state(FL_CTRL) since the state is not
-       //      set until set_event_xy() is called later...
-diff -ur fltk-1.3.0r9619.org/src/xutf8/imKStoUCS.c fltk-1.3.0r9619/src/xutf8/imKStoUCS.c
---- fltk-1.3.0r9619.org/src/xutf8/imKStoUCS.c	2009-03-13 23:43:43.000000000 +0100
-+++ fltk-1.3.0r9619/src/xutf8/imKStoUCS.c	2012-06-18 13:46:07.304320930 +0200
-@@ -266,6 +266,12 @@
-     0x20a8, 0x20a9, 0x20aa, 0x20ab, 0x20ac                          /* 0x20a8-0x20af */
- };
- 
-+static unsigned short const keysym_to_unicode_fe50_fe60[] = {
-+    0x0300, 0x0301, 0x0302, 0x0303, 0x0304, 0x0306, 0x0307, 0x0308, /* 0xfe50-0xfe57 */
-+    0x030a, 0x030b, 0x030c, 0x0327, 0x0328, 0x1da5, 0x3099, 0x309a, /* 0xfe58-0xfe5f */
-+    0x0323                                                          /* 0xfe60-0xfe67 */
-+};
-+
- unsigned int
- KeySymToUcs4(KeySym keysym)
- {
-@@ -315,6 +321,8 @@
- 	return keysym_to_unicode_1e9f_1eff[keysym - 0x1e9f];
-     else if (keysym > 0x209f && keysym < 0x20ad)
- 	return keysym_to_unicode_20a0_20ac[keysym - 0x20a0];
-+    else if (keysym > 0xfe4f && keysym < 0xfe61)
-+	return keysym_to_unicode_fe50_fe60[keysym - 0xfe50];
-     else 
- 	return 0;
- }
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v5.3.x-clipboard-x11.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v5.3.x-clipboard-x11.patch
deleted file mode 100644
index 467160f..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v5.3.x-clipboard-x11.patch
+++ /dev/null
@@ -1,350 +0,0 @@
-diff -up fltk-1.3.2/CMakeLists.txt.clp-x11 fltk-1.3.2/CMakeLists.txt
---- fltk-1.3.2/CMakeLists.txt.clp-x11	2012-09-13 16:19:01.000000000 +0200
-+++ fltk-1.3.2/CMakeLists.txt	2013-01-30 15:56:25.810663430 +0100
-@@ -515,6 +515,20 @@ else()
- endif(OPTION_USE_XINERAMA)
- 
- #######################################################################
-+if(X11_Xfixes_FOUND)
-+   option(OPTION_USE_XFIXES "use lib XFIXES" ON)
-+endif(X11_Xfixes_FOUND)
-+
-+if(OPTION_USE_XFIXES)
-+   set(HAVE_XFIXES ${X11_Xfixes_FOUND})
-+   include_directories(${X11_Xfixes_INCLUDE_PATH})
-+   list(APPEND FLTK_LDLIBS -lXfixes)
-+   set(FLTK_XFIXES_FOUND TRUE)
-+else()
-+   set(FLTK_XFIXES_FOUND FALSE)
-+endif(OPTION_USE_XFIXES)
-+
-+#######################################################################
- if(X11_Xft_FOUND)
-    option(OPTION_USE_XFT "use lib Xft" ON)
- endif(X11_Xft_FOUND)
-diff -up fltk-1.3.2/configh.cmake.in.clp-x11 fltk-1.3.2/configh.cmake.in
---- fltk-1.3.2/configh.cmake.in.clp-x11	2011-07-19 06:49:30.000000000 +0200
-+++ fltk-1.3.2/configh.cmake.in	2013-01-30 15:56:25.810663430 +0100
-@@ -108,6 +108,14 @@
- #define USE_XDBE HAVE_XDBE
- 
- /*
-+ * HAVE_XFIXES:
-+ *
-+ * Do we have the X fixes extension?
-+ */
-+
-+#cmakedefine01 HAVE_XFIXES
-+
-+/*
-  * __APPLE_QUARTZ__:
-  *
-  * If __APPLE_QUARTZ__ is defined, FLTK will be
-diff -up fltk-1.3.2/configh.in.clp-x11 fltk-1.3.2/configh.in
---- fltk-1.3.2/configh.in.clp-x11	2011-10-04 11:21:47.000000000 +0200
-+++ fltk-1.3.2/configh.in	2013-01-30 15:56:25.810663430 +0100
-@@ -108,6 +108,14 @@
- #define USE_XDBE HAVE_XDBE
- 
- /*
-+ * HAVE_XFIXES:
-+ *
-+ * Do we have the X fixes extension?
-+ */
-+
-+#define HAVE_XFIXES 0
-+
-+/*
-  * __APPLE_QUARTZ__:
-  *
-  * All Apple implementations are now based on Quartz and Cocoa,
-diff -up fltk-1.3.2/configure.in.clp-x11 fltk-1.3.2/configure.in
---- fltk-1.3.2/configure.in.clp-x11	2013-01-30 15:56:25.802663573 +0100
-+++ fltk-1.3.2/configure.in	2013-01-30 15:56:25.810663430 +0100
-@@ -999,6 +999,16 @@ case $uname_GUI in
- 		LIBS="-lXext $LIBS")
- 	fi
- 
-+	dnl Check for the Xfixes extension unless disabled...
-+        AC_ARG_ENABLE(xfixes, [  --enable-xfixes       turn on Xfixes support [default=yes]])
-+
-+	if test x$enable_xfixes != xno; then
-+	    AC_CHECK_HEADER(X11/extensions/Xfixes.h, AC_DEFINE(HAVE_XFIXES),,
-+	        [#include <X11/Xlib.h>])
-+	    AC_CHECK_LIB(Xfixes, XFixesQueryExtension,
-+		LIBS="-lXfixes $LIBS")
-+	fi
-+
- 	dnl Check for overlay visuals...
- 	AC_PATH_PROG(XPROP, xprop)
- 	AC_CACHE_CHECK(for X overlay visuals, ac_cv_have_overlay,
-diff -up fltk-1.3.2/fluid/CMakeLists.txt.clp-x11 fltk-1.3.2/fluid/CMakeLists.txt
-diff -up fltk-1.3.2/src/CMakeLists.txt.clp-x11 fltk-1.3.2/src/CMakeLists.txt
---- fltk-1.3.2/src/CMakeLists.txt.clp-x11	2013-01-30 16:06:00.785430590 +0100
-+++ fltk-1.3.2/src/CMakeLists.txt	2013-01-30 16:06:17.883126642 +0100
-@@ -243,6 +243,10 @@ if(HAVE_XINERAMA)
-    target_link_libraries(fltk ${X11_Xinerama_LIB})
- endif(HAVE_XINERAMA)
- 
-+if(HAVE_XFIXES)
-+   target_link_libraries(fltk ${X11_Xfixes_LIB})
-+endif(HAVE_XFIXES)
-+
- if(USE_XFT)
-    target_link_libraries(fltk ${X11_Xft_LIB})
- endif(USE_XFT)
-diff -up fltk-1.3.2/src/Fl_x.cxx.clp-x11 fltk-1.3.2/src/Fl_x.cxx
---- fltk-1.3.2/src/Fl_x.cxx.clp-x11	2013-01-30 15:56:25.793663733 +0100
-+++ fltk-1.3.2/src/Fl_x.cxx	2013-01-30 16:03:37.355981103 +0100
-@@ -53,6 +53,12 @@ static XRRUpdateConfiguration_type XRRUp
- static int randrEventBase;                  // base of RandR-defined events
- #endif
- 
-+#  if HAVE_XFIXES
-+#  include <X11/extensions/Xfixes.h>
-+static int xfixes_event_base = 0;
-+static bool have_xfixes = false;
-+#  endif
-+
- static Fl_Xlib_Graphics_Driver fl_xlib_driver;
- static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
- Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the platform display
-@@ -307,6 +313,9 @@ static Atom WM_PROTOCOLS;
- static Atom fl_MOTIF_WM_HINTS;
- static Atom TARGETS;
- static Atom CLIPBOARD;
-+static Atom TIMESTAMP;
-+static Atom PRIMARY_TIMESTAMP;
-+static Atom CLIPBOARD_TIMESTAMP;
- Atom fl_XdndAware;
- Atom fl_XdndSelection;
- Atom fl_XdndEnter;
-@@ -667,6 +676,9 @@ void fl_open_display(Display* d) {
-   fl_MOTIF_WM_HINTS     = XInternAtom(d, "_MOTIF_WM_HINTS",     0);
-   TARGETS               = XInternAtom(d, "TARGETS",             0);
-   CLIPBOARD             = XInternAtom(d, "CLIPBOARD",           0);
-+  TIMESTAMP             = XInternAtom(d, "TIMESTAMP",           0);
-+  PRIMARY_TIMESTAMP     = XInternAtom(d, "PRIMARY_TIMESTAMP",   0);
-+  CLIPBOARD_TIMESTAMP   = XInternAtom(d, "CLIPBOARD_TIMESTAMP", 0);
-   fl_XdndAware          = XInternAtom(d, "XdndAware",           0);
-   fl_XdndSelection      = XInternAtom(d, "XdndSelection",       0);
-   fl_XdndEnter          = XInternAtom(d, "XdndEnter",           0);
-@@ -713,6 +725,15 @@ void fl_open_display(Display* d) {
- #if !USE_COLORMAP
-   Fl::visual(FL_RGB);
- #endif
-+
-+#if HAVE_XFIXES
-+  int error_base;
-+  if (XFixesQueryExtension(fl_display, &xfixes_event_base, &error_base))
-+    have_xfixes = true;
-+  else
-+    have_xfixes = false;
-+#endif
-+
- #if USE_XRANDR
-   void *libxrandr_addr = dlopen("libXrandr.so.2", RTLD_LAZY);
-   if (!libxrandr_addr)  libxrandr_addr = dlopen("libXrandr.so", RTLD_LAZY);
-@@ -901,6 +922,102 @@ void Fl::copy(const char *stuff, int len
- }
- 
- ////////////////////////////////////////////////////////////////
-+// Code for tracking clipboard changes:
-+
-+static Time primary_timestamp = -1;
-+static Time clipboard_timestamp = -1;
-+
-+extern bool fl_clipboard_notify_empty(void);
-+extern void fl_trigger_clipboard_notify(int source);
-+
-+static void poll_clipboard_owner(void) {
-+  Window xid;
-+
-+#if HAVE_XFIXES
-+  // No polling needed with Xfixes
-+  if (have_xfixes)
-+    return;
-+#endif
-+
-+  // No one is interested, so no point polling
-+  if (fl_clipboard_notify_empty())
-+    return;
-+
-+  // We need a window for this to work
-+  if (!Fl::first_window())
-+    return;
-+  xid = fl_xid(Fl::first_window());
-+  if (!xid)
-+    return;
-+
-+  // Request an update of the selection time for both the primary and
-+  // clipboard selections. Magic continues when we get a SelectionNotify.
-+  if (!fl_i_own_selection[0])
-+    XConvertSelection(fl_display, XA_PRIMARY, TIMESTAMP, PRIMARY_TIMESTAMP,
-+                      xid, fl_event_time);
-+  if (!fl_i_own_selection[1])
-+    XConvertSelection(fl_display, CLIPBOARD, TIMESTAMP, CLIPBOARD_TIMESTAMP,
-+                      xid, fl_event_time);
-+}
-+
-+static void clipboard_timeout(void *data)
-+{
-+  // No one is interested, so stop polling
-+  if (fl_clipboard_notify_empty())
-+    return;
-+
-+  poll_clipboard_owner();
-+
-+  Fl::repeat_timeout(0.5, clipboard_timeout);
-+}
-+
-+static void handle_clipboard_timestamp(int clipboard, Time time)
-+{
-+  Time *timestamp;
-+
-+  timestamp = clipboard ? &clipboard_timestamp : &primary_timestamp;
-+
-+#if HAVE_XFIXES
-+  if (!have_xfixes)
-+#endif
-+  {
-+    // Initial scan, just store the value
-+    if (*timestamp == (Time)-1) {
-+      *timestamp = time;
-+      return;
-+    }
-+  }
-+
-+  // Same selection
-+  if (time == *timestamp)
-+    return;
-+
-+  *timestamp = time;
-+
-+  // Something happened! Let's tell someone!
-+  fl_trigger_clipboard_notify(clipboard);
-+}
-+
-+void fl_clipboard_notify_change() {
-+  // Reset the timestamps if we've going idle so that you don't
-+  // get a bogus immediate trigger next time they're activated.
-+  if (fl_clipboard_notify_empty()) {
-+    primary_timestamp = -1;
-+    clipboard_timestamp = -1;
-+  } else {
-+#if HAVE_XFIXES
-+    if (!have_xfixes)
-+#endif
-+    {
-+      poll_clipboard_owner();
-+
-+      if (!Fl::has_timeout(clipboard_timeout))
-+        Fl::add_timeout(0.5, clipboard_timeout);
-+    }
-+  }
-+}
-+
-+////////////////////////////////////////////////////////////////
- 
- const XEvent* fl_xevent; // the current x event
- ulong fl_event_time; // the last timestamp from an x event
-@@ -1024,7 +1141,6 @@ int fl_handle(const XEvent& thisevent)
-     return 0;
- 
-   case SelectionNotify: {
--    if (!fl_selection_requestor) return 0;
-     static unsigned char* buffer = 0;
-     if (buffer) {XFree(buffer); buffer = 0;}
-     long bytesread = 0;
-@@ -1040,6 +1156,19 @@ int fl_handle(const XEvent& thisevent)
-                              bytesread/4, 65536, 1, 0,
-                              &actual, &format, &count, &remaining,
-                              &portion)) break; // quit on error
-+
-+      if ((fl_xevent->xselection.property == PRIMARY_TIMESTAMP) ||
-+          (fl_xevent->xselection.property == CLIPBOARD_TIMESTAMP)) {
-+        if (portion && format == 32 && count == 1) {
-+          Time t = *(unsigned int*)portion;
-+          if (fl_xevent->xselection.property == CLIPBOARD_TIMESTAMP)
-+            handle_clipboard_timestamp(1, t);
-+          else
-+            handle_clipboard_timestamp(0, t);
-+        }
-+        return true;
-+      }
-+
-       if (actual == TARGETS || actual == XA_ATOM) {
- 	Atom type = XA_STRING;
- 	for (unsigned i = 0; i<count; i++) {
-@@ -1076,6 +1205,9 @@ int fl_handle(const XEvent& thisevent)
-       buffer[bytesread] = 0;
-       convert_crlf(buffer, bytesread);
-     }
-+
-+    if (!fl_selection_requestor) return 0;
-+
-     Fl::e_text = buffer ? (char*)buffer : (char *)"";
-     Fl::e_length = bytesread;
-     int old_event = Fl::e_number;
-@@ -1096,6 +1228,7 @@ int fl_handle(const XEvent& thisevent)
-   case SelectionClear: {
-     int clipboard = fl_xevent->xselectionclear.selection == CLIPBOARD;
-     fl_i_own_selection[clipboard] = 0;
-+    poll_clipboard_owner();
-     return 1;}
- 
-   case SelectionRequest: {
-@@ -1308,6 +1441,9 @@ int fl_handle(const XEvent& thisevent)
-   case FocusIn:
-     if (fl_xim_ic) XSetICFocus(fl_xim_ic);
-     event = FL_FOCUS;
-+    // If the user has toggled from another application to this one,
-+    // then it's a good time to check for clipboard changes.
-+    poll_clipboard_owner();
-     break;
- 
-   case FocusOut:
-@@ -1676,6 +1812,25 @@ int fl_handle(const XEvent& thisevent)
-     }
-   }
- 
-+#if HAVE_XFIXES
-+  switch (xevent.type - xfixes_event_base) {
-+  case XFixesSelectionNotify: {
-+    // Someone feeding us bogus events?
-+    if (!have_xfixes)
-+      return true;
-+
-+    XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)&xevent;
-+
-+    if ((selection_notify->selection == XA_PRIMARY) && !fl_i_own_selection[0])
-+      handle_clipboard_timestamp(0, selection_notify->selection_timestamp);
-+    else if ((selection_notify->selection == CLIPBOARD) && !fl_i_own_selection[1])
-+      handle_clipboard_timestamp(1, selection_notify->selection_timestamp);
-+
-+    return true;
-+    }
-+  }
-+#endif
-+
-   return Fl::handle(event, window);
- }
- 
-@@ -1995,6 +2150,16 @@ void Fl_X::make_xid(Fl_Window* win, XVis
-     XChangeProperty(fl_display, xp->xid, net_wm_type, XA_ATOM, 32, PropModeReplace, (unsigned char*)&net_wm_type_kind, 1);
-   }
- 
-+#if HAVE_XFIXES
-+  // register for clipboard change notifications
-+  if (have_xfixes && !win->parent()) {
-+    XFixesSelectSelectionInput(fl_display, xp->xid, XA_PRIMARY,
-+                               XFixesSetSelectionOwnerNotifyMask);
-+    XFixesSelectSelectionInput(fl_display, xp->xid, CLIPBOARD,
-+                               XFixesSetSelectionOwnerNotifyMask);
-+  }
-+#endif
-+
-   XMapWindow(fl_display, xp->xid);
-   if (showit) {
-     win->set_visible();
-diff -up fltk-1.3.2/test/CMakeLists.txt.clp-x11 fltk-1.3.2/test/CMakeLists.txt
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v5.3.x-cursor.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v5.3.x-cursor.patch
deleted file mode 100644
index 8e99050..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v5.3.x-cursor.patch
+++ /dev/null
@@ -1,1623 +0,0 @@
-diff -up fltk-1.3.2/CMakeLists.txt.cursor fltk-1.3.2/CMakeLists.txt
---- fltk-1.3.2/CMakeLists.txt.cursor	2013-01-30 16:07:59.510320246 +0100
-+++ fltk-1.3.2/CMakeLists.txt	2013-01-30 16:07:59.528319926 +0100
-@@ -529,6 +529,20 @@ else()
- endif(OPTION_USE_XFIXES)
- 
- #######################################################################
-+if(X11_Xcursor_FOUND)
-+   option(OPTION_USE_XCURSOR "use lib XCURSOR" ON)
-+endif(X11_Xcursor_FOUND)
-+
-+if(OPTION_USE_XCURSOR)
-+   set(HAVE_XCURSOR ${X11_Xcursor_FOUND})
-+   include_directories(${X11_Xcursor_INCLUDE_PATH})
-+   list(APPEND FLTK_LDLIBS -lXcursor)
-+   set(FLTK_XCURSOR_FOUND TRUE)
-+else()
-+   set(FLTK_XCURSOR_FOUND FALSE)
-+endif(OPTION_USE_XCURSOR)
-+
-+#######################################################################
- if(X11_Xft_FOUND)
-    option(OPTION_USE_XFT "use lib Xft" ON)
- endif(X11_Xft_FOUND)
-diff -up fltk-1.3.2/configh.cmake.in.cursor fltk-1.3.2/configh.cmake.in
---- fltk-1.3.2/configh.cmake.in.cursor	2013-01-30 16:07:59.510320246 +0100
-+++ fltk-1.3.2/configh.cmake.in	2013-01-30 16:07:59.529319908 +0100
-@@ -116,6 +116,14 @@
- #cmakedefine01 HAVE_XFIXES
- 
- /*
-+ * HAVE_XCURSOR:
-+ *
-+ * Do we have the X cursor library?
-+ */
-+
-+#cmakedefine01 HAVE_XCURSOR
-+
-+/*
-  * __APPLE_QUARTZ__:
-  *
-  * If __APPLE_QUARTZ__ is defined, FLTK will be
-diff -up fltk-1.3.2/configh.in.cursor fltk-1.3.2/configh.in
---- fltk-1.3.2/configh.in.cursor	2013-01-30 16:07:59.510320246 +0100
-+++ fltk-1.3.2/configh.in	2013-01-30 16:07:59.529319908 +0100
-@@ -116,6 +116,14 @@
- #define HAVE_XFIXES 0
- 
- /*
-+ * HAVE_XCURSOR:
-+ *
-+ * Do we have the X cursor library?
-+ */
-+
-+#define HAVE_XCURSOR 0
-+
-+/*
-  * __APPLE_QUARTZ__:
-  *
-  * All Apple implementations are now based on Quartz and Cocoa,
-diff -up fltk-1.3.2/configure.in.cursor fltk-1.3.2/configure.in
---- fltk-1.3.2/configure.in.cursor	2013-01-30 16:07:59.511320228 +0100
-+++ fltk-1.3.2/configure.in	2013-01-30 16:07:59.529319908 +0100
-@@ -1009,6 +1009,16 @@ case $uname_GUI in
- 		LIBS="-lXfixes $LIBS")
- 	fi
- 
-+	dnl Check for the Xcursor library unless disabled...
-+        AC_ARG_ENABLE(xcursor, [  --enable-xcursor        turn on Xcursor support [default=yes]])
-+
-+	if test x$enable_xcursor != xno; then
-+	    AC_CHECK_HEADER(X11/Xcursor/Xcursor.h, AC_DEFINE(HAVE_XCURSOR),,
-+	        [#include <X11/Xlib.h>])
-+	    AC_CHECK_LIB(Xcursor, XcursorImageCreate,
-+		LIBS="-lXcursor $LIBS")
-+	fi
-+
- 	dnl Check for overlay visuals...
- 	AC_PATH_PROG(XPROP, xprop)
- 	AC_CACHE_CHECK(for X overlay visuals, ac_cv_have_overlay,
-diff -up fltk-1.3.2/FL/Enumerations.H.cursor fltk-1.3.2/FL/Enumerations.H
---- fltk-1.3.2/FL/Enumerations.H.cursor	2013-01-30 16:07:59.486320673 +0100
-+++ fltk-1.3.2/FL/Enumerations.H	2013-01-30 16:07:59.530319891 +0100
-@@ -879,35 +879,36 @@ inline Fl_Color fl_color_cube(int r, int
- 
- /** The following constants define the mouse cursors that are available in FLTK.
- 
--    The double-headed arrows are bitmaps provided by FLTK on X, the others
--    are provided by system-defined cursors.
-+    Cursors are provided by the system when available, or bitmaps built into
-+    FLTK as a fallback.
- 
-     \todo enum Fl_Cursor needs maybe an image.
- */
- enum Fl_Cursor {
-   FL_CURSOR_DEFAULT	=  0, /**< the default cursor, usually an arrow. */
--  FL_CURSOR_ARROW	= 35, /**< an arrow pointer. */
--  FL_CURSOR_CROSS	= 66, /**< crosshair. */
--  FL_CURSOR_WAIT	= 76, /**< watch or hourglass. */
--  FL_CURSOR_INSERT	= 77, /**< I-beam. */
--  FL_CURSOR_HAND	= 31, /**< hand (uparrow on MSWindows). */
--  FL_CURSOR_HELP	= 47, /**< question mark. */
--  FL_CURSOR_MOVE	= 27, /**< 4-pointed arrow. */
--  // fltk provides bitmaps for these:
--  FL_CURSOR_NS		= 78, /**< up/down arrow. */
--  FL_CURSOR_WE		= 79, /**< left/right arrow. */
--  FL_CURSOR_NWSE	= 80, /**< diagonal arrow. */
--  FL_CURSOR_NESW	= 81, /**< diagonal arrow. */
--  FL_CURSOR_NONE	=255, /**< invisible. */
--  // for back compatibility (non MSWindows ones):
--  FL_CURSOR_N		= 70, /**< for back compatibility. */
--  FL_CURSOR_NE		= 69, /**< for back compatibility. */
--  FL_CURSOR_E		= 49, /**< for back compatibility. */
--  FL_CURSOR_SE		=  8, /**< for back compatibility. */
--  FL_CURSOR_S		=  9, /**< for back compatibility. */
--  FL_CURSOR_SW		=  7, /**< for back compatibility. */
--  FL_CURSOR_W		= 36, /**< for back compatibility. */
--  FL_CURSOR_NW		= 68 /**< for back compatibility. */
-+  FL_CURSOR_ARROW   = 1,    /**< an arrow pointer. */
-+  FL_CURSOR_CROSS   = 2,    /**< crosshair. */
-+  FL_CURSOR_WAIT    = 3,    /**< busy indicator (e.g. hourglass). */
-+  FL_CURSOR_INSERT  = 4,    /**< I-beam. */
-+  FL_CURSOR_HAND    = 5,    /**< pointing hand. */
-+  FL_CURSOR_HELP    = 6,    /**< question mark pointer. */
-+  FL_CURSOR_MOVE    = 7,    /**< 4-pointed arrow or hand. */
-+
-+  /* Resize indicators */
-+  FL_CURSOR_NS      = 101,  /**< up/down resize. */
-+  FL_CURSOR_WE      = 102,  /**< left/right resize. */
-+  FL_CURSOR_NWSE    = 103,  /**< diagonal resize. */
-+  FL_CURSOR_NESW    = 104,  /**< diagonal resize. */
-+  FL_CURSOR_NE      = 110,  /**< upwards, right resize. */
-+  FL_CURSOR_N       = 111,  /**< upwards resize. */
-+  FL_CURSOR_NW      = 112,  /**< upwards, left resize. */
-+  FL_CURSOR_E       = 113,  /**< leftwards resize. */
-+  FL_CURSOR_W       = 114,  /**< rightwards resize. */
-+  FL_CURSOR_SE      = 115,  /**< downwards, right resize. */
-+  FL_CURSOR_S       = 116,  /**< downwards resize. */
-+  FL_CURSOR_SW      = 117,  /**< downwards, left resize. */
-+
-+  FL_CURSOR_NONE    = 255,  /**< invisible. */
- };
- /*@}*/		// group: Cursors  
- 
-diff -up fltk-1.3.2/FL/fl_draw.H.cursor fltk-1.3.2/FL/fl_draw.H
---- fltk-1.3.2/FL/fl_draw.H.cursor	2012-05-08 18:15:34.000000000 +0200
-+++ fltk-1.3.2/FL/fl_draw.H	2013-01-30 16:07:59.530319891 +0100
-@@ -751,7 +751,8 @@ FL_EXPORT const char* fl_shortcut_label(
- FL_EXPORT unsigned int fl_old_shortcut(const char* s);
- FL_EXPORT void fl_overlay_rect(int x,int y,int w,int h);
- FL_EXPORT void fl_overlay_clear();
--FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg=FL_BLACK, Fl_Color bg=FL_WHITE);
-+FL_EXPORT void fl_cursor(Fl_Cursor);
-+FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg, Fl_Color bg=FL_WHITE);
- FL_EXPORT const char* fl_expand_text(const char* from, char* buf, int maxbuf,
-                                      double maxw, int& n, double &width,
-                                      int wrap, int draw_symbols = 0);
-diff -up fltk-1.3.2/FL/Fl_Window.H.cursor fltk-1.3.2/FL/Fl_Window.H
---- fltk-1.3.2/FL/Fl_Window.H.cursor	2012-11-06 21:46:14.000000000 +0100
-+++ fltk-1.3.2/FL/Fl_Window.H	2013-01-30 16:07:59.531319873 +0100
-@@ -28,6 +28,7 @@
- #define FL_DOUBLE_WINDOW 0xF1   ///< double window type id
- 
- class Fl_X;
-+class Fl_RGB_Image;
- 
- /**
-   This widget produces an actual window.  This can either be a main
-@@ -81,7 +82,6 @@ class FL_EXPORT Fl_Window : public Fl_Gr
-   uchar size_range_set;
-   // cursor stuff
-   Fl_Cursor cursor_default;
--  Fl_Color cursor_fg, cursor_bg;
-   void size_range_();
-   void _Fl_Window(); // constructor innards
-   void fullscreen_x(); // platform-specific part of sending a window to full screen
-@@ -466,14 +466,17 @@ public:
-     is different.
- 
-     The type Fl_Cursor is an enumeration defined in <FL/Enumerations.H>.
--    (Under X you can get any XC_cursor value by passing 
--    Fl_Cursor((XC_foo/2)+1)).  The colors only work on X, they are
--    not implemented on WIN32.
- 
--    For back compatibility only.
-+    \see cursor(const Fl_RGB_Image*, int, int), default_cursor()
-   */
--  void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); // platform dependent
--  void default_cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE);
-+  void cursor(Fl_Cursor);
-+  void cursor(const Fl_RGB_Image*, int, int);
-+  void default_cursor(Fl_Cursor);
-+
-+  /* for legacy compatibility */
-+  void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
-+  void default_cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
-+
-   static void default_callback(Fl_Window*, void* v);
-   
-   /** Returns the window width including any frame added by the window manager.
-diff -up fltk-1.3.2/FL/mac.H.cursor fltk-1.3.2/FL/mac.H
---- fltk-1.3.2/FL/mac.H.cursor	2012-11-13 15:45:42.000000000 +0100
-+++ fltk-1.3.2/FL/mac.H	2013-01-30 16:07:59.531319873 +0100
-@@ -120,7 +120,8 @@ public:
-   void collapse(void);
-   WindowRef window_ref(void);
-   void set_key_window(void);
--  void set_cursor(Fl_Cursor);
-+  int set_cursor(Fl_Cursor);
-+  int set_cursor(const Fl_RGB_Image*, int, int);
-   static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
-   static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
-   static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h);
-diff -up fltk-1.3.2/FL/win32.H.cursor fltk-1.3.2/FL/win32.H
---- fltk-1.3.2/FL/win32.H.cursor	2012-03-12 12:55:50.000000000 +0100
-+++ fltk-1.3.2/FL/win32.H	2013-01-30 16:07:59.531319873 +0100
-@@ -73,6 +73,7 @@ public:
-   int wait_for_expose;
-   HDC private_dc; // used for OpenGL
-   HCURSOR cursor;
-+  int custom_cursor;
-   HDC saved_hdc;  // saves the handle of the DC currently loaded
-   // static variables, static functions and member functions
-   static Fl_X* first;
-@@ -83,6 +84,8 @@ public:
-   void flush() {w->flush();}
-   void set_minmax(LPMINMAXINFO minmax);
-   void mapraise();
-+  int set_cursor(Fl_Cursor);
-+  int set_cursor(const Fl_RGB_Image*, int, int);
-   static Fl_X* make(Fl_Window*);
- };
- extern FL_EXPORT HCURSOR fl_default_cursor;
-diff -up fltk-1.3.2/FL/x.H.cursor fltk-1.3.2/FL/x.H
---- fltk-1.3.2/FL/x.H.cursor	2012-03-23 17:47:53.000000000 +0100
-+++ fltk-1.3.2/FL/x.H	2013-01-30 16:07:59.532319855 +0100
-@@ -154,6 +154,8 @@ public:
-   static Fl_X* i(const Fl_Window* wi) {return wi->i;}
-   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
-   void sendxjunk();
-+  int set_cursor(Fl_Cursor);
-+  int set_cursor(const Fl_RGB_Image*, int, int);
-   static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
-   static Fl_X* set_xid(Fl_Window*, Window);
-   // kludges to get around protection:
-diff -up fltk-1.3.2/src/CMakeLists.txt.cursor fltk-1.3.2/src/CMakeLists.txt
---- fltk-1.3.2/src/CMakeLists.txt.cursor	2013-01-30 16:09:11.981032475 +0100
-+++ fltk-1.3.2/src/CMakeLists.txt	2013-01-30 16:09:26.497774461 +0100
-@@ -247,6 +247,10 @@ if(HAVE_XFIXES)
-    target_link_libraries(fltk ${X11_Xfixes_LIB})
- endif(HAVE_XFIXES)
- 
-+if(HAVE_XCURSOR)
-+   target_link_libraries(fltk ${X11_Xcursor_LIB})
-+endif(HAVE_XCURSOR)
-+
- if(USE_XFT)
-    target_link_libraries(fltk ${X11_Xft_LIB})
- endif(USE_XFT)
-diff -up fltk-1.3.2/src/Fl_cocoa.mm.cursor fltk-1.3.2/src/Fl_cocoa.mm
---- fltk-1.3.2/src/Fl_cocoa.mm.cursor	2013-01-30 16:07:59.522320033 +0100
-+++ fltk-1.3.2/src/Fl_cocoa.mm	2013-01-30 16:07:59.533319837 +0100
-@@ -98,7 +98,6 @@ Fl_Display_Device *Fl_Display_Device::_d
- CGContextRef fl_gc = 0;
- void *fl_system_menu;                   // this is really a NSMenu*
- Fl_Sys_Menu_Bar *fl_sys_menu_bar = 0;
--void *fl_default_cursor;		// this is really a NSCursor*
- void *fl_capture = 0;			// (NSWindow*) we need this to compensate for a missing(?) mouse capture
- bool fl_show_iconic;                    // true if called from iconize() - shows the next created window in collapsed state
- //int fl_disable_transient_for;           // secret method of removing TRANSIENT_FOR
-@@ -1392,8 +1391,6 @@ void fl_open_display() {
- 					  dequeue:YES];
-     while (ign_event);
-     
--    fl_default_cursor = [NSCursor arrowCursor];
--
-     // bring the application into foreground without a 'CARB' resource
-     Boolean same_psn;
-     ProcessSerialNumber cur_psn, front_psn;
-@@ -1698,6 +1695,7 @@ static void  q_set_window_title(NSWindow
- - (void)drawRect:(NSRect)rect;
- - (BOOL)acceptsFirstResponder;
- - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent;
-+- (void)resetCursorRects;
- - (BOOL)performKeyEquivalent:(NSEvent*)theEvent;
- - (void)mouseUp:(NSEvent *)theEvent;
- - (void)rightMouseUp:(NSEvent *)theEvent;
-@@ -1756,6 +1754,16 @@ static void  q_set_window_title(NSWindow
-   Fl_Window *first = Fl::first_window();
-   return (first == w || !first->modal());
- }
-+- (void)resetCursorRects {
-+  Fl_Window *w = [(FLWindow*)[self window] getFl_Window];
-+  Fl_X *i = Fl_X::i(w);
-+  // We have to have at least one cursor rect for invalidateCursorRectsForView
-+  // to work, hence the "else" clause.
-+  if (i->cursor)
-+    [self addCursorRect:[self visibleRect] cursor:(NSCursor*)i->cursor];
-+  else
-+    [self addCursorRect:[self visibleRect] cursor:[NSCursor arrowCursor]];
-+}
- - (void)mouseUp:(NSEvent *)theEvent {
-   cocoaMouseHandler(theEvent);
- }
-@@ -2331,7 +2339,7 @@ void Fl_X::make(Fl_Window* w)
-     x->other_xid = 0;
-     x->region = 0;
-     x->subRegion = 0;
--    x->cursor = fl_default_cursor;
-+    x->cursor = NULL;
-     x->gc = 0;			// stay 0 for Quickdraw; fill with CGContext for Quartz
-     Fl_Window *win = w->window();
-     Fl_X *xo = Fl_X::i(win);
-@@ -2427,7 +2435,7 @@ void Fl_X::make(Fl_Window* w)
-     x->other_xid = 0; // room for doublebuffering image map. On OS X this is only used by overlay windows
-     x->region = 0;
-     x->subRegion = 0;
--    x->cursor = fl_default_cursor;
-+    x->cursor = NULL;
-     x->xidChildren = 0;
-     x->xidNext = 0;
-     x->gc = 0;
-@@ -2974,6 +2982,10 @@ void Fl_X::map() {
-     Fl_X::relink(w, w->window() );
-     w->redraw();
-   }
-+  if (cursor) {
-+    [(NSCursor*)cursor release];
-+    cursor = NULL;
-+  }
- }
- 
- void Fl_X::unmap() {
-@@ -3078,68 +3090,106 @@ static NSImage *CGBitmapContextToNSImage
-   return [image autorelease];
- }
- 
--static NSCursor *PrepareCursor(NSCursor *cursor, CGContextRef (*f)() )
-+int Fl_X::set_cursor(Fl_Cursor c)
- {
--  if (cursor == nil) {
--    CGContextRef c = f();
--    NSImage *image = CGBitmapContextToNSImage(c);
--    fl_delete_offscreen( (Fl_Offscreen)c ); 
--    NSPoint pt = {[image size].width/2, [image size].height/2};
--    cursor = [[NSCursor alloc] initWithImage:image hotSpot:pt];
-+  if (cursor) {
-+    [(NSCursor*)cursor release];
-+    cursor = NULL;
-   }
--  return cursor;
--}
- 
--void Fl_X::set_cursor(Fl_Cursor c)
--{
--  NSCursor *icrsr;
-   switch (c) {
--    case FL_CURSOR_CROSS:  icrsr = [NSCursor crosshairCursor]; break;
--    case FL_CURSOR_WAIT:
--      static NSCursor *watch = nil;
--      watch = PrepareCursor(watch,  &Fl_X::watch_cursor_image);
--      icrsr = watch;
--      break;
--    case FL_CURSOR_INSERT: icrsr = [NSCursor IBeamCursor]; break;
--    case FL_CURSOR_N:      icrsr = [NSCursor resizeUpCursor]; break;
--    case FL_CURSOR_S:      icrsr = [NSCursor resizeDownCursor]; break;
--    case FL_CURSOR_NS:     icrsr = [NSCursor resizeUpDownCursor]; break;
--    case FL_CURSOR_HELP:   
--      static NSCursor *help = nil;
--      help = PrepareCursor(help,  &Fl_X::help_cursor_image);
--      icrsr = help;
--      break;
--    case FL_CURSOR_HAND:   icrsr = [NSCursor pointingHandCursor]; break;
--    case FL_CURSOR_MOVE:   icrsr = [NSCursor openHandCursor]; break;
--    case FL_CURSOR_NE:
--    case FL_CURSOR_SW:
--    case FL_CURSOR_NESW:   
--      static NSCursor *nesw = nil;
--      nesw = PrepareCursor(nesw,  &Fl_X::nesw_cursor_image);
--      icrsr = nesw;
--      break;
--    case FL_CURSOR_E:      icrsr = [NSCursor resizeRightCursor]; break;
--    case FL_CURSOR_W:      icrsr = [NSCursor resizeLeftCursor]; break;
--    case FL_CURSOR_WE:     icrsr = [NSCursor resizeLeftRightCursor]; break;
--    case FL_CURSOR_SE:
--    case FL_CURSOR_NW:
--    case FL_CURSOR_NWSE:   
--      static NSCursor *nwse = nil;
--      nwse = PrepareCursor(nwse,  &Fl_X::nwse_cursor_image);
--      icrsr = nwse;
--      break;
--    case FL_CURSOR_NONE:   
--      static NSCursor *none = nil;
--      none = PrepareCursor(none,  &Fl_X::none_cursor_image);
--      icrsr = none; 
--      break;
--    case FL_CURSOR_ARROW:
--    case FL_CURSOR_DEFAULT:
--    default:			   icrsr = [NSCursor arrowCursor];
--      break;
-+  case FL_CURSOR_ARROW:   cursor = [NSCursor arrowCursor]; break;
-+  case FL_CURSOR_CROSS:   cursor = [NSCursor crosshairCursor]; break;
-+  case FL_CURSOR_INSERT:  cursor = [NSCursor IBeamCursor]; break;
-+  case FL_CURSOR_HAND:    cursor = [NSCursor pointingHandCursor]; break;
-+  case FL_CURSOR_MOVE:    cursor = [NSCursor openHandCursor]; break;
-+  case FL_CURSOR_NS:      cursor = [NSCursor resizeUpDownCursor]; break;
-+  case FL_CURSOR_WE:      cursor = [NSCursor resizeLeftRightCursor]; break;
-+  case FL_CURSOR_N:       cursor = [NSCursor resizeUpCursor]; break;
-+  case FL_CURSOR_E:       cursor = [NSCursor resizeRightCursor]; break;
-+  case FL_CURSOR_W:       cursor = [NSCursor resizeLeftCursor]; break;
-+  case FL_CURSOR_S:       cursor = [NSCursor resizeDownCursor]; break;
-+  default:
-+    return 0;
-+  }
-+
-+  [(NSCursor*)cursor retain];
-+
-+  [(NSWindow*)xid invalidateCursorRectsForView:[(NSWindow*)xid contentView]];
-+
-+  return 1;
-+}
-+
-+int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
-+  if (cursor) {
-+    [(NSCursor*)cursor release];
-+    cursor = NULL;
-+  }
-+
-+  if ((hotx < 0) || (hotx >= image->w()))
-+    return 0;
-+  if ((hoty < 0) || (hoty >= image->h()))
-+    return 0;
-+
-+  // OS X >= 10.6 can create a NSImage from a CGImage, but we need to
-+  // support older versions, hence this pesky handling.
-+
-+  NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
-+                              initWithBitmapDataPlanes:NULL
-+                              pixelsWide:image->w()
-+                              pixelsHigh:image->h()
-+                              bitsPerSample:8
-+                              samplesPerPixel:image->d()
-+                              hasAlpha:!(image->d() & 1)
-+                              isPlanar:NO
-+                              colorSpaceName:(image->d()<=2) ? NSDeviceWhiteColorSpace : NSDeviceRGBColorSpace
-+                              bytesPerRow:(image->w() * image->d())
-+                              bitsPerPixel:(image->d()*8)];
-+
-+  // Alpha needs to be premultiplied for this format
-+
-+  const uchar *i = (const uchar*)*image->data();
-+  unsigned char *o = [bitmap bitmapData];
-+  for (int y = 0;y < image->h();y++) {
-+    if (image->d() & 1) {
-+      for (int x = 0;x < image->w();x++) {
-+        unsigned int alpha;
-+        if (image->d() == 4) {
-+          alpha = i[3];
-+          *o++ = (unsigned char)((unsigned int)*i++ * alpha / 255);
-+          *o++ = (unsigned char)((unsigned int)*i++ * alpha / 255);
-+        }
-+
-+        alpha = i[1];
-+        *o++ = (unsigned char)((unsigned int)*i++ * alpha / 255);
-+        *o++ = alpha;
-+        i++;
-+  }
-+    } else {
-+      // No alpha, so we can just copy everything directly.
-+      int len = image->w() * image->d();
-+      memcpy(o, i, len);
-+      o += len;
-+      i += len;
-+    }
-+    i += image->ld();
-   }
--  [icrsr set];
--  cursor = icrsr;
-+
-+  NSImage *nsimage = [[NSImage alloc]
-+                      initWithSize:NSMakeSize(image->w(), image->h())];
-+
-+  [nsimage addRepresentation:bitmap];
-+
-+  cursor = [[NSCursor alloc]
-+            initWithImage:nsimage
-+            hotSpot:NSMakePoint(hotx, hoty)];
-+
-+  [(NSWindow*)xid invalidateCursorRectsForView:[(NSWindow*)xid contentView]];
-+
-+  [bitmap release];
-+  [nsimage release];
-+
-+  return 1;
- }
- 
- @interface FLaboutItemTarget : NSObject 
-diff -up fltk-1.3.2/src/fl_cursor.cxx.cursor fltk-1.3.2/src/fl_cursor.cxx
---- fltk-1.3.2/src/fl_cursor.cxx.cursor	2012-03-12 12:55:50.000000000 +0100
-+++ fltk-1.3.2/src/fl_cursor.cxx	2013-01-30 16:07:59.534319820 +0100
-@@ -24,297 +24,165 @@
- 
- #include <FL/Fl.H>
- #include <FL/Fl_Window.H>
-+#include <FL/Fl_Pixmap.H>
-+#include <FL/Fl_RGB_Image.H>
- #include <FL/x.H>
--#if !defined(WIN32) && !defined(__APPLE__)
--#  include <X11/cursorfont.h>
--#endif
- #include <FL/fl_draw.H>
- 
-+#include "fl_cursor_wait.xpm"
-+#include "fl_cursor_help.xpm"
-+#include "fl_cursor_nwse.xpm"
-+#include "fl_cursor_nesw.xpm"
-+#include "fl_cursor_none.xpm"
-+
- /**
-   Sets the cursor for the current window to the specified shape and colors.
-   The cursors are defined in the <FL/Enumerations.H> header file. 
-   */
-+void fl_cursor(Fl_Cursor c) {
-+  if (Fl::first_window()) Fl::first_window()->cursor(c);
-+}
-+
-+/* For back compatibility only. */
- void fl_cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
--  if (Fl::first_window()) Fl::first_window()->cursor(c,fg,bg);
-+  fl_cursor(c);
- }
-+
-+
- /** 
--    Sets the default window cursor as well as its color.
-+    Sets the default window cursor. This is the cursor that will be used
-+    after the mouse pointer leaves a widget with a custom cursor set.
- 
--    For back compatibility only.
-+    \see cursor(const Fl_RGB_Image*, int, int), default_cursor()
- */
--void Fl_Window::default_cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
--//  if (c == FL_CURSOR_DEFAULT) c = FL_CURSOR_ARROW;
--
-+void Fl_Window::default_cursor(Fl_Cursor c) {
-   cursor_default = c;
--  cursor_fg      = fg;
--  cursor_bg      = bg;
-+  cursor(c);
-+}
-+
-+
-+void fallback_cursor(Fl_Window *w, Fl_Cursor c) {
-+  const char **xpm;
-+  int hotx, hoty;
-+
-+  // The standard arrow is our final fallback, so something is broken
-+  // if we get called back here with that as an argument.
-+  if (c == FL_CURSOR_ARROW)
-+    return;
-+
-+  switch (c) {
-+  case FL_CURSOR_WAIT:
-+    xpm = (const char**)fl_cursor_wait_xpm;
-+    hotx = 8;
-+    hoty = 15;
-+    break;
-+  case FL_CURSOR_HELP:
-+    xpm = (const char**)fl_cursor_help_xpm;
-+    hotx = 1;
-+    hoty = 3;
-+    break;
-+  case FL_CURSOR_NWSE:
-+    xpm = (const char**)fl_cursor_nwse_xpm;
-+    hotx = 7;
-+    hoty = 7;
-+    break;
-+  case FL_CURSOR_NESW:
-+    xpm = (const char**)fl_cursor_nesw_xpm;
-+    hotx = 7;
-+    hoty = 7;
-+    break;
-+  case FL_CURSOR_NONE:
-+    xpm = (const char**)fl_cursor_none_xpm;
-+    hotx = 0;
-+    hoty = 0;
-+    break;
-+  default:
-+    w->cursor(FL_CURSOR_ARROW);
-+    return;
-+  }
- 
--  cursor(c, fg, bg);
-+  Fl_Pixmap pxm(xpm);
-+  Fl_RGB_Image image(&pxm);
-+
-+  w->cursor(&image, hotx, hoty);
- }
- 
--#ifdef WIN32
- 
--#  ifndef IDC_HAND
--#    define IDC_HAND	MAKEINTRESOURCE(32649)
--#  endif // !IDC_HAND
-+void Fl_Window::cursor(Fl_Cursor c) {
-+  int ret;
- 
--void Fl_Window::cursor(Fl_Cursor c, Fl_Color c1, Fl_Color c2) {
--  if (!shown()) return;
-   // the cursor must be set for the top level window, not for subwindows
-   Fl_Window *w = window(), *toplevel = this;
--  while (w) { toplevel = w; w = w->window(); }
--  if (toplevel != this) { toplevel->cursor(c, c1, c2); return; }
--  // now set the actual cursor
--  if (c == FL_CURSOR_DEFAULT) {
--    c = cursor_default;
--  }
--  if (c > FL_CURSOR_NESW) {
--    i->cursor = 0;
--  } else if (c == FL_CURSOR_DEFAULT) {
--    i->cursor = fl_default_cursor;
--  } else {
--    LPSTR n;
--    switch (c) {
--    case FL_CURSOR_ARROW:	n = IDC_ARROW; break;
--    case FL_CURSOR_CROSS:	n = IDC_CROSS; break;
--    case FL_CURSOR_WAIT:	n = IDC_WAIT; break;
--    case FL_CURSOR_INSERT:	n = IDC_IBEAM; break;
--    case FL_CURSOR_HELP:	n = IDC_HELP; break;
--    case FL_CURSOR_HAND: {
--          OSVERSIONINFO osvi;
--
--          // Get the OS version: Windows 98 and 2000 have a standard
--	  // hand cursor.
--          memset(&osvi, 0, sizeof(OSVERSIONINFO));
--          osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
--          GetVersionEx(&osvi);
--
--          if (osvi.dwMajorVersion > 4 ||
--  	      (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion > 0 &&
--  	       osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)) n = IDC_HAND;
--          else n = IDC_UPARROW;
--	} break;
--    case FL_CURSOR_MOVE:	n = IDC_SIZEALL; break;
--    case FL_CURSOR_N:
--    case FL_CURSOR_S:
--    case FL_CURSOR_NS:		n = IDC_SIZENS; break;
--    case FL_CURSOR_NE:
--    case FL_CURSOR_SW:
--    case FL_CURSOR_NESW:	n = IDC_SIZENESW; break;
--    case FL_CURSOR_E:
--    case FL_CURSOR_W:
--    case FL_CURSOR_WE:		n = IDC_SIZEWE; break;
--    case FL_CURSOR_SE:
--    case FL_CURSOR_NW:
--    case FL_CURSOR_NWSE:	n = IDC_SIZENWSE; break;
--    default:			n = IDC_NO; break;
--    }
--    i->cursor = LoadCursor(NULL, n);
-+
-+  while (w) {
-+    toplevel = w;
-+    w = w->window();
-   }
--  SetCursor(i->cursor);
--}
- 
--#elif defined(__APPLE__)
-+  if (toplevel != this) {
-+    toplevel->cursor(c);
-+    return;
-+  }
- 
--#ifdef __BIG_ENDIAN__
--# define E(x) x
--#elif defined __LITTLE_ENDIAN__
--// Don't worry. This will be resolved at compile time
--# define E(x) (x>>8)|((x<<8)&0xff00)
--#else
--# error "Either __LITTLE_ENDIAN__ or __BIG_ENDIAN__ must be defined"
--#endif
--
--CGContextRef Fl_X::help_cursor_image(void)
--{
--  int w = 20, h = 20;
--  Fl_Offscreen off = Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(w, h);
--  fl_begin_offscreen(off);
--  CGContextSetRGBFillColor( (CGContextRef)off, 0,0,0,0);
--  fl_rectf(0,0,w,h);
--  fl_color(FL_BLACK);
--  fl_font(FL_COURIER_BOLD, 20);
--  fl_draw("?", 1, h-1);
--  fl_end_offscreen();
--  return (CGContextRef)off;
--}
-+  if (c == FL_CURSOR_DEFAULT)
-+    c = cursor_default;
- 
--CGContextRef Fl_X::none_cursor_image(void)
--{
--  int w = 20, h = 20;
--  Fl_Offscreen off = Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(w, h);
--  fl_begin_offscreen(off);
--  CGContextSetRGBFillColor( (CGContextRef)off, 0,0,0,0);
--  fl_rectf(0,0,w,h);
--  fl_end_offscreen();
--  return (CGContextRef)off;
--}
-+  if (!i)
-+    return;
- 
--CGContextRef Fl_X::watch_cursor_image(void)
--{
--  int w, h, r = 5;
--  w = 2*r+6;
--  h = 4*r;
--  Fl_Offscreen off = Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(w, h);
--  fl_begin_offscreen(off);
--  CGContextSetRGBFillColor( (CGContextRef)off, 0,0,0,0);
--  fl_rectf(0,0,w,h);
--  CGContextTranslateCTM( (CGContextRef)off, w/2, h/2);
--  fl_color(FL_WHITE);
--  fl_circle(0, 0, r+1);
--  fl_color(FL_BLACK);
--  fl_rectf(int(-r*0.7), int(-r*1.7), int(1.4*r), int(3.4*r));
--  fl_rectf(r-1, -1, 3, 3);
--  fl_color(FL_WHITE);
--  fl_pie(-r, -r, 2*r, 2*r, 0, 360);
--  fl_color(FL_BLACK);
--  fl_circle(0,0,r);
--  fl_xyline(0, 0, int(-r*.7));
--  fl_xyline(0, 0, 0, int(-r*.7));
--  fl_end_offscreen();
--  return (CGContextRef)off;
--}
-+  ret = i->set_cursor(c);
-+  if (ret)
-+    return;
- 
--CGContextRef Fl_X::nesw_cursor_image(void)
--{
--  int c = 7, r = 2*c;
--  int w = r, h = r;
--  Fl_Offscreen off = Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(w, h);
--  fl_begin_offscreen(off);
--  CGContextSetRGBFillColor( (CGContextRef)off, 0,0,0,0);
--  fl_rectf(0,0,w,h);
--  CGContextTranslateCTM( (CGContextRef)off, 0, h);
--  CGContextScaleCTM( (CGContextRef)off, 1, -1);
--  fl_color(FL_BLACK);
--  fl_polygon(0, 0, c, 0, 0, c);
--  fl_polygon(r, r, r, r-c, r-c, r);
--  fl_line_style(FL_SOLID, 2, 0);
--  fl_line(0,1, r,r+1);
--  fl_line_style(FL_SOLID, 0, 0);
--  fl_end_offscreen();
--  return (CGContextRef)off;
-+  fallback_cursor(this, c);
- }
- 
--CGContextRef Fl_X::nwse_cursor_image(void)
--{
--  int c = 7, r = 2*c;
--  int w = r, h = r;
--  Fl_Offscreen off = Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(w, h);
--  fl_begin_offscreen(off);
--  CGContextSetRGBFillColor( (CGContextRef)off, 0,0,0,0);
--  fl_rectf(0,0,w,h);
--  CGContextTranslateCTM( (CGContextRef)off, 0, h);
--  CGContextScaleCTM( (CGContextRef)off, 1, -1);
--  fl_color(FL_BLACK);
--  fl_polygon(r-1, 0, r-1, c, r-1-c, 0);
--  fl_polygon(-1, r, c-1, r, -1, r-c);
--  fl_line_style(FL_SOLID, 2, 0);
--  fl_line(r-1,1, -1,r+1);
--  fl_line_style(FL_SOLID, 0, 0);
--  fl_end_offscreen();
--  return (CGContextRef)off;
--}
--
--void Fl_Window::cursor(Fl_Cursor c, Fl_Color, Fl_Color) {
--  if (c == FL_CURSOR_DEFAULT) {
--    c = cursor_default;
--  }
--  if (i) i->set_cursor(c);
--}
-+/**
-+  Changes the cursor for this window.  This always calls the system, if
-+  you are changing the cursor a lot you may want to keep track of how
-+  you set it in a static variable and call this only if the new cursor
-+  is different.
- 
--#else
-+  The default cursor will be used if the provided image cannot be used
-+  as a cursor.
- 
--// I like the MSWindows resize cursors, so I duplicate them here:
-+  \see cursor(Fl_Cursor), default_cursor()
-+*/
-+void Fl_Window::cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
-+  int ret;
- 
--#define CURSORSIZE 16
--#define HOTXY 7
--static struct TableEntry {
--  uchar bits[CURSORSIZE*CURSORSIZE/8];
--  uchar mask[CURSORSIZE*CURSORSIZE/8];
--  Cursor cursor;
--} table[] = {
--  {{	// FL_CURSOR_NS
--   0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0x80, 0x01, 0x80, 0x01,
--   0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
--   0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00},
--   {
--   0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf0, 0x0f, 0xc0, 0x03,
--   0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xf0, 0x0f,
--   0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01}},
--  {{	// FL_CURSOR_EW
--   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10,
--   0x0c, 0x30, 0xfe, 0x7f, 0xfe, 0x7f, 0x0c, 0x30, 0x08, 0x10, 0x00, 0x00,
--   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
--   {
--   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1c, 0x38,
--   0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0x1c, 0x38, 0x18, 0x18,
--   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
--  {{	// FL_CURSOR_NWSE
--   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x38, 0x00, 0x78, 0x00,
--   0xe8, 0x00, 0xc0, 0x01, 0x80, 0x03, 0x00, 0x17, 0x00, 0x1e, 0x00, 0x1c,
--   0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
--   {
--   0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0xfc, 0x00, 0x7c, 0x00, 0xfc, 0x00,
--   0xfc, 0x01, 0xec, 0x03, 0xc0, 0x37, 0x80, 0x3f, 0x00, 0x3f, 0x00, 0x3e,
--   0x00, 0x3f, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00}},
--  {{	// FL_CURSOR_NESW
--   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x1c, 0x00, 0x1e,
--   0x00, 0x17, 0x80, 0x03, 0xc0, 0x01, 0xe8, 0x00, 0x78, 0x00, 0x38, 0x00,
--   0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
--   {
--   0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3f,
--   0x80, 0x3f, 0xc0, 0x37, 0xec, 0x03, 0xfc, 0x01, 0xfc, 0x00, 0x7c, 0x00,
--   0xfc, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00}},
--  {{0}, {0}} // FL_CURSOR_NONE & unknown
--};
-+  // the cursor must be set for the top level window, not for subwindows
-+  Fl_Window *w = window(), *toplevel = this;
- 
--void Fl_Window::cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) {
--  if (!shown()) return;
--  Cursor xc;
--  int deleteit = 0;
--  if (c == FL_CURSOR_DEFAULT) {
--    c  = cursor_default;
--    fg = cursor_fg;
--    bg = cursor_bg;
-+  while (w) {
-+    toplevel = w;
-+    w = w->window();
-   }
- 
--  if (!c) {
--    xc = None;
--  } else {
--    if (c >= FL_CURSOR_NS) {
--      TableEntry *q = (c > FL_CURSOR_NESW) ? table+4 : table+(c-FL_CURSOR_NS);
--      if (!(q->cursor)) {
--	XColor dummy = { 0 };
--	Pixmap p = XCreateBitmapFromData(fl_display,
--	  RootWindow(fl_display, fl_screen), (const char*)(q->bits),
--	  CURSORSIZE, CURSORSIZE);
--	Pixmap m = XCreateBitmapFromData(fl_display,
--	  RootWindow(fl_display, fl_screen), (const char*)(q->mask),
--	  CURSORSIZE, CURSORSIZE);
--	q->cursor = XCreatePixmapCursor(fl_display, p,m,&dummy, &dummy,
--					HOTXY, HOTXY);
--	XFreePixmap(fl_display, m);
--	XFreePixmap(fl_display, p);
--      }
--      xc = q->cursor;
--    } else {
--      xc = XCreateFontCursor(fl_display, (c-1)*2);
--      deleteit = 1;
--    }
--    XColor fgc;
--    uchar r,g,b;
--    Fl::get_color(fg,r,g,b);
--    fgc.red = r<<8; fgc.green = g<<8; fgc.blue = b<<8;
--    XColor bgc;
--    Fl::get_color(bg,r,g,b);
--    bgc.red = r<<8; bgc.green = g<<8; bgc.blue = b<<8;
--    XRecolorCursor(fl_display, xc, &fgc, &bgc);
-+  if (toplevel != this) {
-+    toplevel->cursor(image, hotx, hoty);
-+    return;
-   }
--  XDefineCursor(fl_display, fl_xid(this), xc);
--  if (deleteit) XFreeCursor(fl_display, xc);
-+
-+  if (!i)
-+    return;
-+
-+  ret = i->set_cursor(image, hotx, hoty);
-+  if (ret)
-+    return;
-+
-+  cursor(FL_CURSOR_DEFAULT);
- }
- 
--#endif
-+/* For back compatibility only. */
-+void Fl_Window::cursor(Fl_Cursor c, Fl_Color, Fl_Color) {
-+  cursor(c);
-+};
-+
-+void Fl_Window::default_cursor(Fl_Cursor c, Fl_Color, Fl_Color) {
-+  default_cursor(c);
-+};
-+
- 
- //
- // End of "$Id: fl_cursor.cxx 9278 2012-03-12 11:55:50Z manolo $".
-diff -up fltk-1.3.2/src/fl_cursor_help.xpm.cursor fltk-1.3.2/src/fl_cursor_help.xpm
---- fltk-1.3.2/src/fl_cursor_help.xpm.cursor	2013-01-30 16:07:59.534319820 +0100
-+++ fltk-1.3.2/src/fl_cursor_help.xpm	2013-01-30 16:07:59.534319820 +0100
-@@ -0,0 +1,95 @@
-+/* XPM */
-+static const char * fl_cursor_help_xpm[] = {
-+"16 27 65 1",
-+" 	c None",
-+".	c #FFFFFF",
-+"+	c #E2E2E2",
-+"@	c #1C1C1C",
-+"#	c #E7E7E7",
-+"$	c #000000",
-+"%	c #212121",
-+"&	c #EAEAEA",
-+"*	c #262626",
-+"=	c #EDEDED",
-+"-	c #2C2C2C",
-+";	c #F0F0F0",
-+">	c #333333",
-+",	c #F1F1F1",
-+"'	c #393939",
-+")	c #F3F3F3",
-+"!	c #404040",
-+"~	c #484848",
-+"{	c #F4F4F4",
-+"]	c #050505",
-+"^	c #202020",
-+"/	c #707070",
-+"(	c #F5F5F5",
-+"_	c #040404",
-+":	c #E1E1E1",
-+"<	c #EEEEEE",
-+"[	c #EFEFEF",
-+"}	c #FEFEFE",
-+"|	c #3D3D3D",
-+"1	c #7E7E7E",
-+"2	c #696969",
-+"3	c #414141",
-+"4	c #131313",
-+"5	c #080808",
-+"6	c #454545",
-+"7	c #F2F2F2",
-+"8	c #878787",
-+"9	c #7D7D7D",
-+"0	c #101010",
-+"a	c #111111",
-+"b	c #FDFDFD",
-+"c	c #8A8A8A",
-+"d	c #E6E6E6",
-+"e	c #7B7B7B",
-+"f	c #4C4C4C",
-+"g	c #5C5C5C",
-+"h	c #9F9F9F",
-+"i	c #F9F9F9",
-+"j	c #F7F7F7",
-+"k	c #B1B1B1",
-+"l	c #2E2E2E",
-+"m	c #767676",
-+"n	c #DCDCDC",
-+"o	c #DEDEDE",
-+"p	c #C7C7C7",
-+"q	c #1B1B1B",
-+"r	c #6B6B6B",
-+"s	c #575757",
-+"t	c #797979",
-+"u	c #020202",
-+"v	c #010101",
-+"w	c #FBFBFB",
-+"x	c #D7D7D7",
-+"y	c #D8D8D8",
-+"z	c #060606",
-+"                ",
-+".               ",
-+".+              ",
-+".@#             ",
-+".$%&            ",
-+".$$*=           ",
-+".$$$-;          ",
-+".$$$$>,         ",
-+".$$$$$')        ",
-+".$$$$$$!)       ",
-+".$$$$$$$~{      ",
-+".$$$$]^^^/(     ",
-+".$$$$_:(<<[}    ",
-+".$$|1$2<        ",
-+".$3,(45[        ",
-+".67 78$9,       ",
-+".7   {0a( ....  ",
-+"b    ,c5[defgh, ",
-+"      )ijk_la$m.",
-+"         no.p$q.",
-+"           .r$s.",
-+"          .t$-= ",
-+"          7uv+  ",
-+"          wxy.  ",
-+"          :$z.  ",
-+"          :$z.  ",
-+"          ....  "};
-diff -up fltk-1.3.2/src/fl_cursor_nesw.xpm.cursor fltk-1.3.2/src/fl_cursor_nesw.xpm
---- fltk-1.3.2/src/fl_cursor_nesw.xpm.cursor	2013-01-30 16:07:59.534319820 +0100
-+++ fltk-1.3.2/src/fl_cursor_nesw.xpm	2013-01-30 16:07:59.534319820 +0100
-@@ -0,0 +1,46 @@
-+/* XPM */
-+static const char * fl_cursor_nesw_xpm[] = {
-+"15 15 28 1",
-+" 	c None",
-+".	c #FFFFFF",
-+"+	c #767676",
-+"@	c #000000",
-+"#	c #4E4E4E",
-+"$	c #0C0C0C",
-+"%	c #494949",
-+"&	c #4D4D4D",
-+"*	c #1B1B1B",
-+"=	c #515151",
-+"-	c #646464",
-+";	c #363636",
-+">	c #6A6A6A",
-+",	c #545454",
-+"'	c #585858",
-+")	c #242424",
-+"!	c #797979",
-+"~	c #2E2E2E",
-+"{	c #444444",
-+"]	c #3B3B3B",
-+"^	c #0A0A0A",
-+"/	c #595959",
-+"(	c #F7F7F7",
-+"_	c #080808",
-+":	c #6B6B6B",
-+"<	c #FDFDFD",
-+"[	c #FCFCFC",
-+"}	c #FEFEFE",
-+"     ..........",
-+"      .+@@@@@@.",
-+"       .#@@@@@.",
-+"        .$@@@@.",
-+"       .%@@@@@.",
-+".     .&@@@*@@.",
-+"..   .=@@@-.;@.",
-+".>. .,@@@'. .).",
-+".@!.'@@@#.   ..",
-+".@@~@@@{.     .",
-+".@@@@@].       ",
-+".@@@@^.        ",
-+".@@@@@/(       ",
-+".______:(      ",
-+"<[[[[[[[[}     "};
-diff -up fltk-1.3.2/src/fl_cursor_none.xpm.cursor fltk-1.3.2/src/fl_cursor_none.xpm
---- fltk-1.3.2/src/fl_cursor_none.xpm.cursor	2013-01-30 16:07:59.534319820 +0100
-+++ fltk-1.3.2/src/fl_cursor_none.xpm	2013-01-30 16:07:59.534319820 +0100
-@@ -0,0 +1,19 @@
-+/* XPM */
-+static const char * fl_cursor_none_xpm[] = {
-+"15 15 1 1",
-+" 	c None",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               ",
-+"               "};
-diff -up fltk-1.3.2/src/fl_cursor_nwse.xpm.cursor fltk-1.3.2/src/fl_cursor_nwse.xpm
---- fltk-1.3.2/src/fl_cursor_nwse.xpm.cursor	2013-01-30 16:07:59.534319820 +0100
-+++ fltk-1.3.2/src/fl_cursor_nwse.xpm	2013-01-30 16:07:59.535319802 +0100
-@@ -0,0 +1,46 @@
-+/* XPM */
-+static const char * fl_cursor_nwse_xpm[] = {
-+"15 15 28 1",
-+" 	c None",
-+".	c #FFFFFF",
-+"+	c #000000",
-+"@	c #767676",
-+"#	c #4E4E4E",
-+"$	c #0C0C0C",
-+"%	c #494949",
-+"&	c #1B1B1B",
-+"*	c #4D4D4D",
-+"=	c #363636",
-+"-	c #646464",
-+";	c #515151",
-+">	c #242424",
-+",	c #585858",
-+"'	c #545454",
-+")	c #6A6A6A",
-+"!	c #797979",
-+"~	c #444444",
-+"{	c #2E2E2E",
-+"]	c #3B3B3B",
-+"^	c #0A0A0A",
-+"/	c #F7F7F7",
-+"(	c #595959",
-+"_	c #6B6B6B",
-+":	c #080808",
-+"<	c #FEFEFE",
-+"[	c #FCFCFC",
-+"}	c #FDFDFD",
-+"..........     ",
-+".++++++@.      ",
-+".+++++#.       ",
-+".++++$.        ",
-+".+++++%.       ",
-+".++&+++*.     .",
-+".+=.-+++;.   ..",
-+".>. .,+++'. .).",
-+"..   .#+++,.!+.",
-+".     .~+++{++.",
-+"       .]+++++.",
-+"        .^++++.",
-+"       /(+++++.",
-+"      /_::::::.",
-+"     <[[[[[[[[}"};
-diff -up fltk-1.3.2/src/fl_cursor_wait.xpm.cursor fltk-1.3.2/src/fl_cursor_wait.xpm
---- fltk-1.3.2/src/fl_cursor_wait.xpm.cursor	2013-01-30 16:07:59.535319802 +0100
-+++ fltk-1.3.2/src/fl_cursor_wait.xpm	2013-01-30 16:07:59.535319802 +0100
-@@ -0,0 +1,72 @@
-+/* XPM */
-+static const char * fl_cursor_wait_xpm[] = {
-+"17 32 37 1",
-+" 	c None",
-+".	c #FFFFFF",
-+"+	c #2E2E2E",
-+"@	c #202020",
-+"#	c #F1F1F1",
-+"$	c #2D2D2D",
-+"%	c #000000",
-+"&	c #EDEDED",
-+"*	c #585858",
-+"=	c #575757",
-+"-	c #FBFBFB",
-+";	c #848484",
-+">	c #B8B8B8",
-+",	c #E5E5E5",
-+"'	c #F7F7F7",
-+")	c #181818",
-+"!	c #F0F0F0",
-+"~	c #616161",
-+"{	c #B7B7B7",
-+"]	c #F5F5F5",
-+"^	c #050505",
-+"/	c #D4D4D4",
-+"(	c #EEEEEE",
-+"_	c #595959",
-+":	c #7B7B7B",
-+"<	c #E9E9E9",
-+"[	c #131313",
-+"}	c #E3E3E3",
-+"|	c #767676",
-+"1	c #505050",
-+"2	c #F3F3F3",
-+"3	c #2A2A2A",
-+"4	c #070707",
-+"5	c #343434",
-+"6	c #939393",
-+"7	c #191919",
-+"8	c #6A6A6A",
-+".................",
-+".+@@@@@@@@@@@@@+.",
-+".................",
-+" #$%%%%%%%%%%%$# ",
-+" &*%%%%%%%%%%%=& ",
-+" -;%%%%%%%%%%%;- ",
-+"  >%%%%%%%%%%%>  ",
-+"  ,%%%%%%%%%%%,  ",
-+"  ')%%%%%%%%%)'  ",
-+"  !~%%%%%%%%%~!  ",
-+"   {%%%%%%%%%{   ",
-+"   ]^/...../^]   ",
-+"   (_:.....:_(   ",
-+"    <[}...}[<    ",
-+"    !|1...1|!    ",
-+"     2[3.3[2     ",
-+"     2[%.%[2     ",
-+"    !|%%.%%|!    ",
-+"    <4%%.%%4<    ",
-+"   (_%%%.%%%_(   ",
-+"   ]^%%%.%%%^]   ",
-+"   {%%%%.%%%%{   ",
-+"  !~%%%%.%%%%~!  ",
-+"  ')%%%%.%%%%)'  ",
-+"  ,%%56{.{65%%,  ",
-+"  >%*.......*%>  ",
-+" -;7&.......&7;- ",
-+" &*8.........8=& ",
-+" #$%%%%%%%%%%%$# ",
-+".................",
-+".+@@@@@@@@@@@@@+.",
-+"................."};
-diff -up fltk-1.3.2/src/Fl_win32.cxx.cursor fltk-1.3.2/src/Fl_win32.cxx
---- fltk-1.3.2/src/Fl_win32.cxx.cursor	2013-01-30 16:07:59.519320086 +0100
-+++ fltk-1.3.2/src/Fl_win32.cxx	2013-01-30 16:07:59.536319784 +0100
-@@ -1633,7 +1633,6 @@ void fl_fix_focus(); // in Fl.cxx
- 
- char fl_show_iconic;	// hack for Fl_Window::iconic()
- // int fl_background_pixel = -1; // color to use for background
--HCURSOR fl_default_cursor;
- UINT fl_wake_msg = 0;
- int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
- 
-@@ -1682,7 +1681,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
-     if (!w->icon())
-       w->icon((void *)LoadIcon(NULL, IDI_APPLICATION));
-     wcw.hIcon = wcw.hIconSm = (HICON)w->icon();
--    wcw.hCursor = fl_default_cursor = LoadCursor(NULL, IDC_ARROW);
-+    wcw.hCursor = LoadCursor(NULL, IDC_ARROW);
-     //uchar r,g,b; Fl::get_color(FL_GRAY,r,g,b);
-     //wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(r,g,b));
-     wcw.hbrBackground = NULL;
-@@ -1774,7 +1773,8 @@ Fl_X* Fl_X::make(Fl_Window* w) {
-   x->setwindow(w);
-   x->region = 0;
-   x->private_dc = 0;
--  x->cursor = fl_default_cursor;
-+  x->cursor = LoadCursor(NULL, IDC_ARROW);
-+  x->custom_cursor = 0;
-   if (!fl_codepage) fl_get_codepage();
- 
-   WCHAR *lab = NULL;
-@@ -2025,6 +2025,153 @@ void Fl_Window::label(const char *name,c
- }
- 
- ////////////////////////////////////////////////////////////////
-+
-+#ifndef IDC_HAND
-+#  define IDC_HAND  MAKEINTRESOURCE(32649)
-+#endif // !IDC_HAND
-+
-+int Fl_X::set_cursor(Fl_Cursor c) {
-+  LPSTR n;
-+  HCURSOR new_cursor;
-+
-+  if (c == FL_CURSOR_NONE)
-+    new_cursor = NULL;
-+  else {
-+    switch (c) {
-+    case FL_CURSOR_ARROW:   n = IDC_ARROW; break;
-+    case FL_CURSOR_CROSS:   n = IDC_CROSS; break;
-+    case FL_CURSOR_WAIT:    n = IDC_WAIT; break;
-+    case FL_CURSOR_INSERT:  n = IDC_IBEAM; break;
-+    case FL_CURSOR_HAND:    n = IDC_HAND; break;
-+    case FL_CURSOR_HELP:    n = IDC_HELP; break;
-+    case FL_CURSOR_MOVE:    n = IDC_SIZEALL; break;
-+    case FL_CURSOR_N:
-+    case FL_CURSOR_S:
-+      // FIXME: Should probably have fallbacks for these instead
-+    case FL_CURSOR_NS:      n = IDC_SIZENS; break;
-+    case FL_CURSOR_NE:
-+    case FL_CURSOR_SW:
-+      // FIXME: Dito.
-+    case FL_CURSOR_NESW:    n = IDC_SIZENESW; break;
-+    case FL_CURSOR_E:
-+    case FL_CURSOR_W:
-+      // FIXME: Dito.
-+    case FL_CURSOR_WE:      n = IDC_SIZEWE; break;
-+    case FL_CURSOR_SE:
-+    case FL_CURSOR_NW:
-+      // FIXME: Dito.
-+    case FL_CURSOR_NWSE:    n = IDC_SIZENWSE; break;
-+    default:
-+      return 0;
-+    }
-+
-+    new_cursor = LoadCursor(NULL, n);
-+    if (new_cursor == NULL)
-+      return 0;
-+  }
-+
-+  if ((cursor != NULL) && custom_cursor)
-+    DestroyIcon(cursor);
-+
-+  cursor = new_cursor;
-+  custom_cursor = 0;
-+
-+  SetCursor(cursor);
-+
-+  return 1;
-+}
-+
-+int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
-+  BITMAPV5HEADER bi;
-+  HBITMAP bitmap, mask;
-+  DWORD *bits;
-+  HCURSOR new_cursor;
-+
-+  if ((hotx < 0) || (hotx >= image->w()))
-+    return 0;
-+  if ((hoty < 0) || (hoty >= image->h()))
-+    return 0;
-+
-+  memset(&bi, 0, sizeof(BITMAPV5HEADER));
-+
-+  bi.bV5Size        = sizeof(BITMAPV5HEADER);
-+  bi.bV5Width       = image->w();
-+  bi.bV5Height      = -image->h(); // Negative for top-down
-+  bi.bV5Planes      = 1;
-+  bi.bV5BitCount    = 32;
-+  bi.bV5Compression = BI_BITFIELDS;
-+  bi.bV5RedMask     = 0x00FF0000;
-+  bi.bV5GreenMask   = 0x0000FF00;
-+  bi.bV5BlueMask    = 0x000000FF;
-+  bi.bV5AlphaMask   = 0xFF000000;
-+
-+  HDC hdc;
-+
-+  hdc = GetDC(NULL);
-+  bitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
-+  ReleaseDC(NULL, hdc);
-+
-+  if (bits == NULL)
-+    return 0;
-+
-+  const uchar *i = (const uchar*)*image->data();
-+  for (int y = 0;y < image->h();y++) {
-+    for (int x = 0;x < image->w();x++) {
-+      switch (image->d()) {
-+      case 1:
-+        *bits = (0xff<<24) | (i[0]<<16) | (i[0]<<8) | i[0];
-+        break;
-+      case 2:
-+        *bits = (i[1]<<24) | (i[0]<<16) | (i[0]<<8) | i[0];
-+        break;
-+      case 3:
-+        *bits = (0xff<<24) | (i[0]<<16) | (i[1]<<8) | i[2];
-+        break;
-+      case 4:
-+        *bits = (i[3]<<24) | (i[0]<<16) | (i[1]<<8) | i[2];
-+        break;
-+      }
-+      i += image->d();
-+      bits++;
-+    }
-+    i += image->ld();
-+  }
-+
-+  // A mask bitmap is still needed even though it isn't used
-+  mask = CreateBitmap(image->w(),image->h(),1,1,NULL);
-+  if (mask == NULL) {
-+    DeleteObject(bitmap);
-+    return 0;
-+  }
-+
-+  ICONINFO ii;
-+
-+  ii.fIcon    = FALSE;
-+  ii.xHotspot = hotx;
-+  ii.yHotspot = hoty;
-+  ii.hbmMask  = mask;
-+  ii.hbmColor = bitmap;
-+
-+  new_cursor = CreateIconIndirect(&ii);
-+
-+  DeleteObject(bitmap);
-+  DeleteObject(mask);
-+
-+  if (new_cursor == NULL)
-+    return 0;
-+
-+  if ((cursor != NULL) && custom_cursor)
-+    DestroyIcon(cursor);
-+
-+  cursor = new_cursor;
-+  custom_cursor = 1;
-+
-+  SetCursor(cursor);
-+
-+  return 1;
-+}
-+
-+////////////////////////////////////////////////////////////////
- // Implement the virtual functions for the base Fl_Window class:
- 
- // If the box is a filled rectangle, we can make the redisplay *look*
-diff -up fltk-1.3.2/src/Fl_Window.cxx.cursor fltk-1.3.2/src/Fl_Window.cxx
---- fltk-1.3.2/src/Fl_Window.cxx.cursor	2012-11-06 21:46:14.000000000 +0100
-+++ fltk-1.3.2/src/Fl_Window.cxx	2013-01-30 16:07:59.536319784 +0100
-@@ -62,8 +62,6 @@ void Fl_Window::_Fl_Window() {
- Fl_Window::Fl_Window(int X,int Y,int W, int H, const char *l)
- : Fl_Group(X, Y, W, H, l) {
-   cursor_default = FL_CURSOR_DEFAULT;
--  cursor_fg      = FL_BLACK;
--  cursor_bg      = FL_WHITE;
- 
-   _Fl_Window();
-   set_flag(FORCE_POSITION);
-@@ -73,8 +71,6 @@ Fl_Window::Fl_Window(int W, int H, const
- // fix common user error of a missing end() with current(0):
-   : Fl_Group((Fl_Group::current(0),0), 0, W, H, l) {
-   cursor_default = FL_CURSOR_DEFAULT;
--  cursor_fg      = FL_BLACK;
--  cursor_bg      = FL_WHITE;
- 
-   _Fl_Window();
-   clear_visible();
-diff -up fltk-1.3.2/src/Fl_x.cxx.cursor fltk-1.3.2/src/Fl_x.cxx
---- fltk-1.3.2/src/Fl_x.cxx.cursor	2013-01-30 16:07:59.512320211 +0100
-+++ fltk-1.3.2/src/Fl_x.cxx	2013-01-30 16:07:59.537319766 +0100
-@@ -59,6 +59,11 @@ static int xfixes_event_base = 0;
- static bool have_xfixes = false;
- #  endif
- 
-+#  include <X11/cursorfont.h>
-+
-+#  if HAVE_XCURSOR
-+#    include <X11/Xcursor/Xcursor.h>
-+#  endif
- static Fl_Xlib_Graphics_Driver fl_xlib_driver;
- static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
- Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the platform display
-@@ -2259,6 +2264,94 @@ void Fl_Window::size_range_() {
- }
- 
- ////////////////////////////////////////////////////////////////
-+
-+int Fl_X::set_cursor(Fl_Cursor c) {
-+  unsigned int shape;
-+  Cursor xc;
-+
-+  switch (c) {
-+  case FL_CURSOR_ARROW:   shape = XC_left_ptr; break;
-+  case FL_CURSOR_CROSS:   shape = XC_tcross; break;
-+  case FL_CURSOR_WAIT:    shape = XC_watch; break;
-+  case FL_CURSOR_INSERT:  shape = XC_xterm; break;
-+  case FL_CURSOR_HAND:    shape = XC_hand2; break;
-+  case FL_CURSOR_HELP:    shape = XC_question_arrow; break;
-+  case FL_CURSOR_MOVE:    shape = XC_fleur; break;
-+  case FL_CURSOR_NS:      shape = XC_sb_v_double_arrow; break;
-+  case FL_CURSOR_WE:      shape = XC_sb_h_double_arrow; break;
-+  case FL_CURSOR_NE:      shape = XC_top_right_corner; break;
-+  case FL_CURSOR_N:       shape = XC_top_side; break;
-+  case FL_CURSOR_NW:      shape = XC_top_left_corner; break;
-+  case FL_CURSOR_E:       shape = XC_right_side; break;
-+  case FL_CURSOR_W:       shape = XC_left_side; break;
-+  case FL_CURSOR_SE:      shape = XC_bottom_right_corner; break;
-+  case FL_CURSOR_S:       shape = XC_bottom_side; break;
-+  case FL_CURSOR_SW:      shape = XC_bottom_left_corner; break;
-+  default:
-+    return 0;
-+  }
-+
-+  xc = XCreateFontCursor(fl_display, shape);
-+  XDefineCursor(fl_display, xid, xc);
-+  XFreeCursor(fl_display, xc);
-+
-+  return 1;
-+}
-+
-+int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
-+#if ! HAVE_XCURSOR
-+  return 0;
-+#else
-+  XcursorImage *cursor;
-+  Cursor xc;
-+
-+  if ((hotx < 0) || (hotx >= image->w()))
-+    return 0;
-+  if ((hoty < 0) || (hoty >= image->h()))
-+    return 0;
-+
-+  cursor = XcursorImageCreate(image->w(), image->h());
-+  if (!cursor)
-+    return 0;
-+
-+  const uchar *i = (const uchar*)*image->data();
-+  XcursorPixel *o = cursor->pixels;
-+  for (int y = 0;y < image->h();y++) {
-+    for (int x = 0;x < image->w();x++) {
-+      switch (image->d()) {
-+      case 1:
-+        *o = (0xff<<24) | (i[0]<<16) | (i[0]<<8) | i[0];
-+        break;
-+      case 2:
-+        *o = (i[1]<<24) | (i[0]<<16) | (i[0]<<8) | i[0];
-+        break;
-+      case 3:
-+        *o = (0xff<<24) | (i[0]<<16) | (i[1]<<8) | i[2];
-+        break;
-+      case 4:
-+        *o = (i[3]<<24) | (i[0]<<16) | (i[1]<<8) | i[2];
-+        break;
-+      }
-+      i += image->d();
-+      o++;
-+    }
-+    i += image->ld();
-+  }
-+
-+  cursor->xhot = hotx;
-+  cursor->yhot = hoty;
-+
-+  xc = XcursorImageLoadCursor(fl_display, cursor);
-+  XDefineCursor(fl_display, xid, xc);
-+  XFreeCursor(fl_display, xc);
-+
-+  XcursorImageDestroy(cursor);
-+
-+  return 1;
-+#endif
-+}
-+
-+////////////////////////////////////////////////////////////////
- 
- // returns pointer to the filename, or null if name ends with '/'
- const char *fl_filename_name(const char *name) {
-diff -up fltk-1.3.2/test/cursor.cxx.cursor fltk-1.3.2/test/cursor.cxx
---- fltk-1.3.2/test/cursor.cxx.cursor	2011-07-19 06:49:30.000000000 +0200
-+++ fltk-1.3.2/test/cursor.cxx	2013-01-30 16:07:59.537319766 +0100
-@@ -23,8 +23,6 @@
- #include <FL/fl_draw.H>
- #include <FL/Fl_Box.H>
- 
--Fl_Color fg = FL_BLACK;
--Fl_Color bg = FL_WHITE;
- Fl_Cursor cursor = FL_CURSOR_DEFAULT;
- 
- Fl_Hor_Value_Slider *cursor_slider;
-@@ -32,7 +30,7 @@ Fl_Hor_Value_Slider *cursor_slider;
- void choice_cb(Fl_Widget *, void *v) {
-   cursor = (Fl_Cursor)(fl_intptr_t)v;
-   cursor_slider->value(cursor);
--  fl_cursor(cursor,fg,bg);
-+  fl_cursor(cursor);
- }
- 
- Fl_Menu_Item choices[] = {
-@@ -48,8 +46,6 @@ Fl_Menu_Item choices[] = {
-   {"FL_CURSOR_WE",0,choice_cb,(void*)FL_CURSOR_WE},
-   {"FL_CURSOR_NWSE",0,choice_cb,(void*)FL_CURSOR_NWSE},
-   {"FL_CURSOR_NESW",0,choice_cb,(void*)FL_CURSOR_NESW},
--  {"FL_CURSOR_NONE",0,choice_cb,(void*)FL_CURSOR_NONE},
--#if 0
-   {"FL_CURSOR_N",0,choice_cb,(void*)FL_CURSOR_N},
-   {"FL_CURSOR_NE",0,choice_cb,(void*)FL_CURSOR_NE},
-   {"FL_CURSOR_E",0,choice_cb,(void*)FL_CURSOR_E},
-@@ -58,26 +54,14 @@ Fl_Menu_Item choices[] = {
-   {"FL_CURSOR_SW",0,choice_cb,(void*)FL_CURSOR_SW},
-   {"FL_CURSOR_W",0,choice_cb,(void*)FL_CURSOR_W},
-   {"FL_CURSOR_NW",0,choice_cb,(void*)FL_CURSOR_NW},
--#endif
-+  {"FL_CURSOR_NONE",0,choice_cb,(void*)FL_CURSOR_NONE},
-   {0}
- };
- 
- void setcursor(Fl_Widget *o, void *) {
-   Fl_Hor_Value_Slider *slider = (Fl_Hor_Value_Slider *)o;
-   cursor = Fl_Cursor((int)slider->value());
--  fl_cursor(cursor,fg,bg);
--}
--
--void setfg(Fl_Widget *o, void *) {
--  Fl_Hor_Value_Slider *slider = (Fl_Hor_Value_Slider *)o;
--  fg = Fl_Color((int)slider->value());
--  fl_cursor(cursor,fg,bg);
--}
--
--void setbg(Fl_Widget *o, void *) {
--  Fl_Hor_Value_Slider *slider = (Fl_Hor_Value_Slider *)o;
--  bg = Fl_Color((int)slider->value());
--  fl_cursor(cursor,fg,bg);
-+  fl_cursor(cursor);
- }
- 
- // draw the label without any ^C or \nnn conversions:
-@@ -103,29 +87,11 @@ int main(int argc, char **argv) {
-   slider1.align(FL_ALIGN_LEFT);
-   slider1.step(1);
-   slider1.precision(0);
--  slider1.bounds(0,100);
-+  slider1.bounds(0,255);
-   slider1.value(0);
-   slider1.callback(setcursor);
-   slider1.value(cursor);
- 
--  Fl_Hor_Value_Slider slider2(80,220,310,30,"fgcolor:");
--  slider2.align(FL_ALIGN_LEFT);
--  slider2.step(1);
--  slider2.precision(0);
--  slider2.bounds(0,255);
--  slider2.value(0);
--  slider2.callback(setfg);
--  slider2.value(fg);
--
--  Fl_Hor_Value_Slider slider3(80,260,310,30,"bgcolor:");
--  slider3.align(FL_ALIGN_LEFT);
--  slider3.step(1);
--  slider3.precision(0);
--  slider3.bounds(0,255);
--  slider3.value(0);
--  slider3.callback(setbg);
--  slider3.value(bg);
--
- #if 0
-   // draw the manual's diagram of cursors...
-   window.size(400,800);
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v6.3.x-clipboard-x11.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v6.3.x-clipboard-x11.patch
deleted file mode 100644
index 9e253a3..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v6.3.x-clipboard-x11.patch
+++ /dev/null
@@ -1,355 +0,0 @@
-diff -up fltk-1.3.2/CMakeLists.txt.clp-x11 fltk-1.3.2/CMakeLists.txt
---- fltk-1.3.2/CMakeLists.txt.clp-x11	2012-09-13 16:19:01.000000000 +0200
-+++ fltk-1.3.2/CMakeLists.txt	2013-01-30 15:56:25.810663430 +0100
-@@ -515,6 +515,20 @@ else()
- endif(OPTION_USE_XINERAMA)
- 
- #######################################################################
-+if(X11_Xfixes_FOUND)
-+   option(OPTION_USE_XFIXES "use lib XFIXES" ON)
-+endif(X11_Xfixes_FOUND)
-+
-+if(OPTION_USE_XFIXES)
-+   set(HAVE_XFIXES ${X11_Xfixes_FOUND})
-+   include_directories(${X11_Xfixes_INCLUDE_PATH})
-+   list(APPEND FLTK_LDLIBS -lXfixes)
-+   set(FLTK_XFIXES_FOUND TRUE)
-+else()
-+   set(FLTK_XFIXES_FOUND FALSE)
-+endif(OPTION_USE_XFIXES)
-+
-+#######################################################################
- if(X11_Xft_FOUND)
-    option(OPTION_USE_XFT "use lib Xft" ON)
- endif(X11_Xft_FOUND)
-diff -up fltk-1.3.2/configh.cmake.in.clp-x11 fltk-1.3.2/configh.cmake.in
---- fltk-1.3.2/configh.cmake.in.clp-x11	2011-07-19 06:49:30.000000000 +0200
-+++ fltk-1.3.2/configh.cmake.in	2013-01-30 15:56:25.810663430 +0100
-@@ -108,6 +108,14 @@
- #define USE_XDBE HAVE_XDBE
- 
- /*
-+ * HAVE_XFIXES:
-+ *
-+ * Do we have the X fixes extension?
-+ */
-+
-+#cmakedefine01 HAVE_XFIXES
-+
-+/*
-  * __APPLE_QUARTZ__:
-  *
-  * If __APPLE_QUARTZ__ is defined, FLTK will be
-diff -up fltk-1.3.2/configh.in.clp-x11 fltk-1.3.2/configh.in
---- fltk-1.3.2/configh.in.clp-x11	2011-10-04 11:21:47.000000000 +0200
-+++ fltk-1.3.2/configh.in	2013-01-30 15:56:25.810663430 +0100
-@@ -108,6 +108,14 @@
- #define USE_XDBE HAVE_XDBE
- 
- /*
-+ * HAVE_XFIXES:
-+ *
-+ * Do we have the X fixes extension?
-+ */
-+
-+#define HAVE_XFIXES 0
-+
-+/*
-  * __APPLE_QUARTZ__:
-  *
-  * All Apple implementations are now based on Quartz and Cocoa,
-diff -up fltk-1.3.2/configure.in.clp-x11 fltk-1.3.2/configure.in
---- fltk-1.3.2/configure.in.clp-x11	2013-01-30 15:56:25.802663573 +0100
-+++ fltk-1.3.2/configure.in	2013-01-30 15:56:25.810663430 +0100
-@@ -999,6 +999,16 @@ case $uname_GUI in
- 		LIBS="-lXext $LIBS")
- 	fi
- 
-+	dnl Check for the Xfixes extension unless disabled...
-+        AC_ARG_ENABLE(xfixes, [  --enable-xfixes       turn on Xfixes support [default=yes]])
-+
-+	if test x$enable_xfixes != xno; then
-+	    AC_CHECK_HEADER(X11/extensions/Xfixes.h, AC_DEFINE(HAVE_XFIXES),,
-+	        [#include <X11/Xlib.h>])
-+	    AC_CHECK_LIB(Xfixes, XFixesQueryExtension,
-+		LIBS="-lXfixes $LIBS")
-+	fi
-+
- 	dnl Check for overlay visuals...
- 	AC_PATH_PROG(XPROP, xprop)
- 	AC_CACHE_CHECK(for X overlay visuals, ac_cv_have_overlay,
-diff -up fltk-1.3.2/fluid/CMakeLists.txt.clp-x11 fltk-1.3.2/fluid/CMakeLists.txt
-diff -up fltk-1.3.2/src/CMakeLists.txt.clp-x11 fltk-1.3.2/src/CMakeLists.txt
---- fltk-1.3.2/src/CMakeLists.txt.clp-x11	2013-01-30 16:06:00.785430590 +0100
-+++ fltk-1.3.2/src/CMakeLists.txt	2013-01-30 16:06:17.883126642 +0100
-@@ -243,6 +243,10 @@ if(HAVE_XINERAMA)
-    target_link_libraries(fltk ${X11_Xinerama_LIB})
- endif(HAVE_XINERAMA)
- 
-+if(HAVE_XFIXES)
-+   target_link_libraries(fltk ${X11_Xfixes_LIB})
-+endif(HAVE_XFIXES)
-+
- if(USE_XFT)
-    target_link_libraries(fltk ${X11_Xft_LIB})
- endif(USE_XFT)
-diff -up fltk-1.3.2/src/Fl_x.cxx.clp-x11 fltk-1.3.2/src/Fl_x.cxx
---- fltk-1.3.2/src/Fl_x.cxx.clp-x11	2013-01-30 15:56:25.793663733 +0100
-+++ fltk-1.3.2/src/Fl_x.cxx	2013-01-30 16:03:37.355981103 +0100
-@@ -53,6 +53,12 @@ static XRRUpdateConfiguration_type XRRUp
- static int randrEventBase;                  // base of RandR-defined events
- #endif
- 
-+#  if HAVE_XFIXES
-+#  include <X11/extensions/Xfixes.h>
-+static int xfixes_event_base = 0;
-+static bool have_xfixes = false;
-+#  endif
-+
- static Fl_Xlib_Graphics_Driver fl_xlib_driver;
- static Fl_Display_Device fl_xlib_display(&fl_xlib_driver);
- Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the platform display
-@@ -307,6 +313,9 @@ static Atom WM_PROTOCOLS;
- static Atom fl_MOTIF_WM_HINTS;
- static Atom TARGETS;
- static Atom CLIPBOARD;
-+static Atom TIMESTAMP;
-+static Atom PRIMARY_TIMESTAMP;
-+static Atom CLIPBOARD_TIMESTAMP;
- Atom fl_XdndAware;
- Atom fl_XdndSelection;
- Atom fl_XdndEnter;
-@@ -667,6 +676,9 @@ void fl_open_display(Display* d) {
-   fl_MOTIF_WM_HINTS     = XInternAtom(d, "_MOTIF_WM_HINTS",     0);
-   TARGETS               = XInternAtom(d, "TARGETS",             0);
-   CLIPBOARD             = XInternAtom(d, "CLIPBOARD",           0);
-+  TIMESTAMP             = XInternAtom(d, "TIMESTAMP",           0);
-+  PRIMARY_TIMESTAMP     = XInternAtom(d, "PRIMARY_TIMESTAMP",   0);
-+  CLIPBOARD_TIMESTAMP   = XInternAtom(d, "CLIPBOARD_TIMESTAMP", 0);
-   fl_XdndAware          = XInternAtom(d, "XdndAware",           0);
-   fl_XdndSelection      = XInternAtom(d, "XdndSelection",       0);
-   fl_XdndEnter          = XInternAtom(d, "XdndEnter",           0);
-@@ -713,6 +725,15 @@ void fl_open_display(Display* d) {
- #if !USE_COLORMAP
-   Fl::visual(FL_RGB);
- #endif
-+
-+#if HAVE_XFIXES
-+  int error_base;
-+  if (XFixesQueryExtension(fl_display, &xfixes_event_base, &error_base))
-+    have_xfixes = true;
-+  else
-+    have_xfixes = false;
-+#endif
-+
- #if USE_XRANDR
-   void *libxrandr_addr = dlopen("libXrandr.so.2", RTLD_LAZY);
-   if (!libxrandr_addr)  libxrandr_addr = dlopen("libXrandr.so", RTLD_LAZY);
-@@ -901,6 +922,107 @@ void Fl::copy(const char *stuff, int len
- }
- 
- ////////////////////////////////////////////////////////////////
-+// Code for tracking clipboard changes:
-+
-+static Time primary_timestamp = -1;
-+static Time clipboard_timestamp = -1;
-+
-+extern bool fl_clipboard_notify_empty(void);
-+extern void fl_trigger_clipboard_notify(int source);
-+
-+static void poll_clipboard_owner(void) {
-+  Window xid;
-+
-+#if HAVE_XFIXES
-+  // No polling needed with Xfixes
-+  if (have_xfixes)
-+    return;
-+#endif
-+
-+  // No one is interested, so no point polling
-+  if (fl_clipboard_notify_empty())
-+    return;
-+
-+  // We need a window for this to work
-+  if (!Fl::first_window())
-+    return;
-+  xid = fl_xid(Fl::first_window());
-+  if (!xid)
-+    return;
-+
-+  // Request an update of the selection time for both the primary and
-+  // clipboard selections. Magic continues when we get a SelectionNotify.
-+  if (!fl_i_own_selection[0])
-+    XConvertSelection(fl_display, XA_PRIMARY, TIMESTAMP, PRIMARY_TIMESTAMP,
-+                      xid, fl_event_time);
-+  if (!fl_i_own_selection[1])
-+    XConvertSelection(fl_display, CLIPBOARD, TIMESTAMP, CLIPBOARD_TIMESTAMP,
-+                      xid, fl_event_time);
-+}
-+
-+static void clipboard_timeout(void *data)
-+{
-+  // No one is interested, so stop polling
-+  if (fl_clipboard_notify_empty())
-+    return;
-+
-+  poll_clipboard_owner();
-+
-+  Fl::repeat_timeout(0.5, clipboard_timeout);
-+}
-+
-+static void handle_clipboard_timestamp(int clipboard, Time time)
-+{
-+  Time *timestamp;
-+
-+  timestamp = clipboard ? &clipboard_timestamp : &primary_timestamp;
-+
-+#if HAVE_XFIXES
-+  if (!have_xfixes)
-+#endif
-+  {
-+    // Initial scan, just store the value
-+    if (*timestamp == (Time)-1) {
-+      *timestamp = time;
-+      return;
-+    }
-+  }
-+
-+  // Same selection
-+  if (time == *timestamp)
-+    return;
-+
-+  *timestamp = time;
-+
-+  // The clipboard change is the event that caused us to request
-+  // the clipboard data, so use that time as the latest event.
-+  if (time > fl_event_time)
-+    fl_event_time = time;
-+
-+  // Something happened! Let's tell someone!
-+  fl_trigger_clipboard_notify(clipboard);
-+}
-+
-+void fl_clipboard_notify_change() {
-+  // Reset the timestamps if we've going idle so that you don't
-+  // get a bogus immediate trigger next time they're activated.
-+  if (fl_clipboard_notify_empty()) {
-+    primary_timestamp = -1;
-+    clipboard_timestamp = -1;
-+  } else {
-+#if HAVE_XFIXES
-+    if (!have_xfixes)
-+#endif
-+    {
-+      poll_clipboard_owner();
-+
-+      if (!Fl::has_timeout(clipboard_timeout))
-+        Fl::add_timeout(0.5, clipboard_timeout);
-+    }
-+  }
-+}
-+
-+////////////////////////////////////////////////////////////////
- 
- const XEvent* fl_xevent; // the current x event
- ulong fl_event_time; // the last timestamp from an x event
-@@ -1024,7 +1141,6 @@ int fl_handle(const XEvent& thisevent)
-     return 0;
- 
-   case SelectionNotify: {
--    if (!fl_selection_requestor) return 0;
-     static unsigned char* buffer = 0;
-     if (buffer) {XFree(buffer); buffer = 0;}
-     long bytesread = 0;
-@@ -1040,6 +1156,19 @@ int fl_handle(const XEvent& thisevent)
-                              bytesread/4, 65536, 1, 0,
-                              &actual, &format, &count, &remaining,
-                              &portion)) break; // quit on error
-+
-+      if ((fl_xevent->xselection.property == PRIMARY_TIMESTAMP) ||
-+          (fl_xevent->xselection.property == CLIPBOARD_TIMESTAMP)) {
-+        if (portion && format == 32 && count == 1) {
-+          Time t = *(unsigned int*)portion;
-+          if (fl_xevent->xselection.property == CLIPBOARD_TIMESTAMP)
-+            handle_clipboard_timestamp(1, t);
-+          else
-+            handle_clipboard_timestamp(0, t);
-+        }
-+        return true;
-+      }
-+
-       if (actual == TARGETS || actual == XA_ATOM) {
- 	Atom type = XA_STRING;
- 	for (unsigned i = 0; i<count; i++) {
-@@ -1076,6 +1205,9 @@ int fl_handle(const XEvent& thisevent)
-       buffer[bytesread] = 0;
-       convert_crlf(buffer, bytesread);
-     }
-+
-+    if (!fl_selection_requestor) return 0;
-+
-     Fl::e_text = buffer ? (char*)buffer : (char *)"";
-     Fl::e_length = bytesread;
-     int old_event = Fl::e_number;
-@@ -1096,6 +1228,7 @@ int fl_handle(const XEvent& thisevent)
-   case SelectionClear: {
-     int clipboard = fl_xevent->xselectionclear.selection == CLIPBOARD;
-     fl_i_own_selection[clipboard] = 0;
-+    poll_clipboard_owner();
-     return 1;}
- 
-   case SelectionRequest: {
-@@ -1308,6 +1441,9 @@ int fl_handle(const XEvent& thisevent)
-   case FocusIn:
-     if (fl_xim_ic) XSetICFocus(fl_xim_ic);
-     event = FL_FOCUS;
-+    // If the user has toggled from another application to this one,
-+    // then it's a good time to check for clipboard changes.
-+    poll_clipboard_owner();
-     break;
- 
-   case FocusOut:
-@@ -1676,6 +1812,25 @@ int fl_handle(const XEvent& thisevent)
-     }
-   }
- 
-+#if HAVE_XFIXES
-+  switch (xevent.type - xfixes_event_base) {
-+  case XFixesSelectionNotify: {
-+    // Someone feeding us bogus events?
-+    if (!have_xfixes)
-+      return true;
-+
-+    XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)&xevent;
-+
-+    if ((selection_notify->selection == XA_PRIMARY) && !fl_i_own_selection[0])
-+      handle_clipboard_timestamp(0, selection_notify->selection_timestamp);
-+    else if ((selection_notify->selection == CLIPBOARD) && !fl_i_own_selection[1])
-+      handle_clipboard_timestamp(1, selection_notify->selection_timestamp);
-+
-+    return true;
-+    }
-+  }
-+#endif
-+
-   return Fl::handle(event, window);
- }
- 
-@@ -1995,6 +2150,16 @@ void Fl_X::make_xid(Fl_Window* win, XVis
-     XChangeProperty(fl_display, xp->xid, net_wm_type, XA_ATOM, 32, PropModeReplace, (unsigned char*)&net_wm_type_kind, 1);
-   }
- 
-+#if HAVE_XFIXES
-+  // register for clipboard change notifications
-+  if (have_xfixes && !win->parent()) {
-+    XFixesSelectSelectionInput(fl_display, xp->xid, XA_PRIMARY,
-+                               XFixesSetSelectionOwnerNotifyMask);
-+    XFixesSelectSelectionInput(fl_display, xp->xid, CLIPBOARD,
-+                               XFixesSetSelectionOwnerNotifyMask);
-+  }
-+#endif
-+
-   XMapWindow(fl_display, xp->xid);
-   if (showit) {
-     win->set_visible();
-diff -up fltk-1.3.2/test/CMakeLists.txt.clp-x11 fltk-1.3.2/test/CMakeLists.txt
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v6.3.x-keyboard-osx.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v6.3.x-keyboard-osx.patch
deleted file mode 100644
index cf13aad..0000000
--- a/contrib/packages/rpm/el5/SOURCES/fltk-1_v6.3.x-keyboard-osx.patch
+++ /dev/null
@@ -1,375 +0,0 @@
-diff -ur fltk-1.3.0r9619.org/configure.in fltk-1.3.0r9619/configure.in
---- fltk-1.3.0r9619.org/configure.in	2012-04-22 04:45:09.000000000 +0200
-+++ fltk-1.3.0r9619/configure.in	2012-06-18 13:47:33.290447462 +0200
-@@ -865,6 +865,8 @@
-     Darwin*)
-         # MacOS X uses Cocoa for graphics.
-         LIBS="$LIBS -framework Cocoa"
-+        # And some Carbon for keyboard handling
-+        LIBS="$LIBS -framework Carbon"
- 
- 	if test x$have_pthread = xyes; then
- 	    AC_DEFINE(HAVE_PTHREAD)
-diff -ur fltk-1.3.0r9619.org/src/Fl_cocoa.mm fltk-1.3.0r9619/src/Fl_cocoa.mm
---- fltk-1.3.0r9619.org/src/Fl_cocoa.mm	2012-06-16 10:49:52.000000000 +0200
-+++ fltk-1.3.0r9619/src/Fl_cocoa.mm	2012-06-18 13:47:42.944910782 +0200
-@@ -53,6 +53,7 @@
- #include <math.h>
- 
- #import <Cocoa/Cocoa.h>
-+#import <Carbon/Carbon.h>
- 
- #ifndef NSINTEGER_DEFINED // appears with 10.5 in NSObjCRuntime.h
- #if defined(__LP64__) && __LP64__
-@@ -114,6 +115,8 @@
- extern Fl_Window* fl_xmousewin;
- #endif
- 
-+bool use_simple_keyboard = false;
-+
- enum { FLTKTimerEvent = 1, FLTKDataReadyEvent };
- 
- 
-@@ -130,6 +133,39 @@
- {
- }
- 
-+// Undocumented voodoo. Taken from Mozilla.
-+#define ENABLE_ROMAN_KYBDS_ONLY -23
-+
-+void fl_update_focus(void)
-+{
-+  Fl_Widget *focus;
-+
-+  focus = Fl::grab();
-+  if (!focus)
-+    focus = Fl::focus();
-+  if (!focus)
-+    return;
-+
-+  if (focus->simple_keyboard())
-+    use_simple_keyboard = true;
-+  else
-+    use_simple_keyboard = false;
-+
-+  // Force a "Roman" or "ASCII" keyboard, which both the Mozilla and
-+  // Safari people seem to think implies turning off advanced IME stuff
-+  // (see nsTSMManager::SyncKeyScript in Mozilla and enableSecureTextInput
-+  // in Safari/Webcore). Should be good enough for us then...
-+#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
-+  CFArrayRef inputSources = TISCreateASCIICapableInputSourceList();
-+  TSMSetDocumentProperty(TSMGetActiveDocument(),
-+                         kTSMDocumentEnabledInputSourcesPropertyTag,
-+                         sizeof(CFArrayRef), &inputSources);
-+  CFRelease(inputSources);
-+#else
-+  KeyScript(use_simple_keyboard ? ENABLE_ROMAN_KYBDS_ONLY : smKeyEnableKybds);
-+#endif  
-+}
-+
- /*
-  * Mac keyboard lookup table
-  */
-@@ -908,6 +944,25 @@
- }
- @end
- 
-+static const char* cocoaDead2FLTK(const char *in)
-+{
-+  if (strcmp(in, "\140") == 0)      // GRAVE ACCENT
-+    return "\314\200";              // COMBINING GRAVE ACCENT
-+  if (strcmp(in, "\302\264") == 0)  // ACUTE ACCENT
-+    return "\314\201";              // COMBINING ACUTE ACCENT
-+  if (strcmp(in, "\136") == 0)      // CIRCUMFLEX ACCENT
-+    return "\314\202";              // COMBINING CIRCUMFLEX ACCENT
-+  if (strcmp(in, "\176") == 0)      // TILDE
-+    return "\314\203";              // COMBINING TILDE
-+  if (strcmp(in, "\302\250") == 0)  // DIAERESIS
-+    return "\314\210";              // COMBINING DIAERESIS
-+  // FIXME: OS X dead key behaviour isn't documented and I don't have
-+  //        any more keyboards to test with...
-+
-+  // hope that OS X gave us something proper to begin with
-+  return in;
-+}
-+
- /*
- Handle cocoa keyboard events
- Events during a character composition sequence:
-@@ -1648,6 +1703,7 @@
- - (void)rightMouseDragged:(NSEvent *)theEvent;
- - (void)otherMouseDragged:(NSEvent *)theEvent;
- - (void)scrollWheel:(NSEvent *)theEvent;
-++ (NSString *)keyTranslate:(UInt16)keyCode withModifierFlags:(UInt32)modifierFlags;
- - (BOOL)handleKeyDown:(NSEvent *)theEvent;
- - (void)keyDown:(NSEvent *)theEvent;
- - (void)keyUp:(NSEvent *)theEvent;
-@@ -1726,6 +1782,130 @@
- - (void)scrollWheel:(NSEvent *)theEvent {
-   cocoaMouseWheelHandler(theEvent);
- }
-++ (NSString *)keyTranslate:(UInt16)keyCode withModifierFlags:(UInt32)modifierFlags {
-+  const UCKeyboardLayout *layout;
-+  OSStatus err;
-+
-+  layout = NULL;
-+
-+#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
-+  TISInputSourceRef keyboard;
-+  CFDataRef uchr;
-+
-+  keyboard = TISCopyCurrentKeyboardInputSource();
-+  uchr = (CFDataRef)TISGetInputSourceProperty(keyboard,
-+                                              kTISPropertyUnicodeKeyLayoutData);
-+  if (uchr == NULL)
-+    return nil;
-+
-+  layout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
-+#else
-+  KeyboardLayoutRef old_layout;
-+  int kind;
-+
-+  err = KLGetCurrentKeyboardLayout(&old_layout);
-+  if (err != noErr)
-+    return nil;
-+
-+  err = KLGetKeyboardLayoutProperty(old_layout, kKLKind,
-+                                    (const void**)&kind);
-+  if (err != noErr)
-+    return nil;
-+
-+  // Old, crufty layout format?
-+  if (kind == kKLKCHRKind) {
-+    void *kchr_layout;
-+
-+    UInt32 chars, state;
-+    char buf[3];
-+
-+    unichar result[16];
-+    ByteCount in_len, out_len;
-+
-+    err = KLGetKeyboardLayoutProperty(old_layout, kKLKCHRData,
-+                                      (const void**)&kchr_layout);
-+    if (err != noErr)
-+      return nil;
-+
-+    state = 0;
-+
-+    keyCode &= 0x7f;
-+    modifierFlags &= 0xff00;
-+
-+    chars = KeyTranslate(kchr_layout, keyCode | modifierFlags, &state);
-+
-+    buf[0] = (chars >> 16) & 0xff;
-+    buf[1] = chars & 0xff;
-+    buf[2] = '\0';
-+
-+    if (buf[0] == '\0') {
-+      buf[0] = buf[1];
-+      buf[1] = '\0';
-+    }
-+
-+    // The data is now in some layout specific encoding. Need to convert
-+    // this to unicode.
-+
-+    ScriptCode script;
-+    TextEncoding encoding;
-+    TECObjectRef converter;
-+
-+    script = (ScriptCode)GetScriptManagerVariable(smKeyScript);
-+
-+    err = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare,
-+                                          kTextRegionDontCare, NULL,
-+                                          &encoding);
-+    if (err != noErr)
-+      return nil;
-+
-+    err = TECCreateConverter(&converter, encoding, kTextEncodingUnicodeV4_0);
-+    if (err != noErr)
-+      return nil;
-+
-+    in_len = strlen(buf);
-+    out_len = sizeof(result);
-+
-+    err = TECConvertText(converter, (ConstTextPtr)buf, in_len, &in_len,
-+                         (TextPtr)result, out_len, &out_len);
-+
-+    TECDisposeConverter(converter);
-+
-+    if (err != noErr)
-+      return nil;
-+
-+    return [NSString stringWithCharacters:result
-+                     length:(out_len / sizeof(unichar))];
-+  }
-+
-+  if ((kind != kKLKCHRuchrKind) && (kind != kKLuchrKind))
-+    return nil;
-+
-+  err = KLGetKeyboardLayoutProperty(old_layout, kKLuchrData,
-+                                    (const void**)&layout);
-+  if (err != noErr)
-+    return nil;
-+#endif
-+ 
-+  if (layout == NULL)
-+    return nil;
-+
-+  UInt32 dead_state;
-+  UniCharCount max_len, actual_len;
-+  UniChar string[255];
-+
-+  dead_state = 0;
-+  max_len = sizeof(string)/sizeof(*string);
-+
-+  modifierFlags = (modifierFlags >> 8) & 0xff;
-+
-+  err = UCKeyTranslate(layout, keyCode, kUCKeyActionDown, modifierFlags,
-+                       LMGetKbdType(), 0, &dead_state, max_len, &actual_len,
-+                       string);
-+  if (err != noErr)
-+    return nil;
-+
-+  return [NSString stringWithCharacters:string length:actual_len];
-+}
- - (BOOL)handleKeyDown:(NSEvent *)theEvent {
-   //NSLog(@"handleKeyDown");
-   fl_lock_function();
-@@ -1752,14 +1932,47 @@
-       break;
-     }
-   }
--  if (!no_text_key && !(Fl::e_state & FL_META) ) {
--    // Don't send cmd-<key> to interpretKeyEvents because it beeps.
-+  if (!no_text_key) {
-+    // The simple keyboard model will ignore insertText, so we need to grab
-+    // the symbol directly from the event. Note that we still use setMarkedText.
-+    if (use_simple_keyboard) {
-+      NSString *simple_chars;
-+      UInt32 modifiers;
-+
-+      // We want a "normal" symbol out of the event, which basically means
-+      // we only respect the shift and alt/altgr modifiers. Cocoa can help
-+      // us if we only wanted shift, but as we also want alt/altgr, we'll
-+      // have to do some lookup ourselves. This matches our behaviour on
-+      // other platforms.
-+
-+      modifiers = 0;
-+      if ([theEvent modifierFlags] & NSAlphaShiftKeyMask)
-+        modifiers |= alphaLock;
-+      if ([theEvent modifierFlags] & NSShiftKeyMask)
-+        modifiers |= shiftKey;
-+      if ([theEvent modifierFlags] & NSAlternateKeyMask)
-+        modifiers |= optionKey;
-+
-+      simple_chars = [FLView keyTranslate:[theEvent keyCode]
-+                             withModifierFlags:modifiers];
-+      if (simple_chars == nil) {
-+        // Something went wrong. Fall back to what Cocoa gave us...
-+        simple_chars = [theEvent charactersIgnoringModifiers];
-+      }
-+
-+      [FLView prepareEtext:simple_chars];
-+    }
-+
-     // Then we can let the OS have a stab at it and see if it thinks it
-     // should result in some text
--    NSText *edit = [[theEvent window]  fieldEditor:YES forObject:nil];
--    in_key_event = true;
--    [edit interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
--    in_key_event = false;
-+
-+    // Don't send cmd-<key> to interpretKeyEvents because it beeps.
-+    if (!(Fl::e_state & FL_META)) {
-+      NSText *edit = [[theEvent window]  fieldEditor:YES forObject:nil];
-+      in_key_event = true;
-+      [edit interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
-+      in_key_event = false;
-+    }
-   }
-   //NSLog(@"to text=%@ l=%d", [NSString stringWithUTF8String:Fl::e_text], Fl::e_length);
-   int handled = Fl::handle(FL_KEYDOWN, window);
-@@ -1937,21 +2150,30 @@
-   //NSLog(@"insertText: received=%@",received);
- 
-   if (!in_key_event) fl_lock_function();
-+
-+  // Simple keyboard widgets do not want these side channel inputs.
-+  if (use_simple_keyboard)
-+    goto end;
-+
-   [FLView prepareEtext:received];
-+
-   // We can get called outside of key events (e.g. from the character
--  // palette). Transform such actions to FL_PASTE events.
-+  // palette). We need to fake our own key event at that point.
-   if (!in_key_event) {
-     Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
--    Fl::handle(FL_PASTE, target);
-+    Fl::e_keysym = Fl::e_original_keysym = 0;
-+    Fl::handle(FL_KEYDOWN, target);
-     // for some reason, the window does not redraw until the next mouse move or button push
-     // sending a 'redraw()' or 'awake()' does not solve the issue!
-     Fl::flush();
-   }
-+
-+end:
-   if (!in_key_event) fl_unlock_function();
- }
- 
- - (void)setMarkedText:(id)aString selectedRange:(NSRange)newSelection  {
--  NSString *received;
-+  NSString *received, *current, *aggregate;
-   if (newSelection.location == 0) {
-     [self unmarkText];
-     return;
-@@ -1962,11 +2184,47 @@
-     received = (NSString*)aString;
-   }
-   //NSLog(@"setMarkedText: %@ %d %d",received,newSelection.location,newSelection.length);
-+
-+  fl_lock_function();
-+
-+  // Simple keyboard widgets generally do not want these side channel
-+  // inputs, but we have no other way of getting dead keys so we make
-+  // an exception in that case.
-+  if (use_simple_keyboard) {
-+    if (in_key_event && (Fl::e_length == 0)) {
-+      [FLView prepareEtext:received];
-+
-+      Fl::e_text = (char*)cocoaDead2FLTK(Fl::e_text);
-+      Fl::e_length = strlen(Fl::e_text);
-+    }
-+    goto end;
-+  }
-+
-   // This code creates the OS X behaviour of seeing dead keys as things
-   // are being composed.
-+  //
-+  // Note: The concatenation thing is because of how OS X deals with
-+  //       invalid sequences. At that point it will spit out one call
-+  //       to insertText with the now aborted sequence, and one new
-+  //       call to setMarkedText with the new sequence. Since we want
-+  //       both to be visible, we need to concatenate.
-   next_compose_length = newSelection.location;
--  [FLView prepareEtext:received];
--  //NSLog(@"Fl::e_text=%@ Fl::e_length=%d next_compose_length=%d", received, Fl::e_length, next_compose_length);
-+  current = [NSString stringWithUTF8String:Fl::e_text];
-+  aggregate = [current stringByAppendingString:received];
-+
-+  [FLView prepareEtext:aggregate];
-+  //NSLog(@"Fl::e_text=%@ Fl::e_length=%d next_compose_length=%d", aggregate, Fl::e_length, next_compose_length);
-+
-+  // We can get called outside of key events (e.g. from the character
-+  // palette). We need to fake our own key event at that point.
-+  if (!in_key_event) {
-+    Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
-+    Fl::e_keysym = Fl::e_original_keysym = 0;
-+    Fl::handle(FL_KEYDOWN, target);
-+  }
-+
-+end:
-+  fl_unlock_function();
- }
- 
- - (void)unmarkText {
diff --git a/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-CVE-2010-2527.patch b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-CVE-2010-2527.patch
new file mode 100644
index 0000000..ed7ed1e
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-CVE-2010-2527.patch
@@ -0,0 +1,154 @@
+--- freetype-2.3.11/ft2demos-2.3.11/src/ftdiff.c	2009-04-30 18:07:48.000000000 +0200
++++ freetype-2.3.11/ft2demos-2.3.11/src/ftdiff.c	2010-07-22 18:18:06.000000000 +0200
+@@ -1054,11 +1054,11 @@
+ 
+       state->message = state->message0;
+       if ( total > 1 )
+-        sprintf( state->message0, "%s %d/%d @ %5.1fpt",
++        sprintf( state->message0, "%.100s %d/%d @ %5.1fpt",
+                  state->filename, idx + 1, total,
+                  state->char_size );
+       else
+-        sprintf( state->message0, "%s @ %5.1fpt",
++        sprintf( state->message0, "%.100s @ %5.1fpt",
+                  state->filename,
+                  state->char_size );
+     }
+--- freetype-2.3.11/ft2demos-2.3.11/src/ftgrid.c	2009-04-30 18:15:21.000000000 +0200
++++ freetype-2.3.11/ft2demos-2.3.11/src/ftgrid.c	2010-07-22 18:18:06.000000000 +0200
+@@ -2,7 +2,7 @@
+ /*                                                                          */
+ /*  The FreeType project -- a free and portable quality TrueType renderer.  */
+ /*                                                                          */
+-/*  Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by              */
++/*  Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by        */
+ /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
+ /*                                                                          */
+ /*                                                                          */
+@@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus    
+       switch ( error_code )
+       {
+       case FT_Err_Ok:
+-        sprintf( status.header_buffer, "%s %s (file `%s')",
++        sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')",
+                  face->family_name, face->style_name, basename );
+         break;
+ 
+       case FT_Err_Invalid_Pixel_Size:
+-        sprintf( status.header_buffer, "Invalid pixel size (file `%s')",
++        sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')",
+                  basename );
+         break;
+ 
+       case FT_Err_Invalid_PPem:
+-        sprintf( status.header_buffer, "Invalid ppem value (file `%s')",
++        sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')",
+                  basename );
+         break;
+ 
+       default:
+-        sprintf( status.header_buffer, "File `%s': error 0x%04x",
++        sprintf( status.header_buffer, "File `%.100s': error 0x%04x",
+                  basename, (FT_UShort)error_code );
+         break;
+       }
+--- freetype-2.3.11/ft2demos-2.3.11/src/ftmulti.c	2009-03-14 14:58:28.000000000 +0100
++++ freetype-2.3.11/ft2demos-2.3.11/src/ftmulti.c	2010-07-22 18:18:39.000000000 +0200
+@@ -2,7 +2,7 @@
+ /*                                                                          */
+ /*  The FreeType project -- a free and portable quality TrueType renderer.  */
+ /*                                                                          */
+-/*  Copyright 1996-2000, 2003, 2004, 2005 by                                */
++/*  Copyright 1996-2000, 2003, 2004, 2005, 2010 by                          */
+ /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
+ /*                                                                          */
+ /*                                                                          */
+@@ -34,7 +34,7 @@
+ 
+ #define  MAXPTSIZE  500                 /* dtp */
+ 
+-  char  Header[128];
++  char  Header[256];
+   char* new_header = 0;
+ 
+   const unsigned char*  Text = (unsigned char*)
+@@ -795,7 +795,7 @@
+           Render_All( Num, ptsize );
+         }
+ 
+-        sprintf( Header, "%s %s (file %s)",
++        sprintf( Header, "%.50s %.50s (file %.100s)",
+                          face->family_name,
+                          face->style_name,
+                          ft_basename( argv[file] ) );
+@@ -830,7 +830,7 @@
+       }
+       else
+       {
+-        sprintf( Header, "%s: not an MM font file, or could not be opened",
++        sprintf( Header, "%.100s: not an MM font file, or could not be opened",
+                          ft_basename( argv[file] ) );
+       }
+ 
+--- freetype-2.3.11/ft2demos-2.3.11/src/ftstring.c	2009-03-14 14:58:28.000000000 +0100
++++ freetype-2.3.11/ft2demos-2.3.11/src/ftstring.c	2010-07-22 18:18:06.000000000 +0200
+@@ -2,7 +2,7 @@
+ /*                                                                          */
+ /*  The FreeType project -- a free and portable quality TrueType renderer.  */
+ /*                                                                          */
+-/*  Copyright 1996-2002, 2003, 2004, 2005, 2006, 2007, 2009 by              */
++/*  Copyright 1996-2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by        */
+ /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
+ /*                                                                          */
+ /*                                                                          */
+@@ -413,19 +413,20 @@
+       switch ( error_code )
+       {
+       case FT_Err_Ok:
+-        sprintf( status.header_buffer, "%s %s (file `%s')", face->family_name,
++        sprintf( status.header_buffer,
++                 "%.50s %.50s (file `%.100s')", face->family_name,
+                  face->style_name, basename );
+         break;
+       case FT_Err_Invalid_Pixel_Size:
+-        sprintf( status.header_buffer, "Invalid pixel size (file `%s')",
++        sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')",
+                  basename );
+         break;
+       case FT_Err_Invalid_PPem:
+-        sprintf( status.header_buffer, "Invalid ppem value (file `%s')",
++        sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')",
+                  basename );
+         break;
+       default:
+-        sprintf( status.header_buffer, "File `%s': error 0x%04x", basename,
++        sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename,
+             (FT_UShort)error_code );
+         break;
+       }
+--- freetype-2.3.11/ft2demos-2.3.11/src/ftview.c	2009-04-30 20:08:25.000000000 +0200
++++ freetype-2.3.11/ft2demos-2.3.11/src/ftview.c	2010-07-22 18:18:06.000000000 +0200
+@@ -1086,19 +1086,19 @@
+       switch ( error_code )
+       {
+       case FT_Err_Ok:
+-        sprintf( status.header_buffer, "%s %s (file `%s')",
++        sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')",
+                  face->family_name, face->style_name, basename );
+         break;
+       case FT_Err_Invalid_Pixel_Size:
+-        sprintf( status.header_buffer, "Invalid pixel size (file `%s')",
++        sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')",
+                  basename );
+         break;
+       case FT_Err_Invalid_PPem:
+-        sprintf( status.header_buffer, "Invalid ppem value (file `%s')",
++        sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')",
+                  basename );
+         break;
+       default:
+-        sprintf( status.header_buffer, "File `%s': error 0x%04x",
++        sprintf( status.header_buffer, "File `%.100s': error 0x%04x",
+                  basename, (FT_UShort)error_code );
+         break;
+       }
diff --git a/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-CVE-2012-5669.patch b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-CVE-2012-5669.patch
new file mode 100644
index 0000000..3e52997
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-CVE-2012-5669.patch
@@ -0,0 +1,17 @@
+--- freetype-2.3.11/src/bdf/bdflib.c	2013-01-15 09:57:36.000000000 +0100
++++ freetype-2.3.11/src/bdf/bdflib.c	2013-01-15 10:04:37.000000000 +0100
+@@ -1588,9 +1588,11 @@
+ 
+       p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 );
+ 
+-      /* Check that the encoding is in the range [0,65536] because        */
+-      /* otherwise p->have (a bitmap with static size) overflows.         */
+-      if ( (size_t)p->glyph_enc >= sizeof ( p->have ) * 8 )
++      /* Check that the encoding is in the Unicode range because  */
++      /* otherwise p->have (a bitmap with static size) overflows. */
++      if ( p->glyph_enc > 0                                      &&
++           (size_t)p->glyph_enc >= sizeof ( p->have ) /
++                                   sizeof ( unsigned long ) * 32 )
+       {
+         error = BDF_Err_Invalid_File_Format;
+         goto Exit;
diff --git a/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-axis-name-overflow.patch b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-axis-name-overflow.patch
new file mode 100644
index 0000000..5f32b8a
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-axis-name-overflow.patch
@@ -0,0 +1,20 @@
+--- freetype-2.3.11/ft2demos-2.3.11/src/ftmulti.c	2010-07-22 19:11:50.000000000 +0200
++++ freetype-2.3.11/ft2demos-2.3.11/src/ftmulti.c	2010-07-22 19:12:41.000000000 +0200
+@@ -813,13 +813,13 @@
+ 
+           for ( n = 0; n < (int)multimaster->num_axis; n++ )
+           {
+-            char  temp[32];
++            char  temp[100];
+ 
+ 
+-            sprintf( temp, "  %s:%g",
++            sprintf( temp, "  %.50s:%g",
+                            multimaster->axis[n].name,
+-                           design_pos[n]/65536. );
+-            strcat( Header, temp );
++                           design_pos[n] / 65536.0 );
++            strncat( Header, temp, sizeof( Header ) - strlen( Header ) - 1 );
+           }
+         }
+         grWriteCellString( &bit, 0, 16, Header, fore_color );
diff --git a/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-more-demos.patch b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-more-demos.patch
new file mode 100644
index 0000000..4b0046e
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/freetype-2.3.11-more-demos.patch
@@ -0,0 +1,18 @@
+diff -up freetype-2.3.11/ft2demos-2.3.11/Makefile.more-demos freetype-2.3.11/ft2demos-2.3.11/Makefile
+--- freetype-2.3.11/ft2demos-2.3.11/Makefile.more-demos	2009-10-22 16:02:26.000000000 -0400
++++ freetype-2.3.11/ft2demos-2.3.11/Makefile	2009-10-22 16:02:32.000000000 -0400
+@@ -288,10 +288,10 @@ else
+   # Note that ttdebug only works if the FreeType's `truetype' driver has
+   # been compiled with TT_CONFIG_OPTION_BYTECODE_INTERPRETER defined.
+   #
+-  # EXES += ftchkwd
+-  # EXES += ftmemchk
+-  # EXES += ftpatchk
+-  # EXES += fttimer
++  EXES += ftchkwd
++  EXES += ftmemchk
++  EXES += ftpatchk
++  EXES += fttimer
+   # EXES += testname
+   # EXES += ttdebug
+ 
diff --git a/contrib/packages/rpm/el5/SOURCES/intel-revert-vbl.patch b/contrib/packages/rpm/el5/SOURCES/intel-revert-vbl.patch
deleted file mode 100644
index 0394414..0000000
--- a/contrib/packages/rpm/el5/SOURCES/intel-revert-vbl.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-commit 532d2051245a1d8afe7ca236f1d966d555bb121a
-Author: Dave Airlie <airlied@linux.ie>
-Date:   Fri Sep 12 17:21:25 2008 +1000
-
-    Revert "intel: sync to vblank by default"
-    
-    This reverts commit e9bf3e4cc9a7e4bcd4c45bd707541d26ecdf0409.
-
-diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
-index c193830..f02192d 100644
---- a/src/mesa/drivers/dri/intel/intel_screen.c
-+++ b/src/mesa/drivers/dri/intel/intel_screen.c
-@@ -55,7 +55,7 @@ PUBLIC const char __driConfigOptions[] =
-    DRI_CONF_BEGIN
-    DRI_CONF_SECTION_PERFORMANCE
-       DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
--      DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC)
-+      DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
-       /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
-        * DRI_CONF_BO_REUSE_ALL
-        */
diff --git a/contrib/packages/rpm/el5/SOURCES/libX11-1.3.1-creategc-man-page.patch b/contrib/packages/rpm/el5/SOURCES/libX11-1.3.1-creategc-man-page.patch
deleted file mode 100644
index 69f7157..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libX11-1.3.1-creategc-man-page.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff -up libX11-1.3.1/man/XCreateGC.man.fix-XCreateGC_manpage libX11-1.3.1/man/XCreateGC.man
---- libX11-1.3.1/man/XCreateGC.man.fix-XCreateGC_manpage	2010-04-12 19:19:13.860497216 +0200
-+++ libX11-1.3.1/man/XCreateGC.man	2010-04-12 19:23:16.872621817 +0200
-@@ -151,8 +151,8 @@ XCreateGC, XCopyGC, XChangeGC, XGetGCVal
- GC XCreateGC\^(\^Display *\fIdisplay\fP\^, Drawable \fId\fP\^, unsigned long
- \fIvaluemask\fP\^, XGCValues *\^\fIvalues\fP\^); 
- .HP
--int XCopyGC\^(\^Display *\fIdisplay\fP\^, GC \fIsrc\fP\^, GC \fIdest\fP\^,
--unsigned long \fIvaluemask\fP\^); 
-+int XCopyGC\^(\^Display *\fIdisplay\fP\^, GC \fIsrc\fP\^,
-+unsigned long \fIvaluemask\fP\^, GC \fIdest\fP\^); 
- .HP
- int XChangeGC\^(\^Display *\fIdisplay\fP\^, GC \fIgc\fP\^, unsigned long
- \fIvaluemask\fP\^, XGCValues *\^\fIvalues\fP\^); 
diff --git a/contrib/packages/rpm/el5/SOURCES/libXext-1.1-XAllocID.patch b/contrib/packages/rpm/el5/SOURCES/libXext-1.1-XAllocID.patch
deleted file mode 100644
index d525633..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libXext-1.1-XAllocID.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 956fd30e1046e5779ac0b6c07ec4f0e87250869a Mon Sep 17 00:00:00 2001
-From: Jamey Sharp <jamey@minilop.net>
-Date: Wed, 7 Oct 2009 19:31:21 -0700
-Subject: [PATCH] XAllocID must only be called with the Display lock held.
-
-This patch makes XShmAttach follow the same XID allocation pattern used in
-other stubs, such as XShmCreatePixmap.
-
-Reported-by: <fdsteve@ihug.co.nz>
-Signed-off-by: Jamey Sharp <jamey@minilop.net>
----
- src/XShm.c |    3 +--
- 1 files changed, 1 insertions(+), 2 deletions(-)
-
-diff --git a/src/XShm.c b/src/XShm.c
-index 922b4cb..38efa9f 100644
---- a/src/XShm.c
-+++ b/src/XShm.c
-@@ -235,12 +235,11 @@ Status XShmAttach(Display *dpy, XShmSegmentInfo *shminfo)
- 
-     ShmCheckExtension (dpy, info, 0);
- 
--    shminfo->shmseg = XAllocID(dpy);
-     LockDisplay(dpy);
-     GetReq(ShmAttach, req);
-     req->reqType = info->codes->major_opcode;
-     req->shmReqType = X_ShmAttach;
--    req->shmseg = shminfo->shmseg;
-+    req->shmseg = shminfo->shmseg = XAllocID(dpy);
-     req->shmid = shminfo->shmid;
-     req->readOnly = shminfo->readOnly ? xTrue : xFalse;
-     UnlockDisplay(dpy);
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/libXt-1.0.2-libsm-fix.patch b/contrib/packages/rpm/el5/SOURCES/libXt-1.0.2-libsm-fix.patch
deleted file mode 100644
index 309aea8..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libXt-1.0.2-libsm-fix.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- libXt-1.0.2/xt.pc.in.libsm-fix	2006-06-28 14:56:37.000000000 -0400
-+++ libXt-1.0.2/xt.pc.in	2006-06-28 14:56:51.000000000 -0400
-@@ -7,7 +7,7 @@
- Name: Xt
- Description: X Toolkit Library
- Version: @VERSION@
--Requires: xproto x11 sm
-+Requires: xproto x11
- Requires.private: x11 sm
- Cflags: -I${includedir}
- Libs: -L${libdir} -lXt
diff --git a/contrib/packages/rpm/el5/SOURCES/libdrm-2.4.0-no-bc.patch b/contrib/packages/rpm/el5/SOURCES/libdrm-2.4.0-no-bc.patch
deleted file mode 100644
index c09acc5..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libdrm-2.4.0-no-bc.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-diff -up libdrm-20080814/libdrm/xf86drm.c.no-bc libdrm-20080814/libdrm/xf86drm.c
---- libdrm-20080814/libdrm/xf86drm.c.no-bc	2008-08-14 15:43:09.000000000 +1000
-+++ libdrm-20080814/libdrm/xf86drm.c	2008-08-14 15:45:09.000000000 +1000
-@@ -396,11 +396,6 @@ int drmAvailable(void)
-     int           fd;
- 
-     if ((fd = drmOpenMinor(0, 1, DRM_NODE_RENDER)) < 0) {
--#ifdef __linux__
--	/* Try proc for backward Linux compatibility */
--	if (!access("/proc/dri/0", R_OK))
--	    return 1;
--#endif
- 	return 0;
-     }
-     
-@@ -519,38 +514,6 @@ static int drmOpenByName(const char *nam
- 	}
-     }
- 
--#ifdef __linux__
--    /* Backward-compatibility /proc support */
--    for (i = 0; i < 8; i++) {
--	char proc_name[64], buf[512];
--	char *driver, *pt, *devstring;
--	int  retcode;
--	
--	sprintf(proc_name, "/proc/dri/%d/name", i);
--	if ((fd = open(proc_name, 0, 0)) >= 0) {
--	    retcode = read(fd, buf, sizeof(buf)-1);
--	    close(fd);
--	    if (retcode) {
--		buf[retcode-1] = '\0';
--		for (driver = pt = buf; *pt && *pt != ' '; ++pt)
--		    ;
--		if (*pt) { /* Device is next */
--		    *pt = '\0';
--		    if (!strcmp(driver, name)) { /* Match */
--			for (devstring = ++pt; *pt && *pt != ' '; ++pt)
--			    ;
--			if (*pt) { /* Found busid */
--			    return drmOpenByBusid(++pt);
--			} else { /* No busid */
--			    return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_RENDER);
--			}
--		    }
--		}
--	    }
--	}
--    }
--#endif
--
-     return -1;
- }
- 
diff --git a/contrib/packages/rpm/el5/SOURCES/libdrm-make-dri-perms-okay.patch b/contrib/packages/rpm/el5/SOURCES/libdrm-make-dri-perms-okay.patch
deleted file mode 100644
index d9913c4..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libdrm-make-dri-perms-okay.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up libdrm-20080303/libdrm/xf86drm.h.da libdrm-20080303/libdrm/xf86drm.h
---- libdrm-20080303/libdrm/xf86drm.h.da	2008-03-19 15:26:31.000000000 +1000
-+++ libdrm-20080303/libdrm/xf86drm.h	2008-03-19 15:26:46.000000000 +1000
-@@ -45,7 +45,7 @@
- /* Default /dev/dri directory permissions 0755 */
- #define DRM_DEV_DIRMODE	 	\
- 	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
--#define DRM_DEV_MODE	 (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
-+#define DRM_DEV_MODE	 (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
- 
- #define DRM_DIR_NAME  "/dev/dri"
- #define DRM_DEV_NAME  "%s/card%d"
diff --git a/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-better-relocs.patch b/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-better-relocs.patch
deleted file mode 100644
index 343d360..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-better-relocs.patch
+++ /dev/null
@@ -1,295 +0,0 @@
-diff --git a/libdrm/nouveau/nouveau_bo.c b/libdrm/nouveau/nouveau_bo.c
-index b7e6d86..85fc14f 100644
---- a/libdrm/nouveau/nouveau_bo.c
-+++ b/libdrm/nouveau/nouveau_bo.c
-@@ -607,6 +607,7 @@ nouveau_bo_emit_buffer(struct nouveau_channel *chan, struct nouveau_bo *bo)
- 	pbbo = nvpb->buffers + nvpb->nr_buffers++;
- 	nvbo->pending = pbbo;
- 	nvbo->pending_channel = chan;
-+	nvbo->pending_refcnt = 0;
- 
- 	nouveau_bo_ref(bo, &ref);
- 	pbbo->user_priv = (uint64_t)(unsigned long)ref;
-diff --git a/libdrm/nouveau/nouveau_private.h b/libdrm/nouveau/nouveau_private.h
-index 9ce87fb..784afc9 100644
---- a/libdrm/nouveau/nouveau_private.h
-+++ b/libdrm/nouveau/nouveau_private.h
-@@ -52,6 +52,9 @@ struct nouveau_pushbuf_priv {
- 	unsigned *pushbuf;
- 	unsigned  size;
- 
-+	unsigned marker;
-+	unsigned marker_relocs;
-+
- 	struct drm_nouveau_gem_pushbuf_bo *buffers;
- 	unsigned nr_buffers;
- 	struct drm_nouveau_gem_pushbuf_reloc *relocs;
-@@ -99,6 +102,7 @@ struct nouveau_bo_priv {
- 	/* Tracking */
- 	struct drm_nouveau_gem_pushbuf_bo *pending;
- 	struct nouveau_channel *pending_channel;
-+	int pending_refcnt;
- 	int write_marker;
- 
- 	/* Userspace object */
-diff --git a/libdrm/nouveau/nouveau_pushbuf.c b/libdrm/nouveau/nouveau_pushbuf.c
-index d434a5f..90250c0 100644
---- a/libdrm/nouveau/nouveau_pushbuf.c
-+++ b/libdrm/nouveau/nouveau_pushbuf.c
-@@ -60,17 +60,17 @@ nouveau_pushbuf_emit_reloc(struct nouveau_channel *chan, void *ptr,
- 			   uint32_t flags, uint32_t vor, uint32_t tor)
- {
- 	struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(chan->pushbuf);
-+	struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
- 	struct drm_nouveau_gem_pushbuf_reloc *r;
- 	struct drm_nouveau_gem_pushbuf_bo *pbbo;
- 	uint32_t domains = 0;
- 
- 	if (nvpb->nr_relocs >= NOUVEAU_GEM_MAX_RELOCS) {
- 		fprintf(stderr, "too many relocs!!\n");
--		assert(0);
- 		return -ENOMEM;
- 	}
- 
--	if (nouveau_bo(bo)->user && (flags & NOUVEAU_BO_WR)) {
-+	if (nvbo->user && (flags & NOUVEAU_BO_WR)) {
- 		fprintf(stderr, "write to user buffer!!\n");
- 		return -EINVAL;
- 	}
-@@ -78,16 +78,21 @@ nouveau_pushbuf_emit_reloc(struct nouveau_channel *chan, void *ptr,
- 	pbbo = nouveau_bo_emit_buffer(chan, bo);
- 	if (!pbbo) {
- 		fprintf(stderr, "buffer emit fail :(\n");
--		assert(0);
- 		return -ENOMEM;
- 	}
- 
-+	nvbo->pending_refcnt++;
-+
- 	if (flags & NOUVEAU_BO_VRAM)
- 		domains |= NOUVEAU_GEM_DOMAIN_VRAM;
- 	if (flags & NOUVEAU_BO_GART)
- 		domains |= NOUVEAU_GEM_DOMAIN_GART;
-+
-+	if (!(pbbo->valid_domains & domains)) {
-+		fprintf(stderr, "no valid domains remain!\n");
-+		return -EINVAL;
-+	}
- 	pbbo->valid_domains &= domains;
--	assert(pbbo->valid_domains);
- 
- 	assert(flags & NOUVEAU_BO_RDWR);
- 	if (flags & NOUVEAU_BO_RD) {
-@@ -95,7 +100,7 @@ nouveau_pushbuf_emit_reloc(struct nouveau_channel *chan, void *ptr,
- 	}
- 	if (flags & NOUVEAU_BO_WR) {
- 		pbbo->write_domains |= domains;
--		nouveau_bo(bo)->write_marker = 1;
-+		nvbo->write_marker = 1;
- 	}
- 
- 	r = nvpb->relocs + nvpb->nr_relocs++;
-@@ -322,18 +327,25 @@ restart_push:
- 	/* Update presumed offset/domain for any buffers that moved.
- 	 * Dereference all buffers on validate list
- 	 */
--	for (i = 0; i < nvpb->nr_buffers; i++) {
--		struct drm_nouveau_gem_pushbuf_bo *pbbo = &nvpb->buffers[i];
-+	for (i = 0; i < nvpb->nr_relocs; i++) {
-+		struct drm_nouveau_gem_pushbuf_reloc *r = &nvpb->relocs[i];
-+		struct drm_nouveau_gem_pushbuf_bo *pbbo =
-+			&nvpb->buffers[r->bo_index];
- 		struct nouveau_bo *bo = (void *)(unsigned long)pbbo->user_priv;
-+		struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
-+
-+		if (--nvbo->pending_refcnt)
-+			continue;
- 
- 		if (pbbo->presumed_ok == 0) {
--			nouveau_bo(bo)->domain = pbbo->presumed_domain;
--			nouveau_bo(bo)->offset = pbbo->presumed_offset;
-+			nvbo->domain = pbbo->presumed_domain;
-+			nvbo->offset = pbbo->presumed_offset;
- 		}
- 
--		nouveau_bo(bo)->pending = NULL;
-+		nvbo->pending = NULL;
- 		nouveau_bo_ref(NULL, &bo);
- 	}
-+
- 	nvpb->nr_buffers = 0;
- 	nvpb->nr_relocs = 0;
- 
-@@ -343,6 +355,57 @@ restart_push:
- 	if (chan->flush_notify)
- 		chan->flush_notify(chan);
- 
-+	nvpb->marker = 0;
- 	return ret;
- }
- 
-+int
-+nouveau_pushbuf_marker_emit(struct nouveau_channel *chan,
-+			    unsigned wait_dwords, unsigned wait_relocs)
-+{
-+	struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(chan->pushbuf);
-+
-+	if (AVAIL_RING(chan) < wait_dwords)
-+		return nouveau_pushbuf_flush(chan, wait_dwords);
-+
-+	if (nvpb->nr_relocs + wait_relocs >= NOUVEAU_GEM_MAX_RELOCS)
-+		return nouveau_pushbuf_flush(chan, wait_dwords);
-+
-+	nvpb->marker = nvpb->base.cur - nvpb->pushbuf;
-+	nvpb->marker_relocs = nvpb->nr_relocs;
-+	return 0;
-+}
-+
-+void
-+nouveau_pushbuf_marker_undo(struct nouveau_channel *chan)
-+{
-+	struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(chan->pushbuf);
-+	unsigned i;
-+
-+	if (!nvpb->marker)
-+		return;
-+
-+	/* undo any relocs/buffers added to the list since last marker */
-+	for (i = nvpb->marker_relocs; i < nvpb->nr_relocs; i++) {
-+		struct drm_nouveau_gem_pushbuf_reloc *r = &nvpb->relocs[i];
-+		struct drm_nouveau_gem_pushbuf_bo *pbbo =
-+			&nvpb->buffers[r->bo_index];
-+		struct nouveau_bo *bo = (void *)(unsigned long)pbbo->user_priv;
-+		struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
-+
-+		if (--nvbo->pending_refcnt)
-+			continue;
-+
-+		nvbo->pending = NULL;
-+		nouveau_bo_ref(NULL, &bo);
-+		nvpb->nr_buffers--;
-+	}
-+	nvpb->nr_relocs = nvpb->marker_relocs;
-+
-+	/* reset pushbuf back to last marker */
-+	nvpb->base.cur = nvpb->pushbuf + nvpb->marker;
-+	nvpb->base.remaining = nvpb->size - nvpb->marker;
-+	nvpb->marker = 0;
-+}
-+
-+
-diff --git a/libdrm/nouveau/nouveau_pushbuf.h b/libdrm/nouveau/nouveau_pushbuf.h
-index 3c746ed..c7ac8c4 100644
---- a/libdrm/nouveau/nouveau_pushbuf.h
-+++ b/libdrm/nouveau/nouveau_pushbuf.h
-@@ -40,11 +40,30 @@ int
- nouveau_pushbuf_flush(struct nouveau_channel *, unsigned min);
- 
- int
-+nouveau_pushbuf_marker_emit(struct nouveau_channel *chan,
-+			    unsigned wait_dwords, unsigned wait_relocs);
-+
-+void
-+nouveau_pushbuf_marker_undo(struct nouveau_channel *chan);
-+
-+int
- nouveau_pushbuf_emit_reloc(struct nouveau_channel *, void *ptr,
- 			   struct nouveau_bo *, uint32_t data, uint32_t data2,
- 			   uint32_t flags, uint32_t vor, uint32_t tor);
- 
- /* Push buffer access macros */
-+static __inline__ int
-+MARK_RING(struct nouveau_channel *chan, unsigned dwords, unsigned relocs)
-+{
-+	return nouveau_pushbuf_marker_emit(chan, dwords, relocs);
-+}
-+
-+static __inline__ void
-+MARK_UNDO(struct nouveau_channel *chan)
-+{
-+	nouveau_pushbuf_marker_undo(chan);
-+}
-+
- static __inline__ void
- OUT_RING(struct nouveau_channel *chan, unsigned data)
- {
-@@ -116,62 +135,62 @@ BIND_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr, unsigned sc)
- 	OUT_RING  (chan, gr->handle);
- }
- 
--static __inline__ void
-+static __inline__ int
- OUT_RELOC(struct nouveau_channel *chan, struct nouveau_bo *bo,
- 	  unsigned data, unsigned flags, unsigned vor, unsigned tor)
- {
--	nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, bo,
--				   data, 0, flags, vor, tor);
-+	return nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, bo,
-+					  data, 0, flags, vor, tor);
- }
- 
--static __inline__ void
-+static __inline__ int
- OUT_RELOC2(struct nouveau_channel *chan, struct nouveau_bo *bo,
- 	   unsigned data, unsigned data2, unsigned flags,
- 	   unsigned vor, unsigned tor)
- {
--	nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, bo,
--				   data, data2, flags, vor, tor);
-+	return nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, bo,
-+					  data, data2, flags, vor, tor);
- }
- 
- /* Raw data + flags depending on FB/TT buffer */
--static __inline__ void
-+static __inline__ int
- OUT_RELOCd(struct nouveau_channel *chan, struct nouveau_bo *bo,
- 	   unsigned data, unsigned flags, unsigned vor, unsigned tor)
- {
--	OUT_RELOC(chan, bo, data, flags | NOUVEAU_BO_OR, vor, tor);
-+	return OUT_RELOC(chan, bo, data, flags | NOUVEAU_BO_OR, vor, tor);
- }
- 
- /* FB/TT object handle */
--static __inline__ void
-+static __inline__ int
- OUT_RELOCo(struct nouveau_channel *chan, struct nouveau_bo *bo,
- 	   unsigned flags)
- {
--	OUT_RELOC(chan, bo, 0, flags | NOUVEAU_BO_OR,
--		  chan->vram->handle, chan->gart->handle);
-+	return OUT_RELOC(chan, bo, 0, flags | NOUVEAU_BO_OR,
-+			 chan->vram->handle, chan->gart->handle);
- }
- 
- /* Low 32-bits of offset */
--static __inline__ void
-+static __inline__ int
- OUT_RELOCl(struct nouveau_channel *chan, struct nouveau_bo *bo,
- 	   unsigned delta, unsigned flags)
- {
--	OUT_RELOC(chan, bo, delta, flags | NOUVEAU_BO_LOW, 0, 0);
-+	return OUT_RELOC(chan, bo, delta, flags | NOUVEAU_BO_LOW, 0, 0);
- }
- 
- /* Low 32-bits of offset + GPU linear access range info */
--static __inline__ void
-+static __inline__ int
- OUT_RELOCr(struct nouveau_channel *chan, struct nouveau_bo *bo,
- 	   unsigned delta, unsigned size, unsigned flags)
- {
--	OUT_RELOC2(chan, bo, delta, size, flags | NOUVEAU_BO_LOW, 0, 0);
-+	return OUT_RELOC2(chan, bo, delta, size, flags | NOUVEAU_BO_LOW, 0, 0);
- }
- 
- /* High 32-bits of offset */
--static __inline__ void
-+static __inline__ int
- OUT_RELOCh(struct nouveau_channel *chan, struct nouveau_bo *bo,
- 	   unsigned delta, unsigned flags)
- {
--	OUT_RELOC(chan, bo, delta, flags | NOUVEAU_BO_HIGH, 0, 0);
-+	return OUT_RELOC(chan, bo, delta, flags | NOUVEAU_BO_HIGH, 0, 0);
- }
- 
- #endif
diff --git a/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-drop-rendering.patch b/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-drop-rendering.patch
deleted file mode 100644
index fe414f7..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-drop-rendering.patch
+++ /dev/null
@@ -1,103 +0,0 @@
-diff --git a/libdrm/nouveau/nouveau_private.h b/libdrm/nouveau/nouveau_private.h
-index 67144e3..9ce87fb 100644
---- a/libdrm/nouveau/nouveau_private.h
-+++ b/libdrm/nouveau/nouveau_private.h
-@@ -41,6 +41,7 @@
- struct nouveau_pushbuf_priv {
- 	struct nouveau_pushbuf base;
- 
-+	int no_aper_update;
- 	int use_cal;
- 	uint32_t cal_suffix0;
- 	uint32_t cal_suffix1;
-diff --git a/libdrm/nouveau/nouveau_pushbuf.c b/libdrm/nouveau/nouveau_pushbuf.c
-index fbcddd7..d434a5f 100644
---- a/libdrm/nouveau/nouveau_pushbuf.c
-+++ b/libdrm/nouveau/nouveau_pushbuf.c
-@@ -202,10 +202,17 @@ nouveau_pushbuf_init_call(struct nouveau_channel *chan)
- 	req.channel = chan->id;
- 	req.handle = 0;
- 	ret = drmCommandWriteRead(nouveau_device(dev)->fd,
--				  DRM_NOUVEAU_GEM_PUSHBUF_CALL,
-+				  DRM_NOUVEAU_GEM_PUSHBUF_CALL2,
- 				  &req, sizeof(req));
--	if (ret)
--		return;
-+	if (ret) {
-+		ret = drmCommandWriteRead(nouveau_device(dev)->fd,
-+					  DRM_NOUVEAU_GEM_PUSHBUF_CALL2,
-+					  &req, sizeof(req));
-+		if (ret)
-+			return;
-+
-+		nvpb->no_aper_update = 1;
-+	}
- 
- 	for (i = 0; i < CALPB_BUFFERS; i++) {
- 		ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP,
-@@ -282,14 +289,18 @@ restart_cal:
- 				nvpb->current_offset;
- 		req.suffix0 = nvpb->cal_suffix0;
- 		req.suffix1 = nvpb->cal_suffix1;
--		ret = drmCommandWriteRead(nvdev->fd,
--					  DRM_NOUVEAU_GEM_PUSHBUF_CALL,
-+		ret = drmCommandWriteRead(nvdev->fd, nvpb->no_aper_update ?
-+					  DRM_NOUVEAU_GEM_PUSHBUF_CALL :
-+					  DRM_NOUVEAU_GEM_PUSHBUF_CALL2,
- 					  &req, sizeof(req));
- 		if (ret == -EAGAIN)
- 			goto restart_cal;
- 		nvpb->cal_suffix0 = req.suffix0;
- 		nvpb->cal_suffix1 = req.suffix1;
--		assert(ret == 0);
-+		if (!nvpb->no_aper_update) {
-+			nvdev->base.vm_vram_size = req.vram_available;
-+			nvdev->base.vm_gart_size = req.gart_available;
-+		}
- 	} else {
- 		struct drm_nouveau_gem_pushbuf req;
- 
-@@ -305,7 +316,6 @@ restart_push:
- 				      &req, sizeof(req));
- 		if (ret == -EAGAIN)
- 			goto restart_push;
--		assert(ret == 0);
- 	}
- 
- 
-@@ -328,12 +338,11 @@ restart_push:
- 	nvpb->nr_relocs = 0;
- 
- 	/* Allocate space for next push buffer */
--	ret = nouveau_pushbuf_space(chan, min);
--	assert(!ret);
-+	assert(!nouveau_pushbuf_space(chan, min));
- 
- 	if (chan->flush_notify)
- 		chan->flush_notify(chan);
- 
--	return 0;
-+	return ret;
- }
- 
-diff --git a/shared-core/nouveau_drm.h b/shared-core/nouveau_drm.h
-index 2050357..1e67c44 100644
---- a/shared-core/nouveau_drm.h
-+++ b/shared-core/nouveau_drm.h
-@@ -155,6 +155,9 @@ struct drm_nouveau_gem_pushbuf_call {
- 	uint64_t relocs;
- 	uint32_t suffix0;
- 	uint32_t suffix1;
-+	/* below only accessed for CALL2 */
-+	uint64_t vram_available;
-+	uint64_t gart_available;
- };
- 
- struct drm_nouveau_gem_pin {
-@@ -212,5 +215,6 @@ struct drm_nouveau_sarea {
- #define DRM_NOUVEAU_GEM_CPU_PREP       0x45
- #define DRM_NOUVEAU_GEM_CPU_FINI       0x46
- #define DRM_NOUVEAU_GEM_INFO           0x47
-+#define DRM_NOUVEAU_GEM_PUSHBUF_CALL2  0x48
- 
- #endif /* __NOUVEAU_DRM_H__ */
diff --git a/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-restart-pushbuf.patch b/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-restart-pushbuf.patch
deleted file mode 100644
index 408a519..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libdrm-nouveau-restart-pushbuf.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From 67628aa39dd74807989492af5451a3a5c0232e39 Mon Sep 17 00:00:00 2001
-From: Ben Skeggs <bskeggs@redhat.com>
-Date: Tue, 20 Oct 2009 12:57:46 +1000
-Subject: [PATCH] nouveau: retry if pushbuf ioctl interrupted by signal
-
-Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
----
- libdrm/nouveau/nouveau_pushbuf.c |    6 ++++++
- 1 files changed, 6 insertions(+), 0 deletions(-)
-
-diff --git a/libdrm/nouveau/nouveau_pushbuf.c b/libdrm/nouveau/nouveau_pushbuf.c
-index 1192e22..fbcddd7 100644
---- a/libdrm/nouveau/nouveau_pushbuf.c
-+++ b/libdrm/nouveau/nouveau_pushbuf.c
-@@ -270,6 +270,7 @@ nouveau_pushbuf_flush(struct nouveau_channel *chan, unsigned min)
- 		if (nvpb->base.remaining > 2) /* space() will fixup if not */
- 			nvpb->base.remaining -= 2;
- 
-+restart_cal:
- 		req.channel = chan->id;
- 		req.handle = nvpb->buffer[nvpb->current]->handle;
- 		req.offset = nvpb->current_offset * 4;
-@@ -284,12 +285,15 @@ nouveau_pushbuf_flush(struct nouveau_channel *chan, unsigned min)
- 		ret = drmCommandWriteRead(nvdev->fd,
- 					  DRM_NOUVEAU_GEM_PUSHBUF_CALL,
- 					  &req, sizeof(req));
-+		if (ret == -EAGAIN)
-+			goto restart_cal;
- 		nvpb->cal_suffix0 = req.suffix0;
- 		nvpb->cal_suffix1 = req.suffix1;
- 		assert(ret == 0);
- 	} else {
- 		struct drm_nouveau_gem_pushbuf req;
- 
-+restart_push:
- 		req.channel = chan->id;
- 		req.nr_dwords = nvpb->size - nvpb->base.remaining;
- 		req.dwords = (uint64_t)(unsigned long)nvpb->pushbuf;
-@@ -299,6 +303,8 @@ nouveau_pushbuf_flush(struct nouveau_channel *chan, unsigned min)
- 		req.relocs = (uint64_t)(unsigned long)nvpb->relocs;
- 		ret = drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_PUSHBUF,
- 				      &req, sizeof(req));
-+		if (ret == -EAGAIN)
-+			goto restart_push;
- 		assert(ret == 0);
- 	}
- 
--- 
-1.6.5.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/libdrm-page-flip.patch b/contrib/packages/rpm/el5/SOURCES/libdrm-page-flip.patch
deleted file mode 100644
index ba4d39f..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libdrm-page-flip.patch
+++ /dev/null
@@ -1,174 +0,0 @@
-diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h
-index c1d173c..67bea37 100644
---- a/libdrm/xf86drm.h
-+++ b/libdrm/xf86drm.h
-@@ -667,4 +667,22 @@ extern void drmMsg(const char *format, ...);
- extern int drmSetMaster(int fd);
- extern int drmDropMaster(int fd);
- 
-+#define DRM_EVENT_CONTEXT_VERSION 1
-+
-+typedef struct _drmEventContext {
-+
-+	/* This struct is versioned so we can add more pointers if we
-+	 * add more events. */
-+	int version;
-+
-+	void (*page_flip_handler)(int fd,
-+				  unsigned int frame, 
-+				  unsigned int tv_sec,
-+				  unsigned int tv_usec,
-+				  void *user_data);
-+
-+} drmEventContext, *drmEventContextPtr;
-+
-+extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
-+
- #endif
-diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
-index ea11207..f601a00 100644
---- a/libdrm/xf86drmMode.c
-+++ b/libdrm/xf86drmMode.c
-@@ -664,3 +664,56 @@ int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
- 
- 	return 0;
- }
-+
-+int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id, void *user_data)
-+{
-+	struct drm_mode_page_flip flip;
-+
-+	flip.fb_id = fb_id;
-+	flip.crtc_id = crtc_id;
-+	flip.user_data = VOID2U64(user_data);
-+	flip.flags = 0;
-+
-+	return drmIoctl(fd, DRM_IOCTL_MODE_PAGE_FLIP, &flip);
-+}
-+
-+int drmHandleEvent(int fd, drmEventContextPtr evctx)
-+{
-+	char buffer[1024];
-+	int len, i;
-+	struct drm_event *e;
-+	struct drm_event_page_flip *page_flip;
-+	
-+	/* The DRM read semantics guarantees that we always get only
-+	 * complete events. */
-+
-+	len = read(fd, buffer, sizeof buffer);
-+	if (len == 0)
-+		return 0;
-+	if (len < sizeof *e)
-+		return -1;
-+
-+	i = 0;
-+	while (i < len) {
-+		e = (struct drm_event *) &buffer[i];
-+		switch (e->type) {
-+		case DRM_EVENT_MODE_PAGE_FLIP:
-+			if (evctx->version < 1 ||
-+			    evctx->page_flip_handler == NULL)
-+				break;
-+			page_flip = (struct drm_event_page_flip *) e;
-+			evctx->page_flip_handler(fd,
-+						 page_flip->frame, 
-+						 page_flip->tv_sec,
-+						 page_flip->tv_usec,
-+						 U642VOID (page_flip->user_data));
-+			break;
-+			
-+		default:
-+			break;
-+		}
-+		i += e->length;
-+	}
-+
-+	return 0;
-+}
-diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h
-index 62304bb..fe64707 100644
---- a/libdrm/xf86drmMode.h
-+++ b/libdrm/xf86drmMode.h
-@@ -259,8 +259,6 @@ typedef struct _drmModeConnector {
- 	uint32_t *encoders; /**< List of encoder ids */
- } drmModeConnector, *drmModeConnectorPtr;
- 
--
--
- extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr );
- extern void drmModeFreeResources( drmModeResPtr ptr );
- extern void drmModeFreeFB( drmModeFBPtr ptr );
-@@ -362,3 +360,4 @@ extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
- 			       uint16_t *red, uint16_t *green, uint16_t *blue);
- extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
- 			       uint16_t *red, uint16_t *green, uint16_t *blue);
-+extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id, void *user_data);
-diff --git a/shared-core/drm.h b/shared-core/drm.h
-index 97fab9a..8b504cb 100644
---- a/shared-core/drm.h
-+++ b/shared-core/drm.h
-@@ -1113,6 +1113,7 @@ struct drm_gem_open {
- #define DRM_IOCTL_MODE_GETFB		DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
- #define DRM_IOCTL_MODE_ADDFB		DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
- #define DRM_IOCTL_MODE_RMFB		DRM_IOWR(0xAF, uint32_t)
-+#define DRM_IOCTL_MODE_PAGE_FLIP	DRM_IOW( 0xB0, struct drm_mode_page_flip)
- 
- /*@}*/
- 
-@@ -1128,6 +1129,30 @@ struct drm_gem_open {
- #define DRM_COMMAND_BASE                0x40
- #define DRM_COMMAND_END                 0xA0
- 
-+/**
-+ * Header for events written back to userspace on the drm fd.  The
-+ * type defines the type of event, the length specifies the total
-+ * length of the event (including the header), and user_data is
-+ * typically a 64 bit value passed with the ioctl that triggered the
-+ * event.  A read on the drm fd will always only return complete
-+ * events, that is, if for example the read buffer is 100 bytes, and
-+ * there are two 64 byte events pending, only one will be returned.
-+ */
-+struct drm_event {
-+	uint32_t type;
-+	uint32_t length;
-+};
-+
-+#define DRM_EVENT_MODE_PAGE_FLIP 0x01
-+
-+struct drm_event_page_flip {
-+	struct drm_event base;
-+	uint64_t user_data;
-+	uint32_t tv_sec;
-+	uint32_t tv_usec;
-+	uint32_t frame;
-+};
-+
- /* typedef area */
- #ifndef __KERNEL__
- typedef struct drm_clip_rect drm_clip_rect_t;
-diff --git a/shared-core/drm_mode.h b/shared-core/drm_mode.h
-index 9b92733..bebe4e7 100644
---- a/shared-core/drm_mode.h
-+++ b/shared-core/drm_mode.h
-@@ -270,4 +270,20 @@ struct drm_mode_crtc_lut {
- 	uint64_t blue;
- };
- 
-+#define DRM_MODE_PAGE_FLIP_WAIT		(1<<0) /* block on previous page flip */
-+#define DRM_MODE_PAGE_FLIP_FLAGS_MASK	(DRM_MODE_PAGE_FLIP_WAIT)
-+
-+struct drm_mode_page_flip {
-+	/** Handle of new front buffer */
-+	uint32_t fb_id;
-+	uint32_t crtc_id;
-+
-+	/* 64 bit cookie returned to userspace in the page flip event. */
-+	uint64_t user_data;
-+	/**
-+	 * page flip flags (wait on flip only for now)
-+	 */
-+	uint32_t flags;
-+};
-+
- #endif
diff --git a/contrib/packages/rpm/el5/SOURCES/libfontenc-1.0.0-get-fontdir-from-pkgconfig.patch b/contrib/packages/rpm/el5/SOURCES/libfontenc-1.0.0-get-fontdir-from-pkgconfig.patch
deleted file mode 100644
index ceaf43f..0000000
--- a/contrib/packages/rpm/el5/SOURCES/libfontenc-1.0.0-get-fontdir-from-pkgconfig.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git ./configure.ac ./configure.ac
-index fc28ef9..63ef0c8 100644
---- ./configure.ac
-+++ ./configure.ac
-@@ -37,7 +37,7 @@ AC_PROG_CC
- AC_PROG_LIBTOOL
- XORG_CWARNFLAGS
- 
--encodingsdir=${libdir}/X11/fonts/encodings
-+encodingsdir=$(pkg-config --variable=fontdir fontutil)/encodings
- AC_ARG_WITH(encodingsdir, AC_HELP_STRING([--with-encodingsdir=<pathname>],
- 	[Path to font encodings]), [encodingsdir="$withval"])
- ENCODINGSDIR="$encodingsdir"
diff --git a/contrib/packages/rpm/el5/SOURCES/mesa-7.1-nukeglthread-debug.patch b/contrib/packages/rpm/el5/SOURCES/mesa-7.1-nukeglthread-debug.patch
deleted file mode 100644
index 3df6e9a..0000000
--- a/contrib/packages/rpm/el5/SOURCES/mesa-7.1-nukeglthread-debug.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -up Mesa-7.1/src/mesa/drivers/dri/intel/intel_fbo.c.intel-glthread Mesa-7.1/src/mesa/drivers/dri/intel/intel_fbo.c
---- Mesa-7.1/src/mesa/drivers/dri/intel/intel_fbo.c.intel-glthread	2008-08-25 10:49:40.000000000 -0400
-+++ Mesa-7.1/src/mesa/drivers/dri/intel/intel_fbo.c	2008-08-28 14:26:17.000000000 -0400
-@@ -633,11 +633,6 @@ intel_render_texture(GLcontext * ctx,
-        return;
-    }
- 
--   DBG("Begin render texture tid %x tex=%u w=%d h=%d refcount=%d\n",
--       _glthread_GetID(),
--       att->Texture->Name, newImage->Width, newImage->Height,
--       irb->Base.RefCount);
--
-    /* point the renderbufer's region to the texture image region */
-    intel_image = intel_texture_image(newImage);
-    if (irb->region != intel_image->mt->region) {
diff --git a/contrib/packages/rpm/el5/SOURCES/mesa-7.1-osmesa-version.patch b/contrib/packages/rpm/el5/SOURCES/mesa-7.1-osmesa-version.patch
deleted file mode 100644
index 177c0c3..0000000
--- a/contrib/packages/rpm/el5/SOURCES/mesa-7.1-osmesa-version.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up Mesa-7.1/src/mesa/drivers/osmesa/Makefile.jx Mesa-7.1/src/mesa/drivers/osmesa/Makefile
---- Mesa-7.1/src/mesa/drivers/osmesa/Makefile.jx	2008-08-28 14:05:47.000000000 -0400
-+++ Mesa-7.1/src/mesa/drivers/osmesa/Makefile	2008-08-28 14:07:13.000000000 -0400
-@@ -46,7 +46,7 @@ osmesa8: $(TOP)/lib/$(OSMESA_LIB_NAME)
- 
- $(TOP)/lib/$(OSMESA_LIB_NAME): $(OBJECTS)
- 	$(MKLIB) -o $(OSMESA_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
--		-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-+		-major 6 -minor 5 -patch 3 \
- 		-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
- 		-id $(INSTALL_LIB_DIR)/lib$(OSMESA_LIB).$(MESA_MAJOR).dylib \
- 		$(OSMESA_LIB_DEPS) $(OBJECTS)
diff --git a/contrib/packages/rpm/el5/SOURCES/mesa-7.6-glx13-app-warning.patch b/contrib/packages/rpm/el5/SOURCES/mesa-7.6-glx13-app-warning.patch
deleted file mode 100644
index c23bc0e..0000000
--- a/contrib/packages/rpm/el5/SOURCES/mesa-7.6-glx13-app-warning.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff -up mesa-20091030/src/glx/x11/glx_pbuffer.c.jx mesa-20091030/src/glx/x11/glx_pbuffer.c
---- mesa-20091030/src/glx/x11/glx_pbuffer.c.jx	2009-10-29 21:12:50.000000000 -0400
-+++ mesa-20091030/src/glx/x11/glx_pbuffer.c	2009-11-17 14:56:07.000000000 -0500
-@@ -35,6 +35,8 @@
- #include <X11/extensions/Xext.h>
- #include <assert.h>
- #include <string.h>
-+#include <unistd.h>
-+#include <limits.h>
- #include "glapi.h"
- #include "glxextensions.h"
- #include "glcontextmodes.h"
-@@ -56,10 +58,13 @@ warn_GLX_1_3(Display *dpy, const char *f
-    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
- 
-    if (priv->minorVersion < 3) {
-+      char buf[PATH_MAX];
-+      if (readlink("/proc/self/exe", buf, PATH_MAX) == -1)
-+	  buf[0] = '\0';
-       fprintf(stderr, 
--	      "WARNING: Application calling GLX 1.3 function \"%s\" "
-+	      "WARNING: Application %s calling GLX 1.3 function \"%s\" "
- 	      "when GLX 1.3 is not supported!  This is an application bug!\n",
--	      function_name);
-+	      buf, function_name);
-    }
- }
- 
diff --git a/contrib/packages/rpm/el5/SOURCES/mesa-7.6-hush-vblank-warning.patch b/contrib/packages/rpm/el5/SOURCES/mesa-7.6-hush-vblank-warning.patch
deleted file mode 100644
index 8ef007b..0000000
--- a/contrib/packages/rpm/el5/SOURCES/mesa-7.6-hush-vblank-warning.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up mesa-20090813/src/mesa/drivers/dri/common/vblank.c.jx mesa-20090813/src/mesa/drivers/dri/common/vblank.c
---- mesa-20090813/src/mesa/drivers/dri/common/vblank.c.jx	2009-08-13 09:28:01.000000000 -0400
-+++ mesa-20090813/src/mesa/drivers/dri/common/vblank.c	2009-09-08 14:07:51.000000000 -0400
-@@ -256,7 +256,7 @@ static int do_wait( drmVBlank * vbl, GLu
-    if ( ret != 0 ) {
-       static GLboolean first_time = GL_TRUE;
- 
--      if ( first_time ) {
-+      if (0) {
- 	 fprintf(stderr, 
- 		 "%s: drmWaitVBlank returned %d, IRQs don't seem to be"
- 		 " working correctly.\nTry adjusting the vblank_mode"
diff --git a/contrib/packages/rpm/el5/SOURCES/mesa-no-mach64.patch b/contrib/packages/rpm/el5/SOURCES/mesa-no-mach64.patch
deleted file mode 100644
index b8d3272..0000000
--- a/contrib/packages/rpm/el5/SOURCES/mesa-no-mach64.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-diff -up mesa-20091030/configure.ac.da mesa-20091030/configure.ac
---- mesa-20091030/configure.ac.da	2009-10-30 11:12:50.000000000 +1000
-+++ mesa-20091030/configure.ac	2009-10-30 14:53:02.000000000 +1000
-@@ -716,7 +716,7 @@ if test "$mesa_driver" = dri; then
-             # because there is no x86-64 system where they could *ever*
-             # be used.
-             if test "x$DRI_DIRS" = "xyes"; then
--                DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 r600 radeon \
-+                DRI_DIRS="i915 i965 mga r128 r200 r300 r600 radeon \
-                     savage tdfx unichrome swrast"
-             fi
-             ;;
-@@ -724,13 +724,13 @@ if test "$mesa_driver" = dri; then
-             # Build only the drivers for cards that exist on PowerPC.
-             # At some point MGA will be added, but not yet.
-             if test "x$DRI_DIRS" = "xyes"; then
--                DRI_DIRS="mach64 r128 r200 r300 r600 radeon tdfx swrast"
-+                DRI_DIRS="r128 r200 r300 r600 radeon tdfx swrast"
-             fi
-             ;;
-         sparc*)
-             # Build only the drivers for cards that exist on sparc`
-             if test "x$DRI_DIRS" = "xyes"; then
--                DRI_DIRS="mach64 r128 r200 r300 r600 radeon ffb swrast"
-+                DRI_DIRS="r128 r200 r300 r600 radeon ffb swrast"
-             fi
-             ;;
-         esac
-@@ -749,7 +749,7 @@ if test "$mesa_driver" = dri; then
-         # ffb and gamma are missing because they have not been converted
-         # to use the new interface.
-         if test "x$DRI_DIRS" = "xyes"; then
--            DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \
-+            DRI_DIRS="i810 i915 i965 mga r128 r200 r300 r600 radeon tdfx \
-                 unichrome savage sis swrast"
-         fi
-         ;;
-@@ -768,7 +768,7 @@ if test "$mesa_driver" = dri; then
- 
-     # default drivers
-     if test "x$DRI_DIRS" = "xyes"; then
--        DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
-+        DRI_DIRS="i810 i915 i965 mga r128 r200 r300 r600 radeon \
-             savage sis tdfx unichrome ffb swrast"
-     fi
- 
diff --git a/contrib/packages/rpm/el5/SOURCES/pixmap_v2.patch b/contrib/packages/rpm/el5/SOURCES/pixmap_v2.patch
deleted file mode 100644
index 3031513..0000000
--- a/contrib/packages/rpm/el5/SOURCES/pixmap_v2.patch
+++ /dev/null
@@ -1,554 +0,0 @@
-diff -ur fltk-1.3.2.org/FL/Fl_Image.H fltk-1.3.2/FL/Fl_Image.H
---- fltk-1.3.2.org/FL/Fl_Image.H	2012-11-09 17:02:08.000000000 +0100
-+++ fltk-1.3.2/FL/Fl_Image.H	2013-01-16 14:40:51.543230638 +0100
-@@ -26,6 +26,7 @@
- #include <stdlib.h>
- 
- class Fl_Widget;
-+class Fl_Pixmap;
- struct Fl_Menu_Item;
- struct Fl_Label;
- 
-@@ -203,6 +204,7 @@
-   */
-   Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
-     Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
-+  Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
-   virtual ~Fl_RGB_Image();
-   virtual Fl_Image *copy(int W, int H);
-   Fl_Image *copy() { return copy(w(), h()); }
-diff -ur fltk-1.3.2.org/src/fl_draw_pixmap.cxx fltk-1.3.2/src/fl_draw_pixmap.cxx
---- fltk-1.3.2.org/src/fl_draw_pixmap.cxx	2012-04-22 05:09:31.000000000 +0200
-+++ fltk-1.3.2/src/fl_draw_pixmap.cxx	2013-01-16 14:40:51.542230588 +0100
-@@ -58,99 +58,6 @@
-   return 1;
- }
- 
--#ifdef U64
--
--// The callback from fl_draw_image to get a row of data passes this:
--struct pixmap_data {
--  int w, h;
--  const uchar*const* data;
--  union {
--    U64 colors[256];
--    U64* byte1[256];
--  };
--};
--
--// callback for 1 byte per pixel:
--static void cb1(void*v, int x, int y, int w, uchar* buf) {
--  pixmap_data& d = *(pixmap_data*)v;
--  const uchar* p = d.data[y]+x;
--  U64* q = (U64*)buf;
--  for (int X=w; X>0; X-=2, p += 2) {
--    if (X>1) {
--#  if WORDS_BIGENDIAN
--      *q++ = (d.colors[p[0]]<<32) | d.colors[p[1]];
--#  else
--      *q++ = (d.colors[p[1]]<<32) | d.colors[p[0]];
--#  endif
--    } else {
--#  if WORDS_BIGENDIAN
--      *q++ = d.colors[p[0]]<<32;
--#  else
--      *q++ = d.colors[p[0]];
--#  endif
--    }
--  }
--}
--
--// callback for 2 bytes per pixel:
--static void cb2(void*v, int x, int y, int w, uchar* buf) {
--  pixmap_data& d = *(pixmap_data*)v;
--  const uchar* p = d.data[y]+2*x;
--  U64* q = (U64*)buf;
--  for (int X=w; X>0; X-=2) {
--    U64* colors = d.byte1[*p++];
--    int index = *p++;
--    if (X>1) {
--      U64* colors1 = d.byte1[*p++];
--      int index1 = *p++;
--#  if WORDS_BIGENDIAN
--      *q++ = (colors[index]<<32) | colors1[index1];
--#  else
--      *q++ = (colors1[index1]<<32) | colors[index];
--#  endif
--    } else {
--#  if WORDS_BIGENDIAN
--      *q++ = colors[index]<<32;
--#  else
--      *q++ = colors[index];
--#  endif
--    }
--  }
--}
--
--#else // U32
--
--// The callback from fl_draw_image to get a row of data passes this:
--struct pixmap_data {
--  int w, h;
--  const uchar*const* data;
--  union {
--    U32 colors[256];
--    U32* byte1[256];
--  };
--};
--
--// callback for 1 byte per pixel:
--static void cb1(void*v, int x, int y, int w, uchar* buf) {
--  pixmap_data& d = *(pixmap_data*)v;
--  const uchar* p = d.data[y]+x;
--  U32* q = (U32*)buf;
--  for (int X=w; X--;) *q++ = d.colors[*p++];
--}
--
--// callback for 2 bytes per pixel:
--static void cb2(void*v, int x, int y, int w, uchar* buf) {
--  pixmap_data& d = *(pixmap_data*)v;
--  const uchar* p = d.data[y]+2*x;
--  U32* q = (U32*)buf;
--  for (int X=w; X--;) {
--    U32* colors = d.byte1[*p++];
--    *q++ = colors[*p++];
--  }
--}
--
--#endif // U64 else U32
--
- uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here
- 
- /**
-@@ -200,34 +107,33 @@
- }
- #endif
- 
--/**
--  Draw XPM image data, with the top-left corner at the given position.
--  \see fl_draw_pixmap(char* const* data, int x, int y, Fl_Color bg)
--  */
--int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) {
--  pixmap_data d;
--  if (!fl_measure_pixmap(cdata, d.w, d.h)) return 0;
-+int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) {
-+  int w, h;
-   const uchar*const* data = (const uchar*const*)(cdata+1);
-   int transparent_index = -1;
-+
-+  if (!fl_measure_pixmap(cdata, w, h))
-+    return 0;
-+
-+  if ((chars_per_pixel < 1) || (chars_per_pixel > 2))
-+    return 0;
-+
-+  uchar colors[1<<(chars_per_pixel*8)][4];
-+
- #ifdef WIN32
-   uchar *transparent_c = (uchar *)0; // such that transparent_c[0,1,2] are the RGB of the transparent color
-   color_count = 0;
-   used_colors = (uchar *)malloc(abs(ncolors)*3*sizeof(uchar));
- #endif
- 
--  if (ncolors < 0) {	// FLTK (non standard) compressed colormap
-+  if (ncolors < 0) {
-+    // FLTK (non standard) compressed colormap
-     ncolors = -ncolors;
-     const uchar *p = *data++;
-     // if first color is ' ' it is transparent (put it later to make
-     // it not be transparent):
-     if (*p == ' ') {
--      uchar* c = (uchar*)&d.colors[(int)' '];
--#ifdef U64
--      *(U64*)c = 0;
--#  if WORDS_BIGENDIAN
--      c += 4;
--#  endif
--#endif
-+      uchar* c = colors[(int)' '];
-       transparent_index = ' ';
-       Fl::get_color(bg, c[0], c[1], c[2]); c[3] = 0;
- #ifdef WIN32
-@@ -238,13 +144,7 @@
-     }
-     // read all the rest of the colors:
-     for (int i=0; i < ncolors; i++) {
--      uchar* c = (uchar*)&d.colors[*p++];
--#ifdef U64
--      *(U64*)c = 0;
--#  if WORDS_BIGENDIAN
--      c += 4;
--#  endif
--#endif
-+      uchar* c = colors[*p++];
- #ifdef WIN32
-       used_colors[3*color_count] = *p;
-       used_colors[3*color_count+1] = *(p+1);
-@@ -254,69 +154,44 @@
-       *c++ = *p++;
-       *c++ = *p++;
-       *c++ = *p++;
--#ifdef __APPLE_QUARTZ__
-       *c = 255;
--#else
--      *c = 0;
--#endif
-     }
--  } else {	// normal XPM colormap with names
--    if (chars_per_pixel>1) memset(d.byte1, 0, sizeof(d.byte1));
-+  } else {
-+    // normal XPM colormap with names
-     for (int i=0; i<ncolors; i++) {
-       const uchar *p = *data++;
-       // the first 1 or 2 characters are the color index:
-       int ind = *p++;
-       uchar* c;
--      if (chars_per_pixel>1) {
--#ifdef U64
--	U64* colors = d.byte1[ind];
--	if (!colors) colors = d.byte1[ind] = new U64[256];
--#else
--	U32* colors = d.byte1[ind];
--	if (!colors) colors = d.byte1[ind] = new U32[256];
--#endif
--	c = (uchar*)&colors[*p];
--	ind = (ind<<8)|*p++;
--      } else {
--	c = (uchar *)&d.colors[ind];
--      }
-+      if (chars_per_pixel>1)
-+        ind = (ind<<8)|*p++;
-+      c = colors[ind];
-       // look for "c word", or last word if none:
-       const uchar *previous_word = p;
-       for (;;) {
--	while (*p && isspace(*p)) p++;
--	uchar what = *p++;
--	while (*p && !isspace(*p)) p++;
--	while (*p && isspace(*p)) p++;
--	if (!*p) {p = previous_word; break;}
--	if (what == 'c') break;
--	previous_word = p;
--	while (*p && !isspace(*p)) p++;
-+        while (*p && isspace(*p)) p++;
-+        uchar what = *p++;
-+        while (*p && !isspace(*p)) p++;
-+        while (*p && isspace(*p)) p++;
-+        if (!*p) {p = previous_word; break;}
-+        if (what == 'c') break;
-+        previous_word = p;
-+        while (*p && !isspace(*p)) p++;
-       }
--#ifdef U64
--      *(U64*)c = 0;
--#  if WORDS_BIGENDIAN
--      c += 4;
--#  endif
--#endif
--#ifdef __APPLE_QUARTZ__
--      c[3] = 255;
--#endif
-       int parse = fl_parse_color((const char*)p, c[0], c[1], c[2]);
-+      c[3] = 255;
-       if (parse) {
- #ifdef WIN32
--	used_colors[3*color_count] = c[0];
--	used_colors[3*color_count+1] = c[1];
--	used_colors[3*color_count+2] = c[2];
--	color_count++;
-+        used_colors[3*color_count] = c[0];
-+        used_colors[3*color_count+1] = c[1];
-+        used_colors[3*color_count+2] = c[2];
-+        color_count++;
- #endif
--	}
--      else {
-+      } else {
-         // assume "None" or "#transparent" for any errors
--	// "bg" should be transparent...
--	Fl::get_color(bg, c[0], c[1], c[2]);
--#ifdef __APPLE_QUARTZ__
-+        // "bg" should be transparent...
-+        Fl::get_color(bg, c[0], c[1], c[2]);
-         c[3] = 0;
--#endif
- 	transparent_index = ind;
- #ifdef WIN32
- 	transparent_c = c;
-@@ -324,7 +199,6 @@
-       }
-     }
-   }
--  d.data = data;
- #ifdef WIN32
-   if (transparent_c) {
-     make_unused_color(transparent_c[0], transparent_c[1], transparent_c[2]);
-@@ -334,77 +208,76 @@
-     make_unused_color(r, g, b);
-   }
- #endif
-+
-+  U32 *q = (U32*)out;
-+  for (int Y = 0; Y < h; Y++) {
-+    const uchar* p = data[Y];
-+    if (chars_per_pixel <= 1) {
-+      for (int X = 0; X < w; X++)
-+        memcpy(q++, colors[*p++], 4);
-+    } else {
-+      for (int X = 0; X < w; X++) {
-+        int ind = (*p++)<<8;
-+        ind |= *p++;
-+        memcpy(q++, colors[ind], 4);
-+      }
-+    }
-+  }
-   
-+  return 1;
-+}
-+
-+/**
-+  Draw XPM image data, with the top-left corner at the given position.
-+  \see fl_draw_pixmap(char* const* data, int x, int y, Fl_Color bg)
-+  */
-+int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) {
-+  int w, h;
-+
-+  if (!fl_measure_pixmap(cdata, w, h))
-+    return 0;
-+
-+  uchar buffer[w*h*4];
-+
-+  if (!fl_convert_pixmap(cdata, buffer, bg))
-+    return 0;
-+
-+  // FIXME: Hack until fl_draw_image() supports alpha properly
- #ifdef  __APPLE_QUARTZ__
-   if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) {
--    U32 *array = new U32[d.w * d.h], *q = array;
--    for (int Y = 0; Y < d.h; Y++) {
--      const uchar* p = data[Y];
--      if (chars_per_pixel <= 1) {
--	for (int X = 0; X < d.w; X++) {
--	  *q++ = d.colors[*p++];
--	}
--      } else {
--	for (int X = 0; X < d.w; X++) {
--	  U32* colors = (U32*)d.byte1[*p++];
--	  *q++ = colors[*p++];
--	}
--      }
--    }
--    Fl_RGB_Image* rgb = new Fl_RGB_Image((uchar*)array, d.w, d.h, 4);
-+    Fl_RGB_Image* rgb = new Fl_RGB_Image(buffer, w, h, 4);
-     rgb->draw(x, y);
-     delete rgb;
--    delete[] array;
--    }
--  else {
-+  } else {
- #endif // __APPLE_QUARTZ__
--
-   // build the mask bitmap used by Fl_Pixmap:
--  if (fl_mask_bitmap && transparent_index >= 0) {
--    int W = (d.w+7)/8;
--    uchar* bitmap = new uchar[W * d.h];
-+  if (fl_mask_bitmap) {
-+    int W = (w+7)/8;
-+    uchar* bitmap = new uchar[W * h];
-     *fl_mask_bitmap = bitmap;
--    for (int Y = 0; Y < d.h; Y++) {
--      const uchar* p = data[Y];
--      if (chars_per_pixel <= 1) {
--	int dw = d.w;
--	for (int X = 0; X < W; X++) {
--	  uchar b = (dw-->0 && *p++ != transparent_index);
--	  if (dw-->0 && *p++ != transparent_index) b |= 2;
--	  if (dw-->0 && *p++ != transparent_index) b |= 4;
--	  if (dw-->0 && *p++ != transparent_index) b |= 8;
--	  if (dw-->0 && *p++ != transparent_index) b |= 16;
--	  if (dw-->0 && *p++ != transparent_index) b |= 32;
--	  if (dw-->0 && *p++ != transparent_index) b |= 64;
--	  if (dw-->0 && *p++ != transparent_index) b |= 128;
-+    const uchar *p = &buffer[3];
-+    uchar b = 0;
-+    for (int Y = 0; Y < h; Y++) {
-+      b = 0;
-+      for (int X = 0, bit = 1; X < w; X++, p += 4) {
-+	if (*p > 127) b |= bit;
-+	bit <<= 1;
-+	if (bit > 0x80 || X == w-1) {
- 	  *bitmap++ = b;
--	}
--      } else {
--        uchar b = 0, bit = 1;
--	for (int X = 0; X < d.w; X++) {
--	  int ind = *p++;
--	  ind = (ind<<8) | (*p++);
--	  if (ind != transparent_index) b |= bit;
--
--          if (bit < 128) bit <<= 1;
--	  else {
--	    *bitmap++ = b;
--	    b = 0;
--	    bit = 1;
-+	  bit = 1;
-+	  b = 0;
- 	  }
- 	}
--
--        if (bit > 1) *bitmap++ = b;
-       }
--    }
-+    
-   }
- 
--  fl_draw_image(chars_per_pixel==1 ? cb1 : cb2, &d, x, y, d.w, d.h, 4);
-+  fl_draw_image(buffer, x, y, w, h, 4);
-+
- #ifdef __APPLE_QUARTZ__
-     }
- #endif
- 
--  if (chars_per_pixel > 1) for (int i = 0; i < 256; i++) delete[] d.byte1[i];
-   return 1;
- }
- 
-diff -ur fltk-1.3.2.org/src/Fl_Image.cxx fltk-1.3.2/src/Fl_Image.cxx
---- fltk-1.3.2.org/src/Fl_Image.cxx	2012-11-09 17:02:08.000000000 +0100
-+++ fltk-1.3.2/src/Fl_Image.cxx	2013-01-16 14:41:38.404162795 +0100
-@@ -165,7 +165,22 @@
- //
- size_t Fl_RGB_Image::max_size_ = ~((size_t)0);
- 
--/**  The destructor free all memory and server resources that are used by  the image. */
-+int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg);
-+
-+/** The constructor creates a new RGBA image from the specified Fl_Pixmap. 
-+ 
-+ The RGBA image is built fully opaque except for the transparent area
-+ of the pixmap that is assigned the \par bg color with full transparency */
-+Fl_RGB_Image::Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg):
-+  Fl_Image(pxm->w(), pxm->h(), 4), id_(0), mask_(0)
-+{
-+  array = new uchar[w() * h() * d()];
-+  alloc_array = 1;
-+  fl_convert_pixmap(pxm->data(), (uchar*)array, bg);
-+  data((const char **)&array, 1);
-+}
-+
-+/**  The destructor frees all memory and server resources that are used by the image. */
- Fl_RGB_Image::~Fl_RGB_Image() {
-   uncache();
-   if (alloc_array) delete[] (uchar *)array;
-diff -ur fltk-1.3.2.org/src/ps_image.cxx fltk-1.3.2/src/ps_image.cxx
---- fltk-1.3.2.org/src/ps_image.cxx	2011-07-19 06:49:30.000000000 +0200
-+++ fltk-1.3.2/src/ps_image.cxx	2013-01-16 14:40:51.541228080 +0100
-@@ -185,72 +185,38 @@
- 
- extern uchar **fl_mask_bitmap;
- 
-+struct callback_data {
-+  const uchar *data;
-+  int D, LD;
-+};
- 
--void Fl_PostScript_Graphics_Driver::draw_image(const uchar *data, int ix, int iy, int iw, int ih, int D, int LD) {
--  double x = ix, y = iy, w = iw, h = ih;
- 
--  if (D<3){ //mono
--    draw_image_mono(data, ix, iy, iw, ih, D, LD);
--    return;
--  }
-+static void draw_image_cb(void *data, int x, int y, int w, uchar *buf) {
-+  struct callback_data *cb_data;
-+  const uchar *curdata;
- 
-+  cb_data = (struct callback_data*)data;
-+  curdata = cb_data->data + x*cb_data->D + y*cb_data->LD;
- 
--  int i,j, k;
-+  memcpy(buf, curdata, w*cb_data->D);
-+}
- 
--  fprintf(output,"save\n");
- 
--  const char * interpol;
--  if (lang_level_>1){
--    if (interpolate_)
--      interpol="true";
--    else
--      interpol="false";
--    if (mask && lang_level_>2)
--      fprintf(output, "%g %g %g %g %i %i %i %i %s CIM\n", x , y+h , w , -h , iw , ih, mx, my, interpol);
--    else
--      fprintf(output, "%g %g %g %g %i %i %s CII\n", x , y+h , w , -h , iw , ih, interpol);
--  } else
--    fprintf(output , "%g %g %g %g %i %i CI", x , y+h , w , -h , iw , ih);
-+void Fl_PostScript_Graphics_Driver::draw_image(const uchar *data, int ix, int iy, int iw, int ih, int D, int LD) {
-+  if (D<3){ //mono
-+    draw_image_mono(data, ix, iy, iw, ih, D, LD);
-+    return;
-+  }
- 
-+  struct callback_data cb_data;
- 
-   if (!LD) LD = iw*D;
--  uchar *curmask=mask;
--
--  for (j=0; j<ih;j++){
--    if (mask){
--
--      for (k=0;k<my/ih;k++){
--        for (i=0; i<((mx+7)/8);i++){
--          if (!(i%80)) fprintf(output, "\n");
--          fprintf(output, "%.2x",swap_byte(*curmask));
--          curmask++;
--        }
--        fprintf(output,"\n");
--      }
--    }
--    const uchar *curdata=data+j*LD;
--    for (i=0 ; i<iw ; i++) {
--      uchar r = curdata[0];
--      uchar g =  curdata[1];
--      uchar b =  curdata[2];
--      if (lang_level_<3 && D>3) { //can do  mixing using bg_* colors)
--        unsigned int a2 = curdata[3]; //must be int
--        unsigned int a = 255-a2;
--        r = (a2 * r + bg_r * a)/255;
--        g = (a2 * g + bg_g * a)/255;
--        b = (a2 * b + bg_b * a)/255;
--      }
--      if (!(i%40)) fprintf(output, "\n");
--      fprintf(output, "%.2x%.2x%.2x", r, g, b);
--      curdata +=D;
--    }
--    fprintf(output,"\n");
--
--  }
--
--  fprintf(output," >\nrestore\n" );
- 
-+  cb_data.data = data;
-+  cb_data.D = D;
-+  cb_data.LD = LD;
- 
-+  draw_image(draw_image_cb, &cb_data, ix, iy, iw, ih, D);
- }
- 
- void Fl_PostScript_Graphics_Driver::draw_image(Fl_Draw_Image_Cb call, void *data, int ix, int iy, int iw, int ih, int D) {
-@@ -325,6 +291,14 @@
- 	uchar g =  curdata[1];
- 	uchar b =  curdata[2];
- 
-+        if (lang_level_<3 && D>3) { //can do  mixing using bg_* colors)
-+          unsigned int a2 = curdata[3]; //must be int
-+          unsigned int a = 255-a2;
-+          r = (a2 * r + bg_r * a)/255;
-+          g = (a2 * g + bg_g * a)/255;
-+          b = (a2 * b + bg_b * a)/255;
-+        }
-+
- 	if (!(i%40)) 	fputs("\n", output);
- 	fprintf(output, "%.2x%.2x%.2x", r, g, b);
- 
diff --git a/contrib/packages/rpm/el5/SOURCES/pthread-stubs.pc.in b/contrib/packages/rpm/el5/SOURCES/pthread-stubs.pc.in
new file mode 100644
index 0000000..1b722e9
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/pthread-stubs.pc.in
@@ -0,0 +1,8 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+Name: pthread stubs
+Description: Stubs missing from libc for standard pthread functions
+Version: 0.1
+Libs:
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc-2b76d02.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc-2b76d02.patch
new file mode 100644
index 0000000..8ff0b9f
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/tigervnc-2b76d02.patch
@@ -0,0 +1,23 @@
+From 2b76d028b0253be7c4496840fcd2e0fb47c0794e Mon Sep 17 00:00:00 2001
+From: Pierre Ossman <ossman@cendio.se>
+Date: Mon, 15 Dec 2014 10:52:43 +0100
+Subject: [PATCH] Band aid to work around inluding C headers in C++ code
+
+---
+ unix/xserver/hw/vnc/Makefile.am | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/unix/xserver/hw/vnc/Makefile.am b/unix/xserver/hw/vnc/Makefile.am
+index 9885b8a..372a57f 100644
+--- a/unix/xserver/hw/vnc/Makefile.am
++++ b/unix/xserver/hw/vnc/Makefile.am
+@@ -7,6 +7,9 @@ NETWORK_LIB=$(LIB_DIR)/network/libnetwork.la
+ XREGION_LIB=$(LIB_DIR)/Xregion/libXregion.la
+ COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(XREGION_LIB)
+ 
++# Hack to get the C headers to work when included from C++ code
++AM_CXXFLAGS = -fpermissive
++
+ noinst_LTLIBRARIES = libvnccommon.la
+ 
+ HDRS = RegionHelper.h vncExtInit.h vncHooks.h XserverDesktop.h xorg-version.h \
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc-ac-compatibility.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc-ac-compatibility.patch
deleted file mode 100644
index d1b4133..0000000
--- a/contrib/packages/rpm/el5/SOURCES/tigervnc-ac-compatibility.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/m4/shave.m4 b/m4/shave.m4
-index 01cb5c7..0dfde6c 100644
---- a/m4/shave.m4
-+++ b/m4/shave.m4
-@@ -32,8 +32,8 @@ AC_DEFUN([SHAVE_INIT],
-   if test x"$enable_shave" = xyes; then
-     dnl where can we find the shave scripts?
-     m4_if([$1],,
--      [shavedir="$ac_pwd"],
--      [shavedir="$ac_pwd/$1"])
-+      [shavedir=`pwd`],
-+      [shavedir=`pwd`/$1])
-     AC_SUBST(shavedir)
- 
-     dnl make is now quiet
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc-static-fltk.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc-static-fltk.patch
deleted file mode 100644
index 650da73..0000000
--- a/contrib/packages/rpm/el5/SOURCES/tigervnc-static-fltk.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/cmake/StaticBuild.cmake	2014-10-29 20:23:24.000000000 -0400
-+++ b/cmake/StaticBuild.cmake	2014-10-29 20:24:05.000000000 -0400
-@@ -68,7 +68,7 @@
-   endif()
- 
-   if(FLTK_FOUND)
--    set(FLTK_LIBRARIES "-Wl,-Bstatic -lfltk_images -lpng -ljpeg -lfltk -Wl,-Bdynamic")
-+    set(FLTK_LIBRARIES "-Wl,-Bstatic -L${FLTK_LIBRARY_DIR} -lfltk_images -lpng -ljpeg -lfltk -Wl,-Bdynamic")
- 
-     if(WIN32)
-       set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lcomctl32")
---- a/vncviewer/CMakeLists.txt	2014-10-29 20:39:58.000000000 -0400
-+++ b/vncviewer/CMakeLists.txt	2014-10-29 21:01:31.000000000 -0400
-@@ -46,7 +46,7 @@
-   add_executable(vncviewer ${VNCVIEWER_SOURCES})
- endif()
- 
--target_link_libraries(vncviewer rfb network rdr os Xregion ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES})
-+target_link_libraries(vncviewer ${FLTK_LIBRARIES} rfb network rdr os Xregion ${X11_Xdmcp_LIB} ${X11_Xau_LIB} ${GETTEXT_LIBRARIES})
- 
- if(APPLE)
-   target_link_libraries(vncviewer "-framework Cocoa" "-framework Carbon")
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc-x0vncserver-static-libs-fix.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc-x0vncserver-static-libs-fix.patch
deleted file mode 100644
index 9de3f85..0000000
--- a/contrib/packages/rpm/el5/SOURCES/tigervnc-x0vncserver-static-libs-fix.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/unix/x0vncserver/CMakeLists.txt	2014-10-29 18:25:30.000000000 -0400
-+++ b/unix/x0vncserver/CMakeLists.txt	2014-10-29 18:26:38.000000000 -0400
-@@ -31,7 +31,7 @@
-   message(WARNING "No DAMAGE extension.  x0vncserver will have to use the slower polling method.")
- endif()
- 
--target_link_libraries(x0vncserver ${X11_LIBRARIES})
-+target_link_libraries(x0vncserver ${X11_LIBRARIES} ${X11_Xdmcp_LIB} ${X11_Xau_LIB})
- 
- install(TARGETS x0vncserver DESTINATION ${BIN_DIR})
- install(FILES x0vncserver.man DESTINATION ${MAN_DIR}/man1 RENAME x0vncserver.1)
---- a/unix/vncconfig/CMakeLists.txt	2014-10-29 18:45:41.000000000 -0400
-+++ b/unix/vncconfig/CMakeLists.txt	2014-10-29 18:46:17.000000000 -0400
-@@ -9,7 +9,7 @@
-   vncconfig.cxx
-   QueryConnectDialog.cxx)
- 
--target_link_libraries(vncconfig tx rfb network rdr ${X11_LIBRARIES})
-+target_link_libraries(vncconfig tx rfb network rdr ${X11_LIBRARIES} ${X11_Xdmcp_LIB} ${X11_Xau_LIB})
- 
- install(TARGETS vncconfig DESTINATION ${BIN_DIR})
- install(FILES vncconfig.man DESTINATION ${MAN_DIR}/man1 RENAME vncconfig.1)
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc-xorg-1.7.5-remove-copyisolatin1lowered.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc-xorg-1.7.5-remove-copyisolatin1lowered.patch
deleted file mode 100644
index 3150528..0000000
--- a/contrib/packages/rpm/el5/SOURCES/tigervnc-xorg-1.7.5-remove-copyisolatin1lowered.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/dix/dixutils.c	2012-06-28 11:06:25.676773000 -0400
-+++ b/dix/dixutils.c	2012-06-28 11:07:05.224177000 -0400
-@@ -165,16 +165,6 @@
- }
- 
- 
--void
--CopyISOLatin1Lowered(unsigned char *dest, unsigned char *source, int length)
--{
--    int i;
--
--    for (i = 0; i < length; i++, source++, dest++)
--	*dest = ISOLatin1ToLower (*source);
--    *dest = '\0';
--}
--
- int
- CompareISOLatin1Lowered(unsigned char *s1, int s1len, 
- 			unsigned char *s2, int s2len)
---- a/include/dix.h	2012-06-28 11:07:38.135955000 -0400
-+++ b/include/dix.h	2012-06-28 11:07:45.120547000 -0400
-@@ -173,11 +173,6 @@
- extern _X_HIDDEN Bool CreateConnectionBlock(void);
- /* dixutils.c */
- 
--extern _X_EXPORT void CopyISOLatin1Lowered(
--    unsigned char * /*dest*/,
--    unsigned char * /*source*/,
--    int /*length*/);
--
- extern _X_EXPORT int CompareISOLatin1Lowered(
-     unsigned char * /*a*/,
-     int alen,
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc11-gethomedir.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc11-gethomedir.patch
index fd07be3..ea54438 100644
--- a/contrib/packages/rpm/el5/SOURCES/tigervnc11-gethomedir.patch
+++ b/contrib/packages/rpm/el5/SOURCES/tigervnc11-gethomedir.patch
@@ -9,7 +9,7 @@
  COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(XREGION_LIB)
  
  noinst_LTLIBRARIES = libvnccommon.la
-@@ -52,7 +53,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
+@@ -52,6 +53,6 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
  
  libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
  
@@ -17,4 +17,3 @@
 +libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS) $(OS_LIB)
  
  EXTRA_DIST = Xvnc.man
- 
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc11-ldnow.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc11-ldnow.patch
deleted file mode 100644
index 0db5d88..0000000
--- a/contrib/packages/rpm/el5/SOURCES/tigervnc11-ldnow.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up tigervnc-1.0.90-20100721svn4113/unix/xserver/hw/vnc/Makefile.am.ldnow tigervnc-1.0.90-20100721svn4113/unix/xserver/hw/vnc/Makefile.am
---- tigervnc-1.0.90-20100721svn4113/unix/xserver/hw/vnc/Makefile.am.ldnow	2010-05-18 15:48:02.000000000 +0200
-+++ tigervnc-1.0.90-20100721svn4113/unix/xserver/hw/vnc/Makefile.am	2010-07-21 17:05:45.242942531 +0200
-@@ -50,7 +50,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
- 	-I$(top_srcdir)/hw/xfree86/os-support/bus \
- 	-I$(includedir)/pixman-1 -I$(includedir)
- 
--libvnc_la_LDFLAGS = -module -avoid-version
-+libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
- 
- libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS)
- 
diff --git a/contrib/packages/rpm/el5/SOURCES/tigervnc14-static-build-fixes.patch b/contrib/packages/rpm/el5/SOURCES/tigervnc14-static-build-fixes.patch
new file mode 100644
index 0000000..7cad24e
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/tigervnc14-static-build-fixes.patch
@@ -0,0 +1,139 @@
+--- a/cmake/StaticBuild.cmake	2014-12-25 23:28:45.000000000 -0500
++++ b/cmake/StaticBuild.cmake	2015-01-01 18:18:36.000000000 -0500
+@@ -82,10 +82,10 @@
+       if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+         set(FLTK_LIBRARIES "${FLTK_LIBRARIES} ${X11_Xcursor_LIB} ${X11_Xfixes_LIB} -Wl,-Bstatic -lXft -Wl,-Bdynamic -lfontconfig -lXext -R/usr/sfw/lib")
+       else()
+-        set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -Wl,-Bstatic -lXcursor -lXfixes -lXft -lfontconfig -lexpat -lfreetype -lbz2 -lXrender -lXext -lXinerama -Wl,-Bdynamic")
++        set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -Wl,-Bstatic -lXft -lfontconfig -lfreetype -lXcursor -lXfixes -lz -lbz2 -lXrender -lXinerama -lXext -lexpat -Wl,-Bdynamic")
+       endif()
+ 
+-      set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -lX11")
++      set(FLTK_LIBRARIES "${FLTK_LIBRARIES} -Wl,-Bstatic -lX11 -lxcb -lXdmcp -lXau -lICE -Wl,-Bdynamic -ldl")
+     endif()
+   endif()
+ 
+@@ -93,7 +93,7 @@
+   # them statically, even libXext. libX11 is somewhat stable, although
+   # even it has had an ABI change once or twice.
+   if(X11_FOUND AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+-    set(X11_LIBRARIES "-Wl,-Bstatic -lXext -Wl,-Bdynamic -lX11")
++    set(X11_LIBRARIES "-Wl,-Bstatic -lXext -lX11 -lxcb -lXdmcp -lXau -lICE -Wl,-Bdynamic -ldl -lpthread")
+     if(X11_XTest_LIB)
+       set(X11_XTest_LIB "-Wl,-Bstatic -lXtst -Wl,-Bdynamic")
+     endif()
+--- a/vncviewer/CMakeLists.txt	2014-11-04 21:38:36.000000000 -0500
++++ b/vncviewer/CMakeLists.txt	2015-01-01 18:15:32.000000000 -0500
+@@ -46,7 +46,7 @@
+   add_executable(vncviewer ${VNCVIEWER_SOURCES})
+ endif()
+ 
+-target_link_libraries(vncviewer rfb network rdr os Xregion ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES})
++target_link_libraries(vncviewer ${FLTK_LIBRARIES} rfb network rdr os Xregion ${GETTEXT_LIBRARIES})
+ 
+ if(APPLE)
+   target_link_libraries(vncviewer "-framework Cocoa" "-framework Carbon")
+--- a/CMakeLists.txt	2014-12-26 15:16:04.000000000 -0500
++++ b/CMakeLists.txt	2015-01-01 23:00:40.000000000 -0500
+@@ -203,6 +203,41 @@
+   add_subdirectory(java)
+ endif()
+ 
++# Check for GNUTLS library
++option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON)
++if(ENABLE_GNUTLS)
++  find_package(GnuTLS)
++  if (GNUTLS_FOUND)
++    include_directories(${GNUTLS_INCLUDE_DIR})
++    add_definitions("-DHAVE_GNUTLS")
++    add_definitions(${GNUTLS_DEFINITIONS})
++    
++    # Detect old version of GnuTLS
++    set(CMAKE_REQUIRED_FLAGS -I${GNUTLS_INCLUDE_DIR})
++    set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h)
++    set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
++    if(WIN32)
++      set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32 user32)
++    endif()
++    if(ZLIB_FOUND)
++      # When we build against the static version of GnuTLS, we also use the
++      # included version of Zlib, but it isn't built yet, so we have to use the
++      # system's version (if available) to perform this test.
++      set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz)
++    endif()
++    check_function_exists(gnutls_transport_set_errno HAVE_GNUTLS_SET_ERRNO)
++    check_function_exists(gnutls_transport_set_global_errno HAVE_GNUTLS_SET_GLOBAL_ERRNO)
++    check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT)
++    check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T)
++    check_type_size(gnutls_datum_t GNUTLS_DATUM_T)
++    check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T)
++    check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T)
++    set(CMAKE_REQUIRED_FLAGS)
++    set(CMAKE_EXTRA_INCLUDE_FILES) 
++    set(CMAKE_REQUIRED_LIBRARIES)
++  endif()
++endif()
++
+ # Check for FLTK
+ set(FLTK_SKIP_FLUID TRUE)
+ set(FLTK_SKIP_OPENGL TRUE)
+@@ -228,6 +263,8 @@
+   endif()
+ endif()
+ 
++include(cmake/StaticBuild.cmake)
++
+ if(FLTK_FOUND)
+   set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR})
+   set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES})
+@@ -263,41 +300,6 @@
+   set(CMAKE_REQUIRED_LIBRARIES)
+ endif()
+ 
+-# Check for GNUTLS library
+-option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON)
+-if(ENABLE_GNUTLS)
+-  find_package(GnuTLS)
+-  if (GNUTLS_FOUND)
+-    include_directories(${GNUTLS_INCLUDE_DIR})
+-    add_definitions("-DHAVE_GNUTLS")
+-    add_definitions(${GNUTLS_DEFINITIONS})
+-    
+-    # Detect old version of GnuTLS
+-    set(CMAKE_REQUIRED_FLAGS -I${GNUTLS_INCLUDE_DIR})
+-    set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h)
+-    set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
+-    if(WIN32)
+-      set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32 user32)
+-    endif()
+-    if(ZLIB_FOUND)
+-      # When we build against the static version of GnuTLS, we also use the
+-      # included version of Zlib, but it isn't built yet, so we have to use the
+-      # system's version (if available) to perform this test.
+-      set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz)
+-    endif()
+-    check_function_exists(gnutls_transport_set_errno HAVE_GNUTLS_SET_ERRNO)
+-    check_function_exists(gnutls_transport_set_global_errno HAVE_GNUTLS_SET_GLOBAL_ERRNO)
+-    check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT)
+-    check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T)
+-    check_type_size(gnutls_datum_t GNUTLS_DATUM_T)
+-    check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T)
+-    check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T)
+-    set(CMAKE_REQUIRED_FLAGS)
+-    set(CMAKE_EXTRA_INCLUDE_FILES) 
+-    set(CMAKE_REQUIRED_LIBRARIES)
+-  endif()
+-endif()
+-
+ # Check for PAM library
+ option(ENABLE_PAM "Enable PAM authentication support" ON)
+ if(ENABLE_PAM)
+@@ -330,8 +332,6 @@
+ add_definitions(-DHAVE_CONFIG_H)
+ include_directories(${CMAKE_BINARY_DIR})
+ 
+-include(cmake/StaticBuild.cmake)
+-
+ add_subdirectory(common)
+ 
+ if(WIN32)
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.1.1-pam.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.1.1-pam.patch
deleted file mode 100644
index cce82ea..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.1.1-pam.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 89d271cc1cb8214252a213bee37318a82d0e1db4 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 24 May 2010 16:55:24 -0400
-Subject: [PATCH] Build with PAM support
-
----
- configure.ac       |    2 ++
- hw/dmx/Makefile.am |    1 +
- os/utils.c         |    1 +
- 3 files changed, 4 insertions(+), 0 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index 776a3ae..b057af9 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -310,6 +310,8 @@ AC_CHECK_HEADER([execinfo.h],[
-     ])]
- )
- 
-+SYS_LIBS="-lpam_misc -lpam"
-+
- dnl ---------------------------------------------------------------------------
- dnl Bus options and CPU capabilities.  Replaces logic in
- dnl hw/xfree86/os-support/bus/Makefile.am, among others.
-diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
-index 3c59320..bbf0eb1 100644
---- a/hw/dmx/Makefile.am
-+++ b/hw/dmx/Makefile.am
-@@ -83,6 +83,7 @@ Xdmx_SOURCES = dmx.c \
- XDMX_LIBS = \
- 	@XDMX_LIBS@ \
- 	$(GLX_LIBS) \
-+	-lpam_misc -lpam \
-         input/libdmxinput.a \
-         config/libdmxconfig.a
- 
-diff --git a/os/utils.c b/os/utils.c
-index 4b43325..38d2732 100644
---- a/os/utils.c
-+++ b/os/utils.c
-@@ -1838,6 +1838,7 @@ CheckUserParameters(int argc, char **argv, char **envp)
-  * usually only done for setuid servers (uid != euid).
-  */
- 
-+#define USE_PAM 1
- #ifdef USE_PAM
- #include <security/pam_appl.h>
- #include <security/pam_misc.h>
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.4.99-pic-libxf86config.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.4.99-pic-libxf86config.patch
deleted file mode 100644
index 48d2e22..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.4.99-pic-libxf86config.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-From 4306b434038de7e2b17d3c4a6cfd87db469d3bda Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 10 Dec 2007 11:26:57 -0500
-Subject: [PATCH] Build libxf86config with -fPIC.
-
-diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am
-index b8fab28..ed831c9 100644
---- a/hw/xfree86/parser/Makefile.am
-+++ b/hw/xfree86/parser/Makefile.am
-@@ -33,7 +33,7 @@ libxf86config_a_SOURCES = \
- 	$(INTERNAL_SOURCES)
- libxf86config_a_CFLAGS = $(AM_CFLAGS)
- 
--AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
-+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) -fPIC -fvisibility=hidden
- 
- EXTRA_DIST = \
- 	Configint.h \
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.4.99-ssh-isnt-local.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.4.99-ssh-isnt-local.patch
deleted file mode 100644
index d532fe1..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.4.99-ssh-isnt-local.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 4306b434038de7e2b17d3c4a6cfd87db469d3bda Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 10 Dec 2007 11:26:57 -0500
-Subject: [PATCH] Hack for proper MIT-SHM rejection for ssh-forwarded clients.
-
----
- Xext/shm.c |   15 +++++++++++++++
- 1 files changed, 15 insertions(+), 0 deletions(-)
-
-diff --git a/Xext/shm.c b/Xext/shm.c
-index 5937a03..5376c19 100644
---- a/Xext/shm.c
-+++ b/Xext/shm.c
-@@ -381,8 +381,21 @@
-     mode_t mask;
-     int uidset = 0, gidset = 0;
-     LocalClientCredRec *lcc;
-+    Bool is_ssh = FALSE;
-     
-     if (GetLocalClientCreds(client, &lcc) != -1) {
-+#ifdef linux
-+	if (lcc->fieldsSet & LCC_PID_SET) {
-+	    /* ssh isn't actually a local client */
-+	    char exe[64], buf[64];
-+
-+	    memset(buf, 0, 64);
-+	    snprintf(exe, 64, "/proc/%d/exe", lcc->pid);
-+	    readlink(exe, buf, 63);
-+	    if (strstr(buf, "/ssh"))
-+		is_ssh = TRUE;
-+	}
-+#endif
- 
- 	if (lcc->fieldsSet & LCC_UID_SET) {
- 	    uid = lcc->euid;
-@@ -401,6 +414,9 @@
- 	}
- #endif
- 	FreeLocalClientCreds(lcc);
-+
-+	if (is_ssh)
-+	    return -1;
- 	
- 	if (uidset) {
- 	    /* User id 0 always gets access */
--- 
-1.5.3.4
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.5.0-bg-none-root.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.5.0-bg-none-root.patch
deleted file mode 100644
index 097b085..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.5.0-bg-none-root.patch
+++ /dev/null
@@ -1,155 +0,0 @@
-From b4e4b980663692a3af5787eeaf2d48eb6c0188ed Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <airlied@redhat.com>
-Date: Tue, 4 Aug 2009 14:45:58 +1000
-Subject: [PATCH] Add nr for background=none root
-
----
- dix/globals.c                |    1 +
- dix/window.c                 |   12 +++++++-----
- hw/xfree86/common/xf86Init.c |   11 +++++++++++
- hw/xfree86/common/xf86str.h  |    5 ++++-
- include/opaque.h             |    1 +
- os/utils.c                   |    3 +++
- 6 files changed, 27 insertions(+), 6 deletions(-)
-
-diff --git a/dix/globals.c b/dix/globals.c
-index c24a94f..907a5e8 100644
---- a/dix/globals.c
-+++ b/dix/globals.c
-@@ -124,6 +124,7 @@ FontPtr defaultFont;   /* not declared in dix.h to avoid including font.h in
- CursorPtr rootCursor;
- Bool party_like_its_1989 = FALSE;
- Bool whiteRoot = FALSE;
-+Bool bgNoneRoot = FALSE;
- 
- int cursorScreenDevPriv[MAXSCREENS];
- 
-diff --git a/dix/window.c b/dix/window.c
-index 32e26d9..0bf1d52 100644
---- a/dix/window.c
-+++ b/dix/window.c
-@@ -466,22 +466,24 @@ InitRootWindow(WindowPtr pWin)
-     pWin->optional->cursor = rootCursor;
-     rootCursor->refcnt++;
- 
-+    pWin->backingStore = defaultBackingStore;
-+    pWin->forcedBS = (defaultBackingStore != NotUseful);
- 
-     if (party_like_its_1989) {
-         MakeRootTile(pWin);
-         backFlag |= CWBackPixmap;
-+        pScreen->ChangeWindowAttributes(pWin, backFlag);
-+    } else if (bgNoneRoot) {
-+       /* nothing, handled in xf86CreateRootWindow */
-     } else {
- 	if (whiteRoot)
-             pWin->background.pixel = pScreen->whitePixel;
-         else
-             pWin->background.pixel = pScreen->blackPixel;
-         backFlag |= CWBackPixel;
--    } 
- 
--    pWin->backingStore = defaultBackingStore;
--    pWin->forcedBS = (defaultBackingStore != NotUseful);
--    /* We SHOULD check for an error value here XXX */
--    (*pScreen->ChangeWindowAttributes)(pWin, backFlag);
-+        pScreen->ChangeWindowAttributes(pWin, backFlag);
-+    }
- 
-     MapWindow(pWin, serverClient);
- }
-diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
-index e84da4e..2a0f47a 100644
---- a/hw/xfree86/common/xf86Init.c
-+++ b/hw/xfree86/common/xf86Init.c
-@@ -77,6 +77,7 @@
- #ifdef RENDER
- #include "picturestr.h"
- #endif
-+#include "xace.h"
- 
- #include "xf86VGAarbiter.h"
- #include "globals.h"
-@@ -234,6 +235,7 @@ xf86CreateRootWindow(WindowPtr pWin)
-   int ret = TRUE;
-   int err = Success;
-   ScreenPtr pScreen = pWin->drawable.pScreen;
-+  ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   RootWinPropPtr pProp;
-   CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
-       dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
-@@ -285,6 +287,15 @@ xf86CreateRootWindow(WindowPtr pWin)
-     }
-   }
- 
-+  if (bgNoneRoot && pScrn->canDoBGNoneRoot) {
-+      pWin->backgroundState = XaceBackgroundNoneState(pWin);
-+      pWin->background.pixel = pScreen->whitePixel;
-+      pScreen->ChangeWindowAttributes(pWin, CWBackPixmap | CWBorderPixel | CWCursor | CWBackingStore);
-+  } else {
-+      pWin->background.pixel = pScreen->blackPixel;
-+      pScreen->ChangeWindowAttributes(pWin, CWBackPixel | CWBorderPixel | CWCursor | CWBackingStore);
-+  }
-+
-   DebugF("xf86CreateRootWindow() returns %d\n", ret);
-   return (ret);
- }
-diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
-index 5c3ee44..e3c7841 100644
---- a/hw/xfree86/common/xf86str.h
-+++ b/hw/xfree86/common/xf86str.h
-@@ -516,7 +516,7 @@ typedef struct _confdrirec {
- } confDRIRec, *confDRIPtr;
- 
- /* These values should be adjusted when new fields are added to ScrnInfoRec */
--#define NUM_RESERVED_INTS		16
-+#define NUM_RESERVED_INTS		15
- #define NUM_RESERVED_POINTERS		14
- #define NUM_RESERVED_FUNCS		11
- 
-@@ -800,6 +800,9 @@ typedef struct _ScrnInfoRec {
-     ClockRangesPtr	clockRanges;
-     int			adjustFlags;
- 
-+    /* -nr support */
-+    int                 canDoBGNoneRoot;
-+
-     /*
-      * These can be used when the minor ABI version is incremented.
-      * The NUM_* parameters must be reduced appropriately to keep the
-diff --git a/include/opaque.h b/include/opaque.h
-index b3c7c70..fcc8c95 100644
---- a/include/opaque.h
-+++ b/include/opaque.h
-@@ -71,6 +71,7 @@ extern _X_EXPORT Bool defeatAccessControl;
- extern _X_EXPORT long maxBigRequestSize;
- extern _X_EXPORT Bool party_like_its_1989;
- extern _X_EXPORT Bool whiteRoot;
-+extern _X_EXPORT Bool bgNoneRoot;
- 
- extern _X_EXPORT Bool CoreDump;
- 
-diff --git a/os/utils.c b/os/utils.c
-index 00abd63..7bfdf8b 100644
---- a/os/utils.c
-+++ b/os/utils.c
-@@ -514,6 +514,7 @@ void UseMsg(void)
- #endif
-     ErrorF("-nolisten string       don't listen on protocol\n");
-     ErrorF("-noreset               don't reset after last client exists\n");
-+    ErrorF("-nr                    create root window with no background\n");
-     ErrorF("-reset                 reset after last client exists\n");
-     ErrorF("-p #                   screen-saver pattern duration (minutes)\n");
-     ErrorF("-pn                    accept failure to listen on all ports\n");
-@@ -861,6 +862,8 @@ ProcessCommandLine(int argc, char *argv[])
- 	    defaultBackingStore = WhenMapped;
-         else if ( strcmp( argv[i], "-wr") == 0)
-             whiteRoot = TRUE;
-+        else if ( strcmp( argv[i], "-nr") == 0)
-+            bgNoneRoot = TRUE;
-         else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
-              if(++i < argc) {
-                  long reqSizeArg = atol(argv[i]);
--- 
-1.6.0.6
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.5.0-projector-fb-size.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.5.0-projector-fb-size.patch
deleted file mode 100644
index c6178b8..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.5.0-projector-fb-size.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From dc5cedd61e00afec33cbfaa7fdfbb6c357074dbd Mon Sep 17 00:00:00 2001
-From: =?utf-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <sandmann@redhat.com>
-Date: Thu, 11 Sep 2008 12:51:31 -0400
-Subject: [PATCH] Make room for an external monitor if we have enough video RAM
-
----
- hw/xfree86/modes/xf86Crtc.c |    9 +++++++++
- 1 files changed, 9 insertions(+), 0 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
-index 4de7e05..9bcf81b 100644
---- a/hw/xfree86/modes/xf86Crtc.c
-+++ b/hw/xfree86/modes/xf86Crtc.c
-@@ -987,6 +987,15 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp,
- 	if (crtc_height > height)
- 	    height = crtc_height;
-     }
-+
-+    /* Make room for an external monitor if we have enough video ram */
-+    if (scrn->videoRam >= 65536)
-+        width += 1920;
-+    else if (scrn->videoRam >= 32768)
-+        width += 1280;
-+    else if (scrn->videoRam >= 16384)
-+        width += 1024;
-+
-     if (config->maxWidth && width > config->maxWidth) width = config->maxWidth;
-     if (config->maxHeight && height > config->maxHeight) height = config->maxHeight;
-     if (config->minWidth && width < config->minWidth) width = config->minWidth;
--- 
-1.6.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.5.1-mode-debug.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.5.1-mode-debug.patch
deleted file mode 100644
index 11fe5ad..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.5.1-mode-debug.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 079910986a1b8f5042e16ee2ba3ad9ed843b67ca Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 7 Oct 2008 11:09:14 -0400
-Subject: [PATCH] Force ModeDebug on.
-
----
- hw/xfree86/modes/xf86Crtc.c |    3 +--
- 1 files changed, 1 insertions(+), 2 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
-index 9bcf81b..a953c8a 100644
---- a/hw/xfree86/modes/xf86Crtc.c
-+++ b/hw/xfree86/modes/xf86Crtc.c
-@@ -2084,8 +2084,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
-     xf86ProcessOptions (scrn->scrnIndex,
- 			scrn->options,
- 			config->options);
--    config->debug_modes = xf86ReturnOptValBool (config->options,
--						OPTION_MODEDEBUG, FALSE);
-+    config->debug_modes = TRUE;
- 
-     if (scrn->display->virtualX)
- 	width = scrn->display->virtualX;
--- 
-1.6.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.0-displayfd.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.6.0-displayfd.patch
deleted file mode 100644
index 09e7b49..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.0-displayfd.patch
+++ /dev/null
@@ -1,172 +0,0 @@
-From 1766352059d0db67bff3f7dd0820563a30f54858 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Thu, 18 Jun 2009 16:56:41 +1000
-Subject: [PATCH] displayfd hack
-
----
- dix/globals.c    |    1 +
- include/opaque.h |    1 +
- os/connection.c  |   72 ++++++++++++++++++++++++++++++++++++-----------------
- os/utils.c       |   11 ++++++++
- 4 files changed, 62 insertions(+), 23 deletions(-)
-
-diff --git a/dix/globals.c b/dix/globals.c
-index 907a5e8..c1e64d3 100644
---- a/dix/globals.c
-+++ b/dix/globals.c
-@@ -135,6 +135,7 @@ int defaultColorVisualClass = -1;
- int monitorResolution = 0;
- 
- char *display;
-+int displayfd;
- char *ConnectionInfo;
- 
- CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
-diff --git a/include/opaque.h b/include/opaque.h
-index fcc8c95..2a08e2d 100644
---- a/include/opaque.h
-+++ b/include/opaque.h
-@@ -50,6 +50,7 @@ extern _X_EXPORT int ScreenSaverAllowExposures;
- extern _X_EXPORT int defaultScreenSaverBlanking;
- extern _X_EXPORT int defaultScreenSaverAllowExposures;
- extern _X_EXPORT char *display;
-+extern _X_EXPORT int displayfd;
- 
- extern _X_EXPORT int defaultBackingStore;
- extern _X_EXPORT Bool disableBackingStore;
-diff --git a/os/connection.c b/os/connection.c
-index 0c72b67..05d95c4 100644
---- a/os/connection.c
-+++ b/os/connection.c
-@@ -146,6 +146,7 @@ Bool NewOutputPending;		/* not yet attempted to write some new output */
- Bool AnyClientsWriteBlocked;	/* true if some client blocked on write */
- 
- static Bool RunFromSmartParent;	/* send SIGUSR1 to parent process */
-+static char dynamic_display[7];
- Bool PartialNetwork;	/* continue even if unable to bind all addrs */
- static Pid_t ParentProcess;
- 
-@@ -357,9 +358,23 @@ NotifyParentProcess(void)
- 	    kill (ParentProcess, SIGUSR1);
- 	}
-     }
-+    if (dynamic_display[0])
-+	write(displayfd, dynamic_display, strlen(dynamic_display));
- #endif
- }
- 
-+static Bool
-+TryCreateSocket(int num, int *partial)
-+{
-+    char port[20];
-+
-+    sprintf(port, "%d", num);
-+
-+    return _XSERVTransMakeAllCOTSServerListeners(port, partial,
-+						 &ListenTransCount,
-+						 &ListenTransConns);
-+}
-+
- /*****************
-  * CreateWellKnownSockets
-  *    At initialization, create the sockets to listen on for new clients.
-@@ -370,7 +385,6 @@ CreateWellKnownSockets(void)
- {
-     int		i;
-     int		partial;
--    char 	port[20];
- 
-     FD_ZERO(&AllSockets);
-     FD_ZERO(&AllClients);
-@@ -385,32 +399,44 @@ CreateWellKnownSockets(void)
- 
-     FD_ZERO (&WellKnownConnections);
- 
--    sprintf (port, "%d", atoi (display));
--
--    if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
--	&ListenTransCount, &ListenTransConns) >= 0) &&
--	(ListenTransCount >= 1))
-+    if (display)
-     {
--	if (!PartialNetwork && partial)
--	{
--	    FatalError ("Failed to establish all listening sockets");
--	}
--	else
-+	if (TryCreateSocket(atoi(display), &partial) &&
-+	    (ListenTransCount >= 1))
-+	    if (!PartialNetwork && partial)
-+		FatalError ("Failed to establish all listening sockets");
-+    }
-+    else /* -displayfd */
-+    {
-+	Bool found = 0;
-+	for (i = 0; i < 65535 - 1024; i++)
- 	{
--	    ListenTransFds = xalloc (ListenTransCount * sizeof (int));
--
--	    for (i = 0; i < ListenTransCount; i++)
-+	    if (!TryCreateSocket(i, &partial) && !partial)
- 	    {
--		int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
--		
--		ListenTransFds[i] = fd;
--		FD_SET (fd, &WellKnownConnections);
--
--		if (!_XSERVTransIsLocal (ListenTransConns[i]))
--		{
--		    DefineSelf (fd);
--		}
-+		found = 1;
-+		break;
- 	    }
-+	    else
-+		CloseWellKnownConnections();
-+	}
-+	if (!found)
-+	    FatalError("Failed to find a socket to listen on");
-+	sprintf(dynamic_display, "%d\n", i);
-+	display = dynamic_display;
-+    }
-+
-+    ListenTransFds = xalloc (ListenTransCount * sizeof (int));
-+
-+    for (i = 0; i < ListenTransCount; i++)
-+    {
-+	int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
-+
-+	ListenTransFds[i] = fd;
-+	FD_SET (fd, &WellKnownConnections);
-+
-+	if (!_XSERVTransIsLocal (ListenTransConns[i]))
-+	{
-+	    DefineSelf (fd);
- 	}
-     }
- 
-diff --git a/os/utils.c b/os/utils.c
-index 7bfdf8b..37a93b1 100644
---- a/os/utils.c
-+++ b/os/utils.c
-@@ -678,6 +678,17 @@ ProcessCommandLine(int argc, char *argv[])
- 	    else
- 		UseMsg();
- 	}
-+	else if (strcmp(argv[i], "-displayfd") == 0)
-+	{
-+	    if (++i < argc)
-+	    {
-+		displayfd = atoi(argv[i]);
-+		display = NULL;
-+		nolock = TRUE;
-+	    }
-+	    else
-+		UseMsg();
-+	}
- #ifdef DPMSExtension
- 	else if ( strcmp( argv[i], "dpms") == 0)
- 	    /* ignored for compatibility */ ;
--- 
-1.6.3.rc1.2.g0164.dirty
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.0-less-acpi-brokenness.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.6.0-less-acpi-brokenness.patch
deleted file mode 100644
index cc80e6c..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.0-less-acpi-brokenness.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From a8079882f1884edc62a9de28af915bd8b65dfbbe Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Wed, 11 Mar 2009 14:02:11 -0400
-Subject: [PATCH] Don't build the ACPI code.
-
-No good can come of this.
----
- configure.ac |    2 --
- 1 files changed, 0 insertions(+), 2 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index 72ae67e..04716f8 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1269,13 +1269,11 @@ if test "x$XORG" = xyes; then
- 		case $host_cpu in
- 		  ia64*)
- 			linux_ia64=yes
--			linux_acpi="yes"
- 			;;
- 		  alpha*)
- 		  	linux_alpha=yes
- 			;;
- 		  i*86|amd64*|x86_64*)
--			linux_acpi="yes"
- 			;;
- 		  *)
- 			;;
--- 
-1.6.1.3
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.1-nouveau.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.6.1-nouveau.patch
deleted file mode 100644
index c6428ec..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.1-nouveau.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-From b3872657c551d884141196cb098f53d3c01d1d3d Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Tue, 23 Jun 2009 13:52:23 +1000
-Subject: [PATCH] autoconfig: select nouveau by default for NVIDIA GPUs
-
-Also, don't treat DRI setup failure as an error for nouveau.
----
- glx/glxdri.c                       |    7 +++++--
- glx/glxdri2.c                      |    7 +++++--
- hw/xfree86/common/xf86AutoConfig.c |   27 ++++++++++++++++++++++++++-
- 3 files changed, 36 insertions(+), 5 deletions(-)
-
-diff --git a/glx/glxdri.c b/glx/glxdri.c
-index 5fb75a4..45c79c9 100644
---- a/glx/glxdri.c
-+++ b/glx/glxdri.c
-@@ -967,6 +967,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
-     const __DRIconfig **driConfigs;
-     const __DRIextension **extensions;
-     int i;
-+    int from = X_ERROR;
- 
-     if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") ||
- 	!DRIQueryDirectRenderingCapable(pScreen, &isCapable) ||
-@@ -1046,7 +1047,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
- 
-     screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
-     if (screen->driver == NULL) {
--	LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
-+	if (!strcmp(driverName, "nouveau"))
-+	    from = X_INFO;
-+	LogMessage(from, "AIGLX error: dlopen of %s failed (%s)\n",
- 		   filename, dlerror());
-         goto handle_error;
-     }
-@@ -1183,7 +1186,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
- 
-     xfree(screen);
- 
--    LogMessage(X_ERROR, "AIGLX: reverting to software rendering\n");
-+    LogMessage(from, "AIGLX: reverting to software rendering\n");
- 
-     return NULL;
- }
-diff --git a/glx/glxdri2.c b/glx/glxdri2.c
-index 529b2df..ff4490b 100644
---- a/glx/glxdri2.c
-+++ b/glx/glxdri2.c
-@@ -587,6 +587,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
-     const __DRIextension **extensions;
-     const __DRIconfig **driConfigs;
-     int i;
-+    int from = X_ERROR;
- 
-     screen = xcalloc(1, sizeof *screen);
-     if (screen == NULL)
-@@ -613,7 +614,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
- 
-     screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
-     if (screen->driver == NULL) {
--	LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
-+	if (!strcmp(driverName, "nouveau"))
-+	    from = X_INFO;
-+	LogMessage(from, "AIGLX error: dlopen of %s failed (%s)\n",
- 		   filename, dlerror());
-         goto handle_error;
-     }
-@@ -692,7 +695,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
- 
-     xfree(screen);
- 
--    LogMessage(X_ERROR, "AIGLX: reverting to software rendering\n");
-+    LogMessage(from, "AIGLX: reverting to software rendering\n");
- 
-     return NULL;
- }
-diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
-index bc4c80b..d8fa80f 100644
---- a/hw/xfree86/common/xf86AutoConfig.c
-+++ b/hw/xfree86/common/xf86AutoConfig.c
-@@ -180,7 +180,23 @@ videoPtrToDriverList(struct pci_device *dev,
- 	    break;
- 	case 0x102b:		    driverList[0] = "mga";	break;
- 	case 0x10c8:		    driverList[0] = "neomagic"; break;
--	case 0x10de: case 0x12d2:   driverList[0] = "nv";	break;
-+	case 0x10de: case 0x12d2:
-+	    switch (dev->device_id) {
-+	    /* NV1 */
-+	    case 0x0008:
-+	    case 0x0009:
-+		driverList[0] = "vesa";
-+		break;
-+	    /* NV3 */
-+	    case 0x0018:
-+	    case 0x0019:
-+		driverList[0] = "nv";
-+		break;
-+	    default:
-+		driverList[0] = "nouveau";
-+		break;
-+	    }
-+	    break;
- 	case 0x1106:		    driverList[0] = "openchrome"; break;
- 	case 0x1163:		    driverList[0] = "rendition"; break;
- 	case 0x5333:
--- 
-1.6.2.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-default-modes.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-default-modes.patch
deleted file mode 100644
index 782cc69..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-default-modes.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 50552b0ee81b23b997bebd798b19b4a7e234a55f Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Fri, 21 Aug 2009 13:51:45 -0400
-Subject: [PATCH] tweak default mode list yet again
-
----
- hw/xfree86/modes/xf86Crtc.c |    5 ++++-
- 1 files changed, 4 insertions(+), 1 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
-index 4f14a75..c6fd910 100644
---- a/hw/xfree86/modes/xf86Crtc.c
-+++ b/hw/xfree86/modes/xf86Crtc.c
-@@ -1567,7 +1567,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
- 	int		    min_clock = 0;
- 	int		    max_clock = 0;
- 	double		    clock;
--	Bool                add_default_modes = TRUE;
-+	Bool                add_default_modes;
- 	enum { sync_config, sync_edid, sync_default } sync_source = sync_default;
- 	
- 	while (output->probed_modes != NULL)
-@@ -1610,6 +1610,9 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
- 	}
- 	
- 	output_modes = (*output->funcs->get_modes) (output);
-+
-+	/* if the driver found modes, don't second-guess it */
-+	add_default_modes = (output_modes == NULL);
- 	
- 	edid_monitor = output->MonInfo;
- 	
--- 
-1.6.4
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-hush-prerelease-warning.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-hush-prerelease-warning.patch
deleted file mode 100644
index 21ba953..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-hush-prerelease-warning.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From e9a81cb99315cf4c5325b276b802c659b9f04045 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 15 Sep 2009 10:33:40 -0400
-Subject: [PATCH] Hush prerelease warning.
-
----
- hw/xfree86/common/xf86Init.c |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
-index 056e46d..3cdbdf4 100644
---- a/hw/xfree86/common/xf86Init.c
-+++ b/hw/xfree86/common/xf86Init.c
-@@ -132,7 +132,7 @@ static Bool formatsDone = FALSE;
- static void
- xf86PrintBanner(void)
- {
--#if PRE_RELEASE
-+#if 0
-   ErrorF("\n"
-     "This is a pre-release version of the X server from " XVENDORNAME ".\n"
-     "It is not supported in any way.\n"
--- 
-1.6.4.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-randr-error-debugging.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-randr-error-debugging.patch
deleted file mode 100644
index c5d6686..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-randr-error-debugging.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 16be69ef1e2ea9f19cd596b99b5ede7567d374b8 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 27 Jul 2009 16:52:42 -0400
-Subject: [PATCH 11/16] additional randr debugging
-
----
- randr/randr.c |   16 +++++++++++++++-
- 1 files changed, 15 insertions(+), 1 deletions(-)
-
-diff --git a/randr/randr.c b/randr/randr.c
-index 1c1d0c4..accf614 100644
---- a/randr/randr.c
-+++ b/randr/randr.c
-@@ -477,10 +477,24 @@ RRVerticalRefresh (xRRModeInfo *mode)
- static int
- ProcRRDispatch (ClientPtr client)
- {
-+    int ret;
-     REQUEST(xReq);
-     if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
- 	return BadRequest;
--    return (*ProcRandrVector[stuff->data]) (client);
-+    ret = ProcRandrVector[stuff->data](client);
-+
-+    if (ret) {
-+        int i;
-+        ErrorF("RANDR failure: %d (extension base %d)\n", ret, RRErrorBase);
-+        for (i = 0; i < stuff->length; i++) {
-+            ErrorF("%08x ", *(((unsigned int *)stuff) + i));
-+            if ((i+1) % 4 == 0)
-+               ErrorF("\n");
-+        }
-+        ErrorF("\n");
-+    }
-+
-+    return ret;
- }
- 
- static int
--- 
-1.6.4.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-right-of.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-right-of.patch
deleted file mode 100644
index 06c1183..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.6.99-right-of.patch
+++ /dev/null
@@ -1,172 +0,0 @@
-From 1766ae8a69daa06730e41d094fdddf53db3a1a9e Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 28 Jul 2009 11:07:13 -0400
-Subject: [PATCH] RANDR: right-of placement by default
-
-[Enhanced to add a new prefer clone option for drivers. This
-allows for servers like RN50 where two heads are disjoint. - airlied]
-
-[Enhanced to ignore rightof on single crtc cards - airlied]
----
- hw/xfree86/common/xf86str.h |    9 ++++-
- hw/xfree86/modes/xf86Crtc.c |   77 +++++++++++++++++++++++++++++++++++++++----
- 2 files changed, 77 insertions(+), 9 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
-index 5c3aa00..8224668 100644
---- a/hw/xfree86/common/xf86str.h
-+++ b/hw/xfree86/common/xf86str.h
-@@ -503,10 +503,13 @@ typedef struct _confdrirec {
- } confDRIRec, *confDRIPtr;
- 
- /* These values should be adjusted when new fields are added to ScrnInfoRec */
--#define NUM_RESERVED_INTS		15
-+#define NUM_RESERVED_INTS		14
- #define NUM_RESERVED_POINTERS		14
- #define NUM_RESERVED_FUNCS		11
- 
-+/* let clients know they can use this */
-+#define XF86_SCRN_HAS_PREFER_CLONE 1
-+
- typedef pointer (*funcPointer)(void);
- 
- /* flags for depth 24 pixmap options */
-@@ -672,7 +675,6 @@ typedef void xf86SetOverscanProc          (ScrnInfoPtr, int);
-  * are to be dependent on compile-time defines.
-  */
- 
--
- typedef struct _ScrnInfoRec {
-     int			driverVersion;
-     char *		driverName;		/* canonical name used in */
-@@ -778,6 +780,9 @@ typedef struct _ScrnInfoRec {
-     /* -nr support */
-     int                 canDoBGNoneRoot;
- 
-+    /* initial rightof support disable */
-+    int                 preferClone;
-+
-     /*
-      * These can be used when the minor ABI version is incremented.
-      * The NUM_* parameters must be reduced appropriately to keep the
-diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
-index a66c979..4d14f57 100644
---- a/hw/xfree86/modes/xf86Crtc.c
-+++ b/hw/xfree86/modes/xf86Crtc.c
-@@ -1146,6 +1146,15 @@ xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes)
-     int			o;
-     int			min_x, min_y;
-     
-+    /* check for initial right-of heuristic */
-+    for (o = 0; o < config->num_output; o++)
-+    {
-+	xf86OutputPtr	output = config->output[o];
-+
-+	if (output->initial_x || output->initial_y)
-+            return TRUE;
-+    }
-+
-     for (o = 0; o < config->num_output; o++)
-     {
- 	xf86OutputPtr	output = config->output[o];
-@@ -2028,6 +2037,60 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
-     return match;
- }
- 
-+static int
-+numEnabledOutputs(xf86CrtcConfigPtr config, Bool *enabled)
-+{
-+    int i = 0, p;
-+
-+    for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ;
-+
-+    return i;
-+}
-+
-+static Bool
-+xf86TargetRightOf(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
-+		  DisplayModePtr *modes, Bool *enabled,
-+		  int width, int height)
-+{
-+    int o;
-+    int w = 0;
-+
-+    if (config->num_crtc == 1)
-+	return FALSE;
-+
-+    if (scrn->preferClone)
-+	return FALSE;
-+
-+    if (numEnabledOutputs(config, enabled) < 2)
-+	return FALSE;
-+
-+    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
-+	DisplayModePtr mode =
-+	    xf86OutputHasPreferredMode(config->output[o], width, height);
-+
-+	if (!mode)
-+	    return FALSE;
-+
-+	w += mode->HDisplay;
-+    }
-+
-+    if (w > width)
-+	return FALSE;
-+
-+    w = 0;
-+    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
-+	DisplayModePtr mode =
-+	    xf86OutputHasPreferredMode(config->output[o], width, height);
-+
-+	config->output[o]->initial_x = w;
-+	w += mode->HDisplay;
-+
-+	modes[o] = mode;
-+    }
-+
-+    return TRUE;
-+}
-+
- static Bool
- xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- 		    DisplayModePtr *modes, Bool *enabled,
-@@ -2085,13 +2148,9 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
-      * biggest mode for its aspect ratio, assuming one exists.
-      */
-     if (!ret) do {
--	int i = 0;
- 	float aspect = 0.0;
- 
--	/* count the number of enabled outputs */
--	for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ;
--
--	if (i != 1)
-+	if (numEnabledOutputs(config, enabled) != 1)
- 	    break;
- 
- 	p = -1;
-@@ -2378,6 +2437,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
- 
-     if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
- 	xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
-+    else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
-+	xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
-     else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
- 	xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
-     else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
-@@ -2394,8 +2455,10 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
- 			config->output[o]->name);
- 	else
- 	    xf86DrvMsg (scrn->scrnIndex, X_INFO,
--			"Output %s using initial mode %s\n",
--			config->output[o]->name, modes[o]->name);
-+			"Output %s using initial mode %s +%d+%d\n",
-+			config->output[o]->name, modes[o]->name,
-+                        config->output[o]->initial_x,
-+                        config->output[o]->initial_y);
-     }
- 
-     /*
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.0-glx-versioning.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.0-glx-versioning.patch
deleted file mode 100644
index c8a1c30..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.0-glx-versioning.patch
+++ /dev/null
@@ -1,233 +0,0 @@
-From 3ef4be8129f78afd5566a9e5d0fb901449dcb771 Mon Sep 17 00:00:00 2001
-From: Ian Romanick <ian.d.romanick@intel.com>
-Date: Tue, 29 Sep 2009 16:43:43 -0700
-Subject: [PATCH] GLX: Enable GLX 1.4 on DRI2
-
-this squashes 4 commits
-(cherry picked from commit ad5c0d9efa47476ed5cf75c82265c73919e468b4)
-(cherry picked from commit cb54cf1b3e8c4109541cfb698542c00f2473e731)
-(cherry picked from commit 4c6bfa2c09ae2b0cffdf9211a6dfbcaefe0366b5)
-(cherry picked from commit 9bf2ff4faf730913de3073f346646a8727be41d4)
----
- glx/glxcmds.c                      |   12 ++++++++----
- glx/glxdri2.c                      |   12 ++++++++++++
- glx/glxext.c                       |    8 +++++++-
- glx/glxscreens.c                   |   15 ++++++++++++---
- glx/glxscreens.h                   |   11 +++++++++++
- glx/glxserver.h                    |    3 +++
- glx/indirect_texture_compression.c |    4 ++--
- include/protocol-versions.h        |    2 +-
- 8 files changed, 56 insertions(+), 11 deletions(-)
-
-diff --git a/glx/glxcmds.c b/glx/glxcmds.c
-index b1061a8..ba4c123 100644
---- a/glx/glxcmds.c
-+++ b/glx/glxcmds.c
-@@ -50,7 +50,6 @@
- #include "indirect_dispatch.h"
- #include "indirect_table.h"
- #include "indirect_util.h"
--#include "protocol-versions.h"
- 
- static int
- validGlxScreen(ClientPtr client, int screen, __GLXscreen **pGlxScreen, int *err)
-@@ -739,8 +738,8 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc)
-     ** client if it wants to work with older clients; however, in this
-     ** implementation the server just returns its version number.
-     */
--    reply.majorVersion = SERVER_GLX_MAJOR_VERSION;
--    reply.minorVersion = SERVER_GLX_MINOR_VERSION;
-+    reply.majorVersion = glxMajorVersion;
-+    reply.minorVersion = glxMinorVersion;
-     reply.length = 0;
-     reply.type = X_Reply;
-     reply.sequenceNumber = client->sequence;
-@@ -2360,6 +2359,7 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc)
-     char *buf;
-     __GLXscreen *pGlxScreen;
-     int err;
-+    char ver_str[16];
- 
-     if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
- 	return err;
-@@ -2369,7 +2369,11 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc)
- 	    ptr = pGlxScreen->GLXvendor;
- 	    break;
- 	case GLX_VERSION:
--	    ptr = pGlxScreen->GLXversion;
-+	    /* Return to the server version rather than the screen version
-+	     * to prevent confusion when they do not match.
-+	     */
-+	    snprintf(ver_str, 16, "%d.%d", glxMajorVersion, glxMinorVersion);
-+	    ptr = ver_str;
- 	    break;
- 	case GLX_EXTENSIONS:
- 	    ptr = pGlxScreen->GLXextensions;
-diff --git a/glx/glxdri2.c b/glx/glxdri2.c
-index ed7fb4c..ed7dc80 100644
---- a/glx/glxdri2.c
-+++ b/glx/glxdri2.c
-@@ -685,6 +685,18 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
- 				       screen->base.GLXextensions);
-     }
- 
-+    /* We're going to assume (perhaps incorrectly?) that all DRI2-enabled
-+     * drivers support the required extensions for GLX 1.4.  The extensions
-+     * we're assuming are:
-+     *
-+     *    - GLX_SGI_make_current_read (1.3)
-+     *    - GLX_SGIX_fbconfig (1.3)
-+     *    - GLX_SGIX_pbuffer (1.3)
-+     *    - GLX_ARB_multisample (1.4)
-+     */
-+    screen->base.GLXmajor = 1;
-+    screen->base.GLXminor = 4;
-+
-     screen->enterVT = pScrn->EnterVT;
-     pScrn->EnterVT = glxDRIEnterVT; 
-     screen->leaveVT = pScrn->LeaveVT;
-diff --git a/glx/glxext.c b/glx/glxext.c
-index 19d70d4..9f9c0ed 100644
---- a/glx/glxext.c
-+++ b/glx/glxext.c
-@@ -360,12 +360,18 @@ void GlxExtensionInit(void)
- 	pScreen = screenInfo.screens[i];
- 
- 	for (p = __glXProviderStack; p != NULL; p = p->next) {
--	    if (p->screenProbe(pScreen) != NULL) {
-+	    __GLXscreen *glxScreen;
-+
-+	    glxScreen = p->screenProbe(pScreen);
-+	    if (glxScreen != NULL) {
-+	        if (glxScreen->GLXminor < glxMinorVersion)
-+		    glxMinorVersion = glxScreen->GLXminor;
- 		LogMessage(X_INFO,
- 			   "GLX: Initialized %s GL provider for screen %d\n",
- 			   p->name, i);
- 		break;
- 	    }
-+
- 	}
- 
- 	if (!p)
-diff --git a/glx/glxscreens.c b/glx/glxscreens.c
-index 7d29d31..674e2c6 100644
---- a/glx/glxscreens.c
-+++ b/glx/glxscreens.c
-@@ -42,6 +42,7 @@
- #include "glxserver.h"
- #include "glxutil.h"
- #include "glxext.h"
-+#include "protocol-versions.h"
- 
- static int glxScreenPrivateKeyIndex;
- static DevPrivateKey glxScreenPrivateKey = &glxScreenPrivateKeyIndex;
-@@ -162,7 +163,8 @@ static const char GLServerExtensions[] =
- ** supported across all screens in a multi-screen system.
- */
- static char GLXServerVendorName[] = "SGI";
--static char GLXServerVersion[] = "1.2";
-+unsigned glxMajorVersion = SERVER_GLX_MAJOR_VERSION;
-+unsigned glxMinorVersion = SERVER_GLX_MINOR_VERSION;
- static char GLXServerExtensions[] =
- 			"GLX_ARB_multisample "
- 			"GLX_EXT_visual_info "
-@@ -378,9 +380,17 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
-     pGlxScreen->pScreen       = pScreen;
-     pGlxScreen->GLextensions  = xstrdup(GLServerExtensions);
-     pGlxScreen->GLXvendor     = xstrdup(GLXServerVendorName);
--    pGlxScreen->GLXversion    = xstrdup(GLXServerVersion);
-     pGlxScreen->GLXextensions = xstrdup(GLXServerExtensions);
- 
-+    /* All GLX providers must support all of the functionality required for at
-+     * least GLX 1.2.  If the provider supports a higher version, the GLXminor
-+     * version can be changed in the provider's screen-probe routine.  For
-+     * most providers, the screen-probe routine is the caller of this
-+     * function.
-+     */
-+    pGlxScreen->GLXmajor      = 1;
-+    pGlxScreen->GLXminor      = 2;
-+
-     pGlxScreen->CloseScreen = pScreen->CloseScreen;
-     pScreen->CloseScreen = glxCloseScreen;
-     pGlxScreen->DestroyWindow = pScreen->DestroyWindow;
-@@ -454,7 +464,6 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
- void __glXScreenDestroy(__GLXscreen *screen)
- {
-     xfree(screen->GLXvendor);
--    xfree(screen->GLXversion);
-     xfree(screen->GLXextensions);
-     xfree(screen->GLextensions);
- }
-diff --git a/glx/glxscreens.h b/glx/glxscreens.h
-index 3c1bdd4..bff4363 100644
---- a/glx/glxscreens.h
-+++ b/glx/glxscreens.h
-@@ -161,6 +161,17 @@ struct __GLXscreen {
-     char *GLXversion;
-     char *GLXextensions;
- 
-+    /**
-+     * \name GLX version supported by this screen.
-+     *
-+     * Since the GLX version advertised by the server is for the whole server,
-+     * the GLX protocol code uses the minimum version supported on all screens.
-+     */
-+    /*@{*/
-+    unsigned GLXmajor;
-+    unsigned GLXminor;
-+    /*@}*/
-+
-     Bool (*CloseScreen)(int index, ScreenPtr pScreen);
-     Bool (*DestroyWindow)(WindowPtr pWindow);
- };
-diff --git a/glx/glxserver.h b/glx/glxserver.h
-index 4aa8c2e..80f1b28 100644
---- a/glx/glxserver.h
-+++ b/glx/glxserver.h
-@@ -248,4 +248,7 @@ extern int __glXImageSize(GLenum format, GLenum type,
-     GLint imageHeight, GLint rowLength, GLint skipImages, GLint skipRows,
-     GLint alignment);
- 
-+extern unsigned glxMajorVersion;
-+extern unsigned glxMinorVersion;
-+
- #endif /* !__GLX_server_h__ */
-diff --git a/glx/indirect_texture_compression.c b/glx/indirect_texture_compression.c
-index 25c6eb3..5f44d7b 100644
---- a/glx/indirect_texture_compression.c
-+++ b/glx/indirect_texture_compression.c
-@@ -52,7 +52,7 @@ int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *p
- 	const GLenum target = *(GLenum *)(pc + 0);
- 	const GLint  level  = *(GLint  *)(pc + 4);
- 	GLint compsize = 0;
--	char *answer, answerBuffer[200];
-+	char *answer = NULL, answerBuffer[200];
- 
- 	CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize));
- 
-@@ -92,7 +92,7 @@ int __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyt
- 	const GLenum target = (GLenum) bswap_32( *(int *)(pc + 0) );
- 	const GLint  level =  (GLint ) bswap_32( *(int *)(pc + 4) );
- 	GLint compsize = 0;
--	char *answer, answerBuffer[200];
-+	char *answer = NULL, answerBuffer[200];
- 
- 	CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize));
- 
-diff --git a/include/protocol-versions.h b/include/protocol-versions.h
-index da9770c..d688c66 100644
---- a/include/protocol-versions.h
-+++ b/include/protocol-versions.h
-@@ -61,7 +61,7 @@
- 
- /* GLX */
- #define SERVER_GLX_MAJOR_VERSION		1
--#define SERVER_GLX_MINOR_VERSION		2
-+#define SERVER_GLX_MINOR_VERSION		4
- 
- /* Xinerama */
- #define SERVER_PANORAMIX_MAJOR_VERSION          1
--- 
-1.6.5.rc2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.0-randr-gamma-restore.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.0-randr-gamma-restore.patch
deleted file mode 100644
index 81e025f..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.0-randr-gamma-restore.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From 18d2bd8cb513a0436739916620532247f13dbf03 Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Thu, 8 Oct 2009 15:25:24 -0400
-Subject: [PATCH] randr gamma reload hack
-
----
- hw/xfree86/loader/sdksyms.c    |    4 ++++
- hw/xfree86/modes/xf86RandR12.c |    6 ++++++
- 2 files changed, 10 insertions(+), 0 deletions(-)
-
-diff --git a/hw/xfree86/loader/sdksyms.c b/hw/xfree86/loader/sdksyms.c
-index 12af6b7..656d07b 100644
---- a/hw/xfree86/loader/sdksyms.c
-+++ b/hw/xfree86/loader/sdksyms.c
-@@ -1056,6 +1056,8 @@ _X_HIDDEN void *xorg_symbols[] = {
-     (void *) &noXFree86VidModeExtension,
-     (void *) &noXFixesExtension,
-     (void *) &noPanoramiXExtension,
-+    (void *) &noSELinuxExtension,
-+    (void *) &selinuxEnforcingState,
-     (void *) &noXvExtension,
-     (void *) &noDRI2Extension,
-     (void *) &defaultTextFont,
-@@ -1069,6 +1071,7 @@ _X_HIDDEN void *xorg_symbols[] = {
-     (void *) &defaultScreenSaverBlanking,
-     (void *) &defaultScreenSaverAllowExposures,
-     (void *) &display,
-+    (void *) &displayfd,
-     (void *) &defaultBackingStore,
-     (void *) &disableBackingStore,
-     (void *) &enableBackingStore,
-@@ -1078,6 +1081,7 @@ _X_HIDDEN void *xorg_symbols[] = {
-     (void *) &maxBigRequestSize,
-     (void *) &party_like_its_1989,
-     (void *) &whiteRoot,
-+    (void *) &bgNoneRoot,
-     (void *) &CoreDump,
-     (void *) &DontPropagateMasks,
-     (void *) &screenIsSaved,
-diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
-index 6ea9d26..41bac11 100644
---- a/hw/xfree86/modes/xf86RandR12.c
-+++ b/hw/xfree86/modes/xf86RandR12.c
-@@ -1746,12 +1746,18 @@ xf86RandR12EnterVT (int screen_index, int flags)
- {
-     ScreenPtr        pScreen = screenInfo.screens[screen_index];
-     XF86RandRInfoPtr randrp  = XF86RANDRINFO(pScreen);
-+    rrScrPrivPtr     rp = rrGetScrPriv(pScreen);
- 
-     if (randrp->orig_EnterVT) {
- 	if (!randrp->orig_EnterVT (screen_index, flags))
- 	    return FALSE;
-     }
- 
-+    /* reload gamma */
-+    int i;
-+    for (i = 0; i < rp->numCrtcs; i++)
-+	xf86RandR12CrtcSetGamma(pScreen, rp->crtcs[i]);
-+
-     return RRGetInfo (pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
- }
- 
--- 
-1.6.5.rc2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-gamma-kdm-fix.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-gamma-kdm-fix.patch
deleted file mode 100644
index c62837e..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-gamma-kdm-fix.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From acc64ce5be7383c09e88a23aab06ebc2403f2ca3 Mon Sep 17 00:00:00 2001
-From: Bill Nottingham <notting@redhat.com>
-Date: Fri, 6 Nov 2009 10:32:27 +1000
-Subject: [PATCH] fix KDM gamma issue on vt switch
-
----
- hw/xfree86/modes/xf86RandR12.c |    4 ++++
- 1 files changed, 4 insertions(+), 0 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
-index 6ea9d26..ece12b9 100644
---- a/hw/xfree86/modes/xf86RandR12.c
-+++ b/hw/xfree86/modes/xf86RandR12.c
-@@ -1761,6 +1761,7 @@ xf86RandR12Init12 (ScreenPtr pScreen)
-     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
-     rrScrPrivPtr	rp = rrGetScrPriv(pScreen);
-     XF86RandRInfoPtr	randrp  = XF86RANDRINFO(pScreen);
-+    int i;
- 
-     rp->rrGetInfo = xf86RandR12GetInfo12;
-     rp->rrScreenSetSize = xf86RandR12ScreenSetSize;
-@@ -1790,6 +1791,9 @@ xf86RandR12Init12 (ScreenPtr pScreen)
-      */
-     if (!xf86RandR12SetInfo12 (pScreen))
- 	return FALSE;
-+    for (i = 0; i < rp->numCrtcs; i++) {
-+	xf86RandR12CrtcGetGamma(pScreen, rp->crtcs[i]);
-+    }
-     return TRUE;
- }
- 
--- 
-1.6.5.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-glx14-swrast.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-glx14-swrast.patch
deleted file mode 100644
index 2c51802..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-glx14-swrast.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 25a0107768c9f25e8edc5e423ca8b1d0813f2d04 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 24 Nov 2009 13:38:46 -0500
-Subject: [PATCH] Enable GLX 1.4 for swrast
-
----
- glx/glxdriswrast.c |    3 +++
- 1 files changed, 3 insertions(+), 0 deletions(-)
-
-diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
-index 44f658f..20f9f90 100644
---- a/glx/glxdriswrast.c
-+++ b/glx/glxdriswrast.c
-@@ -510,6 +510,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
- 
-     __glXScreenInit(&screen->base, pScreen);
- 
-+    screen->base.GLXmajor = 1;
-+    screen->base.GLXminor = 4;
-+
-     LogMessage(X_INFO,
- 	       "AIGLX: Loaded and initialized %s\n", filename);
- 
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-libcrypto.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-libcrypto.patch
deleted file mode 100644
index c271855..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-libcrypto.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 8875112f5c57ec5d575e717c5638fbc919145efb Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 16 Nov 2009 18:01:26 -0500
-Subject: [PATCH] configure: Only link against libcrypto
-
-openssl.pc will link you against libssl, which we don't need, and which
-brings in another seven libraries we also don't need.  This is still
-bogus, we're really only trying to get a SHA1 routine, we could link it
-statically and be even better off.
----
- configure.ac |    6 ------
- 1 files changed, 0 insertions(+), 6 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index f69f97e..254d33d 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1297,14 +1297,8 @@ if test "x$SHA1_LIB" = "x" ; then
- fi
- 
- if test "x$SHA1_LIB" = "x" ; then
--  PKG_CHECK_EXISTS([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
--                    [HAVE_OPENSSL_PKC=no])
--  if test "x$HAVE_OPENSSL_PKC" = xyes; then
--    REQUIRED_LIBS="$REQUIRED_LIBS openssl"
--  else
-     AC_CHECK_LIB([crypto], [SHA1_Init], [SHA1_LIB="-lcrypto"],
-                  [AC_MSG_ERROR([OpenSSL must be installed in order to build the X server.])])
--  fi
- fi
- 
- PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-multilib.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-multilib.patch
deleted file mode 100644
index 6435999..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.1-multilib.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From 6d9585ba6a5784328de479c6b648d7b7d6cec64c Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Thu, 29 Oct 2009 19:04:10 -0400
-Subject: [PATCH] multilib fix for -devel subpackage
-
----
- include/colormapst.h     |    4 ++--
- include/xorg-server.h.in |    7 ++++---
- 2 files changed, 6 insertions(+), 5 deletions(-)
-
-diff --git a/include/colormapst.h b/include/colormapst.h
-index f1fc8eb..274cd65 100644
---- a/include/colormapst.h
-+++ b/include/colormapst.h
-@@ -103,12 +103,12 @@ typedef struct _ColormapRec
- {
-     VisualPtr	pVisual;
-     short	class;		/* PseudoColor or DirectColor */
--#if defined(_XSERVER64)
-+#ifdef __LP64__
-     short	pad0;
-     XID		pad1;
- #endif
-     XID		mid;		/* client's name for colormap */
--#if defined(_XSERVER64) && (X_BYTE_ORDER == X_LITTLE_ENDIAN)
-+#if defined(__LP64__) && (X_BYTE_ORDER == X_LITTLE_ENDIAN)
-     XID		pad2;
- #endif
-     ScreenPtr	pScreen;	/* screen map is associated with */
-diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
-index 76cab16..081b8f3 100644
---- a/include/xorg-server.h.in
-+++ b/include/xorg-server.h.in
-@@ -157,9 +157,6 @@
- /* Name of X server */
- #undef __XSERVERNAME__
- 
--/* Define to 1 if unsigned long is 64 bits. */
--#undef _XSERVER64
--
- /* Building vgahw module */
- #undef WITH_VGAHW
- 
-@@ -187,4 +184,8 @@
- /* X Access Control Extension */
- #undef XACE
- 
-+#ifdef __LP64__
-+#define _XSERVER64 1
-+#endif
-+
- #endif /* _XORG_SERVER_H_ */
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.3-no-free-on-abort.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.3-no-free-on-abort.patch
deleted file mode 100644
index 6630d05..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.3-no-free-on-abort.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From 3bf24ed9e1c81116c851ba2408b9c37a51a5dc62 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Thu, 7 Jan 2010 11:33:43 -0500
-Subject: [PATCH] hack to make abnormal exit not call free()
-
----
- dix/globals.c  |    2 ++
- include/misc.h |    2 ++
- os/log.c       |    1 +
- os/utils.c     |    3 +++
- 4 files changed, 8 insertions(+), 0 deletions(-)
-
-diff --git a/dix/globals.c b/dix/globals.c
-index c1e64d3..a1eac08 100644
---- a/dix/globals.c
-+++ b/dix/globals.c
-@@ -61,6 +61,8 @@ SOFTWARE.
- #include "dixstruct.h"
- #include "os.h"
- 
-+Bool omg_wtf_aborting = FALSE;
-+
- ScreenInfo screenInfo;
- KeybdCtrl defaultKeyboardControl = {
- 	DEFAULT_KEYBOARD_CLICK,
-diff --git a/include/misc.h b/include/misc.h
-index 877c682..2b3cf2e 100644
---- a/include/misc.h
-+++ b/include/misc.h
-@@ -286,4 +286,6 @@ typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
- extern _X_EXPORT unsigned long globalSerialNumber;
- extern _X_EXPORT unsigned long serverGeneration;
- 
-+extern _X_EXPORT Bool omg_wtf_aborting;
-+
- #endif /* MISC_H */
-diff --git a/os/log.c b/os/log.c
-index 8108890..79b86f3 100644
---- a/os/log.c
-+++ b/os/log.c
-@@ -395,6 +395,7 @@ void AbortServer(void) __attribute__((noreturn));
- void
- AbortServer(void)
- {
-+    omg_wtf_aborting = 1;
- #ifdef XF86BIGFONT
-     XF86BigfontCleanup();
- #endif
-diff --git a/os/utils.c b/os/utils.c
-index 1d1712d..04177aa 100644
---- a/os/utils.c
-+++ b/os/utils.c
-@@ -1164,6 +1164,9 @@ XNFrealloc(pointer ptr, unsigned long amount)
- void
- Xfree(pointer ptr)
- {
-+    if (omg_wtf_aborting)
-+	return;
-+
-     if (ptr)
- 	free(ptr); 
- }
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-dpms-timeouts.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-dpms-timeouts.patch
deleted file mode 100644
index 80765e2..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-dpms-timeouts.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 4704b4d3d60bc40dcb9fbd050ca1ffdf42cbeaf9 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Fri, 12 Feb 2010 14:34:28 -0500
-Subject: [PATCH] Inherit the DPMS timeouts from -s
-
----
- dix/main.c |    6 +++---
- 1 files changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/dix/main.c b/dix/main.c
-index f96245a..d887f5c 100644
---- a/dix/main.c
-+++ b/dix/main.c
-@@ -159,9 +159,9 @@ int main(int argc, char *argv[], char *envp[])
- 	ScreenSaverBlanking = defaultScreenSaverBlanking;
- 	ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
- #ifdef DPMSExtension
--	DPMSStandbyTime = DEFAULT_SCREEN_SAVER_TIME;
--	DPMSSuspendTime = DEFAULT_SCREEN_SAVER_TIME;
--	DPMSOffTime = DEFAULT_SCREEN_SAVER_TIME;
-+	DPMSStandbyTime = defaultScreenSaverTime;
-+	DPMSSuspendTime = defaultScreenSaverTime;
-+	DPMSOffTime = defaultScreenSaverTime;
- 	DPMSEnabled = TRUE;
- 	DPMSPowerLevel = 0;
- #endif
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-qxl-autoconfig.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-qxl-autoconfig.patch
deleted file mode 100644
index 3d99c60..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-qxl-autoconfig.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 4b24f52e58824442e534ea97a137ecac819a9c6f Mon Sep 17 00:00:00 2001
-From: Soren Sandmann <ssp@redhat.com>
-Date: Tue, 9 Feb 2010 11:25:29 -0500
-Subject: [PATCH] Add Red Hat's PCI ID and make it point to the QXL driver.
-
----
- hw/xfree86/common/xf86AutoConfig.c |    3 ++-
- 1 files changed, 2 insertions(+), 1 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
-index d7c0399..e3e605e 100644
---- a/hw/xfree86/common/xf86AutoConfig.c
-+++ b/hw/xfree86/common/xf86AutoConfig.c
-@@ -210,7 +210,8 @@ videoPtrToDriverList(struct pci_device *dev,
- 	    }
- 	    break;
- 	case 0x1106:		    driverList[0] = "openchrome"; break;
--	case 0x1163:		    driverList[0] = "rendition"; break;
-+        case 0x1b36:                driverList[0] = "qxl"; break;
-+        case 0x1163:		    driverList[0] = "rendition"; break;
- 	case 0x5333:
- 	    switch (dev->device_id)
- 	    {
--- 
-1.6.6
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-z-now.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-z-now.patch
deleted file mode 100644
index f81367e..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.4-z-now.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 4de049b00ebb12864dc59764afd907fc7d28ba01 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Wed, 13 Jan 2010 11:19:12 -0500
-Subject: [PATCH] Link Xorg with -z now
-
----
- hw/xfree86/Makefile.am |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
-index 914e11f..20da8c4 100644
---- a/hw/xfree86/Makefile.am
-+++ b/hw/xfree86/Makefile.am
-@@ -74,7 +74,7 @@ DISTCLEANFILES = libxorg.c xorg.c
- Xorg_DEPENDENCIES = libxorg.la
- Xorg_LDADD = $(MAIN_LIB) libxorg.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS)
- 
--Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-+Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) -Wl,-z,now
- 
- BUILT_SOURCES = xorg.conf.example
- DISTCLEANFILES += xorg.conf.example xorg.conf.example.pre
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-default-modes.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-default-modes.patch
deleted file mode 100644
index 495765e..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-default-modes.patch
+++ /dev/null
@@ -1,367 +0,0 @@
-From 9edbc4bd615311f4eefe13a54b7c7b7e34b3645a Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 26 Apr 2010 14:57:23 -0400
-Subject: [PATCH] modes: Combine xf86DefaultModes and DMTModes
-
-DMTModes is what xf86DefaultModes was always meant to be.  Smash the two
-together, leaving aliases in place for the old names to make it easy on
-external modules.
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- hw/xfree86/common/Makefile.am    |   10 +---
- hw/xfree86/common/extramodes     |   27 ---------
- hw/xfree86/common/modeline2c.awk |   93 -------------------------------
- hw/xfree86/common/vesamodes      |  111 --------------------------------------
- hw/xfree86/common/xf86Config.c   |    3 +-
- hw/xfree86/common/xf86Priv.h     |    2 +-
- hw/xfree86/modes/xf86EdidModes.c |    5 ++-
- hw/xfree86/modes/xf86Modes.c     |    2 +-
- 8 files changed, 9 insertions(+), 244 deletions(-)
- delete mode 100644 hw/xfree86/common/extramodes
- delete mode 100644 hw/xfree86/common/modeline2c.awk
- delete mode 100644 hw/xfree86/common/vesamodes
-
-diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
-index ad27210..9bf0c73 100644
---- a/hw/xfree86/common/Makefile.am
-+++ b/hw/xfree86/common/Makefile.am
-@@ -23,14 +23,6 @@ RANDRSOURCES = xf86RandR.c
- 
- BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
- 
--MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
--
--xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
--	cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@
--	echo >> $@
--
--BUILT_SOURCES = xf86DefModeSet.c
--
- AM_LDFLAGS = -r
- libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
-                       xf86Cursor.c $(DGASOURCES) xf86DPMS.c \
-@@ -40,7 +32,7 @@ libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
-                       xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
-                       xf86Mode.c xorgHelper.c \
-                       $(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES)
--nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h
-+nodist_libcommon_la_SOURCES = xf86Build.h
- 
- INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
- 	   -I$(srcdir)/../loader -I$(srcdir)/../parser \
-diff --git a/hw/xfree86/common/extramodes b/hw/xfree86/common/extramodes
-deleted file mode 100644
-index 4505026..0000000
---- a/hw/xfree86/common/extramodes
-+++ /dev/null
-@@ -1,27 +0,0 @@
--//
--// Extra modes to include as default modes in the X server.
--//
--// $XFree86: xc/programs/Xserver/hw/xfree86/etc/extramodes,v 1.5 2002/06/05 19:43:05 dawes Exp $
--//
--
--# 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz
--ModeLine "832x624" 57.284 832  864  928 1152  624  625  628  667 -Hsync -Vsync
--
--# 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz
--ModeLine "1400x1050" 122.0 1400 1488 1640 1880   1050 1052 1064 1082 +hsync +vsync
--
--# 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz
--ModeLine "1400x1050" 155.8 1400 1464 1784 1912   1050 1052 1064 1090 +hsync +vsync
--
--# 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz
--Modeline "1920x1440" 341.35  1920 2072 2288 2656  1440 1441 1444 1512 -hsync +vsync
--
--# 2048x1536 @ 60Hz (VESA GTF) hsync: 95.3kHz
--Modeline "2048x1536" 266.95  2048 2200 2424 2800  1536 1537 1540 1589 -hsync +vsync
--
--# 2048x1536 @ 75Hz (VESA GTF) hsync: 120.2kHz
--Modeline "2048x1536" 340.48  2048 2216 2440 2832  1536 1537 1540 1603 -hsync +vsync
--
--# 2048x1536 @ 85Hz (VESA GTF) hsync: 137.0kHz
--Modeline "2048x1536" 388.04  2048 2216 2440 2832  1536 1537 1540 1612 -hsync +vsync
--
-diff --git a/hw/xfree86/common/modeline2c.awk b/hw/xfree86/common/modeline2c.awk
-deleted file mode 100644
-index 038e7e9..0000000
---- a/hw/xfree86/common/modeline2c.awk
-+++ /dev/null
-@@ -1,93 +0,0 @@
--#!/usr/bin/awk -f
--#
--# Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
--# All rights reserved.
--#
--# Based on Perl script by Dirk Hohndel.
--#
--# Redistribution and use in source and binary forms, with or without
--# modification, are permitted provided that the following conditions
--# are met:
--#
--# 1. Redistributions of source code must retain the above copyright
--#    notice, this list of conditions and the following disclaimer.
--# 2. Redistributions in binary form must reproduce the above copyright
--#    notice, this list of conditions and the following disclaimer in
--#    the documentation and/or other materials provided with the
--#    distribution.
--#
--# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
--# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
--# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
--# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
--# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
--# INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
--# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
--# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
--# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
--# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
--# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
--# SUCH DAMAGE.
--#
--# Usage: modeline2c.awk < modefile > xf86DefModeSet.c
--#
--
--BEGIN {
--	flagsdict[""] = "0"
--
--	flagsdict["+hsync +vsync"] = "V_PHSYNC | V_PVSYNC"
--	flagsdict["+hsync -vsync"] = "V_PHSYNC | V_NVSYNC"
--	flagsdict["-hsync +vsync"] = "V_NHSYNC | V_PVSYNC"
--	flagsdict["-hsync -vsync"] = "V_NHSYNC | V_NVSYNC"
--	flagsdict["+hsync +vsync interlace"] = "V_PHSYNC | V_PVSYNC | V_INTERLACE"
--	flagsdict["+hsync -vsync interlace"] = "V_PHSYNC | V_NVSYNC | V_INTERLACE"
--	flagsdict["-hsync +vsync interlace"] = "V_NHSYNC | V_PVSYNC | V_INTERLACE"
--	flagsdict["-hsync -vsync interlace"] = "V_NHSYNC | V_NVSYNC | V_INTERLACE"
--
--	print "/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at"
--	print " * modeline2c.awk */"
--	print ""
--	print "/*"
--	print " * Author: Joerg Sonnenberger <joerg@NetBSD.org>"
--	print " * Based on Perl script from Dirk Hohndel <hohndel@XFree86.Org>"
--	print " */"
--	print ""
--	print "#ifdef HAVE_XORG_CONFIG_H"
--	print "#include <xorg-config.h>"
--	print "#endif"
--	print ""
--	print "#include \"xf86.h\""
--	print "#include \"xf86Config.h\""
--	print "#include \"xf86Priv.h\""
--	print "#include \"xf86_OSlib.h\""
--	print ""
--	print "#include \"globals.h\""
--	print ""
--	print "#define MODEPREFIX NULL, NULL, NULL, MODE_OK, M_T_DEFAULT"
--	print "#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0"
--	print ""
--	print "const DisplayModeRec xf86DefaultModes [] = {"
--
--	modeline = "\t{MODEPREFIX,%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s, MODESUFFIX},\n"
--	modeline_data = "^[a-zA-Z]+[ \t]+[^ \t]+[ \t0-9.]+"
--}
--
--/^[mM][oO][dD][eE][lL][iI][nN][eE]/ {
--	flags = $0
--	gsub(modeline_data, "", flags)
--	flags = tolower(flags)
--	printf(modeline, $3 * 1000, $4, $5, $6, $7,
--	       $8, $9, $10, $11, flagsdict[flags])
--	# Half-width double scanned modes
--	printf(modeline, $3 * 500, $4/2, $5/2, $6/2, $7/2,
--	       $8/2, $9/2, $10/2, $11/2, flagsdict[flags] " | V_DBLSCAN")
--}
--
--/^#/ {
--	print "/*" substr($0, 2) " */"
--}
--
--END {
--	print "};"
--	printf "const int xf86NumDefaultModes = sizeof(xf86DefaultModes) / sizeof(DisplayModeRec);"
--}
-diff --git a/hw/xfree86/common/vesamodes b/hw/xfree86/common/vesamodes
-deleted file mode 100644
-index 2bc8862..0000000
---- a/hw/xfree86/common/vesamodes
-+++ /dev/null
-@@ -1,111 +0,0 @@
--//
--//  Default modes distilled from
--//      "VESA and Industry Standards and Guide for Computer Display Monitor
--//       Timing", version 1.0, revision 0.8, adopted September 17, 1998.
--//  
--//  $XFree86: xc/programs/Xserver/hw/xfree86/etc/vesamodes,v 1.3 1999/11/16 03:28:03 tsi Exp $
--
--
--# 640x350 @ 85Hz (VESA) hsync: 37.9kHz
--ModeLine "640x350"    31.5  640  672  736  832    350  382  385  445 +hsync -vsync
--
--# 640x400 @ 85Hz (VESA) hsync: 37.9kHz
--ModeLine "640x400"    31.5  640  672  736  832    400  401  404  445 -hsync +vsync
--
--# 720x400 @ 85Hz (VESA) hsync: 37.9kHz
--ModeLine "720x400"    35.5  720  756  828  936    400  401  404  446 -hsync +vsync
--
--# 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz
--ModeLine "640x480"    25.175 640  656  752  800    480  490  492  525 -hsync -vsync
--
--# 640x480 @ 72Hz (VESA) hsync: 37.9kHz
--ModeLine "640x480"    31.5  640  664  704  832    480  489  492  520 -hsync -vsync
--
--# 640x480 @ 75Hz (VESA) hsync: 37.5kHz
--ModeLine "640x480"    31.5  640  656  720  840    480  481  484  500 -hsync -vsync
--
--# 640x480 @ 85Hz (VESA) hsync: 43.3kHz
--ModeLine "640x480"    36.0  640  696  752  832    480  481  484  509 -hsync -vsync
--
--# 800x600 @ 56Hz (VESA) hsync: 35.2kHz
--ModeLine "800x600"    36.0  800  824  896 1024    600  601  603  625 +hsync +vsync
--
--# 800x600 @ 60Hz (VESA) hsync: 37.9kHz
--ModeLine "800x600"    40.0  800  840  968 1056    600  601  605  628 +hsync +vsync
--
--# 800x600 @ 72Hz (VESA) hsync: 48.1kHz
--ModeLine "800x600"    50.0  800  856  976 1040    600  637  643  666 +hsync +vsync
--
--# 800x600 @ 75Hz (VESA) hsync: 46.9kHz
--ModeLine "800x600"    49.5  800  816  896 1056    600  601  604  625 +hsync +vsync
--
--# 800x600 @ 85Hz (VESA) hsync: 53.7kHz
--ModeLine "800x600"    56.3  800  832  896 1048    600  601  604  631 +hsync +vsync
--
--# 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz
--ModeLine "1024x768"   44.9 1024 1032 1208 1264    768  768  776  817 +hsync +vsync Interlace
--
--# 1024x768 @ 60Hz (VESA) hsync: 48.4kHz
--ModeLine "1024x768"   65.0 1024 1048 1184 1344    768  771  777  806 -hsync -vsync
--
--# 1024x768 @ 70Hz (VESA) hsync: 56.5kHz
--ModeLine "1024x768"   75.0 1024 1048 1184 1328    768  771  777  806 -hsync -vsync
--
--# 1024x768 @ 75Hz (VESA) hsync: 60.0kHz
--ModeLine "1024x768"   78.75 1024 1040 1136 1312    768  769  772  800 +hsync +vsync
--
--# 1024x768 @ 85Hz (VESA) hsync: 68.7kHz
--ModeLine "1024x768"   94.5 1024 1072 1168 1376    768  769  772  808 +hsync +vsync
--
--# 1152x864 @ 75Hz (VESA) hsync: 67.5kHz
--ModeLine "1152x864"  108.0 1152 1216 1344 1600    864  865  868  900 +hsync +vsync
--
--# 1280x960 @ 60Hz (VESA) hsync: 60.0kHz
--ModeLine "1280x960"  108.0 1280 1376 1488 1800    960  961  964 1000 +hsync +vsync
--
--# 1280x960 @ 85Hz (VESA) hsync: 85.9kHz
--ModeLine "1280x960"  148.5 1280 1344 1504 1728    960  961  964 1011 +hsync +vsync
--
--# 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz
--ModeLine "1280x1024" 108.0 1280 1328 1440 1688   1024 1025 1028 1066 +hsync +vsync
--
--# 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz
--ModeLine "1280x1024" 135.0 1280 1296 1440 1688   1024 1025 1028 1066 +hsync +vsync
--
--# 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz
--ModeLine "1280x1024" 157.5 1280 1344 1504 1728   1024 1025 1028 1072 +hsync +vsync
--
--# 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz
--ModeLine "1600x1200" 162.0 1600 1664 1856 2160   1200 1201 1204 1250 +hsync +vsync
--
--# 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz
--ModeLine "1600x1200" 175.5 1600 1664 1856 2160   1200 1201 1204 1250 +hsync +vsync
--
--# 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz
--ModeLine "1600x1200" 189.0 1600 1664 1856 2160   1200 1201 1204 1250 +hsync +vsync
--
--# 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz
--ModeLine "1600x1200" 202.5 1600 1664 1856 2160   1200 1201 1204 1250 +hsync +vsync
--
--# 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz
--ModeLine "1600x1200" 229.5 1600 1664 1856 2160   1200 1201 1204 1250 +hsync +vsync
--
--# 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz
--ModeLine "1792x1344" 204.8 1792 1920 2120 2448   1344 1345 1348 1394 -hsync +vsync
--
--# 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz
--ModeLine "1792x1344" 261.0 1792 1888 2104 2456   1344 1345 1348 1417 -hsync +vsync
--
--# 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz
--ModeLine "1856x1392" 218.3 1856 1952 2176 2528   1392 1393 1396 1439 -hsync +vsync
--
--# 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz
--ModeLine "1856x1392" 288.0 1856 1984 2208 2560   1392 1393 1396 1500 -hsync +vsync
--
--# 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz
--ModeLine "1920x1440" 234.0 1920 2048 2256 2600   1440 1441 1444 1500 -hsync +vsync
--
--# 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz
--ModeLine "1920x1440" 297.0 1920 2064 2288 2640   1440 1441 1444 1500 -hsync +vsync
--
--
-diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
-index 6fbf613..d3dcce2 100644
---- a/hw/xfree86/common/xf86Config.c
-+++ b/hw/xfree86/common/xf86Config.c
-@@ -2367,7 +2367,8 @@ addDefaultModes(MonPtr monitorp)
- 
-     for (i = 0; i < xf86NumDefaultModes; i++)
-     {
--	mode = xf86DuplicateMode(&xf86DefaultModes[i]);
-+	mode = xf86DuplicateMode(&DMTModes[i]);
-+	mode->type = M_T_DEFAULT;
- 	if (!modeIsPresent(mode, monitorp))
- 	{
- 	    monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
-diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
-index 3bb1571..0ba7ffa 100644
---- a/hw/xfree86/common/xf86Priv.h
-+++ b/hw/xfree86/common/xf86Priv.h
-@@ -129,7 +129,7 @@ extern _X_EXPORT Bool xf86PathIsSafe(const char *path);
- 
- /* xf86DefaultModes */
- 
--extern _X_EXPORT const DisplayModeRec xf86DefaultModes[];
-+extern _X_EXPORT const DisplayModeRec DMTModes[];
- extern _X_EXPORT const int xf86NumDefaultModes;
- 
- /* xf86Configure.c */
-diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
-index b057d7d..4da0da5 100644
---- a/hw/xfree86/modes/xf86EdidModes.c
-+++ b/hw/xfree86/modes/xf86EdidModes.c
-@@ -425,6 +425,9 @@ const DisplayModeRec DMTModes[] = {
-     { MODEPREFIX,   505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */
-     { MODEPREFIX,   552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */
- };
-+/* name compat */
-+extern _X_EXPORT const DisplayModeRec xf86DefaultModes[] __attribute__((alias("DMTModes")));
-+const int xf86NumDefaultModes = sizeof(DMTModes) / sizeof(DisplayModeRec);
- 
- #define LEVEL_DMT 0
- #define LEVEL_GTF 1
-@@ -459,7 +462,7 @@ FindDMTMode(int hsize, int vsize, int refresh, Bool rb)
-     int i;
-     const DisplayModeRec *ret;
- 
--    for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) {
-+    for (i = 0; i < xf86NumDefaultModes; i++) {
- 	ret = &DMTModes[i];
- 
- 	if (!rb && xf86ModeIsReduced(ret))
-diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
-index 862a473..2935405 100644
---- a/hw/xfree86/modes/xf86Modes.c
-+++ b/hw/xfree86/modes/xf86Modes.c
-@@ -682,7 +682,7 @@ xf86GetDefaultModes (void)
- 
-     for (i = 0; i < xf86NumDefaultModes; i++)
-     {
--	const DisplayModeRec	*defMode = &xf86DefaultModes[i];
-+	const DisplayModeRec	*defMode = &DMTModes[i];
- 	
- 	mode = xf86DuplicateMode(defMode);
- 	head = xf86ModesAdd(head, mode);
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-deviceevent-coordinates-xinerama.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-deviceevent-coordinates-xinerama.patch
deleted file mode 100644
index 6dc9a01..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-deviceevent-coordinates-xinerama.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 21ed660f30a3f96c787ab00a16499e0fb034b2ad Mon Sep 17 00:00:00 2001
-From: Chris Humbert <freedesktop@mahadri.com>
-Date: Fri, 7 May 2010 17:02:43 +1000
-Subject: [PATCH] dix: make DeviceEvent coordinates signed for Xinerama. #24986
-
-With Xinerama enabled, event coordinates are relative to Screen 0, so
-they can be negative.  The new DeviceEvent's coordinates are of type
-uint16_t, making screens above and to the left of Screen 0 unusable.
-
-X.Org Bug 24986 <https://bugs.freedesktop.org/show_bug.cgi?id=24986>
-
-Signed-off-by: Chris Humbert <freedesktop@mahadri.com>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-Signed-off-by: Keith Packard <keithp@keithp.com>
----
- include/eventstr.h |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/include/eventstr.h b/include/eventstr.h
-index 79685c1..433227e 100644
---- a/include/eventstr.h
-+++ b/include/eventstr.h
-@@ -91,9 +91,9 @@ struct _DeviceEvent
-         uint32_t button;  /**< Button number */
-         uint32_t key;     /**< Key code */
-     } detail;
--    uint16_t root_x;      /**< Pos relative to root window in integral data */
-+    int16_t root_x;       /**< Pos relative to root window in integral data */
-     float root_x_frac;    /**< Pos relative to root window in frac part */
--    uint16_t root_y;      /**< Pos relative to root window in integral part */
-+    int16_t root_y;       /**< Pos relative to root window in integral part */
-     float root_y_frac;    /**< Pos relative to root window in frac part */
-     uint8_t    buttons[(MAX_BUTTONS + 7)/8]; /**< Button mask */
-     struct {
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-export-dix-functions.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-export-dix-functions.patch
deleted file mode 100644
index 4bfedfd..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-export-dix-functions.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 7bdea0bb8f38dba2d214482301de981c3260450d Mon Sep 17 00:00:00 2001
-From: Adam Tkac <atkac@redhat.com>
-Date: Mon, 22 Mar 2010 14:52:29 +0100
-Subject: [PATCH] dix: Export AllocDevicePair GetPointerEvents, GetKeyboardEvents and generate_modkeymap functions from Xorg.
-
-Those functions are used by TigerVNC libvnc.so module which doesn't
-use standard XInput infrastructure but uses same functions like,
-for example, XTest devices.
-
-Signed-off-by: Adam Tkac <atkac@redhat.com>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- include/input.h |    8 ++++----
- 1 files changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/include/input.h b/include/input.h
-index 8561308..63f981e 100644
---- a/include/input.h
-+++ b/include/input.h
-@@ -432,7 +432,7 @@ extern void CreateClassesChangedEvent(EventListPtr event,
-                                       DeviceIntPtr master,
-                                       DeviceIntPtr slave,
-                                       int type);
--extern int GetPointerEvents(
-+extern _X_EXPORT int GetPointerEvents(
-     EventListPtr events,
-     DeviceIntPtr pDev,
-     int type,
-@@ -442,7 +442,7 @@ extern int GetPointerEvents(
-     int num_valuators,
-     int *valuators);
- 
--extern int GetKeyboardEvents(
-+extern _X_EXPORT int GetKeyboardEvents(
-     EventListPtr events,
-     DeviceIntPtr pDev,
-     int type,
-@@ -493,7 +493,7 @@ extern int AttachDevice(ClientPtr client,
- extern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd);
- extern DeviceIntPtr GetMaster(DeviceIntPtr dev, int type);
- 
--extern int AllocDevicePair(ClientPtr client,
-+extern _X_EXPORT int AllocDevicePair(ClientPtr client,
-                              char* name,
-                              DeviceIntPtr* ptr,
-                              DeviceIntPtr* keybd,
-@@ -505,7 +505,7 @@ extern void DeepCopyDeviceClasses(DeviceIntPtr from,
-                                   DeviceChangedEvent *dce);
- 
- /* Helper functions. */
--extern int generate_modkeymap(ClientPtr client, DeviceIntPtr dev,
-+extern _X_EXPORT int generate_modkeymap(ClientPtr client, DeviceIntPtr dev,
-                               KeyCode **modkeymap, int *max_keys_per_mod);
- extern int change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *map,
-                          int max_keys_per_mod);
--- 
-1.6.6.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-export-more-dix-functions.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-export-more-dix-functions.patch
deleted file mode 100644
index 9592a95..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-export-more-dix-functions.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 6db7cc3d3f750bbb1c170f8fe538e9fb75bc5b34 Mon Sep 17 00:00:00 2001
-From: Adam Tkac <atkac@redhat.com>
-Date: Wed, 14 Apr 2010 12:16:26 +0200
-Subject: [PATCH] Export XkbCopyDeviceKeymap from Xorg, it is needed by VNC.
-
-Signed-off-by: Adam Tkac <atkac@redhat.com>
----
- include/xkbsrv.h |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/include/xkbsrv.h b/include/xkbsrv.h
-index ebc7cdb..dc3142a 100644
---- a/include/xkbsrv.h
-+++ b/include/xkbsrv.h
-@@ -936,7 +936,7 @@ extern Bool XkbCopyKeymap(
-         XkbDescPtr              /* dst */,
-         XkbDescPtr              /* src */);
- 
--extern Bool XkbCopyDeviceKeymap(
-+extern _X_EXPORT Bool XkbCopyDeviceKeymap(
-         DeviceIntPtr            /* dst */,
-         DeviceIntPtr            /* src */);
- 
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-no-connected-outputs.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-no-connected-outputs.patch
deleted file mode 100644
index 3ee8542..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-no-connected-outputs.patch
+++ /dev/null
@@ -1,142 +0,0 @@
-From b27f93c6dbe0a6e416db2c65738e996c70a403c1 Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <airlied@redhat.com>
-Date: Thu, 6 May 2010 12:55:34 +1000
-Subject: [PATCH] xf86: allow for no outputs connected at startup operation.
-
-When nothing is connected at startup and we canGrow, allow the server to start with a 1024x768 framebuffer, and when the drivers send hotplug events this will expand to the correct size dynamically.
-
-Signed-off-by: Dave Airlie <airlied@redhat.com>
----
- hw/xfree86/modes/xf86Crtc.c |   66 ++++++++++++++++++++++++++++++------------
- 1 files changed, 47 insertions(+), 19 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
-index 571ffd0..99082ec 100644
---- a/hw/xfree86/modes/xf86Crtc.c
-+++ b/hw/xfree86/modes/xf86Crtc.c
-@@ -48,6 +48,8 @@
- 
- #include "xf86xv.h"
- 
-+#define NO_OUTPUT_DEFAULT_WIDTH 1024
-+#define NO_OUTPUT_DEFAULT_HEIGHT 768
- /*
-  * Initialize xf86CrtcConfig structure
-  */
-@@ -1946,7 +1948,7 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
- #endif
- }
- 
--static void
-+static Bool
- xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- 			  Bool *enabled)
- {
-@@ -1961,8 +1963,10 @@ xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- 		   "No outputs definitely connected, trying again...\n");
- 
- 	for (o = 0; o < config->num_output; o++)
--	    enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
-+	    any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
-     }
-+
-+    return any_enabled;
- }
- 
- static Bool
-@@ -2409,6 +2413,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
-     Bool		*enabled;
-     int			width, height;
-     int			i = scrn->scrnIndex;
-+    Bool have_outputs = TRUE;
-+    Bool ret;
- 
-     /* Set up the device options */
-     config->options = xnfalloc (sizeof (xf86DeviceOptions));
-@@ -2433,20 +2439,26 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
-     modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr));
-     enabled = xnfcalloc (config->num_output, sizeof (Bool));
-     
--    xf86CollectEnabledOutputs(scrn, config, enabled);
--
--    if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
--	xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
--    else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
--	xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
--    else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
--	xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
--    else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
--	xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
--    else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
--	xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
--    else
--	xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
-+    ret = xf86CollectEnabledOutputs(scrn, config, enabled);
-+    if (ret == FALSE && canGrow) {
-+	xf86DrvMsg(i, X_WARNING, "Unable to find connected outputs - setting %dx%d initial framebuffer\n",
-+		   NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT);
-+	have_outputs = FALSE;
-+    }
-+    else {
-+	if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
-+	    xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
-+	else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
-+	    xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
-+	else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
-+	    xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
-+	else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
-+	    xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
-+	else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
-+	    xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
-+	else
-+	    xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
-+    }
- 
-     for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- 	if (!modes[o])
-@@ -2479,7 +2491,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
-     /*
-      * Assign CRTCs to fit output configuration
-      */
--    if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
-+    if (have_outputs && !xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
-     {
- 	xfree (crtcs);
- 	xfree (modes);
-@@ -2541,6 +2553,13 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
- 	 */
- 	xf86DefaultScreenLimits (scrn, &width, &height, canGrow);
-     
-+	if (have_outputs == FALSE) {
-+	    if (width < NO_OUTPUT_DEFAULT_WIDTH && height < NO_OUTPUT_DEFAULT_HEIGHT) {
-+		width = NO_OUTPUT_DEFAULT_WIDTH;
-+		height = NO_OUTPUT_DEFAULT_HEIGHT;
-+	    }
-+	}
-+
- 	scrn->display->virtualX = width;
- 	scrn->display->virtualY = height;
-     }
-@@ -2566,8 +2585,17 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
- 			      width, height);
-     }
- 
--    /* Mirror output modes to scrn mode list */
--    xf86SetScrnInfoModes (scrn);
-+    if (have_outputs) {
-+	/* Mirror output modes to scrn mode list */
-+	xf86SetScrnInfoModes (scrn);
-+    } else {
-+	/* Clear any existing modes from scrn->modes */
-+	while (scrn->modes != NULL)
-+	    xf86DeleteMode(&scrn->modes, scrn->modes);
-+	scrn->modes = xf86ModesAdd(scrn->modes,
-+				   xf86CVTMode(width, height, 60, 0, 0));
-+    }
-+
-     
-     xfree (crtcs);
-     xfree (modes);
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-pointerkeys.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-pointerkeys.patch
deleted file mode 100644
index 79167a9..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-pointerkeys.patch
+++ /dev/null
@@ -1,255 +0,0 @@
-From 08cfb3f0e91a6055072b257f2701d3ec935c14ad Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Tue, 13 Apr 2010 14:41:07 +1000
-Subject: [PATCH 1/3] xkb: Post PointerKeys through the XTEST device.
-
-Posting an event through a master device may cause pointer jumps once
-lastSlave == master, caused by double scaling. To avoid this, post the fake
-event generated by XKB through the XTEST device instead.
-
-Fedora bug #560356 <https://bugzilla.redhat.com/560356>
-Tested-by: Andrew McNabb
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Daniel Stone <daniel@fooishbar.org>
----
- xkb/ddxDevBtn.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
-index 94630d1..3bee84b 100644
---- a/xkb/ddxDevBtn.c
-+++ b/xkb/ddxDevBtn.c
-@@ -51,13 +51,13 @@ XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
-     /* If dev is a slave device, and the SD is attached, do nothing. If we'd
-      * post through the attached master pointer we'd get duplicate events.
-      *
--     * if dev is a master keyboard, post through the master pointer.
-+     * if dev is a master keyboard, post through the XTEST device
-      *
-      * if dev is a floating slave, post through the device itself.
-      */
- 
-     if (IsMaster(dev))
--        ptr = GetMaster(dev, MASTER_POINTER);
-+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
-     else if (!dev->u.master)
-         ptr = dev;
-     else
--- 
-1.6.6.1
-
-From f2fe7f8ef94e800be70d0a179c7b27327008d8dd Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Wed, 14 Apr 2010 10:51:41 +1000
-Subject: [PATCH 2/3] xkb: Guard against SIGIO updates during PointerKeys.
-
-In theory, an event coming in during GPE could reset our lastSlave, leading
-to rather interesting events lateron.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Simon Thum <simon.thum@gmx.de>
-Reviewed-by: Daniel Stone <daniel@fooishbar.org>
----
- xkb/ddxDevBtn.c |    3 ++-
- 1 files changed, 2 insertions(+), 1 deletions(-)
-
-diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
-index 3bee84b..b8a222d 100644
---- a/xkb/ddxDevBtn.c
-+++ b/xkb/ddxDevBtn.c
-@@ -64,11 +64,12 @@ XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
-         return;
- 
-     events = InitEventList(GetMaximumEventsNum());
-+    OsBlockSignals();
-     nevents = GetPointerEvents(events, ptr,
-                                press ? ButtonPress : ButtonRelease, button,
-                                0 /* flags */, 0 /* first */,
-                                0 /* num_val */, NULL);
--
-+    OsReleaseSignals();
- 
-     for (i = 0; i < nevents; i++)
-         mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
--- 
-1.6.6.1
-
-From ec98f743d4f04da6228e5a089515febbcf627af8 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Tue, 13 Apr 2010 14:44:59 +1000
-Subject: [PATCH 3/3] xkb: use GPE for XKB fake motion events.
-
-Section 4.6.1 of the XKB spec says that "the initial event always moves the
-cursor the distance specified in the action [...]", so skip the
-POINTER_ACCELERATE flag for GPE, it would cause double-acceleration.
-
-Potential regression - GPE expects the coordinates to be either relative or
-both. XKB in theory allows for x to be relative and y to be absolute (or
-vice versa). Let's pretend that scenario has no users.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Simon Thum <simon.thum@gmx.de>
-Reviewed-by: Daniel Stone <daniel@fooishbar.org>
----
- include/xkbsrv.h |    1 +
- xkb/ddxFakeMtn.c |  100 ++++++++++++-----------------------------------------
- xkb/xkbActions.c |    4 +-
- 3 files changed, 26 insertions(+), 79 deletions(-)
-
-diff --git a/include/xkbsrv.h b/include/xkbsrv.h
-index ebc7cdb..a19cb43 100644
---- a/include/xkbsrv.h
-+++ b/include/xkbsrv.h
-@@ -787,6 +787,7 @@ extern _X_EXPORT void XkbDDXUpdateDeviceIndicators(
- );
- 
- extern _X_EXPORT void XkbDDXFakePointerMotion(
-+	DeviceIntPtr	/* dev */,
-  	unsigned int	/* flags */,
- 	int		/* x */,
- 	int		/* y */
-diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c
-index f90d209..b383716 100644
---- a/xkb/ddxFakeMtn.c
-+++ b/xkb/ddxFakeMtn.c
-@@ -28,91 +28,37 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
- #include <dix-config.h>
- #endif
- 
--#include <stdio.h>
--#include <X11/X.h>
--#include <X11/Xproto.h>
--#include <X11/keysym.h>
- #include "inputstr.h"
--#include "scrnintstr.h"
--#include "windowstr.h"
- #include <xkbsrv.h>
--#include <X11/extensions/XI.h>
--
--#ifdef PANORAMIX
--#include "panoramiX.h"
--#include "panoramiXsrv.h"
--#endif
--
--#include "mipointer.h"
--#include "mipointrst.h"
-+#include "mi.h"
- 
- void
--XkbDDXFakePointerMotion(unsigned flags,int x,int y)
-+XkbDDXFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
- {
--int 		   oldX,oldY;
--ScreenPtr	   pScreen, oldScreen;
--
--    GetSpritePosition(inputInfo.pointer, &oldX, &oldY);
--    pScreen = oldScreen = GetSpriteWindow(inputInfo.pointer)->drawable.pScreen;
--
--#ifdef PANORAMIX
--    if (!noPanoramiXExtension) {
--	BoxRec box;
--	int i;
-+    EventListPtr        events;
-+    int                 nevents, i;
-+    DeviceIntPtr        ptr;
-+    int                 gpe_flags = 0;
- 
--	if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
--							    oldX, oldY, &box)) {
--	    FOR_NSCREENS(i) {
--		if(i == pScreen->myNum)
--		    continue;
--		if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
--				   oldX, oldY, &box)) {
--		    pScreen = screenInfo.screens[i];
--		    break;
--		}
--	    }
--	}
--	oldScreen = pScreen;
--
--	if (flags&XkbSA_MoveAbsoluteX)
--	     oldX=  x;
--	else oldX+= x;
--	if (flags&XkbSA_MoveAbsoluteY)
--	     oldY=  y;
--	else oldY+= y;
-+    if (!dev->u.master)
-+        ptr = dev;
-+    else
-+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
- 
--	if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
--							    oldX, oldY, &box)) {
--	    FOR_NSCREENS(i) {
--		if(i == pScreen->myNum)
--		    continue;
--		if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
--				   oldX, oldY, &box)) {
--		    pScreen = screenInfo.screens[i];
--		    break;
--		}
--	    }
--	}
--	oldX -= panoramiXdataPtr[pScreen->myNum].x;
--	oldY -= panoramiXdataPtr[pScreen->myNum].y;
--    }
-+    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
-+        gpe_flags = POINTER_ABSOLUTE;
-     else
--#endif
--    {
--	if (flags&XkbSA_MoveAbsoluteX)
--	     oldX=  x;
--	else oldX+= x;
--	if (flags&XkbSA_MoveAbsoluteY)
--	     oldY=  y;
--	else oldY+= y;
-+        gpe_flags = POINTER_RELATIVE;
-+
-+    events = InitEventList(GetMaximumEventsNum());
-+    OsBlockSignals();
-+    nevents = GetPointerEvents(events, ptr,
-+                               MotionNotify, 0,
-+                               gpe_flags, 0, 2, (int[]){x, y});
-+    OsReleaseSignals();
- 
--#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
--	(*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
--	    (&pScreen, &oldX, &oldY);
--    }
-+    for (i = 0; i < nevents; i++)
-+        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
- 
--    if (pScreen != oldScreen)
--	NewCurrentScreen(inputInfo.pointer, pScreen, oldX, oldY);
--    if (pScreen->SetCursorPosition)
--	(*pScreen->SetCursorPosition)(inputInfo.pointer, pScreen, oldX, oldY, TRUE);
-+    FreeEventList(events, GetMaximumEventsNum());
- }
-diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
-index b0ab427..663f033 100644
---- a/xkb/xkbActions.c
-+++ b/xkb/xkbActions.c
-@@ -479,7 +479,7 @@ int		dx,dy;
- 	dx= xkbi->mouseKeysDX;
- 	dy= xkbi->mouseKeysDY;
-     }
--    XkbDDXFakePointerMotion(xkbi->mouseKeysFlags,dx,dy);
-+    XkbDDXFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
-     return xkbi->desc->ctrls->mk_interval;
- }
- 
-@@ -507,7 +507,7 @@ Bool	accel;
- 	accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
- 	x= XkbPtrActionX(&pAction->ptr);
- 	y= XkbPtrActionY(&pAction->ptr);
--	XkbDDXFakePointerMotion(pAction->ptr.flags,x,y);
-+	XkbDDXFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
- 	AccessXCancelRepeatKey(xkbi,keycode);
- 	xkbi->mouseKeysAccel= accel&&
- 		(xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
--- 
-1.6.6.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-randr-vt-switch.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-randr-vt-switch.patch
deleted file mode 100644
index d2e6d71..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.6-randr-vt-switch.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 41bdb6c003cca3ef0ff88d9c7de318115bab1ba2 Mon Sep 17 00:00:00 2001
-From: Pierre-Loup A. Griffais <pgriffais@nvidia.com>
-Date: Wed, 21 Apr 2010 18:11:05 -0700
-Subject: [PATCH] xf86: Don't crash when switching modes through RandR without owning the VT.
-
-While VT-switched, FB access is disabled and should remain so. Trying to switch
-modes in that state would re-enable it, potentially causing crashes if trying
-to access it before the driver has recovered from the mode switch.
-
-Signed-off-by: Pierre-Loup A. Griffais <pgriffais@nvidia.com>
-Reviewed-by: Adam Jackson <ajax@redhat.com>
-Signed-off-by: Keith Packard <keithp@keithp.com>
----
- hw/xfree86/common/xf86RandR.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
-index 02dcc34..d4beb2c 100644
---- a/hw/xfree86/common/xf86RandR.c
-+++ b/hw/xfree86/common/xf86RandR.c
-@@ -163,7 +163,7 @@ xf86RandRSetMode (ScreenPtr	    pScreen,
-     WindowPtr		pRoot = WindowTable[pScreen->myNum];
-     Bool		ret = TRUE;
- 
--    if (pRoot)
-+    if (pRoot && scrp->vtSema)
- 	(*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
-     if (useVirtual)
-     {
-@@ -229,7 +229,7 @@ xf86RandRSetMode (ScreenPtr	    pScreen,
-      */
-     xf86SetViewport (pScreen, pScreen->width, pScreen->height);
-     xf86SetViewport (pScreen, 0, 0);
--    if (pRoot)
-+    if (pRoot && scrp->vtSema)
- 	(*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
-     return ret;
- }
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-classic-default-mode.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-classic-default-mode.patch
deleted file mode 100644
index bc72157..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-classic-default-mode.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-From 5f34853d6f936e8a1a317a59972b07e3f191d1ab Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 15 Nov 2010 11:25:13 +1000
-Subject: [PATCH] xfree86: Bump classic driver default to 1024x768
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Keith Packard <keithp@keithp.com>
-Signed-off-by: Keith Packard <keithp@keithp.com>
----
- hw/xfree86/common/xf86Mode.c |   21 ++++++++++++++++-----
- 1 files changed, 16 insertions(+), 5 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
-index d03310e..54fe021 100644
---- a/hw/xfree86/common/xf86Mode.c
-+++ b/hw/xfree86/common/xf86Mode.c
-@@ -1402,6 +1402,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- 	strategy &= ~LOOKUP_OPTIONAL_TOLERANCES;
-     } else {
- 	const char *type = "";
-+        Bool specified = FALSE;
- 
- 	if (scrp->monitor->nHsync <= 0) {
- 	    if (numTimings > 0) {
-@@ -1412,11 +1413,13 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- 		}
- 	    } else {
- 		scrp->monitor->hsync[0].lo = 31.5;
--		scrp->monitor->hsync[0].hi = 37.9;
-+		scrp->monitor->hsync[0].hi = 48.0;
- 		scrp->monitor->nHsync = 1;
- 	    }
- 	    type = "default ";
--	}
-+	} else {
-+            specified = TRUE;
-+        }
- 	for (i = 0; i < scrp->monitor->nHsync; i++) {
- 	    if (scrp->monitor->hsync[i].lo == scrp->monitor->hsync[i].hi)
- 	      xf86DrvMsg(scrp->scrnIndex, X_INFO,
-@@ -1445,7 +1448,9 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- 		scrp->monitor->nVrefresh = 1;
- 	    }
- 	    type = "default ";
--	}
-+	} else {
-+            specified = TRUE;
-+        }
- 	for (i = 0; i < scrp->monitor->nVrefresh; i++) {
- 	    if (scrp->monitor->vrefresh[i].lo == scrp->monitor->vrefresh[i].hi)
- 	      xf86DrvMsg(scrp->scrnIndex, X_INFO,
-@@ -1459,10 +1464,16 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- 			 scrp->monitor->vrefresh[i].lo,
- 			 scrp->monitor->vrefresh[i].hi);
- 	}
-+
-+        type = "";
-+	if (!scrp->monitor->maxPixClock && !specified) {
-+            type = "default ";
-+            scrp->monitor->maxPixClock = 65000.0;
-+        }
- 	if (scrp->monitor->maxPixClock) {
- 	    xf86DrvMsg(scrp->scrnIndex, X_INFO,
--		       "%s: Using maximum pixel clock of %.2f MHz\n",
--		       scrp->monitor->id,
-+		       "%s: Using %smaximum pixel clock of %.2f MHz\n",
-+		       scrp->monitor->id, type,
- 		       (float)scrp->monitor->maxPixClock / 1000.0);
- 	}
-     }
--- 
-1.7.3.4
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-compresize-fix.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-compresize-fix.patch
deleted file mode 100644
index a211093..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-compresize-fix.patch
+++ /dev/null
@@ -1,319 +0,0 @@
-From 08bc76d60fdd39cf6d09e28070f37a0ad620adab Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <airlied@redhat.com>
-Date: Fri, 4 Jun 2010 11:02:58 +1000
-Subject: [PATCH 2/8] composite fixes backported
-
-squashes three upstream patches
-composite: use config notify hook to do pixmap resize. (v3) - backported to avoid ABI breakage
-composite: initialise pOldPixmap to NullPixmap at alloc time.
-composite: fix freeing of old pixmap until after move/resize/cbw
-
-misapplied - fixup
----
- composite/compalloc.c  |    1 +
- composite/compinit.c   |    3 +-
- composite/compint.h    |   11 ++--
- composite/compwindow.c |  124 +++++++++++++++--------------------------------
- dix/window.c           |   18 +++++++-
- include/window.h       |   11 ++++
- 6 files changed, 77 insertions(+), 91 deletions(-)
-
-diff --git a/composite/compalloc.c b/composite/compalloc.c
-index 73adc72..8a6beb9 100644
---- a/composite/compalloc.c
-+++ b/composite/compalloc.c
-@@ -143,6 +143,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
- 	cw->oldy = COMP_ORIGIN_INVALID;
- 	cw->damageRegistered = FALSE;
- 	cw->damaged = FALSE;
-+	cw->pOldPixmap = NullPixmap;
- 	dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
-     }
-     ccw->next = cw->clients;
-diff --git a/composite/compinit.c b/composite/compinit.c
-index e8b563d..2ee9332 100644
---- a/composite/compinit.c
-+++ b/composite/compinit.c
-@@ -69,6 +69,7 @@ compCloseScreen (int index, ScreenPtr pScreen)
-     pScreen->InstallColormap = cs->InstallColormap;
-     pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
-     pScreen->ReparentWindow = cs->ReparentWindow;
-+
-     pScreen->MoveWindow = cs->MoveWindow;
-     pScreen->ResizeWindow = cs->ResizeWindow;
-     pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
-@@ -389,6 +390,6 @@ compScreenInit (ScreenPtr pScreen)
-     dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
- 
-     RegisterRealChildHeadProc(CompositeRealChildHead);
--
-+    RegisterCompositeConfigNotifyProc(compConfigNotify);
-     return TRUE;
- }
-diff --git a/composite/compint.h b/composite/compint.h
-index 845a196..a959ad5 100644
---- a/composite/compint.h
-+++ b/composite/compint.h
-@@ -126,14 +126,11 @@ typedef struct _CompScreen {
-     RealizeWindowProcPtr	RealizeWindow;
-     UnrealizeWindowProcPtr	UnrealizeWindow;
-     ClipNotifyProcPtr		ClipNotify;
--    /*
--     * Called from ConfigureWindow, these
--     * three track changes to the offscreen storage
--     * geometry
--     */
-+
-     MoveWindowProcPtr		MoveWindow;
-     ResizeWindowProcPtr		ResizeWindow;
-     ChangeBorderWidthProcPtr	ChangeBorderWidth;
-+
-     /*
-      * Reparenting has an effect on Subwindows redirect
-      */
-@@ -316,4 +313,8 @@ CompositeRealChildHead (WindowPtr pWin);
- int
- DeleteWindowNoInputDevices(pointer value, XID wid);
- 
-+int
-+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
-+		 int bw, WindowPtr pSib);
-+
- #endif /* _COMPINT_H_ */
-diff --git a/composite/compwindow.c b/composite/compwindow.c
-index 2f5a717..550df39 100644
---- a/composite/compwindow.c
-+++ b/composite/compwindow.c
-@@ -334,37 +334,9 @@ compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
-     return FALSE;
- }
- 
--void
--compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
-+static void compFreeOldPixmap(WindowPtr pWin)
- {
-     ScreenPtr		pScreen = pWin->drawable.pScreen;
--    CompScreenPtr	cs = GetCompScreen (pScreen);
--
--    compCheckTree (pScreen);
--    if (pWin->redirectDraw != RedirectDrawNone)
--    {
--	WindowPtr		pParent;
--	int			draw_x, draw_y;
--	unsigned int		w, h, bw;
--
--	/* if this is a root window, can't be moved */
--	if (!(pParent = pWin->parent))
--	   return;
--
--	bw = wBorderWidth (pWin);
--	draw_x = pParent->drawable.x + x + (int)bw;
--	draw_y = pParent->drawable.y + y + (int)bw;
--	w = pWin->drawable.width;
--	h = pWin->drawable.height;
--	compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
--    }
--    compCheckTree (pScreen);
--
--    pScreen->MoveWindow = cs->MoveWindow;
--    (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
--    cs->MoveWindow = pScreen->MoveWindow;
--    pScreen->MoveWindow = compMoveWindow;
--
-     if (pWin->redirectDraw != RedirectDrawNone)
-     {
- 	CompWindowPtr	cw = GetCompWindow (pWin);
-@@ -374,7 +346,19 @@ compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
- 	    cw->pOldPixmap = NullPixmap;
- 	}
-     }
-+}
-+void
-+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
-+{
-+    ScreenPtr		pScreen = pWin->drawable.pScreen;
-+    CompScreenPtr	cs = GetCompScreen (pScreen);
-+
-+    pScreen->MoveWindow = cs->MoveWindow;
-+    (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
-+    cs->MoveWindow = pScreen->MoveWindow;
-+    pScreen->MoveWindow = compMoveWindow;
- 
-+    compFreeOldPixmap(pWin);
-     compCheckTree (pScreen);
- }
- 
-@@ -385,37 +369,12 @@ compResizeWindow (WindowPtr pWin, int x, int y,
-     ScreenPtr		pScreen = pWin->drawable.pScreen;
-     CompScreenPtr	cs = GetCompScreen (pScreen);
- 
--    compCheckTree (pScreen);
--    if (pWin->redirectDraw != RedirectDrawNone)
--    {
--	WindowPtr		pParent;
--	int			draw_x, draw_y;
--	unsigned int		bw;
--
--	/* if this is a root window, can't be moved */
--	if (!(pParent = pWin->parent))
--	   return;
--
--	bw = wBorderWidth (pWin);
--	draw_x = pParent->drawable.x + x + (int)bw;
--	draw_y = pParent->drawable.y + y + (int)bw;
--	compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
--    }
--    compCheckTree (pScreen);
--
-     pScreen->ResizeWindow = cs->ResizeWindow;
-     (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
-     cs->ResizeWindow = pScreen->ResizeWindow;
-     pScreen->ResizeWindow = compResizeWindow;
--    if (pWin->redirectDraw != RedirectDrawNone)
--    {
--	CompWindowPtr	cw = GetCompWindow (pWin);
--	if (cw->pOldPixmap)
--	{
--	    (*pScreen->DestroyPixmap) (cw->pOldPixmap);
--	    cw->pOldPixmap = NullPixmap;
--	}
--    }
-+
-+    compFreeOldPixmap(pWin);
-     compCheckTree (pWin->drawable.pScreen);
- }
- 
-@@ -425,38 +384,12 @@ compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
-     ScreenPtr		pScreen = pWin->drawable.pScreen;
-     CompScreenPtr	cs = GetCompScreen (pScreen);
- 
--    compCheckTree (pScreen);
--    if (pWin->redirectDraw != RedirectDrawNone)
--    {
--	WindowPtr		pParent;
--	int			draw_x, draw_y;
--	unsigned int		w, h;
--
--	/* if this is a root window, can't be moved */
--	if (!(pParent = pWin->parent))
--	   return;
--
--	draw_x = pWin->drawable.x;
--	draw_y = pWin->drawable.y;
--	w = pWin->drawable.width;
--	h = pWin->drawable.height;
--	compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
--    }
--    compCheckTree (pScreen);
--
-     pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
-     (*pScreen->ChangeBorderWidth) (pWin, bw);
-     cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
-     pScreen->ChangeBorderWidth = compChangeBorderWidth;
--    if (pWin->redirectDraw != RedirectDrawNone)
--    {
--	CompWindowPtr	cw = GetCompWindow (pWin);
--	if (cw->pOldPixmap)
--	{
--	    (*pScreen->DestroyPixmap) (cw->pOldPixmap);
--	    cw->pOldPixmap = NullPixmap;
--	}
--    }
-+
-+    compFreeOldPixmap(pWin);
-     compCheckTree (pWin->drawable.pScreen);
- }
- 
-@@ -822,3 +755,26 @@ CompositeRealChildHead (WindowPtr pWin)
- 	return pChildBefore;
-     }
- }
-+
-+int
-+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
-+		 int bw, WindowPtr pSib)
-+{
-+    ScreenPtr		pScreen = pWin->drawable.pScreen;
-+    WindowPtr		pParent = pWin->parent;
-+    int			draw_x, draw_y;
-+    Bool alloc_ret;
-+
-+    if (pWin->redirectDraw == RedirectDrawNone)
-+	return Success;
-+
-+    compCheckTree (pScreen);
-+
-+    draw_x = pParent->drawable.x + x + bw;
-+    draw_y = pParent->drawable.y + y + bw;
-+    alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-+
-+    if (alloc_ret == FALSE)
-+	return BadAlloc;
-+    return Success;
-+}
-diff --git a/dix/window.c b/dix/window.c
-index e191f09..e4c850f 100644
---- a/dix/window.c
-+++ b/dix/window.c
-@@ -2104,6 +2104,13 @@ ReflectStackChange(
- 	WindowsRestructured ();
- }
- 
-+static compositeConfigNotifyProcPtr compositeConfigNotify;
-+void
-+RegisterCompositeConfigNotifyProc(compositeConfigNotifyProcPtr proc)
-+{
-+    compositeConfigNotify = proc;
-+}
-+
- /*****
-  * ConfigureWindow
-  *****/
-@@ -2220,7 +2227,6 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
-     else
- 	pSib = pWin->nextSib;
- 
--
-     if ((!pWin->overrideRedirect) && 
- 	(RedirectSend(pParent)
- 	))
-@@ -2305,6 +2311,16 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
-     return(Success);
- 
- ActuallyDoSomething:
-+    if (compositeConfigNotify)
-+    {
-+	int ret;
-+	ret = compositeConfigNotify(pWin, x, y, w, h, bw, pSib);
-+	if (ret) {
-+	    client->errorValue = 0;
-+	    return ret;
-+	}
-+    }
-+
-     if (SubStrSend(pWin, pParent))
-     {
- 	memset(&event, 0, sizeof(xEvent));
-diff --git a/include/window.h b/include/window.h
-index 6fb2f8c..ea2edab 100644
---- a/include/window.h
-+++ b/include/window.h
-@@ -266,4 +266,15 @@ extern _X_EXPORT void DisableMapUnmapEvents(
- extern _X_EXPORT void EnableMapUnmapEvents(
-     WindowPtr /* pWin */ );
- 
-+typedef int (* compositeConfigNotifyProcPtr)(
-+    WindowPtr /* pWin */,
-+    int /* x */,
-+    int /* y */,
-+    int /* w */,
-+    int /* h */,
-+    int /* bw */,
-+    WindowPtr /*pSib*/);
-+
-+_X_EXPORT void RegisterCompositeConfigNotifyProc(compositeConfigNotifyProcPtr proc);
-+
- #endif /* WINDOW_H */
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-ddc-probe-less.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-ddc-probe-less.patch
deleted file mode 100644
index 3fe7e4f..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-ddc-probe-less.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 872e6e49882d655c4e7dd7914e0bf34480a8c30b Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 9 Aug 2010 14:33:55 -0400
-Subject: [PATCH] ddc: Don't probe for DDC/CI or EEPROM, some monitors hate that
-
-Those monitors are garbage, of course.
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- hw/xfree86/ddc/ddc.c |    4 ----
- 1 files changed, 0 insertions(+), 4 deletions(-)
-
-diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
-index 6fad9fb..df46689 100644
---- a/hw/xfree86/ddc/ddc.c
-+++ b/hw/xfree86/ddc/ddc.c
-@@ -311,10 +311,6 @@ DDC2Init(int scrnIndex, I2CBusPtr pBus)
-     dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
-     if (xf86I2CProbeAddress(pBus, 0x0060))
- 	DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
--    if (xf86I2CProbeAddress(pBus, 0x0062))
--	DDC2MakeDevice(pBus, 0x0062, "EDID EEPROM interface");
--    if (xf86I2CProbeAddress(pBus, 0x006E))
--	DDC2MakeDevice(pBus, 0x006E, "DDC control interface");
- 
-     return dev;
- }
--- 
-1.7.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-device-mode-list.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-device-mode-list.patch
deleted file mode 100644
index b1328b7..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-device-mode-list.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 532529ced48ff4338cfd7317fa795e9bbf0a2d80 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Wed, 9 Jun 2010 15:41:09 +1000
-Subject: [PATCH] Xi: only list the device mode in XIQueryDevice, not the proximity bit.
-
-The mode is either Absolute or Relative, the mode field in the
-ValuatorClassRec also stores the proximity bit on the second bit for XI 1.x
-clients, returning bad data to clients that just check for (mode ==
-Absolute) or for (mode == Relative).
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- Xi/xiquerydevice.c |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
-index 435868d..4849286 100644
---- a/Xi/xiquerydevice.c
-+++ b/Xi/xiquerydevice.c
-@@ -346,7 +346,7 @@ ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber,
-     info->value.frac = (int)(v->axisVal[axisnumber] * (1 << 16) * (1 << 16));
-     info->resolution = v->axes[axisnumber].resolution;
-     info->number = axisnumber;
--    info->mode = v->mode; /* Server doesn't have per-axis mode yet */
-+    info->mode = v->mode & DeviceMode; /* Server doesn't have per-axis mode yet */
-     info->sourceid = v->sourceid;
- 
-     if (!reportState)
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-dga-master-keyboard.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-dga-master-keyboard.patch
deleted file mode 100644
index 2e12cc2..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-dga-master-keyboard.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 374fca17a231d6ea39154e8dfb881d4c7f3f5c4d Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Fri, 16 Apr 2010 16:35:22 +1000
-Subject: [PATCH] xfree86: dga needs to use the master keyboard state (#27573)
-
-GetPairedDevice() may not always return the keyboard, resulting in a
-null-pointer dereference when accessing the XKB state.
-For floating devices, the GetMaster() returns the device itself.
-
-X.Org Bug 27573 <http://bugs.freedesktop.org/show_bug.cgi?id=27573>
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-Tested-by: Ben Hutchings <ben@decadent.org.uk>
-(cherry picked from commit 10de9e8ee37265a35ceeceb2007d711da70d4f2d)
----
- hw/xfree86/common/xf86DGA.c |    4 +++-
- 1 files changed, 3 insertions(+), 1 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
-index 804fd37..5d8addb 100644
---- a/hw/xfree86/common/xf86DGA.c
-+++ b/hw/xfree86/common/xf86DGA.c
-@@ -1088,13 +1088,15 @@ DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse)
-     ButtonClassPtr  butc = mouse->button;
-     DGAScreenPtr    pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
-     DeviceEvent     ev;
-+    DeviceIntPtr    master = GetMaster(mouse, MASTER_KEYBOARD);
- 
-     memset(&ev, 0, sizeof(ev));
-     ev.header = ET_Internal;
-     ev.length = sizeof(ev);
-     ev.type = event->subtype;
-     ev.corestate  = butc->state;
--    ev.corestate |= XkbStateFieldFromRec(&GetPairedDevice(mouse)->key->xkbInfo->state);
-+    if (master && master->key)
-+        ev.corestate |= XkbStateFieldFromRec(&master->key->xkbInfo->state);
- 
-     UpdateDeviceState(mouse, &ev);
- 
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-event-mask-revert.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-event-mask-revert.patch
deleted file mode 100644
index 315a8eb..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-event-mask-revert.patch
+++ /dev/null
@@ -1,137 +0,0 @@
-From 32fc04c9f8b38627ef13d4640d22563eb18d3de6 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Thu, 24 Jun 2010 12:52:53 +1000
-Subject: [PATCH] Revert "dix: use the event mask of the grab for TryClientEvents."
-
-Behaviour of earlier X servers was to deliver the ButtonPress event
-unconditionally, regardless of the actual event mask being set. This is
-documented in the protocol:
-"This request establishes a passive grab.  In the future, the pointer is
-actively grabbed as described in GrabPointer, the last-pointer-grab time is
-set to the time at which the button was pressed (as transmitted in the
-ButtonPress event), and the ButtonPress event is reported if all of the
-following conditions are true:
-    <list of conditions, event mask is not one of them>"
-
-Thus, a GrabButton event will always deliver the button press event, a
-GrabKey always the key press event, etc. Same goes for XI and XI2.
-
-Reproducible with a simple client requesting a button grab in the form of:
-    XGrabButton(dpy, AnyButton, AnyModifier, win, True, ButtonReleaseMask,
-                GrabModeAsync, GrabModeAsync, None, None);
-
-On servers before MPX/XI2, the client will receive a button press and
-release event. On current servers, the client receives only the release.
-Clients that expect the press event to be delivered unconditionally.
-
-XTS Xlib13 XGrabButton 5/39 now passes.
-
-This reverts commit 48585bd1e3e98db0f3df1ecc68022510216e00cc.
-Effectively reverts commit 1c612acca8568fcdf9761d23f112adaf4d496f1b as well,
-the code introduced with 1c612 is not needed anymore.
-
-Conflicts:
-
-	dix/events.c
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Acked-by: Daniel Stone <daniel@fooishbar.org>
-Reviewed-by: Keith Packard <keithp@keithp.com>
----
- dix/events.c |   52 ++--------------------------------------------------
- 1 files changed, 2 insertions(+), 50 deletions(-)
-
-diff --git a/dix/events.c b/dix/events.c
-index 44c4624..9d35b22 100644
---- a/dix/events.c
-+++ b/dix/events.c
-@@ -3440,7 +3440,6 @@ CheckPassiveGrabsOnWindow(
-     {
- 	DeviceIntPtr	gdev;
- 	XkbSrvInfoPtr	xkbi = NULL;
--	Mask		mask = 0;
- 
- 	gdev= grab->modifierDevice;
-         if (grab->grabtype == GRABTYPE_CORE)
-@@ -3555,9 +3554,6 @@ CheckPassiveGrabsOnWindow(
-                 }
-                 xE = &core;
-                 count = 1;
--                mask = grab->eventMask;
--                if (grab->ownerEvents)
--                    mask |= pWin->eventMask;
-             } else if (match & XI2_MATCH)
-             {
-                 rc = EventToXI2((InternalEvent*)event, &xE);
-@@ -3569,34 +3565,6 @@ CheckPassiveGrabsOnWindow(
-                     continue;
-                 }
-                 count = 1;
--
--                /* FIXME: EventToXI2 returns NULL for enter events, so
--                 * dereferencing the event is bad. Internal event types are
--                 * aligned with core events, so the else clause is valid.
--                 * long-term we should use internal events for enter/focus
--                 * as well */
--                if (xE)
--                    mask = grab->xi2mask[device->id][((xGenericEvent*)xE)->evtype/8];
--                else if (event->type == XI_Enter || event->type == XI_FocusIn)
--                    mask = grab->xi2mask[device->id][event->type/8];
--
--                if (grab->ownerEvents && wOtherInputMasks(grab->window))
--                {
--                    InputClientsPtr icp =
--                        wOtherInputMasks(grab->window)->inputClients;
--
--                    while(icp)
--                    {
--                        if (rClient(icp) == rClient(grab))
--                        {
--                            int evtype = (xE) ? ((xGenericEvent*)xE)->evtype : event->type;
--                            mask |= icp->xi2mask[device->id][evtype/8];
--                            break;
--                        }
--
--                        icp = icp->next;
--                    }
--                }
-             } else
-             {
-                 rc = EventToXI((InternalEvent*)event, &xE, &count);
-@@ -3607,23 +3575,6 @@ CheckPassiveGrabsOnWindow(
-                                 "(%d, %d).\n", device->name, event->type, rc);
-                     continue;
-                 }
--                mask = grab->eventMask;
--                if (grab->ownerEvents && wOtherInputMasks(grab->window))
--                {
--                    InputClientsPtr icp =
--                        wOtherInputMasks(grab->window)->inputClients;
--
--                    while(icp)
--                    {
--                        if (rClient(icp) == rClient(grab))
--                        {
--                            mask |= icp->mask[device->id];
--                            break;
--                        }
--
--                        icp = icp->next;
--                    }
--                }
-             }
- 
- 	    (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
-@@ -3632,7 +3583,8 @@ CheckPassiveGrabsOnWindow(
-             {
-                 FixUpEventFromWindow(device, xE, grab->window, None, TRUE);
- 
--                TryClientEvents(rClient(grab), device, xE, count, mask,
-+                TryClientEvents(rClient(grab), device, xE, count,
-+                                       GetEventFilter(device, xE),
-                                        GetEventFilter(device, xE), grab);
-             }
- 
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-exa-master.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-exa-master.patch
deleted file mode 100644
index 73f7ab3..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-exa-master.patch
+++ /dev/null
@@ -1,2183 +0,0 @@
-From 9f493b930ef99253ba7e37dc280daff6738b6401 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Wed, 26 May 2010 11:15:00 -0500
-Subject: exa master
-
-produced with git diff xorg-server-1.7.6..master exa/
-
-Future diffs of this form will probably have to be careful about the
-devPrivates rework.
-
-diff --git a/exa/exa.c b/exa/exa.c
-index b8f0419..46a850f 100644
---- a/exa/exa.c
-+++ b/exa/exa.c
-@@ -233,19 +233,19 @@ exaPixmapIsPinned (PixmapPtr pPix)
- }
- 
- /**
-- * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen
-+ * exaPixmapHasGpuCopy() is used to determine if a pixmap is in offscreen
-  * memory, meaning that acceleration could probably be done to it, and that it
-  * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it
-  * with the CPU.
-  *
-  * Note that except for UploadToScreen()/DownloadFromScreen() (which explicitly
-  * deal with moving pixmaps in and out of system memory), EXA will give drivers
-- * pixmaps as arguments for which exaPixmapIsOffscreen() is TRUE.
-+ * pixmaps as arguments for which exaPixmapHasGpuCopy() is TRUE.
-  *
-  * @return TRUE if the given drawable is in framebuffer memory.
-  */
- Bool
--exaPixmapIsOffscreen(PixmapPtr pPixmap)
-+exaPixmapHasGpuCopy(PixmapPtr pPixmap)
- {
-     ScreenPtr	pScreen = pPixmap->drawable.pScreen;
-     ExaScreenPriv(pScreen);
-@@ -253,16 +253,16 @@ exaPixmapIsOffscreen(PixmapPtr pPixmap)
-     if (!(pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS))
- 	return FALSE;
- 
--    return (*pExaScr->pixmap_is_offscreen)(pPixmap);
-+    return (*pExaScr->pixmap_has_gpu_copy)(pPixmap);
- }
- 
- /**
-- * exaDrawableIsOffscreen() is a convenience wrapper for exaPixmapIsOffscreen().
-+ * exaDrawableIsOffscreen() is a convenience wrapper for exaPixmapHasGpuCopy().
-  */
- Bool
- exaDrawableIsOffscreen (DrawablePtr pDrawable)
- {
--    return exaPixmapIsOffscreen (exaGetDrawablePixmap (pDrawable));
-+    return exaPixmapHasGpuCopy (exaGetDrawablePixmap (pDrawable));
- }
- 
- /**
-@@ -276,14 +276,14 @@ exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
- 
-     exaGetDrawableDeltas (pDrawable, pPixmap, xp, yp);
- 
--    if (exaPixmapIsOffscreen (pPixmap))
-+    if (exaPixmapHasGpuCopy (pPixmap))
- 	return pPixmap;
-     else
- 	return NULL;
- }
- 
- /**
-- * Returns TRUE if pixmap can be accessed offscreen.
-+ * Returns TRUE if the pixmap GPU copy is being accessed.
-  */
- Bool
- ExaDoPrepareAccess(PixmapPtr pPixmap, int index)
-@@ -291,7 +291,7 @@ ExaDoPrepareAccess(PixmapPtr pPixmap, int index)
-     ScreenPtr pScreen = pPixmap->drawable.pScreen;
-     ExaScreenPriv (pScreen);
-     ExaPixmapPriv(pPixmap);
--    Bool offscreen;
-+    Bool has_gpu_copy, ret;
-     int i;
- 
-     if (!(pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS))
-@@ -304,7 +304,7 @@ ExaDoPrepareAccess(PixmapPtr pPixmap, int index)
-     for (i = 0; i < EXA_NUM_PREPARE_INDICES; i++) {
- 	if (pExaScr->access[i].pixmap == pPixmap) {
- 	    pExaScr->access[i].count++;
--	    return TRUE;
-+	    return pExaScr->access[i].retval;
- 	}
-     }
- 
-@@ -321,31 +321,35 @@ ExaDoPrepareAccess(PixmapPtr pPixmap, int index)
- 			     pPixmap->devPrivate.ptr));
-     }
- 
--    offscreen = exaPixmapIsOffscreen(pPixmap);
-+    has_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
- 
--    if (offscreen && pExaPixmap->fb_ptr)
-+    if (has_gpu_copy && pExaPixmap->fb_ptr) {
- 	pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
--    else
-+	ret = TRUE;
-+    } else {
- 	pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
-+	ret = FALSE;
-+    }
- 
-     /* Store so we can handle repeated / nested calls. */
-     pExaScr->access[index].pixmap = pPixmap;
-     pExaScr->access[index].count = 1;
- 
--    if (!offscreen)
--	return FALSE;
-+    if (!has_gpu_copy)
-+	goto out;
- 
-     exaWaitSync (pScreen);
- 
-     if (pExaScr->info->PrepareAccess == NULL)
--	return TRUE;
-+	goto out;
- 
-     if (index >= EXA_PREPARE_AUX_DEST &&
- 	!(pExaScr->info->flags & EXA_SUPPORTS_PREPARE_AUX)) {
- 	if (pExaPixmap->score == EXA_PIXMAP_SCORE_PINNED)
- 	    FatalError("Unsupported AUX indices used on a pinned pixmap.\n");
- 	exaMoveOutPixmap (pPixmap);
--	return FALSE;
-+	ret = FALSE;
-+	goto out;
-     }
- 
-     if (!(*pExaScr->info->PrepareAccess) (pPixmap, index)) {
-@@ -353,11 +357,15 @@ ExaDoPrepareAccess(PixmapPtr pPixmap, int index)
- 	    !(pExaScr->info->flags & EXA_MIXED_PIXMAPS))
- 	    FatalError("Driver failed PrepareAccess on a pinned pixmap.\n");
- 	exaMoveOutPixmap (pPixmap);
--
--	return FALSE;
-+	ret = FALSE;
-+	goto out;
-     }
- 
--    return TRUE;
-+    ret = TRUE;
-+
-+out:
-+    pExaScr->access[index].retval = ret;
-+    return ret;
- }
- 
- /**
-@@ -409,18 +417,15 @@ exaFinishAccess(DrawablePtr pDrawable, int index)
- 
-     /* Catch unbalanced Prepare/FinishAccess calls. */
-     if (i == EXA_NUM_PREPARE_INDICES)
--	EXA_FatalErrorDebug(("EXA bug: FinishAccess called without PrepareAccess for pixmap 0x%p.\n",
--			     pPixmap));
-+      EXA_FatalErrorDebugWithRet(("EXA bug: FinishAccess called without PrepareAccess for pixmap 0x%p.\n",
-+				  pPixmap),);
- 
-     pExaScr->access[i].pixmap = NULL;
- 
-     /* We always hide the devPrivate.ptr. */
-     pPixmap->devPrivate.ptr = NULL;
- 
--    if (pExaScr->finish_access)
--	pExaScr->finish_access(pPixmap, index);
--
--    if (!pExaScr->info->FinishAccess || !exaPixmapIsOffscreen(pPixmap))
-+    if (!pExaScr->info->FinishAccess || !exaPixmapHasGpuCopy(pPixmap))
- 	return;
- 
-     if (i >= EXA_PREPARE_AUX_DEST &&
-@@ -695,10 +700,18 @@ ExaBlockHandler(int screenNum, pointer blockData, pointer pTimeout,
-     ScreenPtr pScreen = screenInfo.screens[screenNum];
-     ExaScreenPriv(pScreen);
- 
-+    /* Move any deferred results from a software fallback to the driver pixmap */
-+    if (pExaScr->deferred_mixed_pixmap)
-+	exaMoveInPixmap_mixed(pExaScr->deferred_mixed_pixmap);
-+
-     unwrap(pExaScr, pScreen, BlockHandler);
-     (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
-     wrap(pExaScr, pScreen, BlockHandler, ExaBlockHandler);
- 
-+    /* The rest only applies to classic EXA */
-+    if (pExaScr->info->flags & EXA_HANDLES_PIXMAPS)
-+	return;
-+
-     /* Try and keep the offscreen memory area tidy every now and then (at most 
-      * once per second) when the server has been idle for at least 100ms.
-      */
-@@ -740,9 +753,7 @@ static Bool
- exaCloseScreen(int i, ScreenPtr pScreen)
- {
-     ExaScreenPriv(pScreen);
--#ifdef RENDER
-     PictureScreenPtr	ps = GetPictureScreenIfSet(pScreen);
--#endif
- 
-     if (ps->Glyphs == exaGlyphs)
- 	exaGlyphsFini(pScreen);
-@@ -765,18 +776,14 @@ exaCloseScreen(int i, ScreenPtr pScreen)
-     unwrap(pExaScr, pScreen, ChangeWindowAttributes);
-     unwrap(pExaScr, pScreen, BitmapToRegion);
-     unwrap(pExaScr, pScreen, CreateScreenResources);
--#ifdef RENDER
--    if (ps) {
--	unwrap(pExaScr, ps, Composite);
--	if (pExaScr->SavedGlyphs)
--	    unwrap(pExaScr, ps, Glyphs);
--	unwrap(pExaScr, ps, Trapezoids);
--	unwrap(pExaScr, ps, Triangles);
--	unwrap(pExaScr, ps, AddTraps);
--    }
--#endif
-+    unwrap(pExaScr, ps, Composite);
-+    if (pExaScr->SavedGlyphs)
-+	unwrap(pExaScr, ps, Glyphs);
-+    unwrap(pExaScr, ps, Trapezoids);
-+    unwrap(pExaScr, ps, Triangles);
-+    unwrap(pExaScr, ps, AddTraps);
- 
--    xfree (pExaScr);
-+    free(pExaScr);
- 
-     return (*pScreen->CloseScreen) (i, pScreen);
- }
-@@ -787,14 +794,14 @@ exaCloseScreen(int i, ScreenPtr pScreen)
-  * without breaking ABI between EXA and the drivers.  The driver's
-  * responsibility is to check beforehand that the EXA module has a matching
-  * major number and sufficient minor.  Drivers are responsible for freeing the
-- * driver structure using xfree().
-+ * driver structure using free().
-  *
-  * @return a newly allocated, zero-filled driver structure
-  */
- ExaDriverPtr
- exaDriverAlloc(void)
- {
--    return xcalloc(1, sizeof(ExaDriverRec));
-+    return calloc(1, sizeof(ExaDriverRec));
- }
- 
- /**
-@@ -812,9 +819,7 @@ exaDriverInit (ScreenPtr		pScreen,
-                ExaDriverPtr	pScreenInfo)
- {
-     ExaScreenPrivPtr pExaScr;
--#ifdef RENDER
-     PictureScreenPtr ps;
--#endif
- 
-     if (!pScreenInfo)
- 	return FALSE;
-@@ -882,11 +887,9 @@ exaDriverInit (ScreenPtr		pScreen,
-         pScreenInfo->maxPitchPixels = pScreenInfo->maxX;
-     }
- 
--#ifdef RENDER
-     ps = GetPictureScreenIfSet(pScreen);
--#endif
- 
--    pExaScr = xcalloc (sizeof (ExaScreenPrivRec), 1);
-+    pExaScr = calloc(sizeof (ExaScreenPrivRec), 1);
-     if (!pExaScr) {
-         LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n",
- 		   pScreen->myNum);
-@@ -912,10 +915,12 @@ exaDriverInit (ScreenPtr		pScreen,
-      * Replace various fb screen functions
-      */
-     if ((pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) &&
--	!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS)) {
-+	(!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS) ||
-+	 (pExaScr->info->flags & EXA_MIXED_PIXMAPS)))
- 	wrap(pExaScr, pScreen, BlockHandler, ExaBlockHandler);
-+    if ((pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) &&
-+	!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS))
- 	wrap(pExaScr, pScreen, WakeupHandler, ExaWakeupHandler);
--    }
-     wrap(pExaScr, pScreen, CreateGC, exaCreateGC);
-     wrap(pExaScr, pScreen, CloseScreen, exaCloseScreen);
-     wrap(pExaScr, pScreen, GetImage, exaGetImage);
-@@ -925,16 +930,17 @@ exaDriverInit (ScreenPtr		pScreen,
-     wrap(pExaScr, pScreen, BitmapToRegion, exaBitmapToRegion);
-     wrap(pExaScr, pScreen, CreateScreenResources, exaCreateScreenResources);
- 
--#ifdef RENDER
-     if (ps) {
- 	wrap(pExaScr, ps, Composite, exaComposite);
--	if (pScreenInfo->PrepareComposite)
-+	if (pScreenInfo->PrepareComposite) {
- 	    wrap(pExaScr, ps, Glyphs, exaGlyphs);
-+	} else {
-+	    wrap(pExaScr, ps, Glyphs, ExaCheckGlyphs);
-+	}
- 	wrap(pExaScr, ps, Trapezoids, exaTrapezoids);
- 	wrap(pExaScr, ps, Triangles, exaTriangles);
- 	wrap(pExaScr, ps, AddTraps, ExaCheckAddTraps);
-     }
--#endif
- 
- #ifdef MITSHM
-     /*
-@@ -959,32 +965,29 @@ exaDriverInit (ScreenPtr		pScreen,
- 		wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_mixed);
- 		wrap(pExaScr, pScreen, ModifyPixmapHeader, exaModifyPixmapHeader_mixed);
- 		pExaScr->do_migration = exaDoMigration_mixed;
--		pExaScr->pixmap_is_offscreen = exaPixmapIsOffscreen_mixed;
-+		pExaScr->pixmap_has_gpu_copy = exaPixmapHasGpuCopy_mixed;
- 		pExaScr->do_move_in_pixmap = exaMoveInPixmap_mixed;
- 		pExaScr->do_move_out_pixmap = NULL;
- 		pExaScr->prepare_access_reg = exaPrepareAccessReg_mixed;
--		pExaScr->finish_access = exaFinishAccess_mixed;
- 	    } else {
- 		wrap(pExaScr, pScreen, CreatePixmap, exaCreatePixmap_driver);
- 		wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_driver);
- 		wrap(pExaScr, pScreen, ModifyPixmapHeader, exaModifyPixmapHeader_driver);
- 		pExaScr->do_migration = NULL;
--		pExaScr->pixmap_is_offscreen = exaPixmapIsOffscreen_driver;
-+		pExaScr->pixmap_has_gpu_copy = exaPixmapHasGpuCopy_driver;
- 		pExaScr->do_move_in_pixmap = NULL;
- 		pExaScr->do_move_out_pixmap = NULL;
- 		pExaScr->prepare_access_reg = NULL;
--		pExaScr->finish_access = NULL;
- 	    }
- 	} else {
- 	    wrap(pExaScr, pScreen, CreatePixmap, exaCreatePixmap_classic);
- 	    wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_classic);
- 	    wrap(pExaScr, pScreen, ModifyPixmapHeader, exaModifyPixmapHeader_classic);
- 	    pExaScr->do_migration = exaDoMigration_classic;
--	    pExaScr->pixmap_is_offscreen = exaPixmapIsOffscreen_classic;
-+	    pExaScr->pixmap_has_gpu_copy = exaPixmapHasGpuCopy_classic;
- 	    pExaScr->do_move_in_pixmap = exaMoveInPixmap_classic;
- 	    pExaScr->do_move_out_pixmap = exaMoveOutPixmap_classic;
- 	    pExaScr->prepare_access_reg = exaPrepareAccessReg_classic;
--	    pExaScr->finish_access = NULL;
- 	}
- 	if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS)) {
- 	    LogMessage(X_INFO, "EXA(%d): Offscreen pixmap area of %lu bytes\n",
-diff --git a/exa/exa.h b/exa/exa.h
-index 4b39473..8c93d15 100644
---- a/exa/exa.h
-+++ b/exa/exa.h
-@@ -624,13 +624,13 @@ typedef struct _ExaDriver {
- 
-     /**
-      * PixmapIsOffscreen() is an optional driver replacement to
--     * exaPixmapIsOffscreen(). Set to NULL if you want the standard behaviour
--     * of exaPixmapIsOffscreen().
-+     * exaPixmapHasGpuCopy(). Set to NULL if you want the standard behaviour
-+     * of exaPixmapHasGpuCopy().
-      *
-      * @param pPix the pixmap
-      * @return TRUE if the given drawable is in framebuffer memory.
-      *
--     * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen
-+     * exaPixmapHasGpuCopy() is used to determine if a pixmap is in offscreen
-      * memory, meaning that acceleration could probably be done to it, and that it
-      * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it
-      * with the CPU.
-diff --git a/exa/exa_accel.c b/exa/exa_accel.c
-index d4eae89..4164ff7 100644
---- a/exa/exa_accel.c
-+++ b/exa/exa_accel.c
-@@ -157,6 +157,10 @@ exaDoPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
-     if (pExaScr->fallback_counter || pExaPixmap->accel_blocked || !pExaScr->info->UploadToScreen)
- 	return FALSE;
- 
-+    /* If there's a system copy, we want to save the result there */
-+    if (pExaPixmap->pDamage)
-+	return FALSE;
-+
-     /* Don't bother with under 8bpp, XYPixmaps. */
-     if (format != ZPixmap || bpp < 8)
- 	return FALSE;
-@@ -390,7 +394,7 @@ exaHWCopyNtoN (DrawablePtr    pSrcDrawable,
-     exaGetDrawableDeltas (pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
-     exaGetDrawableDeltas (pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
- 
--    rects = xalloc(nbox * sizeof(xRectangle));
-+    rects = malloc(nbox * sizeof(xRectangle));
- 
-     if (rects) {
- 	int i;
-@@ -413,7 +417,7 @@ exaHWCopyNtoN (DrawablePtr    pSrcDrawable,
- 	    ordering = CT_UNSORTED;
- 
- 	srcregion  = RECTS_TO_REGION(pScreen, nbox, rects, ordering);
--	xfree(rects);
-+	free(rects);
- 
- 	if (!pGC || !exaGCReadsDestination(pDstDrawable, pGC->planemask,
- 					   pGC->fillStyle, pGC->alu,
-@@ -482,9 +486,9 @@ exaHWCopyNtoN (DrawablePtr    pSrcDrawable,
- 	goto fallback;
-     }
- 
--    if (exaPixmapIsOffscreen(pDstPixmap)) {
-+    if (exaPixmapHasGpuCopy(pDstPixmap)) {
- 	/* Normal blitting. */
--	if (exaPixmapIsOffscreen(pSrcPixmap)) {
-+	if (exaPixmapHasGpuCopy(pSrcPixmap)) {
- 	    if (!(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, reverse ? -1 : 1,
- 						upsidedown ? -1 : 1,
- 						pGC ? pGC->alu : GXcopy,
-@@ -504,8 +508,11 @@ exaHWCopyNtoN (DrawablePtr    pSrcDrawable,
- 
- 	    (*pExaScr->info->DoneCopy) (pDstPixmap);
- 	    exaMarkSync (pDstDrawable->pScreen);
--	/* UTS: mainly for SHM PutImage's secondary path. */
--	} else if (pSrcExaPixmap->sys_ptr) {
-+	/* UTS: mainly for SHM PutImage's secondary path.
-+	 *
-+	 * Only taking this path for directly accessible pixmaps.
-+	 */
-+	} else if (!pDstExaPixmap->pDamage && pSrcExaPixmap->sys_ptr) {
- 	    int bpp = pSrcDrawable->bitsPerPixel;
- 	    int src_stride = exaGetPixmapPitch(pSrcPixmap);
- 	    CARD8 *src = NULL;
-@@ -619,7 +626,7 @@ exaPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
- 	return;
-     }
- 
--    prect = xalloc(sizeof(xRectangle) * npt);
-+    prect = malloc(sizeof(xRectangle) * npt);
-     for (i = 0; i < npt; i++) {
- 	prect[i].x = ppt[i].x;
- 	prect[i].y = ppt[i].y;
-@@ -631,7 +638,7 @@ exaPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
- 	prect[i].height = 1;
-     }
-     pGC->ops->PolyFillRect(pDrawable, pGC, npt, prect);
--    xfree(prect);
-+    free(prect);
- }
- 
- /**
-@@ -660,7 +667,7 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
- 	return;
-     }
- 
--    prect = xalloc(sizeof(xRectangle) * (npt - 1));
-+    prect = malloc(sizeof(xRectangle) * (npt - 1));
-     x1 = ppt[0].x;
-     y1 = ppt[0].y;
-     /* If we have any non-horizontal/vertical, fall back. */
-@@ -674,7 +681,7 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
- 	}
- 
- 	if (x1 != x2 && y1 != y2) {
--	    xfree(prect);
-+	    free(prect);
- 	    ExaCheckPolylines(pDrawable, pGC, mode, npt, ppt);
- 	    return;
- 	}
-@@ -698,7 +705,7 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
- 	y1 = y2;
-     }
-     pGC->ops->PolyFillRect(pDrawable, pGC, npt - 1, prect);
--    xfree(prect);
-+    free(prect);
- }
- 
- /**
-@@ -730,7 +737,7 @@ exaPolySegment (DrawablePtr pDrawable, GCPtr pGC, int nseg,
- 	}
-     }
- 
--    prect = xalloc(sizeof(xRectangle) * nseg);
-+    prect = malloc(sizeof(xRectangle) * nseg);
-     for (i = 0; i < nseg; i++) {
- 	if (pSeg[i].x1 < pSeg[i].x2) {
- 	    prect[i].x = pSeg[i].x1;
-@@ -756,7 +763,7 @@ exaPolySegment (DrawablePtr pDrawable, GCPtr pGC, int nseg,
- 	}
-     }
-     pGC->ops->PolyFillRect(pDrawable, pGC, nseg, prect);
--    xfree(prect);
-+    free(prect);
- }
- 
- static Bool exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion,
-@@ -835,7 +842,7 @@ exaPolyFillRect(DrawablePtr pDrawable,
- 	exaDoMigration (pixmaps, 1, TRUE);
-     }
- 
--    if (!exaPixmapIsOffscreen (pPixmap) ||
-+    if (!exaPixmapHasGpuCopy (pPixmap) ||
- 	!(*pExaScr->info->PrepareSolid) (pPixmap,
- 					 pGC->alu,
- 					 pGC->planemask,
-@@ -1017,7 +1024,7 @@ exaFillRegionSolid (DrawablePtr	pDrawable, RegionPtr pRegion, Pixel pixel,
- 	exaDoMigration (pixmaps, 1, TRUE);
-     }
- 
--    if (exaPixmapIsOffscreen (pPixmap) &&
-+    if (exaPixmapHasGpuCopy (pPixmap) &&
- 	(*pExaScr->info->PrepareSolid) (pPixmap, alu, planemask, pixel))
-     {
- 	int nbox;
-@@ -1040,6 +1047,7 @@ exaFillRegionSolid (DrawablePtr	pDrawable, RegionPtr pRegion, Pixel pixel,
- 	    pDrawable->width == 1 && pDrawable->height == 1 &&
- 	    pDrawable->bitsPerPixel != 24) {
- 	    ExaPixmapPriv(pPixmap);
-+	    RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
- 
- 	    switch (pDrawable->bitsPerPixel) {
- 	    case 32:
-@@ -1054,6 +1062,9 @@ exaFillRegionSolid (DrawablePtr	pDrawable, RegionPtr pRegion, Pixel pixel,
- 
- 	    REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
- 			 pRegion);
-+	    REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
-+			 pRegion);
-+	    REGION_SUBTRACT(pScreen, pending_damage, pending_damage, pRegion);
- 	}
- 
- 	ret = TRUE;
-@@ -1120,7 +1131,7 @@ exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
- 
-     pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
- 
--    if (!pPixmap || !exaPixmapIsOffscreen(pTile))
-+    if (!pPixmap || !exaPixmapHasGpuCopy(pTile))
- 	return FALSE;
- 
-     if ((*pExaScr->info->PrepareCopy) (pTile, pPixmap, 1, 1, alu, planemask))
-@@ -1254,35 +1265,16 @@ exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
- {
-     ExaScreenPriv (pDrawable->pScreen);
-     PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
-+    ExaPixmapPriv(pPix);
-     int xoff, yoff;
-     Bool ok;
- 
-     if (pExaScr->fallback_counter || pExaScr->swappedOut)
- 	goto fallback;
- 
--    exaGetDrawableDeltas (pDrawable, pPix, &xoff, &yoff);
--
--    if (pExaScr->do_migration) {
--	BoxRec Box;
--	RegionRec Reg;
--	ExaMigrationRec pixmaps[1];
--
--	Box.x1 = pDrawable->y + x + xoff;
--	Box.y1 = pDrawable->y + y + yoff;
--	Box.x2 = Box.x1 + w;
--	Box.y2 = Box.y1 + h;
--
--	REGION_INIT(pScreen, &Reg, &Box, 1);
--
--	pixmaps[0].as_dst = FALSE;
--	pixmaps[0].as_src = TRUE;
--	pixmaps[0].pPix = pPix;
--	pixmaps[0].pReg = &Reg;
--
--	exaDoMigration(pixmaps, 1, FALSE);
--
--	REGION_UNINIT(pScreen, &Reg);
--    }
-+    /* If there's a system copy, we want to save the result there */
-+    if (pExaPixmap->pDamage)
-+	goto fallback;
- 
-     pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
- 
-diff --git a/exa/exa_classic.c b/exa/exa_classic.c
-index 12f3987..e1ead6c 100644
---- a/exa/exa_classic.c
-+++ b/exa/exa_classic.c
-@@ -38,7 +38,7 @@ ExaGetPixmapAddress(PixmapPtr p)
- {
-     ExaPixmapPriv(p);
- 
--    if (pExaPixmap->offscreen && pExaPixmap->fb_ptr)
-+    if (pExaPixmap->use_gpu_copy && pExaPixmap->fb_ptr)
- 	return pExaPixmap->fb_ptr;
-     else
- 	return pExaPixmap->sys_ptr;
-@@ -90,7 +90,7 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
-     pExaPixmap->sys_pitch = pPixmap->devKind;
- 
-     pPixmap->devPrivate.ptr = NULL;
--    pExaPixmap->offscreen = FALSE;
-+    pExaPixmap->use_gpu_copy = FALSE;
- 
-     pExaPixmap->fb_ptr = NULL;
-     exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
-@@ -148,7 +148,7 @@ Bool
- exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int depth,
- 		      int bitsPerPixel, int devKind, pointer pPixData)
- {
--    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-+    ScreenPtr pScreen;
-     ExaScreenPrivPtr pExaScr;
-     ExaPixmapPrivPtr pExaPixmap;
-     Bool ret;
-@@ -156,6 +156,7 @@ exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int dept
-     if (!pPixmap)
-         return FALSE;
- 
-+    pScreen = pPixmap->drawable.pScreen;
-     pExaScr = ExaGetScreenPriv(pScreen);
-     pExaPixmap = ExaGetPixmapPriv(pPixmap);
- 
-@@ -168,7 +169,7 @@ exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int dept
- 
- 	/* Classic EXA:
- 	 * - Framebuffer.
--	 * - Scratch pixmap with offscreen memory.
-+	 * - Scratch pixmap with gpu memory.
- 	 */
- 	if (pExaScr->info->memoryBase && pPixData) {
- 	    if ((CARD8 *)pPixData >= pExaScr->info->memoryBase &&
-@@ -176,7 +177,7 @@ exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int dept
- 				pExaScr->info->memorySize) {
- 		pExaPixmap->fb_ptr = pPixData;
- 		pExaPixmap->fb_pitch = devKind;
--		pExaPixmap->offscreen = TRUE;
-+		pExaPixmap->use_gpu_copy = TRUE;
- 	    }
- 	}
- 
-@@ -189,7 +190,7 @@ exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int dept
-         }
- 
- 	/* Pixmaps subject to ModifyPixmapHeader will be pinned to system or
--	 * offscreen memory, so there's no need to track damage.
-+	 * gpu memory, so there's no need to track damage.
- 	 */
- 	if (pExaPixmap->pDamage) {
- 	    DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage);
-@@ -248,7 +249,7 @@ exaDestroyPixmap_classic (PixmapPtr pPixmap)
- }
- 
- Bool
--exaPixmapIsOffscreen_classic(PixmapPtr pPixmap)
-+exaPixmapHasGpuCopy_classic(PixmapPtr pPixmap)
- {
-     ScreenPtr pScreen = pPixmap->drawable.pScreen;
-     ExaScreenPriv(pScreen);
-@@ -260,7 +261,7 @@ exaPixmapIsOffscreen_classic(PixmapPtr pPixmap)
- 	ret = pExaScr->info->PixmapIsOffscreen(pPixmap);
- 	pPixmap->devPrivate.ptr = NULL;
-     } else
--	ret = (pExaPixmap->offscreen && pExaPixmap->fb_ptr);
-+	ret = (pExaPixmap->use_gpu_copy && pExaPixmap->fb_ptr);
- 
-     return ret;
- }
-diff --git a/exa/exa_driver.c b/exa/exa_driver.c
-index f55c300..abe79ba 100644
---- a/exa/exa_driver.c
-+++ b/exa/exa_driver.c
-@@ -71,8 +71,8 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
- 
-     bpp = pPixmap->drawable.bitsPerPixel;
- 
--    /* Set this before driver hooks, to allow for !offscreen pixmaps.
--     * !offscreen pixmaps have a valid pointer at all times.
-+    /* Set this before driver hooks, to allow for driver pixmaps without gpu
-+     * memory to back it. These pixmaps have a valid pointer at all times.
-      */
-     pPixmap->devPrivate.ptr = NULL;
- 
-@@ -126,7 +126,7 @@ Bool
- exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth,
- 		      int bitsPerPixel, int devKind, pointer pPixData)
- {
--    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-+    ScreenPtr pScreen;
-     ExaScreenPrivPtr pExaScr;
-     ExaPixmapPrivPtr pExaPixmap;
-     Bool ret;
-@@ -134,6 +134,7 @@ exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth
-     if (!pPixmap)
-         return FALSE;
- 
-+    pScreen = pPixmap->drawable.pScreen;
-     pExaScr = ExaGetScreenPriv(pScreen);
-     pExaPixmap = ExaGetPixmapPriv(pPixmap);
- 
-@@ -157,8 +158,9 @@ exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth
- 	ret = pExaScr->info->ModifyPixmapHeader(pPixmap, width, height, depth,
- 						bitsPerPixel, devKind, pPixData);
- 	/* For EXA_HANDLES_PIXMAPS, we set pPixData to NULL.
--	 * If pPixmap->devPrivate.ptr is non-NULL, then we've got a non-offscreen pixmap.
--	 * We need to store the pointer, because PrepareAccess won't be called.
-+	 * If pPixmap->devPrivate.ptr is non-NULL, then we've got a
-+	 * !has_gpu_copy pixmap. We need to store the pointer,
-+	 * because PrepareAccess won't be called.
- 	 */
- 	if (!pPixData && pPixmap->devPrivate.ptr && pPixmap->devKind) {
- 	    pExaPixmap->sys_ptr = pPixmap->devPrivate.ptr;
-@@ -208,7 +210,7 @@ exaDestroyPixmap_driver (PixmapPtr pPixmap)
- }
- 
- Bool
--exaPixmapIsOffscreen_driver(PixmapPtr pPixmap)
-+exaPixmapHasGpuCopy_driver(PixmapPtr pPixmap)
- {
-     ScreenPtr pScreen = pPixmap->drawable.pScreen;
-     ExaScreenPriv(pScreen);
-diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
-index bf097c3..b09db46 100644
---- a/exa/exa_glyphs.c
-+++ b/exa/exa_glyphs.c
-@@ -128,12 +128,12 @@ exaUnrealizeGlyphCaches(ScreenPtr    pScreen,
- 	}
- 
- 	if (cache->hashEntries) {
--	    xfree(cache->hashEntries);
-+	    free(cache->hashEntries);
- 	    cache->hashEntries = NULL;
- 	}
- 	
- 	if (cache->glyphs) {
--	    xfree(cache->glyphs);
-+	    free(cache->glyphs);
- 	    cache->glyphs = NULL;
- 	}
- 	cache->glyphCount = 0;
-@@ -213,8 +213,8 @@ exaRealizeGlyphCaches(ScreenPtr    pScreen,
- 
- 	cache->picture = pPicture;
- 	cache->picture->refcnt++;
--	cache->hashEntries = xalloc(sizeof(int) * cache->hashSize);
--	cache->glyphs = xalloc(sizeof(ExaCachedGlyphRec) * cache->size);
-+	cache->hashEntries = malloc(sizeof(int) * cache->hashSize);
-+	cache->glyphs = malloc(sizeof(ExaCachedGlyphRec) * cache->size);
- 	cache->glyphCount = 0;
- 
- 	if (!cache->hashEntries || !cache->glyphs)
-@@ -352,11 +352,11 @@ exaGlyphCacheHashRemove(ExaGlyphCachePtr cache,
- 
- /* The most efficient thing to way to upload the glyph to the screen
-  * is to use the UploadToScreen() driver hook; this allows us to
-- * pipeline glyph uploads and to avoid creating offscreen pixmaps for
-+ * pipeline glyph uploads and to avoid creating gpu backed pixmaps for
-  * glyphs that we'll never use again.
-  *
-- * If we can't do it with UploadToScreen (because the glyph is offscreen, etc),
-- * we fall back to CompositePicture.
-+ * If we can't do it with UploadToScreen (because the glyph has a gpu copy,
-+ * etc), we fall back to CompositePicture.
-  *
-  * We need to damage the cache pixmap manually in either case because the damage
-  * layer unwrapped the picture screen before calling exaGlyphs.
-@@ -364,7 +364,8 @@ exaGlyphCacheHashRemove(ExaGlyphCachePtr cache,
- static void
- exaGlyphCacheUploadGlyph(ScreenPtr         pScreen,
- 			 ExaGlyphCachePtr  cache,
--			 int               pos,
-+			 int               x,
-+			 int               y,
- 			 GlyphPtr          pGlyph)
- {
-     ExaScreenPriv(pScreen);
-@@ -378,7 +379,7 @@ exaGlyphCacheUploadGlyph(ScreenPtr         pScreen,
- 
-     /* If the glyph pixmap is already uploaded, no point in doing
-      * things this way */
--    if (exaPixmapIsOffscreen(pGlyphPixmap))
-+    if (exaPixmapHasGpuCopy(pGlyphPixmap))
- 	goto composite;
- 
-     /* UploadToScreen only works if bpp match */
-@@ -388,7 +389,7 @@ exaGlyphCacheUploadGlyph(ScreenPtr         pScreen,
-     if (pExaScr->do_migration) {
- 	ExaMigrationRec pixmaps[1];
- 
--	/* cache pixmap must be offscreen. */
-+	/* cache pixmap must have a gpu copy. */
- 	pixmaps[0].as_dst = TRUE;
- 	pixmaps[0].as_src = FALSE;
- 	pixmaps[0].pPix = pCachePixmap;
-@@ -396,13 +397,13 @@ exaGlyphCacheUploadGlyph(ScreenPtr         pScreen,
- 	exaDoMigration (pixmaps, 1, TRUE);
-     }
- 
--    if (!exaPixmapIsOffscreen(pCachePixmap))
-+    if (!exaPixmapHasGpuCopy(pCachePixmap))
- 	goto composite;
- 
--    /* CACHE_{X,Y} are in pixmap coordinates, no need for cache{X,Y}off */
-+    /* x,y are in pixmap coordinates, no need for cache{X,Y}off */
-     if (pExaScr->info->UploadToScreen(pCachePixmap,
--				      CACHE_X(pos),
--				      CACHE_Y(pos),
-+				      x,
-+				      y,
- 				      pGlyph->info.width,
- 				      pGlyph->info.height,
- 				      (char *)pExaPixmap->sys_ptr,
-@@ -416,18 +417,18 @@ composite:
- 		      cache->picture,
- 		      0, 0,
- 		      0, 0,
--		      CACHE_X(pos),
--		      CACHE_Y(pos),
-+		      x,
-+		      y,
- 		      pGlyph->info.width,
- 		      pGlyph->info.height);
- 
- damage:
-     /* The cache pixmap isn't a window, so no need to offset coordinates. */
-     exaPixmapDirty (pCachePixmap,
--		    CACHE_X(pos),
--		    CACHE_Y(pos),
--		    CACHE_X(pos) + cache->glyphWidth,
--		    CACHE_Y(pos) + cache->glyphHeight);
-+		    x,
-+		    y,
-+		    x + cache->glyphWidth,
-+		    y + cache->glyphHeight);
- }
- 
- static ExaGlyphCacheResult
-@@ -446,6 +447,7 @@ exaGlyphCacheBufferGlyph(ScreenPtr         pScreen,
- {
-     ExaCompositeRectPtr rect;
-     int pos;
-+    int x, y;
-     
-     if (buffer->mask && buffer->mask != cache->picture)
- 	return ExaGlyphNeedFlush;
-@@ -462,10 +464,14 @@ exaGlyphCacheBufferGlyph(ScreenPtr         pScreen,
-     pos = exaGlyphCacheHashLookup(cache, pGlyph);
-     if (pos != -1) {
- 	DBG_GLYPH_CACHE(("  found existing glyph at %d\n", pos));
-+	x = CACHE_X(pos);
-+	y = CACHE_Y(pos);
-     } else {
- 	if (cache->glyphCount < cache->size) {
- 	    /* Space remaining; we fill from the start */
- 	    pos = cache->glyphCount;
-+	    x = CACHE_X(pos);
-+	    y = CACHE_Y(pos);
- 	    cache->glyphCount++;
- 	    DBG_GLYPH_CACHE(("  storing glyph in free space at %d\n", pos));
- 
-@@ -477,14 +483,12 @@ exaGlyphCacheBufferGlyph(ScreenPtr         pScreen,
- 	     * the cache
- 	     */
- 	    pos = cache->evictionPosition;
-+	    x = CACHE_X(pos);
-+	    y = CACHE_Y(pos);
- 	    DBG_GLYPH_CACHE(("  evicting glyph at %d\n", pos));
- 	    if (buffer->count) {
--		int x, y;
- 		int i;
- 
--		x = CACHE_X(pos);
--		y = CACHE_Y(pos);
--
- 		for (i = 0; i < buffer->count; i++) {
- 		    if (pSrc ?
- 			(buffer->rects[i].xMask == x && buffer->rects[i].yMask == y) :
-@@ -503,7 +507,7 @@ exaGlyphCacheBufferGlyph(ScreenPtr         pScreen,
- 	    cache->evictionPosition = rand() % cache->size;
- 	}
- 
--	exaGlyphCacheUploadGlyph(pScreen, cache, pos, pGlyph);
-+	exaGlyphCacheUploadGlyph(pScreen, cache, x, y, pGlyph);
-     }
- 
-     buffer->mask = cache->picture;
-@@ -514,13 +518,13 @@ exaGlyphCacheBufferGlyph(ScreenPtr         pScreen,
-     {
- 	rect->xSrc = xSrc;
- 	rect->ySrc = ySrc;
--	rect->xMask = CACHE_X(pos);
--	rect->yMask = CACHE_Y(pos);
-+	rect->xMask = x;
-+	rect->yMask = y;
-     }
-     else
-     {
--	rect->xSrc = CACHE_X(pos);
--	rect->ySrc = CACHE_Y(pos);
-+	rect->xSrc = x;
-+	rect->ySrc = y;
- 	rect->xMask = 0;
- 	rect->yMask = 0;
-     }
-diff --git a/exa/exa_migration_classic.c b/exa/exa_migration_classic.c
-index 6d7b9f5..871679f 100644
---- a/exa/exa_migration_classic.c
-+++ b/exa/exa_migration_classic.c
-@@ -75,6 +75,9 @@ exaPixmapIsDirty (PixmapPtr pPix)
-     if (pExaPixmap == NULL)
- 	EXA_FatalErrorDebugWithRet(("EXA bug: exaPixmapIsDirty was called on a non-exa pixmap.\n"), TRUE);
- 
-+    if (!pExaPixmap->pDamage)
-+	return FALSE;
-+
-     return REGION_NOTEMPTY (pScreen, DamageRegion(pExaPixmap->pDamage)) ||
- 	!REGION_EQUAL(pScreen, &pExaPixmap->validSys, &pExaPixmap->validFB);
- }
-@@ -111,7 +114,7 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
-     ExaPixmapPriv (pPixmap);
-     RegionPtr damage = DamageRegion (pExaPixmap->pDamage);
-     RegionRec CopyReg;
--    Bool save_offscreen;
-+    Bool save_use_gpu_copy;
-     int save_pitch;
-     BoxPtr pBox;
-     int nbox;
-@@ -119,7 +122,7 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
-     Bool need_sync = FALSE;
- 
-     /* Damaged bits are valid in current copy but invalid in other one */
--    if (pExaPixmap->offscreen) {
-+    if (pExaPixmap->use_gpu_copy) {
- 	REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
- 		     damage);
- 	REGION_SUBTRACT(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
-@@ -200,9 +203,9 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
-     pBox = REGION_RECTS(&CopyReg);
-     nbox = REGION_NUM_RECTS(&CopyReg);
- 
--    save_offscreen = pExaPixmap->offscreen;
-+    save_use_gpu_copy = pExaPixmap->use_gpu_copy;
-     save_pitch = pPixmap->devKind;
--    pExaPixmap->offscreen = TRUE;
-+    pExaPixmap->use_gpu_copy = TRUE;
-     pPixmap->devKind = pExaPixmap->fb_pitch;
- 
-     while (nbox--) {
-@@ -242,7 +245,7 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
- 	pBox++;
-     }
- 
--    pExaPixmap->offscreen = save_offscreen;
-+    pExaPixmap->use_gpu_copy = save_use_gpu_copy;
-     pPixmap->devKind = save_pitch;
- 
-     /* Try to prevent source valid region from growing too many rects by
-@@ -351,7 +354,7 @@ exaDoMoveInPixmap (ExaMigrationPtr migrate)
- 
-     exaCopyDirtyToFb (migrate);
- 
--    if (exaPixmapIsOffscreen(pPixmap))
-+    if (exaPixmapHasGpuCopy(pPixmap))
- 	return;
- 
-     DBG_MIGRATE (("-> %p (0x%x) (%dx%d) (%c)\n", pPixmap,
-@@ -361,7 +364,7 @@ exaDoMoveInPixmap (ExaMigrationPtr migrate)
- 		  pPixmap->drawable.height,
- 		  exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
- 
--    pExaPixmap->offscreen = TRUE;
-+    pExaPixmap->use_gpu_copy = TRUE;
- 
-     pPixmap->devKind = pExaPixmap->fb_pitch;
-     pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-@@ -392,7 +395,7 @@ exaDoMoveOutPixmap (ExaMigrationPtr migrate)
- 
-     exaCopyDirtyToSys (migrate);
- 
--    if (exaPixmapIsOffscreen(pPixmap)) {
-+    if (exaPixmapHasGpuCopy(pPixmap)) {
- 
- 	DBG_MIGRATE (("<- %p (%p) (%dx%d) (%c)\n", pPixmap,
- 		      (void*)(ExaGetPixmapPriv(pPixmap)->area ?
-@@ -401,7 +404,7 @@ exaDoMoveOutPixmap (ExaMigrationPtr migrate)
- 		      pPixmap->drawable.height,
- 		      exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
- 
--	pExaPixmap->offscreen = FALSE;
-+	pExaPixmap->use_gpu_copy = FALSE;
- 
- 	pPixmap->devKind = pExaPixmap->sys_pitch;
- 	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-@@ -468,12 +471,12 @@ exaMigrateTowardFb (ExaMigrationPtr migrate)
- 	pExaPixmap->score++;
- 
-     if (pExaPixmap->score >= EXA_PIXMAP_SCORE_MOVE_IN &&
--	!exaPixmapIsOffscreen(pPixmap))
-+	!exaPixmapHasGpuCopy(pPixmap))
-     {
- 	exaDoMoveInPixmap(migrate);
-     }
- 
--    if (exaPixmapIsOffscreen(pPixmap)) {
-+    if (exaPixmapHasGpuCopy(pPixmap)) {
- 	exaCopyDirtyToFb (migrate);
- 	ExaOffscreenMarkUsed (pPixmap);
-     } else
-@@ -504,7 +507,7 @@ exaMigrateTowardSys (ExaMigrationPtr migrate)
-     if (pExaPixmap->score <= EXA_PIXMAP_SCORE_MOVE_OUT && pExaPixmap->area)
- 	exaDoMoveOutPixmap(migrate);
- 
--    if (exaPixmapIsOffscreen(pPixmap)) {
-+    if (exaPixmapHasGpuCopy(pPixmap)) {
- 	exaCopyDirtyToFb (migrate);
- 	ExaOffscreenMarkUsed (pPixmap);
-     } else
-@@ -523,7 +526,7 @@ exaAssertNotDirty (PixmapPtr pPixmap)
-     RegionRec ValidReg;
-     int dst_pitch, src_pitch, cpp, y, nbox, save_pitch;
-     BoxPtr pBox;
--    Bool ret = TRUE, save_offscreen;
-+    Bool ret = TRUE, save_use_gpu_copy;
- 
-     if (exaPixmapIsPinned(pPixmap) || pExaPixmap->area == NULL)
- 	return ret;
-@@ -542,9 +545,9 @@ exaAssertNotDirty (PixmapPtr pPixmap)
-     src_pitch = pExaPixmap->fb_pitch;
-     cpp = pPixmap->drawable.bitsPerPixel / 8;
- 
--    save_offscreen = pExaPixmap->offscreen;
-+    save_use_gpu_copy = pExaPixmap->use_gpu_copy;
-     save_pitch = pPixmap->devKind;
--    pExaPixmap->offscreen = TRUE;
-+    pExaPixmap->use_gpu_copy = TRUE;
-     pPixmap->devKind = pExaPixmap->fb_pitch;
- 
-     if (!ExaDoPrepareAccess(pPixmap, EXA_PREPARE_SRC))
-@@ -579,7 +582,7 @@ exaAssertNotDirty (PixmapPtr pPixmap)
- skip:
-     exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
- 
--    pExaPixmap->offscreen = save_offscreen;
-+    pExaPixmap->use_gpu_copy = save_use_gpu_copy;
-     pPixmap->devKind = save_pitch;
- 
- out:
-@@ -618,7 +621,7 @@ exaDoMigration_classic (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
-      */
-     for (i = 0; i < npixmaps; i++) {
- 	if (exaPixmapIsPinned (pixmaps[i].pPix) &&
--	    !exaPixmapIsOffscreen (pixmaps[i].pPix))
-+	    !exaPixmapHasGpuCopy (pixmaps[i].pPix))
- 	{
- 	    EXA_FALLBACK(("Pixmap %p (%dx%d) pinned in sys\n", pixmaps[i].pPix,
- 		      pixmaps[i].pPix->drawable.width,
-@@ -680,7 +683,7 @@ exaDoMigration_classic (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
- 	}
- 
- 	for (i = 0; i < npixmaps; i++) {
--	    if (exaPixmapIsOffscreen(pixmaps[i].pPix)) {
-+	    if (exaPixmapHasGpuCopy(pixmaps[i].pPix)) {
- 		/* Found one in FB, so move all to FB. */
- 		for (j = 0; j < npixmaps; j++)
- 		    exaMigrateTowardFb(pixmaps + i);
-@@ -709,12 +712,12 @@ exaDoMigration_classic (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
- 
- 	/* If we couldn't fit everything in, abort */
- 	for (i = 0; i < npixmaps; i++) {
--	    if (!exaPixmapIsOffscreen(pixmaps[i].pPix)) {
-+	    if (!exaPixmapHasGpuCopy(pixmaps[i].pPix)) {
- 		return;
- 	    }
- 	}
- 
--	/* Yay, everything's offscreen, mark memory as used */
-+	/* Yay, everything has a gpu copy, mark memory as used */
- 	for (i = 0; i < npixmaps; i++) {
- 	    ExaOffscreenMarkUsed (pixmaps[i].pPix);
- 	}
-diff --git a/exa/exa_migration_mixed.c b/exa/exa_migration_mixed.c
-index 52b18b4..fb47151 100644
---- a/exa/exa_migration_mixed.c
-+++ b/exa/exa_migration_mixed.c
-@@ -80,7 +80,7 @@ exaDoMigration_mixed(ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
-      */
-     for (i = 0; i < npixmaps; i++) {
- 	if (exaPixmapIsPinned (pixmaps[i].pPix) &&
--	    !exaPixmapIsOffscreen (pixmaps[i].pPix))
-+	    !exaPixmapHasGpuCopy (pixmaps[i].pPix))
- 	{
- 	    can_accel = FALSE;
- 	    break;
-@@ -98,12 +98,26 @@ exaDoMigration_mixed(ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
- 	if (!pExaPixmap->driverPriv)
- 	    exaCreateDriverPixmap_mixed(pPixmap);
- 
--	if (pExaPixmap->pDamage && exaPixmapIsOffscreen(pPixmap)) {
-+	if (pExaPixmap->pDamage && exaPixmapHasGpuCopy(pPixmap)) {
-+	    ExaScreenPriv(pPixmap->drawable.pScreen);
-+
-+	    /* This pitch is needed for proper acceleration. For some reason
-+	     * there are pixmaps without pDamage and a bad fb_pitch value.
-+	     * So setting devKind when only exaPixmapHasGpuCopy() is true
-+	     * causes corruption. Pixmaps without pDamage are not migrated
-+	     * and should have a valid devKind at all times, so that's why this
-+	     * isn't causing problems. Pixmaps have their gpu pitch set the
-+	     * first time in the MPH call from exaCreateDriverPixmap_mixed().
-+	     */
- 	    pPixmap->devKind = pExaPixmap->fb_pitch;
- 	    exaCopyDirtyToFb(pixmaps + i);
-+
-+	    if (pExaScr->deferred_mixed_pixmap == pPixmap &&
-+		!pixmaps[i].as_dst && !pixmaps[i].pReg)
-+		pExaScr->deferred_mixed_pixmap = NULL;
- 	}
- 
--	pExaPixmap->offscreen = exaPixmapIsOffscreen(pPixmap);
-+	pExaPixmap->use_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
-     }
- }
- 
-@@ -120,17 +134,68 @@ exaMoveInPixmap_mixed(PixmapPtr pPixmap)
-     exaDoMigration(pixmaps, 1, TRUE);
- }
- 
-+void
-+exaDamageReport_mixed(DamagePtr pDamage, RegionPtr pRegion, void *closure)
-+{
-+    PixmapPtr pPixmap = closure;
-+    ExaPixmapPriv(pPixmap);
-+
-+    /* Move back results of software rendering on system memory copy of mixed driver
-+     * pixmap (see exaPrepareAccessReg_mixed).
-+     *
-+     * Defer moving the destination back into the driver pixmap, to try and save
-+     * overhead on multiple subsequent software fallbacks.
-+     */
-+    if (!pExaPixmap->use_gpu_copy && exaPixmapHasGpuCopy(pPixmap)) {
-+	ExaScreenPriv(pPixmap->drawable.pScreen);
-+
-+	if (pExaScr->deferred_mixed_pixmap &&
-+	    pExaScr->deferred_mixed_pixmap != pPixmap)
-+	    exaMoveInPixmap_mixed(pExaScr->deferred_mixed_pixmap);
-+	pExaScr->deferred_mixed_pixmap = pPixmap;
-+    }
-+}
-+
- /* With mixed pixmaps, if we fail to get direct access to the driver pixmap, we
-  * use the DownloadFromScreen hook to retrieve contents to a copy in system
-  * memory, perform software rendering on that and move back the results with the
-- * UploadToScreen hook (see exaFinishAccess_mixed).
-+ * UploadToScreen hook (see exaDamageReport_mixed).
-  */
- void
- exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
- {
--    if (!ExaDoPrepareAccess(pPixmap, index)) {
--	ExaPixmapPriv(pPixmap);
--	Bool is_offscreen = exaPixmapIsOffscreen(pPixmap);
-+    ExaPixmapPriv(pPixmap);
-+    Bool has_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
-+    Bool success;
-+
-+    success = ExaDoPrepareAccess(pPixmap, index);
-+
-+    if (success && has_gpu_copy && pExaPixmap->pDamage) {
-+	/* You cannot do accelerated operations while a buffer is mapped. */
-+	exaFinishAccess(&pPixmap->drawable, index);
-+	/* Update the gpu view of both deferred destination pixmaps and of
-+	 * source pixmaps that were migrated with a bounding region.
-+	 */
-+	exaMoveInPixmap_mixed(pPixmap);
-+	success = ExaDoPrepareAccess(pPixmap, index);
-+
-+	if (success) {
-+	    /* We have a gpu pixmap that can be accessed, we don't need the cpu
-+	     * copy anymore. Drivers that prefer DFS, should fail prepare
-+	     * access.
-+	     */
-+	    DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage);
-+	    DamageDestroy(pExaPixmap->pDamage);
-+	    pExaPixmap->pDamage = NULL;
-+
-+	    free(pExaPixmap->sys_ptr);
-+	    pExaPixmap->sys_ptr = NULL;
-+
-+	    return;
-+	}
-+    }
-+
-+    if (!success) {
- 	ExaMigrationRec pixmaps[1];
- 
- 	/* Do we need to allocate our system buffer? */
-@@ -152,12 +217,14 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
- 	pixmaps[0].pPix = pPixmap;
- 	pixmaps[0].pReg = pReg;
- 
--	if (!pExaPixmap->pDamage && (is_offscreen || !exaPixmapIsPinned(pPixmap))) {
-+	if (!pExaPixmap->pDamage &&
-+		(has_gpu_copy || !exaPixmapIsPinned(pPixmap))) {
- 	    Bool as_dst = pixmaps[0].as_dst;
- 
- 	    /* Set up damage tracking */
--	    pExaPixmap->pDamage = DamageCreate(NULL, NULL, DamageReportNone,
--					       TRUE, pPixmap->drawable.pScreen,
-+	    pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,
-+					       DamageReportNonEmpty, TRUE,
-+					       pPixmap->drawable.pScreen,
- 					       pPixmap);
- 
- 	    DamageRegister(&pPixmap->drawable, pExaPixmap->pDamage);
-@@ -165,7 +232,7 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
- 	    /* This is used by exa to optimize migration. */
- 	    DamageSetReportAfterOp(pExaPixmap->pDamage, TRUE);
- 
--	    if (is_offscreen) {
-+	    if (has_gpu_copy) {
- 		exaPixmapDirty(pPixmap, 0, 0, pPixmap->drawable.width,
- 			       pPixmap->drawable.height);
- 
-@@ -177,34 +244,18 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
- 		    pixmaps[0].as_src = TRUE;
- 		    pixmaps[0].pReg = NULL;
- 		}
--		pPixmap->devKind = pExaPixmap->fb_pitch;
- 		exaCopyDirtyToSys(pixmaps);
- 	    }
- 
- 	    if (as_dst)
- 		exaPixmapDirty(pPixmap, 0, 0, pPixmap->drawable.width,
- 			       pPixmap->drawable.height);
--	} else if (is_offscreen) {
--	    pPixmap->devKind = pExaPixmap->fb_pitch;
-+	} else if (has_gpu_copy)
- 	    exaCopyDirtyToSys(pixmaps);
--	}
- 
- 	pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
- 	pPixmap->devKind = pExaPixmap->sys_pitch;
--	pExaPixmap->offscreen = FALSE;
-+	pExaPixmap->use_gpu_copy = FALSE;
-     }
- }
- 
--/* Move back results of software rendering on system memory copy of mixed driver
-- * pixmap (see exaPrepareAccessReg_mixed).
-- */
--void exaFinishAccess_mixed(PixmapPtr pPixmap, int index)
--{
--    ExaPixmapPriv(pPixmap);
--
--    if (pExaPixmap->pDamage && exaPixmapIsOffscreen(pPixmap) &&
--	!pExaPixmap->offscreen) {
--	DamageRegionProcessPending(&pPixmap->drawable);
--	exaMoveInPixmap_mixed(pPixmap);
--    }
--}
-diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
-index 47adad7..49e04f2 100644
---- a/exa/exa_mixed.c
-+++ b/exa/exa_mixed.c
-@@ -93,9 +93,25 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
-     /* A scratch pixmap will become a driver pixmap right away. */
-     if (!w || !h) {
- 	exaCreateDriverPixmap_mixed(pPixmap);
--	pExaPixmap->offscreen = exaPixmapIsOffscreen(pPixmap);
--    } else
--	pExaPixmap->offscreen = FALSE;
-+	pExaPixmap->use_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
-+    } else {
-+	pExaPixmap->use_gpu_copy = FALSE;
-+
-+	if (w == 1 && h == 1) {
-+	    pExaPixmap->sys_ptr = malloc((pPixmap->drawable.bitsPerPixel + 7) / 8);
-+
-+	    /* Set up damage tracking */
-+	    pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,
-+					       DamageReportNonEmpty, TRUE,
-+					       pPixmap->drawable.pScreen,
-+					       pPixmap);
-+
-+	    DamageRegister(&pPixmap->drawable, pExaPixmap->pDamage);
-+	    /* This ensures that pending damage reflects the current operation. */
-+	    /* This is used by exa to optimize migration. */
-+	    DamageSetReportAfterOp(pExaPixmap->pDamage, TRUE);
-+	}
-+    }
- 
-     /* During a fallback we must prepare access. */
-     if (pExaScr->fallback_counter)
-@@ -108,14 +124,15 @@ Bool
- exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
- 		      int bitsPerPixel, int devKind, pointer pPixData)
- {
--    ScreenPtr pScreen = pPixmap->drawable.pScreen;
-+    ScreenPtr pScreen;
-     ExaScreenPrivPtr pExaScr;
-     ExaPixmapPrivPtr pExaPixmap;
--    Bool ret, is_offscreen;
-+    Bool ret, has_gpu_copy;
- 
-     if (!pPixmap)
-         return FALSE;
- 
-+    pScreen = pPixmap->drawable.pScreen;
-     pExaScr = ExaGetScreenPriv(pScreen);
-     pExaPixmap = ExaGetPixmapPriv(pPixmap);
- 
-@@ -131,22 +148,58 @@ exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
- 	    pExaPixmap->driverPriv = NULL;
- 	}
- 
--	pExaPixmap->offscreen = FALSE;
-+	pExaPixmap->use_gpu_copy = FALSE;
- 	pExaPixmap->score = EXA_PIXMAP_SCORE_PINNED;
-     }
- 
--    if (pExaPixmap->driverPriv) {
--        if (width > 0 && height > 0 && bitsPerPixel > 0) {
-+    has_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
-+
-+    if (width <= 0)
-+	width = pPixmap->drawable.width;
-+
-+    if (height <= 0)
-+	height = pPixmap->drawable.height;
-+
-+    if (bitsPerPixel <= 0) {
-+	if (depth <= 0)
-+	    bitsPerPixel = pPixmap->drawable.bitsPerPixel;
-+	else
-+	    bitsPerPixel = BitsPerPixel(depth);
-+    }
-+
-+    if (depth <= 0)
-+	depth = pPixmap->drawable.depth;
-+
-+    if (width != pPixmap->drawable.width ||
-+	height != pPixmap->drawable.height ||
-+	depth != pPixmap->drawable.depth ||
-+	bitsPerPixel != pPixmap->drawable.bitsPerPixel) {
-+	if (pExaPixmap->driverPriv) {
-             exaSetFbPitch(pExaScr, pExaPixmap,
-                           width, height, bitsPerPixel);
- 
-             exaSetAccelBlock(pExaScr, pExaPixmap,
-                              width, height, bitsPerPixel);
-+            REGION_EMPTY(pScreen, &pExaPixmap->validFB);
-         }
-+
-+	/* Need to re-create system copy if there's also a GPU copy */
-+	if (has_gpu_copy && pExaPixmap->sys_ptr) {
-+	    free(pExaPixmap->sys_ptr);
-+	    pExaPixmap->sys_ptr = NULL;
-+	    pExaPixmap->sys_pitch = devKind > 0 ? devKind :
-+	        PixmapBytePad(width, depth);
-+	    DamageUnregister(&pPixmap->drawable, pExaPixmap->pDamage);
-+	    DamageDestroy(pExaPixmap->pDamage);
-+	    pExaPixmap->pDamage = NULL;
-+	    REGION_EMPTY(pScreen, &pExaPixmap->validSys);
-+
-+	    if (pExaScr->deferred_mixed_pixmap == pPixmap)
-+		pExaScr->deferred_mixed_pixmap = NULL;
-+	}
-     }
- 
--    is_offscreen = exaPixmapIsOffscreen(pPixmap);
--    if (is_offscreen) {
-+    if (has_gpu_copy) {
- 	pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
- 	pPixmap->devKind = pExaPixmap->fb_pitch;
-     } else {
-@@ -168,7 +221,7 @@ exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
-     swap(pExaScr, pScreen, ModifyPixmapHeader);
- 
- out:
--    if (is_offscreen) {
-+    if (has_gpu_copy) {
- 	pExaPixmap->fb_ptr = pPixmap->devPrivate.ptr;
- 	pExaPixmap->fb_pitch = pPixmap->devKind;
-     } else {
-@@ -196,6 +249,9 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap)
- 	if (pExaScr->fallback_counter)
- 	    exaFinishAccess(&pPixmap->drawable, -1);
- 
-+	if (pExaScr->deferred_mixed_pixmap == pPixmap)
-+	    pExaScr->deferred_mixed_pixmap = NULL;
-+
- 	if (pExaPixmap->driverPriv)
- 	    pExaScr->info->DestroyPixmap(pScreen, pExaPixmap->driverPriv);
- 	pExaPixmap->driverPriv = NULL;
-@@ -216,7 +272,7 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap)
- }
- 
- Bool
--exaPixmapIsOffscreen_mixed(PixmapPtr pPixmap)
-+exaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap)
- {
-     ScreenPtr pScreen = pPixmap->drawable.pScreen;
-     ExaScreenPriv(pScreen);
-diff --git a/exa/exa_offscreen.c b/exa/exa_offscreen.c
-index 2ec4174..5abe3b8 100644
---- a/exa/exa_offscreen.c
-+++ b/exa/exa_offscreen.c
-@@ -245,7 +245,7 @@ exaOffscreenAlloc (ScreenPtr pScreen, int size, int align,
-     /* save extra space in new area */
-     if (real_size < area->size)
-     {
--	ExaOffscreenArea   *new_area = xalloc (sizeof (ExaOffscreenArea));
-+	ExaOffscreenArea   *new_area = malloc(sizeof (ExaOffscreenArea));
- 	if (!new_area)
- 	    return NULL;
- 	new_area->base_offset = area->base_offset;
-@@ -408,7 +408,7 @@ ExaOffscreenMerge (ExaScreenPrivPtr pExaScr, ExaOffscreenArea *area)
- 	area->next->prev = area;
-     else
- 	pExaScr->info->offScreenAreas->prev = area;
--    xfree (next);
-+    free(next);
- 
-     pExaScr->numOffscreenAvailable--;
- }
-@@ -499,7 +499,7 @@ ExaOffscreenDefragment (ScreenPtr pScreen)
- 	return NULL;
- 
-     pExaDstPix = ExaGetPixmapPriv (pDstPix);
--    pExaDstPix->offscreen = TRUE;
-+    pExaDstPix->use_gpu_copy = TRUE;
- 
-     for (area = pExaScr->info->offScreenAreas->prev;
- 	 area != pExaScr->info->offScreenAreas;
-@@ -508,7 +508,7 @@ ExaOffscreenDefragment (ScreenPtr pScreen)
- 	ExaOffscreenArea *prev = area->prev;
- 	PixmapPtr pSrcPix;
- 	ExaPixmapPrivPtr pExaSrcPix;
--	Bool save_offscreen;
-+	Bool save_use_gpu_copy;
- 	int save_pitch;
- 
- 	if (area->state != ExaOffscreenAvail ||
-@@ -553,10 +553,10 @@ ExaOffscreenDefragment (ScreenPtr pScreen)
- 	    continue;
- 	}
- 
--	save_offscreen = pExaSrcPix->offscreen;
-+	save_use_gpu_copy = pExaSrcPix->use_gpu_copy;
- 	save_pitch = pSrcPix->devKind;
- 
--	pExaSrcPix->offscreen = TRUE;
-+	pExaSrcPix->use_gpu_copy = TRUE;
- 	pSrcPix->devKind = pExaSrcPix->fb_pitch;
- 
- 	pDstPix->drawable.width = pSrcPix->drawable.width;
-@@ -566,7 +566,7 @@ ExaOffscreenDefragment (ScreenPtr pScreen)
- 	pDstPix->drawable.bitsPerPixel = pSrcPix->drawable.bitsPerPixel;
- 
- 	if (!pExaScr->info->PrepareCopy (pSrcPix, pDstPix, -1, -1, GXcopy, ~0)) {
--	    pExaSrcPix->offscreen = save_offscreen;
-+	    pExaSrcPix->use_gpu_copy = save_use_gpu_copy;
- 	    pSrcPix->devKind = save_pitch;
- 	    area = prev;
- 	    continue;
-@@ -623,7 +623,7 @@ ExaOffscreenDefragment (ScreenPtr pScreen)
- #endif
- 
- 	pExaSrcPix->fb_ptr = pExaDstPix->fb_ptr;
--	pExaSrcPix->offscreen = save_offscreen;
-+	pExaSrcPix->use_gpu_copy = save_use_gpu_copy;
- 	pSrcPix->devKind = save_pitch;
-     }
- 
-@@ -655,7 +655,7 @@ exaOffscreenInit (ScreenPtr pScreen)
-     ExaOffscreenArea *area;
- 
-     /* Allocate a big free area */
--    area = xalloc (sizeof (ExaOffscreenArea));
-+    area = malloc(sizeof (ExaOffscreenArea));
- 
-     if (!area)
- 	return FALSE;
-@@ -691,6 +691,6 @@ ExaOffscreenFini (ScreenPtr pScreen)
-     while ((area = pExaScr->info->offScreenAreas))
-     {
- 	pExaScr->info->offScreenAreas = area->next;
--	xfree (area);
-+	free(area);
-     }
- }
-diff --git a/exa/exa_priv.h b/exa/exa_priv.h
-index 7d035d4..14c99e9 100644
---- a/exa/exa_priv.h
-+++ b/exa/exa_priv.h
-@@ -50,10 +50,8 @@
- #include "dix.h"
- #include "fb.h"
- #include "fboverlay.h"
--#ifdef RENDER
- #include "fbpict.h"
- #include "glyphstr.h"
--#endif
- #include "damage.h"
- 
- #define DEBUG_TRACE_FALL	0
-@@ -165,19 +163,17 @@ typedef struct {
-     BitmapToRegionProcPtr        SavedBitmapToRegion;
-     CreateScreenResourcesProcPtr SavedCreateScreenResources;
-     ModifyPixmapHeaderProcPtr    SavedModifyPixmapHeader;
--#ifdef RENDER
-+    SourceValidateProcPtr        SavedSourceValidate;
-     CompositeProcPtr             SavedComposite;
-     TrianglesProcPtr		 SavedTriangles;
-     GlyphsProcPtr                SavedGlyphs;
-     TrapezoidsProcPtr            SavedTrapezoids;
-     AddTrapsProcPtr		 SavedAddTraps;
--#endif
-     void (*do_migration) (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
--    Bool (*pixmap_is_offscreen) (PixmapPtr pPixmap);
-+    Bool (*pixmap_has_gpu_copy) (PixmapPtr pPixmap);
-     void (*do_move_in_pixmap) (PixmapPtr pPixmap);
-     void (*do_move_out_pixmap) (PixmapPtr pPixmap);
-     void (*prepare_access_reg)(PixmapPtr pPixmap, int index, RegionPtr pReg);
--    void (*finish_access)(PixmapPtr pPixmap, int index);
- 
-     Bool			 swappedOut;
-     enum ExaMigrationHeuristic	 migration;
-@@ -188,11 +184,13 @@ typedef struct {
-     unsigned			 numOffscreenAvailable;
-     CARD32			 lastDefragment;
-     CARD32			 nextDefragment;
-+    PixmapPtr			 deferred_mixed_pixmap;
- 
-     /* Reference counting for accessed pixmaps */
-     struct {
- 	PixmapPtr pixmap;
- 	int count;
-+	Bool retval;
-     } access[EXA_NUM_PREPARE_INDICES];
- 
-     /* Holds information on fallbacks that cannot be relayed otherwise. */
-@@ -200,6 +198,15 @@ typedef struct {
-     unsigned int fallback_counter;
- 
-     ExaGlyphCacheRec             glyphCaches[EXA_NUM_GLYPH_CACHES];
-+
-+    /**
-+     * Regions affected by fallback composite source / mask operations.
-+     */
-+
-+    RegionRec srcReg;
-+    RegionRec maskReg;
-+    PixmapPtr srcPix;
-+
- } ExaScreenPrivRec, *ExaScreenPrivPtr;
- 
- /*
-@@ -282,7 +289,7 @@ extern DevPrivateKey exaGCPrivateKey;
- typedef struct {
-     ExaOffscreenArea *area;
-     int		    score;	/**< score for the move-in vs move-out heuristic */
--    Bool	    offscreen;
-+    Bool	    use_gpu_copy;
- 
-     CARD8	    *sys_ptr;	/**< pointer to pixmap data in system memory */
-     int		    sys_pitch;	/**< pitch of pixmap in system memory */
-@@ -488,7 +495,6 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable,
- 
- extern const GCOps exaOps;
- 
--#ifdef RENDER
- void
- ExaCheckComposite (CARD8      op,
- 		  PicturePtr pSrc,
-@@ -502,7 +508,17 @@ ExaCheckComposite (CARD8      op,
- 		  INT16      yDst,
- 		  CARD16     width,
- 		  CARD16     height);
--#endif
-+
-+void
-+ExaCheckGlyphs (CARD8	      op,
-+		PicturePtr    pSrc,
-+		PicturePtr    pDst,
-+		PictFormatPtr maskFormat,
-+		INT16	      xSrc,
-+		INT16	      ySrc,
-+		int	      nlist,
-+		GlyphListPtr  list,
-+		GlyphPtr      *glyphs);
- 
- /* exa_offscreen.c */
- void
-@@ -538,7 +554,7 @@ exaGetDrawableDeltas (DrawablePtr pDrawable, PixmapPtr pPixmap,
- 		      int *xp, int *yp);
- 
- Bool
--exaPixmapIsOffscreen(PixmapPtr p);
-+exaPixmapHasGpuCopy(PixmapPtr p);
- 
- PixmapPtr
- exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
-@@ -575,7 +591,7 @@ Bool
- exaDestroyPixmap_classic (PixmapPtr pPixmap);
- 
- Bool
--exaPixmapIsOffscreen_classic(PixmapPtr pPixmap);
-+exaPixmapHasGpuCopy_classic(PixmapPtr pPixmap);
- 
- /* exa_driver.c */
- PixmapPtr
-@@ -590,7 +606,7 @@ Bool
- exaDestroyPixmap_driver (PixmapPtr pPixmap);
- 
- Bool
--exaPixmapIsOffscreen_driver(PixmapPtr pPixmap);
-+exaPixmapHasGpuCopy_driver(PixmapPtr pPixmap);
- 
- /* exa_mixed.c */
- PixmapPtr
-@@ -605,7 +621,7 @@ Bool
- exaDestroyPixmap_mixed(PixmapPtr pPixmap);
- 
- Bool
--exaPixmapIsOffscreen_mixed(PixmapPtr pPixmap);
-+exaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap);
- 
- /* exa_migration_mixed.c */
- void
-@@ -618,10 +634,10 @@ void
- exaMoveInPixmap_mixed(PixmapPtr pPixmap);
- 
- void
--exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg);
-+exaDamageReport_mixed(DamagePtr pDamage, RegionPtr pRegion, void *closure);
- 
- void
--exaFinishAccess_mixed(PixmapPtr pPixmap, int index);
-+exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg);
- 
- /* exa_render.c */
- Bool
-diff --git a/exa/exa_render.c b/exa/exa_render.c
-index db355d6..b7f383f 100644
---- a/exa/exa_render.c
-+++ b/exa/exa_render.c
-@@ -30,7 +30,6 @@
- 
- #include "exa_priv.h"
- 
--#ifdef RENDER
- #include "mipict.h"
- 
- #if DEBUG_TRACE_FALL
-@@ -320,7 +319,7 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
- 	exaDoMigration(pixmaps, 1, TRUE);
-     }
- 
--    if (!exaPixmapIsOffscreen(pDstPix)) {
-+    if (!exaPixmapHasGpuCopy(pDstPix)) {
- 	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
- 	return 0;
-     }
-@@ -540,7 +539,7 @@ exaCompositeRects(CARD8	              op,
- 	/* We have to manage the damage ourselves, since CompositeRects isn't
- 	 * something in the screen that can be managed by the damage extension,
- 	 * and EXA depends on damage to track what needs to be migrated between
--	 * offscreen and onscreen.
-+	 * the gpu and the cpu.
- 	 */
- 
- 	/* Compute the overall extents of the composited region - we're making
-@@ -752,7 +751,7 @@ exaTryDriverComposite(CARD8		op,
- 	}
-     }
- 
--    if (!exaPixmapIsOffscreen(pDstPix)) {
-+    if (!exaPixmapHasGpuCopy(pDstPix)) {
- 	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
- 	return 0;
-     }
-@@ -1072,7 +1071,6 @@ done:
-     if (pMask)
- 	pMask->repeat = saveMaskRepeat;
- }
--#endif
- 
- /**
-  * Same as miCreateAlphaPicture, except it uses ExaCheckPolyFillRect instead
-diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
-index 9bc765a..402d76d 100644
---- a/exa/exa_unaccel.c
-+++ b/exa/exa_unaccel.c
-@@ -23,9 +23,7 @@
- 
- #include "exa_priv.h"
- 
--#ifdef RENDER
- #include "mipict.h"
--#endif
- 
- /*
-  * These functions wrap the low-level fb rendering functions and
-@@ -123,11 +121,36 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst,  GCPtr pGC,
- 	     BoxPtr	pbox, int nbox, int dx, int dy, Bool	reverse, 
- 	     Bool upsidedown, Pixel bitplane, void *closure)
- {
-+    RegionRec reg;
-+    int xoff, yoff;
-     EXA_PRE_FALLBACK_GC(pGC);
-     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
- 		  exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
--    exaPrepareAccess (pDst, EXA_PREPARE_DEST);
--    exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
-+
-+    if (pExaScr->prepare_access_reg) {
-+	PixmapPtr pPixmap = exaGetDrawablePixmap(pSrc);
-+
-+	exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
-+	REGION_INIT(pScreen, &reg, pbox, nbox);
-+	REGION_TRANSLATE(pScreen, &reg, xoff + dx, yoff + dy);
-+	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, &reg);
-+	REGION_UNINIT(pScreen, &reg);
-+    } else
-+	exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
-+
-+    if (pExaScr->prepare_access_reg &&
-+	!exaGCReadsDestination(pDst, pGC->planemask, pGC->fillStyle,
-+			       pGC->alu, pGC->clientClipType)) {
-+	PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
-+
-+	exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
-+	REGION_INIT(pScreen, &reg, pbox, nbox);
-+	REGION_TRANSLATE(pScreen, &reg, xoff, yoff);
-+	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, &reg);
-+	REGION_UNINIT(pScreen, &reg);
-+    } else
-+	exaPrepareAccess (pDst, EXA_PREPARE_DEST);
-+
-     /* This will eventually call fbCopyNtoN, with some calculation overhead. */
-     while (nbox--) {
- 	pGC->ops->CopyArea (pSrc, pDst, pGC, pbox->x1 - pSrc->x + dx, pbox->y1 - pSrc->y + dy, 
-@@ -139,6 +162,40 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst,  GCPtr pGC,
-     EXA_POST_FALLBACK_GC(pGC);
- }
- 
-+static void
-+ExaFallbackPrepareReg(DrawablePtr pDrawable,
-+		      GCPtr pGC,
-+		      int x, int y, int width, int height,
-+		      int index, Bool checkReads)
-+{
-+    ScreenPtr pScreen = pDrawable->pScreen;
-+    ExaScreenPriv(pScreen);
-+
-+    if (pExaScr->prepare_access_reg &&
-+	!(checkReads && exaGCReadsDestination(pDrawable,
-+					      pGC->planemask,
-+					      pGC->fillStyle,
-+					      pGC->alu,
-+					      pGC->clientClipType))) {
-+	BoxRec box;
-+	RegionRec reg;
-+	int xoff, yoff;
-+	PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
-+
-+	exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
-+	box.x1 = pDrawable->x + x + xoff;
-+	box.y1 = pDrawable->y + y + yoff;
-+	box.x2 = box.x1 + width;
-+	box.y2 = box.y1 + height;
-+
-+	REGION_INIT(pScreen, &reg, &box, 1);
-+	pExaScr->prepare_access_reg(pPixmap, index, &reg);
-+	REGION_UNINIT(pScreen, &reg);
-+    } else
-+	exaPrepareAccess(pDrawable, index);
-+}
-+
-+
- RegionPtr
- ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- 		 int srcx, int srcy, int w, int h, int dstx, int dsty)
-@@ -148,8 +205,10 @@ ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
-     EXA_PRE_FALLBACK_GC(pGC);
-     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
- 		  exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
--    exaPrepareAccess (pDst, EXA_PREPARE_DEST);
--    exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
-+    ExaFallbackPrepareReg(pSrc, pGC, srcx, srcy, w, h,
-+			  EXA_PREPARE_SRC, FALSE);
-+    ExaFallbackPrepareReg(pDst, pGC, dstx, dsty, w, h,
-+			  EXA_PREPARE_DEST, TRUE);
-     ret = pGC->ops->CopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
-     exaFinishAccess (pSrc, EXA_PREPARE_SRC);
-     exaFinishAccess (pDst, EXA_PREPARE_DEST);
-@@ -168,8 +227,10 @@ ExaCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
-     EXA_PRE_FALLBACK_GC(pGC);
-     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
- 		  exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
--    exaPrepareAccess (pDst, EXA_PREPARE_DEST);
--    exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
-+    ExaFallbackPrepareReg(pSrc, pGC, srcx, srcy, w, h,
-+			  EXA_PREPARE_SRC, FALSE);
-+    ExaFallbackPrepareReg(pDst, pGC, dstx, dsty, w, h,
-+			  EXA_PREPARE_DEST, TRUE);
-     ret = pGC->ops->CopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
- 		       bitPlane);
-     exaFinishAccess (pSrc, EXA_PREPARE_SRC);
-@@ -295,8 +356,10 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
-     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pBitmap, pDrawable,
- 		  exaDrawableLocation(&pBitmap->drawable),
- 		  exaDrawableLocation(pDrawable)));
--    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
--    exaPrepareAccess (&pBitmap->drawable, EXA_PREPARE_SRC);
-+    ExaFallbackPrepareReg(pDrawable, pGC, x, y, w, h,
-+			  EXA_PREPARE_DEST, TRUE);
-+    ExaFallbackPrepareReg(&pBitmap->drawable, pGC, 0, 0, w, h,
-+			  EXA_PREPARE_SRC, FALSE);
-     exaPrepareAccessGC (pGC);
-     pGC->ops->PushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
-     exaFinishAccessGC (pGC);
-@@ -313,8 +376,18 @@ ExaCheckCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-     EXA_PRE_FALLBACK(pScreen);
-     EXA_FALLBACK(("from %p\n", pWin));
- 
--    /* being both src and dest, src is safest. */
--    exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
-+    /* Only need the source bits, the destination region will be overwritten */
-+    if (pExaScr->prepare_access_reg) {
-+	PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
-+	int xoff, yoff;
-+
-+	exaGetDrawableDeltas(&pWin->drawable, pPixmap, &xoff, &yoff);
-+	REGION_TRANSLATE(pScreen, prgnSrc, xoff, yoff);
-+	pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, prgnSrc);
-+	REGION_TRANSLATE(pScreen, prgnSrc, -xoff, -yoff);
-+    } else
-+	exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
-+
-     swap(pExaScr, pScreen, CopyWindow);
-     pScreen->CopyWindow (pWin, ptOldOrg, prgnSrc);
-     swap(pExaScr, pScreen, CopyWindow);
-@@ -327,29 +400,12 @@ ExaCheckGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
- 		unsigned int format, unsigned long planeMask, char *d)
- {
-     ScreenPtr pScreen = pDrawable->pScreen;
--    PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
-     EXA_PRE_FALLBACK(pScreen);
-     EXA_FALLBACK(("from %p (%c)\n", pDrawable,
- 		  exaDrawableLocation(pDrawable)));
- 
--    if (pExaScr->prepare_access_reg) {
--	int xoff, yoff;
--	BoxRec Box;
--	RegionRec Reg;
--
--	exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);
--
--	Box.x1 = pDrawable->y + x + xoff;
--	Box.y1 = pDrawable->y + y + yoff;
--	Box.x2 = Box.x1 + w;
--	Box.y2 = Box.y1 + h;
--
--	REGION_INIT(pScreen, &Reg, &Box, 1);
--
--	pExaScr->prepare_access_reg(pPix, EXA_PREPARE_SRC, &Reg);
--    } else
--	exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
--
-+    ExaFallbackPrepareReg(pDrawable, NULL, x, y, w, h,
-+			  EXA_PREPARE_SRC, FALSE);
-     swap(pExaScr, pScreen, GetImage);
-     pScreen->GetImage (pDrawable, x, y, w, h, format, planeMask, d);
-     swap(pExaScr, pScreen, GetImage);
-@@ -377,6 +433,175 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
-     EXA_POST_FALLBACK(pScreen);
- }
- 
-+static void
-+ExaSrcValidate(DrawablePtr pDrawable,
-+	       int x,
-+	       int y,
-+	       int width,
-+	       int height)
-+{
-+    ScreenPtr pScreen = pDrawable->pScreen;
-+    ExaScreenPriv(pScreen);
-+    PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
-+    BoxRec box;
-+    RegionRec reg;
-+    RegionPtr dst;
-+    int xoff, yoff;
-+
-+    exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);
-+
-+    box.x1 = x + xoff;
-+    box.y1 = y + yoff;
-+    box.x2 = box.x1 + width;
-+    box.y2 = box.y1 + height;
-+
-+    dst = (pExaScr->srcPix == pPix) ? &pExaScr->srcReg :
-+	&pExaScr->maskReg;
-+
-+    REGION_INIT(pScreen, &reg, &box, 1);
-+    REGION_UNION(pScreen, dst, dst, &reg);
-+    REGION_UNINIT(pScreen, &reg);
-+
-+    if (pExaScr->SavedSourceValidate) {
-+        swap(pExaScr, pScreen, SourceValidate);
-+        pScreen->SourceValidate(pDrawable, x, y, width, height);
-+        swap(pExaScr, pScreen, SourceValidate);
-+    }
-+}
-+
-+static Bool
-+ExaPrepareCompositeReg(ScreenPtr  pScreen,
-+		       CARD8      op,
-+		       PicturePtr pSrc,
-+		       PicturePtr pMask,
-+		       PicturePtr pDst,
-+		       INT16      xSrc,
-+		       INT16      ySrc,
-+		       INT16      xMask,
-+		       INT16      yMask,
-+		       INT16      xDst,
-+		       INT16      yDst,
-+		       CARD16     width,
-+		       CARD16     height)
-+{
-+    RegionRec region;
-+    RegionPtr dstReg = NULL;
-+    RegionPtr srcReg = NULL;
-+    RegionPtr maskReg = NULL;
-+    PixmapPtr pSrcPix = NULL;
-+    PixmapPtr pMaskPix = NULL;
-+    PixmapPtr pDstPix;
-+    ExaScreenPriv(pScreen);
-+    Bool ret;
-+
-+
-+    REGION_NULL(pScreen, &region);
-+
-+    if (pSrc->pDrawable) {
-+	pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
-+	REGION_NULL(pScreen, &pExaScr->srcReg);
-+	srcReg = &pExaScr->srcReg;
-+	pExaScr->srcPix = pSrcPix;
-+	if (pSrc != pDst)
-+	    REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
-+			     -pSrc->pDrawable->x,
-+			     -pSrc->pDrawable->y);
-+    }
-+
-+    if (pMask && pMask->pDrawable) {
-+	pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
-+	REGION_NULL(pScreen, &pExaScr->maskReg);
-+	maskReg = &pExaScr->maskReg;
-+	if (pMask != pDst && pMask != pSrc)
-+	    REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
-+			     -pMask->pDrawable->x,
-+			     -pMask->pDrawable->y);
-+    }
-+
-+    REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
-+		     -pDst->pDrawable->x,
-+		     -pDst->pDrawable->y);
-+
-+    pExaScr->SavedSourceValidate = ExaSrcValidate;
-+    swap(pExaScr, pScreen, SourceValidate);
-+    ret = miComputeCompositeRegion (&region, pSrc, pMask, pDst,
-+				    xSrc, ySrc, xMask, yMask,
-+				    xDst,
-+				    yDst,
-+				    width, height);
-+    swap(pExaScr, pScreen, SourceValidate);
-+
-+    REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
-+		     pDst->pDrawable->x,
-+		     pDst->pDrawable->y);
-+    if (pSrc->pDrawable && pSrc != pDst)
-+	REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
-+			 pSrc->pDrawable->x,
-+			 pSrc->pDrawable->y);
-+    if (pMask && pMask->pDrawable && pMask != pDst && pMask != pSrc)
-+	REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
-+			 pMask->pDrawable->x,
-+			 pMask->pDrawable->y);
-+
-+    if (!ret) {
-+	if (srcReg)
-+	    REGION_UNINIT(pScreen, srcReg);
-+	if (maskReg)
-+	    REGION_UNINIT(pScreen, maskReg);
-+
-+	return FALSE;
-+    }
-+
-+    /**
-+     * Don't limit alphamaps readbacks for now until we've figured out how that
-+     * should be done.
-+     */
-+
-+    if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
-+	pExaScr->prepare_access_reg(exaGetDrawablePixmap(pSrc->alphaMap->pDrawable),
-+				    EXA_PREPARE_AUX_SRC,
-+				    NULL);
-+    if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
-+	pExaScr->prepare_access_reg(exaGetDrawablePixmap(pMask->alphaMap->pDrawable),
-+				    EXA_PREPARE_AUX_MASK,
-+				    NULL);
-+
-+    if (pSrcPix)
-+	pExaScr->prepare_access_reg(pSrcPix,
-+				    EXA_PREPARE_SRC,
-+				    srcReg);
-+
-+    if (pMaskPix)
-+	pExaScr->prepare_access_reg(pMaskPix,
-+				    EXA_PREPARE_MASK,
-+				    maskReg);
-+
-+    if (srcReg)
-+	REGION_UNINIT(pScreen, srcReg);
-+    if (maskReg)
-+	REGION_UNINIT(pScreen, maskReg);
-+
-+    pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
-+    if (!exaOpReadsDestination(op)) {
-+	int xoff;
-+	int yoff;
-+
-+	exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &xoff, &yoff);
-+	REGION_TRANSLATE(pScreen, &region, pDst->pDrawable->x + xoff,
-+			 pDst->pDrawable->y + yoff);
-+	dstReg = &region;
-+    }
-+
-+    if (pDst->alphaMap && pDst->alphaMap->pDrawable)
-+	pExaScr->prepare_access_reg(exaGetDrawablePixmap(pDst->alphaMap->pDrawable),
-+				    EXA_PREPARE_AUX_DEST,
-+				    dstReg);
-+    pExaScr->prepare_access_reg(pDstPix, EXA_PREPARE_DEST, dstReg);
-+
-+    REGION_UNINIT(pScreen, &region);
-+    return TRUE;
-+}
-+
- void
- ExaCheckComposite (CARD8      op,
-                    PicturePtr pSrc,
-@@ -392,56 +617,39 @@ ExaCheckComposite (CARD8      op,
-                    CARD16     height)
- {
-     ScreenPtr pScreen = pDst->pDrawable->pScreen;
--#ifdef RENDER
-     PictureScreenPtr	ps = GetPictureScreen(pScreen);
--#endif /* RENDER */
--    RegionRec region;
--    int xoff, yoff;
-     EXA_PRE_FALLBACK(pScreen);
- 
--    REGION_NULL(pScreen, &region);
--
--    /* We need to prepare access to any separate alpha maps first, in case the
--     * driver doesn't support EXA_PREPARE_AUX*, in which case EXA_PREPARE_SRC
--     * may be used for moving them out.
--     */
--    if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
--	exaPrepareAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
--    if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
--	exaPrepareAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
--
--    if (!exaOpReadsDestination(op) && pExaScr->prepare_access_reg) {
--	PixmapPtr pDstPix;
--
--	if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
--				       xSrc, ySrc, xMask, yMask, xDst, yDst,
--				       width, height))
--	    goto skip;
--
--	pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
--	exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &xoff, &yoff);
--	REGION_TRANSLATE(pScreen, &region, xoff, yoff);
-+    if (pExaScr->prepare_access_reg) {
-+	if (!ExaPrepareCompositeReg(pScreen, op, pSrc, pMask, pDst, xSrc,
-+				   ySrc, xMask, yMask, xDst, yDst, width,
-+				   height))
-+	    goto out_no_clip;
-+    } else {
- 
--	if (pDst->alphaMap && pDst->alphaMap->pDrawable)
--	    pExaScr->prepare_access_reg(exaGetDrawablePixmap(pDst->alphaMap->pDrawable),
--					EXA_PREPARE_AUX_DEST, &region);
-+	/* We need to prepare access to any separate alpha maps first,
-+	 * in case the driver doesn't support EXA_PREPARE_AUX*,
-+	 * in which case EXA_PREPARE_SRC may be used for moving them out.
-+	 */
- 
--	pExaScr->prepare_access_reg(pDstPix, EXA_PREPARE_DEST, &region);
--    } else {
-+	if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
-+	    exaPrepareAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
-+	if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
-+	    exaPrepareAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
- 	if (pDst->alphaMap && pDst->alphaMap->pDrawable)
- 	    exaPrepareAccess(pDst->alphaMap->pDrawable, EXA_PREPARE_AUX_DEST);
- 
- 	exaPrepareAccess (pDst->pDrawable, EXA_PREPARE_DEST);
--    }
- 
--    EXA_FALLBACK(("from picts %p/%p to pict %p\n",
--		 pSrc, pMask, pDst));
-+	EXA_FALLBACK(("from picts %p/%p to pict %p\n",
-+		      pSrc, pMask, pDst));
-+
-+	if (pSrc->pDrawable != NULL)
-+	    exaPrepareAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
-+	if (pMask && pMask->pDrawable != NULL)
-+	    exaPrepareAccess (pMask->pDrawable, EXA_PREPARE_MASK);
-+    }
- 
--    if (pSrc->pDrawable != NULL)
--	exaPrepareAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
--    if (pMask && pMask->pDrawable != NULL)
--	exaPrepareAccess (pMask->pDrawable, EXA_PREPARE_MASK);
--#ifdef RENDER
-     swap(pExaScr, ps, Composite);
-     ps->Composite (op,
-                  pSrc,
-@@ -456,7 +664,6 @@ ExaCheckComposite (CARD8      op,
-                  width,
-                  height);
-     swap(pExaScr, ps, Composite);
--#endif /* RENDER */
-     if (pMask && pMask->pDrawable != NULL)
- 	exaFinishAccess (pMask->pDrawable, EXA_PREPARE_MASK);
-     if (pSrc->pDrawable != NULL)
-@@ -464,14 +671,34 @@ ExaCheckComposite (CARD8      op,
-     exaFinishAccess (pDst->pDrawable, EXA_PREPARE_DEST);
-     if (pDst->alphaMap && pDst->alphaMap->pDrawable)
- 	exaFinishAccess(pDst->alphaMap->pDrawable, EXA_PREPARE_AUX_DEST);
--
--skip:
-     if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
- 	exaFinishAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
-     if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
- 	exaFinishAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
- 
--    REGION_UNINIT(pScreen, &region);
-+out_no_clip:
-+    EXA_POST_FALLBACK(pScreen);
-+}
-+
-+/**
-+ * Avoid migration ping-pong when using a mask.
-+ */
-+void
-+ExaCheckGlyphs (CARD8	      op,
-+		PicturePtr    pSrc,
-+		PicturePtr    pDst,
-+		PictFormatPtr maskFormat,
-+		INT16	      xSrc,
-+		INT16	      ySrc,
-+		int	      nlist,
-+		GlyphListPtr  list,
-+		GlyphPtr      *glyphs)
-+{
-+    ScreenPtr pScreen = pDst->pDrawable->pScreen;
-+    EXA_PRE_FALLBACK(pScreen);
-+
-+    miGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
-+
-     EXA_POST_FALLBACK(pScreen);
- }
- 
-@@ -483,19 +710,15 @@ ExaCheckAddTraps (PicturePtr	pPicture,
- 		  xTrap		*traps)
- {
-     ScreenPtr pScreen = pPicture->pDrawable->pScreen;
--#ifdef RENDER
-     PictureScreenPtr	ps = GetPictureScreen(pScreen);
--#endif /* RENDER */
-     EXA_PRE_FALLBACK(pScreen);
- 
-     EXA_FALLBACK(("to pict %p (%c)\n",
- 		  exaDrawableLocation(pPicture->pDrawable)));
-     exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
--#ifdef RENDER
-     swap(pExaScr, ps, AddTraps);
-     ps->AddTraps (pPicture, x_off, y_off, ntrap, traps);
-     swap(pExaScr, ps, AddTraps);
--#endif /* RENDER */
-     exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
-     EXA_POST_FALLBACK(pScreen);
- }
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-fix-randr-rotation.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-fix-randr-rotation.patch
deleted file mode 100644
index 191d4f9..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-fix-randr-rotation.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-From d66172eb30398176ee64eaf5841887c76cbac06f Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Mon, 21 Jun 2010 09:55:39 +1000
-Subject: [PATCH] rotation: fix cursor and overlap of one pixel.
-
-Commit 77c7a64e8885696665556c9fbcb3cffb552e367a was introduced to fix a cursor off by one on Intel hw, however it also move the whole crtc into an off by one
-position and you could see gnom-eshell overlapping.
-
-This commit reverts that and instead fixes the cursor hotspot translation to
-work like pixman does. We add 0.5 to the cursor vector before translating,
-and floor the value afterwards.
-
-Thanks to Soeren (ssp) for pointing out where the real problem was after explaning how pixman translates points.
-
-Signed-off-by: Dave Airlie <airlied@redhat.com>
----
- hw/xfree86/modes/xf86Cursors.c |    9 ++++++---
- randr/rrtransform.c            |   28 ++++++++++++++--------------
- 2 files changed, 20 insertions(+), 17 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
-index 385848b..483f62d 100644
---- a/hw/xfree86/modes/xf86Cursors.c
-+++ b/hw/xfree86/modes/xf86Cursors.c
-@@ -327,10 +327,13 @@ xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
- 						  xf86CursorScreenKey);
- 	struct pict_f_vector   v;
- 
--	v.v[0] = x + ScreenPriv->HotX; v.v[1] = y + ScreenPriv->HotY; v.v[2] = 1;
-+	v.v[0] = (x + ScreenPriv->HotX) + 0.5;
-+	v.v[1] = (y + ScreenPriv->HotY) + 0.5;
-+	v.v[2] = 1;
- 	pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
--	x = floor (v.v[0] + 0.5);
--	y = floor (v.v[1] + 0.5);
-+	/* cursor will have 0.5 added to it already so floor is sufficent */
-+	x = floor (v.v[0]);
-+	y = floor (v.v[1]);
- 	/*
- 	 * Transform position of cursor upper left corner
- 	 */
-diff --git a/randr/rrtransform.c b/randr/rrtransform.c
-index 06f6298..53de3b8 100644
---- a/randr/rrtransform.c
-+++ b/randr/rrtransform.c
-@@ -185,21 +185,21 @@ RRTransformCompute (int			    x,
- 	    break;
- 	case RR_Rotate_90:
- 	    f_rot_cos = 0;	    f_rot_sin = 1;
--	    f_rot_dx  = height-1;   f_rot_dy  = 0;
-+	    f_rot_dx  = height;	    f_rot_dy  = 0;
- 	    rot_cos = F ( 0);	    rot_sin = F ( 1);
--	    rot_dx =  F (height-1); rot_dy  = F (0);
-+	    rot_dx =  F ( height);  rot_dy  = F (0);
- 	    break;
- 	case RR_Rotate_180:
- 	    f_rot_cos = -1;	    f_rot_sin = 0;
--	    f_rot_dx  = width - 1;  f_rot_dy  = height - 1;
-+	    f_rot_dx  = width;	    f_rot_dy  = height;
- 	    rot_cos = F (-1);	    rot_sin = F ( 0);
--	    rot_dx  = F (width-1);  rot_dy  = F ( height-1);
-+	    rot_dx  = F (width);   rot_dy  = F ( height);
- 	    break;
- 	case RR_Rotate_270:
- 	    f_rot_cos = 0;	    f_rot_sin = -1;
--	    f_rot_dx  = 0;	    f_rot_dy  = width-1;
-+	    f_rot_dx  = 0;	    f_rot_dy  = width;
- 	    rot_cos = F ( 0);	    rot_sin = F (-1);
--	    rot_dx  = F ( 0);	    rot_dy  = F ( width-1);
-+	    rot_dx  = F ( 0);	    rot_dy  = F ( width);
- 	    break;
- 	}
- 	
-@@ -222,11 +222,11 @@ RRTransformCompute (int			    x,
- 	    f_scale_x = -1;
- 	    scale_x = F(-1);
- 	    if (rotation & (RR_Rotate_0|RR_Rotate_180)) {
--		f_scale_dx = width-1;
--		scale_dx = F(width-1);
-+		f_scale_dx = width;
-+		scale_dx = F(width);
- 	    } else {
--		f_scale_dx = height-1;
--		scale_dx = F(height-1);
-+		f_scale_dx = height;
-+		scale_dx = F(height);
- 	    }
- 	}
- 	if (rotation & RR_Reflect_Y)
-@@ -234,11 +234,11 @@ RRTransformCompute (int			    x,
- 	    f_scale_y = -1;
- 	    scale_y = F(-1);
- 	    if (rotation & (RR_Rotate_0|RR_Rotate_180)) {
--		f_scale_dy = height-1;
--		scale_dy = F(height-1);
-+		f_scale_dy = height;
-+		scale_dy = F(height);
- 	    } else {
--		f_scale_dy = width-1;
--		scale_dy = F(width-1);
-+		f_scale_dy = width;
-+		scale_dy = F(width);
- 	    }
- 	}
- 	
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-improve-mode-selection.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-improve-mode-selection.patch
deleted file mode 100644
index e637573..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-improve-mode-selection.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From 6a18acbe113c5ce0108fb07bcd6cc5aeefcc5f6f Mon Sep 17 00:00:00 2001
-From: Olivier Fourdan <ofourdan@redhat.com>
-Date: Wed, 23 Jun 2010 15:01:08 -0400
-Subject: [PATCH] modes: improve aspect ratio match for classic drivers
-
-The X server tries to infer the aspect ratio of the screen, and estimates the
-virtual size of the screen as the largest mode in the combined list of modes
-given then runs through the mode list checking it against the sync ranges from
-the monitor and the driver's ValidMode hook.
-In doing so it might filter away all modes that exactly match the earlier
-aspect ratio guess in which case the server picks the mode with the next most
-area by pixel count.
-
-The following patch changes the logic, and instead of picking the largest
-area, it looks first in the builtin modes, the driver modes and at last the
-rest of modes which includes the default modes.
-
-This way, if there is no mode matching the initial mode, we do not end up
-picking a random mode and prefer instead a user defined or a monitor mode.
-
-As the virtual size is changed, the line pitch also needs to be recalculated.
----
- hw/xfree86/common/xf86Mode.c |   64 ++++++++++++++++++++++++++++++++++++++---
- 1 files changed, 59 insertions(+), 5 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
-index 4a948d7..da50b27 100644
---- a/hw/xfree86/common/xf86Mode.c
-+++ b/hw/xfree86/common/xf86Mode.c
-@@ -1665,8 +1665,6 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- 	numModes++;
-     }
- 
--#undef _VIRTUALX
--
-     /*
-      * If we estimated the virtual size above, we may have filtered away all
-      * the modes that maximally match that size; scan again to find out and
-@@ -1681,13 +1679,69 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- 	    }
- 	}
- 	if (vx < virtX || vy < virtY) {
-+	    const int types[] = {
-+		M_T_BUILTIN | M_T_PREFERRED,
-+		M_T_BUILTIN,
-+		M_T_DRIVER | M_T_PREFERRED,
-+		M_T_DRIVER,
-+		0
-+	    };
-+	    const int ntypes = sizeof(types) / sizeof(int);
-+	    int n;
-+
-+	    /*
-+	     * We did not find the estimated virtual size. So now we want to
-+	     * find the largest mode available, but we want to search in the
-+	     * modes in the order of "types" listed above.
-+	     */
-+	    for (n = 0; n < ntypes; n++) {
-+		int type = types[n];
-+
-+		vx = 0; vy = 0;
-+		for (p = scrp->modes; p; p = p->next) {
-+		    /* scan through the modes in the sort order above */
-+		    if ((p->type & type) != type)
-+			continue;
-+		    if (p->HDisplay > vx && p->VDisplay > vy) {
-+			vx = p->HDisplay;
-+			vy = p->VDisplay;
-+		    }
-+		}
-+		if (vx && vy)
-+		    /* Found one */
-+		    break;
-+	    }
- 	    xf86DrvMsg(scrp->scrnIndex, X_WARNING,
- 		       "Shrinking virtual size estimate from %dx%d to %dx%d\n",
- 		       virtX, virtY, vx, vy);
--	    virtX = vx;
-+	    virtX = _VIRTUALX(vx);
- 	    virtY = vy;
--	    linePitch = miScanLineWidth(vx, vy, minPitch, apertureSize,
--					BankFormat, pitchInc);
-+	    for (p = scrp->modes; p; p = p->next) {
-+		if (numModes > 0) {
-+		    if (p->HDisplay > virtX)
-+			p->status = MODE_VIRTUAL_X;
-+		    if (p->VDisplay > virtY)
-+			p->status = MODE_VIRTUAL_Y;
-+		    if (p->status != MODE_OK) {
-+			numModes--;
-+			printModeRejectMessage(scrp->scrnIndex, p, p->status);
-+		    }
-+		}
-+	    }
-+	    if (linePitches != NULL) {
-+		for (i = 0; linePitches[i] != 0; i++) {
-+		    if ((linePitches[i] >= virtX) &&
-+			(linePitches[i] ==
-+			miScanLineWidth(virtX, virtY, linePitches[i],
-+					apertureSize, BankFormat, pitchInc))) {
-+			linePitch = linePitches[i];
-+			break;
-+		    }
-+		}
-+	    } else {
-+		linePitch = miScanLineWidth(virtX, virtY, minPitch,
-+					    apertureSize, BankFormat, pitchInc);
-+	    }
- 	}
-     }
- 
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-int10-reserved-areas.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-int10-reserved-areas.patch
deleted file mode 100644
index e30d9b0..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-int10-reserved-areas.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-From 4a315630356aa7f4d99ded9d2e61f134dcde61d1 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 13 Jul 2010 12:06:40 -0400
-Subject: [PATCH] int10: Map up to one e820 reserved area if it looks like we need it
-
-Apparently some sandybridge machines put the int10 vector into code
-that's below 0xa0000.  Nice work guys.
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- hw/xfree86/int10/generic.c    |   11 ++++-
- hw/xfree86/int10/helper_mem.c |   98 ++++++++++++++++++++++++++++++++++++++---
- 2 files changed, 100 insertions(+), 9 deletions(-)
-
-diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
-index 9d39e99..7ca2100 100644
---- a/hw/xfree86/int10/generic.c
-+++ b/hw/xfree86/int10/generic.c
-@@ -394,9 +394,16 @@ xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
- # define HIGH_BASE   SYS_BIOS
- #endif
- # define SYS(addr) ((addr) >= HIGH_OFFSET)
-+
-+extern void *rht_reserved_range;
-+extern CARD32 rht_reserved_low, rht_reserved_high;
-+
- #define V_ADDR(addr) \
--	  (SYS(addr) ? ((char*)INTPriv(pInt)->sysMem) + (addr - HIGH_BASE) \
--	   : (((char*)(INTPriv(pInt)->base) + addr)))
-+	  (SYS(addr) ? \
-+	      ((char*)INTPriv(pInt)->sysMem) + (addr - HIGH_BASE) : \
-+	       ((rht_reserved_range && addr >= rht_reserved_low && addr <= rht_reserved_high) ? \
-+		((char *)rht_reserved_range + (addr - rht_reserved_low)) : \
-+		((char*)(INTPriv(pInt)->base) + addr)))
- #define VRAM_ADDR(addr) (addr - V_RAM)
- #define VRAM_BASE (INTPriv(pInt)->vRam)
- 
-diff --git a/hw/xfree86/int10/helper_mem.c b/hw/xfree86/int10/helper_mem.c
-index 6f6ecc2..c4f20d8 100644
---- a/hw/xfree86/int10/helper_mem.c
-+++ b/hw/xfree86/int10/helper_mem.c
-@@ -9,6 +9,12 @@
- 
- #include <string.h>
- #include <stdlib.h>
-+#include <stdio.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <sys/mman.h>
-+#include <unistd.h>
-+#include <fcntl.h>
- 
- #include "xf86.h"
- #include "xf86_OSproc.h"
-@@ -281,15 +287,92 @@ xf86int10GetBiosLocationType(const xf86Int10InfoPtr pInt)
-     return location_type;
- }
- 
-+/*
-+ * This should be in the Int10Priv, but we can't get there from here.
-+ * And it's a horrible layering violation to be setting up maps _here_
-+ * instead of from the xf86ExtendedInitInt10 top level, but it's a
-+ * rather large refactor to do that.
-+ *
-+ * Namespaced to avoid collisions with drivers, not that that's likely.
-+ */
-+_X_EXPORT void *rht_reserved_range;
-+_X_EXPORT CARD32 rht_reserved_low, rht_reserved_high;
-+
-+#define rht_align(x) ((x) & ~4095)
-+
-+static Bool
-+check_segment(xf86Int10InfoPtr pInt, CARD32 x)
-+{
-+    int fd, low, high;
-+    char *b, buf[1024];
- 
--#define CHECK_V_SEGMENT_RANGE(x)   \
--    if (((x) << 4) < V_BIOS) { \
--	xf86DrvMsg(pInt->scrnIndex, X_ERROR, \
--		   "V_BIOS address 0x%lx out of range\n", \
--		   (unsigned long)(x) << 4); \
--	return FALSE; \
-+    x <<= 4;
-+
-+    if (x >= V_BIOS)
-+	return TRUE;
-+
-+    fd = open("/proc/iomem", O_RDONLY);
-+    if (fd == -1)
-+	goto out;
-+
-+    read(fd, buf, sizeof(buf));
-+    close(fd);
-+    buf[1023] = '\0';
-+
-+    b = buf;
-+    while (1) {
-+	char junk[80];
-+	if (sscanf(b, " %x-%x : %s", &low, &high, junk) != 3)
-+	    break;
-+
-+	if (low >= (1 << 20))
-+	    break;
-+
-+	if (low && x >= low && x <= high && !strncmp(junk, "reserved", 8)) {
-+	    /* oh god, here we go */
-+	    int mem;
-+
-+	    if (rht_reserved_range) {
-+		if (rht_reserved_low == rht_align(low) && rht_reserved_high == high)
-+		    /* re-map, probably server regen, no problem */
-+		    return TRUE;
-+		xf86DrvMsg(pInt->scrnIndex, X_ERROR,
-+			   "Multiple reserved ranges. Please file a bug\n");
-+		return FALSE;
-+	    }
-+
-+	    mem = open("/dev/mem", O_RDWR);
-+	    if (mem == -1)
-+		return FALSE;
-+
-+	    rht_reserved_range = mmap(NULL, high + 1 - rht_align(low),
-+				      PROT_READ | PROT_WRITE,
-+				      MAP_SHARED, mem, rht_align(low));
-+	    close(mem);
-+	    if (rht_reserved_range == MAP_FAILED) {
-+		xf86DrvMsg(pInt->scrnIndex, X_ERROR,
-+			   "Failed to map reserved region at 0x%x\n", low);
-+		return FALSE;
-+	    }
-+
-+	    rht_reserved_low = rht_align(low);
-+	    rht_reserved_high = high;
-+
-+	    return TRUE;
-+	}
-+
-+	b = strchr(b + 1, '\n');
-+	if (!b)
-+	    break;
-     }
- 
-+out:
-+    xf86DrvMsg(pInt->scrnIndex, X_ERROR, "V_BIOS address 0x%lx out of range\n",
-+	       (unsigned long)(x));
-+
-+    return FALSE;
-+}
-+
- Bool
- xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base)
- {
-@@ -310,7 +393,8 @@ xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base)
- 
- 	cs = segments[i];
- 
--	CHECK_V_SEGMENT_RANGE(cs);
-+	if (!check_segment(pInt, cs))
-+	    return FALSE;
- 	vbiosMem = (unsigned char *)base + (cs << 4);
- 	if (int10_check_bios(pInt->scrnIndex, cs, vbiosMem)) {
- 	    break;
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-lid-hack.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-lid-hack.patch
deleted file mode 100644
index 9cf1f44..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-lid-hack.patch
+++ /dev/null
@@ -1,130 +0,0 @@
-From a7083389e14221c0ed6bff00e4006b9a0b1f7e4d Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Tue, 27 Jul 2010 14:56:29 -0400
-Subject: [PATCH] modes: Account for lid status, sometimes, if the devil chicken says so
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- hw/xfree86/modes/xf86Crtc.c |   80 ++++++++++++++++++++++++++++++++++++++----
- 1 files changed, 72 insertions(+), 8 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
-index 06d1fc2..7a849e1 100644
---- a/hw/xfree86/modes/xf86Crtc.c
-+++ b/hw/xfree86/modes/xf86Crtc.c
-@@ -32,6 +32,11 @@
- #include <stddef.h>
- #include <string.h>
- #include <stdio.h>
-+#include <glob.h>
-+#include <unistd.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
- 
- #include "xf86.h"
- #include "xf86DDC.h"
-@@ -1515,11 +1520,44 @@ GuessRangeFromModes(MonPtr mon, DisplayModePtr mode)
-        mon->vrefresh[0].lo = 58.0;
- }
- 
-+static int
-+lvds_lid_status(void)
-+{
-+    glob_t g = {0, };
-+    int ret = XF86OutputStatusConnected;
-+#ifdef linux
-+    int fd;
-+    char buf[80];
-+
-+    memset(buf, '\0', sizeof(buf));
-+
-+    if (glob("/proc/acpi/button/lid/*/state", GLOB_NOSORT, NULL, &g) != 0)
-+	goto out;
-+
-+    if (g.gl_pathc != 1)
-+	goto out;
-+
-+    fd = open(g.gl_pathv[0], O_RDONLY);
-+    if (fd == -1)
-+	goto out;
-+
-+    read(fd, buf, sizeof(buf)-1);
-+    close(fd);
-+    if (strstr(buf, "closed"))
-+	ret = XF86OutputStatusDisconnected;
-+#endif
-+
-+out:
-+    globfree(&g);
-+    return ret;
-+}
-+
- void
- xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
- {
-     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
-     int			o;
-+    int			num_connected = 0;
- 
-     /* When canGrow was TRUE in the initial configuration we have to
-      * compare against the maximum values so that we don't drop modes.
-@@ -1531,6 +1569,40 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
- 	maxY = config->maxHeight;
-     }
- 
-+    /* clean the mode list */
-+    for (o = 0; o < config->num_output; o++)
-+    {
-+	xf86OutputPtr output = config->output[o];
-+	while (output->probed_modes != NULL)
-+	    xf86DeleteMode(&output->probed_modes, output->probed_modes);
-+    }
-+
-+    /* scan for connectivity */
-+    for (o = 0; o < config->num_output; o++)
-+    {
-+	xf86OutputPtr output = config->output[o];
-+	output->status = output->funcs->detect(output);
-+
-+	if (output->status == XF86OutputStatusConnected)
-+	    num_connected++;
-+    }
-+
-+    /*
-+     * Hack for LVDS/eDP.  We want to consider these disconnected if the
-+     * lid is closed, but only if more than one output is connected (lest
-+     * we darken the only available output, since lid status is unreliable)
-+     */
-+    if (num_connected > 1)
-+    {
-+	for (o = 0; o < config->num_output; o++)
-+	{
-+	    xf86OutputPtr output = config->output[o];
-+	    if (strstr(output->name, "LVDS") || strstr(output->name, "eDP"))
-+		if (output->status == XF86OutputStatusConnected)
-+		    output->status = lvds_lid_status();
-+	}
-+    }
-+
-     /* Probe the list of modes for each output. */
-     for (o = 0; o < config->num_output; o++) 
-     {
-@@ -1547,14 +1619,6 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
- 	Bool                add_default_modes;
- 	enum { sync_config, sync_edid, sync_default } sync_source = sync_default;
- 	
--	while (output->probed_modes != NULL)
--	    xf86DeleteMode(&output->probed_modes, output->probed_modes);
--
--	/*
--	 * Check connection status
--	 */
--	output->status = (*output->funcs->detect)(output);
--
- 	if (output->status == XF86OutputStatusDisconnected)
- 	{
- 	    xf86OutputSetEDID (output, NULL);
--- 
-1.7.1.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-make-ephyr-resize.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-make-ephyr-resize.patch
deleted file mode 100644
index 189cbc7..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-make-ephyr-resize.patch
+++ /dev/null
@@ -1,176 +0,0 @@
-From 4822319b9d771f54bc26cec7a9941c6e60202d63 Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <airlied@redhat.com>
-Date: Wed, 23 Jun 2010 15:55:00 +1000
-Subject: [PATCH] make ephyr resizeable (600505)
-
-Author is Vic Lee
-taken from
-https://bugs.freedesktop.org/show_bug.cgi?id=25804
-
----
- hw/kdrive/ephyr/ephyr.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++
- hw/kdrive/ephyr/hostx.c |   24 +++++++++++++---------
- hw/kdrive/ephyr/hostx.h |   10 ++++++++-
- 3 files changed, 72 insertions(+), 11 deletions(-)
-
-diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
-index 254fcbc..14ab591 100644
---- a/hw/kdrive/ephyr/ephyr.c
-+++ b/hw/kdrive/ephyr/ephyr.c
-@@ -578,6 +578,8 @@ ephyrRandRSetConfig (ScreenPtr		pScreen,
-   if (wasEnabled)
-     KdEnableScreen (pScreen);
-   
-+  RRScreenSizeNotify(pScreen);
-+
-   return TRUE;
-   
-  bail4:
-@@ -610,6 +612,45 @@ ephyrRandRInit (ScreenPtr pScreen)
-   pScrPriv->rrSetConfig = ephyrRandRSetConfig;
-   return TRUE;
- }
-+
-+static Bool
-+ephyrResizeScreen (ScreenPtr		pScreen,
-+		   int			newwidth,
-+		   int			newheight)
-+{
-+  KdScreenPriv(pScreen);
-+  KdScreenInfo	*screen    = pScreenPriv->screen;
-+  RRScreenSize	size	   = {0};
-+  Bool		ret;
-+  int		t;
-+
-+  if (screen->randr & (RR_Rotate_90|RR_Rotate_270))
-+    {
-+      t = newwidth;
-+      newwidth = newheight;
-+      newheight = t;
-+    }
-+
-+  if (newwidth == screen->width && newheight == screen->height)
-+    {
-+      return FALSE;
-+    }
-+
-+  size.width = newwidth;
-+  size.height = newheight;
-+
-+  ret = ephyrRandRSetConfig (pScreen, screen->randr, 0, &size);
-+  if (ret)
-+    {
-+      RROutputPtr output;
-+
-+      output = RRFirstOutput(pScreen);
-+      if (!output) return FALSE;
-+      RROutputSetModes(output, NULL, 0, 0);
-+    }
-+
-+  return ret;
-+}
- #endif
- 
- Bool
-@@ -1008,6 +1049,14 @@ ephyrPoll(void)
- 	  break;
- #endif /* XF86DRI */
- 
-+#ifdef RANDR
-+	case EPHYR_EV_CONFIGURE:
-+	  ephyrResizeScreen (screenInfo.screens[ev.data.configure.screen],
-+			     ev.data.configure.width,
-+			     ev.data.configure.height);
-+	  break;
-+#endif /* RANDR */
-+
- 	default:
- 	  break;
- 	}
-diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
-index d546370..cdb019d 100644
---- a/hw/kdrive/ephyr/hostx.c
-+++ b/hw/kdrive/ephyr/hostx.c
-@@ -348,7 +348,8 @@ hostx_init (void)
-     |PointerMotionMask
-     |KeyPressMask
-     |KeyReleaseMask
--    |ExposureMask;
-+    |ExposureMask
-+    |StructureNotifyMask;
- 
-   EPHYR_DBG("mark");
- 
-@@ -642,7 +643,6 @@ hostx_screen_init (EphyrScreenInfo screen,
- {
-   int         bitmap_pad;
-   Bool        shm_success = False;
--  XSizeHints *size_hints;
- 
-   struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
-   if (!host_screen)
-@@ -729,14 +729,6 @@ hostx_screen_init (EphyrScreenInfo screen,
- 
-   XResizeWindow (HostX.dpy, host_screen->win, width, height);
- 
--  /* Ask the WM to keep our size static */
--  size_hints = XAllocSizeHints();
--  size_hints->max_width = size_hints->min_width = width;
--  size_hints->max_height = size_hints->min_height = height;
--  size_hints->flags = PMinSize|PMaxSize;
--  XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
--  XFree(size_hints);
--
-   XMapWindow(HostX.dpy, host_screen->win);
- 
-   XSync(HostX.dpy, False);
-@@ -1054,6 +1046,18 @@ hostx_get_event(EphyrHostXEvent *ev)
- 	  ev->data.key_up.scancode = xev.xkey.keycode;
- 	  return 1;
- 
-+	case ConfigureNotify:
-+	  {
-+	    struct EphyrHostScreen *host_screen =
-+                host_screen_from_window (xev.xconfigure.window);
-+		ev->type = EPHYR_EV_CONFIGURE;
-+		ev->data.configure.width = xev.xconfigure.width;
-+		ev->data.configure.height = xev.xconfigure.height;
-+		ev->data.configure.window = xev.xconfigure.window;
-+		ev->data.configure.screen = host_screen->mynum;
-+		return 1;
-+	  }
-+
- 	default:
- 	  break;
- 
-diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
-index e65e0c9..69e3ceb 100644
---- a/hw/kdrive/ephyr/hostx.h
-+++ b/hw/kdrive/ephyr/hostx.h
-@@ -48,7 +48,8 @@ typedef enum EphyrHostXEventType
-   EPHYR_EV_MOUSE_RELEASE,
-   EPHYR_EV_KEY_PRESS,
-   EPHYR_EV_KEY_RELEASE,
--  EPHYR_EV_EXPOSE
-+  EPHYR_EV_EXPOSE,
-+  EPHYR_EV_CONFIGURE
- } 
- EphyrHostXEventType;
- 
-@@ -93,6 +94,13 @@ struct EphyrHostXEvent
-       int window;
-     } expose;
- 
-+    struct configure {
-+      int width;
-+      int height;
-+      int screen;
-+      int window;
-+    } configure;
-+
-   } data;
- 
-   int key_state;
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-modifier-keycount.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-modifier-keycount.patch
deleted file mode 100644
index 5f607fe..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-modifier-keycount.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From dab76a0ce7d784133313f743d2bf876c1bd7f5e5 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Thu, 10 Jun 2010 12:21:36 +1000
-Subject: [PATCH] Xi: don't copy the modifier key count when copying device classes (#25480)
-
-The modifier key count is maintained by the XKB layer and
-increased/decreased for all modifiers that set state.
-
-Test case, MD/SD modifier key count in comment:
-1. keyboard 1: press and hold Shift_L    # SD:1     MD:1
-2. keyboard 2: press and release Shift_L # SD:1,0   MD:1,0
-<class copy happens>                     # SD:1     MD:1
-3. keyboard 1: release Shift_L           # SD:0     MD:1
-4. keyboard 1: press and release Shift_L # SD:1,0   MD:2,1
-
-The modifier is now logically down on the MD but not on keyboard 1 or
-keyboard 2.
-
-XKB is layered in before the DIX, it increases/decreases the modifier key
-count accordingly. In the above example, during (2), the MD gets the key
-release and thus clears the modifier bit. (3) doesn't forward the release to
-the MD because it is already cleared. The copy of modifierKeysDown when the
-lastSlave changes however increases the counter for the held key. On (4),
-the press and release are both forwarded to the MD, causing a offset by 1
-and thus do not clear the logical modifier state.
-
-X.Org Bug 25480 <http://bugs.freedesktop.org/show_bug.cgi?id=25480>
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Acked-by: Daniel Stone <daniel@fooishbar.org>
----
- Xi/exevents.c |    4 ----
- 1 files changed, 0 insertions(+), 4 deletions(-)
-
-diff --git a/Xi/exevents.c b/Xi/exevents.c
-index e680f6f..566b0ef 100644
---- a/Xi/exevents.c
-+++ b/Xi/exevents.c
-@@ -196,16 +196,12 @@ void
- CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
- {
-     KeyClassPtr mk = master->key;
--    KeyClassPtr dk = device->key;
--    int i;
- 
-     if (device == master)
-         return;
- 
-     mk->sourceid = device->id;
- 
--    for (i = 0; i < 8; i++)
--        mk->modifierKeyCount[i] = dk->modifierKeyCount[i];
- 
-     if (!XkbCopyDeviceKeymap(master, device))
-         FatalError("Couldn't pivot keymap from device to core!\n");
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-postfix-DCE-PointerKeys.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-postfix-DCE-PointerKeys.patch
deleted file mode 100644
index 6f3906d..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-postfix-DCE-PointerKeys.patch
+++ /dev/null
@@ -1,118 +0,0 @@
-From 31aebe89b716989e81e5de889e4f7e03d154a482 Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Mon, 26 Jul 2010 10:48:41 +1000
-Subject: [PATCH] xkb: post-fix PointerKeys button events with a DeviceChangedEvent.
-
-commit 14327858391ebe929b806efb53ad79e789361883
-    xkb: release XTEST pointer buttons on physical releases. (#28808)
-revealed a bug with the XTEST/PointerKeys interaction.
-
-Events resulting from PointerKeys are injected into the event processing
-stream, not appended to the event queue. The events generated for the fake
-button press include a DeviceChangedEvent (DCE), a raw button event and the
-button event itself. The DCE causes the master to switch classes to the
-attached XTEST pointer device.
-
-Once the fake button is processed, normal event processing continues with
-events in the EQ. The master still contains the XTEST classes, causing some
-events to be dropped if e.g. the number of valuators of the event in the
-queue exceeds the XTEST device's number of valuators.
-
-Example: the EQ contains the following events, processed one-by-one, left to
-right.
-
-[DCE (dev)][Btn down][Btn up][Motion][Motion][...]
-                  ^ XkbFakeDeviceButton injects [DCE (XTEST)][Btn up]
-
-Thus the event sequence processed looks like this:
-
-[DCE (dev)][Btn down][Btn up][DCE (XTEST)][Btn up][Motion][Motion][...]
-
-The first DCE causes the master to switch to the device. The button up event
-injects a DCE to the XTEST device, causing the following Motion events to be
-processed with the master still being on XTEST classes.
-
-This patch post-fixes the injected event sequence with a DCE to restore the
-classes of the original slave device, resulting in an event sequence like
-this:
-[DCE (dev)][Btn down][Btn up][DCE (XTEST)][Btn up][DCE (dev)][Motion][Motion]
-
-Note that this is a simplified description. The event sequence injected by
-the PointerKeys code is injected for the master device only and the matching
-slave device that caused the injection has already finished processing on
-the slave. Furthermore, the injection happens as part of the the XKB layer,
-before the unwrapping of the processInputProc takes us into the DIX where
-the DCE is actually handled.
-
-Bug reproducible with a device that reports more than 2 valuators. Simply
-cause button releases on the device and wait for a "too many valuators"
-warning message.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- xkb/xkbActions.c |   28 +++++++++++++++++++++-------
- 1 files changed, 21 insertions(+), 7 deletions(-)
-
-diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
-index 33ad5c5..0bbca29 100644
---- a/xkb/xkbActions.c
-+++ b/xkb/xkbActions.c
-@@ -1366,34 +1366,48 @@ XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
- {
-     EventListPtr        events;
-     int                 nevents, i;
--    DeviceIntPtr        ptr;
-+    DeviceIntPtr        ptr, mpointer, lastSlave;
- 
-     /* If dev is a slave device, and the SD is attached, do nothing. If we'd
-      * post through the attached master pointer we'd get duplicate events.
-      *
-      * if dev is a master keyboard, post through the XTEST device
--     *
-      * if dev is a floating slave, post through the device itself.
-+     *
-+     * The event is injected into the event processing, not the EQ. Thus,
-+     * ensure that we restore the master after the event sequence to the
-+     * original set of classes. Otherwise, the master remains on the XTEST
-+     * classes and drops events that don't fit into the XTEST layout (e.g.
-+     * events with more than 2 valuators).
-+     * To do so, we remember the lastSlave that posted through the master
-+     * and add a DeviceChangedEvent to the end of the list.
-      */
- 
--    if (IsMaster(dev))
--        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
--    else if (!dev->u.master)
-+    if (IsMaster(dev)) {
-+        mpointer = GetMaster(dev, MASTER_POINTER);
-+        lastSlave = mpointer->u.lastSlave;
-+        ptr = GetXTestDevice(mpointer);
-+    } else if (!dev->u.master)
-         ptr = dev;
-     else
-         return;
- 
--    events = InitEventList(GetMaximumEventsNum());
-+    /* xkb fake device buttons are one-shot events. Force a DCE after they
-+     * happen to restore the device to it's previous source */
-+    events = InitEventList(GetMaximumEventsNum() + 1);
-     OsBlockSignals();
-     nevents = GetPointerEvents(events, ptr,
-                                press ? ButtonPress : ButtonRelease, button,
-                                0 /* flags */, 0 /* first */,
-                                0 /* num_val */, NULL);
-+    if (IsMaster(dev) && (lastSlave && lastSlave != ptr))
-+        CreateClassesChangedEvent(&events[nevents++], mpointer,
-+                                  lastSlave, DEVCHANGE_POINTER_EVENT);
-     OsReleaseSignals();
- 
- 
-     for (i = 0; i < nevents; i++)
-         mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
- 
--    FreeEventList(events, GetMaximumEventsNum());
-+    FreeEventList(events, GetMaximumEventsNum() + 1);
- }
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-property-generation-reset.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-property-generation-reset.patch
deleted file mode 100644
index c8105f7..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-property-generation-reset.patch
+++ /dev/null
@@ -1,83 +0,0 @@
-From 3743ce98a24b3e3767b2a278af8d888e4e8bd335 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Fri, 7 May 2010 16:22:12 +1000
-Subject: [PATCH] Xi: reset the known properties at the end of the server generation.
-
-NOTE: this has a second patch squashed in, see
-http://lists.freedesktop.org/archives/xorg-devel/2010-June/009838.html
-
-
-Properties allocated through XIGetKnownProperty() aren't reset on the second
-server generation but keep the old value. As a result, wrong Atoms are
-supplied to the driver, resulting in potential data corruption or weird
-error message.
-
-Reproducible by running "xlsatom | grep FLOAT" twice on a plain X server.
-The second X server generation won't have the FLOAT atom defined anymore,
-despite the users of this atom not noticing any errors.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Keith Packard <keithp@keithp.com>
----
- Xi/extinit.c    |    3 ++-
- Xi/xiproperty.c |    9 +++++++++
- Xi/xiproperty.h |    3 +++
- 3 files changed, 14 insertions(+), 1 deletions(-)
-
-diff --git a/Xi/extinit.c b/Xi/extinit.c
-index 0c12919..daa79f6 100644
---- a/Xi/extinit.c
-+++ b/Xi/extinit.c
-@@ -1123,7 +1123,6 @@ RestoreExtensionEvents(void)
- static void
- IResetProc(ExtensionEntry * unused)
- {
--
-     ReplySwapVector[IReqCode] = ReplyNotSwappd;
-     EventSwapVector[DeviceValuator] = NotImplemented;
-     EventSwapVector[DeviceKeyPress] = NotImplemented;
-@@ -1302,6 +1301,8 @@ XInputExtensionInit(void)
- 
- 	inputInfo.all_devices = &xi_all_devices;
- 	inputInfo.all_master_devices = &xi_all_master_devices;
-+
-+	XIResetProperties();
-     } else {
- 	FatalError("IExtensionInit: AddExtensions failed\n");
-     }
-diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
-index ea66c54..2482171 100644
---- a/Xi/xiproperty.c
-+++ b/Xi/xiproperty.c
-@@ -392,6 +392,15 @@ XIGetKnownProperty(char *name)
-     return 0;
- }
- 
-+void
-+XIResetProperties(void)
-+{
-+    int i;
-+
-+    for (i = 0; i < (sizeof(dev_properties)/sizeof(struct dev_properties)); i++)
-+        dev_properties[i].type = None;
-+}
-+
- /**
-  * Convert the given property's value(s) into @nelem_return integer values and
-  * store them in @buf_return. If @nelem_return is larger than the number of
-diff --git a/Xi/xiproperty.h b/Xi/xiproperty.h
-index 69b41fa..d8b8863 100644
---- a/Xi/xiproperty.h
-+++ b/Xi/xiproperty.h
-@@ -62,4 +62,7 @@ void SRepXIListProperties(ClientPtr client, int size,
-                           xXIListPropertiesReply *rep);
- void SRepXIGetProperty(ClientPtr client, int size,
-                        xXIGetPropertyReply *rep);
-+
-+void XIResetProperties(void);
-+
- #endif /* XIPROPERTY_H */
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-randr-cursor-dead-zones.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-randr-cursor-dead-zones.patch
deleted file mode 100644
index 975b1cd..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-randr-cursor-dead-zones.patch
+++ /dev/null
@@ -1,381 +0,0 @@
-From ca589bdc757401aebd7daa0dafaa860b5c8ec15a Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Thu, 5 Aug 2010 13:45:22 -0400
-Subject: [PATCH 1/2] randr: Add additional cursor constraint logic
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- include/scrnintstr.h |   11 +++-
- mi/mibstore.c        |    1 -
- mi/mipointer.c       |    3 +
- mi/mipointrst.h      |    4 +-
- mi/miscrinit.c       |    1 -
- randr/randr.c        |    2 +
- randr/randrstr.h     |    4 +
- randr/rrcrtc.c       |  186 ++++++++++++++++++++++++++++++++++++++++++++++++++
- 8 files changed, 207 insertions(+), 5 deletions(-)
-
-diff --git a/include/scrnintstr.h b/include/scrnintstr.h
-index ab50e7a..1e2d645 100644
---- a/include/scrnintstr.h
-+++ b/include/scrnintstr.h
-@@ -446,6 +446,11 @@ typedef    void (* DeviceCursorCleanupProcPtr)(
-         DeviceIntPtr /* pDev */,
-         ScreenPtr    /* pScreen */);
- 
-+typedef struct _miPointer *miPointerPtr;
-+
-+typedef void (*ConstrainCursorHarderProcPtr)(
-+	miPointerPtr, ScreenPtr, int *, int *);
-+
- typedef struct _Screen {
-     int			myNum;	/* index of this instance in Screens[] */
-     ATOM		id;
-@@ -506,9 +511,13 @@ typedef struct _Screen {
-     CreatePixmapProcPtr		CreatePixmap;
-     DestroyPixmapProcPtr	DestroyPixmap;
- 
--    /* Backing store procedures */
-+    /* Reuse the SDA slot for CCH for minimal ABI hassle */
-+    ConstrainCursorHarderProcPtr ConstrainCursorHarder;
- 
-+    /* Backing store procedures */
-+#if 0
-     SaveDoomedAreasProcPtr	SaveDoomedAreas;
-+#endif
-     RestoreAreasProcPtr		RestoreAreas;
-     ExposeCopyProcPtr		ExposeCopy;
-     TranslateBackingStoreProcPtr TranslateBackingStore;
-diff --git a/mi/mibstore.c b/mi/mibstore.c
-index 262b494..1388189 100644
---- a/mi/mibstore.c
-+++ b/mi/mibstore.c
-@@ -40,7 +40,6 @@
- void
- miInitializeBackingStore (ScreenPtr pScreen)
- {
--    pScreen->SaveDoomedAreas = NULL;
-     pScreen->RestoreAreas = NULL;
-     pScreen->ExposeCopy = NULL;
-     pScreen->TranslateBackingStore = NULL;
-diff --git a/mi/mipointer.c b/mi/mipointer.c
-index e1f63be..3c4552a 100644
---- a/mi/mipointer.c
-+++ b/mi/mipointer.c
-@@ -534,6 +534,9 @@ miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y)
-     if (*y >= pPointer->limits.y2)
- 	*y = pPointer->limits.y2 - 1;
- 
-+    if (pScreen->ConstrainCursorHarder)
-+	pScreen->ConstrainCursorHarder(pPointer, pScreen, x, y);
-+
-     if (pPointer->x == *x && pPointer->y == *y && 
-             pPointer->pScreen == pScreen) 
-         return;
-diff --git a/mi/mipointrst.h b/mi/mipointrst.h
-index bd9c24a..f643c01 100644
---- a/mi/mipointrst.h
-+++ b/mi/mipointrst.h
-@@ -35,7 +35,7 @@ in this Software without prior written authorization from The Open Group.
- #include "mipointer.h"
- #include "scrnintstr.h"
- 
--typedef struct {
-+typedef struct _miPointer {
-     ScreenPtr		    pScreen;    /* current screen */
-     ScreenPtr		    pSpriteScreen;/* screen containing current sprite */
-     CursorPtr		    pCursor;    /* current cursor */
-@@ -44,7 +44,7 @@ typedef struct {
-     Bool		    confined;	/* pointer can't change screens */
-     int			    x, y;	/* hot spot location */
-     int			    devx, devy;	/* sprite position */
--} miPointerRec, *miPointerPtr;
-+} miPointerRec /* , *miPointerPtr */;
- 
- typedef struct {
-     miPointerSpriteFuncPtr  spriteFuncs;	/* sprite-specific methods */
-diff --git a/mi/miscrinit.c b/mi/miscrinit.c
-index 96113d6..71a3e07 100644
---- a/mi/miscrinit.c
-+++ b/mi/miscrinit.c
-@@ -281,7 +281,6 @@ miScreenInit(
-     pScreen->SetShape = miSetShape;
-     pScreen->MarkUnrealizedWindow = miMarkUnrealizedWindow;
- 
--    pScreen->SaveDoomedAreas = 0;
-     pScreen->RestoreAreas = 0;
-     pScreen->ExposeCopy = 0;
-     pScreen->TranslateBackingStore = 0;
-diff --git a/randr/randr.c b/randr/randr.c
-index a21753f..3489d7e 100644
---- a/randr/randr.c
-+++ b/randr/randr.c
-@@ -269,6 +269,8 @@ Bool RRScreenInit(ScreenPtr pScreen)
-     
-     wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen);
- 
-+    pScreen->ConstrainCursorHarder = RRConstrainCursorHarder;
-+
-     pScrPriv->numOutputs = 0;
-     pScrPriv->outputs = NULL;
-     pScrPriv->numCrtcs = 0;
-diff --git a/randr/randrstr.h b/randr/randrstr.h
-index 975fe33..e30dfd0 100644
---- a/randr/randrstr.h
-+++ b/randr/randrstr.h
-@@ -299,6 +299,7 @@ typedef struct _rrScrPriv {
-     int			    rate;
-     int			    size;
- #endif
-+    Bool		    discontiguous;
- } rrScrPrivRec, *rrScrPrivPtr;
- 
- extern _X_EXPORT DevPrivateKey rrPrivKey;
-@@ -731,6 +732,9 @@ ProcRRGetPanning (ClientPtr client);
- int
- ProcRRSetPanning (ClientPtr client);
- 
-+void
-+RRConstrainCursorHarder (miPointerPtr, ScreenPtr, int *, int *);
-+
- /* rrdispatch.c */
- extern _X_EXPORT Bool
- RRClientKnowsRates (ClientPtr	pClient);
-diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
-index 0e14b36..2a4f884 100644
---- a/randr/rrcrtc.c
-+++ b/randr/rrcrtc.c
-@@ -1,5 +1,6 @@
- /*
-  * Copyright © 2006 Keith Packard
-+ * Copyright 2010 Red Hat, Inc
-  *
-  * Permission to use, copy, modify, distribute, and sell this software and its
-  * documentation for any purpose is hereby granted without fee, provided that
-@@ -23,6 +24,7 @@
- #include "randrstr.h"
- #include "swaprep.h"
- #include "registry.h"
-+#include "mipointrst.h"
- 
- RESTYPE	RRCrtcType;
- 
-@@ -295,6 +297,102 @@ RRCrtcPendingProperties (RRCrtcPtr crtc)
-     return FALSE;
- }
- 
-+/* overlapping counts as adjacent */
-+static Bool
-+crtcs_adjacent(const RRCrtcPtr a, const RRCrtcPtr b)
-+{
-+    int al = a->x, ar = a->x + a->mode->mode.width;
-+    int bl = b->x, br = b->x + b->mode->mode.width;
-+    int at = a->y, ab = a->y + a->mode->mode.height;
-+    int bt = b->y, bb = b->y + b->mode->mode.height;
-+
-+    int cl = max(al, bl);
-+    int cr = min(ar, br);
-+    int ct = max(at, ct);
-+    int cb = min(ab, bb);
-+
-+    return (cl <= cr) && (ct <= cb);
-+}
-+
-+/*
-+ * This isn't really multiplication, but we don't need it to be.  All
-+ * we need is a boolean for connectivity, not an integer for number of
-+ * paths.  As a result we can scale to gratuitously large n without
-+ * worrying about integer overflow.
-+ */
-+static Bool
-+matrix_pseudomultiply(char *left, const char *right, int n)
-+{
-+    int i, j, k;
-+    char *res = calloc(1, n * n);
-+
-+    if (!res)
-+	return FALSE;
-+
-+    for (i = 0; i < n; i++)
-+	for (j = 0; j < n; j++)
-+	    for (k = 0; k < n; k++)
-+		res[i*n + j] |= left[i*n + k] && right[k*n + j];
-+
-+    memcpy(left, res, n * n);
-+
-+    free(res);
-+
-+    return TRUE;
-+}
-+
-+static void
-+RRComputeContiguity (ScreenPtr pScreen)
-+{
-+    rrScrPriv(pScreen);
-+    Bool discontiguous = TRUE;
-+    int i, j, n = pScrPriv->numCrtcs;
-+    RRCrtcPtr a, b;
-+    char *matrix = NULL, *m = NULL;
-+
-+    matrix = calloc(1, n*n);
-+    m = calloc(1, n*n);
-+    if (!matrix || !m)
-+	goto out;
-+
-+    /* compute adjacency matrix; everything is adjacent with itself */
-+    for (i = 0; i < n; i++) {
-+	a = pScrPriv->crtcs[i];
-+
-+	if (!a->mode)
-+	    continue;
-+
-+	for (j = 0; j < n; j++) {
-+	    b = pScrPriv->crtcs[j];
-+
-+	    if (!b->mode)
-+		continue;
-+
-+	    if (a == b || crtcs_adjacent(a, b))
-+		matrix[i*n + j] = 1;
-+	}
-+    }
-+
-+    memcpy(m, matrix, n*n);
-+
-+    /* raise it to the n-1th; finds connected paths */
-+    for (i = 0; i < n-1; i++)
-+	if (!matrix_pseudomultiply(m, matrix, n))
-+	    goto out;
-+
-+    /* check for connectivity */
-+    for (i = 0; i < n; i++)
-+	if (pScrPriv->crtcs[i]->mode && !m[i])
-+	    goto out;
-+
-+    discontiguous = FALSE;
-+
-+out:
-+    free(matrix);
-+    free(m);
-+    pScrPriv->discontiguous = discontiguous;
-+}
-+
- /*
-  * Request that the Crtc be reconfigured
-  */
-@@ -309,6 +407,7 @@ RRCrtcSet (RRCrtcPtr    crtc,
- {
-     ScreenPtr	pScreen = crtc->pScreen;
-     Bool	ret = FALSE;
-+    Bool	recompute = TRUE;
-     rrScrPriv(pScreen);
- 
-     /* See if nothing changed */
-@@ -322,6 +421,7 @@ RRCrtcSet (RRCrtcPtr    crtc,
- 	!RRCrtcPendingTransform (crtc))
-     {
- 	ret = TRUE;
-+	recompute = FALSE;
-     }
-     else
-     {
-@@ -384,6 +484,10 @@ RRCrtcSet (RRCrtcPtr    crtc,
- 		RRPostPendingProperties (outputs[o]);
- 	}
-     }
-+
-+    if (recompute)
-+	RRComputeContiguity(pScreen);
-+
-     return ret;
- }
- 
-@@ -1387,3 +1491,85 @@ ProcRRGetCrtcTransform (ClientPtr client)
-     xfree(reply);
-     return client->noClientException;
- }
-+
-+static void
-+crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom)
-+{
-+    *left = crtc->x;
-+    *top = crtc->y;
-+
-+    switch (crtc->rotation) {
-+    case RR_Rotate_0:
-+    case RR_Rotate_180:
-+	*right = crtc->x + crtc->mode->mode.width;
-+	*bottom = crtc->y + crtc->mode->mode.height;
-+	return;
-+    case RR_Rotate_90:
-+    case RR_Rotate_270:
-+	*right = crtc->x + crtc->mode->mode.height;
-+	*bottom = crtc->y + crtc->mode->mode.width;
-+    default:
-+	return;
-+    }
-+}
-+
-+void
-+RRConstrainCursorHarder(miPointerPtr pDev, ScreenPtr pScreen, int *x, int *y)
-+{
-+    rrScrPriv (pScreen);
-+    int i;
-+
-+    /* intentional dead space -> let it float */
-+    if (pScrPriv->discontiguous)
-+	return;
-+
-+    /* if we're moving inside a crtc, we're fine */
-+    for (i = 0; i < pScrPriv->numCrtcs; i++) {
-+	RRCrtcPtr crtc = pScrPriv->crtcs[i];
-+
-+	int left, right, top, bottom;
-+
-+	if (!crtc->mode)
-+	    continue;
-+
-+	crtc_bounds(crtc, &left, &right, &top, &bottom);
-+
-+	if ((*x >= left) && (*x <= right) && (*y >= top) && (*y <= bottom))
-+	    return;
-+    }
-+
-+    /* if we're trying to escape, clamp to the CRTC we're coming from */
-+    for (i = 0; i < pScrPriv->numCrtcs; i++) {
-+	RRCrtcPtr crtc = pScrPriv->crtcs[i];
-+	int nx = pDev->x;
-+	int ny = pDev->y;
-+	int left, right, top, bottom;
-+
-+	if (!crtc->mode)
-+	    continue;
-+
-+	crtc_bounds(crtc, &left, &right, &top, &bottom);
-+
-+	if ((nx >= left) && (nx <= right) && (ny >= top) && (ny <= bottom)) {
-+	    if ((*x <= left) || (*x >= right)) {
-+		int dx = *x - nx;
-+
-+		if (dx > 0)
-+		    *x = right;
-+		else if (dx < 0)
-+		    *x = left;
-+	    }
-+
-+	    if ((*y <= top) || (*y >= bottom)) {
-+		int dy = *y - ny;
-+
-+		if (dy > 0)
-+		    *y = bottom;
-+		else if (dy < 0)
-+		    *y = top;
-+	    }
-+
-+	    return;
-+	}
-+    }
-+}
--- 
-1.7.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-randr-initial.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-randr-initial.patch
deleted file mode 100644
index 1004f61..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-randr-initial.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 96cf3862b5807857dd39e55fa4b2d95ab7978708 Mon Sep 17 00:00:00 2001
-From: Ben Skeggs <bskeggs@redhat.com>
-Date: Mon, 7 Jun 2010 10:10:10 +1000
-Subject: [PATCH] randr: prevent an unnecessary screen resize with multiple displays
-
-crtc->{x,y} is always 0 when xf86DefaultScreenLimits() is called, so we
-calculate too small an area for the initial framebuffer and force a resize
-to happen.
-
-This commit fixes the code to use desired{X,Y} instead, which contains the
-initial output positions.
-
-Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-Reviewed-by: Dave Airlie <airlied@redhat.com>
-Reviewed-by: Keith Packard <keithp@keithp.com>
----
- hw/xfree86/modes/xf86Crtc.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
-index 304d503..cd978ae 100644
---- a/hw/xfree86/modes/xf86Crtc.c
-+++ b/hw/xfree86/modes/xf86Crtc.c
-@@ -1038,8 +1038,8 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp,
- 
- 	if (crtc->enabled)
- 	{
--	    crtc_width = crtc->x + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation);
--	    crtc_height = crtc->y + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation);
-+	    crtc_width = crtc->desiredX + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation);
-+	    crtc_height = crtc->desiredY + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation);
- 	}
- 	if (!canGrow) {
- 	    for (o = 0; o < config->num_output; o++)
--- 
-1.7.0.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-release-xtest-on-phys-buttons.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-release-xtest-on-phys-buttons.patch
deleted file mode 100644
index 6f561a8..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-release-xtest-on-phys-buttons.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-From 005073e94bde03b52ae8f5b6ae98abc2f75f7355 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Thu, 1 Jul 2010 12:44:57 +1000
-Subject: [PATCH] xkb: release XTEST pointer buttons on physical releases.
-
-If a button release event is posted for the MD pointer, post a release event
-through the matching XTEST device. This way, a client who posts a button
-press through the XTEST extension cannot inadvertedly lock the button.
-
-This behaviour is required for historical reasons, until server 1.7 the core
-pointer would release a button press on physical events, regardless of the
-XTEST state.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- include/xkbsrv.h |    6 ++++++
- xkb/xkbAccessX.c |   20 +++++++-------------
- xkb/xkbActions.c |    4 ++--
- 3 files changed, 15 insertions(+), 15 deletions(-)
-
-diff --git a/include/xkbsrv.h b/include/xkbsrv.h
-index aab833f..7a5d351 100644
---- a/include/xkbsrv.h
-+++ b/include/xkbsrv.h
-@@ -941,6 +941,12 @@ extern int XkbGetEffectiveGroup(
- extern void XkbMergeLockedPtrBtns(
-         DeviceIntPtr            /* master */);
- 
-+extern void XkbFakeDeviceButton(
-+        DeviceIntPtr            /* dev */,
-+        int                     /* press */,
-+        int                     /* button */);
-+
-+
- #include "xkbfile.h"
- #include "xkbrules.h"
- 
-diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
-index 670f368..dae85f3 100644
---- a/xkb/xkbAccessX.c
-+++ b/xkb/xkbAccessX.c
-@@ -710,19 +710,13 @@ DeviceEvent     *event = &ev->device_event;
- 	if (xkbi) {
- 	    xkbi->lockedPtrButtons&= ~(1 << (event->detail.key & 0x7));
- 
--            /* Merge this MD's lockedPtrButtons with the one of all
--             * attached slave devices.
--             * The DIX uses a merged button state for MDs, not
--             * releasing buttons until the last SD has released
--             * thenm. If we unconditionally clear the
--             * lockedPtrButtons bit on the MD, a PointerKeys button
--             * release on the SD keyboard won't generate the required fake button
--             * event on the XTEST pointer, thus never processing the
--             * button event in the DIX and the XTEST pointer's
--             * buttons stay down - result is a stuck button.
--             */
--	    if (IsMaster(dev))
--                XkbMergeLockedPtrBtns(dev);
-+            if (IsMaster(dev))
-+            {
-+                DeviceIntPtr source;
-+                dixLookupDevice(&source, event->sourceid, serverClient, DixWriteAccess);
-+                if (!IsXTestDevice(source, GetMaster(dev, MASTER_POINTER)))
-+                    XkbFakeDeviceButton(dev, FALSE, event->detail.key);
-+            }
- 	}
- 
- 	changed |= XkbPointerButtonMask;
-diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
-index e68b782..33ad5c5 100644
---- a/xkb/xkbActions.c
-+++ b/xkb/xkbActions.c
-@@ -46,7 +46,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
- static int xkbDevicePrivateKeyIndex;
- DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKeyIndex;
- 
--static void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
-+void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
- static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y);
- 
- void
-@@ -1361,7 +1361,7 @@ XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
-     FreeEventList(events, GetMaximumEventsNum());
- }
- 
--static void
-+void
- XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
- {
-     EventListPtr        events;
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-reset-unused-classes.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-reset-unused-classes.patch
deleted file mode 100644
index e22fae9..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-reset-unused-classes.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From 742150bab3b2d184a8ff7b6224151c2bb395aab6 Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Wed, 28 Jul 2010 14:24:59 +1000
-Subject: [PATCH] Xi: reset the unused classes pointer after copying
-
-After copying the unused_classes into the device, reset the original
-pointer. Otherwise we have two pointers pointing to the same field and both
-get freed on device removal.
-
-Some classes already have this behaviour since 51c8fd69.
-
-Signed-off-by: Fedora X Ninjas <x@fedoraproject.org>
----
- Xi/exevents.c |    6 ++++++
- 1 files changed, 6 insertions(+), 0 deletions(-)
-
-diff --git a/Xi/exevents.c b/Xi/exevents.c
-index 566b0ef..a6160dd 100644
---- a/Xi/exevents.c
-+++ b/Xi/exevents.c
-@@ -227,6 +227,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
-             classes = dixLookupPrivate(&to->devPrivates,
-                                        UnusedClassesPrivateKey);
-             to->intfeed = classes->intfeed;
-+            classes->intfeed = NULL;
-         }
- 
-         i = &to->intfeed;
-@@ -263,6 +264,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
-             classes = dixLookupPrivate(&to->devPrivates,
-                                        UnusedClassesPrivateKey);
-             to->stringfeed = classes->stringfeed;
-+            classes->stringfeed = NULL;
-         }
- 
-         s = &to->stringfeed;
-@@ -299,6 +301,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
-             classes = dixLookupPrivate(&to->devPrivates,
-                                        UnusedClassesPrivateKey);
-             to->bell = classes->bell;
-+            classes->bell = NULL;
-         }
- 
-         b = &to->bell;
-@@ -336,6 +339,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
-             classes = dixLookupPrivate(&to->devPrivates,
-                                        UnusedClassesPrivateKey);
-             to->leds = classes->leds;
-+            classes->leds = NULL;
-         }
- 
-         l = &to->leds;
-@@ -387,6 +391,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
-             to->kbdfeed = classes->kbdfeed;
-             if (!to->kbdfeed)
-                 InitKeyboardDeviceStruct(to, NULL, NULL, NULL);
-+            classes->kbdfeed = NULL;
-         }
- 
-         k = &to->kbdfeed;
-@@ -517,6 +522,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
-             classes = dixLookupPrivate(&to->devPrivates,
-                                        UnusedClassesPrivateKey);
-             to->ptrfeed = classes->ptrfeed;
-+            classes->ptrfeed = NULL;
-         }
- 
-         p = &to->ptrfeed;
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-sd-keyboard-controls.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-sd-keyboard-controls.patch
deleted file mode 100644
index 93a49f0..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-sd-keyboard-controls.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 03d384b3f37bb6213d52589955eb658985998c5e Mon Sep 17 00:00:00 2001
-From: Nicolas George <nicolas.george@normalesup.org>
-Date: Wed, 2 Jun 2010 13:40:51 +0200
-Subject: [PATCH] Change keyboard controls on slave keyboards (#27926)
-
-Makes the use of IsMaster in ProcChangeKeyboardControl consistent with other
-similar loops.
-
-Signed-off-by: Nicolas George <nicolas.george@normalesup.org>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- dix/devices.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/dix/devices.c b/dix/devices.c
-index 87b6dc7..1037e42 100644
---- a/dix/devices.c
-+++ b/dix/devices.c
-@@ -1956,7 +1956,7 @@ ProcChangeKeyboardControl (ClientPtr client)
-     keyboard = PickKeyboard(client);
- 
-     for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
--        if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
-+        if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
-             pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
-             ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
- 	    if (ret != Success)
-@@ -1965,7 +1965,7 @@ ProcChangeKeyboardControl (ClientPtr client)
-     }
- 
-     for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
--        if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
-+        if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
-             pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
-             ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
-             if (ret != Success)
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-showopts-segv.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-showopts-segv.patch
deleted file mode 100644
index 18fec5f..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-showopts-segv.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 657d9ece7d8198a5ee9cef3cbbef2c1b81766e77 Mon Sep 17 00:00:00 2001
-From: Alan Coopersmith <alan.coopersmith@oracle.com>
-Date: Sat, 12 Jun 2010 08:19:16 -0700
-Subject: [PATCH] Don't coredump on "X -showopts" (bug 25874)
-
-Don't try walking the xf86ConfigLayout.screens table if it's empty
-https://bugs.freedesktop.org/show_bug.cgi?id=25874
-
-Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
-Signed-off-by: Keith Packard <keithp@keithp.com>
-(cherry picked from commit b8615d592700b7be319c04cc0563fdeb5a266534)
----
- hw/xfree86/common/xf86Helper.c |    7 +++++++
- 1 files changed, 7 insertions(+), 0 deletions(-)
-
-diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
-index 1cc1526..512b39e 100644
---- a/hw/xfree86/common/xf86Helper.c
-+++ b/hw/xfree86/common/xf86Helper.c
-@@ -1447,6 +1447,13 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
-     if (xf86DoConfigure && xf86DoConfigurePass1) return 1;
- 
-     /*
-+     * This can happen when running Xorg -showopts and a module like ati
-+     * or vmware tries to load its submodules when xf86ConfigLayout is empty
-+     */
-+    if (!xf86ConfigLayout.screens)
-+	return 0;
-+
-+    /*
-      * This is a very important function that matches the device sections
-      * as they show up in the config file with the drivers that the server
-      * loads at run time.
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xephyr-24bpp.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xephyr-24bpp.patch
deleted file mode 100644
index 61c84a6..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xephyr-24bpp.patch
+++ /dev/null
@@ -1,83 +0,0 @@
-From bb0c8f36cca4027be3f70cfea63516508170e1f8 Mon Sep 17 00:00:00 2001
-From: Adam Jackson <ajax@redhat.com>
-Date: Mon, 12 Jul 2010 10:01:53 -0400
-Subject: [PATCH] kdrive/ephyr: Fix crash on 24bpp host framebuffer
-
-bytes_per_line in the XImage will (more or less) reflect the pixmap
-format of the server.  On 24bpp servers it will be approximately 3*width
-(plus scanline padding); we were assuming depth 24 always meant 32bpp,
-so the exposure painting in root window map would walk off the end of
-the image and crash.
-
-Signed-off-by: Adam Jackson <ajax@redhat.com>
----
- hw/kdrive/ephyr/ephyr.c |    9 ++++++---
- hw/kdrive/ephyr/hostx.c |    4 +++-
- hw/kdrive/ephyr/hostx.h |    2 +-
- 3 files changed, 10 insertions(+), 5 deletions(-)
-
-diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
-index 14ab591..a6057db 100644
---- a/hw/kdrive/ephyr/ephyr.c
-+++ b/hw/kdrive/ephyr/ephyr.c
-@@ -234,8 +234,6 @@ ephyrMapFramebuffer (KdScreenInfo *screen)
-   KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
-   KdSetPointerMatrix (&m);
-   
--  priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
--  
-   /* point the framebuffer to the data in an XImage */
-   /* If fakexa is enabled, allocate a larger buffer so that fakexa has space to
-    * put offscreen pixmaps.
-@@ -245,7 +243,12 @@ ephyrMapFramebuffer (KdScreenInfo *screen)
-   else
-     buffer_height = 3 * screen->height;
- 
--  priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
-+  priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height, &priv->bytes_per_line);
-+
-+  /* laaaaaame */
-+  if (screen->fb[0].depth == 24)
-+    if (priv->bytes_per_line < (screen->width * 4))
-+      screen->fb[0].bitsPerPixel = 24;
- 
-   screen->memory_base  = (CARD8 *) (priv->base);
-   screen->memory_size  = priv->bytes_per_line * buffer_height;
-diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
-index cdb019d..874c754 100644
---- a/hw/kdrive/ephyr/hostx.c
-+++ b/hw/kdrive/ephyr/hostx.c
-@@ -639,7 +639,7 @@ hostx_set_cmap_entry(unsigned char idx,
- void*
- hostx_screen_init (EphyrScreenInfo screen,
-                    int width, int height,
--                   int buffer_height)
-+                   int buffer_height, int *bytes_per_line)
- {
-   int         bitmap_pad;
-   Bool        shm_success = False;
-@@ -727,6 +727,8 @@ hostx_screen_init (EphyrScreenInfo screen,
-               malloc (host_screen->ximg->bytes_per_line * buffer_height);
-     }
- 
-+  *bytes_per_line = host_screen->ximg->bytes_per_line;
-+
-   XResizeWindow (HostX.dpy, host_screen->win, width, height);
- 
-   XMapWindow(HostX.dpy, host_screen->win);
-diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
-index 69e3ceb..b0627da 100644
---- a/hw/kdrive/ephyr/hostx.h
-+++ b/hw/kdrive/ephyr/hostx.h
-@@ -203,7 +203,7 @@ hostx_set_cmap_entry(unsigned char idx,
- void*
- hostx_screen_init (EphyrScreenInfo screen,
-                    int width, int height,
--                   int buffer_height);
-+                   int buffer_height, int *bytes_per_line);
- 
- void
- hostx_paint_rect(EphyrScreenInfo screen,
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-geom-copy.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-geom-copy.patch
deleted file mode 100644
index 5db9cec..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-geom-copy.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From 34fa79f3f914b6a739d101cd78b7dbda6eca4760 Mon Sep 17 00:00:00 2001
-From: Dirk Wallenstein <halsmit@t-online.de>
-Date: Sat, 17 Apr 2010 21:36:23 +0200
-Subject: [PATCH] xkb: Fix omissions in geometry initialization #27679
-
-_XkbCopyGeom did not copy all of the data from the source geometry. This
-resulted in failures when trying to obtain the keymap from a server
-where the default geometry has not been replaced by a custom
-configuration.
-
-Signed-off-by: Dirk Wallenstein <halsmit@t-online.de>
-Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- xkb/xkbUtils.c |   41 +++++++++++++++++++++++++++++++++++++++--
- 1 files changed, 39 insertions(+), 2 deletions(-)
-
-diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
-index 1abb5a8..fe093a4 100644
---- a/xkb/xkbUtils.c
-+++ b/xkb/xkbUtils.c
-@@ -1601,6 +1601,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
-                 else {
-                     dcolor->spec = xstrdup(scolor->spec);
-                 }
-+                dcolor->pixel = scolor->pixel;
-             }
- 
-             dst->geom->num_colors = dst->geom->sz_colors;
-@@ -1672,6 +1673,8 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
- 
-                             memcpy(doutline->points, soutline->points,
-                                    soutline->num_points * sizeof(XkbPointRec));
-+
-+                            doutline->corner_radius = soutline->corner_radius;
-                         }
- 
-                         doutline->num_points = soutline->num_points;
-@@ -1681,6 +1684,36 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
- 
-                 dshape->num_outlines = sshape->num_outlines;
-                 dshape->sz_outlines = sshape->num_outlines;
-+                dshape->name = sshape->name;
-+                dshape->bounds = sshape->bounds;
-+
-+                dshape->approx = NULL;
-+                if (sshape->approx && sshape->num_outlines > 0) {
-+
-+                    const ptrdiff_t approx_idx =
-+                            sshape->approx - sshape->outlines;
-+
-+                    if (approx_idx < dshape->num_outlines) {
-+                            dshape->approx = dshape->outlines + approx_idx;
-+                    } else {
-+                            LogMessage(X_WARNING, "XKB: approx outline "
-+                                            "index is out of range\n");
-+                    }
-+                }
-+
-+                dshape->primary = NULL;
-+                if (sshape->primary && sshape->num_outlines > 0) {
-+
-+                    const ptrdiff_t primary_idx =
-+                            sshape->primary - sshape->outlines;
-+
-+                    if (primary_idx < dshape->num_outlines) {
-+                            dshape->primary = dshape->outlines + primary_idx;
-+                    } else {
-+                            LogMessage(X_WARNING, "XKB: primary outline "
-+                                            "index is out of range\n");
-+                    }
-+                }
-             }
- 
-             dst->geom->num_shapes = src->geom->num_shapes;
-@@ -1784,6 +1817,10 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
-                     }
-                     drow->num_keys = srow->num_keys;
-                     drow->sz_keys = srow->num_keys;
-+                    drow->top = srow->top;
-+                    drow->left = srow->left;
-+                    drow->vertical = srow->vertical;
-+                    drow->bounds = srow->bounds;
-                 }
- 
-                 if (ssection->num_doodads) {
-@@ -1802,6 +1839,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
-                       ddoodad = dsection->doodads;
-                      k < ssection->num_doodads;
-                      k++, sdoodad++, ddoodad++) {
-+                    memcpy(ddoodad , sdoodad, sizeof(XkbDoodadRec));
-                     if (sdoodad->any.type == XkbTextDoodad) {
-                         if (sdoodad->text.text)
-                             ddoodad->text.text =
-@@ -1815,7 +1853,6 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
-                             ddoodad->logo.logo_name =
-                              xstrdup(sdoodad->logo.logo_name);
-                     }
--                    ddoodad->any.type = sdoodad->any.type;
-                 }
-                 dsection->overlays = NULL;
-                 dsection->sz_overlays = 0;
-@@ -1880,7 +1917,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
-                   ddoodad = dst->geom->doodads;
-                  i < src->geom->num_doodads;
-                  i++, sdoodad++, ddoodad++) {
--                ddoodad->any.type = sdoodad->any.type;
-+                memcpy(ddoodad , sdoodad, sizeof(XkbDoodadRec));
-                 if (sdoodad->any.type == XkbTextDoodad) {
-                     if (sdoodad->text.text)
-                         ddoodad->text.text = xstrdup(sdoodad->text.text);
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-invalid-writes.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-invalid-writes.patch
deleted file mode 100644
index 5f1bb78..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-invalid-writes.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From d68eb105421d4b88b1489ac954085dea4c99fc24 Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Wed, 9 Jun 2010 16:38:20 +1000
-Subject: [PATCH] xkb: fix invalid memory writes in _XkbCopyGeom.
-
-Classic strlen/strcpy mistake of
-   foo = malloc(strlen(bar));
-   strcpy(foo, bar);
-
-Testcase: valgrind Xephyr :1
-
-==8591== Invalid write of size 1
-==8591==    at 0x4A0638F: strcpy (mc_replace_strmem.c:311)
-==8591==    by 0x605593: _XkbCopyGeom (xkbUtils.c:1994)
-==8591==    by 0x605973: XkbCopyKeymap (xkbUtils.c:2118)
-==8591==    by 0x6122B3: InitKeyboardDeviceStruct (xkbInit.c:560)
-==8591==    by 0x4472E2: CoreKeyboardProc (devices.c:577)
-==8591==    by 0x447162: ActivateDevice (devices.c:530)
-==8591==    by 0x4475D6: InitCoreDevices (devices.c:672)
-==8591==    by 0x4449EE: main (main.c:254)
-==8591==  Address 0x6f96505 is 0 bytes after a block of size 53 alloc'd
-==8591==    at 0x4A0515D: malloc (vg_replace_malloc.c:195)
-==8591==    by 0x6054B7: _XkbCopyGeom (xkbUtils.c:1980)
-==8591==    by 0x605973: XkbCopyKeymap (xkbUtils.c:2118)
-==8591==    by 0x6122B3: InitKeyboardDeviceStruct (xkbInit.c:560)
-==8591==    by 0x4472E2: CoreKeyboardProc (devices.c:577)
-==8591==    by 0x447162: ActivateDevice (devices.c:530)
-==8591==    by 0x4475D6: InitCoreDevices (devices.c:672)
-==8591==    by 0x4449EE: main (main.c:254)
-
-Reported-by: Dave Airlie <airlied@redhat.com>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by-and-apologised-for: Daniel Stone <daniel@fooishbar.org>
-Signed-off-by: Keith Packard <keithp@keithp.com>
-
-Conflicts:
-
-	xkb/xkbUtils.c
----
- xkb/xkbUtils.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
-index 30ec438..1abb5a8 100644
---- a/xkb/xkbUtils.c
-+++ b/xkb/xkbUtils.c
-@@ -1940,7 +1940,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
-         /* font */
-         if (src->geom->label_font) {
-             if (!dst->geom->label_font) {
--                tmp = xalloc(strlen(src->geom->label_font));
-+                tmp = xalloc(strlen(src->geom->label_font) + 1);
-                 if (!tmp)
-                     return FALSE;
-                 dst->geom->label_font = tmp;
-@@ -1948,7 +1948,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
-             else if (strlen(src->geom->label_font) !=
-                 strlen(dst->geom->label_font)) {
-                 tmp = xrealloc(dst->geom->label_font,
--                               strlen(src->geom->label_font));
-+                               strlen(src->geom->label_font) + 1);
-                 if (!tmp)
-                     return FALSE;
-                 dst->geom->label_font = tmp;
--- 
-1.6.5.2
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-lockedPtrBtns-state-merge.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-lockedPtrBtns-state-merge.patch
deleted file mode 100644
index 607c3e2..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-lockedPtrBtns-state-merge.patch
+++ /dev/null
@@ -1,160 +0,0 @@
-From 2ee9103f13e0ed3729aed93cdedc723067335e68 Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Wed, 30 Jun 2010 09:21:22 +1000
-Subject: [PATCH 4/4] xkb: merge lockedPtrButtons state from all attached SDs.
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Problem:
-lockedPtrButtons keeps the state of the buttons locked by a PointerKeys button
-press. Unconditionally clearing the bits may cause stuck buttons in this
-sequence of events:
-
-1. type Shift + NumLock to enable PointerKeys
-2. type 0/Ins on keypad to emulate Button 1 press
-        → button1 press event to client
-3. press and release button 1 on physical mouse
-        → button1 release event to client
-
-Button 1 on the MD is now stuck and cannot be released.
-
-Cause:
-XKB PointerKeys button events are posted through the XTEST pointer device.
-Once a press is generated, the XTEST device's button is down. The DIX merges
-the button state of all attached SDs, hence the MD will have a button down
-while the XTEST device has a button down.
-
-PointerKey button events are only generated on the master device to avoid
-duplicate events (see XkbFakeDeviceButton()). If the MD has the
-lockedPtrButtons bit cleared by a release event on a physical device, no
-such event is generated when a keyboard device triggers the PointerKey
-ButtonRelease trigger. Since the event - if generated - is posted through
-the XTEST pointer device, lack of a generated ButtonRelease event on the
-XTEST pointer device means the button is never released, resulting in the
-stuck button observed above.
-
-Solution:
-This patch merges the MD's lockedPtrButtons with the one of all attached
-slave devices on release events. Thus, as long as one attached keyboard has
-a lockedPtrButtons bit set, this bit is kept in the MD. Once a PointerKey
-button is released on all keyboards, the matching release event is emulated
-from the MD through the XTEST pointer device, thus also releasing the button
-in the DIX.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-
-Conflicts:
-
-	xkb/xkbActions.c
-
-Signed-off-by: Fedora X Ninjas <x@fedoraproject.org>
----
- include/xkbsrv.h |    3 +++
- xkb/xkbAccessX.c |   18 +++++++++++++++++-
- xkb/xkbActions.c |   10 ++++++++++
- xkb/xkbUtils.c   |   26 ++++++++++++++++++++++++++
- 4 files changed, 56 insertions(+), 1 deletions(-)
-
-diff --git a/include/xkbsrv.h b/include/xkbsrv.h
-index c2da3f3..aab833f 100644
---- a/include/xkbsrv.h
-+++ b/include/xkbsrv.h
-@@ -938,6 +938,9 @@ extern int XkbGetEffectiveGroup(
-         XkbStatePtr             /* xkbstate */,
-         CARD8                   /* keycode */);
- 
-+extern void XkbMergeLockedPtrBtns(
-+        DeviceIntPtr            /* master */);
-+
- #include "xkbfile.h"
- #include "xkbrules.h"
- 
-diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
-index 0d8e4eb..670f368 100644
---- a/xkb/xkbAccessX.c
-+++ b/xkb/xkbAccessX.c
-@@ -707,8 +707,24 @@ DeviceEvent     *event = &ev->device_event;
- 	    changed |= XkbPointerButtonMask;
-     }
-     else if (event->type == ET_ButtonRelease) {
--	if (xkbi)
-+	if (xkbi) {
- 	    xkbi->lockedPtrButtons&= ~(1 << (event->detail.key & 0x7));
-+
-+            /* Merge this MD's lockedPtrButtons with the one of all
-+             * attached slave devices.
-+             * The DIX uses a merged button state for MDs, not
-+             * releasing buttons until the last SD has released
-+             * thenm. If we unconditionally clear the
-+             * lockedPtrButtons bit on the MD, a PointerKeys button
-+             * release on the SD keyboard won't generate the required fake button
-+             * event on the XTEST pointer, thus never processing the
-+             * button event in the DIX and the XTEST pointer's
-+             * buttons stay down - result is a stuck button.
-+             */
-+	    if (IsMaster(dev))
-+                XkbMergeLockedPtrBtns(dev);
-+	}
-+
- 	changed |= XkbPointerButtonMask;
-     }
- 
-diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
-index 3f57202..e68b782 100644
---- a/xkb/xkbActions.c
-+++ b/xkb/xkbActions.c
-@@ -626,6 +626,16 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
- 		    break;
- 		}
- 		xkbi->lockedPtrButtons&= ~(1<<button);
-+
-+		if (IsMaster(xkbi->device))
-+		{
-+		    XkbMergeLockedPtrBtns(xkbi->device);
-+                    /* One SD still has lock set, don't post event */
-+		    if ((xkbi->lockedPtrButtons & (1 << button)) != 0)
-+			break;
-+		}
-+
-+		/* fallthrough */
- 	    case XkbSA_PtrBtn:
- 		XkbFakeDeviceButton(xkbi->device, 0, button);
- 		break;
-diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
-index fe093a4..6294858 100644
---- a/xkb/xkbUtils.c
-+++ b/xkb/xkbUtils.c
-@@ -2190,3 +2190,29 @@ XkbGetEffectiveGroup(XkbSrvInfoPtr xkbi, XkbStatePtr xkbState, CARD8 keycode)
- 
-     return effectiveGroup;
- }
-+
-+/* Merge the lockedPtrButtons from all attached SDs for the given master
-+ * device into the MD's state.
-+ */
-+void
-+XkbMergeLockedPtrBtns(DeviceIntPtr master)
-+{
-+    DeviceIntPtr d = inputInfo.devices;
-+    XkbSrvInfoPtr xkbi = NULL;
-+
-+    if (!IsMaster(master))
-+        return;
-+
-+    if (!master->key)
-+        return;
-+
-+    xkbi = master->key->xkbInfo;
-+    xkbi->lockedPtrButtons = 0;
-+
-+    for (; d; d = d->next) {
-+        if (IsMaster(d) || GetMaster(d, MASTER_KEYBOARD) != master || !d->key)
-+            continue;
-+
-+        xkbi->lockedPtrButtons |= d->key->xkbInfo->lockedPtrButtons;
-+    }
-+}
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-pointerkeys-on-master.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-pointerkeys-on-master.patch
deleted file mode 100644
index 8be9770..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-pointerkeys-on-master.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From cd73cd8cdd64b73e0d371d90843a78fb5fa471bd Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Tue, 29 Jun 2010 15:24:51 +1000
-Subject: [PATCH 3/4] xkb: emulate PointerKeys events only on the master device.
-
-This patch replicates the behaviour for button events. Only generate a
-PointerKeys motion event on the master device, not on the slave device.
-Fixes the current issue of PointerKey motion events generating key events as
-well.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- xkb/xkbActions.c |    9 ++++-----
- 1 files changed, 4 insertions(+), 5 deletions(-)
-
-diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
-index 8d70a55..3f57202 100644
---- a/xkb/xkbActions.c
-+++ b/xkb/xkbActions.c
-@@ -496,9 +496,6 @@ _XkbFilterPointerMove(	XkbSrvInfoPtr	xkbi,
- int	x,y;
- Bool	accel;
- 
--    if (xkbi->device == inputInfo.keyboard)
--        return 0;
--
-     if (filter->keycode==0) {		/* initial press */
- 	filter->keycode = keycode;
- 	filter->active = 1;
-@@ -1329,10 +1326,12 @@ XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
-     DeviceIntPtr        ptr;
-     int                 gpe_flags = 0;
- 
--    if (!dev->u.master)
-+    if (IsMaster(dev))
-+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
-+    else if (!dev->u.master)
-         ptr = dev;
-     else
--        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
-+        return;
- 
-     if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
-         gpe_flags = POINTER_ABSOLUTE;
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-purge-includes.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-purge-includes.patch
deleted file mode 100644
index dc38339..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-purge-includes.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From e2bebcd40bf5826eeba90e1242e2b946b2d2265e Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Wed, 14 Apr 2010 09:48:53 +1000
-Subject: [PATCH 1/4] xkb: purge unneeded includes from ddxDevBtn.c
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
----
- xkb/ddxDevBtn.c |    9 ---------
- 1 files changed, 0 insertions(+), 9 deletions(-)
-
-diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
-index b8a222d..b8a1255 100644
---- a/xkb/ddxDevBtn.c
-+++ b/xkb/ddxDevBtn.c
-@@ -28,18 +28,9 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
- #include <dix-config.h>
- #endif
- 
--#include <stdio.h>
--#include <X11/X.h>
--#include <X11/Xproto.h>
--#include <X11/keysym.h>
- #include "inputstr.h"
--#include "scrnintstr.h"
--#include "windowstr.h"
--#include "eventstr.h"
- #include <xkbsrv.h>
- #include "mi.h"
--#include <X11/extensions/XI.h>
--#include <X11/extensions/XIproto.h>
- 
- void
- XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-rename-fakebutton.patch b/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-rename-fakebutton.patch
deleted file mode 100644
index cb21c69..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xserver-1.7.7-xkb-rename-fakebutton.patch
+++ /dev/null
@@ -1,398 +0,0 @@
-From 6c5ac8e2258c5d23d04f5799c0471b8404a717ec Mon Sep 17 00:00:00 2001
-From: Fedora X Ninjas <x@fedoraproject.org>
-Date: Tue, 29 Jun 2010 14:29:04 +1000
-Subject: [PATCH 2/4] xkb: rename XkbFakeDeviceButton and XkbFakeDeviceMotion, move into xkbActions.c
-
-The name XkbDDXFakeDeviceButton and XkbDDXFakeDeviceMotion is somewhat
-misleading, there's no DDX involved in the game at all anymore.
-
-This removes XkbFakeDeviceMotion and XkbFakeDeviceButton from the API where
-it arguably shouldn't have been in the first place.
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
-
-Conflicts:
-
-	xkb/xkbActions.c
----
- include/xkbsrv.h |   13 -------
- xkb/Makefile.am  |    4 +--
- xkb/ddxDevBtn.c  |   69 --------------------------------------
- xkb/ddxFakeMtn.c |   64 -----------------------------------
- xkb/xkbActions.c |   97 ++++++++++++++++++++++++++++++++++++++++++++++-------
- 5 files changed, 85 insertions(+), 162 deletions(-)
- delete mode 100644 xkb/ddxDevBtn.c
- delete mode 100644 xkb/ddxFakeMtn.c
-
-diff --git a/include/xkbsrv.h b/include/xkbsrv.h
-index de8ec90..c2da3f3 100644
---- a/include/xkbsrv.h
-+++ b/include/xkbsrv.h
-@@ -786,19 +786,6 @@ extern _X_EXPORT void XkbDDXUpdateDeviceIndicators(
- 	CARD32			/* newState */
- );
- 
--extern _X_EXPORT void XkbDDXFakePointerMotion(
--	DeviceIntPtr	/* dev */,
-- 	unsigned int	/* flags */,
--	int		/* x */,
--	int		/* y */
--);
--
--extern _X_EXPORT void XkbDDXFakeDeviceButton(
--	DeviceIntPtr	/* dev */,
--	Bool		/* press */,
--	int		/* button */
--);
--
- extern _X_EXPORT int XkbDDXTerminateServer(
- 	DeviceIntPtr	/* dev */,
- 	KeyCode		/* key */,
-diff --git a/xkb/Makefile.am b/xkb/Makefile.am
-index b85ee8a..c88fbd0 100644
---- a/xkb/Makefile.am
-+++ b/xkb/Makefile.am
-@@ -6,11 +6,9 @@ AM_CFLAGS = $(DIX_CFLAGS) \
- DDX_SRCS = \
-         ddxBeep.c \
-         ddxCtrls.c \
--        ddxFakeMtn.c \
-         ddxLEDs.c \
-         ddxLoad.c \
--        ddxList.c \
--        ddxDevBtn.c
-+        ddxList.c
- 
- DIX_SRCS = \
-         xkb.c \
-diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
-deleted file mode 100644
-index b8a1255..0000000
---- a/xkb/ddxDevBtn.c
-+++ /dev/null
-@@ -1,69 +0,0 @@
--/************************************************************
--Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
--
--Permission to use, copy, modify, and distribute this
--software and its documentation for any purpose and without
--fee is hereby granted, provided that the above copyright
--notice appear in all copies and that both that copyright
--notice and this permission notice appear in supporting
--documentation, and that the name of Silicon Graphics not be 
--used in advertising or publicity pertaining to distribution 
--of the software without specific prior written permission.
--Silicon Graphics makes no representation about the suitability 
--of this software for any purpose. It is provided "as is"
--without any express or implied warranty.
--
--SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
--SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
--AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
--GRAPHICS BE LIABLE FOR ANY SPECIAL, 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.
--
--********************************************************/
--
--#ifdef HAVE_DIX_CONFIG_H
--#include <dix-config.h>
--#endif
--
--#include "inputstr.h"
--#include <xkbsrv.h>
--#include "mi.h"
--
--void
--XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
--{
--    EventListPtr        events;
--    int                 nevents, i;
--    DeviceIntPtr        ptr;
--
--    /* If dev is a slave device, and the SD is attached, do nothing. If we'd
--     * post through the attached master pointer we'd get duplicate events.
--     *
--     * if dev is a master keyboard, post through the XTEST device
--     *
--     * if dev is a floating slave, post through the device itself.
--     */
--
--    if (IsMaster(dev))
--        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
--    else if (!dev->u.master)
--        ptr = dev;
--    else
--        return;
--
--    events = InitEventList(GetMaximumEventsNum());
--    OsBlockSignals();
--    nevents = GetPointerEvents(events, ptr,
--                               press ? ButtonPress : ButtonRelease, button,
--                               0 /* flags */, 0 /* first */,
--                               0 /* num_val */, NULL);
--    OsReleaseSignals();
--
--    for (i = 0; i < nevents; i++)
--        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
--
--    FreeEventList(events, GetMaximumEventsNum());
--}
-diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c
-deleted file mode 100644
-index b383716..0000000
---- a/xkb/ddxFakeMtn.c
-+++ /dev/null
-@@ -1,64 +0,0 @@
--/************************************************************
--Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
--
--Permission to use, copy, modify, and distribute this
--software and its documentation for any purpose and without
--fee is hereby granted, provided that the above copyright
--notice appear in all copies and that both that copyright
--notice and this permission notice appear in supporting
--documentation, and that the name of Silicon Graphics not be 
--used in advertising or publicity pertaining to distribution 
--of the software without specific prior written permission.
--Silicon Graphics makes no representation about the suitability 
--of this software for any purpose. It is provided "as is"
--without any express or implied warranty.
--
--SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
--SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
--AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
--GRAPHICS BE LIABLE FOR ANY SPECIAL, 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.
--
--********************************************************/
--
--#ifdef HAVE_DIX_CONFIG_H
--#include <dix-config.h>
--#endif
--
--#include "inputstr.h"
--#include <xkbsrv.h>
--#include "mi.h"
--
--void
--XkbDDXFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
--{
--    EventListPtr        events;
--    int                 nevents, i;
--    DeviceIntPtr        ptr;
--    int                 gpe_flags = 0;
--
--    if (!dev->u.master)
--        ptr = dev;
--    else
--        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
--
--    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
--        gpe_flags = POINTER_ABSOLUTE;
--    else
--        gpe_flags = POINTER_RELATIVE;
--
--    events = InitEventList(GetMaximumEventsNum());
--    OsBlockSignals();
--    nevents = GetPointerEvents(events, ptr,
--                               MotionNotify, 0,
--                               gpe_flags, 0, 2, (int[]){x, y});
--    OsReleaseSignals();
--
--    for (i = 0; i < nevents; i++)
--        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
--
--    FreeEventList(events, GetMaximumEventsNum());
--}
-diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
-index 663f033..8d70a55 100644
---- a/xkb/xkbActions.c
-+++ b/xkb/xkbActions.c
-@@ -40,11 +40,15 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
- #include <xkbsrv.h>
- #include "xkb.h"
- #include <ctype.h>
-+#include "mi.h"
- #define EXTENSION_EVENT_BASE 64
- 
- static int xkbDevicePrivateKeyIndex;
- DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKeyIndex;
- 
-+static void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
-+static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y);
-+
- void
- xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
-                    pointer data)
-@@ -479,7 +483,7 @@ int		dx,dy;
- 	dx= xkbi->mouseKeysDX;
- 	dy= xkbi->mouseKeysDY;
-     }
--    XkbDDXFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
-+    XkbFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
-     return xkbi->desc->ctrls->mk_interval;
- }
- 
-@@ -507,7 +511,7 @@ Bool	accel;
- 	accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
- 	x= XkbPtrActionX(&pAction->ptr);
- 	y= XkbPtrActionY(&pAction->ptr);
--	XkbDDXFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
-+	XkbFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
- 	AccessXCancelRepeatKey(xkbi,keycode);
- 	xkbi->mouseKeysAccel= accel&&
- 		(xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
-@@ -554,7 +558,7 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
- 			((pAction->btn.flags&XkbSA_LockNoLock)==0)) {
- 		    xkbi->lockedPtrButtons|= (1<<button);
- 		    AccessXCancelRepeatKey(xkbi,keycode);
--		    XkbDDXFakeDeviceButton(xkbi->device, 1, button);
-+		    XkbFakeDeviceButton(xkbi->device, 1, button);
- 		    filter->upAction.type= XkbSA_NoAction;
- 		}
- 		break;
-@@ -565,12 +569,12 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
- 		    if (pAction->btn.count>0) {
- 			nClicks= pAction->btn.count;
- 			for (i=0;i<nClicks;i++) {
--			    XkbDDXFakeDeviceButton(xkbi->device, 1, button);
--			    XkbDDXFakeDeviceButton(xkbi->device, 0, button);
-+			    XkbFakeDeviceButton(xkbi->device, 1, button);
-+			    XkbFakeDeviceButton(xkbi->device, 0, button);
- 			}
- 			filter->upAction.type= XkbSA_NoAction;
- 		    }
--		    else XkbDDXFakeDeviceButton(xkbi->device, 1, button);
-+		    else XkbFakeDeviceButton(xkbi->device, 1, button);
- 		}
- 		break;
- 	    case XkbSA_SetPtrDflt:
-@@ -626,7 +630,7 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
- 		}
- 		xkbi->lockedPtrButtons&= ~(1<<button);
- 	    case XkbSA_PtrBtn:
--		XkbDDXFakeDeviceButton(xkbi->device, 0, button);
-+		XkbFakeDeviceButton(xkbi->device, 0, button);
- 		break;
- 	}
- 	filter->active = 0;
-@@ -964,7 +968,7 @@ int		button;
- 		if ((pAction->devbtn.flags&XkbSA_LockNoLock)||
- 		    BitIsOn(dev->button->down, button))
- 		    return 0;
--		XkbDDXFakeDeviceButton(dev,True,button);
-+		XkbFakeDeviceButton(dev,TRUE,button);
- 		filter->upAction.type= XkbSA_NoAction;
- 		break;
- 	    case XkbSA_DeviceBtn:
-@@ -972,12 +976,12 @@ int		button;
- 		    int nClicks,i;
- 		    nClicks= pAction->btn.count;
- 		    for (i=0;i<nClicks;i++) {
--			XkbDDXFakeDeviceButton(dev,True,button);
--			XkbDDXFakeDeviceButton(dev,False,button);
-+			XkbFakeDeviceButton(dev,TRUE,button);
-+			XkbFakeDeviceButton(dev,FALSE,button);
- 		    }
- 		    filter->upAction.type= XkbSA_NoAction;
- 		}
--		else XkbDDXFakeDeviceButton(dev,True,button);
-+		else XkbFakeDeviceButton(dev,TRUE,button);
- 		break;
- 	}
-     }
-@@ -996,10 +1000,10 @@ int		button;
- 		if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)||
- 		    !BitIsOn(dev->button->down, button))
- 		    return 0;
--		XkbDDXFakeDeviceButton(dev,False,button);
-+		XkbFakeDeviceButton(dev,FALSE,button);
- 		break;
- 	    case XkbSA_DeviceBtn:
--		XkbDDXFakeDeviceButton(dev,False,button);
-+		XkbFakeDeviceButton(dev,FALSE,button);
- 		break;
- 	}
- 	filter->active = 0;
-@@ -1317,3 +1321,70 @@ xkbStateNotify	sn;
-     return;
- }
- 
-+static void
-+XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
-+{
-+    EventListPtr        events;
-+    int                 nevents, i;
-+    DeviceIntPtr        ptr;
-+    int                 gpe_flags = 0;
-+
-+    if (!dev->u.master)
-+        ptr = dev;
-+    else
-+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
-+
-+    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
-+        gpe_flags = POINTER_ABSOLUTE;
-+    else
-+        gpe_flags = POINTER_RELATIVE;
-+
-+    events = InitEventList(GetMaximumEventsNum());
-+    OsBlockSignals();
-+    nevents = GetPointerEvents(events, ptr,
-+                               MotionNotify, 0,
-+                               gpe_flags, 0, 2, (int[]){x, y});
-+    OsReleaseSignals();
-+
-+    for (i = 0; i < nevents; i++)
-+        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
-+
-+    FreeEventList(events, GetMaximumEventsNum());
-+}
-+
-+static void
-+XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
-+{
-+    EventListPtr        events;
-+    int                 nevents, i;
-+    DeviceIntPtr        ptr;
-+
-+    /* If dev is a slave device, and the SD is attached, do nothing. If we'd
-+     * post through the attached master pointer we'd get duplicate events.
-+     *
-+     * if dev is a master keyboard, post through the XTEST device
-+     *
-+     * if dev is a floating slave, post through the device itself.
-+     */
-+
-+    if (IsMaster(dev))
-+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
-+    else if (!dev->u.master)
-+        ptr = dev;
-+    else
-+        return;
-+
-+    events = InitEventList(GetMaximumEventsNum());
-+    OsBlockSignals();
-+    nevents = GetPointerEvents(events, ptr,
-+                               press ? ButtonPress : ButtonRelease, button,
-+                               0 /* flags */, 0 /* first */,
-+                               0 /* num_val */, NULL);
-+    OsReleaseSignals();
-+
-+
-+    for (i = 0; i < nevents; i++)
-+        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
-+
-+    FreeEventList(events, GetMaximumEventsNum());
-+}
--- 
-1.7.1
-
diff --git a/contrib/packages/rpm/el5/SOURCES/xtrans-1.0.3-avoid-gethostname.patch b/contrib/packages/rpm/el5/SOURCES/xtrans-1.0.3-avoid-gethostname.patch
deleted file mode 100644
index 5d474d5..0000000
--- a/contrib/packages/rpm/el5/SOURCES/xtrans-1.0.3-avoid-gethostname.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -up xtrans-1.0.3/Xtransutil.c.jx xtrans-1.0.3/Xtransutil.c
---- xtrans-1.0.3/Xtransutil.c.jx	2006-12-06 11:08:53.000000000 -0500
-+++ xtrans-1.0.3/Xtransutil.c	2007-10-01 14:53:43.000000000 -0400
-@@ -271,6 +271,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ci
-     case AF_UNIX:
-     {
- 	struct sockaddr_un *saddr = (struct sockaddr_un *) addr;
-+	strcpy(hostnamebuf, "unix");
- 	networkId = (char *) xalloc (3 + strlen (transName) +
- 	    strlen (hostnamebuf) + strlen (saddr->sun_path));
- 	sprintf (networkId, "%s/%s:%s", transName,
diff --git a/contrib/packages/rpm/el5/SPECS/tigervnc.spec b/contrib/packages/rpm/el5/SPECS/tigervnc.spec
index b863311..93c2a78 100644
--- a/contrib/packages/rpm/el5/SPECS/tigervnc.spec
+++ b/contrib/packages/rpm/el5/SPECS/tigervnc.spec
@@ -1,10 +1,11 @@
 %define _default_patch_fuzz 2
-%define mesa_version 7.7.1
+%define tigervnc_src_dir %{_builddir}/%{name}-%{version}%{?snap:-%{snap}}
+%define xorg_buildroot %{tigervnc_src_dir}/xorg.build
 %{!?_self_signed: %define _self_signed 1}
 
 Name: tigervnc
 Version: @VERSION@
-Release: 18%{?snap:.%{snap}}%{?dist}
+Release: 5%{?snap:.%{snap}}%{?dist}
 Summary: A TigerVNC remote display system
 
 Group: User Interface/Desktops
@@ -17,128 +18,93 @@
 Source2: vncserver.sysconfig
 Source6: vncviewer.desktop
 Source9: FindX11.cmake
-Source11: http://fltk.org/pub/fltk/1.3.2/fltk-1.3.2-source.tar.gz
+Source11: http://fltk.org/pub/fltk/1.3.3/fltk-1.3.3-source.tar.gz
 Source12: http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz
+Source13: http://downloads.sourceforge.net/project/libpng/libpng15/older-releases/1.5.10/libpng-1.5.10.tar.bz2
 
-# http://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/xorg-x11-proto-devel-7.6-13.el6.src.rpm
-# http://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/
-Source98: http://www.x.org/releases/X11R7.5/src/util/makedepend-1.0.2.tar.bz2
-Source99: http://xcb.freedesktop.org/dist/libpthread-stubs-0.3.tar.bz2
-Source100: http://www.x.org/releases/X11R7.5/src/lib/libICE-1.0.6.tar.bz2
-Source101: http://www.x.org/releases/X11R7.5/src/lib/libSM-1.1.1.tar.bz2
-Source102: http://www.x.org/releases/X11R7.5/src/lib/libX11-1.3.2.tar.bz2
-Source103: http://www.x.org/releases/X11R7.5/src/lib/libXScrnSaver-1.2.0.tar.bz2
-Source104: http://www.x.org/releases/X11R7.5/src/lib/libXau-1.0.5.tar.bz2
-Source105: http://www.x.org/releases/X11R7.5/src/lib/libXaw-1.0.7.tar.bz2
-Source106: http://www.x.org/releases/X11R7.5/src/lib/libXcomposite-0.4.1.tar.bz2
-Source107: http://www.x.org/releases/X11R7.5/src/lib/libXcursor-1.1.10.tar.bz2
-Source108: http://www.x.org/releases/X11R7.5/src/lib/libXdamage-1.1.2.tar.bz2
-Source109: http://www.x.org/releases/X11R7.5/src/lib/libXdmcp-1.0.3.tar.bz2
-Source110: http://www.x.org/releases/individual/lib/libXext-1.1.tar.bz2
-Source111: http://www.x.org/releases/X11R7.5/src/lib/libXfixes-4.0.4.tar.bz2
-Source112: http://www.x.org/releases/X11R7.5/src/lib/libXfont-1.4.1.tar.bz2
-Source113: http://www.x.org/releases/X11R7.5/src/lib/libXft-2.1.14.tar.bz2
-Source114: http://www.x.org/releases/X11R7.5/src/lib/libXi-1.3.tar.bz2
-Source115: http://www.x.org/releases/X11R7.5/src/lib/libXinerama-1.1.tar.bz2
-Source116: http://www.x.org/releases/X11R7.5/src/lib/libXmu-1.0.5.tar.bz2
-Source117: http://www.x.org/releases/X11R7.5/src/lib/libXpm-3.5.8.tar.bz2
-Source118: http://www.x.org/releases/X11R7.5/src/lib/libXrandr-1.3.0.tar.bz2
-Source119: http://www.x.org/releases/X11R7.5/src/lib/libXrender-0.9.5.tar.bz2
-Source120: http://www.x.org/releases/X11R7.5/src/lib/libXt-1.0.7.tar.bz2
-Source121: http://www.x.org/releases/X11R7.5/src/lib/libXtst-1.1.0.tar.bz2
-Source122: http://www.x.org/releases/X11R7.5/src/lib/libXv-1.0.5.tar.bz2
-Source123: http://www.x.org/releases/X11R7.5/src/lib/libXvMC-1.0.5.tar.bz2
-Source124: http://www.x.org/releases/X11R7.5/src/lib/libXxf86dga-1.1.1.tar.bz2
-Source125: http://www.x.org/releases/X11R7.5/src/lib/libXxf86vm-1.1.0.tar.bz2
-Source126: http://www.x.org/releases/X11R7.5/src/lib/libfontenc-1.0.5.tar.bz2
-Source127: http://www.x.org/releases/X11R7.5/src/lib/libpciaccess-0.10.9.tar.bz2
-Source128: http://www.x.org/releases/X11R7.5/src/lib/libxkbfile-1.0.6.tar.bz2
-Source129: http://www.x.org/releases/X11R7.5/src/lib/xtrans-1.2.5.tar.bz2
-Source130: http://xorg.freedesktop.org/archive/individual/proto/bigreqsproto-1.1.0.tar.bz2
-Source131: http://xorg.freedesktop.org/archive/individual/proto/compositeproto-0.4.1.tar.bz2
-Source132: http://xorg.freedesktop.org/archive/individual/proto/damageproto-1.2.0.tar.bz2
-Source133: http://xorg.freedesktop.org/archive/individual/proto/evieext-1.1.1.tar.bz2
-Source134: http://xorg.freedesktop.org/archive/individual/proto/fixesproto-5.0.tar.bz2
-Source135: http://xorg.freedesktop.org/archive/individual/proto/fontsproto-2.1.0.tar.bz2
-Source136: http://xorg.freedesktop.org/archive/individual/proto/glproto-1.4.12.tar.bz2
-Source137: http://xorg.freedesktop.org/archive/individual/proto/inputproto-2.0.2.tar.bz2
-Source138: http://xorg.freedesktop.org/archive/individual/proto/kbproto-1.0.5.tar.bz2
-Source139: http://xorg.freedesktop.org/archive/individual/proto/randrproto-1.3.1.tar.bz2
-#Source139: http://xorg.freedesktop.org/archive/individual/proto/randrproto-20110224-git105a161.tar.bz2
-Source140: http://xorg.freedesktop.org/archive/individual/proto/recordproto-1.14.1.tar.bz2
-Source141: http://xorg.freedesktop.org/archive/individual/proto/renderproto-0.11.1.tar.bz2
-Source142: http://xorg.freedesktop.org/archive/individual/proto/resourceproto-1.2.0.tar.bz2
-Source143: http://xorg.freedesktop.org/archive/individual/proto/scrnsaverproto-1.2.1.tar.bz2
-Source144: http://xorg.freedesktop.org/archive/individual/proto/videoproto-2.3.1.tar.bz2
-Source145: http://xorg.freedesktop.org/archive/individual/proto/xcmiscproto-1.2.1.tar.bz2
-Source146: http://xorg.freedesktop.org/archive/individual/proto/xextproto-7.2.0.tar.bz2
-Source147: http://xorg.freedesktop.org/archive/individual/proto/xf86bigfontproto-1.2.0.tar.bz2
-Source148: http://xorg.freedesktop.org/archive/individual/proto/xf86dgaproto-2.1.tar.bz2
-Source149: http://xorg.freedesktop.org/archive/individual/proto/xf86driproto-2.1.1.tar.bz2
-Source150: http://xorg.freedesktop.org/archive/individual/proto/xf86miscproto-0.9.3.tar.bz2
-Source151: http://xorg.freedesktop.org/archive/individual/proto/xf86vidmodeproto-2.3.1.tar.bz2
-Source152: http://xorg.freedesktop.org/archive/individual/proto/xineramaproto-1.2.1.tar.bz2
-Source153: http://xorg.freedesktop.org/archive/individual/proto/xproto-7.0.22.tar.bz2
-Source154: http://xorg.freedesktop.org/archive/individual/proto/dri2proto-2.3.tar.bz2
+Source100: http://www.x.org/releases/X11R7.7/src/everything/bigreqsproto-1.1.2.tar.bz2
+Source101: http://www.x.org/releases/X11R7.7/src/everything/compositeproto-0.4.2.tar.bz2
+Source102: http://www.x.org/releases/X11R7.7/src/everything/damageproto-1.2.1.tar.bz2
+Source103: http://www.x.org/releases/X11R7.7/src/everything/dmxproto-2.3.1.tar.bz2
+Source104: http://www.x.org/releases/X11R7.7/src/everything/dri2proto-2.6.tar.bz2
+Source105: http://www.x.org/releases/X11R7.7/src/everything/fixesproto-5.0.tar.bz2
+Source106: http://www.x.org/releases/X11R7.7/src/everything/font-util-1.3.0.tar.bz2
+Source107: http://www.x.org/releases/X11R7.7/src/everything/fontsproto-2.1.2.tar.bz2
+Source108: http://www.x.org/releases/X11R7.7/src/everything/glproto-1.4.15.tar.bz2
+Source109: http://www.x.org/releases/X11R7.7/src/everything/inputproto-2.2.tar.bz2
+Source110: http://www.x.org/releases/X11R7.7/src/everything/kbproto-1.0.6.tar.bz2
+Source111: http://www.x.org/releases/X11R7.7/src/everything/libICE-1.0.8.tar.bz2
+Source112: http://www.x.org/releases/X11R7.7/src/everything/libSM-1.2.1.tar.bz2
+Source113: http://www.x.org/releases/X11R7.7/src/everything/libX11-1.5.0.tar.bz2
+Source114: http://www.x.org/releases/X11R7.7/src/everything/libXScrnSaver-1.2.2.tar.bz2
+Source115: http://www.x.org/releases/X11R7.7/src/everything/libXau-1.0.7.tar.bz2
+Source116: http://www.x.org/releases/X11R7.7/src/everything/libXaw-1.0.11.tar.bz2
+Source117: http://www.x.org/releases/X11R7.7/src/everything/libXcomposite-0.4.3.tar.bz2
+Source118: http://www.x.org/releases/X11R7.7/src/everything/libXcursor-1.1.13.tar.bz2
+Source119: http://www.x.org/releases/X11R7.7/src/everything/libXdamage-1.1.3.tar.bz2
+Source120: http://www.x.org/releases/X11R7.7/src/everything/libXdmcp-1.1.1.tar.bz2
+Source121: http://www.x.org/releases/X11R7.7/src/everything/libXext-1.3.1.tar.bz2
+Source122: http://www.x.org/releases/X11R7.7/src/everything/libXfixes-5.0.tar.bz2
+Source123: http://www.x.org/releases/X11R7.7/src/everything/libXfont-1.4.5.tar.bz2
+Source124: http://www.x.org/releases/X11R7.7/src/everything/libXft-2.3.1.tar.bz2
+Source125: http://www.x.org/releases/X11R7.7/src/everything/libXi-1.6.1.tar.bz2
+Source126: http://www.x.org/releases/X11R7.7/src/everything/libXinerama-1.1.2.tar.bz2
+Source127: http://www.x.org/releases/X11R7.7/src/everything/libXmu-1.1.1.tar.bz2
+Source128: http://www.x.org/releases/X11R7.7/src/everything/libXpm-3.5.10.tar.bz2
+Source129: http://www.x.org/releases/X11R7.7/src/everything/libXrandr-1.3.2.tar.bz2
+Source130: http://www.x.org/releases/X11R7.7/src/everything/libXrender-0.9.7.tar.bz2
+Source131: http://www.x.org/releases/X11R7.7/src/everything/libXres-1.0.6.tar.bz2
+Source132: http://www.x.org/releases/X11R7.7/src/everything/libXt-1.1.3.tar.bz2
+Source133: http://www.x.org/releases/X11R7.7/src/everything/libXtst-1.2.1.tar.bz2
+Source134: http://www.x.org/releases/X11R7.7/src/everything/libXv-1.0.7.tar.bz2
+Source135: http://www.x.org/releases/X11R7.7/src/everything/libXvMC-1.0.7.tar.bz2
+Source136: http://www.x.org/releases/X11R7.7/src/everything/libXxf86dga-1.1.3.tar.bz2
+Source137: http://www.x.org/releases/X11R7.7/src/everything/libXxf86vm-1.1.2.tar.bz2
+Source138: http://www.x.org/releases/X11R7.7/src/everything/libfontenc-1.1.1.tar.bz2
+Source139: http://www.x.org/releases/X11R7.7/src/everything/libpciaccess-0.13.1.tar.bz2
+#Source140: http://www.x.org/releases/X11R7.7/src/everything/libpthread-stubs-0.3.tar.bz2
+# libpthread-stubs fails to compile, so we use the same method
+# as the el6 libxcb rpm. pthread-stubs.pc.in taken from el6 libxcb rpm
+Source140: pthread-stubs.pc.in
+Source141: http://www.x.org/releases/X11R7.7/src/everything/libxcb-1.8.1.tar.bz2
+Source142: http://www.x.org/releases/X11R7.7/src/everything/libxkbfile-1.0.8.tar.bz2
+Source143: http://www.x.org/releases/X11R7.7/src/everything/makedepend-1.0.4.tar.bz2
+Source144: http://www.x.org/releases/X11R7.7/src/everything/randrproto-1.3.2.tar.bz2
+Source145: http://www.x.org/releases/X11R7.7/src/everything/recordproto-1.14.2.tar.bz2
+Source146: http://www.x.org/releases/X11R7.7/src/everything/renderproto-0.11.1.tar.bz2
+Source147: http://www.x.org/releases/X11R7.7/src/everything/resourceproto-1.2.0.tar.bz2
+Source148: http://www.x.org/releases/X11R7.7/src/everything/scrnsaverproto-1.2.2.tar.bz2
+Source149: http://www.x.org/releases/X11R7.7/src/everything/util-macros-1.17.tar.bz2
+Source150: http://www.x.org/releases/X11R7.7/src/everything/videoproto-2.3.1.tar.bz2
+Source151: http://www.x.org/releases/X11R7.7/src/everything/xcb-proto-1.7.1.tar.bz2
+Source152: http://www.x.org/releases/X11R7.7/src/everything/xcmiscproto-1.2.2.tar.bz2
+Source153: http://www.x.org/releases/X11R7.7/src/everything/xextproto-7.2.1.tar.bz2
+Source154: http://www.x.org/releases/X11R7.7/src/everything/xf86bigfontproto-1.2.0.tar.bz2
+Source155: http://www.x.org/releases/X11R7.7/src/everything/xf86dgaproto-2.1.tar.bz2
+Source156: http://www.x.org/releases/X11R7.7/src/everything/xf86driproto-2.1.1.tar.bz2
+Source157: http://www.x.org/releases/X11R7.7/src/everything/xf86vidmodeproto-2.3.1.tar.bz2
+Source158: http://www.x.org/releases/X11R7.7/src/everything/xineramaproto-1.2.1.tar.bz2
+Source159: http://www.x.org/releases/X11R7.7/src/everything/xorg-server-1.12.2.tar.bz2
+Source160: http://www.x.org/releases/X11R7.7/src/everything/xproto-7.0.23.tar.bz2
+Source161: http://www.x.org/releases/X11R7.7/src/everything/xrandr-1.3.5.tar.bz2
+Source162: http://www.x.org/releases/X11R7.7/src/everything/xtrans-1.2.7.tar.bz2
 
-#Source130: http://www.x.org/releases/X11R7.5/src/proto/bigreqsproto-1.1.0.tar.bz2
-#Source131: http://www.x.org/releases/X11R7.5/src/proto/compositeproto-0.4.1.tar.bz2
-#Source132: http://www.x.org/releases/X11R7.5/src/proto/damageproto-1.2.0.tar.bz2
-#Source133: http://www.x.org/releases/X11R7.5/src/proto/dri2proto-2.3.tar.bz2
-#Source134: http://www.x.org/releases/X11R7.5/src/proto/fixesproto-5.0.tar.bz2
-#Source135: http://www.x.org/releases/X11R7.5/src/proto/fontsproto-2.1.0.tar.bz2
-#Source136: http://www.x.org/releases/X11R7.5/src/proto/glproto-1.4.12.tar.bz2
-#Source137: http://www.x.org/releases/X11R7.5/src/proto/inputproto-2.0.2.tar.bz2
-#Source138: http://www.x.org/releases/X11R7.5/src/proto/kbproto-1.0.5.tar.bz2
-#Source139: http://www.x.org/releases/X11R7.5/src/proto/randrproto-20110224-git105a161.tar.bz2
-#Source140: http://www.x.org/releases/X11R7.5/src/proto/recordproto-1.14.1.tar.bz2
-#Source141: http://www.x.org/releases/X11R7.5/src/proto/renderproto-0.11.1.tar.bz2
-#Source142: http://www.x.org/releases/X11R7.5/src/proto/resourceproto-1.2.0.tar.bz2
-#Source143: http://www.x.org/releases/X11R7.5/src/proto/scrnsaverproto-1.2.1.tar.bz2
-#Source144: http://www.x.org/releases/X11R7.5/src/proto/videoproto-2.3.1.tar.bz2
-#Source145: http://www.x.org/releases/X11R7.5/src/proto/xcmiscproto-1.2.1.tar.bz2
-#Source146: http://www.x.org/releases/X11R7.5/src/proto/xextproto-7.2.0.tar.bz2
-#Source147: http://www.x.org/releases/X11R7.5/src/proto/xf86bigfontproto-1.2.0.tar.bz2
-#Source148: http://www.x.org/releases/X11R7.5/src/proto/xf86dgaproto-2.1.tar.bz2
-#Source149: http://www.x.org/releases/X11R7.5/src/proto/xf86driproto-2.1.1.tar.bz2
-#Source150: http://www.x.org/releases/X11R7.5/src/proto/xf86vidmodeproto-2.3.1.tar.bz2
-#Source151: http://www.x.org/releases/X11R7.5/src/proto/xproto-7.0.22.tar.bz2
-
-Source155: http://www.x.org/releases/individual/util/util-macros-1.4.1.tar.bz2
-Source156: http://www.x.org/pub/individual/xserver/xorg-server-1.7.7.tar.bz2
-#Source157: ftp://ftp.x.org/pub/individual/app/xauth-1.0.2.tar.bz2
-#Source158: http://www.x.org/releases/X11R7.5/src/everything/xkbutils-1.0.2.tar.bz2
-Source159: http://dri.freedesktop.org/libdrm/libdrm-2.4.15.tar.bz2
-Source160: http://downloads.sourceforge.net/project/freetype/freetype2/2.3.11/freetype-2.3.11.tar.bz2
-Source161: ftp://ftp.freedesktop.org/pub/mesa/older-versions/7.x/%{mesa_version}/MesaLib-%{mesa_version}.tar.bz2
-Source162: http://cgit.freedesktop.org/pixman/snapshot/pixman-0.26.0.tar.gz
-Source163: http://www.x.org/releases/X11R7.5/src/lib/libXres-1.0.4.tar.bz2
-Source164: http://www.x.org/releases/individual/lib/libXxf86misc-1.0.2.tar.bz2
-
-Source200: http://fontconfig.org/release/fontconfig-2.4.1.tar.gz
-Source201: 25-no-hint-fedora.conf
-Source202: 30-aliases-fedora.conf
-Source203: 40-generic-fedora.conf
-Source204: 64-nonlatin-fedora.conf
-Source205: 75-blacklist-fedora.conf
-
-Source210: fc-cache.1
-Source211: fc-cat.1
-Source212: fc-list.1
-Source213: fc-match.1
-
-# FIXME:
-# need to apply any patches in from the F12 srpms
-# http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/12/Fedora/source/SRPMS/mesa-7.6-0.13.fc12.src.rpm
-# http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/12/Fedora/source/SRPMS/pixman-0.16.2-1.fc12.src.rpm
-# http://vault.centos.org/6.3/os/Source/SPackages/pixman-0.18.4-1.el6_0.1.src.rpm
-# http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/source/SRPMS/libdrm-2.4.15-4.fc12.src.rpm
-# http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/12/Fedora/source/SRPMS/freetype-2.3.9-6.fc12.src.rpm
+Source200: http://fontconfig.org/release/fontconfig-2.8.0.tar.gz
+Source201: http://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-2.3.11.tar.bz2
+Source202: http://xorg.freedesktop.org/archive/individual/lib/pixman-0.32.4.tar.bz2
+Source203: http://dri.freedesktop.org/libdrm/libdrm-2.4.52.tar.bz2
+Source204: ftp://ftp.freedesktop.org/pub/mesa/older-versions/9.x/9.2.5/MesaLib-9.2.5.tar.bz2
+# NOTE:
+#   libgcrypt from el5 is not new enough to satisfy newer Xorg requirements for --with-sha1,
+#   which causes Xorg to link against libssl.so and introduce about 10 dynamic dependencies. 
+#   to prevent this, build a static libsha1 and link against that.
+# NOTE:
+Source205: https://github.com/dottedmag/libsha1/archive/0.3.tar.gz
 
 BuildRoot: %{_tmppath}/%{name}-%{version}%{?snap:-%{snap}}-%{release}-root-%(%{__id_u} -n)
 
-BuildRequires: automake >= 1.7, autoconf >= 2.57, libtool >= 1.4, gettext >= 0.14.4, gettext-devel >= 0.14.4, bison-devel
-BuildRequires: openssl-devel
+# xorg requires newer versions of automake, & autoconf than are available with el5. Use el6 versions.
+BuildRequires: automake >= 1.11, autoconf >= 2.60, libtool >= 1.4, gettext >= 0.14.4, gettext-devel >= 0.14.4, bison-devel, python26
 BuildRequires: desktop-file-utils, java-devel, jpackage-utils
 BuildRequires: gnutls-devel, pam-devel
 BuildRequires: cmake28
@@ -146,7 +112,8 @@
 BuildRequires: gcc44, gcc44-c++
 BuildRequires: glibc-devel, libstdc++-devel, libpng-devel
 BuildRequires: expat-devel
-BuildRequires: gperf, intltool, libtalloc-devel
+BuildRequires: git, gperf, intltool, libtalloc-devel
+BuildRequires: kernel-headers, libatomic_ops-devel
 
 BuildRequires: openmotif-devel
 Requires: openmotif, openmotif22
@@ -160,230 +127,60 @@
 Provides: tightvnc = 1.5.0-0.15.20090204svn3586
 Obsoletes: tightvnc < 1.5.0-0.15.20090204svn3586
 
+# tigervnc patches
 Patch4: tigervnc-cookie.patch
-Patch10: tigervnc11-ldnow.patch
 Patch11: tigervnc11-gethomedir.patch
-# https://bugzilla.redhat.com/show_bug.cgi?id=692048
-Patch14: tigervnc-x0vncserver-static-libs-fix.patch
-Patch15: tigervnc-static-fltk.patch
+Patch12: tigervnc14-static-build-fixes.patch
 
-Patch101: tigervnc-ac-compatibility.patch
-Patch102: tigervnc-xorg-1.7.5-remove-copyisolatin1lowered.patch
-Patch124: fltk-1.3.2-libdl.patch
-Patch125: fltk-1.3.2-static-libs.patch
+# fltk patches
+Patch15: fltk-1.3.3-static-libs.patch
 
-# Patches from libdrm-2.4.15-4.fc12.src.rpm
-# hardcode the 666 instead of 660 for device nodes
-Patch133: libdrm-make-dri-perms-okay.patch
-# remove backwards compat not needed on Fedora
-Patch134: libdrm-2.4.0-no-bc.patch
-
-Patch135: libdrm-page-flip.patch
-
-# nouveau: retry pushbuf ioctl if interrupted by signal
-Patch136: libdrm-nouveau-restart-pushbuf.patch
-# nouveau: drop rendering on floor rather than asserting if flush fails
-Patch137: libdrm-nouveau-drop-rendering.patch
-# nouveau: improve reloc API to allow better error handling
-Patch138: libdrm-nouveau-better-relocs.patch
-
-# patches from mesa-7.11-5.el6.src.rpm
-# ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/mesa-7.11-5.el6.src.rpm
-Patch141: mesa-7.1-osmesa-version.patch
-Patch142: mesa-7.1-nukeglthread-debug.patch
-Patch143: mesa-no-mach64.patch
-
-#Patch147: mesa-7.1-link-shared.patch
-Patch149: intel-revert-vbl.patch
-#Patch1410: r600-fix-tfp.patch
-
-#Patch1413: mesa-7.5-sparc64.patch
-
-Patch1430: mesa-7.6-hush-vblank-warning.patch
-Patch1431: mesa-7.6-glx13-app-warning.patch
-
-#Patch1440: r300g-no-llvm.patch
-
-# 7.11 branch backport
-#Patch1460: mesa-7.11-b9c7773e.patch
-
-# not on 7.11 branch yet
-#Patch1470: mesa-7.11-gen6-depth-stalls.patch
-
-#Patch1480: mesa-r600g-new-pciids.patch
-#Patch1481: mesa-7.11-ivybridge-server-pci-ids.patch
-
-# Patches from EL6 xorg-x11-server-1.7.7 source RPM
-# ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/xorg-x11-server-1.7.7-29.el6_1.2.src.rpm
-Patch5: xserver-1.4.99-pic-libxf86config.patch
-Patch6: xserver-1.7.4-z-now.patch
-
-# OpenGL compositing manager feature/optimization patches.
-Patch103: xserver-1.5.0-bg-none-root.patch
-
-Patch2014: xserver-1.5.0-projector-fb-size.patch
-
-# Trivial things to never merge upstream ever:
-# This really could be done prettier.
-Patch5002: xserver-1.4.99-ssh-isnt-local.patch
-
-# force mode debugging on for randr 1.2 drivers
-Patch6002: xserver-1.5.1-mode-debug.patch
-
-# don't build the (broken) acpi code
-Patch6011: xserver-1.6.0-less-acpi-brokenness.patch
-
-# Make autoconfiguration chose nouveau driver for NVIDIA GPUs
-Patch6016: xserver-1.6.1-nouveau.patch
-
-# ajax needs to upstream this
-Patch6027: xserver-1.6.0-displayfd.patch
-Patch6028: xserver-1.6.99-randr-error-debugging.patch
-Patch6030: xserver-1.6.99-right-of.patch
-Patch6033: xserver-1.6.99-default-modes.patch
-Patch6044: xserver-1.6.99-hush-prerelease-warning.patch
-Patch6045: xserver-1.7.0-randr-gamma-restore.patch
-
-Patch6047: xserver-1.7.0-glx-versioning.patch
-#Patch6048: xserver-1.7.0-exa-fix-mixed.patch
-Patch6049: xserver-1.7.1-multilib.patch
-Patch6051: xserver-1.7.1-gamma-kdm-fix.patch
-Patch6052: xserver-1.7.1-libcrypto.patch
-Patch6066: xserver-1.7.1-glx14-swrast.patch
-
-Patch6067: xserver-1.7.7-exa-master.patch
-
-Patch6070: xserver-1.7.3-no-free-on-abort.patch
-# 558613
-Patch6075: xserver-1.7.4-qxl-autoconfig.patch
-# 516918
-Patch6076: xserver-1.7.4-dpms-timeouts.patch
-Patch6077: xserver-1.7.6-export-dix-functions.patch
-Patch6078: xserver-1.7.6-export-more-dix-functions.patch
-
-# 583544 - Pointer jumps to lower-right corner when clicking mousekeys
-Patch6087: xserver-1.7.6-pointerkeys.patch
-
-Patch7002: xserver-1.7.6-no-connected-outputs.patch
-# 586926 - randr change while off vt
-Patch7003: xserver-1.7.6-randr-vt-switch.patch
-# 582710 - pam support
-Patch7004: xserver-1.1.1-pam.patch
-# 584927 - xinerama coordinate sign fix
-Patch7005: xserver-1.7.6-deviceevent-coordinates-xinerama.patch
-# 585371 - default mode list unification
-Patch7006: xserver-1.7.6-default-modes.patch
-# 586567 - big window crash when try to resize
-Patch7007: xserver-1.7.7-compresize-fix.patch
-# 602080 - fix unnecessary fb resize in multi-head configurations
-Patch7008: xserver-1.7.7-randr-initial.patch
-# 600180  - Buffer overflow in XKB geometry copying code.
-Patch7009: xserver-1.7.7-xkb-invalid-writes.patch
-# 600116  - Properties are not reset in the second server generation
-Patch7010: xserver-1.7.7-property-generation-reset.patch
-# 594523  - Wrong axis mode for absolute axes 
-Patch7011: xserver-1.7.7-device-mode-list.patch
-# 602511  - Stuck modifiers when using multiple keyboards or XTEST
-Patch7012: xserver-1.7.7-modifier-keycount.patch
-# 588640  - XKEYBOARD Warning: Duplicate shape name ""
-Patch7013: xserver-1.7.7-xkb-geom-copy.patch
-# 574486 - Dual head setup overlaps one pixel 
-Patch7014: xserver-1.7.7-fix-randr-rotation.patch
-# 600505 - Xephyr utility should be resizeable
-Patch7015: xserver-1.7.7-make-ephyr-resize.patch
-# 604057 - fix aspect match for classic drivers
-Patch7016: xserver-1.7.7-improve-mode-selection.patch
-# 607045 - DGA client can crash the server
-Patch7017: xserver-1.7.7-dga-master-keyboard.patch
-# 607410 - Reproducible stuck grab on server
-Patch7018: xserver-1.7.7-event-mask-revert.patch
-# 607051 - Keyboard bell settings don't apply to keyboards.
-Patch7019: xserver-1.7.7-sd-keyboard-controls.patch
-# 607022 - segfault during Xorg -showopts
-Patch7020: xserver-1.7.7-showopts-segv.patch
-# Related 607150
-Patch7021: xserver-1.7.7-xkb-purge-includes.patch
-# Related 607150
-Patch7022: xserver-1.7.7-xkb-rename-fakebutton.patch
-# Related 607150
-Patch7023: xserver-1.7.7-xkb-pointerkeys-on-master.patch
-# 607150 - Mouse button never releases when xkb PointerKeys are used
-Patch7024: xserver-1.7.7-xkb-lockedPtrBtns-state-merge.patch
-# 607150 - Mouse button never releases when xkb PointerKeys are used, part2
-Patch7025: xserver-1.7.7-release-xtest-on-phys-buttons.patch
-# 581505 - Xephyr crashes inside kvm-qemu virtual host
-Patch7026: xserver-1.7.7-xephyr-24bpp.patch
-# 605302 - vesa doesn't work on intel gen6
-Patch7027: xserver-1.7.7-int10-reserved-areas.patch
-# 618422 - Wrong handling of devices with more than 2 valuators
-Patch7028: xserver-1.7.7-postfix-DCE-PointerKeys.patch
-# related 618422, Patch7028
-Patch7029: xserver-1.7.7-reset-unused-classes.patch
-# 601319 - LVDS activated when notebook lid is closed
-Patch7030: xserver-1.7.7-lid-hack.patch
-# 585283 - xrandr allows mouse to move into non-existant screen locations
-Patch7031: xserver-1.7.7-randr-cursor-dead-zones.patch
-# 620333 - mga shows blank screen when X server starts
-Patch7032: xserver-1.7.7-ddc-probe-less.patch
-# 638234 - Bump classic driver default resolution to 1024x768
-Patch7033: xserver-1.7.7-classic-default-mode.patch
-
-Patch8000: cve-2011-4818.patch
-Patch8001: cve-2011-4818-extra.patch
-
-# Add -lm when linking X demos
-Patch9020: freetype-2.1.10-enable-ft2-bci.patch
-Patch9021: freetype-2.3.0-enable-spr.patch
+# freetype patches
+Patch20:  freetype-2.1.10-enable-ft2-bci.patch
+Patch21:  freetype-2.3.0-enable-spr.patch
 
 # Enable otvalid and gxvalid modules
-Patch9046: freetype-2.2.1-enable-valid.patch
+Patch46:  freetype-2.2.1-enable-valid.patch
 
 # Fix multilib conflicts
-Patch9088: freetype-multilib.patch
+Patch88:  freetype-multilib.patch
 
-Patch9089: freetype-2.3.11-CVE-2010-2498.patch
-Patch9090: freetype-2.3.11-CVE-2010-2499.patch
-Patch9091: freetype-2.3.11-CVE-2010-2500.patch
-Patch9092: freetype-2.3.11-CVE-2010-2519.patch
-Patch9093: freetype-2.3.11-CVE-2010-2520.patch
-#Patch9094: freetype-2.3.11-CVE-2010-2527.patch
-#Patch9095: freetype-2.3.11-axis-name-overflow.patch
-Patch9096: freetype-2.3.11-CVE-2010-1797.patch
-Patch9097: freetype-2.3.11-CVE-2010-2805.patch
-Patch9098: freetype-2.3.11-CVE-2010-2806.patch
-Patch9099: freetype-2.3.11-CVE-2010-2808.patch
-Patch9100: freetype-2.3.11-CVE-2010-3311.patch
-Patch9101: freetype-2.3.11-CVE-2010-3855.patch
-Patch9102: freetype-2.3.11-CVE-2011-0226.patch
-Patch9103: freetype-2.3.11-CVE-2011-3256.patch
-Patch9104: freetype-2.3.11-CVE-2011-3439.patch
-Patch9105: freetype-2.3.11-CVE-2012-1126.patch
-Patch9106: freetype-2.3.11-CVE-2012-1127.patch
-Patch9107: freetype-2.3.11-CVE-2012-1130.patch
-Patch9108: freetype-2.3.11-CVE-2012-1131.patch
-Patch9109: freetype-2.3.11-CVE-2012-1132.patch
-Patch9110: freetype-2.3.11-CVE-2012-1134.patch
-Patch9111: freetype-2.3.11-CVE-2012-1136.patch
-Patch9112: freetype-2.3.11-CVE-2012-1137.patch
-Patch9113: freetype-2.3.11-CVE-2012-1139.patch
-Patch9114: freetype-2.3.11-CVE-2012-1140.patch
-Patch9115: freetype-2.3.11-CVE-2012-1141.patch
-Patch9116: freetype-2.3.11-CVE-2012-1142.patch
-Patch9117: freetype-2.3.11-CVE-2012-1143.patch
-Patch9118: freetype-2.3.11-CVE-2012-1144.patch
-Patch9119: freetype-2.3.11-bdf-overflow.patch
-Patch9120: freetype-2.3.11-array-initialization.patch
+Patch89:  freetype-2.3.11-CVE-2010-2498.patch
+Patch90:  freetype-2.3.11-CVE-2010-2499.patch
+Patch91:  freetype-2.3.11-CVE-2010-2500.patch
+Patch92:  freetype-2.3.11-CVE-2010-2519.patch
+Patch93:  freetype-2.3.11-CVE-2010-2520.patch
+Patch96:  freetype-2.3.11-CVE-2010-1797.patch
+Patch97:  freetype-2.3.11-CVE-2010-2805.patch
+Patch98:  freetype-2.3.11-CVE-2010-2806.patch
+Patch99:  freetype-2.3.11-CVE-2010-2808.patch
+Patch100:  freetype-2.3.11-CVE-2010-3311.patch
+Patch101:  freetype-2.3.11-CVE-2010-3855.patch
+Patch102:  freetype-2.3.11-CVE-2011-0226.patch
+Patch103:  freetype-2.3.11-CVE-2011-3256.patch
+Patch104:  freetype-2.3.11-CVE-2011-3439.patch
+Patch105:  freetype-2.3.11-CVE-2012-1126.patch
+Patch106:  freetype-2.3.11-CVE-2012-1127.patch
+Patch107:  freetype-2.3.11-CVE-2012-1130.patch
+Patch108:  freetype-2.3.11-CVE-2012-1131.patch
+Patch109:  freetype-2.3.11-CVE-2012-1132.patch
+Patch110:  freetype-2.3.11-CVE-2012-1134.patch
+Patch111:  freetype-2.3.11-CVE-2012-1136.patch
+Patch112:  freetype-2.3.11-CVE-2012-1137.patch
+Patch113:  freetype-2.3.11-CVE-2012-1139.patch
+Patch114:  freetype-2.3.11-CVE-2012-1140.patch
+Patch115:  freetype-2.3.11-CVE-2012-1141.patch
+Patch116:  freetype-2.3.11-CVE-2012-1142.patch
+Patch117:  freetype-2.3.11-CVE-2012-1143.patch
+Patch118:  freetype-2.3.11-CVE-2012-1144.patch
+Patch119:  freetype-2.3.11-bdf-overflow.patch
+Patch120:  freetype-2.3.11-array-initialization.patch
+Patch121:  freetype-2.3.11-CVE-2012-5669.patch
 
-Patch10001: xtrans-1.0.3-avoid-gethostname.patch
-
-Patch10102: dont-forward-keycode-0.patch
-Patch10103: libX11-1.3.1-creategc-man-page.patch
-
-Patch10201: libXext-1.1-XAllocID.patch
-
-Patch10301: libfontenc-1.0.0-get-fontdir-from-pkgconfig.patch
-
-Patch10400: libXt-1.0.2-libsm-fix.patch
+# Patches for Xorg CVE-2014-12-09 taken from Debian:
+# https://release.debian.org/proposed-updates/stable_diffs/xorg-server_1.12.4-6+deb7u5.debdiff
+Patch10000: 16_CVE-2014-mult.diff
+Patch10001: 17_CVE-regressions.diff
 
 %description
 Virtual Network Computing (VNC) is a remote display system which
@@ -420,6 +217,7 @@
 Requires(postun):initscripts
 
 Requires: xkeyboard-config, xorg-x11-xkb-utils
+Requires: keyutils-libs-devel
 Requires: tigervnc-license
 
 %description server-minimal
@@ -464,31 +262,24 @@
 rm -rf %{_builddir}/%{name}-%{version}%{?snap:-%{snap}}
 %setup -q -n %{name}-%{version}%{?snap:-%{snap}}
 
-# sed -i -e 's/80/0/g' CMakeLists.txt
+# Search paths for X11 are hard coded into FindX11.cmake
 cp %SOURCE9 cmake/Modules/
+sed -i -e "s#@_includedir@#%{xorg_buildroot}%{_includedir}#" cmake/Modules/FindX11.cmake
+sed -i -e "s#@_libdir@#%{xorg_buildroot}%{_libdir}#" cmake/Modules/FindX11.cmake
 %patch4 -p1 -b .cookie
-%patch10 -p1 -b .ldnow
 %patch11 -p1 -b .gethomedir
-%patch15 -p1 -b .static-fltk
-%patch14 -p1 -b .x0vncserver
+%patch12 -p1 -b .static-build-fixes
 
 tar xzf %SOURCE11
 pushd fltk-*
-for p in `find ../contrib/fltk -maxdepth 1 -type f -name "*.patch"|sort` ;
-do
-  patch -p1 -i $p
-done
-cp %SOURCE9 CMake/
-%patch124 -p1 -b .libdl
-%patch125 -p1 -b .static-libs
+%patch15 -p1 -b .static-libs
 popd
 
 tar xzf %SOURCE12
+tar xjf %SOURCE13
 
 mkdir xorg
 pushd xorg
-tar xjf %SOURCE98
-tar xjf %SOURCE99
 tar xjf %SOURCE100
 tar xjf %SOURCE101
 tar xjf %SOURCE102
@@ -529,7 +320,7 @@
 tar xjf %SOURCE137
 tar xjf %SOURCE138
 tar xjf %SOURCE139
-tar xjf %SOURCE140
+
 tar xjf %SOURCE141
 tar xjf %SOURCE142
 tar xjf %SOURCE143
@@ -546,284 +337,126 @@
 tar xjf %SOURCE154
 tar xjf %SOURCE155
 tar xjf %SOURCE156
-# tar xjf %SOURCE157
-# tar xjf %SOURCE158
+tar xjf %SOURCE157
+tar xjf %SOURCE158
 tar xjf %SOURCE159
 tar xjf %SOURCE160
 tar xjf %SOURCE161
-tar xzf %SOURCE162
-tar xjf %SOURCE163
-tar xjf %SOURCE164
-popd
+tar xjf %SOURCE162
 tar xzf %SOURCE200
-cp -a xorg/xorg-server-1.*/* unix/xserver
-pushd xorg
-pushd libdrm-*
-%patch133 -p1 -b .forceperms
-%patch134 -p1 -b .no-bc
-%patch135 -p1 -b .page-flip
-%patch136 -p1 -b .nouveau-pbrestart
-%patch137 -p1 -b .nouveau-drop
-%patch138 -p1 -b .nouveau-relocs
-popd
-pushd Mesa-*
-%patch141 -p1 -b .osmesa
-%patch142 -p1 -b .intel-glthread
-%patch143 -p1 -b .no-mach64
-#%patch147 -p1 -b .dricore
-%patch149 -p1 -b .intel-vbl
-#%patch1410 -p1 -b .r600_tfp
-#%patch1413 -p1 -b .sparc64
-%patch1430 -p1 -b .vblank-warning
-%patch1431 -p1 -b .glx13-warning
-#%patch1440 -p1 -b .r300g
-#%patch1460 -p1
-
-#%patch1470 -p1 -b .depth-stall
-
-#%patch1480 -p1 -b .r600gpciids
-#%patch1481 -p1 -b .ivbpciid
-popd
-
+tar xjf %SOURCE201
 pushd freetype-*
-%patch9020 -p1 -b .enable-ft2-bci
-%patch9021 -p1 -b .enable-spr
-
-# Enable otvalid and gxvalid modules
-%patch9046 -p1 -b .enable-valid
-
-# Fix multilib conflicts
-%patch9088 -p1 -b .multilib
-
-%patch9089 -p1 -b .CVE-2010-2498
-%patch9090 -p1 -b .CVE-2010-2499
-%patch9091 -p1 -b .CVE-2010-2500
-%patch9092 -p1 -b .CVE-2010-2519
-%patch9093 -p1 -b .CVE-2010-2520
-%patch9096 -p1 -b .CVE-2010-1797
-%patch9097 -p1 -b .CVE-2010-2805
-%patch9098 -p1 -b .CVE-2010-2806
-%patch9099 -p1 -b .CVE-2010-2808
-%patch9100 -p1 -b .CVE-2010-3311
-%patch9101 -p1 -b .CVE-2010-3855
-%patch9102 -p1 -b .CVE-2011-0226
-%patch9103 -p1 -b .CVE-2011-3256
-%patch9104 -p1 -b .CVE-2011-3439
-%patch9105 -p1 -b .CVE-2012-1126
-%patch9106 -p1 -b .CVE-2012-1127
-%patch9107 -p1 -b .CVE-2012-1130
-%patch9108 -p1 -b .CVE-2012-1131
-%patch9109 -p1 -b .CVE-2012-1132
-%patch9110 -p1 -b .CVE-2012-1134
-%patch9111 -p1 -b .CVE-2012-1136
-%patch9112 -p1 -b .CVE-2012-1137
-%patch9113 -p1 -b .CVE-2012-1139
-%patch9114 -p1 -b .CVE-2012-1140
-%patch9115 -p1 -b .CVE-2012-1141
-%patch9116 -p1 -b .CVE-2012-1142
-%patch9117 -p1 -b .CVE-2012-1143
-%patch9118 -p1 -b .CVE-2012-1144
-%patch9119 -p1 -b .bdf-overflow
-%patch9120 -p1 -b .array-initialization
+%patch46  -p1 -b .enable-valid
+%patch88 -p1 -b .multilib
+%patch89 -p1 -b .CVE-2010-2498
+%patch90 -p1 -b .CVE-2010-2499
+%patch91 -p1 -b .CVE-2010-2500
+%patch92 -p1 -b .CVE-2010-2519
+%patch93 -p1 -b .CVE-2010-2520
+%patch96 -p1 -b .CVE-2010-1797
+%patch97 -p1 -b .CVE-2010-2805
+%patch98 -p1 -b .CVE-2010-2806
+%patch99 -p1 -b .CVE-2010-2808
+%patch100 -p1 -b .CVE-2010-3311
+%patch101 -p1 -b .CVE-2010-3855
+%patch102 -p1 -b .CVE-2011-0226
+%patch103 -p1 -b .CVE-2011-3256
+%patch104 -p1 -b .CVE-2011-3439
+%patch105 -p1 -b .CVE-2012-1126
+%patch106 -p1 -b .CVE-2012-1127
+%patch107 -p1 -b .CVE-2012-1130
+%patch108 -p1 -b .CVE-2012-1131
+%patch109 -p1 -b .CVE-2012-1132
+%patch110 -p1 -b .CVE-2012-1134
+%patch111 -p1 -b .CVE-2012-1136
+%patch112 -p1 -b .CVE-2012-1137
+%patch113 -p1 -b .CVE-2012-1139
+%patch114 -p1 -b .CVE-2012-1140
+%patch115 -p1 -b .CVE-2012-1141
+%patch116 -p1 -b .CVE-2012-1142
+%patch117 -p1 -b .CVE-2012-1143
+%patch118 -p1 -b .CVE-2012-1144
+%patch119 -p1 -b .bdf-overflow
+%patch120 -p1 -b .array-initialization
+%patch121 -p1 -b .CVE-2012-5669
+popd
+tar xjf %SOURCE202
+tar xjf %SOURCE203
+tar xjf %SOURCE204
+pushd xorg-server-1*
+%patch10000 -p1 -b .CVE-2014-mult
+%patch10001 -p1 -b .CVE-regressions
+for f in `find . -type f -perm -000`; do
+  chmod +r "$f"
+done
+popd
+tar xzf %SOURCE205
 popd
 
-pushd xtrans-*
-%patch10001 -p1 -b .my-name-is-unix
-popd
-
-pushd libX11-*
-%patch10102 -p1 -b .dont-forward-keycode-0
-%patch10103 -p1 -b .manual
-popd
-
-pushd libXext-*
-%patch10201 -p1 
-popd
-
-pushd libfontenc-*
-%patch10301 -p0 -b .get-fontdir-from-pkgconfig
-popd
-
-pushd libXt-*
-%patch10400 -p1 -b .libsm-fix
-popd
-
-popd
+cp -a xorg/xorg-server-1*/* unix/xserver
 
 pushd unix/xserver
-patch -p1 < %{_builddir}/%{name}-%{version}%{?snap:-%{snap}}/unix/xserver17.patch
-for all in `find %{_builddir}/%{name}-%{version}%{?snap:-%{snap}}/unix/xorg-7.5-patches/ -type f |grep '.*\.patch$'`; do
-	echo Applying $all
-	patch -p1 < $all
+for all in `find . -type f -perm -001`; do
+  chmod -x "$all"
 done
-%patch101 -p1 -b .ac-compatibility
-%patch102 -p1 -b .CopyISOLatin1Lowered
-
-%patch5 -p1 -b .xserver-1.4.99-pic-libxf86config
-%patch6 -p1 -b .xserver-1.7.4-z-now
-
-# OpenGL compositing manager feature/optimization patches.
-%patch103 -p1 -b .xserver-1.5.0-bg-none-root
-
-%patch2014 -p1 -b .xserver-1.5.0-projector-fb-size
-
-# Trivial things to never merge upstream ever:
-# This really could be done prettier.
-%patch5002 -p1 -b .xserver-1.4.99-ssh-isnt-local
-
-# force mode debugging on for randr 1.2 drivers
-%patch6002 -p1 -b .xserver-1.5.1-mode-debug
-
-# don't build the (broken) acpi code
-%patch6011 -p1 -b .xserver-1.6.0-less-acpi-brokenness
-
-# Make autoconfiguration chose nouveau driver for NVIDIA GPUs
-%patch6016 -p1 -b .xserver-1.6.1-nouveau
-
-# ajax needs to upstream this
-%patch6027 -p1 -b .xserver-1.6.0-displayfd
-%patch6028 -p1 -b .xserver-1.6.99-randr-error-debugging
-%patch6030 -p1 -b .xserver-1.6.99-right-of
-%patch6033 -p1 -b .xserver-1.6.99-default-modes
-%patch6044 -p1 -b .xserver-1.6.99-hush-prerelease-warning
-%patch6045 -p1 -b .xserver-1.7.0-randr-gamma-restore
-
-%patch6047 -p1 -b .xserver-1.7.0-glx-versioning
-#%patch6048 -p1 -b .xserver-1.7.0-exa-fix-mixed
-%patch6049 -p1 -b .xserver-1.7.1-multilib
-%patch6051 -p1 -b .xserver-1.7.1-gamma-kdm-fix
-%patch6052 -p1 -b .xserver-1.7.1-libcrypto
-%patch6066 -p1 -b .xserver-1.7.1-glx14-swrast
-
-%patch6067 -p1 -b .xserver-1.7.7-exa-master
-
-%patch6070 -p1 -b .xserver-1.7.3-no-free-on-abort
-# 558613
-%patch6075 -p1 -b .xserver-1.7.4-qxl-autoconfig
-# 516918
-%patch6076 -p1 -b .xserver-1.7.4-dpms-timeouts
-%patch6077 -p1 -b .xserver-1.7.6-export-dix-functions
-%patch6078 -p1 -b .xserver-1.7.6-export-more-dix-functions
-
-# 583544 - Pointer jumps to lower-right corner when clicking mousekeys
-%patch6087 -p1 -b .xserver-1.7.6-pointerkeys
-
-%patch7002 -p1 -b .xserver-1.7.6-no-connected-outputs
-# 586926 - randr change while off vt
-%patch7003 -p1 -b .xserver-1.7.6-randr-vt-switch
-# 582710 - pam support
-%patch7004 -p1 -b .xserver-1.1.1-pam
-# 584927 - xinerama coordinate sign fix
-%patch7005 -p1 -b .xserver-1.7.6-deviceevent-coordinates-xinerama
-# 585371 - default mode list unification
-%patch7006 -p1 -b .xserver-1.7.6-default-modes
-# 586567 - big window crash when try to resize
-%patch7007 -p1 -b .xserver-1.7.7-compresize-fix
-# 602080 - fix unnecessary fb resize in multi-head configurations
-%patch7008 -p1 -b .xserver-1.7.7-randr-initial
-# 600180 - Buffer overflow in XKB geometry copying code.
-%patch7009 -p1 -b .xserver-1.7.7-xkb-invalid-writes
-# 600116 - Properties are not reset in the second server generation
-%patch7010 -p1 -b .xserver-1.7.7-property-generation-reset
-# 594523 - Wrong axis mode for absolute axes 
-%patch7011 -p1 -b .xserver-1.7.7-device-mode-list
-# 602511 - Stuck modifiers when using multiple keyboards or XTEST
-%patch7012 -p1 -b .xserver-1.7.7-modifier-keycount
-# 588640 - XKEYBOARD Warning: Duplicate shape name ""
-%patch7013 -p1 -b .xserver-1.7.7-xkb-geom-copy
-# 574486 - Dual head setup overlaps one pixel 
-%patch7014 -p1 -b .xserver-1.7.7-fix-randr-rotation
-# 600505 - Xephyr utility should be resizeable
-%patch7015 -p1 -b .xserver-1.7.7-make-ephyr-resize
-# 604057 - fix aspect match for classic drivers
-%patch7016 -p1 -b .xserver-1.7.7-improve-mode-selection
-# 607045 - DGA client can crash the server
-%patch7017 -p1 -b .xserver-1.7.7-dga-master-keyboard
-# 607410 - Reproducible stuck grab on server
-%patch7018 -p1 -b .xserver-1.7.7-event-mask-revert
-# 607051 - Keyboard bell settings don't apply to keyboards.
-%patch7019 -p1 -b .xserver-1.7.7-sd-keyboard-controls
-# 607022 - segfault during Xorg -showopts
-%patch7020 -p1 -b .xserver-1.7.7-showopts-segv
-# Related 607150
-%patch7021 -p1 -b .xserver-1.7.7-xkb-purge-includes
-# Related 607150
-%patch7022 -p1 -b .xserver-1.7.7-xkb-rename-fakebutton
-# Related 607150
-%patch7023 -p1 -b .xserver-1.7.7-xkb-pointerkeys-on-master
-# 607150 - Mouse button never releases when xkb PointerKeys are used
-%patch7024 -p1 -b .xserver-1.7.7-xkb-lockedPtrBtns-state-merge
-# 607150 - Mouse button never releases when xkb PointerKeys are used, part2
-%patch7025 -p1 -b .xserver-1.7.7-release-xtest-on-phys-buttons
-# 581505 - Xephyr crashes inside kvm-qemu virtual host
-%patch7026 -p1 -b .xserver-1.7.7-xephyr-24bpp
-# 605302 - vesa doesn't work on intel gen6
-%patch7027 -p1 -b .xserver-1.7.7-int10-reserved-areas
-# 618422 - Wrong handling of devices with more than 2 valuators
-%patch7028 -p1 -b .xserver-1.7.7-postfix-DCE-PointerKeys
-# related 618422, Patch7028
-%patch7029 -p1 -b .xserver-1.7.7-reset-unused-classes
-# 601319 - LVDS activated when notebook lid is closed
-%patch7030 -p1 -b .xserver-1.7.7-lid-hack
-# 585283 - xrandr allows mouse to move into non-existant screen locations
-%patch7031 -p1 -b .xserver-1.7.7-randr-cursor-dead-zones
-# 620333 - mga shows blank screen when X server starts
-%patch7032 -p1 -b .xserver-1.7.7-ddc-probe-less
-# 638234 - Bump classic driver default resolution to 1024x768
-%patch7033 -p1 -b .xserver-1.7.7-classic-default-mode
-
-%patch8000 -p1 -b .cve-2011-4818
-%patch8001 -p1 -b .cve-2011-4818-extra
+patch -p1 < %{_builddir}/%{name}-%{version}%{?snap:-%{snap}}/unix/xserver112.patch
 
 popd
 
 %build
-%define tigervnc_src_dir %{_builddir}/%{name}-%{version}%{?snap:-%{snap}}
-%define static_lib_buildroot %{tigervnc_src_dir}/build
 export CC=gcc44
 export CXX=g++44
 export CFLAGS="$RPM_OPT_FLAGS -fPIC"
 export CXXFLAGS="$CFLAGS -static-libgcc"
+export PYTHON=python26
 
-%define xorg_buildroot %{tigervnc_src_dir}/xorg.build
 mkdir -p %{xorg_buildroot}%{_libdir}
 pushd %{xorg_buildroot}%{_libdir}
-ln -s `g++44 -print-file-name=libexpat.a`
-ln -s `g++44 -print-file-name=libgcrypt.a`
-ln -s `g++44 -print-file-name=libgpg-error.a`
-ln -s `g++44 -print-file-name=libgnutls.a`
-ln -s `g++44 -print-file-name=libstdc++.a`
-ln -s `g++44 -print-file-name=libcrypto.a`
 ln -s `g++44 -print-file-name=libz.a`
 ln -s `g++44 -print-file-name=libgcc.a`
-ln -s `g++44 -print-file-name=libpng.a`
+ln -s `g++44 -print-file-name=libexpat.a`
+ln -s `g++44 -print-file-name=libgnutls.a`
+ln -s `g++44 -print-file-name=libgpg-error.a`
+ln -s `g++44 -print-file-name=libgcrypt.a`
+ln -s `g++44 -print-file-name=libcrypto.a`
 popd
 
 echo "*** Building libjpeg-turbo ***"
 pushd libjpeg-turbo-*
-./configure --prefix=%{_prefix} --libdir=%{_libdir} --disable-nls --enable-static --disable-shared
+LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" ./configure --prefix=%{_prefix} --libdir=%{_libdir} --disable-nls --enable-static --disable-shared
 make %{?_smp_mflags} DESTDIR=%{xorg_buildroot} install
 popd
 
+echo "*** Building Xorg ***"
+pushd xorg
+
+echo "*** Building libsha1 ***"
+pushd libsha1-*
+autoreconf -fiv
+LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" ./configure --prefix=%{_prefix} --libdir=%{_libdir} --disable-nls --enable-static --disable-shared
+make %{?_smp_mflags} DESTDIR=%{xorg_buildroot} install
+find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -delete
+find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|libdir=%{_libdir}|libdir=%{xorg_buildroot}%{_libdir}|" {} \;
+find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=%{_prefix}|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
+popd
+
 export CFLAGS="$RPM_OPT_FLAGS -fPIC -I%{xorg_buildroot}%{_includedir}"
 export CXXFLAGS="$RPM_OPT_FLAGS -fPIC -I%{xorg_buildroot}%{_includedir} -static-libgcc"
 export CPPFLAGS=$CXXFLAGS
-export LDFLAGS="$LDFLAGS -L%{xorg_buildroot}%{_libdir}"
+export LDFLAGS="$LDFLAGS -L%{xorg_buildroot}%{_libdir} -L%{xorg_buildroot}%{_libdir}/tigervnc"
 export ACLOCAL="aclocal -I %{xorg_buildroot}%{_datadir}/aclocal"
-export PKG_CONFIG_PATH="%{xorg_buildroot}%{_libdir}/pkgconfig:%{xorg_buildroot}%{_datadir}/pkgconfig"
-
-echo "*** Building Xorg ***"
-pushd xorg
+export PKG_CONFIG_PATH="%{xorg_buildroot}%{_libdir}/pkgconfig:%{xorg_buildroot}%{_libdir}/tigervnc/pkgconfig:%{xorg_buildroot}%{_datadir}/pkgconfig:%{_libdir}/pkgconfig:%{_datadir}/pkgconfig"
 
 echo "*** Building freetype ***"
 pushd freetype-*
-CFLAGS="$CFLAGS -fno-strict-aliasing" LDFLAGS="$LDFLAGS -static" ./configure --prefix=/usr --libdir=%{_libdir} --enable-static --disable-shared
+LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" CFLAGS="$CFLAGS -fno-strict-aliasing" ./configure --prefix=%{_prefix} --libdir=%{_libdir} --enable-static --disable-shared
 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' builds/unix/libtool
 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' builds/unix/libtool
 make DESTDIR=%{xorg_buildroot} install
+# FIXME: fontconfig bails out if we delete the libtool archives
 find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -exec sed -i -e "s|libdir='%{_libdir}'|libdir='%{xorg_buildroot}%{_libdir}'|" {} \;
 find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|libdir=%{_libdir}|libdir=%{xorg_buildroot}%{_libdir}|" {} \;
-find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=/usr|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
+find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=%{_prefix}|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
 # fix multilib issues
 %ifarch x86_64 s390x ia64 ppc64 alpha sparc64
 %define wordsize 64
@@ -851,13 +484,24 @@
 EOF
 popd
 
+echo "*** Building fontconfig ***"
+pushd fontconfig-*
+autoreconf -fiv
+LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" HASDOCBOOK=no ./configure --prefix=%{_prefix} --libdir=%{_libdir} --enable-static --disable-shared --with-confdir=%{_sysconfdir}/fonts --with-cache-dir=%{_localstatedir}/cache/fontconfig --with-default-fonts=%{_datadir}/fonts --with-add-fonts="%{_datadir}/X11/fonts/Type1,%{_datadir}/X11/fonts/OTF,%{_datadir}/X11/fonts/TTF,%{_datadir}/X11/fonts/misc,%{_datadir}/X11/fonts/100dpi,%{_datadir}/X11/fonts/75dpi,%{_prefix}/local/share/fonts,~/.fonts"
+make %{?_smp_mflags}
+make DESTDIR=%{xorg_buildroot} install
+find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -delete
+find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|libdir=%{_libdir}|libdir=%{xorg_buildroot}%{_libdir}|" {} \;
+find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=%{_prefix}|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
+popd
+
 pushd util-macros-*
 echo "Building macros"
-./configure --prefix=/usr --libdir=%{_libdir} --disable-nls --enable-static --disable-shared
+LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" ./configure --prefix=%{_prefix} --libdir=%{_libdir} --enable-static --disable-shared
 make DESTDIR=%{xorg_buildroot} install
-find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -exec sed -i -e "s|libdir='%{_libdir}'|libdir='%{xorg_buildroot}%{_libdir}'|" {} \;
+find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -delete
 find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|libdir=%{_libdir}|libdir=%{xorg_buildroot}%{_libdir}|" {} \;
-find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=/usr|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
+find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=%{_prefix}|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
 popd
 
 modules="\
@@ -876,6 +520,7 @@
     resourceproto \
     scrnsaverproto \
     videoproto \
+    xcb-proto \
     xproto \
     xcmiscproto \
     xextproto \
@@ -883,13 +528,12 @@
     xf86dgaproto \
     xf86driproto \
     xf86vidmodeproto \
-    xf86miscproto \
     xineramaproto \
     makedepend \
     xtrans \
     libXau \
     libXdmcp \
-    libpthread-stubs \
+    libxcb \
     libX11 \
     libXext \
     libfontenc \
@@ -916,10 +560,10 @@
     libXv \
     libXxf86dga \
     libXxf86vm \
-    libXxf86misc \
     libpciaccess \
     pixman \
-    libdrm"
+    libdrm \
+    font-util"
 
 for module in ${modules}; do
   extraoptions=""
@@ -927,22 +571,41 @@
   echo ======================
   echo configuring ${module}
   echo ======================
-%ifarch i386 i686
+%ifarch i386 i686 x86_64
   if [ "${module}" = "libdrm" ]; then
-    extraoptions="${extraoptions} --disable-intel"
+    autoreconf -fiv
+    extraoptions="${extraoptions} --enable-udev --disable-libkms --disable-manpages --disable-intel --disable-radeon --disable-nouveau --disable-vmwgfx"
   fi
 %endif
+  if [ "${module}" = "libXdmcp" ]; then
+    autoreconf -fiv
+  fi
+  if [ "${module}" = "libXcursor" ]; then
+    autoreconf -fiv
+  fi
+  if [ "${module}" = "libfontenc" ]; then
+    autoconf
+  fi
+  if [ "${module}" = "libXi" ]; then
+    autoreconf -fiv
+  fi
   if [ "${module}" = "libXaw" ]; then
     extraoptions="${extraoptions} --disable-xaw8 --disable-xaw6"
   fi
+  if [ "${module}" = "libxcb" ]; then
+    sed -i 's/pthread-stubs //' configure.ac
+    autoreconf -fiv
+  fi
   if [ "${module}" = "libX11" ]; then
-    extraoptions="${extraoptions} --without-xcb --disable-specs"
+    autoreconf -fiv
+    sed -i -e 's|^\(#pragma weak pthread_equal.*\)$||' src/UIThrStubs.c
+    extraoptions="${extraoptions} --disable-specs"
   fi
   if [ "${module}" = "libSM" ]; then
     extraoptions="${extraoptions} --without-libuuid"
   fi
   if [ "${module}" = "pixman" ]; then
-    extraoptions="${extraoptions} --disable-gtk"
+    extraoptions="${extraoptions} --disable-gtk --disable-openmp"
     aclocal -I %{xorg_buildroot}%{_datadir}/aclocal
     autoconf
     autoreconf -fiv
@@ -950,154 +613,172 @@
   if [ "${module}" = "libXfont" ]; then
     extraoptions="${extraoptions} --with-freetype-config=%{xorg_buildroot}%{_bindir}/freetype-config"
   fi
-  if [ "${module}" = "libpthread-stubs" ]; then
-    LDFLAGS="" ./configure --prefix=/usr --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+  if [ "${module}" = "libXScrnSaver" ]; then
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" CFLAGS="$CFLAGS -fno-strict-aliasing" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+  elif [ "${module}" = "libxkbfile" ]; then
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" CFLAGS="$CFLAGS -fno-strict-aliasing" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+  elif [ "${module}" = "pixman" ]; then
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" CFLAGS="$CFLAGS -fno-strict-aliasing" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+  elif [ "${module}" = "libXt" ]; then
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" CFLAGS="$CFLAGS -fno-strict-aliasing" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic --with-xfile-search-path="%{_sysconfdir}/X11/%%L/%%T/%%N%%C%%S:%{_sysconfdir}/X11/%%l/%%T/\%%N%%C%%S:%{_sysconfdir}/X11/%%T/%%N%%C%%S:%{_sysconfdir}/X11/%%L/%%T/%%N%%S:%{_sysconfdir}/X\11/%%l/%%T/%%N%%S:%{_sysconfdir}/X11/%%T/%%N%%S:%{_datadir}/X11/%%L/%%T/%%N%%C%%S:%{_datadir}/X1\1/%%l/%%T/%%N%%C%%S:%{_datadir}/X11/%%T/%%N%%C%%S:%{_datadir}/X11/%%L/%%T/%%N%%S:%{_datadir}/X11/%%\l/%%T/%%N%%S:%{_datadir}/X11/%%T/%%N%%S"
   elif [ "${module}" = "libX11" ]; then
-    XDMCP_FLAGS="-L%{xorg_buildroot}%{_libdir} -Wl,-B,static -lXdmcp -lXau" ./configure --prefix=/usr --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
   elif [ "${module}" = "libXtst" ]; then
-    XTST_FLAGS="-L%{xorg_buildroot}%{_libdir} -Wl,-B,static -lXext" ./configure --prefix=/usr --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+  elif [ "${module}" = "libXpm" ]; then
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
   else
-    ./configure --prefix=/usr --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
+    LDFLAGS="$LDFLAGS -static" PKG_CONFIG="pkg-config --static" ./configure --prefix=%{_prefix} --libdir=%{_libdir} ${extraoptions} --enable-static --disable-shared --with-pic
   fi
   echo ======================
   echo building ${module}
   echo ======================
-  make DESTDIR=%{xorg_buildroot} install
-  find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -exec sed -i -e "s|libdir='%{_libdir}'|libdir='%{xorg_buildroot}%{_libdir}'|" {} \;
+  make DESTDIR=%{xorg_buildroot}
+  if [ "${module}" = "libX11" ]; then
+    make DESTDIR=%{xorg_buildroot} INSTALL="install -p" install
+  else
+    make DESTDIR=%{xorg_buildroot} install
+  fi
+  find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -delete
   find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|libdir=%{_libdir}|libdir=%{xorg_buildroot}%{_libdir}|" {} \;
-  find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=/usr|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
+  find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=%{_prefix}|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
+  if [ "${module}" = "libxcb" ]; then
+    sed 's,@libdir@,%{xorg_buildroot}%{_libdir},;s,@prefix@,%{xorg_buildroot}%{_prefix},;s,@exec_prefix@,%{xorg_buildroot}%{_exec_prefix},' %{SOURCE140} > %{xorg_buildroot}%{_libdir}/pkgconfig/pthread-stubs.pc
+    sed -i -e 's/^\(Libs.private:.*\)$/\1 -L${libdir} -lXdmcp -lXau/' %{xorg_buildroot}%{_libdir}/pkgconfig/xcb.pc 
+  elif [ "${module}" = "libX11" ]; then
+    sed -i -e 's/^\(Libs:.*\)$/\1 -ldl/' %{xorg_buildroot}%{_libdir}/pkgconfig/x11.pc 
+    sed -i -e 's/^\(Libs.private:.*\)$/\1 -L${libdir} -lxcb/' %{xorg_buildroot}%{_libdir}/pkgconfig/x11.pc 
+  elif [ "${module}" = "libSM" ]; then
+    echo 'Libs.private: -L${libdir} -lICE' >> %{xorg_buildroot}%{_libdir}/pkgconfig/sm.pc
+  fi
+
   popd
 done
 
 # build mesa
 echo "*** Building Mesa ***"
 pushd Mesa-*
+export PYTHON2=python26
+%ifarch %{ix86}
+sed -i -e 's/-std=c99/-std=gnu99/g' configure.ac
+%endif
+autoreconf -fiv
 %ifarch %{ix86}
 # i do not have words for how much the assembly dispatch code infuriates me
-%define _mesa_flags --enable-pic --disable-asm
+%define common_flags --disable-selinux --enable-pic --disable-asm
 %else
-%define _mesa_flags --enable-pic
+%define common_flags --disable-selinux --enable-pic
 %endif
 
-# Need to set cfghost?
-./configure \
-  --prefix=/usr \
-  --libdir=%{_libdir} \
-  --enable-motif \
-  --with-driver=dri \
-  --with-dri-drivers=swrast \
-  --with-dri-driverdir=%{_libdir}/dri \
-  --with-gallium-drivers="" \
-  --without-demos \
-  --disable-driglx-direct \
-  --disable-egl \
-  --disable-glut \
-  --disable-gallium \
-  --disable-gl-osmesa \
-  --disable-gallium-intel \
-  --disable-gallium-radeon \
-  --disable-gallium-nouveau \
-  %{_mesa_flags}
+# link libGL statically against any xorg libraries built above
+LDFLAGS="$LDFLAGS -Wl,-Bstatic -lxcb -lX11 -lXdmcp -lXau -lXext -lXxf86vm -ldrm -Wl,-Bdynamic -Wl,-rpath,%{_libdir}/tigervnc:%{_libdir}" \
+PKG_CONFIG="pkg-config --static" ./configure %{common_flags} \
+    --prefix=%{_prefix} \
+    --libdir=%{_libdir}/tigervnc \
+    --disable-osmesa \
+    --disable-shared-glapi \
+    --disable-egl \
+    --disable-gbm \
+    --enable-glx \
+    --disable-glx-tls \
+    --disable-opencl \
+    --disable-xvmc \
+    --with-dri-driverdir=%{_libdir}/tigervnc/dri \
+    --disable-gallium-egl \
+    --with-gallium-drivers="" \
+    --with-dri-drivers=swrast
 
-# Mesa build fails to install libGLU* if 'make install' is run before 'make'
 make DESTDIR=%{xorg_buildroot}
-make DESTDIR=%{xorg_buildroot} install
-find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -exec sed -i -e "s|libdir='%{_libdir}'|libdir='%{xorg_buildroot}%{_libdir}'|" {} \;
+make install DESTDIR=%{xorg_buildroot}
+find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -delete
 find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|libdir=%{_libdir}|libdir=%{xorg_buildroot}%{_libdir}|" {} \;
-find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=/usr|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
+find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=%{_prefix}|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
 popd
 
 popd
 
-echo "*** Building fontconfig ***"
-pushd fontconfig-*
-HASDOCBOOK=no ./configure --prefix=%{_prefix} --libdir=%{_libdir} --with-add-fonts=/usr/share/X11/fonts/Type1,/usr/share/X11/fonts/OTF --enable-static --disable-shared
+echo "*** Building libpng ***"
+pushd libpng-*
+CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
+  --prefix=%{_prefix} \
+  --libdir=%{_libdir} \
+  --disable-shared \
+  --enable-static
 make %{?_smp_mflags}
 make DESTDIR=%{xorg_buildroot} install
-find %{xorg_buildroot}%{_prefix} -type f -name "*.la" -exec sed -i -e "s|libdir='%{_libdir}'|libdir='%{xorg_buildroot}%{_libdir}'|" {} \;
-find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|libdir=%{_libdir}|libdir=%{xorg_buildroot}%{_libdir}|" {} \;
-find %{xorg_buildroot}%{_prefix} -type f -name "*.pc" -exec sed -i -e "s|prefix=/usr|prefix=%{xorg_buildroot}%{_prefix}|" {} \;
 popd
 
 echo "*** Building fltk ***"
 pushd fltk-*
 export CMAKE_PREFIX_PATH="%{xorg_buildroot}%{_prefix}:%{_prefix}"
-export CMAKE_EXE_LINKER_FLAGS="-static-libgcc -L%{xorg_buildroot}%{_libdir}"
-%{cmake28} -G"Unix Makefiles" \
-  -DCMAKE_INSTALL_PREFIX=%{xorg_buildroot}%{_prefix} \
-  -DX11_INC_SEARCH_PATH=%{xorg_buildroot}%{_includedir} \
-  -DX11_LIB_SEARCH_PATH=%{xorg_buildroot}%{_libdir} \
-  -DCMAKE_BUILD_TYPE=Release \
-  -DOPTION_USE_THREADS=off \
-  -DOPTION_BUILD_EXAMPLES=off \
-  -DOPTION_USE_SYSTEM_LIBPNG=on
+export CMAKE_EXE_LINKER_FLAGS=$LDFLAGS
+export PKG_CONFIG="pkg-config --static" 
+CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
+  --prefix=%{_prefix} \
+  --libdir=%{_libdir} \
+  --enable-x11 \
+  --enable-gl \
+  --disable-shared \
+  --enable-localjpeg \
+  --enable-localzlib \
+  --disable-localpng \
+  --enable-xinerama \
+  --enable-xft \
+  --enable-xdbe \
+  --enable-xfixes \
+  --enable-xcursor \
+  --with-x 
 make %{?_smp_mflags}
+make DESTDIR=%{xorg_buildroot} install
 popd
 
 echo "*** Building VNC ***"
 export CFLAGS="$CFLAGS -fPIC"
 export CXXFLAGS=`echo $CXXFLAGS | sed -e 's/ -c //g'`
 %{cmake28} -G"Unix Makefiles" \
-  -DX11_INC_SEARCH_PATH=%{xorg_buildroot}%{_includedir} \
-  -DX11_LIB_SEARCH_PATH=%{xorg_buildroot}%{_libdir} \
-  -DFLTK_LIBRARY_DIR=%{tigervnc_src_dir}/fltk-1.3.2/lib \
-  -DFLTK_LIBRARIES="%{tigervnc_src_dir}/fltk-1.3.2/lib/libfltk.a;%{tigervnc_src_dir}/fltk-1.3.2/lib/libfltk_images.a;-lpng" \
-  -DFLTK_FLUID_EXECUTABLE=%{tigervnc_src_dir}/fltk-1.3.2/bin/fluid \
-  -DFLTK_INCLUDE_DIR=%{tigervnc_src_dir}/fltk-1.3.2 \
+  -DFLTK_FLUID_EXECUTABLE=%{xorg_buildroot}%{_bindir}/fluid \
+  -DFLTK_LIBRARY_DIR=%{xorg_buildroot}%{_libdir} \
+  -DFLTK_INCLUDE_DIR=%{xorg_buildroot}%{_includedir} \
   -DBUILD_STATIC=1 \
   -DCMAKE_BUILD_TYPE=Release \
+  -DZLIB_INCLUDE_DIR=%{_includedir} \
+  -DZLIB_LIBRARY=%{_libdir}/libz.a \
   -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
 make %{?_smp_mflags}
 
 pushd unix/xserver
-export LD=$CXX
 export PIXMANINCDIR=%{xorg_buildroot}%{_includedir}/pixman-1
+sed -i -e 's/^\(\s*WAYLAND_SCANNER_RULES.*\)/dnl\1/' configure.ac
 autoreconf -fiv 
-./configure --prefix=/usr --libdir=%{_libdir} --mandir=%{_datadir}/man \
-	--disable-xorg --disable-xnest --disable-xvfb --disable-dmx \
-	--disable-xwin --disable-xephyr --disable-kdrive --with-pic \
-	--disable-xinerama \
-	--with-int10=x86emu \
-	--enable-xdmcp \
-	--enable-composite \
-	--disable-xgl \
-	--disable-xglx \
-	--enable-freetype \
-	--with-fontdir=%{_datadir}/X11/fonts \
-	--with-xkb-output=%{_localstatedir}/lib/xkb \
-	--enable-install-libxf86config \
-	--enable-glx --disable-dri --enable-dri2 \
-	--disable-config-dbus \
-	--disable-config-hal \
-	--disable-config-udev \
-	--with-dri-driver-path=%{_libdir}/dri \
-	--without-dtrace \
-	--disable-unit-tests \
-	--disable-devel-docs \
-	--with-sha1=libgcrypt SHA1_LIB=-lcrypto \
-	--disable-shared \
-	--enable-static \
-	--disable-record \
-	--enable-aiglx \
-	--disable-xvmc \
-	--enable-dga \
-	--disable-screensaver \
-	--enable-xdm-auth-1 \
-	--enable-xf86vidmode \
-	--enable-xcsecurity \
-	--enable-appgroup \
-	--enable-xevie \
-	--enable-evi \
-	--enable-multibuffer \
-	--enable-xf86bigfont \
-	--disable-dpms \
-	--disable-ipv6 \
-	--with-mesa-source=%{tigervnc_src_dir}/xorg/Mesa-%{mesa_version} \
-	--with-freetype-config=%{xorg_buildroot}%{_bindir}/freetype-config \
-	--disable-maintainer-mode
-
-sed -i -e 's/^ECHO/echo/' ./libtool
+chmod +x ./configure
+# create a relocatable Xvnc so that we can bundle the custom libGL & swrast w/o overwriting existing libs
+GL_LIBS='-Wl,-Bdynamic -lGL' LDFLAGS="$LDFLAGS -L%{xorg_buildroot}%{_libdir}/tigervnc -Wl,-rpath,%{_libdir}/tigervnc:%{_libdir}" \
+%configure \
+  --prefix=%{_prefix} --libdir=%{_libdir} --mandir=%{_datadir}/man \
+  --sysconfdir=%{_sysconfdir} --localstatedir=%{_localstatedir} \
+  --with-vendor-name="The TigerVNC Project" --with-vendor-name-short="TigerVNC" \
+  --with-vendor-web="http://www.tigervnc.org" \
+  --disable-xorg --disable-xnest --disable-xvfb --disable-dmx \
+  --disable-xwin --disable-xephyr --disable-kdrive --disable-wayland \
+  --with-pic --enable-static --disable-shared --enable-xinerama \
+  --with-default-xkb-rules=base \
+  --with-default-font-path="catalogue:%{_sysconfdir}/X11/fontpath.d,%{_datadir}/X11/fonts/misc,%{_datadir}/X11/fonts/OTF,%{_datadir}/X11/fonts/TTF,%{_datadir}/X11/fonts/Type1,%{_datadir}/X11/fonts/100dpi,%{_datadir}/X11/fonts/75dpi,built-ins" \
+  --with-serverconfig-path=%{_libdir}/xorg \
+  --with-fontrootdir=%{_datadir}/X11/fonts \
+  --with-xkb-output=%{_localstatedir}/lib/xkb \
+  --enable-install-libxf86config \
+  --enable-glx --disable-glx-tls --disable-dri --enable-dri2 --disable-dri3 \
+  --disable-present \
+  --disable-config-dbus \
+  --disable-config-hal \
+  --disable-config-udev \
+  --without-dtrace \
+  --disable-unit-tests \
+  --disable-docs \
+  --disable-devel-docs \
+  --disable-selective-werror \
+  --with-sha1=libsha1
 
 make TIGERVNC_SRCDIR=%{tigervnc_src_dir} %{?_smp_mflags}
 popd
@@ -1111,12 +792,12 @@
 pushd java
 %{cmake28} \
 %if !%{_self_signed}
-	-DJAVA_KEYSTORE=%{_keystore} \
-	-DJAVA_KEYSTORE_TYPE=%{_keystore_type} \
-	-DJAVA_KEY_ALIAS=%{_key_alias} \
-	-DJAVA_STOREPASS=":env STOREPASS" \
-	-DJAVA_KEYPASS=":env KEYPASS" \
-	-DJAVA_TSA_URL=https://timestamp.geotrust.com/tsa .
+  -DJAVA_KEYSTORE=%{_keystore} \
+  -DJAVA_KEYSTORE_TYPE=%{_keystore_type} \
+  -DJAVA_KEY_ALIAS=%{_key_alias} \
+  -DJAVA_STOREPASS=":env STOREPASS" \
+  -DJAVA_KEYPASS=":env KEYPASS" \
+  -DJAVA_TSA_URL=https://timestamp.geotrust.com/tsa .
 %endif
 
 JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" make
@@ -1130,6 +811,10 @@
 make install DESTDIR=$RPM_BUILD_ROOT
 popd
 
+pushd xorg/Mesa-*
+make install DESTDIR=$RPM_BUILD_ROOT
+popd
+
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
 install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/init.d/vncserver
@@ -1160,13 +845,12 @@
 %find_lang %{name} %{name}.lang
 
 # remove unwanted files
-rm -f $RPM_BUILD_ROOT%{_libdir}/xorg/modules/extensions/libvnc.la
-rm -f $RPM_BUILD_ROOT%{_libdir}/xorg/modules/extensions/libvnc.a
-rm -f $RPM_BUILD_ROOT%{_libdir}/dri/libdricore.so
-
-# move files to correct location
-mkdir -p $RPM_BUILD_ROOT%{_libdir}/dri
-cp %{xorg_buildroot}%{_libdir}/dri/* $RPM_BUILD_ROOT%{_libdir}/dri/
+rm -rf $RPM_BUILD_ROOT%{_libdir}/tigervnc/pkgconfig
+rm -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig
+rm -rf $RPM_BUILD_ROOT%{_libdir}/xorg
+rm -rf $RPM_BUILD_ROOT%{_includedir}
+rm -f $RPM_BUILD_ROOT%{_libdir}/tigervnc/*.la
+rm -f $RPM_BUILD_ROOT%{_libdir}/tigervnc/dri/*.la
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -1219,7 +903,7 @@
 %{_mandir}/man1/Xvnc.1*
 %{_mandir}/man1/vncpasswd.1*
 %{_mandir}/man1/vncconfig.1*
-%{_libdir}/dri/swrast_dri.so
+%{_libdir}/*
 
 %files server-applet
 %defattr(-,root,root,-)
@@ -1235,6 +919,23 @@
 %{_datadir}/icons/hicolor/*/apps/*
 
 %changelog
+* Sat Mar 07 2015 Brian P. Hinz <bphinz@users.sourceforge.net> 1.4.80-5
+- Don't disable xinerama extension
+
+* Thu Feb 19 2015 Brian P. Hinz <bphinz@users.sourceforge.net> 1.4.80-4
+- Bumped fltk to 1.3.3, no longer requires patching
+
+* Mon Jan 19 2015 Brian P. Hinz <bphinz@users.sourceforge.net> 1.4.0-3
+- Added default font paths to Xvnc and fontconfig
+- Added vendor strings to Xvnc
+- Specified xfile-search-path when configuring libXt the same way el6 does
+
+* Wed Dec 24 2014 Brian P. Hinz <bphinz@users.sourceforge.net> 1.4.80-1.20141119git59c5a55c
+- Rebuilt against Xorg 7.7 with CVE-2104-12-09 patches from debian.
+- Bumped versions of Mesa, Freetype, fontconfig, etc.
+- Link against our own version of libGL to improve portability.
+- Added static libsha1 to avoid linking against libssl.so.
+
 * Wed Nov 19 2014 Brian P. Hinz <bphinz@users.sourceforge.net> 1.3.80-18.20141119git59c5a55c
 - Removed server module sub-package
 
diff --git a/contrib/packages/rpm/el6/SOURCES/tigervnc11-gethomedir.patch b/contrib/packages/rpm/el6/SOURCES/tigervnc11-gethomedir.patch
index 0a4252d..53b4dc1 100644
--- a/contrib/packages/rpm/el6/SOURCES/tigervnc11-gethomedir.patch
+++ b/contrib/packages/rpm/el6/SOURCES/tigervnc11-gethomedir.patch
@@ -9,7 +9,7 @@
  COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(XREGION_LIB)
  
  noinst_LTLIBRARIES = libvnccommon.la
-@@ -55,7 +56,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
+@@ -55,6 +56,6 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
  
  libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
  
@@ -17,4 +17,3 @@
 +libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS) $(OS_LIB)
  
  EXTRA_DIST = Xvnc.man
- 
diff --git a/contrib/packages/rpm/el6/SOURCES/tigervnc11-ldnow.patch b/contrib/packages/rpm/el6/SOURCES/tigervnc11-ldnow.patch
deleted file mode 100644
index f6edd09..0000000
--- a/contrib/packages/rpm/el6/SOURCES/tigervnc11-ldnow.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up tigervnc-1.2.0/unix/xserver/hw/vnc/Makefile.am.ldnow tigervnc-1.2.0/unix/xserver/hw/vnc/Makefile.am
---- tigervnc-1.2.0/unix/xserver/hw/vnc/Makefile.am.ldnow	2011-10-31 09:14:40.000000000 +0100
-+++ tigervnc-1.2.0/unix/xserver/hw/vnc/Makefile.am	2012-08-22 15:51:47.013241342 +0200
-@@ -53,7 +53,7 @@ libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I
- 	-I$(top_srcdir)/include \
- 	${XSERVERLIBS_CFLAGS} -I$(includedir)
- 
--libvnc_la_LDFLAGS = -module -avoid-version
-+libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
- 
- libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS)
- 
diff --git a/contrib/packages/rpm/el6/SPECS/tigervnc.spec b/contrib/packages/rpm/el6/SPECS/tigervnc.spec
index d16a416..dd0fb09 100644
--- a/contrib/packages/rpm/el6/SPECS/tigervnc.spec
+++ b/contrib/packages/rpm/el6/SPECS/tigervnc.spec
@@ -2,7 +2,7 @@
 
 Name: tigervnc
 Version: @VERSION@
-Release: 18%{?snap:.%{snap}}%{?dist}
+Release: 20%{?snap:.%{snap}}%{?dist}
 Summary: A TigerVNC remote display system
 
 Group: User Interface/Desktops
@@ -14,7 +14,7 @@
 Source1: vncserver.service
 Source2: vncserver.sysconfig
 Source6: vncviewer.desktop
-Source11: http://fltk.org/pub/fltk/1.3.2/fltk-1.3.2-source.tar.gz
+Source11: http://fltk.org/pub/fltk/1.3.3/fltk-1.3.3-source.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires: libX11-devel, automake, autoconf, libtool, gettext, gettext-devel
@@ -46,7 +46,6 @@
 Obsoletes: tightvnc < 1.5.0-0.15.20090204svn3586
 
 Patch4: tigervnc-cookie.patch
-Patch10: tigervnc11-ldnow.patch
 Patch11: tigervnc11-gethomedir.patch
 Patch16: tigervnc-xorg-manpages.patch
 
@@ -140,16 +139,9 @@
 
 # sed -i -e 's/80/0/g' CMakeLists.txt
 %patch4 -p1 -b .cookie
-%patch10 -p1 -b .ldnow
 %patch11 -p1 -b .gethomedir
 
 tar xzf %SOURCE11
-pushd fltk-*
-for p in `find ../contrib/fltk -maxdepth 1 -type f -name "*.patch"|sort` ;
-do
-  patch -p1 -i $p
-done
-popd
 
 cp -r /usr/share/xorg-x11-server-source/* unix/xserver
 pushd unix/xserver
@@ -186,8 +178,8 @@
 %{cmake28} -G"Unix Makefiles" \
   -DBUILD_STATIC=off \
   -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-  -DFLTK_LIBRARIES="%{tigervnc_src_dir}/fltk-1.3.2/lib/libfltk.a;%{tigervnc_src_dir}/fltk-1.3.2/lib/libfltk_images.a;-lpng" \
-  -DFLTK_INCLUDE_DIR=%{tigervnc_src_dir}/fltk-1.3.2
+  -DFLTK_LIBRARIES="%{tigervnc_src_dir}/fltk-1.3.3/lib/libfltk.a;%{tigervnc_src_dir}/fltk-1.3.3/lib/libfltk_images.a;-lpng" \
+  -DFLTK_INCLUDE_DIR=%{tigervnc_src_dir}/fltk-1.3.3
 make LDFLAGS="-lpng" %{?_smp_mflags}
 
 pushd unix/xserver
@@ -195,7 +187,7 @@
 %configure \
 	--disable-xorg --disable-xnest --disable-xvfb --disable-dmx \
 	--disable-xwin --disable-xephyr --disable-kdrive --disable-wayland \
-	--with-pic --disable-static --disable-xinerama \
+	--with-pic --disable-static --enable-xinerama \
 	--with-default-font-path="catalogue:%{_sysconfdir}/X11/fontpath.d,built-ins" \
 	--with-serverconfig-path=%{_libdir}/xorg \
 	--with-fontrootdir=%{_datadir}/X11/fonts \
@@ -344,6 +336,12 @@
 %{_datadir}/icons/hicolor/*/apps/*
 
 %changelog
+* Sat Mar 07 2015 Brian P. Hinz <bphinz@users.sourceforge.net> 1.4.80-20
+- Don't disable xinerama extension
+
+* Thu Feb 19 2015 Brian P. Hinz <bphinz@users.sourceforge.net> 1.4.80-19
+- Bumped fltk version to 1.3.3, no longer requires any patching
+
 * Tue Nov 04 2014 Brian P. Hinz <bphinz@users.sourceforge.net> 1.3.80-18.20131128svn5139
 - Bumped xserver patch to keep pace with native version
 
diff --git a/java/com/tigervnc/rfb/CMsgReader.java b/java/com/tigervnc/rfb/CMsgReader.java
index 71045f3..a93324c 100644
--- a/java/com/tigervnc/rfb/CMsgReader.java
+++ b/java/com/tigervnc/rfb/CMsgReader.java
@@ -23,6 +23,9 @@
 
 package com.tigervnc.rfb;
 
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
 import com.tigervnc.rdr.*;
 
 abstract public class CMsgReader {
@@ -64,13 +67,9 @@
     }
     byte[] buf = new byte[len];
     is.readBytes(buf, 0, len);
-    String str = new String();
-    try {
-      str = new String(buf,"UTF8");
-    } catch(java.io.UnsupportedEncodingException e) {
-      e.printStackTrace();
-    }
-    handler.serverCutText(str, len);
+    Charset latin1 = Charset.forName("ISO-8859-1");
+    CharBuffer chars = latin1.decode(ByteBuffer.wrap(buf));
+    handler.serverCutText(chars.toString(), len);
   }
 
   protected void readFramebufferUpdateStart()
diff --git a/java/com/tigervnc/rfb/CMsgWriter.java b/java/com/tigervnc/rfb/CMsgWriter.java
index 3b226b1..0d3dccf 100644
--- a/java/com/tigervnc/rfb/CMsgWriter.java
+++ b/java/com/tigervnc/rfb/CMsgWriter.java
@@ -20,6 +20,8 @@
 
 package com.tigervnc.rfb;
 
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
 import com.tigervnc.rdr.*;
 
 abstract public class CMsgWriter {
@@ -155,12 +157,9 @@
     startMsg(MsgTypes.msgTypeClientCutText);
     os.pad(3);
     os.writeU32(len);
-    try {
-      byte[] utf8str = str.getBytes("UTF8");
-      os.writeBytes(utf8str, 0, len);
-    } catch(java.io.UnsupportedEncodingException e) {
-      e.printStackTrace();
-    }
+    Charset latin1 = Charset.forName("ISO-8859-1");
+    ByteBuffer bytes = latin1.encode(str);
+    os.writeBytes(bytes.array(), 0, len);
     endMsg();
   }
 
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index 513cfcc..7e5a2ea 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -1,7 +1,7 @@
 # Gettext support - mostly borrowed from the Licq project
 
 set(po_FILES
-    de es fr it nl pl pt_BR ru sk sv tr uk
+    de eo es fr it nl pl pt_BR ru sk sv tr uk
 )
 
 if (NOT GETTEXT_MSGMERGE_EXECUTABLE AND NOT GETTEXT_MSGFMT_EXECUTABLE)
diff --git a/po/eo.po b/po/eo.po
new file mode 100644
index 0000000..9ab37ce
--- /dev/null
+++ b/po/eo.po
@@ -0,0 +1,752 @@
+# Esperanto translation
+# Copyright (C) 2015 the TigerVNC Team (msgids)
+# This file is distributed under the same license as the tigervnc package.
+# Felipe Castro <fefcas@gmail.com>, 2015.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: tigervnc 1.3.90\n"
+"Report-Msgid-Bugs-To: tigervnc-devel@googlegroups.com\n"
+"POT-Creation-Date: 2014-11-19 12:46+0000\n"
+"PO-Revision-Date: 2015-01-20 15:14-0300\n"
+"Last-Translator: Felipe Castro <fefcas@gmail.com>\n"
+"Language-Team: Esperanto <translation-team-eo@lists.sourceforge.net>\n"
+"Language: eo\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.6.10\n"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:194
+#, c-format
+msgid "(server default %s)"
+msgstr "(servila implicito %s)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:227
+msgid "About"
+msgstr "Pri"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:103
+msgid "About TigerVNC Viewer"
+msgstr "Pri la montrilo TigerVNC"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1097
+msgid "About TigerVNC viewer..."
+msgstr "Pri la montrilo TigerVNC..."
+
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:86
+msgid "About..."
+msgstr "Pri..."
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:704
+msgid "Accept clipboard from server"
+msgstr "Akcepti tondaĵon el la servilo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/DesktopWindow.cxx:327
+msgid "Adjusting window size to avoid accidental full screen request"
+msgstr "Alĝustigo de fenestra grando por eviti akcidentan plenekranan peton"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:563
+msgid "Allow JPEG compression:"
+msgstr "Permesi JPEG-densigon:"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1081
+msgid "Alt"
+msgstr "Alt-klavo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:648
+msgid "Authentication"
+msgstr "Aŭtentikiĝo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/UserDialog.cxx:89
+msgid "Authentication cancelled"
+msgstr "Aŭtentikiĝo estas nuligita"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:437
+msgid "Auto select"
+msgstr "Aŭtomate elekti"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:651
+#, c-format
+msgid "Bad Name/Value pair on line: %d in file: %s"
+msgstr "Malĝusta paro novo/valoro en linio: %d en dosiero: %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Win32PixelBuffer.cxx:91
+msgid "BitBlt failed"
+msgstr "BitBlt malsukcesis"
+
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:91
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:221
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:83
+msgid "Cancel"
+msgstr "Nuligi"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:116
+msgid "CleanupSignalHandler called"
+msgstr "CleanupSignalHandler estas vokita"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:222
+msgid "Close"
+msgstr "Fermi"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:499
+msgid "Color level"
+msgstr "Kolora nivelo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:421
+msgid "Compression"
+msgstr "Densigo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:96
+msgid "Connect"
+msgstr "Konekti"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1096
+msgid "Connection info..."
+msgstr "Informo pri konekto..."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:362
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:404
+#, c-format
+msgid "Could not convert the parameter-name %s to wchar_t* when reading from the Registry, the buffersize is to small."
+msgstr "Ne eblis konverti la parametro-nomo %s al wchar_t* dum lego el la Registrujo, la bufrogrando tro malgrandas."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:302
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:340
+#, c-format
+msgid "Could not convert the parameter-name %s to wchar_t* when writing to the Registry, the buffersize is to small."
+msgstr "Ne eblis konverti la parametro-nomo %s al wchar_t* dum skribo al la Registrujo, la bufrogrando tro malgrandas."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:318
+#, c-format
+msgid "Could not convert the parameter-value %s to wchar_t* when writing to the Registry, the buffersize is to small."
+msgstr "Ne eblis konverti la parametro-valoro %s al wchar_t* dum skribo al la Registrujo, la bufrogrando tro malgrandas."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:381
+#, c-format
+msgid "Could not convert the parameter-value for %s to utf8 char* when reading from the Registry, the buffer dest is to small."
+msgstr "Ne eblis konverti la parametro-valoro %s al utf8 char* dum lego el la Registrujo, la bufra celo tro malgrandas."
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:256
+#, c-format
+msgid "Could not create VNC home directory: %s."
+msgstr "Ne eblis krei hejman dosierujon de VNC: %s."
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:251
+msgid "Could not create VNC home directory: can't obtain home directory path."
+msgstr "Ne eblis krei hejman dosierujon de VNC: ne eblas havi tiun vojon."
+
+#: /home/ossman/devel/tigervnc/vncviewer/OSXPixelBuffer.cxx:58
+msgid "Could not create framebuffer bitmap"
+msgstr "Ne eblis krei frambufran bitmapon"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OSXPixelBuffer.cxx:52
+msgid "Could not create framebuffer device"
+msgstr "Ne eblis krei frambufran aparaton"
+
+#: /home/ossman/devel/tigervnc/vncviewer/X11PixelBuffer.cxx:107
+msgid "Could not create framebuffer image"
+msgstr "Ne eblis krei frambufran bildon"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:310
+#, c-format
+msgid "Could not encode the parameter-value %s when writing to the Registry."
+msgstr "Ne eblis enkodigi la parametro-valoron %s dum skribo al la Registrujo."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:613
+#, c-format
+msgid "Could not read the line(%d) in the configuration file,the buffersize is to small."
+msgstr "Ne eblis legi la linion(%d) en la agorda dosiero, la bufrogrando tro malgrandas."
+
+#: /home/ossman/devel/tigervnc/vncviewer/X11PixelBuffer.cxx:68
+msgid "Couldn't find suitable pixmap format"
+msgstr "Ne eblis trovi taŭgan bildermapan formon"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Win32PixelBuffer.cxx:79
+msgid "CreateCompatibleDC failed"
+msgstr "CreateCompatibleDC malsukcesis"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1079
+msgid "Ctrl"
+msgstr "Stirklavo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:550
+msgid "Custom compression level:"
+msgstr "Persona densig-nivelo:"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:283
+msgid "Decoding: The size of the buffer dest is to small, it needs to be 1 byte bigger."
+msgstr "Dekodigo: la grando de la bufra celo tro etas, ĝi bezonas esti 1 bajto pli granda."
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:172
+#, c-format
+msgid "Desktop name: %.80s"
+msgstr "Labortabla nomo: %.80s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1099
+msgid "Dismiss menu"
+msgstr "Forlasi la menuon"
+
+#: /home/ossman/devel/tigervnc/vncviewer/X11PixelBuffer.cxx:59
+msgid "Display lacks pixmap format for default depth"
+msgstr "Montri la bildermapan formon \"lacks\" por apriora profundo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:778
+msgid "Enable full-screen mode over all monitors"
+msgstr "Ebligi plenekranan reĝimon en ĉiuj ekranoj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:469
+msgid "Enabling continuous updates"
+msgstr "Ebligo de daŭrigaj ĝisdatigoj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:200
+#, c-format
+msgid "Encoding backslash: The size of the buffer dest is to small, it needs to be more than %d bytes bigger."
+msgstr "Enkodigo de retroklino: la grando de la bufra celo tro etas, ĝi bezonas esti pli ol %d bajtoj pli granda."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:214
+#, c-format
+msgid "Encoding escape sequence: The size of the buffer dest is to small, it needs to be more than %d bytes bigger."
+msgstr "Enkodigo de skapsekvo: la grando de la bufra celo tro etas, ĝi bezonas esti pli ol %d bajtoj pli granda."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:234
+#, c-format
+msgid "Encoding normal character: The size of the buffer dest is to small, it needs to be more than %d bytes bigger."
+msgstr "Enkodigo de ordinara signo: la grando de la bufra celo tro etas, ĝi bezonas esti pli ol %d bajtoj pli granda."
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:595
+msgid "Encryption"
+msgstr "Ĉifrado"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:503
+#, c-format
+msgid "Error(%d) closing key:  Software\\TigerVNC\\vncviewer"
+msgstr "Eraro(%d) dum fermo de ŝlosilo:  Software\\TigerVNC\\vncviewer"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:455
+#, c-format
+msgid "Error(%d) closing key: Software\\TigerVNC\\vncviewer"
+msgstr "Eraro(%d) dum fermo de ŝlosilo: Software\\TigerVNC\\vncviewer"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:434
+#, c-format
+msgid "Error(%d) creating key: Software\\TigerVNC\\vncviewer"
+msgstr "Eraro(%d) dum kreo de ŝlosilo: Software\\TigerVNC\\vncviewer"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:471
+#, c-format
+msgid "Error(%d) opening key: Software\\TigerVNC\\vncviewer"
+msgstr "Eraro(%d) dum malfermo de ŝlosilo: Software\\TigerVNC\\vncviewer"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:373
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:415
+#, c-format
+msgid "Error(%d) reading %s from Registry."
+msgstr "Eraro(%d) dum lego de %s el la Registrujo."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:348
+#, c-format
+msgid "Error(%d) writing %d(REG_DWORD) to Registry."
+msgstr "Eraro(%d) dum skribo de %d(REG_DWORD) al la Registrujo."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:326
+#, c-format
+msgid "Error(%d) writing %s(REG_SZ) to Registry."
+msgstr "Eraro(%d) dum skribo de %s(REG_SZ) al la Registrujo."
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1067
+msgid "Exit viewer"
+msgstr "Eliri la montrilon"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:588
+msgid "Failed to read configuration file, can't obtain home directory path."
+msgstr "Fiasko dum lego de agorda dosiero, ne eblas preni la hejman dosierujan vojon."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:602
+#, c-format
+msgid "Failed to read configuration file, can't open %s"
+msgstr "Fiasko dum lego de agorda dosiero, ne eblas malfermi %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:621
+#, c-format
+msgid "Failed to read line %d in file %s"
+msgstr "Fiasko dum lego de la linio %d en la dosiero %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:528
+msgid "Failed to write configuration file, can't obtain home directory path."
+msgstr "Fiasko dum skribo de agorda dosiero, ne eblas preni la hejman dosierujan vojon."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:542
+#, c-format
+msgid "Failed to write configuration file, can't open %s"
+msgstr "Fiasko dum skribo de la agorda dosiero, ne eblas malfermi %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/DesktopWindow.cxx:526
+#: /home/ossman/devel/tigervnc/vncviewer/DesktopWindow.cxx:538
+#: /home/ossman/devel/tigervnc/vncviewer/DesktopWindow.cxx:551
+msgid "Failure grabbing keyboard"
+msgstr "Fiasko dum elpreno de klavaro"
+
+#: /home/ossman/devel/tigervnc/vncviewer/DesktopWindow.cxx:563
+msgid "Failure grabbing mouse"
+msgstr "Fiasko dum elpreno de muso"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:512
+msgid "Full (all available colors)"
+msgstr "Kompleta (ĉiuj disponeblaj koloroj)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1070
+msgid "Full screen"
+msgstr "Plena ekrano"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:770
+msgid "Full-screen mode"
+msgstr "Plenekrana reĝimo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:230
+msgid "Hide"
+msgstr "Kaŝi"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:238
+msgid "Hide Others"
+msgstr "Kaŝi aliajn"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:177
+#, c-format
+msgid "Host: %.80s port: %d"
+msgstr "Gastiganto: %.80s pordo: %d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:690
+msgid "Input"
+msgstr "Enigo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:510
+msgid "Internal FLTK error. Exiting."
+msgstr "Interna eraro de FLTK. Ni ĉesas."
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:384
+msgid "Invalid SetColourMapEntries from server!"
+msgstr "Malvalida SetColourMapEntries el servilo!"
+
+#: /home/ossman/devel/tigervnc/vncviewer/DesktopWindow.cxx:106
+msgid "Invalid geometry specified!"
+msgstr "Malvalida geometrio indikita!"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:708
+#, c-format
+msgid "Invalid parameter name on line: %d in file: %s"
+msgstr "Malvalida parametra nomo en linio: %d en dosiero: %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/DesktopWindow.cxx:805
+msgid "Invalid screen layout computed for resize request!"
+msgstr "Malvalida ekrana aranĝo komputita por regrandiga peto!"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:204
+#, c-format
+msgid "Last used encoding: %s"
+msgstr "Lasta uzata enkodigo: %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:631
+#, c-format
+msgid ""
+"Line 1 in file %s\n"
+"must contain the TigerVNC configuration file identifier string:\n"
+"\"%s\""
+msgstr ""
+"Linio 1 en la dosiero %s\n"
+"devas enhavi la agordo-dosieran identig-ĉenon de TigerVNC:\n"
+"\"%s\""
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:209
+#, c-format
+msgid "Line speed estimate: %d kbit/s"
+msgstr "Lini-rapida konjekto: %d kbit/s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:478
+#, c-format
+msgid "Listening on port %d\n"
+msgstr "Ni aŭskultas pordon %d\n"
+
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:69
+msgid "Load..."
+msgstr "Ŝargo..."
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:526
+msgid "Low (64 colors)"
+msgstr "Malalte (64 koloroj)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:519
+msgid "Medium (256 colors)"
+msgstr "Meze (256 koloroj)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:725
+msgid "Menu key"
+msgstr "Menu-klavo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:791
+msgid "Misc."
+msgstr "Divers."
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1037
+#, c-format
+msgid "Multiple characters given for key code %d (0x%04x): '%s'"
+msgstr "Multoblaj signoj indikitaj por klavkodo %d (0x%04x): '%s'"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:218
+msgid "No"
+msgstr "Ne"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:691
+#, c-format
+msgid "No scan code for extended virtual key 0x%02x"
+msgstr "Neniu skankodo por kroma virtuala klavo 0x%02x"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:693
+#, c-format
+msgid "No scan code for virtual key 0x%02x"
+msgstr "Neniu skankodo por virtuala klavo 0x%02x"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:710
+#, c-format
+msgid "No symbol for extended virtual key 0x%02x"
+msgstr "Neniu simbolo por kroma virtuala klavo 0x%02x"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:776
+#, c-format
+msgid "No symbol for key code %d (in the current state)"
+msgstr "Neniu simbolo por klavkodo %d (en la nuna stato)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:750
+#, c-format
+msgid "No symbol for key code 0x%02x (in the current state)"
+msgstr "Neniu simbolo por klavkodo 0x%02x (en la nuna stato)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:712
+#, c-format
+msgid "No symbol for virtual key 0x%02x"
+msgstr "Neniu simbolo por virtuala klavo 0x%02x"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:606
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:659
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:727
+msgid "None"
+msgstr "Nenio"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OSXPixelBuffer.cxx:48
+#: /home/ossman/devel/tigervnc/vncviewer/FLTKPixelBuffer.cxx:33
+#: /home/ossman/devel/tigervnc/vncviewer/X11PixelBuffer.cxx:111
+msgid "Not enough memory for framebuffer"
+msgstr "Ne sufiĉe da memoro por frambufro"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:220
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:88
+msgid "OK"
+msgstr "Bone"
+
+#: /home/ossman/devel/tigervnc/vncviewer/X11PixelBuffer.cxx:77
+msgid "Only true colour displays supported"
+msgstr "Nur verŝajn-koloraj montriloj estas subtenataj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/UserDialog.cxx:74
+msgid "Opening password file failed"
+msgstr "Malfermo de pasvorta dosiero fiaskis"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1095
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:64
+msgid "Options..."
+msgstr "Modifiloj..."
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:463
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:464
+msgid "Parameters -listen and -via are incompatible"
+msgstr "Parametroj -listen kaj -via estas malkongruaj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:722
+msgid "Pass system keys directly to server (full screen)"
+msgstr "Pasi sistemajn klavojn rekte al la servilo (plenekrane)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/UserDialog.cxx:87
+#: /home/ossman/devel/tigervnc/vncviewer/UserDialog.cxx:102
+msgid "Password:"
+msgstr "Pasvorto:"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:625
+msgid "Path to X509 CA certificate"
+msgstr "Vojo al atestilo X509 CA"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:632
+msgid "Path to X509 CRL file"
+msgstr "Vojo al dosiero X509 CRL"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:188
+#, c-format
+msgid "Pixel format: %s"
+msgstr "Bildero-formo: %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:449
+msgid "Preferred encoding"
+msgstr "Preferata enkodigo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:214
+#, c-format
+msgid "Protocol version: %d.%d"
+msgstr "Protokola versio: %d.%d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:233
+msgid "Quit"
+msgstr "Eliri"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1093
+msgid "Refresh screen"
+msgstr "Aktualigi ekranon"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:199
+#, c-format
+msgid "Requested encoding: %s"
+msgstr "Petata enkodigo: %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:749
+msgid "Resize remote session on connect"
+msgstr "Regrandigi foran seancon dum konekto"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:762
+msgid "Resize remote session to the local window"
+msgstr "Regrandigi foran seancon al la loka fenestro"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1073
+msgid "Resize window to session"
+msgstr "Regrandigi fenestron al seanco"
+
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:74
+msgid "Save As..."
+msgstr "Konservi kiel..."
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:741
+msgid "Screen"
+msgstr "Ekrano"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:580
+msgid "Security"
+msgstr "Sekureco"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:219
+#, c-format
+msgid "Security method: %s"
+msgstr "Sekureca metodo: %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Win32PixelBuffer.cxx:82
+msgid "SelectObject failed"
+msgstr "SelectObject fiaskis"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1086
+#, c-format
+msgid "Send %s"
+msgstr "Sendi %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1091
+msgid "Send Ctrl-Alt-Del"
+msgstr "Sendi Ctrl-Alt-Del"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:710
+msgid "Send clipboard to server"
+msgstr "Sendi tondaĵon al la servilo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:716
+msgid "Send primary selection and cut buffer as clipboard"
+msgstr "Sendi ĉefan elekton kaj tondan bufron kiel tondajôn"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:237
+msgid "Services"
+msgstr "Servoj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:319
+#, c-format
+msgid "SetDesktopSize failed: %d"
+msgstr "SetDesktopSize fiaskis: %d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:799
+msgid "Shared (don't disconnect other viewers)"
+msgstr "Kunhave (ne malkonekti aliajn montrilojn)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:239
+msgid "Show All"
+msgstr "Montri ĉiujn"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:805
+msgid "Show dot when no cursor"
+msgstr "Montri punkton kiam sen kursoro"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:182
+#, c-format
+msgid "Size: %d x %d"
+msgstr "Grando: %d x %d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:665
+msgid "Standard VNC (insecure without encryption)"
+msgstr "Ordinara VNC (nesekura sen ĉifrado)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:618
+msgid "TLS with X509 certificates"
+msgstr "TLS kun atestiloj X509"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:612
+msgid "TLS with anonymous certificates"
+msgstr "TLS kun anonimaj atestiloj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:448
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:497
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:561
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:701
+#, c-format
+msgid "The parameterArray contains a object of a invalid type at line %d."
+msgstr "La parameterArray enhavas objekton de malvalida tipo ĉe linio %d."
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:664
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:680
+#, c-format
+msgid "The value of the parameter %s on line %d in file %s is invalid."
+msgstr "La valoro de parametro %s en linio %d en dosiero %s malvalidas."
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:539
+#, c-format
+msgid "Throughput %d kbit/s - changing to quality %d"
+msgstr "Traigo %d kbit/s - ni ŝanĝas al kvalito %d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:561
+#, c-format
+msgid "Throughput %d kbit/s - full color is now %s"
+msgstr "Traigo %d kbit/s - plenkoloro nun estas %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:210
+msgid "TigerVNC Viewer"
+msgstr "Montrilo TigerVNC"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:80
+#, c-format
+msgid ""
+"TigerVNC Viewer %d-bit v%s\n"
+"Built on: %s\n"
+"Copyright (C) 1999-%d TigerVNC Team and many others (see README.txt)\n"
+"See http://www.tigervnc.org for information on TigerVNC."
+msgstr ""
+"Montrilo TigerVNC %d-bit v%s\n"
+"Konstruita en: %s\n"
+"Kopirajto (C) 1999-%d teamo TigerVNC kaj multaj aliaj (konsultu README.txt)\n"
+"Konsultu http://www.tigervnc.org por informoj pri TigerVNC."
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:456
+#, c-format
+msgid "Unable to create platform specific framebuffer: %s"
+msgstr "Ne eblas krei frambufron specifan de platformo: %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1015
+#, c-format
+msgid "Unknown FLTK key code %d (0x%04x)"
+msgstr "Nekonata klavkodo de FLTK %d (0x%04x)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:889
+#, c-format
+msgid "Unknown decimal separator: '%s'"
+msgstr "Nekonata dekuma apartigilo: '%s'"
+
+#: /home/ossman/devel/tigervnc/vncviewer/parameters.cxx:271
+#, c-format
+msgid "Unknown escape sequence at character %d"
+msgstr "Nekonata eskap-sekvo ĉe signo %d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:430
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:437
+msgid "Unknown rect encoding"
+msgstr "Nekonata enkodigo 'rect'"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:429
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:436
+#, c-format
+msgid "Unknown rect encoding %d"
+msgstr "Nekonata enkodigo 'rect' %d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:671
+msgid "Username and password (insecure without encryption)"
+msgstr "Uzantnomo kaj pasvorto (nesekura sen ĉifrado)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/UserDialog.cxx:99
+msgid "Username:"
+msgstr "Uzantnomo:"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:573
+#, c-format
+msgid "Using %s encoding"
+msgstr "Ni uzas enkodigon %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/X11PixelBuffer.cxx:79
+#, c-format
+msgid "Using default colormap and visual, %sdepth %d."
+msgstr "Ni uzas aprioran kolormapon kaj ŝajnon, %sprofundo %d."
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:620
+#, c-format
+msgid "Using pixel format %s"
+msgstr "Ni uzas bilderformon %s"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:457
+msgid "Using platform independent framebuffer"
+msgstr "Ni uzas frambufron sendependan de platformo"
+
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:42
+msgid "VNC Viewer: Connection Details"
+msgstr "Montrilo VNC: konektaj detaloj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:57
+msgid "VNC Viewer: Connection Options"
+msgstr "Montrilo VNC: konektaj preferoj"
+
+#: /home/ossman/devel/tigervnc/vncviewer/UserDialog.cxx:86
+#: /home/ossman/devel/tigervnc/vncviewer/UserDialog.cxx:96
+msgid "VNC authentication"
+msgstr "Aŭtentikiĝo de VNC"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Viewport.cxx:1187
+msgid "VNC connection info"
+msgstr "Konekta informo de VNC"
+
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:49
+#: /home/ossman/devel/tigervnc/vncviewer/ServerDialog.cxx:54
+msgid "VNC server:"
+msgstr "Servilo VNC:"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:533
+msgid "Very low (8 colors)"
+msgstr "Tre malalta (8 koloroj)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:698
+msgid "View only (ignore mouse and keyboard)"
+msgstr "Nur rigardi (preteratenti muson kaj klavaron)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/vncviewer.cxx:219
+msgid "Yes"
+msgstr "Jes"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:111
+#, c-format
+msgid "connected to host %s port %d"
+msgstr "konektita al gastiganto %s pordo %d"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:563
+msgid "disabled"
+msgstr "malebligita"
+
+#: /home/ossman/devel/tigervnc/vncviewer/CConn.cxx:563
+msgid "enabled"
+msgstr "ebligita"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:556
+msgid "level (1=fast, 6=best [4-6 are rarely useful])"
+msgstr "nivelo (1=rapida, 6=plejbona [4-6 rare utilas])"
+
+#: /home/ossman/devel/tigervnc/vncviewer/OptionsDialog.cxx:569
+msgid "quality (0=poor, 9=best)"
+msgstr "kvalito (0=aĉa, 9=plejbona)"
+
+#: /home/ossman/devel/tigervnc/vncviewer/Win32PixelBuffer.cxx:62
+msgid "unable to create DIB section"
+msgstr "ne eblas krei sekcion DIB"
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index afab3e2..e99c825 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -7,3 +7,9 @@
 
 add_executable(conv conv.cxx)
 target_link_libraries(conv rfb)
+
+add_executable(decperf decperf.cxx)
+target_link_libraries(decperf test_util rfb)
+
+add_executable(encperf encperf.cxx)
+target_link_libraries(encperf test_util rfb)
diff --git a/tests/conv.cxx b/tests/conv.cxx
index 2ee523a..840f18d 100644
--- a/tests/conv.cxx
+++ b/tests/conv.cxx
@@ -266,7 +266,7 @@
 static void doTests(const rfb::PixelFormat &dstpf,
                     const rfb::PixelFormat &srcpf)
 {
-  int i;
+  size_t i;
   char dstb[256], srcb[256];
 
   dstpf.print(dstb, sizeof(dstb));
diff --git a/tests/convperf.cxx b/tests/convperf.cxx
index c8381d5..e4a3fd5 100644
--- a/tests/convperf.cxx
+++ b/tests/convperf.cxx
@@ -100,7 +100,7 @@
 
 static void doTests(rfb::PixelFormat &dstpf, rfb::PixelFormat &srcpf)
 {
-  int i;
+  size_t i;
   char dstb[256], srcb[256];
 
   dstpf.print(dstb, sizeof(dstb));
@@ -118,19 +118,19 @@
 
 int main(int argc, char **argv)
 {
-  int bufsize;
+  size_t bufsize;
 
   time_t t;
   char datebuffer[256];
 
-  int i;
+  size_t i;
 
   bufsize = fbsize * fbsize * 4;
 
   fb1 = new rdr::U8[bufsize];
   fb2 = new rdr::U8[bufsize];
 
-  for (int i = 0;i < bufsize;i++) {
+  for (i = 0;i < bufsize;i++) {
     fb1[i] = rand();
     fb2[i] = rand();
   }
diff --git a/tests/decperf.cxx b/tests/decperf.cxx
new file mode 100644
index 0000000..fe7b032
--- /dev/null
+++ b/tests/decperf.cxx
@@ -0,0 +1,222 @@
+/* Copyright 2015 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ * 
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+/*
+ * This program reads files produced by TightVNC's/TurboVNC's
+ * compare-encodings. It is basically a dump of the RFB protocol
+ * from the server side from the ServerInit message and forward.
+ * It is assumed that the client is using a bgr888 (LE) pixel
+ * format.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <rdr/Exception.h>
+#include <rdr/FileInStream.h>
+
+#include <rfb/CConnection.h>
+#include <rfb/CMsgReader.h>
+#include <rfb/Decoder.h>
+#include <rfb/PixelBuffer.h>
+#include <rfb/PixelFormat.h>
+
+#include "util.h"
+
+// FIXME: Files are always in this format
+static const rfb::PixelFormat filePF(32, 24, false, true, 255, 255, 255, 0, 8, 16);
+
+class CConn : public rfb::CConnection {
+public:
+  CConn(const char *filename);
+  ~CConn();
+
+  virtual void setDesktopSize(int w, int h);
+  virtual void setPixelFormat(const rfb::PixelFormat& pf);
+  virtual void setCursor(int, int, const rfb::Point&, void*, void*);
+  virtual void dataRect(const rfb::Rect&, int);
+  virtual void setColourMapEntries(int, int, rdr::U16*);
+  virtual void bell();
+  virtual void serverCutText(const char*, rdr::U32);
+
+public:
+  double cpuTime;
+
+protected:
+  rdr::FileInStream *in;
+  rfb::Decoder *decoders[rfb::encodingMax+1];
+  rfb::ManagedPixelBuffer pb;
+};
+
+CConn::CConn(const char *filename)
+{
+  int i;
+
+  cpuTime = 0.0;
+
+  in = new rdr::FileInStream(filename);
+  setStreams(in, NULL);
+
+  memset(decoders, 0, sizeof(decoders));
+  for (i = 0;i < rfb::encodingMax;i++) {
+    if (!rfb::Decoder::supported(i))
+      continue;
+
+    decoders[i] = rfb::Decoder::createDecoder(i, this);
+  }
+
+  // Need to skip the initial handshake
+  setState(RFBSTATE_INITIALISATION);
+  // That also means that the reader and writer weren't setup
+  setReader(new rfb::CMsgReader(this, in));
+}
+
+CConn::~CConn()
+{
+  int i;
+
+  delete in;
+
+  for (i = 0;i < rfb::encodingMax;i++)
+    delete decoders[i];
+}
+
+void CConn::setDesktopSize(int w, int h)
+{
+  CConnection::setDesktopSize(w, h);
+
+  pb.setSize(cp.width, cp.height);
+}
+
+void CConn::setPixelFormat(const rfb::PixelFormat& pf)
+{
+  // Override format
+  CConnection::setPixelFormat(filePF);
+
+  pb.setPF(cp.pf());
+}
+
+void CConn::setCursor(int, int, const rfb::Point&, void*, void*)
+{
+}
+
+void CConn::dataRect(const rfb::Rect &r, int encoding)
+{
+  if (!decoders[encoding])
+    throw rdr::Exception("Unknown encoding");
+
+  startCpuCounter();
+  decoders[encoding]->readRect(r, &pb);
+  endCpuCounter();
+
+  cpuTime += getCpuCounter();
+}
+
+void CConn::setColourMapEntries(int, int, rdr::U16*)
+{
+}
+
+void CConn::bell()
+{
+}
+
+void CConn::serverCutText(const char*, rdr::U32)
+{
+}
+
+static double runTest(const char *fn)
+{
+  CConn *cc;
+  double time;
+
+  try {
+    cc = new CConn(fn);
+  } catch (rdr::Exception e) {
+    fprintf(stderr, "Failed to open rfb file: %s\n", e.str());
+    exit(1);
+  }
+
+  try {
+    while (true)
+      cc->processMsg();
+  } catch (rdr::EndOfStream e) {
+  } catch (rdr::Exception e) {
+    fprintf(stderr, "Failed to run rfb file: %s\n", e.str());
+    exit(1);
+  }
+
+  time = cc->cpuTime;
+
+  delete cc;
+
+  return time;
+}
+
+static void sort(double *array, int count)
+{
+  bool sorted;
+  int i;
+  do {
+    sorted = true;
+    for (i = 1;i < count;i++) {
+      if (array[i-1] > array[i]) {
+        double d;
+        d = array[i];
+        array[i] = array[i-1];
+        array[i-1] = d;
+        sorted = false;
+      }
+    }
+  } while (!sorted);
+}
+
+static const int runCount = 9;
+
+int main(int argc, char **argv)
+{
+  int i;
+  double times[runCount], dev[runCount];
+  double median, meddev;
+
+  if (argc != 2) {
+    printf("Syntax: %s <rfb file>\n", argv[0]);
+    return 1;
+  }
+
+  // Warmup
+  runTest(argv[1]);
+
+  // Multiple runs to get a good average
+  for (i = 0;i < runCount;i++)
+    times[i] = runTest(argv[1]);
+
+  // Calculate median and median deviation
+  sort(times, runCount);
+  median = times[runCount/2];
+
+  for (i = 0;i < runCount;i++)
+    dev[i] = fabs((times[i] - median) / median) * 100;
+
+  sort(dev, runCount);
+  meddev = dev[runCount/2];
+
+  printf("CPU time: %g s (+/- %g %%)\n", median, meddev);
+
+  return 0;
+}
diff --git a/tests/encperf.cxx b/tests/encperf.cxx
new file mode 100644
index 0000000..9b632e7
--- /dev/null
+++ b/tests/encperf.cxx
@@ -0,0 +1,468 @@
+/* Copyright 2015 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ * Copyright (C) 2015 D. R. Commander.  All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+/*
+ * This program reads files produced by TightVNC's/TurboVNC's
+ * fbs-dump, which in turn takes files from rfbproxy. It is
+ * basically a dump of the RFB protocol from the server side after
+ * the ServerInit message. Mostly this consists of FramebufferUpdate
+ * message using the HexTile encoding. Screen size and pixel format
+ * are not encoded in the file and must be specified by the user.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <rdr/Exception.h>
+#include <rdr/OutStream.h>
+#include <rdr/FileInStream.h>
+
+#include <rfb/PixelFormat.h>
+
+#include <rfb/CConnection.h>
+#include <rfb/CMsgReader.h>
+#include <rfb/Decoder.h>
+#include <rfb/UpdateTracker.h>
+
+#include <rfb/EncodeManager.h>
+#include <rfb/SConnection.h>
+#include <rfb/SMsgWriter.h>
+
+#include "util.h"
+
+static rfb::IntParameter width("width", "Frame buffer width", 0);
+static rfb::IntParameter height("height", "Frame buffer height", 0);
+static rfb::IntParameter count("count", "Number of benchmark iterations", 9);
+
+static rfb::StringParameter format("format", "Pixel format (e.g. bgr888)", "");
+
+static rfb::BoolParameter translate("translate",
+                                    "Translate 8-bit and 16-bit datasets into 24-bit",
+                                    true);
+
+// The frame buffer (and output) is always this format
+static const rfb::PixelFormat fbPF(32, 24, false, true, 255, 255, 255, 0, 8, 16);
+
+// Encodings to use
+static const rdr::S32 encodings[] = {
+  rfb::encodingTight, rfb::encodingCopyRect, rfb::encodingRRE,
+  rfb::encodingHextile, rfb::encodingZRLE, rfb::pseudoEncodingLastRect,
+  rfb::pseudoEncodingQualityLevel0 + 8,
+  rfb::pseudoEncodingCompressLevel0 + 2};
+
+class DummyOutStream : public rdr::OutStream {
+public:
+  DummyOutStream();
+
+  virtual int length();
+  virtual void flush();
+
+private:
+  virtual int overrun(int itemSize, int nItems);
+
+  int offset;
+  rdr::U8 buf[131072];
+};
+
+class CConn : public rfb::CConnection {
+public:
+  CConn(const char *filename);
+  ~CConn();
+
+  void getStats(double& ratio, unsigned long long& bytes,
+                unsigned long long& rawEquivalent);
+
+  virtual void setDesktopSize(int w, int h);
+  virtual void setCursor(int, int, const rfb::Point&, void*, void*);
+  virtual void framebufferUpdateStart();
+  virtual void framebufferUpdateEnd();
+  virtual void dataRect(const rfb::Rect&, int);
+  virtual void setColourMapEntries(int, int, rdr::U16*);
+  virtual void bell();
+  virtual void serverCutText(const char*, rdr::U32);
+
+public:
+  double decodeTime;
+  double encodeTime;
+
+protected:
+  rdr::FileInStream *in;
+  rfb::Decoder *decoders[rfb::encodingMax + 1];
+  rfb::ManagedPixelBuffer pb;
+  rfb::SimpleUpdateTracker updates;
+  class SConn *sc;
+};
+
+class Manager : public rfb::EncodeManager {
+public:
+  Manager(class rfb::SConnection *conn);
+
+  void getStats(double&, unsigned long long&, unsigned long long&);
+};
+
+class SConn : public rfb::SConnection {
+public:
+  SConn();
+  ~SConn();
+
+  void writeUpdate(const rfb::UpdateInfo& ui, const rfb::PixelBuffer* pb);
+
+  void getStats(double&, unsigned long long&, unsigned long long&);
+
+  virtual void setAccessRights(AccessRights ar);
+
+  virtual void setDesktopSize(int fb_width, int fb_height,
+                              const rfb::ScreenSet& layout);
+
+protected:
+  DummyOutStream *out;
+  Manager *manager;
+};
+
+DummyOutStream::DummyOutStream()
+{
+  offset = 0;
+  ptr = buf;
+  end = buf + sizeof(buf);
+}
+
+int DummyOutStream::length()
+{
+  flush();
+  return offset;
+}
+
+void DummyOutStream::flush()
+{
+  offset += ptr - buf;
+  ptr = buf;
+}
+
+int DummyOutStream::overrun(int itemSize, int nItems)
+{
+  flush();
+  if (itemSize * nItems > end - ptr)
+    nItems = (end - ptr) / itemSize;
+  return nItems;
+}
+
+CConn::CConn(const char *filename)
+{
+  int i;
+
+  decodeTime = 0.0;
+  encodeTime = 0.0;
+
+  in = new rdr::FileInStream(filename);
+  setStreams(in, NULL);
+
+  memset(decoders, 0, sizeof(decoders));
+  for (i = 0; i < rfb::encodingMax; i++) {
+    if (!rfb::Decoder::supported(i))
+      continue;
+
+    decoders[i] = rfb::Decoder::createDecoder(i, this);
+  }
+
+  // Need to skip the initial handshake and ServerInit
+  setState(RFBSTATE_NORMAL);
+  // That also means that the reader and writer weren't setup
+  setReader(new rfb::CMsgReader(this, in));
+  // Nor the frame buffer size and format
+  setDesktopSize(width, height);
+  rfb::PixelFormat pf;
+  pf.parse(format);
+  setPixelFormat(pf);
+
+  pb.setPF((bool)translate ? fbPF : pf);
+
+  sc = new SConn();
+  sc->cp.setPF(pb.getPF());
+  sc->setEncodings(sizeof(encodings) / sizeof(*encodings), encodings);
+}
+
+CConn::~CConn()
+{
+  int i;
+
+  delete sc;
+
+  delete in;
+
+  for (i = 0; i < rfb::encodingMax; i++)
+    delete decoders[i];
+}
+
+void CConn::getStats(double& ratio, unsigned long long& bytes,
+                     unsigned long long& rawEquivalent)
+{
+  sc->getStats(ratio, bytes, rawEquivalent);
+}
+
+void CConn::setDesktopSize(int w, int h)
+{
+  CConnection::setDesktopSize(w, h);
+
+  pb.setSize(cp.width, cp.height);
+}
+
+void CConn::setCursor(int, int, const rfb::Point&, void*, void*)
+{
+}
+
+void CConn::framebufferUpdateStart()
+{
+  updates.clear();
+}
+
+void CConn::framebufferUpdateEnd()
+{
+  rfb::UpdateInfo ui;
+  rfb::Region clip(pb.getRect());
+
+  updates.getUpdateInfo(&ui, clip);
+
+  startCpuCounter();
+  sc->writeUpdate(ui, &pb);
+  endCpuCounter();
+
+  encodeTime += getCpuCounter();
+}
+
+void CConn::dataRect(const rfb::Rect &r, int encoding)
+{
+  if (!decoders[encoding])
+    throw rdr::Exception("Unknown encoding");
+
+  startCpuCounter();
+  decoders[encoding]->readRect(r, &pb);
+  endCpuCounter();
+
+  decodeTime += getCpuCounter();
+
+  if (encoding != rfb::encodingCopyRect) // FIXME
+    updates.add_changed(rfb::Region(r));
+}
+
+void CConn::setColourMapEntries(int, int, rdr::U16*)
+{
+}
+
+void CConn::bell()
+{
+}
+
+void CConn::serverCutText(const char*, rdr::U32)
+{
+}
+
+Manager::Manager(class rfb::SConnection *conn) :
+  EncodeManager(conn)
+{
+}
+
+void Manager::getStats(double& ratio, unsigned long long& encodedBytes,
+                       unsigned long long& rawEquivalent)
+{
+  StatsVector::iterator iter;
+  unsigned long long bytes, equivalent;
+
+  bytes = equivalent = 0;
+  for (iter = stats.begin(); iter != stats.end(); ++iter) {
+    StatsVector::value_type::iterator iter2;
+    for (iter2 = iter->begin(); iter2 != iter->end(); ++iter2) {
+      bytes += iter2->bytes;
+      equivalent += iter2->equivalent;
+    }
+  }
+
+  ratio = (double)equivalent / bytes;
+  encodedBytes = bytes;
+  rawEquivalent = equivalent;
+}
+
+SConn::SConn()
+{
+  out = new DummyOutStream;
+  setStreams(NULL, out);
+
+  setWriter(new rfb::SMsgWriter(&cp, out));
+
+  manager = new Manager(this);
+}
+
+SConn::~SConn()
+{
+  delete manager;
+  delete out;
+}
+
+void SConn::writeUpdate(const rfb::UpdateInfo& ui, const rfb::PixelBuffer* pb)
+{
+  manager->writeUpdate(ui, pb, NULL);
+}
+
+void SConn::getStats(double& ratio, unsigned long long& bytes,
+                     unsigned long long& rawEquivalent)
+{
+  manager->getStats(ratio, bytes, rawEquivalent);
+}
+
+void SConn::setAccessRights(AccessRights ar)
+{
+}
+
+void SConn::setDesktopSize(int fb_width, int fb_height,
+                           const rfb::ScreenSet& layout)
+{
+}
+
+static double runTest(const char *fn, double& ratio, unsigned long long& bytes,
+                      unsigned long long& rawEquivalent)
+{
+  CConn *cc;
+  double time;
+
+  try {
+    cc = new CConn(fn);
+  } catch (rdr::Exception e) {
+    fprintf(stderr, "Failed to open rfb file: %s\n", e.str());
+    exit(1);
+  }
+
+  try {
+    while (true)
+      cc->processMsg();
+  } catch (rdr::EndOfStream e) {
+  } catch (rdr::Exception e) {
+    fprintf(stderr, "Failed to run rfb file: %s\n", e.str());
+    exit(1);
+  }
+
+  time = cc->encodeTime;
+  cc->getStats(ratio, bytes, rawEquivalent);
+
+  delete cc;
+
+  return time;
+}
+
+static void sort(double *array, int count)
+{
+  bool sorted;
+  int i;
+  do {
+    sorted = true;
+    for (i = 1; i < count; i++) {
+      if (array[i-1] > array[i]) {
+        double d;
+        d = array[i];
+        array[i] = array[i - 1];
+        array[i - 1] = d;
+        sorted = false;
+      }
+    }
+  } while (!sorted);
+}
+
+static void usage(const char *argv0)
+{
+  fprintf(stderr, "Syntax: %s [options] <rfb file>\n", argv0);
+  fprintf(stderr, "Options:\n");
+  rfb::Configuration::listParams(79, 14);
+  exit(1);
+}
+
+int main(int argc, char **argv)
+{
+  int i;
+
+  const char *fn;
+
+  fn = NULL;
+  for (i = 1; i < argc; i++) {
+    if (rfb::Configuration::setParam(argv[i]))
+      continue;
+
+    if (argv[i][0] == '-') {
+      if (i + 1 < argc) {
+        if (rfb::Configuration::setParam(&argv[i][1], argv[i + 1])) {
+          i++;
+          continue;
+        }
+      }
+      usage(argv[0]);
+    }
+
+    if (fn != NULL)
+      usage(argv[0]);
+
+    fn = argv[i];
+  }
+
+  int runCount = count;
+  double times[runCount], dev[runCount];
+  double median, meddev, ratio;
+  unsigned long long bytes, equivalent;
+
+  if (fn == NULL) {
+    fprintf(stderr, "No file specified!\n\n");
+    usage(argv[0]);
+  }
+
+  if (!format.hasBeenSet()) {
+    fprintf(stderr, "Pixel format not specified!\n\n");
+    usage(argv[0]);
+  }
+
+  if (!width.hasBeenSet() || !height.hasBeenSet()) {
+    fprintf(stderr, "Frame buffer size not specified!\n\n");
+    usage(argv[0]);
+  }
+
+  // Warmup
+  runTest(fn, ratio, bytes, equivalent);
+
+  // Multiple runs to get a good average
+  for (i = 0; i < runCount; i++)
+    times[i] = runTest(fn, ratio, bytes, equivalent);
+
+  // Calculate median and median deviation
+  sort(times, runCount);
+  median = times[runCount / 2];
+
+  for (i = 0; i < runCount; i++)
+    dev[i] = fabs((times[i] - median) / median) * 100;
+
+  sort(dev, runCount);
+  meddev = dev[runCount / 2];
+
+  printf("CPU time: %g s (+/- %g %%)\n", median, meddev);
+#ifdef WIN32
+  printf("Encoded bytes: %I64d\n", bytes);
+  printf("Raw equivalent bytes: %I64d\n", equivalent);
+#else
+  printf("Encoded bytes: %lld\n", bytes);
+  printf("Raw equivalent bytes: %lld\n", equivalent);
+#endif
+  printf("Ratio: %g\n", ratio);
+
+  return 0;
+}
diff --git a/tests/util.cxx b/tests/util.cxx
index c2685ab..419f09c 100644
--- a/tests/util.cxx
+++ b/tests/util.cxx
@@ -17,6 +17,8 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
 
 #ifdef WIN32
 #include <windows.h>
@@ -24,52 +26,93 @@
 #include <sys/resource.h>
 #endif
 
+#include "util.h"
+
 #ifdef WIN32
-static FILETIME cpuCounters[2];
+typedef FILETIME syscounter_t;
 #else
-struct rusage cpuCounters[2];
+typedef struct rusage syscounter_t;
 #endif
 
-static void measureCpu(void *counter)
+static syscounter_t _globalCounter[2];
+static cpucounter_t globalCounter = _globalCounter;
+
+void startCpuCounter(void)
+{
+  startCpuCounter(globalCounter);
+}
+
+void endCpuCounter(void)
+{
+  endCpuCounter(globalCounter);
+}
+
+double getCpuCounter(void)
+{
+  return getCpuCounter(globalCounter);
+}
+
+cpucounter_t newCpuCounter(void)
+{
+  syscounter_t *c;
+
+  c = (syscounter_t*)malloc(sizeof(syscounter_t) * 2);
+  if (c == NULL)
+    return NULL;
+
+  memset(c, 0, sizeof(syscounter_t) * 2);
+
+  return c;
+}
+
+void freeCpuCounter(cpucounter_t c)
+{
+  free(c);
+}
+
+static void measureCpu(syscounter_t *counter)
 {
 #ifdef WIN32
   FILETIME dummy1, dummy2, dummy3;
 
   GetProcessTimes(GetCurrentProcess(), &dummy1, &dummy2,
-                  &dummy3, (FILETIME*)counter);
+                  &dummy3, counter);
 #else
-  getrusage(RUSAGE_SELF, (struct rusage*)counter);
+  getrusage(RUSAGE_SELF, counter);
 #endif
 }
 
-void startCpuCounter(void)
+void startCpuCounter(cpucounter_t c)
 {
-  measureCpu(&cpuCounters[0]);
+  syscounter_t *s = (syscounter_t*)c;
+  measureCpu(&s[0]);
 }
 
-void endCpuCounter(void)
+void endCpuCounter(cpucounter_t c)
 {
-  measureCpu(&cpuCounters[1]);
+  syscounter_t *s = (syscounter_t*)c;
+  measureCpu(&s[1]);
 }
 
-double getCpuCounter(void)
+double getCpuCounter(cpucounter_t c)
 {
+  syscounter_t *s = (syscounter_t*)c;
   double seconds;
 
 #ifdef WIN32
   uint64_t counters[2];
 
-  counters[0] = (uint64_t)cpuCounters[0].dwHighDateTime << 32 |
-                cpuCounters[0].dwLowDateTime;
-  counters[1] = (uint64_t)cpuCounters[1].dwHighDateTime << 32 |
-                cpuCounters[1].dwLowDateTime;
+  counters[0] = (uint64_t)s[0].dwHighDateTime << 32 |
+                s[0].dwLowDateTime;
+  counters[1] = (uint64_t)s[1].dwHighDateTime << 32 |
+                s[1].dwLowDateTime;
 
-  seconds = (double)(counters[1] - counters[2]) / 10000000.0;
+  seconds = (double)(counters[1] - counters[0]) / 10000000.0;
 #else
-  seconds = (double)(cpuCounters[1].ru_utime.tv_sec -
-                     cpuCounters[0].ru_utime.tv_sec);
-  seconds += (double)(cpuCounters[1].ru_utime.tv_usec -
-                      cpuCounters[0].ru_utime.tv_usec) / 1000000.0;
+  seconds = (double)(s[1].ru_utime.tv_sec -
+                     s[0].ru_utime.tv_sec);
+  seconds += (double)(s[1].ru_utime.tv_usec -
+                      s[0].ru_utime.tv_usec) / 1000000.0;
 #endif
 
   return seconds;
diff --git a/tests/util.h b/tests/util.h
index ebeadeb..16f2ba2 100644
--- a/tests/util.h
+++ b/tests/util.h
@@ -19,9 +19,19 @@
 #ifndef __TESTS_UTIL_H__
 #define __TESTS_UTIL_H__
 
+typedef void* cpucounter_t;
+
 void startCpuCounter(void);
 void endCpuCounter(void);
 
 double getCpuCounter(void);
 
+cpucounter_t newCpuCounter(void);
+void freeCpuCounter(cpucounter_t c);
+
+void startCpuCounter(cpucounter_t c);
+void endCpuCounter(cpucounter_t c);
+
+double getCpuCounter(cpucounter_t c);
+
 #endif
diff --git a/unix/vncconfig/vncExt.c b/unix/vncconfig/vncExt.c
index c2e6d3c..ff6b4d6 100644
--- a/unix/vncconfig/vncExt.c
+++ b/unix/vncconfig/vncExt.c
@@ -16,6 +16,7 @@
  * USA.
  */
 #include <stdio.h>
+#include <stdint.h>
 
 #define NEED_REPLIES
 #include <X11/Xlib.h>
@@ -277,7 +278,7 @@
   return True;
 }
 
-Bool XVncExtConnect(Display* dpy, char* hostAndPort)
+Bool XVncExtConnect(Display* dpy, const char* hostAndPort)
 {
   xVncExtConnectReq* req;
   xVncExtConnectReply rep;
@@ -328,7 +329,7 @@
   if (!*addr || !*user) {
     Xfree(*addr);
     Xfree(*user);
-    _XEatData(dpy, (rep.addrLen+1)&~1 + (rep.userLen+1)&~1);
+    _XEatData(dpy, ((rep.addrLen+1)&~1) + ((rep.userLen+1)&~1));
     return False;
   }
   _XReadPad(dpy, *addr, rep.addrLen);
@@ -336,7 +337,7 @@
   _XReadPad(dpy, *user, rep.userLen);
   (*user)[rep.userLen] = 0;
   *timeout = rep.timeout;
-  *opaqueId = (void*)rep.opaqueId;
+  *opaqueId = (void*)(intptr_t)rep.opaqueId;
   return True;
 }
 
@@ -351,7 +352,7 @@
   req->reqType = codes->major_opcode;
   req->vncExtReqType = X_VncExtApproveConnect;
   req->approve = approve;
-  req->opaqueId = (CARD32)opaqueId;
+  req->opaqueId = (CARD32)(intptr_t)opaqueId;
   UnlockDisplay(dpy);
   SyncHandle();
   return True;
diff --git a/unix/vncconfig/vncExt.h b/unix/vncconfig/vncExt.h
index f1502c4..e41e2e5 100644
--- a/unix/vncconfig/vncExt.h
+++ b/unix/vncconfig/vncExt.h
@@ -54,7 +54,7 @@
 Bool XVncExtSetServerCutText(Display* dpy, const char* str, int len);
 Bool XVncExtGetClientCutText(Display* dpy, char** str, int* len);
 Bool XVncExtSelectInput(Display* dpy, Window w, int mask);
-Bool XVncExtConnect(Display* dpy, char* hostAndPort);
+Bool XVncExtConnect(Display* dpy, const char* hostAndPort);
 Bool XVncExtGetQueryConnect(Display* dpy, char** addr,
                             char** user, int* timeout, void** opaqueId);
 Bool XVncExtApproveConnect(Display* dpy, void* opaqueId, int approve);
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index ee39fae..a9b328f 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -287,6 +287,8 @@
     server->add_changed(rect);
 
     return true;
+#else
+  return false;
 #endif
   }
 
diff --git a/unix/xserver/hw/vnc/Input.c b/unix/xserver/hw/vnc/Input.c
index 7975fd6..4c90a95 100644
--- a/unix/xserver/hw/vnc/Input.c
+++ b/unix/xserver/hw/vnc/Input.c
@@ -26,6 +26,7 @@
 
 #include "Input.h"
 #include "vncExtInit.h"
+#include "RFBGlue.h"
 
 #include "inputstr.h"
 #if XORG >= 110
diff --git a/unix/xserver/hw/vnc/InputXKB.c b/unix/xserver/hw/vnc/InputXKB.c
index 8d7488a..490d6d1 100644
--- a/unix/xserver/hw/vnc/InputXKB.c
+++ b/unix/xserver/hw/vnc/InputXKB.c
@@ -626,33 +626,30 @@
                                      DeviceIntPtr dev)
 {
 	unsigned int backupctrls;
+	XkbControlsPtr ctrls;
 
-	if (event->device_event.sourceid == vncKeyboardDev->id) {
-		XkbControlsPtr ctrls;
-
-		/*
-		 * We need to bypass AccessX since it is timing sensitive and
-		 * the network can cause fake event delays.
-		 */
-		ctrls = dev->key->xkbInfo->desc->ctrls;
-		backupctrls = ctrls->enabled_ctrls;
-		ctrls->enabled_ctrls &= ~XkbAllFilteredEventsMask;
-
-		/*
-		 * This flag needs to be set for key repeats to be properly
-		 * respected.
-		 */
-		if ((event->device_event.type == ET_KeyPress) &&
-		    key_is_down(dev, event->device_event.detail.key, KEY_PROCESSED))
-			event->device_event.key_repeat = TRUE;
+	if (event->device_event.sourceid != vncKeyboardDev->id) {
+		dev->public.processInputProc(event, dev);
+		return;
 	}
 
+	/*
+	 * We need to bypass AccessX since it is timing sensitive and
+	 * the network can cause fake event delays.
+	 */
+	ctrls = dev->key->xkbInfo->desc->ctrls;
+	backupctrls = ctrls->enabled_ctrls;
+	ctrls->enabled_ctrls &= ~XkbAllFilteredEventsMask;
+
+	/*
+	 * This flag needs to be set for key repeats to be properly
+	 * respected.
+	 */
+	if ((event->device_event.type == ET_KeyPress) &&
+	    key_is_down(dev, event->device_event.detail.key, KEY_PROCESSED))
+		event->device_event.key_repeat = TRUE;
+
 	dev->public.processInputProc(event, dev);
 
-	if (event->device_event.sourceid == vncKeyboardDev->id) {
-		XkbControlsPtr ctrls;
-
-		ctrls = dev->key->xkbInfo->desc->ctrls;
-		ctrls->enabled_ctrls = backupctrls;
-	}
+	ctrls->enabled_ctrls = backupctrls;
 }
diff --git a/unix/xserver/hw/vnc/Makefile.am b/unix/xserver/hw/vnc/Makefile.am
index 8f9b0f4..d7ab259 100644
--- a/unix/xserver/hw/vnc/Makefile.am
+++ b/unix/xserver/hw/vnc/Makefile.am
@@ -31,6 +31,11 @@
 	$(top_srcdir)/Xi/stubs.c $(top_srcdir)/mi/miinitext.c \
 	$(top_srcdir)/fb/fbcmap_mi.c buildtime.c
 
+# Xvnc contains no C++ sources so automake doesn't understand that we
+# need to use the C++ compiler to link things. This is the upstream
+# recommendation for coaxing automake.
+nodist_EXTRA_Xvnc_SOURCES = dummy.cxx
+
 Xvnc_CPPFLAGS = $(XVNC_CPPFLAGS) -DTIGERVNC -DNO_MODULE_EXTS \
 	-UHAVE_CONFIG_H \
 	-DXFree86Server -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
@@ -47,6 +52,9 @@
 
 libvnc_la_SOURCES = vncModule.c
 
+# See Xvnc magic above
+nodist_EXTRA_libvnc_la_SOURCES = dummy.cxx
+
 libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I$(TIGERVNC_SRCDIR)/common -UHAVE_CONFIG_H \
 	-I$(top_srcdir)/hw/xfree86/common \
 	-I$(top_srcdir)/hw/xfree86/os-support \
@@ -54,7 +62,7 @@
 	-I$(top_srcdir)/include \
 	${XSERVERLIBS_CFLAGS} -I$(includedir)
 
-libvnc_la_LDFLAGS = -module -avoid-version
+libvnc_la_LDFLAGS = -module -avoid-version -Wl,-z,now
 
 libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS)
 
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc
index 7747d88..53d5bdb 100644
--- a/unix/xserver/hw/vnc/RFBGlue.cc
+++ b/unix/xserver/hw/vnc/RFBGlue.cc
@@ -46,7 +46,7 @@
   if (vlog == NULL)
     return;
   va_start(ap, format);
-  vlog->error(format, ap);
+  vlog->verror(format, ap);
   va_end(ap);
 }
 
@@ -58,7 +58,7 @@
   if (vlog == NULL)
     return;
   va_start(ap, format);
-  vlog->status(format, ap);
+  vlog->vstatus(format, ap);
   va_end(ap);
 }
 
@@ -70,7 +70,7 @@
   if (vlog == NULL)
     return;
   va_start(ap, format);
-  vlog->info(format, ap);
+  vlog->vinfo(format, ap);
   va_end(ap);
 }
 
@@ -82,7 +82,7 @@
   if (vlog == NULL)
     return;
   va_start(ap, format);
-  vlog->debug(format, ap);
+  vlog->vdebug(format, ap);
   va_end(ap);
 }
 
diff --git a/unix/xserver/hw/vnc/XorgGlue.c b/unix/xserver/hw/vnc/XorgGlue.c
index 630d67d..8a3a273 100644
--- a/unix/xserver/hw/vnc/XorgGlue.c
+++ b/unix/xserver/hw/vnc/XorgGlue.c
@@ -30,10 +30,6 @@
 
 #include "XorgGlue.h"
 
-#ifdef RANDR
-extern RRModePtr vncRandRModeGet(int width, int height);
-#endif
-
 const char *vncGetDisplay(void)
 {
   return display;
diff --git a/unix/xserver/hw/vnc/XorgGlue.h b/unix/xserver/hw/vnc/XorgGlue.h
index abca48d..05ca7ba 100644
--- a/unix/xserver/hw/vnc/XorgGlue.h
+++ b/unix/xserver/hw/vnc/XorgGlue.h
@@ -57,7 +57,9 @@
 void vncRandRGetOutputDimensions(int scrIdx, int outputIdx,
                                  int *x, int *y, int *width, int *height);
 
-// This one hides in xvnc.c or vncModule.c
+// These hide in xvnc.c or vncModule.c
+void vncClientGone(int fd);
+void *vncRandRModeGet(int width, int height);
 int vncRandRCreateOutputs(int scrIdx, int extraOutputs);
 
 #ifdef __cplusplus
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index b898813..54e09cb 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -46,9 +46,6 @@
 #include "XorgGlue.h"
 #include "Input.h"
 
-// Hack to catch when inetd has let us go
-extern "C" void vncClientGone(int fd);
-
 using namespace rfb;
 using namespace network;
 
diff --git a/unix/xserver/hw/vnc/vncExt.c b/unix/xserver/hw/vnc/vncExt.c
index 2330eee..2f5ff5c 100644
--- a/unix/xserver/hw/vnc/vncExt.c
+++ b/unix/xserver/hw/vnc/vncExt.c
@@ -123,6 +123,8 @@
 
 void vncClientCutText(const char* str, int len)
 {
+  xVncExtClientCutTextNotifyEvent ev;
+
   if (clientCutText != NULL)
     free(clientCutText);
   clientCutTextLen = 0;
@@ -136,7 +138,6 @@
   memcpy(clientCutText, str, len);
   clientCutTextLen = len;
 
-  xVncExtClientCutTextNotifyEvent ev;
   ev.type = vncEventBase + VncExtClientCutTextNotify;
   for (struct VncInputSelect* cur = vncInputSelectHead; cur; cur = cur->next) {
     if (cur->mask & VncExtClientCutTextMask) {
@@ -164,6 +165,7 @@
 static int ProcVncExtSetParam(ClientPtr client)
 {
   char *param;
+  xVncExtSetParamReply rep;
 
   REQUEST(xVncExtSetParamReq);
   REQUEST_FIXED_SIZE(xVncExtSetParamReq, stuff->paramLen);
@@ -174,7 +176,6 @@
   strncpy(param, (char*)&stuff[1], stuff->paramLen);
   param[stuff->paramLen] = '\0';
 
-  xVncExtSetParamReply rep;
   rep.type = X_Reply;
   rep.length = 0;
   rep.success = 0;
@@ -233,6 +234,7 @@
   char* param;
   char* value;
   size_t len;
+  xVncExtGetParamReply rep;
 
   REQUEST(xVncExtGetParamReq);
   REQUEST_FIXED_SIZE(xVncExtGetParamReq, stuff->paramLen);
@@ -248,7 +250,6 @@
 
   free(param);
 
-  xVncExtGetParamReply rep;
   rep.type = X_Reply;
   rep.sequenceNumber = client->sequence;
   rep.success = 0;
@@ -293,6 +294,7 @@
   char* param;
   const char* desc;
   size_t len;
+  xVncExtGetParamDescReply rep;
 
   REQUEST(xVncExtGetParamDescReq);
   REQUEST_FIXED_SIZE(xVncExtGetParamDescReq, stuff->paramLen);
@@ -308,7 +310,6 @@
 
   free(param);
 
-  xVncExtGetParamDescReply rep;
   rep.type = X_Reply;
   rep.sequenceNumber = client->sequence;
   rep.success = 0;
@@ -330,7 +331,7 @@
   }
   WriteToClient(client, sizeof(xVncExtGetParamDescReply), (char *)&rep);
   if (desc)
-    WriteToClient(client, len, (char*)desc);
+    WriteToClient(client, len, desc);
   return (client->noClientException);
 }
 
@@ -349,16 +350,15 @@
 
 static int ProcVncExtListParams(ClientPtr client)
 {
-  REQUEST(xVncExtListParamsReq);
-  REQUEST_SIZE_MATCH(xVncExtListParamsReq);
-
   xVncExtListParamsReply rep;
-  rep.type = X_Reply;
-  rep.sequenceNumber = client->sequence;
-
   char *params;
   size_t len;
 
+  REQUEST_SIZE_MATCH(xVncExtListParamsReq);
+
+  rep.type = X_Reply;
+  rep.sequenceNumber = client->sequence;
+
   params = vncGetParamList();
   if (params == NULL)
     return BadAlloc;
@@ -426,10 +426,10 @@
 
 static int ProcVncExtGetClientCutText(ClientPtr client)
 {
-  REQUEST(xVncExtGetClientCutTextReq);
+  xVncExtGetClientCutTextReply rep;
+
   REQUEST_SIZE_MATCH(xVncExtGetClientCutTextReq);
 
-  xVncExtGetClientCutTextReply rep;
   rep.type = X_Reply;
   rep.length = (clientCutTextLen + 3) >> 2;
   rep.sequenceNumber = client->sequence;
@@ -522,6 +522,7 @@
 static int ProcVncExtConnect(ClientPtr client)
 {
   char *address;
+  xVncExtConnectReply rep;
 
   REQUEST(xVncExtConnectReq);
   REQUEST_FIXED_SIZE(xVncExtConnectReq, stuff->strLen);
@@ -532,7 +533,6 @@
   strncpy(address, (char*)&stuff[1], stuff->strLen);
   address[stuff->strLen] = 0;
 
-  xVncExtConnectReply rep;
   rep.success = 0;
   if (vncConnectClient(address) == 0)
         rep.success = 1;
@@ -573,16 +573,16 @@
 
 static int ProcVncExtGetQueryConnect(ClientPtr client)
 {
-  REQUEST(xVncExtGetQueryConnectReq);
-  REQUEST_SIZE_MATCH(xVncExtGetQueryConnectReq);
-
   uint32_t opaqueId;
   const char *qcAddress, *qcUsername;
   int qcTimeout;
 
+  xVncExtGetQueryConnectReply rep;
+
+  REQUEST_SIZE_MATCH(xVncExtGetQueryConnectReq);
+
   vncGetQueryConnect(&opaqueId, &qcAddress, &qcUsername, &qcTimeout);
 
-  xVncExtGetQueryConnectReply rep;
   rep.type = X_Reply;
   rep.sequenceNumber = client->sequence;
   rep.timeout = qcTimeout;
@@ -610,9 +610,9 @@
   }
   WriteToClient(client, sizeof(xVncExtGetQueryConnectReply), (char *)&rep);
   if (qcTimeout)
-    WriteToClient(client, strlen(qcAddress), (char*)qcAddress);
+    WriteToClient(client, strlen(qcAddress), qcAddress);
   if (qcTimeout)
-    WriteToClient(client, strlen(qcUsername), (char*)qcUsername);
+    WriteToClient(client, strlen(qcUsername), qcUsername);
   return (client->noClientException);
 }
 
diff --git a/unix/xserver/hw/vnc/vncExtInit.h b/unix/xserver/hw/vnc/vncExtInit.h
index 6c9857c..65cbbe4 100644
--- a/unix/xserver/hw/vnc/vncExtInit.h
+++ b/unix/xserver/hw/vnc/vncExtInit.h
@@ -20,6 +20,7 @@
 #define __VNCEXTINIT_H__
 
 #include <stdint.h>
+#include <stddef.h>
 #include <sys/select.h>
 
 // Only from C++
diff --git a/unix/xserver/hw/vnc/vncModule.c b/unix/xserver/hw/vnc/vncModule.c
index 051f6b4..8cbf9c2 100644
--- a/unix/xserver/hw/vnc/vncModule.c
+++ b/unix/xserver/hw/vnc/vncModule.c
@@ -29,12 +29,16 @@
 #endif
 
 #include "xorg-version.h"
+#if XORG <= 111
+typedef pointer XF86OptionPtr;
+#endif
 
 #include "xf86.h"
 #include "xf86Module.h"
 
 #include "vncExtInit.h"
 #include "RFBGlue.h"
+#include "XorgGlue.h"
 
 static void vncModuleInit(INITARGS);
 
@@ -103,8 +107,12 @@
   vncExtensionInit();
 }
 
+void vncClientGone(int fd)
+{
+}
+
 #ifdef RANDR
-RRModePtr vncRandRModeGet(int width, int height)
+void *vncRandRModeGet(int width, int height)
 {
     return NULL;
 }
diff --git a/unix/xserver/hw/vnc/xorg-version.h b/unix/xserver/hw/vnc/xorg-version.h
index 234e250..8cc1c86 100644
--- a/unix/xserver/hw/vnc/xorg-version.h
+++ b/unix/xserver/hw/vnc/xorg-version.h
@@ -46,8 +46,10 @@
 #define XORG 115
 #elif XORG_VERSION_CURRENT < ((1 * 10000000) + (16 * 100000) + (99 * 1000))
 #define XORG 116
+#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (17 * 100000) + (99 * 1000))
+#define XORG 117
 #else
-#error "X.Org newer than 1.16 is not supported"
+#error "X.Org newer than 1.17 is not supported"
 #endif
 
 #endif
diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c
index 1f99107..6aad434 100644
--- a/unix/xserver/hw/vnc/xvnc.c
+++ b/unix/xserver/hw/vnc/xvnc.c
@@ -34,6 +34,7 @@
 
 #include "vncExtInit.h"
 #include "RFBGlue.h"
+#include "XorgGlue.h"
 #include "xorg-version.h"
 
 #ifdef WIN32
@@ -68,11 +69,15 @@
 #include <sys/shm.h>
 #endif /* HAS_SHM */
 #include "dix.h"
+#include "os.h"
 #include "miline.h"
 #include "inputstr.h"
 #ifdef RANDR
 #include "randrstr.h"
 #endif /* RANDR */
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
 #include <X11/keysym.h>
   extern char buildtime[];
 #undef VENDOR_RELEASE
@@ -80,18 +85,10 @@
 #include "version-config.h"
 #include "site.h"
 
-#if XORG >= 110
-#define Xalloc malloc
-#define Xfree free
-#endif
-
 #define XVNCVERSION "TigerVNC 1.4.80"
-#define XVNCCOPYRIGHT ("Copyright (C) 1999-2013 TigerVNC Team and many others (see README.txt)\n" \
+#define XVNCCOPYRIGHT ("Copyright (C) 1999-2015 TigerVNC Team and many others (see README.txt)\n" \
                        "See http://www.tigervnc.org for information on TigerVNC.\n")
 
-
-extern int monitorResolution;
-
 #define VFB_DEFAULT_WIDTH  1024
 #define VFB_DEFAULT_HEIGHT 768
 #define VFB_DEFAULT_DEPTH  24
@@ -207,7 +204,7 @@
     return Success;
 }
 
-Bool DPMSSupported()
+Bool DPMSSupported(void)
 {
     /* Causes DPMSCapable to return false, meaning no devices are DPMS
        capable */
@@ -266,7 +263,7 @@
 #endif
 
 void
-OsVendorInit()
+OsVendorInit(void)
 {
 }
 
@@ -279,13 +276,14 @@
 {
 }
 
+#ifdef DDXBEFORERESET
 void ddxBeforeReset(void)
 {
     return;
 }
+#endif
 
-void 
-ddxUseMsg()
+void ddxUseMsg(void)
 {
     ErrorF("\nXvnc %s - built %s\n%s", XVNCVERSION, buildtime, XVNCCOPYRIGHT);
     ErrorF("Underlying X server release %d, %s\n\n", VENDOR_RELEASE,
@@ -323,11 +321,6 @@
     vncListParams(79, 14);
 }
 
-/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
-void ddxInitGlobals(void)
-{
-}
-
 static 
 Bool displayNumFree(int num)
 {
@@ -346,6 +339,13 @@
     return TRUE;
 }
 
+#define fail_unless_args(_argc,_i,_n)		\
+    if (_i + _n >= _argc)			\
+    {						\
+        UseMsg();				\
+        return 0;				\
+    }
+
 int 
 ddxProcessArgument(int argc, char *argv[], int i)
 {
@@ -365,12 +365,13 @@
     if (strcmp (argv[i], "-screen") == 0)	/* -screen n WxHxD */
     {
 	int screenNum;
-	if (i + 2 >= argc) UseMsg();
+	fail_unless_args(argc, i, 2);
 	screenNum = atoi(argv[i+1]);
 	if (screenNum < 0 || screenNum >= MAXSCREENS)
 	{
 	    ErrorF("Invalid screen number %d\n", screenNum);
 	    UseMsg();
+	    return 0;
 	}
 	if (3 != sscanf(argv[i+2], "%dx%dx%d",
 			&vfbScreens[screenNum].fb.width,
@@ -379,6 +380,7 @@
 	{
 	    ErrorF("Invalid screen configuration %s\n", argv[i+2]);
 	    UseMsg();
+	    return 0;
 	}
 
 	if (screenNum >= vfbNumScreens)
@@ -391,13 +393,15 @@
     {
 	int depth, ret = 1;
 
-	if (++i >= argc) UseMsg();
+	fail_unless_args(argc, i, 1);
+	++i;
 	while ((i < argc) && (depth = atoi(argv[i++])) != 0)
 	{
 	    if (depth < 0 || depth > 32)
 	    {
 		ErrorF("Invalid pixmap depth %d\n", depth);
 		UseMsg();
+		return 0;
 	    }
 	    vfbPixmapDepths[depth] = TRUE;
 	    ret++;
@@ -420,14 +424,15 @@
     if (strcmp (argv[i], "-blackpixel") == 0)	/* -blackpixel n */
     {
 	Pixel pix;
-	if (++i >= argc) UseMsg();
+	fail_unless_args(argc, i, 1);
+	++i;
 	pix = atoi(argv[i]);
 	if (-1 == lastScreen)
 	{
-	    int i;
-	    for (i = 0; i < MAXSCREENS; i++)
+	    int j;
+	    for (j = 0; j < MAXSCREENS; j++)
 	    {
-		vfbScreens[i].blackPixel = pix;
+		vfbScreens[j].blackPixel = pix;
 	    }
 	}
 	else
@@ -440,14 +445,15 @@
     if (strcmp (argv[i], "-whitepixel") == 0)	/* -whitepixel n */
     {
 	Pixel pix;
-	if (++i >= argc) UseMsg();
+	fail_unless_args(argc, i, 1);
+	++i;
 	pix = atoi(argv[i]);
 	if (-1 == lastScreen)
 	{
-	    int i;
-	    for (i = 0; i < MAXSCREENS; i++)
+	    int j;
+	    for (j = 0; j < MAXSCREENS; j++)
 	    {
-		vfbScreens[i].whitePixel = pix;
+		vfbScreens[j].whitePixel = pix;
 	    }
 	}
 	else
@@ -460,14 +466,15 @@
     if (strcmp (argv[i], "-linebias") == 0)	/* -linebias n */
     {
 	unsigned int linebias;
-	if (++i >= argc) UseMsg();
+	fail_unless_args(argc, i, 1);
+	++i;
 	linebias = atoi(argv[i]);
 	if (-1 == lastScreen)
 	{
-	    int i;
-	    for (i = 0; i < MAXSCREENS; i++)
+	    int j;
+	    for (j = 0; j < MAXSCREENS; j++)
 	    {
-		vfbScreens[i].lineBias = linebias;
+		vfbScreens[j].lineBias = linebias;
 	    }
 	}
 	else
@@ -487,18 +494,21 @@
     
     if (strcmp(argv[i], "-geometry") == 0)
     {
-	if (++i >= argc) UseMsg();
+	fail_unless_args(argc, i, 1);
+	++i;
 	if (sscanf(argv[i],"%dx%d",&vfbScreens[0].fb.width,
 		   &vfbScreens[0].fb.height) != 2) {
 	    ErrorF("Invalid geometry %s\n", argv[i]);
 	    UseMsg();
+	    return 0;
 	}
 	return 2;
     }
     
     if (strcmp(argv[i], "-depth") == 0)
     {
-	if (++i >= argc) UseMsg();
+	fail_unless_args(argc, i, 1);
+	++i;
 	vfbScreens[0].fb.depth = atoi(argv[i]);
 	return 2;
     }
@@ -507,10 +517,12 @@
     {
 	char rgbbgr[4];
 	int bits1, bits2, bits3;
-	if (++i >= argc) UseMsg();
+	fail_unless_args(argc, i, 1);
+	++i;
 	if (sscanf(argv[i], "%3s%1d%1d%1d", rgbbgr,&bits1,&bits2,&bits3) < 4) {
 	    ErrorF("Invalid pixel format %s\n", argv[i]);
 	    UseMsg();
+	    return 0;
 	}
 
 #define SET_PIXEL_FORMAT(vfbScreen)                     \
@@ -528,14 +540,15 @@
     } else {                                            \
         ErrorF("Invalid pixel format %s\n", argv[i]);   \
         UseMsg();                                       \
+        return 0;					\
     }
 
 	if (-1 == lastScreen)
 	{
-	    int i;
-	    for (i = 0; i < MAXSCREENS; i++)
+	    int j;
+	    for (j = 0; j < MAXSCREENS; j++)
 	    {
-		SET_PIXEL_FORMAT(vfbScreens[i]);
+		SET_PIXEL_FORMAT(vfbScreens[j]);
 	    }
 	}
 	else
@@ -679,9 +692,11 @@
 	entries = pmap->pVisual->ColormapEntries;
 	pVisual = pmap->pVisual;
 
-	ppix = (Pixel *)xalloc(entries * sizeof(Pixel));
-	prgb = (xrgb *)xalloc(entries * sizeof(xrgb));
-	defs = (xColorItem *)xalloc(entries * sizeof(xColorItem));
+	ppix = (Pixel *)calloc(entries, sizeof(Pixel));
+	prgb = (xrgb *)calloc(entries, sizeof(xrgb));
+	defs = (xColorItem *)calloc(entries, sizeof(xColorItem));
+	if (!ppix || !prgb || !defs)
+	  FatalError ("Not enough memory for color map\n");
 
 	for (i = 0; i < entries; i++)  ppix[i] = i;
 	/* XXX truecolor */
@@ -700,9 +715,9 @@
 	}
 	(*pmap->pScreen->StoreColors)(pmap, entries, defs);
 	
-	xfree(ppix);
-	xfree(prgb);
-	xfree(defs);
+	free(ppix);
+	free(prgb);
+	free(defs);
     }
 }
 
@@ -786,7 +801,7 @@
         break;
 #endif
     case NORMAL_MEMORY_FB:
-        pfb->pfbMemory = Xalloc(pfb->sizeInBytes);
+        pfb->pfbMemory = malloc(pfb->sizeInBytes);
         break;
     }
 
@@ -813,7 +828,7 @@
         break;
 #endif /* HAS_SHM */
     case NORMAL_MEMORY_FB:
-        Xfree(pfb->pfbMemory);
+        free(pfb->pfbMemory);
         break;
     }
 
@@ -1037,7 +1052,6 @@
     FlushAllOutput ();
 }
 
-RRModePtr vncRandRModeGet(int width, int height);
 static Bool vncRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode,
                             int x, int y, Rotation rotation, int num_outputs,
                             RROutputPtr *outputs);
@@ -1214,8 +1228,8 @@
 
 static int vncRandRIndex = 0;
 
-/* This is a global symbol since XserverDesktop also uses it */
-RRModePtr vncRandRModeGet(int width, int height)
+/* This is a global symbol since findRandRMode() also uses it */
+void *vncRandRModeGet(int width, int height)
 {
     xRRModeInfo	modeInfo;
     char name[100];
@@ -1244,6 +1258,9 @@
     RRModePtr mode;
     char name[100];
 
+    RRModePtr *modes;
+    int i, num_modes;
+
     /* First we create the CRTC... */
     crtc = RRCrtcCreate(pScreen, NULL);
 
@@ -1263,11 +1280,12 @@
     vncRandRCrtcSet(pScreen, crtc, NULL, 0, 0, RR_Rotate_0, 1, &output);
 
     /* Populate a list of default modes */
-    RRModePtr modes[sizeof(vncRandRWidths)/sizeof(*vncRandRWidths)];
-    int num_modes;
+    modes = malloc(sizeof(RRModePtr)*sizeof(vncRandRWidths)/sizeof(*vncRandRWidths));
+    if (modes == NULL)
+        return NULL;
 
     num_modes = 0;
-    for (int i = 0;i < sizeof(vncRandRWidths)/sizeof(*vncRandRWidths);i++) {
+    for (i = 0;i < sizeof(vncRandRWidths)/sizeof(*vncRandRWidths);i++) {
         mode = vncRandRModeGet(vncRandRWidths[i], vncRandRHeights[i]);
         if (mode != NULL) {
             modes[num_modes] = mode;
@@ -1277,6 +1295,8 @@
 
     RROutputSetModes(output, modes, num_modes, 0);
 
+    free(modes);
+
     return crtc;
 }
 
@@ -1385,6 +1405,10 @@
     int ret;
     void *pbits;
 
+#ifdef RANDR
+    rrScrPrivPtr rp;
+#endif
+
 #if XORG >= 113
     if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
 	return FALSE;
@@ -1519,8 +1543,6 @@
     pScreen->CloseScreen = vfbCloseScreen;
 
 #ifdef RANDR
-    rrScrPrivPtr rp;
-
     ret = RRScreenInit(pScreen);
     if (!ret) return FALSE;
 
@@ -1560,7 +1582,7 @@
 #endif
 
 void
-InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
+InitOutput(ScreenInfo *scrInfo, int argc, char **argv)
 {
     int i;
     int NumFormats = 0;
@@ -1605,18 +1627,18 @@
 	{
 	    if (NumFormats >= MAXFORMATS)
 		FatalError ("MAXFORMATS is too small for this server\n");
-	    screenInfo->formats[NumFormats].depth = i;
-	    screenInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i);
-	    screenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
+	    scrInfo->formats[NumFormats].depth = i;
+	    scrInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i);
+	    scrInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
 	    NumFormats++;
 	}
     }
 
-    screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
-    screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
-    screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
-    screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
-    screenInfo->numPixmapFormats = NumFormats;
+    scrInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+    scrInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+    scrInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+    scrInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+    scrInfo->numPixmapFormats = NumFormats;
 
     /* initialize screens */
 
@@ -1649,7 +1671,7 @@
   return TRUE;
 }
 
-void ProcessInputEvents()
+void ProcessInputEvents(void)
 {
   mieqProcessInputEvents();
 }
diff --git a/unix/xserver117.patch b/unix/xserver117.patch
new file mode 100644
index 0000000..8a21040
--- /dev/null
+++ b/unix/xserver117.patch
@@ -0,0 +1,137 @@
+diff -up xorg-server-1.17.1/configure.ac.vnc xorg-server-1.17.1/configure.ac
+--- xorg-server-1.17.1/configure.ac.vnc	2015-02-10 22:43:52.000000000 +0000
++++ xorg-server-1.17.1/configure.ac	2015-02-13 16:14:05.074515927 +0000
+@@ -74,6 +74,7 @@ dnl forcing an entire recompile.x
+ AC_CONFIG_HEADERS(include/version-config.h)
+ 
+ AM_PROG_AS
++AC_PROG_CXX
+ AC_PROG_LN_S
+ LT_PREREQ([2.2])
+ LT_INIT([disable-static win32-dll])
+@@ -1795,6 +1796,10 @@ if test "x$XVFB" = xyes; then
+ 	AC_SUBST([XVFB_SYS_LIBS])
+ fi
+ 
++dnl Xvnc DDX
++AC_SUBST([XVNC_CPPFLAGS], ["-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"])
++AC_SUBST([XVNC_LIBS], ["$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB"])
++AC_SUBST([XVNC_SYS_LIBS], ["$GLX_SYS_LIBS"])
+ 
+ dnl Xnest DDX
+ 
+@@ -1830,6 +1835,8 @@ if test "x$XORG" = xauto; then
+ fi
+ AC_MSG_RESULT([$XORG])
+ 
++AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
++
+ if test "x$XORG" = xyes; then
+ 	XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
+ 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
+@@ -2059,7 +2066,6 @@ if test "x$XORG" = xyes; then
+ 	AC_DEFINE(XORG_SERVER, 1, [Building Xorg server])
+ 	AC_DEFINE(XORGSERVER, 1, [Building Xorg server])
+ 	AC_DEFINE(XFree86Server, 1, [Building XFree86 server])
+-	AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
+ 	AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
+ 	AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
+ 	AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
+@@ -2599,6 +2605,7 @@ hw/dmx/Makefile
+ hw/dmx/man/Makefile
+ hw/vfb/Makefile
+ hw/vfb/man/Makefile
++hw/vnc/Makefile
+ hw/xnest/Makefile
+ hw/xnest/man/Makefile
+ hw/xwin/Makefile
+diff -up xorg-server-1.17.1/hw/Makefile.am.vnc xorg-server-1.17.1/hw/Makefile.am
+--- xorg-server-1.17.1/hw/Makefile.am.vnc	2014-04-16 21:24:00.000000000 +0100
++++ xorg-server-1.17.1/hw/Makefile.am	2015-02-13 16:14:05.131516821 +0000
+@@ -38,7 +38,8 @@ SUBDIRS =			\
+ 	$(DMX_SUBDIRS)		\
+ 	$(KDRIVE_SUBDIRS)	\
+ 	$(XQUARTZ_SUBDIRS)	\
+-	$(XWAYLAND_SUBDIRS)
++	$(XWAYLAND_SUBDIRS)	\
++	vnc
+ 
+ DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xwayland
+ 
+diff -up xorg-server-1.17.1/mi/miinitext.c.vnc xorg-server-1.17.1/mi/miinitext.c
+--- xorg-server-1.17.1/mi/miinitext.c.vnc	2015-01-17 23:42:52.000000000 +0000
++++ xorg-server-1.17.1/mi/miinitext.c	2015-02-13 16:14:05.131516821 +0000
+@@ -111,6 +111,10 @@ SOFTWARE.
+ #include "micmap.h"
+ #include "globals.h"
+ 
++#ifdef TIGERVNC
++extern void vncExtensionInit(INITARGS);
++#endif
++
+ /* The following is only a small first step towards run-time
+  * configurable extensions.
+  */
+@@ -235,6 +239,9 @@ EnableDisableExtensionError(const char *
+ 
+ /* List of built-in (statically linked) extensions */
+ static const ExtensionModule staticExtensions[] = {
++#ifdef TIGERVNC
++    {vncExtensionInit, "VNC-EXTENSION", NULL},
++#endif
+     {GEExtensionInit, "Generic Event Extension", &noGEExtension},
+     {ShapeExtensionInit, "SHAPE", NULL},
+ #ifdef MITSHM
+diff -up xorg-server-1.17.1/os/WaitFor.c.vnc xorg-server-1.17.1/os/WaitFor.c
+--- xorg-server-1.17.1/os/WaitFor.c.vnc	2015-01-26 18:40:30.000000000 +0000
++++ xorg-server-1.17.1/os/WaitFor.c	2015-02-13 16:14:05.132516837 +0000
+@@ -125,6 +125,9 @@ static void DoTimer(OsTimerPtr timer, CA
+ static void CheckAllTimers(void);
+ static volatile OsTimerPtr timers = NULL;
+ 
++extern void vncWriteBlockHandler(fd_set *fds);
++extern void vncWriteWakeupHandler(int nfds, fd_set *fds);
++
+ /*****************
+  * WaitForSomething:
+  *     Make the server suspend until there is
+@@ -150,6 +153,7 @@ WaitForSomething(int *pClientsReady)
+     INT32 timeout = 0;
+     fd_set clientsReadable;
+     fd_set clientsWritable;
++    fd_set socketsWritable;
+     int curclient;
+     int selecterr;
+     static int nready;
+@@ -212,6 +216,9 @@ WaitForSomething(int *pClientsReady)
+             XFD_COPYSET(&AllSockets, &LastSelectMask);
+         }
+ 
++        FD_ZERO(&socketsWritable);
++        vncWriteBlockHandler(&socketsWritable);
++
+         BlockHandler((void *) &wt, (void *) &LastSelectMask);
+         if (NewOutputPending)
+             FlushAllOutput();
+@@ -223,10 +230,20 @@ WaitForSomething(int *pClientsReady)
+             i = Select(MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
+         }
+         else {
+-            i = Select(MaxClients, &LastSelectMask, NULL, NULL, wt);
++	    if (AnyClientsWriteBlocked)
++		XFD_ORSET(&socketsWritable, &ClientsWriteBlocked, &socketsWritable);
++
++	    if (XFD_ANYSET(&socketsWritable)) {
++		i = Select(MaxClients, &LastSelectMask, &socketsWritable, NULL, wt);
++		if (AnyClientsWriteBlocked)
++		    XFD_ANDSET(&clientsWritable, &socketsWritable, &ClientsWriteBlocked);
++	    } else {
++		i = Select(MaxClients, &LastSelectMask, NULL, NULL, wt);
++	    }
+         }
+         selecterr = GetErrno();
+         WakeupHandler(i, (void *) &LastSelectMask);
++	vncWriteWakeupHandler(i, &socketsWritable);
+         if (i <= 0) {           /* An error or timeout occurred */
+             if (dispatchException)
+                 return 0;
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx
index cf4f31b..f8b45af 100644
--- a/vncviewer/CConn.cxx
+++ b/vncviewer/CConn.cxx
@@ -134,7 +134,7 @@
 {
   OptionsDialog::removeCallback(handleOptions);
 
-  for (int i = 0; i < sizeof(decoders)/sizeof(decoders[0]); i++)
+  for (size_t i = 0; i < sizeof(decoders)/sizeof(decoders[0]); i++)
     delete decoders[i];
 
   if (desktop)
@@ -313,8 +313,8 @@
 }
 
 // setExtendedDesktopSize() is a more advanced version of setDesktopSize()
-void CConn::setExtendedDesktopSize(int reason, int result, int w, int h,
-                                   const rfb::ScreenSet& layout)
+void CConn::setExtendedDesktopSize(unsigned reason, unsigned result,
+                                   int w, int h, const rfb::ScreenSet& layout)
 {
   CConnection::setExtendedDesktopSize(reason, result, w, h, layout);
 
@@ -411,7 +411,7 @@
   ret = fl_utf8froma(buffer, size, str, len);
   assert(ret < size);
 
-  vlog.debug("Got clipboard data (%d bytes)", strlen(buffer));
+  vlog.debug("Got clipboard data (%d bytes)", (int)strlen(buffer));
 
   // RFB doesn't have separate selection and clipboard concepts, so we
   // dump the data into both variants.
diff --git a/vncviewer/CConn.h b/vncviewer/CConn.h
index 709ca2f..1b92937 100644
--- a/vncviewer/CConn.h
+++ b/vncviewer/CConn.h
@@ -51,8 +51,8 @@
   void serverInit();
 
   void setDesktopSize(int w, int h);
-  void setExtendedDesktopSize(int reason, int result, int w, int h,
-                              const rfb::ScreenSet& layout);
+  void setExtendedDesktopSize(unsigned reason, unsigned result,
+                              int w, int h, const rfb::ScreenSet& layout);
 
   void setName(const char* name);
 
diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx
index 5adf78d..3c8fcb4 100644
--- a/vncviewer/OptionsDialog.cxx
+++ b/vncviewer/OptionsDialog.cxx
@@ -414,7 +414,7 @@
 
   int orig_tx, orig_ty;
   int half_width, full_width;
-  int width, height;
+  int height;
 
   tx += OUTER_MARGIN;
   ty += OUTER_MARGIN;
@@ -446,8 +446,6 @@
     tx += GROUP_MARGIN;
     ty += GROUP_MARGIN;
 
-    width = encodingGroup->w() - GROUP_MARGIN * 2;
-
     tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty,
                                                RADIO_MIN_WIDTH,
                                                RADIO_HEIGHT,
@@ -496,8 +494,6 @@
     tx += GROUP_MARGIN;
     ty += GROUP_MARGIN;
 
-    width = colorlevelGroup->w() - GROUP_MARGIN * 2;
-
     fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty,
                                                      RADIO_MIN_WIDTH,
                                                      RADIO_HEIGHT,
@@ -716,9 +712,9 @@
 
   menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
 
-  menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
+  fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
   for (int i = 0; i < getMenuKeySymbolCount(); i++)
-    menuKeyChoice->add(getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
+    fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
 
   ty += CHOICE_HEIGHT + TIGHT_MARGIN;
 
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index c81f7a6..3d0d688 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -104,7 +104,7 @@
 Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_)
   : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(NULL),
     lastPointerPos(0, 0), lastButtonMask(0),
-    cursor(NULL), menuCtrlKey(false), menuAltKey(false)
+    menuCtrlKey(false), menuAltKey(false), cursor(NULL)
 {
   Fl::add_clipboard_notify(handleClipboardChange, this);
 
@@ -338,7 +338,7 @@
                      Fl::event_length() + 1);
     assert(ret < (Fl::event_length() + 1));
 
-    vlog.debug("Sending clipboard data (%d bytes)", strlen(buffer));
+    vlog.debug("Sending clipboard data (%d bytes)", (int)strlen(buffer));
 
     try {
       cc->writer()->clientCutText(buffer, ret);
@@ -758,11 +758,9 @@
     // For the first few years, there wasn't a good consensus on what the
     // Windows keys should be mapped to for X11. So we need to help out a
     // bit and map all variants to the same key...
-    case XK_Meta_L:
     case XK_Hyper_L:
       keysym = XK_Super_L;
       break;
-    case XK_Meta_R:
     case XK_Hyper_R:
       keysym = XK_Super_R;
       break;
@@ -788,35 +786,44 @@
 {
   contextMenu->clear();
 
-  contextMenu->add(_("Exit viewer"), 0, NULL, (void*)ID_EXIT, FL_MENU_DIVIDER);
+  fltk_menu_add(contextMenu, _("E&xit viewer"), 0, NULL,
+                (void*)ID_EXIT, FL_MENU_DIVIDER);
 
-  contextMenu->add(_("Full screen"), 0, NULL, (void*)ID_FULLSCREEN, 
-		   FL_MENU_TOGGLE | (window()->fullscreen_active()?FL_MENU_VALUE:0));
-  contextMenu->add(_("Resize window to session"), 0, NULL, (void*)ID_RESIZE, 
-       (window()->fullscreen_active()?FL_MENU_INACTIVE:0) |
-		   FL_MENU_DIVIDER);
+  fltk_menu_add(contextMenu, _("&Full screen"), 0, NULL, (void*)ID_FULLSCREEN,
+                FL_MENU_TOGGLE | (window()->fullscreen_active()?FL_MENU_VALUE:0));
+  fltk_menu_add(contextMenu, _("Resize &window to session"), 0, NULL,
+                (void*)ID_RESIZE,
+                (window()->fullscreen_active()?FL_MENU_INACTIVE:0) |
+                FL_MENU_DIVIDER);
 
-  contextMenu->add(_("Ctrl"), 0, NULL, (void*)ID_CTRL, 
-		   FL_MENU_TOGGLE | (menuCtrlKey?FL_MENU_VALUE:0));
-  contextMenu->add(_("Alt"), 0, NULL, (void*)ID_ALT,
-		   FL_MENU_TOGGLE | (menuAltKey?FL_MENU_VALUE:0));
+  fltk_menu_add(contextMenu, _("&Ctrl"), 0, NULL, (void*)ID_CTRL,
+                FL_MENU_TOGGLE | (menuCtrlKey?FL_MENU_VALUE:0));
+  fltk_menu_add(contextMenu, _("&Alt"), 0, NULL, (void*)ID_ALT,
+                FL_MENU_TOGGLE | (menuAltKey?FL_MENU_VALUE:0));
 
   if (menuKeySym) {
     char sendMenuKey[64];
     snprintf(sendMenuKey, 64, _("Send %s"), (const char *)menuKey);
-    contextMenu->add(sendMenuKey, 0, NULL, (void*)ID_MENUKEY, 0);
-    contextMenu->add("Secret shortcut menu key", menuKeyCode, NULL, (void*)ID_MENUKEY, FL_MENU_INVISIBLE);
+    fltk_menu_add(contextMenu, sendMenuKey, 0, NULL, (void*)ID_MENUKEY, 0);
+    fltk_menu_add(contextMenu, "Secret shortcut menu key", menuKeyCode, NULL,
+                  (void*)ID_MENUKEY, FL_MENU_INVISIBLE);
   }
 
-  contextMenu->add(_("Send Ctrl-Alt-Del"), 0, NULL, (void*)ID_CTRLALTDEL, FL_MENU_DIVIDER);
+  fltk_menu_add(contextMenu, _("Send Ctrl-Alt-&Del"), 0, NULL,
+                (void*)ID_CTRLALTDEL, FL_MENU_DIVIDER);
 
-  contextMenu->add(_("Refresh screen"), 0, NULL, (void*)ID_REFRESH, FL_MENU_DIVIDER);
+  fltk_menu_add(contextMenu, _("&Refresh screen"), 0, NULL,
+                (void*)ID_REFRESH, FL_MENU_DIVIDER);
 
-  contextMenu->add(_("Options..."), 0, NULL, (void*)ID_OPTIONS, 0);
-  contextMenu->add(_("Connection info..."), 0, NULL, (void*)ID_INFO, 0);
-  contextMenu->add(_("About TigerVNC viewer..."), 0, NULL, (void*)ID_ABOUT, FL_MENU_DIVIDER);
+  fltk_menu_add(contextMenu, _("&Options..."), 0, NULL,
+                (void*)ID_OPTIONS, 0);
+  fltk_menu_add(contextMenu, _("Connection &info..."), 0, NULL,
+                (void*)ID_INFO, 0);
+  fltk_menu_add(contextMenu, _("About &TigerVNC viewer..."), 0, NULL,
+                (void*)ID_ABOUT, FL_MENU_DIVIDER);
 
-  contextMenu->add(_("Dismiss menu"), 0, NULL, (void*)ID_DISMISS, 0);
+  fltk_menu_add(contextMenu, _("Dismiss &menu"), 0, NULL,
+                (void*)ID_DISMISS, 0);
 }
 
 
diff --git a/vncviewer/X11PixelBuffer.cxx b/vncviewer/X11PixelBuffer.cxx
index 7e89a60..9196fdc 100644
--- a/vncviewer/X11PixelBuffer.cxx
+++ b/vncviewer/X11PixelBuffer.cxx
@@ -157,7 +157,6 @@
   int major, minor;
   Bool pixmaps;
   XErrorHandler old_handler;
-  Status status;
   const char *display_name = XDisplayName (NULL);
 
   /* Don't use MIT-SHM on remote displays */
diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm
index 5869d5b..3919cb8 100644
--- a/vncviewer/cocoa.mm
+++ b/vncviewer/cocoa.mm
@@ -57,7 +57,7 @@
       if (CGGetActiveDisplayList(16, displays, &count) != kCGErrorSuccess)
         return 1;
 
-      if (count != Fl::screen_count())
+      if (count != (unsigned)Fl::screen_count())
         return 1;
 
       index = Fl::screen_num(win->x(), win->y(), win->w(), win->h());
@@ -197,7 +197,7 @@
 
   layout = NULL;
 
-#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) || defined(__x86_64__)
   TISInputSourceRef keyboard;
   CFDataRef uchr;
 
@@ -418,7 +418,7 @@
   NSEvent *nsevent;
 
   UInt16 key_code;
-  int i;
+  size_t i;
 
   NSString *chars;
   UInt32 modifiers;
diff --git a/vncviewer/fltk_layout.h b/vncviewer/fltk_layout.h
index c16a359..9e5c2d4 100644
--- a/vncviewer/fltk_layout.h
+++ b/vncviewer/fltk_layout.h
@@ -20,6 +20,7 @@
 #define __FLTK_LAYOUT_H__
 
 #include <FL/fl_draw.H>
+#include <FL/Fl_Menu_.H>
 
 /* Calculates the width of a string as printed by FLTK (pixels) */
 static inline int gui_str_len(const char *str)
@@ -34,9 +35,9 @@
 }
 
 /* Escapes all @ in text as those have special meaning in labels */
-static inline int fltk_escape(const char *in, char *out, size_t maxlen)
+static inline size_t fltk_escape(const char *in, char *out, size_t maxlen)
 {
-    int len;
+    size_t len;
 
     len = 0;
 
@@ -67,6 +68,53 @@
     return len;
 }
 
+/* Filter out unsafe characters for menu entries */
+static inline size_t fltk_menu_escape(const char *in, char *out, size_t maxlen)
+{
+    size_t len;
+
+    len = 0;
+
+    while (*in != '\0') {
+        if (*in == '/') {
+            if (maxlen >= 3) {
+                *out++ = '\\';
+                *out++ = '/';
+                maxlen -= 2;
+            }
+
+            len += 2;
+        } else {
+            if (maxlen >= 2) {
+                *out++ = *in;
+                maxlen--;
+            }
+
+            len += 1;
+        }
+
+        in++;
+    }
+
+    if (maxlen)
+        *out = '\0';
+
+    return len;
+}
+
+/* Helper to add menu entries safely */
+static inline void fltk_menu_add(Fl_Menu_ *menu, const char *text,
+                                 int shortcut, Fl_Callback *cb,
+                                 void *data = 0, int flags = 0)
+{
+    char buffer[1024];
+
+    if (fltk_menu_escape(text, buffer, sizeof(buffer)) >= sizeof(buffer))
+        return;
+
+    menu->add(buffer, shortcut, cb, data, flags);
+}
+
 /**** MARGINS ****/
 
 #define OUTER_MARGIN            10
diff --git a/vncviewer/keysym2ucs.c b/vncviewer/keysym2ucs.c
index d91df67..33a5653 100644
--- a/vncviewer/keysym2ucs.c
+++ b/vncviewer/keysym2ucs.c
@@ -899,7 +899,6 @@
 {
   int cur = 0;
   int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
-  int mid;
 
   /* first check for Latin-1 characters (1:1 mapping) */
   if ((ucs >= 0x0020 && ucs <= 0x007e) ||
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index ba8b181..bf39010 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -174,8 +174,8 @@
 static struct {
   const char first;
   const char second;
-} replaceMap[] = {'\n', 'n',
-                  '\r', 'r'};
+} replaceMap[] = { { '\n', 'n' },
+                   { '\r', 'r' } };
 
 static bool encodeValue(const char* val, char* dest, size_t destSize) {
 
@@ -194,7 +194,7 @@
 
     } else {
 
-      for (int j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) {
+      for (size_t j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) {
 
         if (val[i] == replaceMap[j].first) {
           dest[pos] = '\\';
@@ -234,7 +234,7 @@
     // Check for escape sequences
     if (val[i] == '\\') {
       
-      for (int j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) {
+      for (size_t j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) {
         if (val[i+1] == replaceMap[j].second) {
           dest[pos] = replaceMap[j].first;
           escapedCharacter = true;
@@ -295,7 +295,7 @@
 
   LONG res = RegSetValueExW(*hKey, name, 0, REG_SZ, (BYTE*)&value, (wcslen(value)+1)*2);
   if (res != ERROR_SUCCESS) {
-    vlog.error(_("Failed to write parameter %s of type %s to the registry: %d"),
+    vlog.error(_("Failed to write parameter %s of type %s to the registry: %ld"),
                _name, "REG_SZ", res);
     return;
   }
@@ -316,7 +316,7 @@
   
   LONG res = RegSetValueExW(*hKey, name, 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD));
   if (res != ERROR_SUCCESS) {
-    vlog.error(_("Failed to write parameter %s of type %s to the registry: %d"),
+    vlog.error(_("Failed to write parameter %s of type %s to the registry: %ld"),
                _name, "REG_DWORD", res);
     return;
   }
@@ -340,7 +340,7 @@
     if (res == ERROR_FILE_NOT_FOUND) {
       // The value does not exist, defaults will be used.
     } else {
-      vlog.error(_("Failed to read parameter %s from the registry: %d"),
+      vlog.error(_("Failed to read parameter %s from the registry: %ld"),
                  _name, res);
     }
     return false;
@@ -379,7 +379,7 @@
     if (res == ERROR_FILE_NOT_FOUND) {
       // The value does not exist, defaults will be used.
     } else {
-      vlog.error(_("Failed to read parameter %s from the registry: %d"),
+      vlog.error(_("Failed to read parameter %s from the registry: %ld"),
                  _name, res);
     }
     return false;
@@ -399,13 +399,13 @@
                              REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
                              &hKey, NULL);
   if (res != ERROR_SUCCESS) {
-    vlog.error(_("Failed to create registry key: %d"), res);
+    vlog.error(_("Failed to create registry key: %ld"), res);
     return;
   }
 
   setKeyString("ServerName", servername, &hKey);
 
-  for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
+  for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
     if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
       setKeyString(parameterArray[i]->getName(), *(StringParameter*)parameterArray[i], &hKey);
     } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != NULL) {
@@ -420,7 +420,7 @@
 
   res = RegCloseKey(hKey);
   if (res != ERROR_SUCCESS) {
-    vlog.error(_("Failed to close registry key: %d"), res);
+    vlog.error(_("Failed to close registry key: %ld"), res);
   }
 }
 
@@ -436,7 +436,7 @@
     if (res == ERROR_FILE_NOT_FOUND) {
       // The key does not exist, defaults will be used.
     } else {
-      vlog.error(_("Failed to open registry key: %d"), res);
+      vlog.error(_("Failed to open registry key: %ld"), res);
     }
     return NULL;
   }
@@ -451,7 +451,7 @@
   int intValue = 0;
   char stringValue[buffersize];
   
-  for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
+  for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
     if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
       if (getKeyString(parameterArray[i]->getName(), stringValue, buffersize, &hKey))
         parameterArray[i]->setParam(stringValue);
@@ -469,7 +469,7 @@
 
   res = RegCloseKey(hKey);
   if (res != ERROR_SUCCESS){
-    vlog.error(_("Failed to close registry key: %d"), res);
+    vlog.error(_("Failed to close registry key: %ld"), res);
   }
   
   return servername;
@@ -481,7 +481,6 @@
 
   const size_t buffersize = 256;
   char filepath[PATH_MAX];
-  char write_error[buffersize*2];
   char encodingBuffer[buffersize];
 
   // Write to the registry or a predefined file if no filename was specified.
@@ -506,12 +505,9 @@
 
   /* Write parameters to file */
   FILE* f = fopen(filepath, "w+");
-  if (!f) {
-    snprintf(write_error, sizeof(write_error),
-             _("Failed to write configuration file, can't open %s: %s"),
-             filepath, strerror(errno));
-    throw Exception(write_error);
-  }
+  if (!f)
+    throw Exception(_("Failed to write configuration file, can't open %s: %s"),
+                    filepath, strerror(errno));
   
   fprintf(f, "%s\r\n", IDENTIFIER_STRING);
   fprintf(f, "\r\n");
@@ -519,7 +515,7 @@
   if (encodeValue(servername, encodingBuffer, buffersize))  
     fprintf(f, "ServerName=%s\n", encodingBuffer);
   
-  for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
+  for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
     if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
       if (encodeValue(*(StringParameter*)parameterArray[i], encodingBuffer, buffersize))
         fprintf(f, "%s=%s\n", ((StringParameter*)parameterArray[i])->getName(), encodingBuffer);
@@ -540,10 +536,8 @@
 
   const size_t buffersize = 256;
   char filepath[PATH_MAX];
-  char readError[buffersize*2];
   char line[buffersize];
   char decodingBuffer[buffersize];
-  char decodedValue[buffersize];
   static char servername[sizeof(line)];
 
   // Load from the registry or a predefined file if no filename was specified.
@@ -568,10 +562,8 @@
   if (!f) {
     if (!filename)
       return NULL; // Use defaults.
-    snprintf(readError, sizeof(readError),
-             _("Failed to read configuration file, can't open %s: %s"),
-             filepath, strerror(errno));
-    throw Exception(readError);
+    throw Exception(_("Failed to read configuration file, can't open %s: %s"),
+                    filepath, strerror(errno));
   }
   
   int lineNr = 0;
@@ -580,31 +572,24 @@
     // Read the next line
     lineNr++;
     if (!fgets(line, sizeof(line), f)) {
-      if (line[sizeof(line) -1] != '\0') {
-        snprintf(readError, sizeof(readError),
-                 _("Failed to read line %d in file %s: %s"),
-                 lineNr, filepath, _("Line too long"));
-        throw Exception(readError);
-      }
       if (feof(f))
         break;
 
-      snprintf(readError, sizeof(readError),
-               _("Failed to read line %d in file %s: %s"),
-               lineNr, filepath, strerror(errno));
-      throw Exception(readError);
+      throw Exception(_("Failed to read line %d in file %s: %s"),
+                      lineNr, filepath, strerror(errno));
     }
+
+    if (strlen(line) == (sizeof(line) - 1))
+      throw Exception(_("Failed to read line %d in file %s: %s"),
+                      lineNr, filepath, _("Line too long"));
     
     // Make sure that the first line of the file has the file identifier string
     if(lineNr == 1) {
-      if(strncmp(line, IDENTIFIER_STRING, strlen(IDENTIFIER_STRING)) == 0) {
+      if(strncmp(line, IDENTIFIER_STRING, strlen(IDENTIFIER_STRING)) == 0)
         continue;
-      } else {
-        snprintf(readError, sizeof(readError),
-                 _("Configuration file %s is in an invalid format"),
-                 filepath);
-        throw Exception(readError);
-      }
+      else
+        throw Exception(_("Configuration file %s is in an invalid format"),
+                        filepath);
     }
     
     // Skip empty lines and comments
@@ -643,7 +628,7 @@
     } else {
     
       // Find and set the correct parameter
-      for (int i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
+      for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
 
         if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
           if (strcasecmp(line, ((StringParameter*)parameterArray[i])->getName()) == 0) {
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index 5de9a94..5f84679 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -29,9 +29,12 @@
 #include <errno.h>
 #include <signal.h>
 #include <locale.h>
+#include <fcntl.h>
+#include <unistd.h>
 #include <sys/stat.h>
 
 #ifdef WIN32
+#include <os/winerrno.h>
 #include <direct.h>
 #define mkdir(path, mode) _mkdir(path)
 #endif
@@ -56,6 +59,7 @@
 #include <FL/Fl.H>
 #include <FL/Fl_Widget.H>
 #include <FL/Fl_PNG_Image.H>
+#include <FL/Fl_Sys_Menu_Bar.H>
 #include <FL/fl_ask.H>
 #include <FL/x.H>
 
@@ -65,6 +69,7 @@
 #include "ServerDialog.h"
 #include "UserDialog.h"
 #include "vncviewer.h"
+#include "fltk_layout.h"
 
 #ifdef WIN32
 #include "resource.h"
@@ -77,14 +82,12 @@
 using namespace rfb;
 using namespace std;
 
-static const char _aboutText[] = N_("TigerVNC Viewer %d-bit v%s\n"
-                                    "Built on: %s\n"
-                                    "Copyright (C) 1999-%d TigerVNC Team and many others (see README.txt)\n"
-                                    "See http://www.tigervnc.org for information on TigerVNC.");
 static char aboutText[1024];
 
 char vncServerName[VNCSERVERNAMELEN] = { '\0' };
 
+static const char *argv0 = NULL;
+
 static bool exitMainloop = false;
 static const char *exitError = NULL;
 
@@ -104,11 +107,36 @@
   fl_message("%s", aboutText);
 }
 
+#ifdef __APPLE__
 static void about_callback(Fl_Widget *widget, void *data)
 {
   about_vncviewer();
 }
 
+static void new_connection_cb(Fl_Widget *widget, void *data)
+{
+  const char *argv[2];
+  pid_t pid;
+
+  pid = fork();
+  if (pid == -1) {
+    vlog.error(_("Error starting new TigerVNC Viewer: %s"), strerror(errno));
+    return;
+  }
+
+  if (pid != 0)
+    return;
+
+  argv[0] = argv0;
+  argv[1] = NULL;
+
+  execvp(argv[0], (char * const *)argv);
+
+  vlog.error(_("Error starting new TigerVNC Viewer: %s"), strerror(errno));
+  _exit(1);
+}
+#endif
+
 static void CleanupSignalHandler(int sig)
 {
   // CleanupSignalHandler allows C++ object cleanup to happen because it calls
@@ -237,6 +265,16 @@
   Fl_Mac_App_Menu::show = _("Show All");
 
   fl_mac_set_about(about_callback, NULL);
+
+  Fl_Sys_Menu_Bar *menubar;
+  char buffer[1024];
+  menubar = new Fl_Sys_Menu_Bar(0, 0, 500, 25);
+  // Fl_Sys_Menu_Bar overrides methods without them being virtual,
+  // which means we cannot use our generic Fl_Menu_ helpers.
+  if (fltk_menu_escape(_("&File"), buffer, sizeof(buffer)) < sizeof(buffer))
+      menubar->add(buffer, 0, 0, 0, FL_SUBMENU);
+  if (fltk_menu_escape(_("&New Connection"), buffer, sizeof(buffer)) < sizeof(buffer))
+      menubar->insert(1, buffer, FL_COMMAND | 'n', new_connection_cb);
 #endif
 }
 
@@ -258,6 +296,20 @@
 
 static void usage(const char *programName)
 {
+#ifdef WIN32
+  // If we don't have a console then we need to create one for output
+  if (GetConsoleWindow() == NULL) {
+    HANDLE handle;
+    int fd;
+
+    AllocConsole();
+
+    handle = GetStdHandle(STD_ERROR_HANDLE);
+    fd = _open_osfhandle((intptr_t)handle, O_TEXT);
+    *stderr = *fdopen(fd, "w");
+  }
+#endif
+
   fprintf(stderr,
           "\nusage: %s [parameters] [host:displayNum] [parameters]\n"
           "       %s [parameters] -listen [port] [parameters]\n",
@@ -270,6 +322,12 @@
           "--<param>=<value>\n"
           "Parameter names are case-insensitive.  The parameters are:\n\n");
   Configuration::listParams(79, 14);
+
+#ifdef WIN32
+  // Just wait for the user to kill the console window
+  Sleep(INFINITE);
+#endif
+
   exit(1);
 }
 
@@ -306,7 +364,6 @@
 
   snprintf(vncServerName, VNCSERVERNAMELEN, "localhost::%d", localPort);
   vncServerName[VNCSERVERNAMELEN - 1] = '\0';
-  vlog.error(vncServerName);
 
   return 0;
 }
@@ -354,14 +411,20 @@
 {
   UserDialog dlg;
 
+  argv0 = argv[0];
+
   setlocale(LC_ALL, "");
   bindtextdomain(PACKAGE_NAME, LOCALE_DIR);
   textdomain(PACKAGE_NAME);
 
   // Generate the about string now that we get the proper translation
-  snprintf(aboutText, sizeof(aboutText), _aboutText,
+  snprintf(aboutText, sizeof(aboutText),
+           _("TigerVNC Viewer %d-bit v%s\n"
+             "Built on: %s\n"
+             "Copyright (C) 1999-%d TigerVNC Team and many others (see README.txt)\n"
+             "See http://www.tigervnc.org for information on TigerVNC."),
            (int)sizeof(size_t)*8, PACKAGE_VERSION,
-           BUILD_TIMESTAMP, 2014);
+           BUILD_TIMESTAMP, 2015);
 
   rfb::SecurityClient::setDefaults();
 
@@ -402,6 +465,7 @@
   try {
     defaultServerName = loadViewerParameters(NULL);
   } catch (rfb::Exception& e) {
+    defaultServerName = "";
     fl_alert("%s", e.str());
   }
   
diff --git a/win/resdefs.h.in b/win/resdefs.h.in
index b61db53..e86a92d 100644
--- a/win/resdefs.h.in
+++ b/win/resdefs.h.in
@@ -1,4 +1,3 @@
 #define __VERSIONSTR "@VERSION@\0"
 #define __RCVERSION @RCVERSION@
 #define __RCVERSIONSTR "@RCVERSION@\0"
-#cmakedefine WIN64
diff --git a/win/rfb_win32/CleanDesktop.cxx b/win/rfb_win32/CleanDesktop.cxx
index 52dc6bd..8009fc8 100644
--- a/win/rfb_win32/CleanDesktop.cxx
+++ b/win/rfb_win32/CleanDesktop.cxx
@@ -129,7 +129,7 @@
         vlog.error("failed to get desktop item count: %ld", hr);
         return false;
       }
-      for (unsigned int i=0; i<itemCount; i++) {
+      for (int i=0; i<itemCount; i++) {
         if (enableItem(i, false))
           restoreItems.insert(i);
       }
@@ -148,7 +148,7 @@
   DWORD r = ERROR_SUCCESS;
   if (!SystemParametersInfo(action, param, ptr, ini)) {
     r = GetLastError();
-    vlog.info("SPI error: %d", r);
+    vlog.info("SPI error: %lu", r);
   }
   return r;
 }
@@ -303,12 +303,12 @@
       desktopCfg.openKey(HKEY_CURRENT_USER, _T("Control Panel\\Desktop"));
       SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt(_T("FontSmoothing"), 0) != 0, 0, SPIF_SENDCHANGE);
 #ifdef RFB_HAVE_SPI_UIEFFECTS
-      if (SysParamsInfo(SPI_SETUIEFFECTS, 0, (void*)uiEffects, SPIF_SENDCHANGE) == ERROR_CALL_NOT_IMPLEMENTED) {
-        SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (void*)comboBoxAnim, SPIF_SENDCHANGE);
-        SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (void*)gradientCaptions, SPIF_SENDCHANGE);
-        SysParamsInfo(SPI_SETHOTTRACKING, 0, (void*)hotTracking, SPIF_SENDCHANGE);
-        SysParamsInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, (void*)listBoxSmoothScroll, SPIF_SENDCHANGE);
-        SysParamsInfo(SPI_SETMENUANIMATION, 0, (void*)menuAnim, SPIF_SENDCHANGE);
+      if (SysParamsInfo(SPI_SETUIEFFECTS, 0, (void*)(intptr_t)uiEffects, SPIF_SENDCHANGE) == ERROR_CALL_NOT_IMPLEMENTED) {
+        SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (void*)(intptr_t)comboBoxAnim, SPIF_SENDCHANGE);
+        SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (void*)(intptr_t)gradientCaptions, SPIF_SENDCHANGE);
+        SysParamsInfo(SPI_SETHOTTRACKING, 0, (void*)(intptr_t)hotTracking, SPIF_SENDCHANGE);
+        SysParamsInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, (void*)(intptr_t)listBoxSmoothScroll, SPIF_SENDCHANGE);
+        SysParamsInfo(SPI_SETMENUANIMATION, 0, (void*)(intptr_t)menuAnim, SPIF_SENDCHANGE);
       }
       restoreEffects = false;
 #else
diff --git a/win/rfb_win32/Clipboard.cxx b/win/rfb_win32/Clipboard.cxx
index 482519e..0e29062 100644
--- a/win/rfb_win32/Clipboard.cxx
+++ b/win/rfb_win32/Clipboard.cxx
@@ -87,7 +87,7 @@
 }
 
 Clipboard::~Clipboard() {
-  vlog.debug("removing %x from chain (next is %x)", getHandle(), next_window);
+  vlog.debug("removing %p from chain (next is %p)", getHandle(), next_window);
   ChangeClipboardChain(getHandle(), next_window);
 }
 
@@ -96,7 +96,8 @@
   switch (msg) {
 
   case WM_CHANGECBCHAIN:
-    vlog.debug("change clipboard chain (%x, %x)", wParam, lParam);
+    vlog.debug("change clipboard chain (%I64x, %I64x)",
+               (long long)wParam, (long long)lParam);
     if ((HWND) wParam == next_window)
       next_window = (HWND) lParam;
     else if (next_window != 0)
@@ -111,7 +112,7 @@
       if (owner == getHandle()) {
         vlog.debug("local clipboard changed by me");
       } else {
-        vlog.debug("local clipboard changed by %x", owner);
+        vlog.debug("local clipboard changed by %p", owner);
 
 			  // Open the clipboard
 			  if (OpenClipboard(getHandle())) {
@@ -190,7 +191,7 @@
 
   // - Close the clipboard
   if (!CloseClipboard())
-    vlog.debug("unable to close Win32 clipboard: %u", GetLastError());
+    vlog.debug("unable to close Win32 clipboard: %lu", GetLastError());
   else
     vlog.debug("closed clipboard");
   if (clip_handle) {
diff --git a/win/rfb_win32/DeviceContext.cxx b/win/rfb_win32/DeviceContext.cxx
index 26721a6..da19de8 100644
--- a/win/rfb_win32/DeviceContext.cxx
+++ b/win/rfb_win32/DeviceContext.cxx
@@ -91,7 +91,7 @@
       rMask = bi.mask.red;
       gMask = bi.mask.green;
       bMask = bi.mask.blue;
-      vlog.info("%lu-bit BitFields: (%lx, %lx, %lx)",
+      vlog.info("%d-bit BitFields: (%lx, %lx, %lx)",
                  bi.bmiHeader.biBitCount, rMask, gMask, bMask);
       break;
     };
@@ -127,6 +127,10 @@
     if (bpp < 8)
       bpp = 8;
     vlog.info("%d-colour palettised", 1<<depth);
+    // Aren't really used, but set them to keep the compiler happy
+    redMax = redShift = 0;
+    greenMax = greenShift = 0;
+    blueMax = blueShift = 0;
   }
 
 
diff --git a/win/rfb_win32/Dialog.cxx b/win/rfb_win32/Dialog.cxx
index 70a5fb5..6b52244 100644
--- a/win/rfb_win32/Dialog.cxx
+++ b/win/rfb_win32/Dialog.cxx
@@ -278,7 +278,7 @@
     if ((handle == 0) || (handle == (HWND)-1))
       throw rdr::SystemException("PropertySheet failed", GetLastError());
     centerWindow(handle, owner);
-    plog.info("created %lx", handle);
+    plog.info("created %p", handle);
 
 #ifdef _DIALOG_CAPTURE
     if (capture) {
@@ -336,7 +336,7 @@
     }
 #endif
 
-    plog.info("finished %lx", handle);
+    plog.info("finished %p", handle);
 
     DestroyWindow(handle);
     handle = 0;
@@ -361,7 +361,7 @@
 }
 
 void PropSheet::reInitPages() {
-  plog.debug("reInitPages %lx", handle);
+  plog.debug("reInitPages %p", handle);
   std::list<PropSheetPage*>::iterator pspi;
   for (pspi=pages.begin(); pspi!=pages.end(); pspi++) {
     if ((*pspi)->handle)
@@ -370,7 +370,7 @@
 }
 
 bool PropSheet::commitPages() {
-  plog.debug("commitPages %lx", handle);
+  plog.debug("commitPages %p", handle);
   bool result = true;
   std::list<PropSheetPage*>::iterator pspi;
   for (pspi=pages.begin(); pspi!=pages.end(); pspi++) {
@@ -383,7 +383,7 @@
 
 void PropSheetPage::setChanged(bool changed) {
   if (propSheet) {
-    plog.debug("setChanged[%lx(%lx)]=%d", handle, propSheet->handle, (int)changed);
+    plog.debug("setChanged[%p(%p)]=%d", handle, propSheet->handle, (int)changed);
     if (changed)
       PropSheet_Changed(propSheet->handle, handle);
     else
diff --git a/win/rfb_win32/DynamicFn.cxx b/win/rfb_win32/DynamicFn.cxx
index 033971d..97d17ff 100644
--- a/win/rfb_win32/DynamicFn.cxx
+++ b/win/rfb_win32/DynamicFn.cxx
@@ -29,12 +29,12 @@
 DynamicFnBase::DynamicFnBase(const TCHAR* dllName, const char* fnName) : fnPtr(0), dllHandle(0) {
   dllHandle = LoadLibrary(dllName);
   if (!dllHandle) {
-    vlog.info("DLL %s not found (%d)", (const char*)CStr(dllName), GetLastError());
+    vlog.info("DLL %s not found (%lu)", (const char*)CStr(dllName), GetLastError());
     return;
   }
   fnPtr = (void*) GetProcAddress(dllHandle, fnName);
   if (!fnPtr)
-    vlog.info("proc %s not found in %s (%d)", fnName, (const char*)CStr(dllName), GetLastError());
+    vlog.info("proc %s not found in %s (%lu)", fnName, (const char*)CStr(dllName), GetLastError());
 }
 
 DynamicFnBase::~DynamicFnBase() {
diff --git a/win/rfb_win32/ListViewControl.cxx b/win/rfb_win32/ListViewControl.cxx
index bd375e2..f7733f7 100644
--- a/win/rfb_win32/ListViewControl.cxx
+++ b/win/rfb_win32/ListViewControl.cxx
@@ -30,7 +30,7 @@
 BOOL ListViewControl::InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns,
                                     TCHAR *title[], DWORD mask, DWORD LVStyle, DWORD format)
 {
-  ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle);
+  (void)ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle);
   TCHAR szText[256];      
   LVCOLUMN lvc; 
   int iCol;
@@ -90,12 +90,12 @@
 
 void ListViewControl::DeleteLVItem(DWORD idListView, HWND hDlg, int number)
 {
-  ListView_DeleteItem(GetDlgItem(hDlg, idListView), number);
+  (void)ListView_DeleteItem(GetDlgItem(hDlg, idListView), number);
 }
 
 void ListViewControl::DeleteAllLVItem(DWORD idListView, HWND hDlg)
 {
-  ListView_DeleteAllItems(GetDlgItem(hDlg, idListView));
+  (void)ListView_DeleteAllItems(GetDlgItem(hDlg, idListView));
 }
 
 ListViewControl::~ListViewControl()
diff --git a/win/rfb_win32/MonitorInfo.cxx b/win/rfb_win32/MonitorInfo.cxx
index c57cd26..d639ac5 100644
--- a/win/rfb_win32/MonitorInfo.cxx
+++ b/win/rfb_win32/MonitorInfo.cxx
@@ -50,15 +50,15 @@
 typedef BOOL (WINAPI *_EnumDisplayMonitors_proto)(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
 static rfb::win32::DynamicFn<_EnumDisplayMonitors_proto> _EnumDisplayMonitors(_T("user32.dll"), "EnumDisplayMonitors");
 static void fillMonitorInfo(HMONITOR monitor, MonitorInfo* mi) {
-  vlog.debug("monitor=%lx", monitor);
+  vlog.debug("monitor=%p", monitor);
   if (!_GetMonitorInfo.isValid())
     throw rdr::Exception("no GetMonitorInfo");
   memset(mi, 0, sizeof(MONITORINFOEXA));
   mi->cbSize = sizeof(MONITORINFOEXA);
   if (!(*_GetMonitorInfo)(monitor, mi))
     throw rdr::SystemException("failed to GetMonitorInfo", GetLastError());
-  vlog.debug("monitor is %d,%d-%d,%d", mi->rcMonitor.left, mi->rcMonitor.top, mi->rcMonitor.right, mi->rcMonitor.bottom);
-  vlog.debug("work area is %d,%d-%d,%d", mi->rcWork.left, mi->rcWork.top, mi->rcWork.right, mi->rcWork.bottom);
+  vlog.debug("monitor is %ld,%ld-%ld,%ld", mi->rcMonitor.left, mi->rcMonitor.top, mi->rcMonitor.right, mi->rcMonitor.bottom);
+  vlog.debug("work area is %ld,%ld-%ld,%ld", mi->rcWork.left, mi->rcWork.top, mi->rcWork.right, mi->rcWork.bottom);
   vlog.debug("device is \"%s\"", mi->szDevice);
 }
 #else
diff --git a/win/rfb_win32/MsgWindow.cxx b/win/rfb_win32/MsgWindow.cxx
index 4c50c2f..8086bea 100644
--- a/win/rfb_win32/MsgWindow.cxx
+++ b/win/rfb_win32/MsgWindow.cxx
@@ -52,7 +52,7 @@
     SetWindowLongPtr(wnd, GWLP_USERDATA, 0);
   MsgWindow* _this = (MsgWindow*) GetWindowLongPtr(wnd, GWLP_USERDATA);
   if (!_this) {
-    vlog.info("null _this in %x, message %x", wnd, msg);
+    vlog.info("null _this in %p, message %x", wnd, msg);
     return SafeDefWindowProc(wnd, msg, wParam, lParam);
   }
 
@@ -85,7 +85,7 @@
 
 MsgWindowClass::~MsgWindowClass() {
   if (classAtom) {
-    UnregisterClass((const TCHAR*)classAtom, instance);
+    UnregisterClass((const TCHAR*)(intptr_t)classAtom, instance);
   }
 }
 
@@ -97,18 +97,19 @@
 
 MsgWindow::MsgWindow(const TCHAR* name_) : name(tstrDup(name_)), handle(0) {
   vlog.debug("creating window \"%s\"", (const char*)CStr(name.buf));
-  handle = CreateWindow((const TCHAR*)baseClass.classAtom, name.buf, WS_OVERLAPPED,
-    0, 0, 10, 10, 0, 0, baseClass.instance, this);
+  handle = CreateWindow((const TCHAR*)(intptr_t)baseClass.classAtom,
+                        name.buf, WS_OVERLAPPED, 0, 0, 10, 10, 0, 0,
+                        baseClass.instance, this);
   if (!handle) {
     throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
   }
-  vlog.debug("created window \"%s\" (%x)", (const char*)CStr(name.buf), handle);
+  vlog.debug("created window \"%s\" (%p)", (const char*)CStr(name.buf), handle);
 }
 
 MsgWindow::~MsgWindow() {
   if (handle)
     DestroyWindow(handle);
-  vlog.debug("destroyed window \"%s\" (%x)", (const char*)CStr(name.buf), handle); 
+  vlog.debug("destroyed window \"%s\" (%p)", (const char*)CStr(name.buf), handle);
 }
 
 LRESULT
diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx
index b278576..70083f4 100644
--- a/win/rfb_win32/Registry.cxx
+++ b/win/rfb_win32/Registry.cxx
@@ -51,7 +51,7 @@
   LONG result = RegOpenKeyEx(k, 0, 0, KEY_ALL_ACCESS, &key);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegOpenKeyEx(HKEY)", result);
-  vlog.debug("duplicated %x to %x", k, key);
+  vlog.debug("duplicated %p to %p", k, key);
   freeKey = true;
 }
 
@@ -59,7 +59,7 @@
   LONG result = RegOpenKeyEx(k.key, 0, 0, KEY_ALL_ACCESS, &key);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegOpenKeyEx(RegKey&)", result);
-  vlog.debug("duplicated %x to %x", k.key, key);
+  vlog.debug("duplicated %p to %p", k.key, key);
   freeKey = true;
 }
 
@@ -69,7 +69,7 @@
 
 
 void RegKey::setHKEY(HKEY k, bool fK) {
-  vlog.debug("setHKEY(%x,%d)", k, (int)fK);
+  vlog.debug("setHKEY(%p,%d)", k, (int)fK);
   close();
   freeKey = fK;
   key = k;
@@ -80,10 +80,10 @@
   close();
   LONG result = RegCreateKey(root.key, name, &key);
   if (result != ERROR_SUCCESS) {
-    vlog.error("RegCreateKey(%x, %s): %x", root.key, name, result);
+    vlog.error("RegCreateKey(%p, %s): %lx", root.key, name, result);
     throw rdr::SystemException("RegCreateKeyEx", result);
   }
-  vlog.debug("createKey(%x,%s) = %x", root.key, (const char*)CStr(name), key);
+  vlog.debug("createKey(%p,%s) = %p", root.key, (const char*)CStr(name), key);
   freeKey = true;
   return true;
 }
@@ -93,7 +93,7 @@
   LONG result = RegOpenKeyEx(root.key, name, 0, readOnly ? KEY_READ : KEY_ALL_ACCESS, &key);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegOpenKeyEx (open)", result);
-  vlog.debug("openKey(%x,%s,%s) = %x", root.key, (const char*)CStr(name),
+  vlog.debug("openKey(%p,%s,%s) = %p", root.key, (const char*)CStr(name),
 	         readOnly ? "ro" : "rw", key);
   freeKey = true;
 }
@@ -113,7 +113,7 @@
 
 void RegKey::close() {
   if (freeKey) {
-    vlog.debug("RegCloseKey(%x)", key);
+    vlog.debug("RegCloseKey(%p)", key);
     RegCloseKey(key);
     key = 0;
   }
diff --git a/win/rfb_win32/SInput.cxx b/win/rfb_win32/SInput.cxx
index aa8a21b..f634566 100644
--- a/win/rfb_win32/SInput.cxx
+++ b/win/rfb_win32/SInput.cxx
@@ -151,7 +151,7 @@
         flags &= ~MOUSEEVENTF_ABSOLUTE;
         SystemParametersInfo(SPI_GETMOUSE, 0, &mouseInfo, 0);
         SystemParametersInfo(SPI_GETMOUSESPEED, 0, &oldSpeed, 0);
-        vlog.debug("SPI_GETMOUSE %d, %d, %d, speed %d", mouseInfo[0], mouseInfo[1], mouseInfo[2], oldSpeed);
+        vlog.debug("SPI_GETMOUSE %lu, %lu, %lu, speed %lu", mouseInfo[0], mouseInfo[1], mouseInfo[2], oldSpeed);
         ULONG idealMouseInfo[] = {10, 0, 0};
         SystemParametersInfo(SPI_SETMOUSESPEED, 0, &newSpeed, 0);
         SystemParametersInfo(SPI_SETMOUSE, 0, &idealMouseInfo, 0);
@@ -266,7 +266,7 @@
 // the appropriate scancode corresponding to the supplied virtual keycode.
 
 inline void doKeyboardEvent(BYTE vkCode, DWORD flags) {
-  vlog.debug("vkCode 0x%x flags 0x%x", vkCode, flags);
+  vlog.debug("vkCode 0x%x flags 0x%lx", vkCode, flags);
   keybd_event(vkCode, MapVirtualKey(vkCode, 0), flags, 0);
 }
 
diff --git a/win/rfb_win32/Security.cxx b/win/rfb_win32/Security.cxx
index 95ef1d8..cad1325 100644
--- a/win/rfb_win32/Security.cxx
+++ b/win/rfb_win32/Security.cxx
@@ -112,7 +112,7 @@
   LookupAccountSid(0, (PSID)buf, 0, &nameLen, 0, &domainLen, &use);
   if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
     throw rdr::SystemException("Unable to determine SID name lengths", GetLastError());
-  vlog.info("nameLen=%d, domainLen=%d, use=%d", nameLen, domainLen, use);
+  vlog.info("nameLen=%lu, domainLen=%lu, use=%d", nameLen, domainLen, use);
   *name = new TCHAR[nameLen];
   *domain = new TCHAR[domainLen];
   if (!LookupAccountSid(0, (PSID)buf, *name, &nameLen, *domain, &domainLen, &use))
@@ -122,7 +122,7 @@
 
 Sid::Administrators::Administrators() {
   PSID sid = 0;
-  SID_IDENTIFIER_AUTHORITY ntAuth = SECURITY_NT_AUTHORITY;
+  SID_IDENTIFIER_AUTHORITY ntAuth = { SECURITY_NT_AUTHORITY };
   if (!AllocateAndInitializeSid(&ntAuth, 2,
                                 SECURITY_BUILTIN_DOMAIN_RID,
                                 DOMAIN_ALIAS_RID_ADMINS,
@@ -134,7 +134,7 @@
 
 Sid::SYSTEM::SYSTEM() {
   PSID sid = 0;
-  SID_IDENTIFIER_AUTHORITY ntAuth = SECURITY_NT_AUTHORITY;
+  SID_IDENTIFIER_AUTHORITY ntAuth = { SECURITY_NT_AUTHORITY };
   if (!AllocateAndInitializeSid(&ntAuth, 1,
                                 SECURITY_LOCAL_SYSTEM_RID,
                                 0, 0, 0, 0, 0, 0, 0, &sid))
diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx
index 89be92e..99b3eaa 100644
--- a/win/rfb_win32/Service.cxx
+++ b/win/rfb_win32/Service.cxx
@@ -99,7 +99,7 @@
     vlog.error("failed to register handler: %lu", err);
     ExitProcess(err);
   }
-  vlog.debug("registered handler (%lx)", service->status_handle);
+  vlog.debug("registered handler (%p)", service->status_handle);
   service->setStatus(SERVICE_START_PENDING);
   vlog.debug("entering %s serviceMain", service->getName());
   service->status.dwWin32ExitCode = service->serviceMain(dwArgc, lpszArgv);
@@ -132,7 +132,7 @@
     entry[1].lpServiceProc = NULL;
     vlog.debug("entering dispatcher");
     if (!SetProcessShutdownParameters(0x100, 0))
-      vlog.error("unable to set shutdown parameters: %d", GetLastError());
+      vlog.error("unable to set shutdown parameters: %lu", GetLastError());
     service = this;
     if (!StartServiceCtrlDispatcher(entry))
       throw SystemException("unable to start service", GetLastError());
@@ -176,9 +176,9 @@
   if (!SetServiceStatus(status_handle, &status)) {
     status.dwCurrentState = SERVICE_STOPPED;
     status.dwWin32ExitCode = GetLastError();
-    vlog.error("unable to set service status:%u", status.dwWin32ExitCode);
+    vlog.error("unable to set service status:%lu", status.dwWin32ExitCode);
   }
-  vlog.debug("set status to %u(%u)", state, status.dwCheckPoint);
+  vlog.debug("set status to %lu(%lu)", state, status.dwCheckPoint);
 }
 
 Service::~Service() {
@@ -200,11 +200,11 @@
 switchToDesktop(HDESK desktop) {
   HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
   if (!SetThreadDesktop(desktop)) {
-    vlog.debug("switchToDesktop failed:%u", GetLastError());
+    vlog.debug("switchToDesktop failed:%lu", GetLastError());
     return false;
   }
   if (!CloseDesktop(old_desktop))
-    vlog.debug("unable to close old desktop:%u", GetLastError());
+    vlog.debug("unable to close old desktop:%lu", GetLastError());
   return true;
 }
 
@@ -218,7 +218,7 @@
 		DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
 		DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
   if (!input) {
-    vlog.debug("unable to OpenInputDesktop(1):%u", GetLastError());
+    vlog.debug("unable to OpenInputDesktop(1):%lu", GetLastError());
     return false;
   }
 
@@ -227,17 +227,17 @@
   char inputname[256];
 
   if (!GetUserObjectInformation(current, UOI_NAME, currentname, 256, &size)) {
-    vlog.debug("unable to GetUserObjectInformation(1):%u", GetLastError());
+    vlog.debug("unable to GetUserObjectInformation(1):%lu", GetLastError());
     CloseDesktop(input);
     return false;
   }
   if (!GetUserObjectInformation(input, UOI_NAME, inputname, 256, &size)) {
-    vlog.debug("unable to GetUserObjectInformation(2):%u", GetLastError());
+    vlog.debug("unable to GetUserObjectInformation(2):%lu", GetLastError());
     CloseDesktop(input);
     return false;
   }
   if (!CloseDesktop(input))
-    vlog.debug("unable to close input desktop:%u", GetLastError());
+    vlog.debug("unable to close input desktop:%lu", GetLastError());
 
   // *** vlog.debug("current=%s, input=%s", currentname, inputname);
   bool result = strcmp(currentname, inputname) == 0;
@@ -254,7 +254,7 @@
 		DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
 		DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
   if (!desktop) {
-    vlog.debug("unable to OpenInputDesktop(2):%u", GetLastError());
+    vlog.debug("unable to OpenInputDesktop(2):%lu", GetLastError());
     return false;
   }
 
diff --git a/win/rfb_win32/Threading.cxx b/win/rfb_win32/Threading.cxx
index 7960766..5873b58 100644
--- a/win/rfb_win32/Threading.cxx
+++ b/win/rfb_win32/Threading.cxx
@@ -34,11 +34,11 @@
 
 
 inline void logAction(Thread* t, const char* action) {
-  vlog.debug("%-16.16s %s(%lx)", action, t->getName(), t);
+  vlog.debug("%-16.16s %s(%p)", action, t->getName(), t);
 }
 
 inline void logError(Thread* t, const char* err) {
-  vlog.error("%-16.16s %s(%lx):%s", "failed", t->getName(), t, err);
+  vlog.error("%-16.16s %s(%p):%s", "failed", t->getName(), t, err);
 }
 
 
diff --git a/win/rfb_win32/TsSessions.cxx b/win/rfb_win32/TsSessions.cxx
index efe7564..b02f619 100644
--- a/win/rfb_win32/TsSessions.cxx
+++ b/win/rfb_win32/TsSessions.cxx
@@ -48,7 +48,7 @@
     id = 0;
     if (!_ProcessIdToSessionId.isValid())
       return;
-    if (processId == -1)
+    if (processId == (DWORD)-1)
       processId = GetCurrentProcessId();
     if (!(*_ProcessIdToSessionId)(GetCurrentProcessId(), &id))
       throw rdr::SystemException("ProcessIdToSessionId", GetLastError());
@@ -72,12 +72,12 @@
 #ifdef RFB_HAVE_WINSTATION_CONNECT
     if (!_WinStationConnect.isValid())
       throw rdr::Exception("WinSta APIs missing");
-    if (sessionId == -1)
+    if (sessionId == (DWORD)-1)
       sessionId = mySessionId.id;
 
     // Try to reconnect our session to the console
     ConsoleSessionId console;
-    vlog.info("Console session is %d", console.id);
+    vlog.info("Console session is %lu", console.id);
     if (!(*_WinStationConnect)(0, sessionId, console.id, L"", 0))
       throw rdr::SystemException("Unable to connect session to Console", GetLastError());
 
diff --git a/win/rfb_win32/WMCursor.cxx b/win/rfb_win32/WMCursor.cxx
index 4d696cb..fa15833 100644
--- a/win/rfb_win32/WMCursor.cxx
+++ b/win/rfb_win32/WMCursor.cxx
@@ -49,7 +49,8 @@
 #ifdef RFB_HAVE_GETCURSORINFO
   // Check the OS version
   bool is_win98 = (osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
-    (osVersion.dwMajorVersion > 4) || ((osVersion.dwMajorVersion == 4) && (osVersion.dwMinorVersion > 0));
+    ((osVersion.dwMajorVersion > 4) ||
+     ((osVersion.dwMajorVersion == 4) && (osVersion.dwMinorVersion > 0)));
   bool is_win2K = (osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osVersion.dwMajorVersion >= 5);
 
   // Use GetCursorInfo if OS version is sufficient
diff --git a/win/rfb_win32/WMShatter.cxx b/win/rfb_win32/WMShatter.cxx
index e68abfb..687deda 100644
--- a/win/rfb_win32/WMShatter.cxx
+++ b/win/rfb_win32/WMShatter.cxx
@@ -37,7 +37,8 @@
     break;
   };
   if (!result) {
-    vlog.info("IsSafeWM: 0x%x received 0x%x(%u, %lu) - not safe", window, msg, wParam, lParam);
+    vlog.info("IsSafeWM: 0x%p received 0x%x(%I64u, %I64u) - not safe",
+              window, msg, (long long)wParam, (long long)lParam);
   }
   return result;
 }
diff --git a/win/vncconfig/Connections.h b/win/vncconfig/Connections.h
index 209e4fd..6176f3d 100644
--- a/win/vncconfig/Connections.h
+++ b/win/vncconfig/Connections.h
@@ -117,11 +117,11 @@
         case IDC_HOSTS:
           {
             DWORD selected = SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_GETCURSEL, 0, 0);
-            int count = SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_GETCOUNT, 0, 0);
-            bool enable = selected != LB_ERR;
+            DWORD count = SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_GETCOUNT, 0, 0);
+            bool enable = selected != (DWORD)LB_ERR;
             enableItem(IDC_HOST_REMOVE, enable);
             enableItem(IDC_HOST_UP, enable && (selected > 0));
-            enableItem(IDC_HOST_DOWN, enable && (selected < count-1));
+            enableItem(IDC_HOST_DOWN, enable && (selected+1 < count));
             enableItem(IDC_HOST_EDIT, enable);
             setChanged(isChanged());
           }
diff --git a/win/winvnc/ControlPanel.cxx b/win/winvnc/ControlPanel.cxx
index 9c850d3..ba6cab2 100644
--- a/win/winvnc/ControlPanel.cxx
+++ b/win/winvnc/ControlPanel.cxx
@@ -141,17 +141,16 @@
 {
   COPYDATASTRUCT copyData;
   copyData.dwData = command;
-  copyData.lpData = 0;
   getSelConnInfo();
   if (data != -1) {
     ListConnStatus.Copy(&ListSelConn);
     ListConnStatus.setAllStatus(data);
     ListConnStatus.setDisable(isItemChecked(IDC_DISABLE_CLIENTS));
-    copyData.cbData = (DWORD)((long long)&ListConnStatus);
   } else {
     ListConnStatus.Clear();
   }
-  copyData.cbData = (DWORD)((long long)&ListConnStatus);
+  copyData.cbData = 0;
+  copyData.lpData = &ListConnStatus;
   SendMessage(m_hSTIcon, WM_COPYDATA, 0, (LPARAM)&copyData);
 }
 
diff --git a/win/winvnc/ManagedListener.cxx b/win/winvnc/ManagedListener.cxx
index f2933bb..e7728bc 100644
--- a/win/winvnc/ManagedListener.cxx
+++ b/win/winvnc/ManagedListener.cxx
@@ -79,7 +79,7 @@
     if (port)
       sock = new network::TcpListener(NULL, port, localOnly);
   } catch (rdr::Exception& e) {
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
   }
   if (sock) {
     if (!localOnly)
diff --git a/win/winvnc/STrayIcon.cxx b/win/winvnc/STrayIcon.cxx
index 84575bd..762a56a 100644
--- a/win/winvnc/STrayIcon.cxx
+++ b/win/winvnc/STrayIcon.cxx
@@ -63,9 +63,9 @@
 
 class STrayIcon : public TrayIcon {
 public:
-  STrayIcon(STrayIconThread& t) : thread(t),
+  STrayIcon(STrayIconThread& t) :
     vncConfig(_T("vncconfig.exe"), isServiceProcess() ? _T("-noconsole -service") : _T("-noconsole")),
-    vncConnect(_T("winvnc4.exe"), _T("-noconsole -connect")) {
+    vncConnect(_T("winvnc4.exe"), _T("-noconsole -connect")), thread(t) {
 
     // ***
     SetWindowText(getHandle(), _T("winvnc::IPC_Interface"));
@@ -179,7 +179,7 @@
         case 2:
           return thread.server.disconnectClients("IPC disconnect") ? 1 : 0;
         case 3:
-          thread.server.setClientsStatus((rfb::ListConnInfo *)command->cbData);
+          thread.server.setClientsStatus((rfb::ListConnInfo *)command->lpData);
         case 4:
           thread.server.getClientsInfo(&LCInfo);
           CPanel->UpdateListView(&LCInfo);
@@ -231,9 +231,10 @@
 
 STrayIconThread::STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon_, UINT activeIcon_, 
                                  UINT dis_inactiveIcon_, UINT dis_activeIcon_, UINT menu_)
-: Thread("TrayIcon"), server(sm), inactiveIcon(inactiveIcon_), activeIcon(activeIcon_),
-  dis_inactiveIcon(dis_inactiveIcon_), dis_activeIcon(dis_activeIcon_),menu(menu_),
-  windowHandle(0), runTrayIcon(true) {
+: Thread("TrayIcon"), windowHandle(0), server(sm),
+  inactiveIcon(inactiveIcon_), activeIcon(activeIcon_),
+  dis_inactiveIcon(dis_inactiveIcon_), dis_activeIcon(dis_activeIcon_),
+  menu(menu_), runTrayIcon(true) {
   start();
 }
 
diff --git a/win/winvnc/VNCServerService.cxx b/win/winvnc/VNCServerService.cxx
index 1a2a8e9..481df21 100644
--- a/win/winvnc/VNCServerService.cxx
+++ b/win/winvnc/VNCServerService.cxx
@@ -97,9 +97,8 @@
     if (GetSessionUserTokenWin(&hToken))
     {
         ModuleFileName filename;
-        static const char cmdLineFmt[] = "\"%s\" -noconsole -service_run";
-        TCharArray cmdLine(_tcslen(filename.buf) + sizeof(cmdLineFmt)/sizeof(cmdLineFmt[0]));
-        _stprintf(cmdLine.buf, cmdLineFmt, filename.buf);
+        TCharArray cmdLine;
+        cmdLine.format("\"%s\" -noconsole -service_run", filename.buf);
         STARTUPINFO si;
         ZeroMemory(&si, sizeof si);
         si.cb = sizeof si;
diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx
index 9d77c27..36dbcee 100644
--- a/win/winvnc/VNCServerWin32.cxx
+++ b/win/winvnc/VNCServerWin32.cxx
@@ -59,8 +59,8 @@
       CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNC") : 0),
     vncServer(CStr(ComputerName().buf), &desktop),
     hostThread(0), runServer(false), isDesktopStarted(false),
-    httpServer(&vncServer), config(&sockMgr), trayIcon(0),
-    rfbSock(&sockMgr), httpSock(&sockMgr),
+    httpServer(&vncServer), config(&sockMgr),
+    rfbSock(&sockMgr), httpSock(&sockMgr), trayIcon(0),
     queryConnectDialog(0)
 {
   // Initialise the desktop
@@ -189,10 +189,10 @@
 
     vlog.debug("Server exited cleanly");
   } catch (rdr::SystemException &s) {
-    vlog.error(s.str());
+    vlog.error("%s", s.str());
     result = s.err;
   } catch (rdr::Exception &e) {
-    vlog.error(e.str());
+    vlog.error("%s", e.str());
   }
 
   { Lock l(runLock);
diff --git a/win/winvnc/winvnc.cxx b/win/winvnc/winvnc.cxx
index 17b3a91..b906865 100644
--- a/win/winvnc/winvnc.cxx
+++ b/win/winvnc/winvnc.cxx
@@ -87,7 +87,7 @@
   } else {
     if (isError) {
       try {
-        vlog.error(msg);
+        vlog.error("%s", msg);
         return;
       } catch (...) {
       }
@@ -148,11 +148,11 @@
       } else if (strcasecmp(argv[i], "-status") == 0) {
         printf("Querying service status...\n");
         runServer = false;
+        CharArray result;
         DWORD state = rfb::win32::getServiceState(VNCServerService::Name);
-        CharArray stateStr(rfb::win32::serviceStateName(state));
-        const char* stateMsg = "The %s Service is in the %s state.";
-        CharArray result(strlen(stateStr.buf) + _tcslen(VNCServerService::Name) + strlen(stateMsg) + 1);
-        sprintf(result.buf, stateMsg, (const char*)CStr(VNCServerService::Name), stateStr.buf);
+        result.format("The %s Service is in the %s state.",
+                      (const char*)CStr(VNCServerService::Name),
+                      rfb::win32::serviceStateName(state));
         MsgBoxOrLog(result.buf);
       } else if (strcasecmp(argv[i], "-service") == 0) {
         printf("Run in service mode\n");
@@ -182,7 +182,7 @@
         close_console = true;
         vlog.info("closing console");
         if (!FreeConsole())
-          vlog.info("unable to close console:%u", GetLastError());
+          vlog.info("unable to close console:%lu", GetLastError());
 
       } else if ((strcasecmp(argv[i], "-help") == 0) ||
         (strcasecmp(argv[i], "--help") == 0) ||
diff --git a/win/wm_hooks/wm_hooks.cxx b/win/wm_hooks/wm_hooks.cxx
index 50a981e..c0350cd 100644
--- a/win/wm_hooks/wm_hooks.cxx
+++ b/win/wm_hooks/wm_hooks.cxx
@@ -204,11 +204,11 @@
     // Handle pop-up menus having items selected
 	case 485:
 		{
-			HANDLE prop = GetProp(wnd, (LPCTSTR) MAKELONG(ATOM_Popup_Selection, 0));
+			HANDLE prop = GetProp(wnd, (LPCTSTR) (intptr_t) ATOM_Popup_Selection);
       if (prop != (HANDLE) wParam) {
         NotifyWindow(wnd, 485);
 				SetProp(wnd,
-					(LPCTSTR) MAKELONG(ATOM_Popup_Selection, 0),
+					(LPCTSTR) (intptr_t) ATOM_Popup_Selection,
 					(HANDLE) wParam);
 			}
 		}