public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
* Built XWin on mingw - with patches
@ 2011-11-01 20:40 Ryan Pavlik
  2011-11-03 19:18 ` Jon TURNEY
  0 siblings, 1 reply; 11+ messages in thread
From: Ryan Pavlik @ 2011-11-01 20:40 UTC (permalink / raw)
  To: cygwin-xfree

All,
Not sure if this is the right forum for this, but it seemed more
specific and probably more appropriate than the overall xorg lists.
I wanted to build a native windows X server (essentially an
open-source Xming). I had to patch a number of the packages along the
way, but did eventually arrive at a build that worked.  I looked at
and used a few of the Xming patches, but only generally went to those
when the naive approach didn't work.

I'm looking for some feedback on the patches so that they can get into
the main line of the projects.

I built using mingw-cross-env, with my fork here that includes the
dependency packages: https://bitbucket.org/rpavlik/mingw-cross-env/
This builds everything except the xorg-server module (ignore the fact
there's an xorg-server makefile there - the patches aren't up to date
for that module.)

Patches for these dependencies are as follows, in that mingw-cross-env
repo (These should all have commit messages from being exported from
git format-patch):
libX11-1-add-xwinsock-include, libX11-2-windows-threads,
libX11-3-MinGW-lacks-caddr_t
libXaw-1-need-winsock
libXfont-1-dummy-readlink
libxcb-1-fix-include-order-with-Xdmcp, libxcb-2-wsastartup - this last
one fixes running libX11 apps built for Windows, including the
integrated multi-window WM.
xkbcomp-1-Use-X11-Xwindows.h, xkbcomp-2-Look-in-windows-base-dir-too -
this last one supports the "RELOCATE_PROJECTROOT" option in the XWin
server - should still work fine in the normal case though.


Then, the xorg-server is here:
https://github.com/rpavlik/Xserver/commits/patched-1.11-branch

I've tried to make the commits independent, atomic changes. (For some
of the patches from XMing, this does mean that I split some patches,
and combined some from multiple files, since those patches are offered
per-file, not per-topic.)

With this, I can run in -rootless or default mode (metacity over ssh
forwarding as well as local, patched Fluxbox work great for window
managers), as well as -multiwindow, on a Windows 7 machine. This
should run fine when installed to its prefix, as well, so I have
hopefully not negatively affected a Cygwin build with any of my
changes. I've put up some information on the wiki of my github repo,
including full build instructions:
https://github.com/rpavlik/Xserver/wiki

I would appreciate any feedback either through this list, or through
comments on the github commits, whichever is easier. A number of the
xorg-server patches are not XWin specific, and most are not even XWin
on MinGW-specific (that is, they may apply to Cygwin/X as well), so
I'd like to see as much as you're comfortable with merged.

Thanks for your time!

Ryan
--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik@iastate.edu
http://academic.cleardefinition.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-01 20:40 Built XWin on mingw - with patches Ryan Pavlik
@ 2011-11-03 19:18 ` Jon TURNEY
  2011-11-04 23:39   ` Ryan Pavlik
  0 siblings, 1 reply; 11+ messages in thread
From: Jon TURNEY @ 2011-11-03 19:18 UTC (permalink / raw)
  To: cygwin-xfree; +Cc: rpavlik

On 01/11/2011 20:39, Ryan Pavlik wrote:
> Not sure if this is the right forum for this, but it seemed more

This is absolutely the correct list.

Thanks very much for putting in the effort to do this.

> specific and probably more appropriate than the overall xorg lists.
> I wanted to build a native windows X server (essentially an
> open-source Xming). I had to patch a number of the packages along the
> way, but did eventually arrive at a build that worked.  I looked at
> and used a few of the Xming patches, but only generally went to those
> when the naive approach didn't work.

This may be a problem.

The material on the Xming website is licensed under a Creative Commons 
license, which is not compatible with the X11 license.  So, patches from the 
Xming website are not acceptable unless the author has agreed to re-license 
them appropriately.

> I'm looking for some feedback on the patches so that they can get into
> the main line of the projects.
>
> I built using mingw-cross-env, with my fork here that includes the
> dependency packages: https://bitbucket.org/rpavlik/mingw-cross-env/
> This builds everything except the xorg-server module (ignore the fact
> there's an xorg-server makefile there - the patches aren't up to date
> for that module.)
>
> Patches for these dependencies are as follows, in that mingw-cross-env
> repo (These should all have commit messages from being exported from
> git format-patch):
> libX11-1-add-xwinsock-include, libX11-2-windows-threads,
> libX11-3-MinGW-lacks-caddr_t
> libXaw-1-need-winsock
> libXfont-1-dummy-readlink
> libxcb-1-fix-include-order-with-Xdmcp, libxcb-2-wsastartup - this last
> one fixes running libX11 apps built for Windows, including the
> integrated multi-window WM.
> xkbcomp-1-Use-X11-Xwindows.h, xkbcomp-2-Look-in-windows-base-dir-too -
> this last one supports the "RELOCATE_PROJECTROOT" option in the XWin
> server - should still work fine in the normal case though.

I've quickly looked over these patches and in general they look good, and I'd 
be happy to help get them merged upstream.

A couple of general points I'd make though:

It helps a great deal in reviewing if the comments state why the change is a 
good idea (e.g. what problem it fixes), rather than just describing the change 
which is made.

I also noticed that a bit more care might be needed with the define you are 
using to enable platform specific code: WIN32 and __MINGW__ should not be used 
interchangeably.  WIN32 will also be defined when building VcXsrv, and neither 
is defined on Cygwin.

So, can you post your patches here, preferably in git-send-email format so we 
can review them in detail?

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-03 19:18 ` Jon TURNEY
@ 2011-11-04 23:39   ` Ryan Pavlik
  2011-11-07 18:10     ` Jon TURNEY
  0 siblings, 1 reply; 11+ messages in thread
From: Ryan Pavlik @ 2011-11-04 23:39 UTC (permalink / raw)
  To: cygwin-xfree

