xserver: Branch 'XACE-SELINUX' - 9 commits

Eamon Walsh ewalsh at kemper.freedesktop.org
Thu Dec 13 21:32:47 PST 2007


 .gitignore                            |    1 
 configure.ac                          |   79 ++++------------------------------
 hw/xfree86/common/xf86Mode.c          |   48 --------------------
 hw/xfree86/common/xf86str.h           |    1 
 hw/xfree86/modes/xf86Modes.c          |   69 ++++++++++++++++++++---------
 hw/xfree86/modes/xf86Modes.h          |    5 ++
 hw/xquartz/Makefile.am                |    6 ++
 hw/xquartz/bundle/Makefile.am         |   11 +++-
 hw/xquartz/bundle/org.x.X11.plist.in  |   23 ---------
 hw/xquartz/bundle/org.x.X11.plist.pre |   23 +++++++++
 hw/xquartz/x11-exec.c                 |   74 +++++++++++++++++++++++++++++++
 11 files changed, 179 insertions(+), 161 deletions(-)

New commits:
commit 86b2e59bfb79bd042a13c35fbb4ccecec576f629
Merge: 1c1a4bc... cb0d7e2...
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Fri Dec 14 00:32:24 2007 -0500

    Merge branch 'master' into XACE-SELINUX
    
    Conflicts:
    
    	configure.ac
    
    This is the last pull before merging to master.

diff --cc configure.ac
index 8dae13f,090a0f5..49d57d7
--- a/configure.ac
+++ b/configure.ac
@@@ -468,21 -475,18 +468,19 @@@ AC_ARG_WITH(xkb-path,         AS_HELP_S
  AC_ARG_WITH(xkb-output,       AS_HELP_STRING([--with-xkb-output=PATH], [Path to XKB output dir (default: ${datadir}/X11/xkb/compiled)]),
  				[ XKBOUTPUT="$withval" ],
  				[ XKBOUTPUT="compiled" ])
 -AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH], [Path to server config (default: ${libdir}/xserver)]),
 +AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH],
 +				   [Directory where ancillary server config files are installed (default: ${libdir}/xorg)]),
  				[ SERVERCONFIG="$withval" ],
 -				[ SERVERCONFIG="${libdir}/xserver" ])
 +				[ SERVERCONFIG="${libdir}/xorg" ])
- APPLE_APPLICATIONS_DIR="/Applications/Utilities"
  AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
