Skip to content

Commit

Permalink
From Jeremy Huddleston:
Browse files Browse the repository at this point in the history
1) Fixed a bug where XQUARTZ was #defined when auto but not when --enable-xquartz
2) Cleaned up missing #includes and function prototypes.
3) Fixed some invalid C syntax problems
4) Removed a bunch of dead code
5) Cleaned up code to prevent some warnings
6) Bugfix in xpr/x-hook.c - looks like someone just forgot to finish writing code for hook_remove()... I only noticed it because gcc -Wall complained about reaching the end of a non-void function... lucky for us gcc is smarter than we are.
  • Loading branch information
Ben Byer authored and Jeremy Huddleston committed Nov 19, 2007
1 parent 815bf67 commit 213b517
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 172 deletions.
21 changes: 11 additions & 10 deletions configure.ac
Expand Up @@ -1610,23 +1610,14 @@ if test "X$XQUARTZ" = Xauto; then
LDFLAGS=$save_LDFLAGS])

if test "X$xorg_cv_Carbon_framework" = Xyes; then
AC_DEFINE([XQUARTZ],[1],[Have Quartz])
XQUARTZ=yes
else
XQUARTZ=no
fi
fi

if test "x$XQUARTZ" = xyes; then
if test "x$X11APP" = xauto; then
AC_MSG_CHECKING([whether to build X11.app])
if test "x$XQUARTZ" = xyes ; then
X11APP=yes
else
X11APP=no
fi
AC_MSG_RESULT([$X11APP])
fi
AC_DEFINE([XQUARTZ],[1],[Have Quartz])

# glxAGL / glxCGL don't work yet
# AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
Expand Down Expand Up @@ -1669,6 +1660,16 @@ if test "x$XQUARTZ" = xyes; then
fi
fi

if test "x$X11APP" = xauto; then
AC_MSG_CHECKING([whether to build X11.app])
if test "x$XQUARTZ" = xyes ; then
X11APP=yes
else
X11APP=no
fi
AC_MSG_RESULT([$X11APP])
fi

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])
Expand Down
5 changes: 0 additions & 5 deletions dix/main.c
Expand Up @@ -260,11 +260,6 @@ main(int argc, char *argv[], char *envp[])
/* Quartz support on Mac OS X requires that the Cocoa event loop be in
* the main thread. This allows the X server main to be called again
* from another thread. */

/* TODO: Put some runtime conditioning on this, so it doesn't get
* executed by Xvfb, Xnest, Xfake, Xephyr, etc when built at the same
* time as Xquartz
*/
DarwinHandleGUI(argc, argv, envp);
#endif

Expand Down
2 changes: 1 addition & 1 deletion hw/darwin/Makefile.am
@@ -1,5 +1,5 @@
AM_CFLAGS = @XORG_CFLAGS@
AM_CPPFLAGS = @XORG_INCS@ -I../../miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ
AM_CPPFLAGS = @XORG_INCS@ -I$(top_srcdir)/Xext -I$(top_srcdir)/miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ

SUBDIRS = quartz utils

Expand Down
6 changes: 5 additions & 1 deletion hw/darwin/apple/X11Application.m
Expand Up @@ -47,6 +47,10 @@
#include <unistd.h>
#include <pthread.h>

#include "rootlessCommon.h"

WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c

#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"