[-- Attachment #1: Type: text/plain, Size: 4272 bytes --]

On Thu, Nov 3, 2011 at 2:18 PM, Jon TURNEY <jon.turney@dronecode.org.uk> wrote:
>
> On 01/11/2011 20:39, Ryan Pavlik wrote:
>>
>> Not sure if this is the right forum for this, but it seemed more
>
> This is absolutely the correct list.
>
> Thanks very much for putting in the effort to do this.
>
>> specific and probably more appropriate than the overall xorg lists.
>> I wanted to build a native windows X server (essentially an
>> open-source Xming). I had to patch a number of the packages along the
>> way, but did eventually arrive at a build that worked.  I looked at
>> and used a few of the Xming patches, but only generally went to those
>> when the naive approach didn't work.
>
> This may be a problem.
>
> The material on the Xming website is licensed under a Creative Commons license, which is not compatible with the X11 license.  So, patches from the Xming website are not acceptable unless the author has agreed to re-license them appropriately.

I emailed him and he indicated that he already has a process worked
out for re-licensing a patch at a time to submit to you.

As such, I have re-worked my patch queue to remove all patches derived
from the Xming web site. It doesn't add everything that the previous
branch did, but it does build and start to work, and all these patches
are licensed like the X11 source itself as they are my work.  I also
re-worked the commit messages and patches a bit, and added some
additional patches.

https://github.com/rpavlik/Xserver/tree/cleanpatches-1.11-branch

>>
>> I'm looking for some feedback on the patches so that they can get into
>> the main line of the projects.
>>
>> I built using mingw-cross-env, with my fork here that includes the
>> dependency packages: https://bitbucket.org/rpavlik/mingw-cross-env/
>> This builds everything except the xorg-server module (ignore the fact
>> there's an xorg-server makefile there - the patches aren't up to date
>> for that module.)
>>
>> Patches for these dependencies are as follows, in that mingw-cross-env
>> repo (These should all have commit messages from being exported from
>> git format-patch):
>> libX11-1-add-xwinsock-include, libX11-2-windows-threads,
>> libX11-3-MinGW-lacks-caddr_t
>> libXaw-1-need-winsock
>> libXfont-1-dummy-readlink
>> libxcb-1-fix-include-order-with-Xdmcp, libxcb-2-wsastartup - this last
>> one fixes running libX11 apps built for Windows, including the
>> integrated multi-window WM.
>> xkbcomp-1-Use-X11-Xwindows.h, xkbcomp-2-Look-in-windows-base-dir-too -
>> this last one supports the "RELOCATE_PROJECTROOT" option in the XWin
>> server - should still work fine in the normal case though.
>
> I've quickly looked over these patches and in general they look good, and I'd be happy to help get them merged upstream.
>
> A couple of general points I'd make though:
>
> It helps a great deal in reviewing if the comments state why the change is a good idea (e.g. what problem it fixes), rather than just describing the change which is made.

I've revised the commit messages for xorg-server accordingly -
hopefully these are better.

>
> I also noticed that a bit more care might be needed with the define you are using to enable platform specific code: WIN32 and __MINGW__ should not be used interchangeably.  WIN32 will also be defined when building VcXsrv, and neither is defined on Cygwin.
>


Ah, true. I have gone through and improved this in my cleanpatches
branch, and have also added some convenience defines to make this
easier to get right - this is the last half of the commits.

>
> So, can you post your patches here, preferably in git-send-email format so we can review them in detail?
>

I wasn't sure if you wanted one email per patch, and 43 emails seemed
like an awful lot, so I've attached them all (git format-patch) to
this one. If you prefer, I can send them individually to this (or
another) list with git send-email.  These are just the xserver
patches, not the ones for other packages that I mentioned in the
mingw-cross-env repository.

Thanks!

Ryan
--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik@iastate.edu
http://academic.cleardefinition.com

[-- Attachment #2: 0001-os-osinit.c-Exclude-new-signal-sigaction-code-on-non.patch --]
[-- Type: application/octet-stream, Size: 877 bytes --]

From 502544be07011972fc810e370ba7d490b96115ad Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 15:21:35 -0500
Subject: [PATCH 01/43] os/osinit.c: Exclude new signal (sigaction) code on
 non-posix.

In particular, this is needed for MinGW builds.
---
 os/osinit.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/os/osinit.c b/os/osinit.c
index 45d202d..d1163c3 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -155,6 +155,7 @@ OsInit(void)
     char fname[PATH_MAX];
 
     if (!been_here) {
+#ifndef X_NO_POSIX
 	struct sigaction act, oact;
 	int i;
 	int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
@@ -199,6 +200,8 @@ OsInit(void)
 	dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
 #endif
 
+#endif /* !X_NO_POSIX */
+
 #if !defined(__CYGWIN__) 
 	fclose(stdin);
 	fclose(stdout);
-- 
1.7.7.1


[-- Attachment #3: 0002-os-xsha1.c-Preemptively-include-X11-Xwindows.h-on-Wi.patch --]
[-- Type: application/octet-stream, Size: 925 bytes --]

From f62592718e7ceec53a04c9c30055c9ba858d596e Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 14:49:15 -0500
Subject: [PATCH 02/43] os/xsha1.c: Preemptively include <X11/Xwindows.h> on
 Win32.

Avoids duplicate defines if someone includes windows.h before
the specially wrapped X11/Xwindows.h header.
---
 os/xsha1.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/os/xsha1.c b/os/xsha1.c
index 5ea71da..f13dd1f 100644
--- a/os/xsha1.c
+++ b/os/xsha1.c
@@ -64,6 +64,13 @@ int x_sha1_final(void *ctx, unsigned char result[20])
 
 #elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
 
+# if defined(WIN32) && !defined(__CYGWIN__)
+/*
+ * Must be included before any other header includes windows.h, to avoid
+ * conflicting definitions.
+ */
+#  include <X11/Xwindows.h>
+# endif
 # include <gcrypt.h>
 
 void *x_sha1_init(void)
-- 
1.7.7.1


[-- Attachment #4: 0003-os-utils.c-sigaction-is-POSIX.patch --]
[-- Type: application/octet-stream, Size: 869 bytes --]

From 92f7115b61feba83f364b5f128a301f1e826eb62 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 15:14:50 -0500
Subject: [PATCH 03/43] os/utils.c: sigaction is POSIX

MinGW doesn't have it, so this patch is needed for building.
---
 os/utils.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/os/utils.c b/os/utils.c
index d9aa65e..2b8c119 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -208,6 +208,9 @@ int auditTrailLevel = 1;
 OsSigHandlerPtr
 OsSignal(int sig, OsSigHandlerPtr handler)
 {
+#ifdef X_NOT_POSIX
+    return signal(sig, handler);
+#else
     struct sigaction act, oact;
 
     sigemptyset(&act.sa_mask);
@@ -218,6 +221,7 @@ OsSignal(int sig, OsSigHandlerPtr handler)
     if (sigaction(sig, &act, &oact))
       perror("sigaction");
     return oact.sa_handler;
+#endif
 }
 
 /*
-- 
1.7.7.1


[-- Attachment #5: 0004-os-utils.c-Windows-non-cygwin-get-only-stubs-for-Loc.patch --]
[-- Type: application/octet-stream, Size: 1893 bytes --]

From fdf546a221bacd4fc5937e1173d3ac2fe96a7ec2 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 21 Oct 2011 12:32:49 -0500
Subject: [PATCH 04/43] os/utils.c: Windows non-cygwin get only stubs for
 Lock/UnlockServer

MinGW and MSVC lack the POSIX functions to compile the locking code.
---
 os/utils.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/os/utils.c b/os/utils.c
index 2b8c119..97e6a6c 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -235,6 +235,15 @@ OsSignal(int sig, OsSigHandlerPtr handler)
 #define LOCK_PREFIX "/.X"
 #define LOCK_SUFFIX "-lock"
 
+#if defined(WIN32) && !defined(__CYGWIN__)
+void
+LockServer(void)
+{}
+
+void
+UnlockServer(void)
+{}
+#else
 static Bool StillLocking = FALSE;
 static char LockFile[PATH_MAX];
 static Bool nolock = FALSE;
@@ -382,6 +391,7 @@ UnlockServer(void)
   }
 }
 
+#endif /* not windows non-cygwin */
 /* Force connections to close on SIGHUP from init */
 
 void
@@ -502,7 +512,9 @@ void UseMsg(void)
 #ifdef RLIMIT_STACK
     ErrorF("-ls int                limit stack space to N Kb\n");
 #endif
+#if !defined(WIN32) || defined(__CYGWIN__)
     ErrorF("-nolock                disable the locking mechanism\n");
+#endif
     ErrorF("-nolisten string       don't listen on protocol\n");
     ErrorF("-noreset               don't reset after last client exists\n");
     ErrorF("-background [none]     create root window with no background\n");
@@ -750,6 +762,8 @@ ProcessCommandLine(int argc, char *argv[])
 		UseMsg();
 	}
 #endif
+
+#if !defined(WIN32) || defined(__CYGWIN__)
 	else if ( strcmp ( argv[i], "-nolock") == 0)
 	{
 #if !defined(WIN32) && !defined(__CYGWIN__)
@@ -759,6 +773,8 @@ ProcessCommandLine(int argc, char *argv[])
 #endif
 	    nolock = TRUE;
 	}
+#endif
+
 	else if ( strcmp( argv[i], "-nolisten") == 0)
 	{
             if(++i < argc) {
-- 
1.7.7.1


[-- Attachment #6: 0005-hw-xwin-XWin.exe.manifest-Modify-to-be-more-generic.patch --]
[-- Type: application/octet-stream, Size: 864 bytes --]

From 45c10cfb0c1b46e033e6cb774df72bc33060efea Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 14:28:45 -0500
Subject: [PATCH 05/43] hw/xwin/XWin.exe.manifest: Modify to be more generic

Not every build of XWin is Cygwin/X.
---
 hw/xwin/XWin.exe.manifest |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest
index 221150d..6650d34 100755
--- a/hw/xwin/XWin.exe.manifest
+++ b/hw/xwin/XWin.exe.manifest
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-	<description>The XWin X Windows server for Cygwin.</description>
+	<description>The XWin X Windows server.</description>
 	<dependency>
 	   <dependentAssembly>
 	     <assemblyIdentity
-- 
1.7.7.1


[-- Attachment #7: 0006-hw-xwin-Makefile.am-Include-manifest-in-the-dist-tar.patch --]
[-- Type: application/octet-stream, Size: 667 bytes --]

From e8094a64ad6b0ef02cbfb65bbda8e89508901bb5 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 14:29:01 -0500
Subject: [PATCH 06/43] hw/xwin/Makefile.am: Include manifest in the dist
 tarball.

---
 hw/xwin/Makefile.am |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 256af0b..c490163 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -175,7 +175,8 @@ install-exec-hook:
 EXTRA_DIST = \
 	$(xwinconfig_DATA) \
 	X.ico \
-	XWin.rc
+	XWin.rc \
+	XWin.exe.manifest
 
 relink:
 	$(AM_V_at)rm -f XWin$(EXEEXT) && $(MAKE) XWin$(EXEEXT)
-- 
1.7.7.1


[-- Attachment #8: 0007-configure.ac-use-ws2_32-instead-of-winsock2-on-MinGW.patch --]
[-- Type: application/octet-stream, Size: 942 bytes --]

From 5ff2053b78b66a0be5b9f095b9ec38cec751d605 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 21 Oct 2011 12:47:38 -0500
Subject: [PATCH 07/43] configure.ac: use ws2_32 instead of winsock2 on MinGW

---
 configure.ac |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index cc4292b..cf3d80b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1834,7 +1834,7 @@ if test "x$XWIN" = xyes; then
 			XWIN_SERVER_NAME=Xming
 			AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
 			AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
-			XWIN_SYS_LIBS=-lwinsock2
+			XWIN_SYS_LIBS=-lws2_32
 			;;
 	esac
 	XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $RANDR_LIB $RENDER_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $OS_LIB"
-- 
1.7.7.1


[-- Attachment #9: 0008-os-osinit.c-no-getpgrp-and-friends-on-windows-except.patch --]
[-- Type: application/octet-stream, Size: 629 bytes --]

From c5b4e5b6f25df5b2e73d93bc39ce85329f1366df Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 3 Nov 2011 19:25:57 -0500
Subject: [PATCH 08/43] os/osinit.c: no getpgrp and friends on windows except
 with cygwin

---
 os/osinit.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/os/osinit.c b/os/osinit.c
index d1163c3..ac5aceb 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -240,8 +240,10 @@ OsInit(void)
 #endif
 	}
 
+#if !defined(WIN32) || defined(__CYGWIN__)
 	if (getpgrp () == 0)
 	    setpgid (0, 0);
+#endif
 
 #ifdef RLIMIT_DATA
 	if (limitDataSpace >= 0)
-- 
1.7.7.1


[-- Attachment #10: 0009-os-utils.c-Use-winxp-or-better-for-Winsock-API.patch --]
[-- Type: application/octet-stream, Size: 644 bytes --]

From c8a5317e67c66ccbbb3acabf922fd45dae2fefb0 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 3 Nov 2011 19:27:37 -0500
Subject: [PATCH 09/43] os/utils.c: Use winxp or better for Winsock API

---
 os/utils.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/os/utils.c b/os/utils.c
index 97e6a6c..12b9deb 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -64,6 +64,9 @@ __stdcall unsigned long GetTickCount(void);
 #endif
 
 #if defined(WIN32) && !defined(__CYGWIN__)
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
 #include <X11/Xwinsock.h>
 #endif
 #include <X11/Xos.h>
-- 
1.7.7.1


[-- Attachment #11: 0010-include-xwin-config.h.in-Add-RELOCATE_PROJECTROOT-to.patch --]
[-- Type: application/octet-stream, Size: 684 bytes --]

From ebb78bd11cf320585c358ed4f19a7d5a19792c9c Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Wed, 26 Oct 2011 17:03:25 -0500
Subject: [PATCH 10/43] include/xwin-config.h.in: Add RELOCATE_PROJECTROOT to
 config header

---
 include/xwin-config.h.in |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/xwin-config.h.in b/include/xwin-config.h.in
index 13b51ca..b4e99fd 100644
--- a/include/xwin-config.h.in
+++ b/include/xwin-config.h.in
@@ -34,3 +34,7 @@
 
 /* Default log location */
 #undef DEFAULT_LOGDIR
+
+/* Whether we should re-located the root to where the executable lives */
+#undef RELOCATE_PROJECTROOT
+
-- 
1.7.7.1


[-- Attachment #12: 0011-hw-xwin-InitOutput.c-Only-reset-the-xkb-directory-if.patch --]
[-- Type: application/octet-stream, Size: 2148 bytes --]

From 6bd530b4b0814ee2f6fcb0265cf69e981040bb40 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 27 Oct 2011 11:55:21 -0500
Subject: [PATCH 11/43] hw/xwin/InitOutput.c: Only reset the xkb directory if
 the new one exists.

This is for running builds with RELOCATE_PROJECTROOT in their default
install locations.
---
 hw/xwin/InitOutput.c |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 4fe5053..682e9f0 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -49,6 +49,9 @@ from The Open Group.
 #endif
 #ifdef RELOCATE_PROJECTROOT
 #include <shlobj.h>
+#include <io.h>
+#include <sys/stat.h>
+
 typedef WINAPI HRESULT (*SHGETFOLDERPATHPROC)(
     HWND hwndOwner,
     int nFolder,
@@ -358,7 +361,26 @@ winCheckMount(void)
 #endif
 
 #ifdef RELOCATE_PROJECTROOT
-const char * 
+
+static BOOL
+winDirectoryExists(const char * path)
+{
+  BOOL ret = FALSE;
+  if (access(path, 0) == 0)
+  {
+    struct stat pathstat;
+    stat(path, &pathstat);
+    if (pathstat.st_mode & S_IFDIR)
+    {
+      ret = TRUE;
+    }
+  }
+  ErrorF("winDirectoryExists(\"%s\") = %d\n", path, ret);
+  return ret;
+}
+
+
+const char *
 winGetBaseDir(void)
 {
     static BOOL inited = FALSE;
@@ -642,16 +664,20 @@ winFixupPaths (void)
             g_pszLogFile = buffer;
             winMsg (X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile);
         }
+  {
+    static char xkbbasedir[MAX_PATH];
+
+    snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir);
+    if (sizeof(xkbbasedir) > 0)
+    {
+      xkbbasedir[sizeof(xkbbasedir) - 1] = 0;
     }
+    if (winDirectoryExists(xkbbasedir))
     {
-        static char xkbbasedir[MAX_PATH];
-
-        snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir);
-        if (sizeof(xkbbasedir) > 0)
-            xkbbasedir[sizeof(xkbbasedir)-1] = 0;
-        XkbBaseDirectory = xkbbasedir;
-	XkbBinDirectory = basedir;
+      XkbBaseDirectory = xkbbasedir;
     }
+    XkbBinDirectory = basedir;
+  }
 #endif /* RELOCATE_PROJECTROOT */
 }
 
-- 
1.7.7.1


[-- Attachment #13: 0012-hw-xwin-InitOutput.c-reformat-winGetBaseDir.patch --]
[-- Type: application/octet-stream, Size: 1768 bytes --]

From f97289411cb1cabcf48d55de0a3e856071d48e69 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 27 Oct 2011 11:57:04 -0500
Subject: [PATCH 12/43] hw/xwin/InitOutput.c: reformat winGetBaseDir

---
 hw/xwin/InitOutput.c |   44 +++++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 682e9f0..5e50807 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -383,29 +383,31 @@ winDirectoryExists(const char * path)
 const char *
 winGetBaseDir(void)
 {
-    static BOOL inited = FALSE;
-    static char buffer[MAX_PATH];
-    if (!inited)
+  static BOOL inited = FALSE;
+  static char buffer[MAX_PATH];
+  if (!inited)
+  {
+    char *fendptr;
+    HMODULE module = GetModuleHandle(NULL);
+    DWORD size = GetModuleFileName(module, buffer, sizeof(buffer));
+    if (sizeof(buffer) > 0)
     {
-        char *fendptr;
-        HMODULE module = GetModuleHandle(NULL);
-        DWORD size = GetModuleFileName(module, buffer, sizeof(buffer));
-        if (sizeof(buffer) > 0)
-            buffer[sizeof(buffer)-1] = 0;
-    
-        fendptr = buffer + size;
-        while (fendptr > buffer)
-        {
-            if (*fendptr == '\\' || *fendptr == '/')
-            {
-                *fendptr = 0;
-                break;
-            }
-            fendptr--;
-        }
-        inited = TRUE;
+      buffer[sizeof(buffer) - 1] = 0;
     }
-    return buffer;
+
+    fendptr = buffer + size;
+    while (fendptr > buffer)
+    {
+      if (*fendptr == '\\' || *fendptr == '/')
+      {
+        *fendptr = 0;
+        break;
+      }
+      fendptr--;
+    }
+    inited = TRUE;
+  }
+  return buffer;
 }
 #endif
 
-- 
1.7.7.1


[-- Attachment #14: 0013-hw-xwin-InitOutput.c-Remove-duplicated-code-for-sett.patch --]
[-- Type: application/octet-stream, Size: 6069 bytes --]

From 2ee4e5b2d27fc9b4c261af2527d1a02c9c3e492a Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 27 Oct 2011 11:59:40 -0500
Subject: [PATCH 13/43] hw/xwin/InitOutput.c: Remove duplicated code for
 setting up environment variables

---
 hw/xwin/InitOutput.c |  160 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 102 insertions(+), 58 deletions(-)

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 5e50807..50b38bd 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -379,6 +379,22 @@ winDirectoryExists(const char * path)
   return ret;
 }
 
+static BOOL
+winFileIs(const char * path, mode_t mask)
+{
+  BOOL ret = FALSE;
+  if (access(path, 0) == 0)
+  {
+    struct stat pathstat;
+    stat(path, &pathstat);
+    if (pathstat.st_mode & mask)
+    {
+      ret = TRUE;
+    }
+  }
+  ErrorF("winFileExists(\"%s\") = %d\n", path, ret);
+  return ret;
+}
 
 const char *
 winGetBaseDir(void)
@@ -409,6 +425,46 @@ winGetBaseDir(void)
   }
   return buffer;
 }
+
+
+static void
+winVerifyEnvironment(const char * basedir, mode_t mask, const char * varname, const char * dirsuffix)
+{
+  if (getenv(varname) == NULL)
+  {
+    char buffer[MAX_PATH];
+    snprintf(buffer, sizeof(buffer), "%s\\%s",
+             PROJECTROOT, dirsuffix);
+    buffer[sizeof(buffer) - 1] = 0;
+    if (winFileIs(buffer, mask))
+    {
+      snprintf(buffer, sizeof(buffer), "%s=%s\\%s",
+               varname, PROJECTROOT, dirsuffix);
+      buffer[sizeof(buffer) - 1] = 0;
+      putenv(buffer);
+    }
+    else
+    {
+      snprintf(buffer, sizeof(buffer), "%s\\%s",
+               basedir, dirsuffix);
+      buffer[sizeof(buffer) - 1] = 0;
+      if (winFileIs(buffer, mask))
+      {
+        snprintf(buffer, sizeof(buffer), "%s=%s\\%s",
+                 varname, basedir, dirsuffix);
+        buffer[sizeof(buffer) - 1] = 0;
+        putenv(buffer);
+      }
+      else
+      {
+        ErrorF("winVerifyEnvironment: Could not find a valid path for \"%s\"\n", varname);
+      }
+    }
+
+    putenv(buffer);
+  }
+
+}
 #endif
 
 static void
@@ -600,72 +656,60 @@ winFixupPaths (void)
         winMsg (font_from, "FontPath set to \"%s\"\n", defaultFontPath);
 
 #ifdef RELOCATE_PROJECTROOT
-    if (getenv("XKEYSYMDB") == NULL)
+  winVerifyEnvironment(basedir, S_IFREG, "XKEYSYMDB", "XKeysymDB");
+  winVerifyEnvironment(basedir, S_IFREG, "XERRORDB", "XErrorDB");
+  winVerifyEnvironment(basedir, S_IFDIR, "XLOCALEDIR", "locale");
+  if (getenv("HOME") == NULL)
+  {
+    HMODULE shfolder;
+    SHGETFOLDERPATHPROC shgetfolderpath = NULL;
+    char buffer[MAX_PATH + 5];
+    strncpy(buffer, "HOME=", 5);
+
+    /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
+
+    shfolder = LoadLibrary("shfolder.dll");
+    /* fallback to shell32.dll */
+    if (shfolder == NULL)
     {
-        char buffer[MAX_PATH];
-        snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB",
-                basedir);
-        buffer[sizeof(buffer)-1] = 0;
-        putenv(buffer);
+      shfolder = LoadLibrary("shell32.dll");
     }
-    if (getenv("XERRORDB") == NULL)
+
+    /* resolve SHGetFolderPath */
+    if (shfolder != NULL)
     {
-        char buffer[MAX_PATH];
-        snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB",
-                basedir);
-        buffer[sizeof(buffer)-1] = 0;
-        putenv(buffer);
+      shgetfolderpath = (SHGETFOLDERPATHPROC) GetProcAddress(shfolder, "SHGetFolderPathA");
+    }
+
+    /* query appdata directory */
+    if (shgetfolderpath &&
+        shgetfolderpath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0,
+                        buffer + 5) == 0)
+    {
+      putenv(buffer);
     }
-    if (getenv("XLOCALEDIR") == NULL)
+    else
     {
-        char buffer[MAX_PATH];
-        snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale",
-                basedir);
-        buffer[sizeof(buffer)-1] = 0;
-        putenv(buffer);
+      winMsg(X_ERROR, "Can not determine HOME directory\n");
     }
-    if (getenv("HOME") == NULL)
+    if (shfolder != NULL)
     {
-        HMODULE shfolder;
-        SHGETFOLDERPATHPROC shgetfolderpath = NULL;
-        char buffer[MAX_PATH + 5];
-        strncpy(buffer, "HOME=", 5);
-
-        /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
-        
-        shfolder = LoadLibrary("shfolder.dll");
-        /* fallback to shell32.dll */
-        if (shfolder == NULL)
-            shfolder = LoadLibrary("shell32.dll");
-
-        /* resolve SHGetFolderPath */
-        if (shfolder != NULL)
-            shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
-
-        /* query appdata directory */
-        if (shgetfolderpath &&
-                shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, 
-                    buffer + 5) == 0)
-        { 
-            putenv(buffer);
-        } else
-        {
-            winMsg (X_ERROR, "Can not determine HOME directory\n");
-        } 
-        if (shfolder != NULL)
-            FreeLibrary(shfolder);
+      FreeLibrary(shfolder);
     }
-    if (!g_fLogFileChanged) {
-        static char buffer[MAX_PATH];
-        DWORD size = GetTempPath(sizeof(buffer), buffer);
-        if (size && size < sizeof(buffer))
-        {
-            snprintf(buffer + size, sizeof(buffer) - size, 
-                    "XWin.%s.log", display); 
-            buffer[sizeof(buffer)-1] = 0;
-            g_pszLogFile = buffer;
-            winMsg (X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile);
-        }
+  }
+  if (!g_fLogFileChanged)
+  {
+    static char buffer[MAX_PATH];
+    DWORD size = GetTempPath(sizeof(buffer), buffer);
+    if (size && size < sizeof(buffer))
+    {
+      snprintf(buffer + size, sizeof(buffer) - size,
+               "XWin.%s.log", display);
+      buffer[sizeof(buffer) - 1] = 0;
+      g_pszLogFile = buffer;
+      winMsg(X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile);
+    }
+  }
   {
     static char xkbbasedir[MAX_PATH];
 
-- 
1.7.7.1


[-- Attachment #15: 0014-hw-xwin-winwindow.h-Add-missing-include-xwin-config..patch --]
[-- Type: application/octet-stream, Size: 623 bytes --]

From 447b46369bc475af1d462fca5a8ee461a89d5d40 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 27 Oct 2011 12:04:32 -0500
Subject: [PATCH 14/43] hw/xwin/winwindow.h: Add missing include xwin-config.h

---
 hw/xwin/winwindow.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index a6c8e05..0d90a65 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -32,6 +32,10 @@
  *              Colin Harrison
  */
 
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+
 #ifndef NO
 #define NO			0
 #endif
-- 
1.7.7.1


[-- Attachment #16: 0015-hw-xwin-winwindow.h-change-window-class-and-window-c.patch --]
[-- Type: application/octet-stream, Size: 971 bytes --]

From 400ec55da89f70f4eba234ace96cee98e21465f5 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 27 Oct 2011 12:43:02 -0500
Subject: [PATCH 15/43] hw/xwin/winwindow.h: change window class and window
 class X

---
 hw/xwin/winwindow.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index 0d90a65..5f3cc65 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -48,11 +48,11 @@
 #  define PROJECT_NAME		"Cygwin/X"
 #endif
 #define EXECUTABLE_NAME         "XWin"
-#define WINDOW_CLASS		"cygwin/x"
+#define WINDOW_CLASS		PROJECT_NAME
 #define WINDOW_TITLE		PROJECT_NAME ":%s.%d"
 #define WINDOW_TITLE_XDMCP	"%s:%s.%d"
 #define WIN_SCR_PROP		"cyg_screen_prop rl"
-#define WINDOW_CLASS_X		"cygwin/x X rl"
+#define WINDOW_CLASS_X		PROJECT_NAME " X"
 #define WINDOW_TITLE_X		PROJECT_NAME " X"
 #define WIN_WINDOW_PROP		"cyg_window_prop_rl"
 #ifdef HAS_DEVWINDOWS
-- 
1.7.7.1


[-- Attachment #17: 0016-hw-xwin-winwindow.h-make-project-name-aware-of-non-C.patch --]
[-- Type: application/octet-stream, Size: 903 bytes --]

From 2c52d098bbdb85b885da3b5f4f5c90da5b0be50b Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 3 Nov 2011 19:28:58 -0500
Subject: [PATCH 16/43] hw/xwin/winwindow.h: make project name aware of
 non-Cygwin builds

---
 hw/xwin/winwindow.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index 5f3cc65..fa78c5a 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -45,8 +45,15 @@
 
 /* Constant strings */
 #ifndef PROJECT_NAME
-#  define PROJECT_NAME		"Cygwin/X"
+#  if defined(__MINGW32__)
+#    define PROJECT_NAME "XWin-MinGW"
+#  elif defined(__CYGWIN__)
+#    define PROJECT_NAME		"Cygwin/X"
+#  else
+#    define PROJECT_NAME		"XWin"
+#  endif
 #endif
+
 #define EXECUTABLE_NAME         "XWin"
 #define WINDOW_CLASS		PROJECT_NAME
 #define WINDOW_TITLE		PROJECT_NAME ":%s.%d"
-- 
1.7.7.1


[-- Attachment #18: 0017-dix-registry.c-non-cygwin-find-protocol.txt-in-reloc.patch --]
[-- Type: application/octet-stream, Size: 1480 bytes --]

From 9448110682ae8ac0c4343f7df2139b1b06389078 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 3 Nov 2011 19:30:46 -0500
Subject: [PATCH 17/43] dix/registry.c: non-cygwin find protocol.txt in
 relocated root

---
 dix/registry.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/dix/registry.c b/dix/registry.c
index fc35dbb..ba588c4 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -32,8 +32,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define BASE_SIZE 16
 #define CORE "X11"
+
+/* Should this actually be checking RELOCATE_PROJECTROOT ? */
+#if defined(WIN32) && !defined(__CYGWIN__)
+#define FILENAME_ONLY "protocol.txt"
+extern const char *winGetBaseDir(void);
+#endif
 #define FILENAME SERVER_MISC_CONFIG_PATH "/protocol.txt"
 
+
 #define PROT_COMMENT '#'
 #define PROT_REQUEST 'R'
 #define PROT_EVENT 'V'
@@ -311,7 +318,19 @@ dixResetRegistry(void)
     /* Open the protocol file */
     if (fh)
 	fclose(fh);
+#if defined(WIN32) && !defined(__CYGWIN__)
+    {
+	char filename[MAX_PATH];
+	snprintf(filename, sizeof(filename), "%s\\%s", winGetBaseDir(), FILENAME_ONLY);
+	filename[sizeof(filename)-1] = 0;
+	fh = fopen(filename, "r");
+    }
+    if (!fh) {
+#endif
     fh = fopen(FILENAME, "r");
+#if defined(WIN32) && !defined(__CYGWIN__)
+	}
+#endif
     if (!fh)
 	LogMessage(X_WARNING, "Failed to open protocol names file " FILENAME "\n");
 
-- 
1.7.7.1


[-- Attachment #19: 0018-hw-xwin-winrandr.c-Fix-function-pointer-mismatch.patch --]
[-- Type: application/octet-stream, Size: 711 bytes --]

From dd7a2abb28861d6d3d9bcfccfbd9c333a8d3f0ee Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 27 Oct 2011 15:49:59 -0500
Subject: [PATCH 18/43] hw/xwin/winrandr.c: Fix function pointer mismatch

---
 hw/xwin/winrandr.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/hw/xwin/winrandr.c b/hw/xwin/winrandr.c
index c581193..596c1ab 100644
--- a/hw/xwin/winrandr.c
+++ b/hw/xwin/winrandr.c
@@ -122,8 +122,6 @@ Bool
 winRandRScreenSetSize (ScreenPtr  pScreen,
 		       CARD16	    width,
 		       CARD16	    height,
-		       CARD16       pixWidth,
-		       CARD16       pixHeight,
 		       CARD32	    mmWidth,
 		       CARD32	    mmHeight)
 {
-- 
1.7.7.1


[-- Attachment #20: 0019-hw-xwin-winmultiwindowwm.c-fix-memory-leak.patch --]
[-- Type: application/octet-stream, Size: 1111 bytes --]

From 3e7512e24d2f2bf117b3db0c1659cd3336f83a29 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:46:45 -0500
Subject: [PATCH 19/43] hw/xwin/winmultiwindowwm.c: fix memory leak

---
 hw/xwin/winmultiwindowwm.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 67a58a0..4178756 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1201,11 +1201,13 @@ winInitWM (void **ppWMInfo,
   XMsgProcArgPtr	pXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec));
 
   /* Bail if the input parameters are bad */
-  if (pArg == NULL || pWMInfo == NULL)
-    {
-      ErrorF ("winInitWM - malloc failed.\n");
-      return FALSE;
-    }
+  if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
+    ErrorF ("winInitWM - malloc failed.\n");
+    if (pArg) free(pArg);
+    if (pWMInfo) free(pWMInfo);
+    if (pXMsgArg) free(pXMsgArg);
+    return FALSE;
+  }
   
   /* Zero the allocated memory */
   ZeroMemory (pArg, sizeof (WMProcArgRec));
-- 
1.7.7.1


[-- Attachment #21: 0020-hw-xwin-winengine.c-clarify-if-statement-mixed-with-.patch --]
[-- Type: application/octet-stream, Size: 866 bytes --]

From 26cf5793cd988257ecc650acd7f9e2337d082d34 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:46:56 -0500
Subject: [PATCH 20/43] hw/xwin/winengine.c: clarify if statement mixed with
 ifdef

---
 hw/xwin/winengine.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c
index e866e1e..752c4fe 100644
--- a/hw/xwin/winengine.c
+++ b/hw/xwin/winengine.c
@@ -192,15 +192,12 @@ winSetEngine (ScreenPtr pScreen)
 
   /* ShadowGDI is the only engine that supports Multi Window Mode */
   if (
-#ifdef XWIN_MULTIWINDOWEXTWM
-      pScreenInfo->fMWExtWM
-#else
       FALSE
+#ifdef XWIN_MULTIWINDOWEXTWM
+      || pScreenInfo->fMWExtWM
 #endif
 #ifdef XWIN_MULTIWINDOW
       || pScreenInfo->fMultiWindow
-#else
-      || FALSE
 #endif
       )
     {
-- 
1.7.7.1


[-- Attachment #22: 0021-hw-xwin-winnativegdi.c-Fix-potential-null-ptr-deref.patch --]
[-- Type: application/octet-stream, Size: 1312 bytes --]

From 3f1f4847160e4d915ead881e790bf1cccdbb9084 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:49:00 -0500
Subject: [PATCH 21/43] hw/xwin/winnativegdi.c: Fix potential null ptr deref.

---
 hw/xwin/winnativegdi.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/xwin/winnativegdi.c b/hw/xwin/winnativegdi.c
index 4d7afe8..68f8020 100644
--- a/hw/xwin/winnativegdi.c
+++ b/hw/xwin/winnativegdi.c
@@ -315,7 +315,6 @@ static Bool
 winActivateAppNativeGDI (ScreenPtr pScreen)
 {
   winScreenPriv(pScreen);
-  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
 
   /*
    * Are we active?
@@ -323,7 +322,8 @@ winActivateAppNativeGDI (ScreenPtr pScreen)
    */
   if (pScreenPriv != NULL
       && pScreenPriv->fActive
-      && pScreenInfo->fFullScreen)
+      && pScreenPriv->pScreenInfo
+      && pScreenPriv->pScreenInfo->fFullScreen)
     {
       /*
        * Activating, attempt to bring our window 
@@ -338,7 +338,8 @@ winActivateAppNativeGDI (ScreenPtr pScreen)
    */
   if (pScreenPriv != NULL
       && !pScreenPriv->fActive
-      && pScreenInfo->fFullScreen)
+      && pScreenPriv->pScreenInfo
+      && pScreenPriv->pScreenInfo->fFullScreen)
     {
       /*
        * Deactivating, stuff our window onto the
-- 
1.7.7.1


[-- Attachment #23: 0022-hw-xwin-winpfbdd.c-fix-possible-null-ptr-deref.patch --]
[-- Type: application/octet-stream, Size: 1291 bytes --]

From 5e3f0b90cc06c552c7b53661168f913b15541d00 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:52:34 -0500
Subject: [PATCH 22/43] hw/xwin/winpfbdd.c: fix possible null ptr deref

---
 hw/xwin/winpfbdd.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/xwin/winpfbdd.c b/hw/xwin/winpfbdd.c
index a399020..1a5a0e7 100644
--- a/hw/xwin/winpfbdd.c
+++ b/hw/xwin/winpfbdd.c
@@ -461,12 +461,12 @@ static Bool
 winActivateAppPrimaryDD (ScreenPtr pScreen)
 {
   winScreenPriv(pScreen);
-  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
   RECT			rcSrc, rcClient;
   HRESULT		ddrval = DD_OK;
 
   /* Check for errors */
   if (pScreenPriv == NULL
+      || pScreenPriv->pScreenInfo == NULL
       || pScreenPriv->pddsPrimary == NULL
       || pScreenPriv->pddsOffscreen == NULL)
     return FALSE;
@@ -500,8 +500,8 @@ winActivateAppPrimaryDD (ScreenPtr pScreen)
   /* Setup a source rectangle */
   rcSrc.left = 0;
   rcSrc.top = 0;
-  rcSrc.right = pScreenInfo->dwWidth;
-  rcSrc.bottom = pScreenInfo->dwHeight;
+  rcSrc.right = pScreenPriv->pScreenInfo->dwWidth;
+  rcSrc.bottom = pScreenPriv->pScreenInfo->dwHeight;
 
   ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
 				    &rcClient,
-- 
1.7.7.1


[-- Attachment #24: 0023-hw-xwin-winshadgdi.c-fix-double-free.patch --]
[-- Type: application/octet-stream, Size: 662 bytes --]

From 76fc9f3e0eecbe27fd2ee7a30edad800635a416f Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:52:37 -0500
Subject: [PATCH 23/43] hw/xwin/winshadgdi.c: fix double-free

---
 hw/xwin/winshadgdi.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c
index 1e7cb00..6339010 100644
--- a/hw/xwin/winshadgdi.c
+++ b/hw/xwin/winshadgdi.c
@@ -270,7 +270,6 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen)
   else
     {
       ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
-      free (pbmih);
       fReturn = FALSE;
     }
 
-- 
1.7.7.1


[-- Attachment #25: 0024-hw-xwin-winwin32rootless.c-Fix-possible-null-ptr-der.patch --]
[-- Type: application/octet-stream, Size: 829 bytes --]

From 3718322fa2d651df9939029b74eb629a404de6a8 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:56:11 -0500
Subject: [PATCH 24/43] hw/xwin/winwin32rootless.c: Fix possible null ptr
 deref

---
 hw/xwin/winwin32rootless.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index 8f9917a..f9b9420 100644
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -551,7 +551,7 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
   winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
 #endif
 
-  if (pScreenPriv->fRestacking) return;
+  if (pScreenPriv && pScreenPriv->fRestacking) return;
 
   if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
 
-- 
1.7.7.1


[-- Attachment #26: 0025-hw-xwin-winwin32rootlesswindow.c-Fix-possible-null-p.patch --]
[-- Type: application/octet-stream, Size: 1232 bytes --]

From 0cf878d6788c2fc42fa3cefa5e400fea7e6d55e5 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:56:19 -0500
Subject: [PATCH 25/43] hw/xwin/winwin32rootlesswindow.c: Fix possible null
 ptr deref

---
 hw/xwin/winwin32rootlesswindow.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/winwin32rootlesswindow.c b/hw/xwin/winwin32rootlesswindow.c
index 214e895..fbff838 100644
--- a/hw/xwin/winwin32rootlesswindow.c
+++ b/hw/xwin/winwin32rootlesswindow.c
@@ -202,7 +202,8 @@ winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam)
   /* Check if the Windows window property for our X window pointer is valid */
   if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
     {
-      pScreen				= pRLWinPriv->pFrame->win->drawable.pScreen;
+      if (pRLWinPriv != NULL && pRLWinPriv->pFrame != NULL && pRLWinPriv->pFrame->win != NULL)
+        pScreen				= pRLWinPriv->pFrame->win->drawable.pScreen;
       if (pScreen) pScreenPriv		= winGetScreenPriv(pScreen);
       if (pScreenPriv) pScreenInfo	= pScreenPriv->pScreenInfo;
       if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
-- 
1.7.7.1


[-- Attachment #27: 0026-hw-xwin-winwin32rootless.c-remove-empty-if0.patch --]
[-- Type: application/octet-stream, Size: 827 bytes --]

From e1715664ee17485cdff079e95f9ab783177d619a Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 09:56:26 -0500
Subject: [PATCH 26/43] hw/xwin/winwin32rootless.c: remove empty if0

---
 hw/xwin/winwin32rootless.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index f9b9420..91399c2 100644
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -640,8 +640,6 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
       SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
 		    0, 0, 0, 0,
 		    SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
-#if 0
-#endif
     }
 #if CYGMULTIWINDOW_DEBUG
   winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
-- 
1.7.7.1


[-- Attachment #28: 0027-dix-registry.c-Free-old-memory-upon-realloc-failure.patch --]
[-- Type: application/octet-stream, Size: 778 bytes --]

From 631e4ef632ddddafc6a0f58e7ead6b0be6d6f830 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 28 Oct 2011 10:05:35 -0500
Subject: [PATCH 27/43] dix/registry.c: Free old memory upon realloc failure

---
 dix/registry.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/dix/registry.c b/dix/registry.c
index ba588c4..6505fc4 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -67,8 +67,14 @@ static int double_size(void *p, unsigned n, unsigned size)
 	s = 0;
 	n = f = BASE_SIZE * size;
     }
-
-    *ptr = realloc(*ptr, n);
+	{
+	    char * newptr = realloc(*ptr, n);
+	    if (!newptr) {
+	    	free(*ptr);
+	    }
+	    *ptr = newptr;
+	}
+    
     if (!*ptr) {
 	dixResetRegistry();
 	return FALSE;
-- 
1.7.7.1


[-- Attachment #29: 0028-os-access.c-Windows-non-cygwin-isn-t-just-mingw.patch --]
[-- Type: application/octet-stream, Size: 654 bytes --]

From 731348a546ba7d18e7d22d4168313b27234b1fff Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 3 Nov 2011 19:39:49 -0500
Subject: [PATCH 28/43] os/access.c: Windows non-cygwin isn't just mingw

---
 os/access.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/os/access.c b/os/access.c
index b7b1927..ca6b9d7 100644
--- a/os/access.c
+++ b/os/access.c
@@ -874,7 +874,7 @@ ResetHosts (char *display)
         FreeHost (host);
     }
 
-#if defined WIN32 && defined __MINGW32__
+#if defined(WIN32)&& !defined(__CYGWIN__)
 #define ETC_HOST_PREFIX "X"
 #else
 #define ETC_HOST_PREFIX "/etc/X"
-- 
1.7.7.1


[-- Attachment #30: 0029-os-utils.c-core-policy-needs-non-Windows-or-Cygwin.patch --]
[-- Type: application/octet-stream, Size: 747 bytes --]

From 597896074a2738b2d9fba57019c2d1a64b671f15 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 3 Nov 2011 19:41:20 -0500
Subject: [PATCH 29/43] os/utils.c: core policy needs non-Windows or Cygwin

---
 os/utils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/os/utils.c b/os/utils.c
index 12b9deb..1755bf8 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -660,7 +660,7 @@ ProcessCommandLine(int argc, char *argv[])
 	}
 	else if ( strcmp( argv[i], "-core") == 0)
 	{
-#if !defined(WIN32) || !defined(__MINGW32__)
+#if !defined(WIN32) || defined(__CYGWIN__)
 	    struct rlimit   core_limit;
 	    getrlimit (RLIMIT_CORE, &core_limit);
 	    core_limit.rlim_cur = core_limit.rlim_max;
-- 
1.7.7.1


[-- Attachment #31: 0030-os-utils.c-All-Windows-gets-GetTimeInMillis.patch --]
[-- Type: application/octet-stream, Size: 617 bytes --]

From bf67e5845f01f919c9100013fd06b3c1659e5b77 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Thu, 3 Nov 2011 19:42:05 -0500
Subject: [PATCH 30/43] os/utils.c: All Windows gets GetTimeInMillis

---
 os/utils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/os/utils.c b/os/utils.c
index 1755bf8..5b431c4 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -419,7 +419,7 @@ GiveUp(int sig)
     errno = olderrno;
 }
 
-#if (defined WIN32 && defined __MINGW32__) || defined(__CYGWIN__)
+#if defined(WIN32) || defined(__CYGWIN__)
 CARD32
 GetTimeInMillis (void)
 {
-- 
1.7.7.1


[-- Attachment #32: 0031-os-xdmcp.c-fix-_XSERVTransWSAStartup-warning.patch --]
[-- Type: application/octet-stream, Size: 551 bytes --]

From a8fc83bb4b861c08caec79d2e6b166da063023bd Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:10:33 -0500
Subject: [PATCH 31/43] os/xdmcp.c: fix _XSERVTransWSAStartup warning

---
 os/xdmcp.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/os/xdmcp.c b/os/xdmcp.c
index f5331e1..a7516cc 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -19,6 +19,8 @@
 
 #ifdef WIN32
 #include <X11/Xwinsock.h>
+#define XSERV_t
+#include <X11/Xtrans/Xtrans.h>
 #endif
 
 #include <X11/Xos.h>
-- 
1.7.7.1


[-- Attachment #33: 0032-dix-dispatch.c-os-utils.c-Disable-smart-scheduler-fo.patch --]
[-- Type: application/octet-stream, Size: 2638 bytes --]

From 67ca7659b8203ce78f661dd2875f4152d18dfa17 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 18:00:38 -0500
Subject: [PATCH 32/43] dix/dispatch.c, os/utils.c: Disable smart scheduler
 for windows non-cygwin

---
 dix/dispatch.c |    4 ++++
 os/utils.c     |    9 +++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/dix/dispatch.c b/dix/dispatch.c
index f8200b1..7bcda91 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -225,7 +225,11 @@ UpdateCurrentTimeIf(void)
 #define SMART_SCHEDULE_DEFAULT_INTERVAL	20	    /* ms */
 #define SMART_SCHEDULE_MAX_SLICE	200	    /* ms */
 
+#if defined(WIN32) && !defined(__CYGWIN__)
+Bool SmartScheduleDisable = TRUE;
+#else
 Bool SmartScheduleDisable = FALSE;
+#endif
 long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
 long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
 long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
diff --git a/os/utils.c b/os/utils.c
index 5b431c4..6fefdc6 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -75,6 +75,7 @@ __stdcall unsigned long GetTickCount(void);
 #if !defined(WIN32) || !defined(__MINGW32__)
 #include <sys/time.h>
 #include <sys/resource.h>
+# define HAVE_SMARTSCHEDULE
 #endif
 #include "misc.h"
 #include <X11/X.h>
@@ -907,10 +908,12 @@ ProcessCommandLine(int argc, char *argv[])
 	    i = skip - 1;
 	}
 #endif
+#ifdef HAVE_SMARTSCHEDULE
 	else if ( strcmp( argv[i], "-dumbSched") == 0)
 	{
 	    SmartScheduleDisable = TRUE;
 	}
+#endif
 	else if ( strcmp( argv[i], "-schedInterval") == 0)
 	{
 	    if (++i < argc)
@@ -1145,6 +1148,7 @@ XNFstrdup(const char *s)
 void
 SmartScheduleStopTimer (void)
 {
+#ifdef HAVE_SMARTSCHEDULE
     struct itimerval	timer;
     
     if (SmartScheduleDisable)
@@ -1154,11 +1158,13 @@ SmartScheduleStopTimer (void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = 0;
     (void) setitimer (ITIMER_REAL, &timer, 0);
+#endif
 }
 
 void
 SmartScheduleStartTimer (void)
 {
+#ifdef HAVE_SMARTSCHEDULE
     struct itimerval	timer;
     
     if (SmartScheduleDisable)
@@ -1168,6 +1174,7 @@ SmartScheduleStartTimer (void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = SmartScheduleInterval * 1000;
     setitimer (ITIMER_REAL, &timer, 0);
+#endif
 }
 
 static void
@@ -1179,6 +1186,7 @@ SmartScheduleTimer (int sig)
 void
 SmartScheduleInit (void)
 {
+#ifdef HAVE_SMARTSCHEDULE
     struct sigaction	act;
 
     if (SmartScheduleDisable)
@@ -1195,6 +1203,7 @@ SmartScheduleInit (void)
 	perror ("sigaction for smart scheduler");
 	SmartScheduleDisable = TRUE;
     }
+#endif
 }
 
 #ifdef SIG_BLOCK
-- 
1.7.7.1


[-- Attachment #34: 0033-include-misc.h-Add-simplified-defines-for-windowsnes.patch --]
[-- Type: application/octet-stream, Size: 975 bytes --]

From 29916288cc47eb81b1ec2bab2851f6fcafc94668 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 12:58:09 -0500
Subject: [PATCH 33/43] include/misc.h: Add simplified defines for windowsness

---
 include/misc.h |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/misc.h b/include/misc.h
index bdcc8cc..a876a10 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -81,6 +81,25 @@ OF THIS SOFTWARE.
 #include <stddef.h>
 #include <stdint.h>
 
+
+/* Simplified definitions describing varieties of Win32-ness */
+#if defined(__CYGWIN__)
+#define IS_WIN32_CYGWIN
+#undef IS_WIN32_NATIVE
+#define IS_WIN32_NATIVE_OR_CYGWIN
+
+#elif defined(WIN32)
+#undef IS_WIN32_CYGWIN
+#define IS_WIN32_NATIVE
+#define IS_WIN32_NATIVE_OR_CYGWIN
+
+#else
+#undef IS_WIN32_CYGWIN
+#undef IS_WIN32_NATIVE
+#undef IS_WIN32_NATIVE_OR_CYGWIN
+#endif
+
+
 #ifndef MAXSCREENS
 #define MAXSCREENS	16
 #endif
-- 
1.7.7.1


[-- Attachment #35: 0034-xkb-xkbInit.c-use-new-Win32-defines.patch --]
[-- Type: application/octet-stream, Size: 761 bytes --]

From faad4321970e2ae32f8e23a1db87651dcbcf9538 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:11:21 -0500
Subject: [PATCH 34/43] xkb/xkbInit.c: use new Win32 defines.

---
 xkb/xkbInit.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 3d3febb..4b255ae 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -685,7 +685,7 @@ XkbProcessArguments(int argc,char *argv[],int i)
 {
     if (strncmp(argv[i], "-xkbdir", 7) == 0) {
 	if(++i < argc) {
-#if !defined(WIN32) && !defined(__CYGWIN__)
+#ifndef IS_WIN32_NATIVE_OR_CYGWIN
 	    if (getuid() != geteuid()) {
 		LogMessage(X_WARNING, "-xkbdir is not available for setuid X servers\n");
 		return -1;
-- 
1.7.7.1


[-- Attachment #36: 0035-os-utils.c-New-win32-defines.patch --]
[-- Type: application/octet-stream, Size: 1280 bytes --]

From f611ec9984eded8b3d2c20ca3518f11e5dbd13f4 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 18:00:47 -0500
Subject: [PATCH 35/43] os/utils.c: New win32 defines

---
 os/utils.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/os/utils.c b/os/utils.c
index 6fefdc6..a50b6e2 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -63,20 +63,22 @@ OR PERFORMANCE OF THIS SOFTWARE.
 __stdcall unsigned long GetTickCount(void);
 #endif
 
-#if defined(WIN32) && !defined(__CYGWIN__)
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0501
-#endif
-#include <X11/Xwinsock.h>
+#ifdef IS_WIN32_NATIVE
+# ifndef _WIN32_WINNT
+#  define _WIN32_WINNT 0x0501
+# endif
+# include <X11/Xwinsock.h>
 #endif
 #include <X11/Xos.h>
 #include <stdio.h>
 #include <time.h>
-#if !defined(WIN32) || !defined(__MINGW32__)
-#include <sys/time.h>
-#include <sys/resource.h>
+#ifndef IS_WIN32_NATIVE
 # define HAVE_SMARTSCHEDULE
+
+# include <sys/time.h>
+# include <sys/resource.h>
 #endif
+
 #include "misc.h"
 #include <X11/X.h>
 #define XSERV_t
@@ -420,7 +422,7 @@ GiveUp(int sig)
     errno = olderrno;
 }
 
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef IS_WIN32_NATIVE_OR_CYGWIN
 CARD32
 GetTimeInMillis (void)
 {
-- 
1.7.7.1


[-- Attachment #37: 0036-miext-rootless-rootlessConfig.h-New-win32-defines.patch --]
[-- Type: application/octet-stream, Size: 905 bytes --]

From d66b5a281efe3ffdd094fedab6e63139d59f0cec Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:17:30 -0500
Subject: [PATCH 36/43] miext/rootless/rootlessConfig.h: New win32 defines

---
 miext/rootless/rootlessConfig.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index a6c0d25..85c8e21 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -48,7 +48,7 @@
 
 #endif /* __APPLE__ */
 
-#if defined(__CYGWIN__) || defined(WIN32)
+#ifdef IS_WIN32_NATIVE_OR_CYGWIN
 
 # define ROOTLESS_PROTECT_ALPHA NO
 # define ROOTLESS_REDISPLAY_DELAY 10
@@ -57,6 +57,6 @@
 
 # define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0)
 
-#endif /* __CYGWIN__ */
+#endif /* IS_WIN32_NATIVE_OR_CYGWIN */
 
 #endif /* _ROOTLESSCONFIG_H */
-- 
1.7.7.1


[-- Attachment #38: 0037-hw-xwin-winclipboard.h-Fix-duplicate-definition.patch --]
[-- Type: application/octet-stream, Size: 618 bytes --]

From 11e1f231ce4c4f836174e9038f8f8c80e5d9337c Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:17:50 -0500
Subject: [PATCH 37/43] hw/xwin/winclipboard.h: Fix duplicate definition

---
 hw/xwin/winclipboard.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/winclipboard.h b/hw/xwin/winclipboard.h
index 089c291..6b5249f 100644
--- a/hw/xwin/winclipboard.h
+++ b/hw/xwin/winclipboard.h
@@ -39,7 +39,6 @@
 #include <sys/select.h>
 #else
 #include <X11/Xwinsock.h>
-#define HAS_WINSOCK
 #endif
 #include <fcntl.h>
 #include <setjmp.h>
-- 
1.7.7.1


[-- Attachment #39: 0038-dix-registry.c-New-win32-defines.patch --]
[-- Type: application/octet-stream, Size: 1236 bytes --]

From 8e77a8bad3b5f99fa3b8607d36ba6095eadcfdf8 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:18:21 -0500
Subject: [PATCH 38/43] dix/registry.c: New win32 defines.

---
 dix/registry.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dix/registry.c b/dix/registry.c
index 6505fc4..fc80b93 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define CORE "X11"
 
 /* Should this actually be checking RELOCATE_PROJECTROOT ? */
-#if defined(WIN32) && !defined(__CYGWIN__)
+#ifdef IS_WIN32_NATIVE
 #define FILENAME_ONLY "protocol.txt"
 extern const char *winGetBaseDir(void);
 #endif
@@ -324,7 +324,7 @@ dixResetRegistry(void)
     /* Open the protocol file */
     if (fh)
 	fclose(fh);
-#if defined(WIN32) && !defined(__CYGWIN__)
+#ifdef IS_WIN32_NATIVE
     {
 	char filename[MAX_PATH];
 	snprintf(filename, sizeof(filename), "%s\\%s", winGetBaseDir(), FILENAME_ONLY);
@@ -334,7 +334,7 @@ dixResetRegistry(void)
     if (!fh) {
 #endif
     fh = fopen(FILENAME, "r");
-#if defined(WIN32) && !defined(__CYGWIN__)
+#ifdef IS_WIN32_NATIVE
 	}
 #endif
     if (!fh)
-- 
1.7.7.1


[-- Attachment #40: 0039-dix-dispatch.c-New-win32-defines.patch --]
[-- Type: application/octet-stream, Size: 720 bytes --]

From 1acc61f04b36a29d2d03e89e64148fdd530877a3 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:18:35 -0500
Subject: [PATCH 39/43] dix/dispatch.c: New win32 defines.

---
 dix/dispatch.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 7bcda91..bef62f0 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -225,7 +225,7 @@ UpdateCurrentTimeIf(void)
 #define SMART_SCHEDULE_DEFAULT_INTERVAL	20	    /* ms */
 #define SMART_SCHEDULE_MAX_SLICE	200	    /* ms */
 
-#if defined(WIN32) && !defined(__CYGWIN__)
+#ifdef IS_WIN32_NATIVE
 Bool SmartScheduleDisable = TRUE;
 #else
 Bool SmartScheduleDisable = FALSE;
-- 
1.7.7.1


[-- Attachment #41: 0040-os-utils.c-include-misc.h.patch --]
[-- Type: application/octet-stream, Size: 606 bytes --]

From 7a36439cfe6c0ede3dd1e48f1912b13644ac4680 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:21:42 -0500
Subject: [PATCH 40/43] os/utils.c: include misc.h

Needed to make the new Win32 defines available.
---
 os/utils.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/os/utils.c b/os/utils.c
index a50b6e2..f2f04dc 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -53,6 +53,8 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #include <dix-config.h>
 #endif
 
+#include <misc.h>
+
 #ifdef __CYGWIN__
 #include <stdlib.h>
 #include <signal.h>
-- 
1.7.7.1


[-- Attachment #42: 0041-configure.ac-mingw-doesn-t-have-setuid-either.patch --]
[-- Type: application/octet-stream, Size: 754 bytes --]

From f9ba736acf4ad2f39f27471ffec2cc349087c000 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:26:14 -0500
Subject: [PATCH 41/43] configure.ac: mingw doesn't have setuid either.

Fixes having to pass this flag for a successful MinGW build.
---
 configure.ac |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index cf3d80b..af78235 100644
--- a/configure.ac
+++ b/configure.ac
@@ -670,6 +670,7 @@ AC_MSG_CHECKING([to see if we can install the Xorg server as root])
 if test "x$SETUID" = "xauto" ; then
 	case $host_os in
 	    cygwin*)		SETUID="no"  ;;
+	    mingw*)			SETUID="no"  ;;
 	    darwin*)		SETUID="no"  ;;
 	    *)
 	   	case $host_cpu in
-- 
1.7.7.1


[-- Attachment #43: 0042-configure.ac-auto-disable-MITSHM-if-we-lack-IPC.patch --]
[-- Type: application/octet-stream, Size: 2014 bytes --]

From 981f4e720d014663bf1123ce755b611cfa30cda5 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:30:43 -0500
Subject: [PATCH 42/43] configure.ac: auto-disable MITSHM if we lack IPC

The MITSHM extension uses SYSV IPC, but even if configure's test
for IPC failed, MITSHM was still enabled by default, breaking
MinGW builds by default.
---
 configure.ac |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index af78235..6de0c9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -608,7 +608,7 @@ AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Pa
 dnl Extensions.
 AC_ARG_ENABLE(registry,       AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
-AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
+AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: auto)]), [MITSHM=$enableval], [MITSHM=auto])
 AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
 AC_ARG_ENABLE(record,         AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
 AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
@@ -966,6 +966,9 @@ if test "x$COMPOSITE" = xyes; then
 	COMPOSITE_INC='-I$(top_srcdir)/composite'
 fi
 
+if test "x$MITSHM" = xauto; then
+	MITSHM="$HAVE_SYSV_IPC"
+fi
 AM_CONDITIONAL(MITSHM, [test "x$MITSHM" = xyes])
 if test "x$MITSHM" = xyes; then
 	AC_DEFINE(MITSHM, 1, [Support MIT-SHM extension])
-- 
1.7.7.1


[-- Attachment #44: 0043-configure.ac-Fix-typo-in-extension-flag-help.patch --]
[-- Type: application/octet-stream, Size: 1653 bytes --]

From 002a1c678aedd3d232caadf4c77c1b2398b9ba4f Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Fri, 4 Nov 2011 13:31:09 -0500
Subject: [PATCH 43/43] configure.ac: Fix typo in extension flag help

The help said it was --disable-shm when that isn't actually what
you had to pass to get it to work.
---
 configure.ac |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6de0c9d..bee0f72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -608,7 +608,7 @@ AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Pa
 dnl Extensions.
 AC_ARG_ENABLE(registry,       AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
-AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: auto)]), [MITSHM=$enableval], [MITSHM=auto])
+AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-mitshm], [Build SHM extension (default: auto)]), [MITSHM=$enableval], [MITSHM=auto])
 AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
 AC_ARG_ENABLE(record,         AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
 AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
-- 
1.7.7.1


[-- Attachment #45: Type: text/plain, Size: 223 bytes --]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-04 23:39   ` Ryan Pavlik
@ 2011-11-07 18:10     ` Jon TURNEY
  2011-11-07 19:36       ` Charles Wilson
  2011-11-10 16:50       ` Ryan Pavlik
  0 siblings, 2 replies; 11+ messages in thread
From: Jon TURNEY @ 2011-11-07 18:10 UTC (permalink / raw)
  To: cygwin-xfree; +Cc: rpavlik

On 04/11/2011 23:39, Ryan Pavlik wrote:
> On Thu, Nov 3, 2011 at 2:18 PM, Jon TURNEY wrote:
>> On 01/11/2011 20:39, Ryan Pavlik wrote:
>>> specific and probably more appropriate than the overall xorg lists.
>>> I wanted to build a native windows X server (essentially an
>>> open-source Xming). I had to patch a number of the packages along the
>>> way, but did eventually arrive at a build that worked.  I looked at
>>> and used a few of the Xming patches, but only generally went to those
>>> when the naive approach didn't work.
>>
>> This may be a problem.
>>
>> The material on the Xming website is licensed under a Creative Commons license, which is not compatible with the X11 license.  So, patches from the Xming website are not acceptable unless the author has agreed to re-license them appropriately.
>
> I emailed him and he indicated that he already has a process worked
> out for re-licensing a patch at a time to submit to you.
>
> As such, I have re-worked my patch queue to remove all patches derived
> from the Xming web site. It doesn't add everything that the previous
> branch did, but it does build and start to work, and all these patches
> are licensed like the X11 source itself as they are my work.  I also
> re-worked the commit messages and patches a bit, and added some
> additional patches.

Okay, thank you.

> https://github.com/rpavlik/Xserver/tree/cleanpatches-1.11-branch
>
>> I've quickly looked over these patches and in general they look good, and I'd be happy to help get them merged upstream.
>>
>> A couple of general points I'd make though:
>>
>> It helps a great deal in reviewing if the comments state why the change is a good idea (e.g. what problem it fixes), rather than just describing the change which is made.
>
> I've revised the commit messages for xorg-server accordingly -
> hopefully these are better.
>
>>
>> I also noticed that a bit more care might be needed with the define you are using to enable platform specific code: WIN32 and __MINGW__ should not be used interchangeably.  WIN32 will also be defined when building VcXsrv, and neither is defined on Cygwin.
>>
>
> Ah, true. I have gone through and improved this in my cleanpatches
> branch, and have also added some convenience defines to make this
> easier to get right - this is the last half of the commits.

I see what you are trying to do here, but I'm not sure it actually adds any 
clarity.

I think I'd just prefer to assume the knowledge that WIN32 and CYGWIN are 
mutually exclusive, so '#if defined(WIN32) && !defined(__CYGWIN__)' can just 
be written '#ifdef WIN32'

>> So, can you post your patches here, preferably in git-send-email format so we can review them in detail?
>
> I wasn't sure if you wanted one email per patch, and 43 emails seemed
> like an awful lot, so I've attached them all (git format-patch) to
> this one. If you prefer, I can send them individually to this (or
> another) list with git send-email.  These are just the xserver
> patches, not the ones for other packages that I mentioned in the
> mingw-cross-env repository.

Sorry, I should have mentioned this before, but please can you add a 
'Signed-off-by' line to these (git commit --amend --signoff will add one for you)

A few comments, I'll take a deeper look later:

0001-os-osinit.c-Exclude-new-signal-sigaction-code-on-non.patch

Shouldn't this be X_NOT_POSIX rather than X_NO_POSIX?

0006-hw-xwin-Makefile.am-Include-manifest-in-the-dist-tar.patch

Good catch! :-)

0009-os-utils.c-Use-winxp-or-better-for-Winsock-API.patch

I am a bit unclear why this is needed, surely the winsock API predates XP?
It might be better to add this define to CFLAGS rather than to start 
sprinkling it around source files as needed?

0013-hw-xwin-InitOutput.c-Remove-duplicated-code-for-sett.patch

Comment should probably say 'Consolidate duplicate code' rather than 'Remove'

It seems this changes more than that, though, as it now looks for the files in 
both PROJECTROOT and basedir?

0017-dix-registry.c-non-cygwin-find-protocol.txt-in-reloc.patch

I think the answer to the question 'Should this actually be checking 
RELOCATE_PROJECTROOT ?' is yes

I think it would probably be neater to do something like arrange for FILENAME 
to start with the platform-appropriate path separator, rather than to define 
FILENAME_ONLY as the same name without an initial path separator?

0027-dix-registry.c-Free-old-memory-upon-realloc-failure.patch

Interesting.

It would probably be useful to quote the language from the appropriate 
standard which describes the behavior of realloc() in this error case in the 
comment.

I don't think this change is fully correct however.  If the realloc'ed size is 
0, realloc() may return NULL, but the previously allocated memory has been 
freed.  Perhaps you need to check if errno has been set by realloc to 
distinguish these two cases?

Did you notice this by inspection or actually have a problem caused by this 
code? Have you audited the rest of the xserver code for this class of error?

0041-configure.ac-mingw-doesn-t-have-setuid-either.patch

Use whitespace consistently with the context, please

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-07 18:10     ` Jon TURNEY
@ 2011-11-07 19:36       ` Charles Wilson
  2011-11-09 18:46         ` Jon TURNEY
  2011-11-10 16:50       ` Ryan Pavlik
  1 sibling, 1 reply; 11+ messages in thread
From: Charles Wilson @ 2011-11-07 19:36 UTC (permalink / raw)
  To: cygwin-xfree

On 11/7/2011 1:10 PM, Jon TURNEY wrote:
> I see what you are trying to do here, but I'm not sure it actually adds
> any clarity.
> 
> I think I'd just prefer to assume the knowledge that WIN32 and CYGWIN
> are mutually exclusive, so '#if defined(WIN32) && !defined(__CYGWIN__)'
> can just be written '#ifdef WIN32'

But this isn't true if you ever #include any of the w32api headers. Then
you get WIN32 defined, even on cygwin...

windef.h:

#ifndef WIN32
#define WIN32
#endif
#ifndef _WIN32
#define _WIN32
#endif

--
Chuck

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-07 19:36       ` Charles Wilson
@ 2011-11-09 18:46         ` Jon TURNEY
  2011-11-09 19:11           ` Charles Wilson
  0 siblings, 1 reply; 11+ messages in thread
From: Jon TURNEY @ 2011-11-09 18:46 UTC (permalink / raw)
  To: cygwin-xfree

On 07/11/2011 19:36, Charles Wilson wrote:
> On 11/7/2011 1:10 PM, Jon TURNEY wrote:
>> I see what you are trying to do here, but I'm not sure it actually adds
>> any clarity.
>>
>> I think I'd just prefer to assume the knowledge that WIN32 and CYGWIN
>> are mutually exclusive, so '#if defined(WIN32)&&  !defined(__CYGWIN__)'
>> can just be written '#ifdef WIN32'
>
> But this isn't true if you ever #include any of the w32api headers. Then
> you get WIN32 defined, even on cygwin...

True.  I guess what I meant to say is that there isn't any compiler which 
defines both WIN32 and CYGWIN (I hope :-)).

Any portable code which includes w32api headers before checking if WIN32 is 
defined isn't going to be very portable :-)

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-09 18:46         ` Jon TURNEY
@ 2011-11-09 19:11           ` Charles Wilson
       [not found]             ` <CABMFTE8wrNqbNLX+jmd7WcxT-xqfxYctB-ZgmxfwBg38_g5xmw@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Charles Wilson @ 2011-11-09 19:11 UTC (permalink / raw)
  To: cygwin-xfree

On 11/9/2011 1:46 PM, Jon TURNEY wrote:
> On 07/11/2011 19:36, Charles Wilson wrote:
>> But this isn't true if you ever #include any of the w32api headers. Then
>> you get WIN32 defined, even on cygwin...
>
> True. I guess what I meant to say is that there isn't any compiler which
> defines both WIN32 and CYGWIN (I hope :-)).
>
> Any portable code which includes w32api headers before checking if WIN32
> is defined isn't going to be very portable :-)

But it's perfectly portable to check for __CYGWIN__ (or, for that 
matter, __MINGW32__) instead of WIN32 before #including w32api headers, 
because you know that the windows API will be available in those cases 
as well.

The difference is, IF you do this (perfectly fine, legal, and portable) 
thing:

#if defined(WIN32) || defined(__CYGWIN__)
# include <windows.h>
#endif

then you can no longer rely on

#if defined(WIN32)
...stuff that applies only for truly "native" windows (e.g.
...msvc or mingw), but not cygwin
#endif

even though both hunks above are legal and make perfect sense *in 
isolation*.  The problem occurs when both hunks are present in the same 
translation unit -- and that's not always under your control.  What if 
libjpeg's header does the first hunk (it doesn't, but assume that it 
does for argument's sake), and your project's headers only do the second?

You *think* you're safe in assuming that WIN32 == !__CYGWIN__, 
but...#include <jpeg.h> breaks all your assumptions.  But jpeg.h *did 
nothing wrong*.

It's better to be explicit.

--
Chuck



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-07 18:10     ` Jon TURNEY
  2011-11-07 19:36       ` Charles Wilson
@ 2011-11-10 16:50       ` Ryan Pavlik
  2011-11-22  2:55         ` SeongNam Oh
  2012-01-09 19:31         ` Jon TURNEY
  1 sibling, 2 replies; 11+ messages in thread
From: Ryan Pavlik @ 2011-11-10 16:50 UTC (permalink / raw)
  To: cygwin-xfree

On Mon, Nov 7, 2011 at 12:10 PM, Jon TURNEY <jon.turney@dronecode.org.uk> wrote:
> Sorry, I should have mentioned this before, but please can you add a
> 'Signed-off-by' line to these (git commit --amend --signoff will add one for
> you)
>
> A few comments, I'll take a deeper look later:
>
> 0001-os-osinit.c-Exclude-new-signal-sigaction-code-on-non.patch
>
> Shouldn't this be X_NOT_POSIX rather than X_NO_POSIX?

Good catch, thanks!

>
> 0006-hw-xwin-Makefile.am-Include-manifest-in-the-dist-tar.patch
>
> Good catch! :-)
>

Yeah, notices this when trying to build for tarballs.

> 0009-os-utils.c-Use-winxp-or-better-for-Winsock-API.patch
>
> I am a bit unclear why this is needed, surely the winsock API predates XP?
> It might be better to add this define to CFLAGS rather than to start
> sprinkling it around source files as needed?
>

Yes, but one of the calls in that file uses a part of the winsock API
introduced in XP - getaddrinfo and freeaddrinfo.
http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/ws2tcpip.h?rev=1.12&content-type=text/x-cvsweb-markup&cvsroot=src

> 0013-hw-xwin-InitOutput.c-Remove-duplicated-code-for-sett.patch
>
> Comment should probably say 'Consolidate duplicate code' rather than
> 'Remove'
>
> It seems this changes more than that, though, as it now looks for the files
> in both PROJECTROOT and basedir?
>
> 0017-dix-registry.c-non-cygwin-find-protocol.txt-in-reloc.patch
>
> I think the answer to the question 'Should this actually be checking
> RELOCATE_PROJECTROOT ?' is yes
>

The catch here is that RELOCATE_PROJECTROOT is currently (added by me,
since it wasn't in any header except the unused autogenerated one) in
xwin-config.h. Would it be appropriate to move it to dix-config.h for
this purpose?

> I think it would probably be neater to do something like arrange for
> FILENAME to start with the platform-appropriate path separator, rather than
> to define FILENAME_ONLY as the same name without an initial path separator?
>

The difference is not just the path separator - the FILENAME also
includes the macro define (string literal) of the install location,
which is concatenated with the filename by the preprocessor.

> 0027-dix-registry.c-Free-old-memory-upon-realloc-failure.patch
>
> Interesting.
>
> It would probably be useful to quote the language from the appropriate
> standard which describes the behavior of realloc() in this error case in the
> comment.
>
> I don't think this change is fully correct however.  If the realloc'ed size
> is 0, realloc() may return NULL, but the previously allocated memory has
> been freed.  Perhaps you need to check if errno has been set by realloc to
> distinguish these two cases?
>
> Did you notice this by inspection or actually have a problem caused by this
> code? Have you audited the rest of the xserver code for this class of error?
>

Good point. I found this with cppcheck - a static analysis tool that,
despite its name, is useful for C code as well. There were other
issues it mentioned in the xserver code, but I didn't get to any of
the others yet. In any case, it's a completely orthogonal patch. Might
be useful for someone more familiar with the code to run cppcheck and
address the issues.

> 0041-configure.ac-mingw-doesn-t-have-setuid-either.patch
>
> Use whitespace consistently with the context, please

Oops - will correct.

>
> --
> Jon TURNEY
> Volunteer Cygwin/X X Server maintainer
>



-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik@iastate.edu
http://academic.cleardefinition.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
       [not found]             ` <CABMFTE8wrNqbNLX+jmd7WcxT-xqfxYctB-ZgmxfwBg38_g5xmw@mail.gmail.com>
@ 2011-11-10 22:58               ` Charles Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Charles Wilson @ 2011-11-10 22:58 UTC (permalink / raw)
  To: Ryan Pavlik; +Cc: cygwin-xfree

On 11/10/2011 11:29 AM, Ryan Pavlik wrote:
> On Wed, Nov 9, 2011 at 1:11 PM, Charles Wilson  wrote:
>> You *think* you're safe in assuming that WIN32 == !__CYGWIN__,
>> but...#include<jpeg.h>  breaks all your assumptions.  But jpeg.h *did
>> nothing wrong*.
>>
>> It's better to be explicit.
>>
>> --
>> Chuck
>
> OK, so this leads me to the next question: The existing codebase has
> substantial numbers of places with #if defined(WIN32) - do these all
> imply #if defined(WIN32)&&  !defined(__CYGWIN__) ?

That I don't know.

> I generally
> avoided touching things I didn't have to,

A good policy.

> but this may be worth
> clarifying codebase-wide.

Perhaps -- I'll leave that call to others. I suspect a global patch that 
affected only #if lines should be a separate patch from any other 
changes, if taking this action was desirable.

--
Chuck

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-10 16:50       ` Ryan Pavlik
@ 2011-11-22  2:55         ` SeongNam Oh
  2012-01-09 19:31         ` Jon TURNEY
  1 sibling, 0 replies; 11+ messages in thread
From: SeongNam Oh @ 2011-11-22  2:55 UTC (permalink / raw)
  To: cygwin-xfree

Ryan Pavlik <rpavlik <at> iastate.edu> writes:

> 
> On Mon, Nov 7, 2011 at 12:10 PM, Jon TURNEY <jon.turney <at> dronecode.org.uk>
wrote:
> > Sorry, I should have mentioned this before, but please can you add a
> > 'Signed-off-by' line to these (git commit --amend --signoff will add one for
> > you)
> >
> > A few comments, I'll take a deeper look later:
> >
> > 0001-os-osinit.c-Exclude-new-signal-sigaction-code-on-non.patch
> >
> > Shouldn't this be X_NOT_POSIX rather than X_NO_POSIX?
> 
> Good catch, thanks!
> 
> >
> > 0006-hw-xwin-Makefile.am-Include-manifest-in-the-dist-tar.patch
> >
> > Good catch! 
> >
> 
> Yeah, notices this when trying to build for tarballs.
> 
> > 0009-os-utils.c-Use-winxp-or-better-for-Winsock-API.patch
> >
> > I am a bit unclear why this is needed, surely the winsock API predates XP?
> > It might be better to add this define to CFLAGS rather than to start
> > sprinkling it around source files as needed?
> >
> 
> Yes, but one of the calls in that file uses a part of the winsock API
> introduced in XP - getaddrinfo and freeaddrinfo.
>
http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/ws2tcpip.h?rev=1.12&content-type=text/x-cvsweb-markup&cvsroot=src
> 
> > 0013-hw-xwin-InitOutput.c-Remove-duplicated-code-for-sett.patch
> >
> > Comment should probably say 'Consolidate duplicate code' rather than
> > 'Remove'
> >
> > It seems this changes more than that, though, as it now looks for the files
> > in both PROJECTROOT and basedir?
> >
> > 0017-dix-registry.c-non-cygwin-find-protocol.txt-in-reloc.patch
> >
> > I think the answer to the question 'Should this actually be checking
> > RELOCATE_PROJECTROOT ?' is yes
> >
> 
> The catch here is that RELOCATE_PROJECTROOT is currently (added by me,
> since it wasn't in any header except the unused autogenerated one) in
> xwin-config.h. Would it be appropriate to move it to dix-config.h for
> this purpose?
> 
> > I think it would probably be neater to do something like arrange for
> > FILENAME to start with the platform-appropriate path separator, rather than
> > to define FILENAME_ONLY as the same name without an initial path separator?
> >
> 
> The difference is not just the path separator - the FILENAME also
> includes the macro define (string literal) of the install location,
> which is concatenated with the filename by the preprocessor.
> 
> > 0027-dix-registry.c-Free-old-memory-upon-realloc-failure.patch
> >
> > Interesting.
> >
> > It would probably be useful to quote the language from the appropriate
> > standard which describes the behavior of realloc() in this error case in the
> > comment.
> >
> > I don't think this change is fully correct however.  If the realloc'ed size
> > is 0, realloc() may return NULL, but the previously allocated memory has
> > been freed.  Perhaps you need to check if errno has been set by realloc to
> > distinguish these two cases?
> >
> > Did you notice this by inspection or actually have a problem caused by this
> > code? Have you audited the rest of the xserver code for this class of error?
> >
> 
> Good point. I found this with cppcheck - a static analysis tool that,
> despite its name, is useful for C code as well. There were other
> issues it mentioned in the xserver code, but I didn't get to any of
> the others yet. In any case, it's a completely orthogonal patch. Might
> be useful for someone more familiar with the code to run cppcheck and
> address the issues.
> 
> > 0041-configure.ac-mingw-doesn-t-have-setuid-either.patch
> >
> > Use whitespace consistently with the context, please
> 
> Oops - will correct.
> 
> >
> > --
> > Jon TURNEY
> > Volunteer Cygwin/X X Server maintainer
> >
> 

I have successfully built XWin with some Xming project patches( manually adopted
line by line after understanding the purpose) on MINGW environment and also
activated GLX. not AIGLX yet because I couldn't find a way to build swrast
driver of Mesa with xlib option, but server side is activated. 

I am finalizing my built, and I am facing on an issue point.

1. in MINGW environment, I could successfully compile xkeyboard-config 1.3
version package, but higher version is failed.

below is an error message from version 2.3
interesting thing is "xkbcomp -lfhlpR -o compat.dir '*'" command doesn't
generate the compat.dir file and even command from 1.3 also doesn't generate the
file when I manually wrote in MINGW shell.

but 1.3 version is working in script operation in the shell.

why I am trying to do this is to figure out an root error point after calling
XSync() command in XMesaSwapBuffers() which is the last call after rendering 3D
objects.
Now, XWin is working fine before calling the command and the command is
generating "BadRequest" and I believe that it comes from Xi module and then
digging the root cause. ( to clean out a possibility because I used too old
xkeyboard-config )

***********************************************************
[ Client End ]
seongnam@Panda ~/build/bin
$ ./GLlesson05.exe
Got Doublebuffered Visual!
glX-Version 1.4
Resolution 600x600
Depth 24
Congrats, you have Direct Rendering!
X Error:  BadRequest
  Request Major code 0 ()
  Error Serial #35
  Current Serial #38

***********************************************************
[ Server End ] 
REPLY: ClientIDX: 4 Xerror: Code: 0x1 resID: 0xffffffe6 maj: 0x0 min: 0
REQUEST: ClientIDX: 4, type: 0x0 data: 0x0 len: 0
REPLY: ClientIDX: 4 Xerror: Code: 0x1 resID: 0xffffffe6 maj: 0x0 min: 0
REPLY: ClientIDX: 1 XEvent: type: 0x12 detail: 0x0 seq#: 0x19
REPLY: ClientIDX: 1 XEvent: type: 0x11 detail: 0x0 seq#: 0x19

***********************************************************
[ xkeyboard-config error message ]
  xkeyboard-config is configured with the following parameters:
    XKB base directory: ${datarootdir}/X11/xkb
    Symbolic link(s) to legacy rules are not created
    Compatibility rules are included
***********************************************************
Making all in compat
make[1]: Entering directory `/home/seongnam/src/xkeyboard-config-2.3/compat'
rm -f compat.dir
/home/seongnam/build/bin/xkbcomp -lfhlpR -o compat.dir '*'
make[1]: *** [compat.dir] Error 1
make[1]: Leaving directory `/home/seongnam/src/xkeyboard-config-2.3/compat'
make: *** [all-recursive] Error 1
build.sh: "make " failed on xkeyboard-config/xkeyboard-config
build.sh: error processing module/component:  "xkeyboard-config/xkeyboard-config




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Built XWin on mingw - with patches
  2011-11-10 16:50       ` Ryan Pavlik
  2011-11-22  2:55         ` SeongNam Oh
@ 2012-01-09 19:31         ` Jon TURNEY
  1 sibling, 0 replies; 11+ messages in thread
From: Jon TURNEY @ 2012-01-09 19:31 UTC (permalink / raw)
  To: cygwin-xfree; +Cc: Ryan Pavlik

On 10/11/2011 16:50, Ryan Pavlik wrote:
> On Mon, Nov 7, 2011 at 12:10 PM, Jon TURNEY wrote:
>> 0009-os-utils.c-Use-winxp-or-better-for-Winsock-API.patch
>>
>> I am a bit unclear why this is needed, surely the winsock API predates XP?
>> It might be better to add this define to CFLAGS rather than to start
>> sprinkling it around source files as needed?
> 
> Yes, but one of the calls in that file uses a part of the winsock API
> introduced in XP - getaddrinfo and freeaddrinfo.
> http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/ws2tcpip.h?rev=1.12&content-type=text/x-cvsweb-markup&cvsroot=src

In my build testing, this only seems to be a problem if you explicitly
./configure the X server with --enable-ipv6, and in that case other build
problems exist as well (No inet_pton/inet_ntop, inclusion of ws2tcpip.h is needed)

(Ideally, if you were to ./configure with CFLAGS=-D_WIN32_WINNT=0x0501, IPv6
should be auto-detected by ./configure and build successfully.  But this
auto-detection doesn't work, because AC_CHECK_FUNC(getaddrinfo) fails because
the test program generated doesn't prototype getaddrinfo, so it doesn't look
for it with stdcall mangling...)

So it seems there are a couple of generic problems here, so I'm not sure
fixing it like this is the right thing to do.

>> 0027-dix-registry.c-Free-old-memory-upon-realloc-failure.patch
>>
>> Interesting.
>>
>> It would probably be useful to quote the language from the appropriate
>> standard which describes the behavior of realloc() in this error case in the
>> comment.
>>
>> I don't think this change is fully correct however.  If the realloc'ed size
>> is 0, realloc() may return NULL, but the previously allocated memory has
>> been freed.  Perhaps you need to check if errno has been set by realloc to
>> distinguish these two cases?
>>
>> Did you notice this by inspection or actually have a problem caused by this
>> code? Have you audited the rest of the xserver code for this class of error?
> 
> Good point. I found this with cppcheck - a static analysis tool that,
> despite its name, is useful for C code as well. There were other
> issues it mentioned in the xserver code, but I didn't get to any of
> the others yet. In any case, it's a completely orthogonal patch. Might
> be useful for someone more familiar with the code to run cppcheck and
> address the issues.

Since it's outside my area of expertise to do a good review, I'd suggest you
post this patch (when you have it in a correct form) directly to xorg-devel.

>> 0041-configure.ac-mingw-doesn-t-have-setuid-either.patch
>>
>> Use whitespace consistently with the context, please
> 
> Oops - will correct.

Looking at this again, I'm a bit puzzled by the comment "Fixes having to pass
this flag for a successful MinGW build"

I can understand adding MinGW to the set of targets which don't have setuid
binaries, but I'm not sure how the MinGW build can fail if this flag isn't
supplied: INSTALL_SETUID appears to only apply to installing the Xorg DDX.

Is the real bug here that the test immediately below this assumes that we are
not cross-compiling?  Should the test check for cross-compiling and assume
setuid binaries are possible unless it's on the list of excluded targets?

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-01-09 19:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-01 20:40 Built XWin on mingw - with patches Ryan Pavlik
2011-11-03 19:18 ` Jon TURNEY
2011-11-04 23:39   ` Ryan Pavlik
2011-11-07 18:10     ` Jon TURNEY
2011-11-07 19:36       ` Charles Wilson
2011-11-09 18:46         ` Jon TURNEY
2011-11-09 19:11           ` Charles Wilson
     [not found]             ` <CABMFTE8wrNqbNLX+jmd7WcxT-xqfxYctB-ZgmxfwBg38_g5xmw@mail.gmail.com>
2011-11-10 22:58               ` Charles Wilson
2011-11-10 16:50       ` Ryan Pavlik
2011-11-22  2:55         ` SeongNam Oh
2012-01-09 19:31         ` Jon TURNEY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).