- 				[ APPLE_APPLICATIONS_DIR="${withval}" ].
+ 				[ APPLE_APPLICATIONS_DIR="${withval}" ],
  				[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
- 
+ AC_SUBST([APPLE_APPLICATIONS_DIR])
  AC_ARG_WITH(launchd,          AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
- 
- AC_ARG_WITH(pci-txt-ids-dir, AS_HELP_STRING([--with-pci-txt-ids-dir=PATH],
- [Path to pci id directory (default: ${datadir}/X11/pci)]),
- 				[ PCI_TXT_IDS_DIR="$withval" ],
- 				[ PCI_TXT_IDS_DIR="${datadir}/X11/pci" ])
+ AC_ARG_WITH(launchagents-dir,AS_HELP_STRING([--with-launchagents-dir=PATH], [Path to launchd's LaunchAgents directory (default: /Library/LaunchAgents)]),
+ 				[ launchagentsdir="${withval}" ],
+ 				[ launchagentsdir="/Library/LaunchAgents" ])
+ AC_SUBST([launchagentsdir])
  AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
                                  [BUILDDOCS=$enableval],
                                  [BUILDDOCS=no])
commit cb0d7e2c2692a332e2bd5495478ebf9a6cd601d0
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 13 16:23:46 2007 -0800

    Xquartz: Don't hardcode libexec dir
    (cherry picked from commit 67b479ef80cb740a24981335eb8d596744168a62)

diff --git a/configure.ac b/configure.ac
index cb31524..090a0f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2118,7 +2118,6 @@ hw/xnest/Makefile
 hw/xwin/Makefile
 hw/xquartz/Makefile
 hw/xquartz/bundle/Makefile
-hw/xquartz/bundle/org.x.X11.plist
 hw/xquartz/xpr/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ati/Makefile
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 612a7d8..97b8c94 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -1,7 +1,3 @@
-libexec_PROGRAMS = x11-exec
-
-x11_exec_LDFLAGS = -framework ApplicationServices
-
 noinst_LTLIBRARIES = libXquartz.la
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
@@ -13,6 +9,12 @@ AM_CPPFLAGS = \
 
 if X11APP
 X11APP_SUBDIRS = bundle
+
+if LAUNCHD
+libexec_PROGRAMS = x11-exec
+x11_exec_LDFLAGS = -framework ApplicationServices
+endif
+
 endif
 
 SUBDIRS = . xpr $(X11APP_SUBDIRS)
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 8aa2357..775e1aa 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -9,7 +9,14 @@ install-data-hook:
 	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
 
 if LAUNCHD
-launchagents_DATA = org.x.X11.plist
+launchagents_PRE = org.x.X11.plist.pre
+launchagents_DATA = $(launchagents_PRE:plist.pre=plist)
+
+CPP_FILES_FLAGS = -D__libexecdir__="${libexecdir}"
+
+CLEANFILES = $(launchagents_DATA)
+
+include $(top_srcdir)/cpprules.in
 endif
 
 clean-local:
diff --git a/hw/xquartz/bundle/org.x.X11.plist b/hw/xquartz/bundle/org.x.X11.plist
deleted file mode 100644
index 1e646ac..0000000
--- a/hw/xquartz/bundle/org.x.X11.plist
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>/usr/libexec/x11-exec</string>
-		<string>-launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
diff --git a/hw/xquartz/bundle/org.x.X11.plist.pre b/hw/xquartz/bundle/org.x.X11.plist.pre
new file mode 100644
index 0000000..83d8b2f
--- /dev/null
+++ b/hw/xquartz/bundle/org.x.X11.plist.pre
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>__libexecdir__/x11-exec</string>
+		<string>-launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
commit c39212fd7353fc1a07a30bade90f78356c748e2d
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 13 15:56:31 2007 -0800

    Xquartz: Don't hardcode LaunchAgents dir
    (cherry picked from commit 07a12d71fefd78c380078efa835700f2868ab204)

diff --git a/configure.ac b/configure.ac
index b56c115..cb31524 100644
--- a/configure.ac
+++ b/configure.ac
@@ -478,17 +478,15 @@ AC_ARG_WITH(xkb-output,       AS_HELP_STRING([--with-xkb-output=PATH], [Path to
 AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH], [Path to server config (default: ${libdir}/xserver)]),
 				[ SERVERCONFIG="$withval" ],
 				[ SERVERCONFIG="${libdir}/xserver" ])
-APPLE_APPLICATIONS_DIR="/Applications/Utilities"
 AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
-				[ APPLE_APPLICATIONS_DIR="${withval}" ].
+				[ APPLE_APPLICATIONS_DIR="${withval}" ],
 				[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
-
+AC_SUBST([APPLE_APPLICATIONS_DIR])
 AC_ARG_WITH(launchd,          AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
-
-AC_ARG_WITH(pci-txt-ids-dir, AS_HELP_STRING([--with-pci-txt-ids-dir=PATH],
-[Path to pci id directory (default: ${datadir}/X11/pci)]),
-				[ PCI_TXT_IDS_DIR="$withval" ],
-				[ PCI_TXT_IDS_DIR="${datadir}/X11/pci" ])
+AC_ARG_WITH(launchagents-dir,AS_HELP_STRING([--with-launchagents-dir=PATH], [Path to launchd's LaunchAgents directory (default: /Library/LaunchAgents)]),
+				[ launchagentsdir="${withval}" ],
+				[ launchagentsdir="/Library/LaunchAgents" ])
+AC_SUBST([launchagentsdir])
 AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
                                 [BUILDDOCS=$enableval],
                                 [BUILDDOCS=no])
@@ -1709,7 +1707,6 @@ if test "x$XQUARTZ" = xyes; then
 	DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
 	AC_SUBST([DARWIN_LIBS])
 	AC_CHECK_LIB([Xplugin],[xp_init],[:])
-	AC_SUBST([APPLE_APPLICATIONS_DIR])
 	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
 	if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
 		AC_MSG_NOTICE([Disabling XF86Misc extension])
@@ -1759,73 +1756,20 @@ if test "x$X11APP" = xauto; then
 fi
 AM_CONDITIONAL(X11APP,[test "X$X11APP" = Xyes]) 
 
-if test "x$LAUNCHD" = xauto; then
-	# Do we want to have this default to on for Xquartz builds only or any time we have launchd (like Xnest or Xvfb on OS-X)
-	#AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
-	AC_MSG_CHECKING([whether to support launchd])
-	if test "x$XQUARTZ" = xyes ; then
+if test "x$LAUNCHD" = "xauto"; then
+	if test "x$XQUARTZ" = "xyes" ; then
 		LAUNCHD=yes
 	else
-		LAUNCHD=no
+		AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
 	fi
-	AC_MSG_RESULT([$LAUNCHD])
-fi
-AM_CONDITIONAL(LAUNCHD, [test "x$LAUNCHD" = xyes])
-
-dnl DMX DDX
-
-AC_MSG_CHECKING([whether to build Xdmx DDX])
-PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfixes xfont xi dmxproto xau $XDMCP_MODULES], [have_dmx=yes], [have_dmx=no])
-if test "x$DMX" = xauto; then
-	DMX="$have_dmx"
 fi
 AC_MSG_RESULT([$DMX])
 AM_CONDITIONAL(DMX, [test "x$DMX" = xyes])
 
-if test "x$DMX" = xyes; then
-	if test "x$have_dmx" = xno; then
-		AC_MSG_ERROR([Xdmx build explicitly requested, but required
-		              modules not found.])
-	fi
-	DMX_INCLUDES="$XEXT_INC $RENDER_INC $XTRAP_INC $RECORD_INC"
-	XDMX_CFLAGS="$DMXMODULES_CFLAGS"
-	XDMX_LIBS="$XEXT_LIB $FB_LIB $CONFIG_LIB $RENDER_LIB $XTRAP_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB"
-	XDMX_SYS_LIBS="$DMXMODULES_LIBS"
-	AC_SUBST([XDMX_CFLAGS])
-	AC_SUBST([XDMX_LIBS])
-	AC_SUBST([XDMX_SYS_LIBS])
-
-dnl USB sources in DMX require <linux/input.h>
-	AC_CHECK_HEADER([linux/input.h], DMX_BUILD_USB="yes",
-			DMX_BUILD_USB="no")
-dnl Linux sources in DMX require <linux/keyboard.h>
-	AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
-			DMX_BUILD_LNX="no")
-	if test "x$GLX" = xyes; then
-		PKG_CHECK_MODULES([GL], [glproto])
-	fi
-	PKG_CHECK_MODULES([XDMXCONFIG_DEP], [xaw7 xmu xt xpm x11])
-	AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
-	AC_SUBST(XDMXCONFIG_DEP_LIBS)
-	PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [dmx xext x11])
-	AC_SUBST(DMXEXAMPLES_DEP_LIBS)
-	PKG_CHECK_MODULES([DMXXMUEXAMPLES_DEP], [dmx xmu xext x11])
-	AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
-	PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [dmx xi xext x11])
-	AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
-	PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [xtst xext x11])
-	AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
-	PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres xext x11])
-	AC_SUBST(XRESEXAMPLES_DEP_LIBS)
-	PKG_CHECK_MODULES([X11EXAMPLES_DEP], [xext x11])
-	AC_SUBST(X11EXAMPLES_DEP_LIBS)
-fi
-AM_CONDITIONAL([DMX_BUILD_LNX], [test "x$DMX_BUILD_LNX" = xyes])
-AM_CONDITIONAL([DMX_BUILD_USB], [test "x$DMX_BUILD_USB" = xyes])
-if test "x$LAUNCHD" = xyes ; then
+if test "x$LAUNCHD" = "xyes" ; then
 	AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
 fi