int X11EnableKeyEquivalents = TRUE;
Expand Down Expand Up @@ -577,7 +581,7 @@ - (int) prefs_get_boolean:(NSString *)key default:(int)def
ret = CFBooleanGetValue (value);
else if (CFGetTypeID (value) == CFStringGetTypeID ())
{
const char *tem = [(NSString *) value lossyCString];
const char *tem = [(NSString *) value UTF8String];
if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
ret = YES;
else
Expand Down
37 changes: 32 additions & 5 deletions hw/darwin/darwin.c
Expand Up @@ -69,6 +69,11 @@
#include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/ev_keymap.h>

#ifdef MITSHM
#define _XSHM_SERVER_
#include <X11/extensions/XShm.h>
#endif

#include "darwin.h"
#include "darwinClut8.h"

Expand Down Expand Up @@ -186,7 +191,9 @@ static Bool DarwinAddScreen(

// allocate space for private per screen storage
dfb = xalloc(sizeof(DarwinFramebufferRec));
SCREEN_PRIV(pScreen) = dfb;

// SCREEN_PRIV(pScreen) = dfb;
pScreen->devPrivates[darwinScreenIndex].ptr = dfb;

// setup hardware/mode specific details
ret = DarwinModeAddScreen(foundIndex, pScreen);
Expand Down Expand Up @@ -342,7 +349,7 @@ static int DarwinMouseProc(
DeviceIntPtr pPointer,
int what )
{
char map[6];
CARD8 map[6];

switch (what) {

Expand Down Expand Up @@ -699,10 +706,30 @@ void ddxInitGlobals(void)
*/
int ddxProcessArgument( int argc, char *argv[], int i )
{
int numDone;
if ( !strcmp( argv[i], "-fullscreen" ) ) {
ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
return 1;
}

if ( !strcmp( argv[i], "-rootless" ) ) {
ErrorF( "Running rootless inside Mac OS X window server.\n" );
return 1;
}

if ((numDone = DarwinModeProcessArgument( argc, argv, i )))
return numDone;
if ( !strcmp( argv[i], "-quartz" ) ) {
ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
return 1;
}

// The Mac OS X front end uses this argument, which we just ignore here.
if ( !strcmp( argv[i], "-nostartx" ) ) {
return 1;
}

// This command line arg is passed when launched from the Aqua GUI.
if ( !strncmp( argv[i], "-psn_", 5 ) ) {
return 1;
}

if ( !strcmp( argv[i], "-fakebuttons" ) ) {
darwinFakeButtons = TRUE;
Expand Down
1 change: 0 additions & 1 deletion hw/darwin/darwin.h
Expand Up @@ -72,7 +72,6 @@ Bool DarwinModeAddScreen(int index, ScreenPtr pScreen);
Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen);
void DarwinModeInitOutput(int argc,char **argv);
void DarwinModeInitInput(int argc, char **argv);
int DarwinModeProcessArgument(int argc, char *argv[], int i);
void DarwinModeProcessEvent(xEvent *xe);
void DarwinModeGiveUp(void);
void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
Expand Down
2 changes: 1 addition & 1 deletion hw/darwin/darwinEvents.c
Expand Up @@ -235,7 +235,7 @@ static void DarwinUpdateModifiers(
void DarwinReleaseModifiers(void) {
KeySym *map = NULL;
xEvent ke;
int i = 0, j = 0, nevents = 0;
int i = 0;

DEBUG_LOG("DarwinReleaseModifiers(%p)\n", &keyInfo.keyMap);

Expand Down
2 changes: 1 addition & 1 deletion hw/darwin/quartz/Makefile.am
Expand Up @@ -2,7 +2,7 @@ noinst_LIBRARIES = libXQuartz.a

AM_CFLAGS = @XORG_CFLAGS@
AM_OBJCFLAGS = @XORG_CFLAGS@
AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H
AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../apple -I$(top_srcdir)/miext/rootless @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H

SUBDIRS = cr fullscreen xpr

Expand Down
1 change: 1 addition & 0 deletions hw/darwin/quartz/applewm.c
Expand Up @@ -47,6 +47,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define _APPLEWM_SERVER_
#include "X11/extensions/applewmstr.h"
#include "applewmExt.h"
#include "X11Application.h"

#define DEFINE_ATOM_HELPER(func,atom_name) \
static Atom func (void) { \
Expand Down
7 changes: 6 additions & 1 deletion hw/darwin/quartz/quartz.c
Expand Up @@ -40,11 +40,14 @@
#include "X11/extensions/applewm.h"
#include "applewmExt.h"

#include "X11Application.h"

// X headers
#include "scrnintstr.h"
#include "windowstr.h"
#include "colormapst.h"
#include "globals.h"
#include "rootlessWindow.h"

// System headers
#include <sys/types.h>
Expand Down Expand Up @@ -111,7 +114,9 @@ Bool DarwinModeAddScreen(
{
// allocate space for private per screen Quartz specific storage
QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1);
QUARTZ_PRIV(pScreen) = displayInfo;

// QUARTZ_PRIV(pScreen) = displayInfo;
pScreen->devPrivates[quartzScreenIndex].ptr = displayInfo;

// do Quartz mode specific initialization
return quartzProcs->AddScreen(index, pScreen);
Expand Down
2 changes: 0 additions & 2 deletions hw/darwin/quartz/quartz.h
Expand Up @@ -124,6 +124,4 @@ typedef struct _QuartzModeProcs {
extern QuartzModeProcsPtr quartzProcs;
extern int quartzHasRoot, quartzEnableRootless;

Bool QuartzLoadDisplayBundle(const char *dpyBundleName);

#endif
140 changes: 3 additions & 137 deletions hw/darwin/quartz/quartzStartup.c
Expand Up @@ -40,14 +40,10 @@ char **envpGlobal; // argcGlobal and argvGlobal
// are from dix/globals.c


void X11ControllerMain(int argc, char *argv[],
void (*server_thread) (void *), void *server_arg);
void GlxExtensionInit(void);
void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr);
void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);

static void server_thread (void *arg) {
extern int main(int argc, char **argv, char **envp);

exit (main (argcGlobal, argvGlobal, envpGlobal));
}

Expand All @@ -65,7 +61,7 @@ void DarwinHandleGUI(
char *envp[] )
{
static Bool been_here = FALSE;
int main_exit, i;
int i;
int fd[2];

if (been_here) {
Expand Down Expand Up @@ -107,135 +103,5 @@ void DarwinHandleGUI(

_InitHLTB();
X11ControllerMain(argc, argv, server_thread, NULL);
exit(main_exit);
}

/*
* QuartzLoadDisplayBundle
* Try to load the appropriate bundle containing the back end display code.
*/
Bool QuartzLoadDisplayBundle(
const char *dpyBundleName)
{
return TRUE;
}


/*
* LoadGlxBundle
* The Quartz mode X server needs to dynamically load the appropriate
* bundle before initializing GLX.
*/
static void LoadGlxBundle(void)
{
CFBundleRef mainBundle;
CFStringRef bundleName;
CFURLRef bundleURL;
CFBundleRef glxBundle;

// Get the main bundle for the application
mainBundle = CFBundleGetMainBundle();

// Choose the bundle to load
ErrorF("Loading GLX bundle ");
if (/*quartzUseAGL*/0) {
bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
quartzOpenGLBundle,
kCFStringEncodingASCII,
kCFAllocatorNull);
ErrorF("%s (using Apple's OpenGL)\n", quartzOpenGLBundle);
} else {
bundleName = CFSTR("glxMesa.bundle");
CFRetain(bundleName); // so we can release later
ErrorF("glxMesa.bundle (using Mesa)\n");
}

// Look for the appropriate GLX bundle in the main bundle by name
bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
NULL, NULL);
if (!bundleURL) {
FatalError("Could not find GLX bundle.");
}

// Make a bundle instance using the URLRef
glxBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);

if (!CFBundleLoadExecutable(glxBundle)) {
FatalError("Could not load GLX bundle.");
}

// Find the GLX init functions
if (!GlxExtensionInit || !GlxWrapInitVisuals) {
FatalError("Could not initialize GLX bundle.");
}

// Release the CF objects
CFRelease(bundleName);
CFRelease(bundleURL);
}


/*
* DarwinGlxExtensionInit
* Initialize the GLX extension.
*/
void DarwinGlxPushProvider(void *impl)
{
GlxPushProvider(impl);
}

/*
* DarwinGlxExtensionInit
* Initialize the GLX extension.
*/
void DarwinGlxExtensionInit(void)
{
GlxExtensionInit();
}


/*
* DarwinGlxWrapInitVisuals
*/
void DarwinGlxWrapInitVisuals(
miInitVisualsProcPtr *procPtr)
{
if (!GlxWrapInitVisuals)
LoadGlxBundle();
GlxWrapInitVisuals(procPtr);
}


int DarwinModeProcessArgument( int argc, char *argv[], int i )
{
// fullscreen: CoreGraphics full-screen mode
// rootless: Cocoa rootless mode
// quartz: Default, either fullscreen or rootless

if ( !strcmp( argv[i], "-fullscreen" ) ) {
ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
return 1;
}

if ( !strcmp( argv[i], "-rootless" ) ) {
ErrorF( "Running rootless inside Mac OS X window server.\n" );
return 1;
}

if ( !strcmp( argv[i], "-quartz" ) ) {
ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
return 1;
}

// The Mac OS X front end uses this argument, which we just ignore here.
if ( !strcmp( argv[i], "-nostartx" ) ) {
return 1;
}

// This command line arg is passed when launched from the Aqua GUI.
if ( !strncmp( argv[i], "-psn_", 5 ) ) {
return 1;
}

return 0;
exit(0);
}
2 changes: 1 addition & 1 deletion hw/darwin/quartz/xpr/appledri.c
Expand Up @@ -175,7 +175,7 @@ ProcAppleDRIAuthConnection(
rep.authenticated = 1;

if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
ErrorF("Failed to authenticate %u\n", stuff->magic);
ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
rep.authenticated = 0;
}
WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
Expand Down

0 comments on commit 213b517

Please sign in to comment.