Merge branch 'master' into mpx

This commit is contained in:
Peter Hutterer 2008-05-26 17:37:31 +09:30
commit 26c1958c32
155 changed files with 34604 additions and 13167 deletions

View file

@ -2,7 +2,7 @@ noinst_LTLIBRARIES = libCGLCore.la
AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/GL/glx \
-I$(top_srcdir)/glx \
-I$(top_srcdir)/GL/include \
-I$(top_srcdir)/GL/mesa/glapi \
-I$(top_srcdir)/hw/xquartz \

View file

@ -87,7 +87,7 @@ typedef long long GLint64EXT;
// ggs: needed to call back to glx with visual configs
extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
__GLXprovider * GlxGetMesaProvider (void);
__GLXprovider * GlxGetDRISWrastProvider (void);
// Write debugging output, or not
#ifdef GLAQUA_DEBUG
@ -120,17 +120,17 @@ static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, un
static CGLPixelFormatObj makeFormat(__GLXconfig *mode);
__GLXprovider __glXMesaProvider = {
__GLXprovider __glXDRISWRastProvider = {
__glXAquaScreenProbe,
"Core OpenGL",
NULL
};
__GLXprovider *
GlxGetMesaProvider (void)
GlxGetDRISWRastProvider (void)
{
GLAQUA_DEBUG_MSG("GlxGetMesaProvider\n");
return &__glXMesaProvider;
GLAQUA_DEBUG_MSG("GlxGetDRISWRastProvider\n");
return &__glXDRISWRastProvider;
}
typedef struct __GLXAquaScreen __GLXAquaScreen;

View file

@ -45,9 +45,6 @@
#include "X11/extensions/applewm.h"
#include "micmap.h"
#include "os.h"
#include "mach-startup/launchd_fd.h"
#include <mach/mach.h>
#include <unistd.h>
@ -815,14 +812,6 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
/* Tell the server thread that it can proceed */
QuartzInitServer(argc, argv, envp);
#ifndef NEW_LAUNCH_METHOD
/* Start listening on the launchd fd */
int launchd_fd = launchd_display_fd();
if(launchd_fd != -1) {
DarwinListenOnOpenFD(launchd_fd);
}
#endif
[NSApp run];
/* not reached */
}

View file