-AM_CONDITIONAL(LAUNCHD, [test "x$LAUNCHD" = xyes])
+AM_CONDITIONAL(LAUNCHD, [test "x$LAUNCHD" = "xyes"])
 
 dnl kdrive DDX
 
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 5734434..8aa2357 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -7,9 +7,9 @@ x11app:
 
 install-data-hook:
 	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+
 if LAUNCHD
-	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
-	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
+launchagents_DATA = org.x.X11.plist
 endif
 
 clean-local:
commit 82e1aff9fbc1d15e3451707e3ccbf4b13eedda94
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 15:57:39 2007 -0800

    Modified X11 plist to use x11-exec
    (cherry picked from commit 7d9a11329e476f45e4d9f9aebcb43469321347c7)

diff --git a/.gitignore b/.gitignore
index 37f35f4..2e60d58 100644
--- a/.gitignore
+++ b/.gitignore
@@ -275,7 +275,6 @@ hw/xprint/doc/Xprt.1x
 hw/xprint/doc/Xprt.man
 hw/xprint/dpmsstubs-wrapper.c
 hw/xprint/miinitext-wrapper.c
-hw/xquartz/bundle/org.x.X11.plist
 include/dix-config.h
 include/kdrive-config.h
 include/xgl-config.h
diff --git a/hw/xquartz/bundle/org.x.X11.plist b/hw/xquartz/bundle/org.x.X11.plist
new file mode 100644
index 0000000..1e646ac
--- /dev/null
+++ b/hw/xquartz/bundle/org.x.X11.plist
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>/usr/libexec/x11-exec</string>
+		<string>-launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/org.x.X11.plist.in b/hw/xquartz/bundle/org.x.X11.plist.in
deleted file mode 100644
index 26eca96..0000000
--- a/hw/xquartz/bundle/org.x.X11.plist.in
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>@APPLE_APPLICATIONS_DIR@/X11.app/Contents/MacOS/X11</string>
-		<string>-launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
commit 1a5910588a60af0c136595e2457d897d9e54ac88
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 15:55:28 2007 -0800

    created x11-exec wrapper, which uses LaunchServices to find
    (and then exec) X11.app
    (cherry picked from commit fc04c9759b30d062111d4a7f3f411ed0f18cbde4)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 831ba49..612a7d8 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -1,3 +1,7 @@