@ -675,15 +675,6 @@ void OsVendorInit(void)
}
/*
* ddxInitGlobals
* Called by InitGlobals() from os/util.c.
*/
void ddxInitGlobals(void)
{
}
/*
* ddxProcessArgument
* Process device-dependent command line args. Returns 0 if argument is

View file

@ -47,6 +47,10 @@
#include "mach_startup.h"
#include "mach_startupServer.h"
#include "launchd_fd.h"
void DarwinListenOnOpenFD(int fd);
#define DEFAULT_CLIENT "/usr/X11/bin/xterm"
#define DEFAULT_STARTX "/usr/X11/bin/startx"
#define DEFAULT_SHELL "/bin/sh"
@ -60,8 +64,21 @@ int server_main(int argc, char **argv, char **envp);
static int execute(const char *command);
static char *command_from_prefs(const char *key, const char *default_value);
#ifdef NEW_LAUNCH_METHOD
/*** Pthread Magics ***/
static pthread_t create_thread(void *func, void *arg) {
pthread_attr_t attr;
pthread_t tid;
pthread_attr_init (&attr);
pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
pthread_create (&tid, &attr, func, arg);
pthread_attr_destroy (&attr);
return tid;
}
#ifdef NEW_LAUNCH_METHOD
struct arg {
int argc;
char **argv;
@ -106,20 +123,6 @@ static mach_port_t checkin_or_register(char *bname) {
return mp;
}
/*** Pthread Magics ***/
static pthread_t create_thread(void *func, void *arg) {
pthread_attr_t attr;
pthread_t tid;
pthread_attr_init (&attr);
pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
pthread_create (&tid, &attr, func, arg);
pthread_attr_destroy (&attr);
return tid;
}
/*** $DISPLAY handoff ***/
/* From darwinEvents.c ... but don't want to pull in all the server cruft */
void DarwinListenOnOpenFD(int fd);
@ -163,10 +166,11 @@ static void accept_fd_handoff(int connected_fd) {
launchd_fd = *((int*)CMSG_DATA(cmsg));
if(launchd_fd > 0)
DarwinListenOnOpenFD(launchd_fd);
else
if(launchd_fd == -1)
fprintf(stderr, "Error receiving $DISPLAY file descriptor, no descriptor received? %d\n", launchd_fd);
fprintf(stderr, "Received new DISPLAY fd: %d\n", launchd_fd);
DarwinListenOnOpenFD(launchd_fd);
}
typedef struct {
@ -227,9 +231,6 @@ static void socket_handoff_thread(void *arg) {
connected_fd = accept(handoff_fd, NULL, NULL);
/* We delete this temporary socket after we get the connection */
unlink(filename);
if(connected_fd == -1) {
fprintf(stderr, "Failed to accept incoming connection on socket: %s - %s\n", filename, strerror(errno));
return;
@ -237,8 +238,10 @@ static void socket_handoff_thread(void *arg) {
/* Now actually get the passed file descriptor from this connection */
accept_fd_handoff(connected_fd);
close(connected_fd);
close(handoff_fd);
unlink(filename);
}
kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
@ -289,6 +292,8 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
int startup_trigger(int argc, char **argv, char **envp) {
#else
void *add_launchd_display_thread(void *data);
int main(int argc, char **argv, char **envp) {
#endif
Display *display;
@ -345,6 +350,7 @@ int main(int argc, char **argv, char **envp) {
}
exit(EXIT_SUCCESS);
#else
create_thread(add_launchd_display_thread, NULL);
return server_main(argc, argv, envp);
#endif
}
@ -356,14 +362,9 @@ int main(int argc, char **argv, char **envp) {
/* Now, try to open a display, if so, run the launcher */
display = XOpenDisplay(NULL);
if(display) {
fprintf(stderr, "X11.app: Closing the display and sleeping for 2s to allow the X server to start up.\n");
/* Could open the display, start the launcher */
XCloseDisplay(display);
/* Give 2 seconds for the server to start...
* TODO: *Really* fix this race condition
*/
usleep(2000);
return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT));
}
}
@ -434,6 +435,20 @@ int main(int argc, char **argv, char **envp) {
return EXIT_SUCCESS;
}
#else
void *add_launchd_display_thread(void *data) {
/* TODO: Really fix this race... we want xinitrc to finish before connections
* are accepted on the launchd socket.
*/
sleep(2);
/* Start listening on the launchd fd */
int launchd_fd = launchd_display_fd();
if(launchd_fd != -1) {
DarwinListenOnOpenFD(launchd_fd);
}
return NULL;
}
#endif
static int execute(const char *command) {

View file

@ -113,7 +113,7 @@ static void set_x11_path() {
}
}
static void send_fd_handoff(int connected_fd, int launchd_fd) {
static void send_fd_handoff(int handoff_fd, int launchd_fd) {
char databuf[] = "display";
struct iovec iov[1];
@ -143,19 +143,19 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) {
*((int*)CMSG_DATA(cmsg)) = launchd_fd;
if (sendmsg(connected_fd, &msg, 0) < 0) {
if (sendmsg(handoff_fd, &msg, 0) < 0) {
fprintf(stderr, "Error sending $DISPLAY file descriptor: %s\n", strerror(errno));
return;
}
fprintf(stderr, "send %d %d %d %s\n", connected_fd, launchd_fd, errno, strerror(errno));
fprintf(stderr, "send %d %d %d %s\n", handoff_fd, launchd_fd, errno, strerror(errno));
}
static void handoff_fd(const char *filename, int launchd_fd) {
struct sockaddr_un servaddr_un;
struct sockaddr *servaddr;
socklen_t servaddr_len;
int handoff_fd, connected_fd;
int handoff_fd;
/* Setup servaddr_un */
memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
@ -171,15 +171,14 @@ static void handoff_fd(const char *filename, int launchd_fd) {
return;
}
connected_fd = connect(handoff_fd, servaddr, servaddr_len);
if(connected_fd == -1) {
if(connect(handoff_fd, servaddr, servaddr_len) < 0) {
fprintf(stderr, "Failed to establish connection on socket: %s - %s\n", filename, strerror(errno));
return;
}
send_fd_handoff(connected_fd, launchd_fd);
fprintf(stderr, "Socket: %s\n", filename);
send_fd_handoff(handoff_fd, launchd_fd);
close(handoff_fd);
}