+libexec_PROGRAMS = x11-exec
+
+x11_exec_LDFLAGS = -framework ApplicationServices
+
 noinst_LTLIBRARIES = libXquartz.la
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
diff --git a/hw/xquartz/x11-exec.c b/hw/xquartz/x11-exec.c
new file mode 100644
index 0000000..d0b5c49
--- /dev/null
+++ b/hw/xquartz/x11-exec.c
@@ -0,0 +1,74 @@
+/* x11-exec.c -- Find X11.app by bundle-id and exec it.  This is so launchd
+   can correctly find X11.app, even if the user moved it.
+
+ Copyright (c) 2007 Apple, Inc.
+ 
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ 
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+
+#include <ApplicationServices/ApplicationServices.h>
+#include <stdio.h>
+
+#define kX11AppBundleId "org.x.X11"
+#define kX11AppBundlePath "/Contents/MacOS/X11"
+
+int main(int argc, char **argv) {
+  char x11_path[PATH_MAX];
+  CFURLRef appURL = NULL;
+  OSStatus osstatus = 
+    LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), 
+			     nil, nil, &appURL);
+  
+  switch (osstatus) {
+  case noErr:
+    if (appURL == NULL) {
+      fprintf(stderr, "%s: Invalid response from LSFindApplicationForInfo(%s)\n", 
+	      argv[0], kX11AppBundleId);
+      exit(1);
+    }
+    if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
+      fprintf(stderr, "%s: Error resolving URL for %s\n", argv[0], kX11AppBundleId);
+      exit(2);
+    }
+    strlcpy(argv[0], "X11", strlen(argv[0])+1);
+    strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
+//  fprintf(stderr, "X11.app = %s\n", x11_path);
+    execv(x11_path, argv);
+    fprintf(stderr, "Error executing X11.app (%s):", x11_path);
+    perror(NULL);
+    exit(3);
+    break;
+  case kLSApplicationNotFoundErr:
+    fprintf(stderr, "%s: Unable to find application for %s\n", argv[0], kX11AppBundleId);
+    exit(4);
+  default:
+    fprintf(stderr, "%s: Unable to find application for %s, error code = %d\n", 
+	    argv[0], kX11AppBundleId, osstatus);
+    exit(5);
+  }
+  /* not reached */
+}
+
+    
commit efcdc0d7010f4e6ec833842cb010a07068edf7ab
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Dec 13 15:38:41 2007 -0500

    Correct the documentation comments in xf86Modes.c
    
    Most of those functions do not, in fact, work with circular mode lists,
    and by this point the API isn't really "proposed" anymore.

diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index 3febd37..3d222cc 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -339,12 +339,10 @@ xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
 /**
  * Marks as bad any modes with unsupported flags.
  *
- * \param modeList doubly-linked or circular list of modes.
+ * \param modeList doubly-linked list of modes.
  * \param flags flags supported by the driver.
  *
  * \bug only V_INTERLACE and V_DBLSCAN are supported.  Is that enough?
- *
- * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
 _X_EXPORT void
 xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
@@ -363,9 +361,7 @@ xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 /**
  * Marks as bad any modes extending beyond the given max X, Y, or pitch.
  *
- * \param modeList doubly-linked or circular list of modes.
- *
- * This is not in xf86Modes.c, but would be part of the proposed new API.
+ * \param modeList doubly-linked list of modes.
  */
 _X_EXPORT void
 xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
@@ -392,9 +388,7 @@ xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
  * Marks as bad any modes that aren't supported by the given monitor's
  * hsync and vrefresh ranges.
  *
- * \param modeList doubly-linked or circular list of modes.
- *
- * This is not in xf86Modes.c, but would be part of the proposed new API.
+ * \param modeList doubly-linked list of modes.
  */
 _X_EXPORT void
 xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
@@ -436,12 +430,10 @@ xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 /**
  * Marks as bad any modes extending beyond outside of the given clock ranges.
  *
- * \param modeList doubly-linked or circular list of modes.
+ * \param modeList doubly-linked list of modes.
  * \param min pointer to minimums of clock ranges
  * \param max pointer to maximums of clock ranges
  * \param n_ranges number of ranges.
- *
- * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
 _X_EXPORT void
 xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList,
@@ -474,9 +466,7 @@ xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList,
  *
  * MODE_BAD is used as the rejection flag, for lack of a better flag.
  *
- * \param modeList doubly-linked or circular list of modes.
- *
- * This is not in xf86Modes.c, but would be part of the proposed new API.
+ * \param modeList doubly-linked list of modes.
  */
 _X_EXPORT void
 xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList)
@@ -506,7 +496,7 @@ xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList)
 /**
  * Marks as bad any modes exceeding the given bandwidth.
  *
- * \param modeList doubly-linked or circular list of modes.
+ * \param modeList doubly-linked list of modes.
  * \param bandwidth bandwidth in MHz.
  * \param depth color depth.
  */
@@ -528,8 +518,6 @@ xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList,
  * \param modeList pointer to a doubly-linked or circular list of modes.
  * \param verbose determines whether the reason for mode invalidation is
  *	  printed.
- *
- * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
 _X_EXPORT void
 xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
commit 1768af38c737f4c14d32f587b51a8ec3d3d6ed5f
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Dec 13 15:06:18 2007 -0500

    Add infrastructure for validating modes by memory bandwidth.

diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index 544276b..782f08b 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -183,6 +183,8 @@ xf86ModeStatusToString(ModeStatus status)
         return "all modes must have the same resolution";
     case MODE_NO_REDUCED:
         return "monitor doesn't support reduced blanking";
+    case MODE_BANDWIDTH:
+	return "mode requires too much memory bandwidth";
     case MODE_BAD:
 	return "unknown reason";
     case MODE_ERROR:
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index af98b4f..2e02135 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -125,6 +125,7 @@ typedef enum {
     MODE_ONE_HEIGHT,    /* only one height is supported */
     MODE_ONE_SIZE,      /* only one resolution is supported */
     MODE_NO_REDUCED,    /* monitor doesn't accept reduced blanking */
+    MODE_BANDWIDTH,	/* mode requires too much memory bandwidth */
     MODE_BAD = -2,	/* unspecified reason */
     MODE_ERROR	= -1	/* error condition */
 } ModeStatus;
diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index 12ee6e0..3febd37 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -118,6 +118,24 @@ xf86ModeHeight (DisplayModePtr mode, Rotation rotation)
     }
 }
 
+/** Calculates the memory bandwidth (in MiB/sec) of a mode. */
+_X_EXPORT unsigned int
+xf86ModeBandwidth(DisplayModePtr mode, int depth)
+{
+    float a_active, a_total, active_percent, pixels_per_second;
+    int bytes_per_pixel = (depth + 7) / 8;
+
+    if (!mode->HTotal || !mode->VTotal || !mode->Clock)
+	return 0;
+
+    a_active = mode->HDisplay * mode->VDisplay;
+    a_total = mode->HTotal * mode->VTotal;
+    active_percent = a_active / a_total;
+    pixels_per_second = active_percent * mode->Clock * 1000.0;
+
+    return (unsigned int)(pixels_per_second * bytes_per_pixel / (1024 * 1024));
+}
+
 /** Sets a default mode name of <width>x<height> on a mode. */
 _X_EXPORT void
 xf86SetModeDefaultName(DisplayModePtr mode)
@@ -486,6 +504,25 @@ xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList)
 
 
 /**
+ * Marks as bad any modes exceeding the given bandwidth.
+ *
+ * \param modeList doubly-linked or circular list of modes.
+ * \param bandwidth bandwidth in MHz.
+ * \param depth color depth.
+ */
+_X_EXPORT void
+xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList,
+			   unsigned int bandwidth, int depth)
+{
+    DisplayModePtr mode;
+
+    for (mode = modeList; mode != NULL; mode = mode->next) {
+	if (xf86ModeBandwidth(mode, depth) > bandwidth)
+	    mode->status = MODE_BANDWIDTH;
+    }
+}
+
+/**
  * Frees any modes from the list with a status other than MODE_OK.
  *
  * \param modeList pointer to a doubly-linked or circular list of modes.
diff --git a/hw/xfree86/modes/xf86Modes.h b/hw/xfree86/modes/xf86Modes.h
index 3722d25..9ad5ee6 100644
--- a/hw/xfree86/modes/xf86Modes.h
+++ b/hw/xfree86/modes/xf86Modes.h
@@ -42,6 +42,7 @@
 
 double xf86ModeHSync(DisplayModePtr mode);
 double xf86ModeVRefresh(DisplayModePtr mode);
+unsigned int xf86ModeBandwidth(DisplayModePtr mode, int depth);
 
 int
 xf86ModeWidth (DisplayModePtr mode, Rotation rotation);
@@ -79,6 +80,10 @@ xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 		      MonPtr mon);
 
 void
+xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList,
+			   unsigned int bandwidth, int depth);
+
+void
 xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
 		      Bool verbose);
 
commit 4359193aaa522599c502d012b9c163e993c01d79
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Dec 13 10:59:48 2007 -0500

    Explain a confusing #ifdef.

diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index 3879b91..12ee6e0 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -38,12 +38,14 @@
 
 extern XF86ConfigPtr xf86configptr;
 
-/**
- * @file this file contains symbols from xf86Mode.c and friends that are static
- * there but we still want to use.  We need to come up with better API here.
+/*
+ * This is the version number where we epoched.  These files get copied
+ * into drivers that want to use this setup infrastructure on pre-1.3
+ * servers, so when that happens they need to define these symbols
+ * themselves.  However, _in_ the server, we basically always define them now.
  */
-
 #if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0)
+
 /**
  * Calculates the horizontal sync rate of a mode.
  *
commit 8cedbb0a53d47b12f03edb726db9d5879c8a63a4
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Dec 13 10:57:35 2007 -0500

    Clean up some #if 0.

diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index 7fcce10..544276b 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -368,52 +368,6 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
     return MODE_OK;
 }
 
-#if 0
-/** Calculates the horizontal sync rate of a mode */
-_X_EXPORT double
-xf86ModeHSync(DisplayModePtr mode)
-{
-    double hsync = 0.0;
-    
-    if (mode->HSync > 0.0)
-	    hsync = mode->HSync;
-    else if (mode->HTotal > 0)
-	    hsync = (float)mode->Clock / (float)mode->HTotal;
-
-    return hsync;
-}
-
-/** Calculates the vertical refresh rate of a mode */
-_X_EXPORT double
-xf86ModeVRefresh(DisplayModePtr mode)
-{
-    double refresh = 0.0;
-
-    if (mode->VRefresh > 0.0)
-	refresh = mode->VRefresh;
-    else if (mode->HTotal > 0 && mode->VTotal > 0) {
-	refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal;
-	if (mode->Flags & V_INTERLACE)
-	    refresh *= 2.0;
-	if (mode->Flags & V_DBLSCAN)
-	    refresh /= 2.0;
-	if (mode->VScan > 1)
-	    refresh /= (float)(mode->VScan);
-    }
-    return refresh;
-}
-
-/** Sets a default mode name of <width>x<height> on a mode. */
-_X_EXPORT void
-xf86SetModeDefaultName(DisplayModePtr mode)
-{
-    if (mode->name != NULL)
-	xfree(mode->name);
-
-    mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay);
-}
-#endif
-
 /*
  * xf86LookupMode
  *


More information about the xorg-commit mailing list