diff options
-rw-r--r-- | xorg-server/dix/main.c | 25 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/X11Application.m | 6 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/console_redirect.c | 2 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/darwin.c | 33 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/darwin.h | 15 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/mach-startup/bundle-main.c | 5 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/mach-startup/stub.c | 1 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/man/Xquartz.man | 6 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/pbproxy/app-main.m | 6 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/pbproxy/main.m | 16 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/quartz.c | 15 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/quartzRandR.c | 219 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/quartzStartup.c | 1 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/xpr/xprScreen.c | 3 | ||||
-rw-r--r-- | xorg-server/mi/mieq.c | 16 |
15 files changed, 210 insertions, 159 deletions
diff --git a/xorg-server/dix/main.c b/xorg-server/dix/main.c index 31e2d48c4..bc958b896 100644 --- a/xorg-server/dix/main.c +++ b/xorg-server/dix/main.c @@ -121,9 +121,9 @@ extern void Dispatch(void); #ifdef XQUARTZ #include <pthread.h> -BOOL serverInitComplete = FALSE; -pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER; +BOOL serverRunning = FALSE; +pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER; int dix_main(int argc, char *argv[], char *envp[]); @@ -277,18 +277,25 @@ int main(int argc, char *argv[], char *envp[]) } #ifdef XQUARTZ - /* Let the other threads know the server is done with its init */ - pthread_mutex_lock(&serverInitCompleteMutex); - serverInitComplete = TRUE; - pthread_cond_broadcast(&serverInitCompleteCond); - pthread_mutex_unlock(&serverInitCompleteMutex); + /* Let the other threads know the server is done with its init */ + pthread_mutex_lock(&serverRunningMutex); + serverRunning = TRUE; + pthread_cond_broadcast(&serverRunningCond); + pthread_mutex_unlock(&serverRunningMutex); #endif NotifyParentProcess(); Dispatch(); - UndisplayDevices(); +#ifdef XQUARTZ + /* Let the other threads know the server is no longer running */ + pthread_mutex_lock(&serverRunningMutex); + serverRunning = FALSE; + pthread_mutex_unlock(&serverRunningMutex); +#endif + + UndisplayDevices(); /* Now free up whatever must be freed */ if (screenIsSaved == SCREEN_SAVER_ON) diff --git a/xorg-server/hw/xquartz/X11Application.m b/xorg-server/hw/xquartz/X11Application.m index 283132e75..7c41cbcb5 100644 --- a/xorg-server/hw/xquartz/X11Application.m +++ b/xorg-server/hw/xquartz/X11Application.m @@ -1269,7 +1269,7 @@ static const char *untrusted_str(NSEvent *e) { #if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0 /* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */ xp_window_id wid = 0; - xp_error e; + xp_error err; /* Sigh. Need to check that we're really over one of * our windows. (We need to receive pointer events while @@ -1277,9 +1277,9 @@ static const char *untrusted_str(NSEvent *e) { * when another window is over us or we might show a tooltip) */ - e = xp_find_window(location.x, location.y, 0, &wid); + err = xp_find_window(location.x, location.y, 0, &wid); - if (e != XP_Success || (e == XP_Success && wid == 0)) + if (err != XP_Success || (err == XP_Success && wid == 0)) #endif { bgMouseLocation = location; diff --git a/xorg-server/hw/xquartz/console_redirect.c b/xorg-server/hw/xquartz/console_redirect.c index cdd2b8960..70a819e42 100644 --- a/xorg-server/hw/xquartz/console_redirect.c +++ b/xorg-server/hw/xquartz/console_redirect.c @@ -116,7 +116,7 @@ static inline int _read_redirect(int fd, int flush) { *s='\0'; asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p); } else if(aslr->buf != p) { - memmove(aslr->buf, p, BUF_SIZE); + memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf)); aslr->w = aslr->buf + (s - p); break; } else if(nbytes == BUF_SIZE - 1) { diff --git a/xorg-server/hw/xquartz/darwin.c b/xorg-server/hw/xquartz/darwin.c index 50234f243..fa8d4ced2 100644 --- a/xorg-server/hw/xquartz/darwin.c +++ b/xorg-server/hw/xquartz/darwin.c @@ -60,6 +60,7 @@ #include <stdio.h> #include <fcntl.h> #include <unistd.h> +#include <stdarg.h> #define HAS_UTSNAME 1 #include <sys/utsname.h> @@ -76,9 +77,31 @@ #include "quartzKeyboard.h" #include "quartz.h" -#ifdef ENABLE_DEBUG_LOG -FILE *debug_log_fp = NULL; -#endif +aslclient aslc; + +void debug_asl (const char *file, const char *function, int line, const char *fmt, ...) { + va_list args; + aslmsg msg = asl_new(ASL_TYPE_MSG); + + if(msg) { + char *_line; + + asl_set(msg, "File", file); + asl_set(msg, "Function", function); + asprintf(&_line, "%d", line); + if(_line) { + asl_set(msg, "Line", _line); + free(_line); + } + } + + va_start(args, fmt); + asl_vlog(aslc, msg, ASL_LEVEL_DEBUG, fmt, args); + va_end(args); + + if(msg) + asl_free(msg); +} /* * X server shared global variables @@ -749,8 +772,8 @@ void ddxGiveUp( void ) * made to restore all original setting of the displays. Also all devices * are closed. */ -void AbortDDX( void ) -{ +_X_NORETURN +void AbortDDX( void ) { ErrorF( " AbortDDX\n" ); OsAbort(); } diff --git a/xorg-server/hw/xquartz/darwin.h b/xorg-server/hw/xquartz/darwin.h index 507c6f7f6..659de432c 100644 --- a/xorg-server/hw/xquartz/darwin.h +++ b/xorg-server/hw/xquartz/darwin.h @@ -32,7 +32,7 @@ #include "inputstr.h" #include "scrnintstr.h" #include <X11/extensions/XKB.h> -#include <assert.h> +#include <asl.h> #include "darwinfb.h" @@ -76,16 +76,9 @@ extern int darwinMainScreenY; // bundle-main.c extern char *bundle_id_prefix; -#define ENABLE_DEBUG_LOG 1 +extern void debug_asl (const char *file, const char *function, int line, const char *fmt, ...) _X_ATTRIBUTE_PRINTF(4,5); -#ifdef ENABLE_DEBUG_LOG -extern FILE *debug_log_fp; -#define DEBUG_LOG_NAME "x11-debug.txt" -#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp); -#else -#define DEBUG_LOG(msg, args...) -#endif - -#define TRACE() DEBUG_LOG("\n") +#define DEBUG_LOG(msg, args...) debug_asl(__FILE__, __FUNCTION__, __LINE__, msg, ##args); +#define TRACE() DEBUG_LOG("TRACE") #endif /* _DARWIN_H */ diff --git a/xorg-server/hw/xquartz/mach-startup/bundle-main.c b/xorg-server/hw/xquartz/mach-startup/bundle-main.c index 8e3437644..94c606823 100644 --- a/xorg-server/hw/xquartz/mach-startup/bundle-main.c +++ b/xorg-server/hw/xquartz/mach-startup/bundle-main.c @@ -66,6 +66,8 @@ /* From darwinEvents.c ... but don't want to pull in all the server cruft */ void DarwinListenOnOpenFD(int fd); +extern aslclient aslc; + /* Ditto, from os/log.c */ extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); extern void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN; @@ -485,7 +487,6 @@ static void ensure_path(const char *dir) { static void setup_console_redirect(const char *bundle_id) { char *asl_sender; char *asl_facility; - aslclient aslc; asprintf(&asl_sender, "%s.server", bundle_id); assert(asl_sender); @@ -644,7 +645,7 @@ int main(int argc, char **argv, char **envp) { child2 = fork(); switch (child2) { - int max_files, i; + int max_files; case -1: /* error */ FatalError("fork() failed: %s\n", strerror(errno)); diff --git a/xorg-server/hw/xquartz/mach-startup/stub.c b/xorg-server/hw/xquartz/mach-startup/stub.c index 8319dd06e..d8e4abdd1 100644 --- a/xorg-server/hw/xquartz/mach-startup/stub.c +++ b/xorg-server/hw/xquartz/mach-startup/stub.c @@ -164,6 +164,7 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) { close(connected_fd); } +__attribute__((__noreturn__)) static void signal_handler(int sig) { if(x11app_pid) kill(x11app_pid, sig); diff --git a/xorg-server/hw/xquartz/man/Xquartz.man b/xorg-server/hw/xquartz/man/Xquartz.man index 19e8efbad..aea56c943 100644 --- a/xorg-server/hw/xquartz/man/Xquartz.man +++ b/xorg-server/hw/xquartz/man/Xquartz.man @@ -111,7 +111,11 @@ In addition to this server log, XQuartz sends messages to syslogd(8) using asl(3). These logs are sent to the __bundle_id_prefix__ facility, and you can watch these logs using the following syslog(1) command: .TP 8 -.B $ syslog -w -k Facility __bundle_id_prefix__ +.B $ syslog -w -k Facility eq __bundle_id_prefix__ +.PP +or you can include extra information such as the file, line, and function where the message originated: +.TP 8 +.B $ syslog -w -F '$(Time) $(Sender) <$(Level)> $(File):$(Line) $(Function) :: $(Message)' -k Facility eq __bundle_id_prefix__ .PP By default, XQaurtz sets an ASL mask which prevents it from logging messages below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly diff --git a/xorg-server/hw/xquartz/pbproxy/app-main.m b/xorg-server/hw/xquartz/pbproxy/app-main.m index 9055bad06..a8c3a6055 100644 --- a/xorg-server/hw/xquartz/pbproxy/app-main.m +++ b/xorg-server/hw/xquartz/pbproxy/app-main.m @@ -39,9 +39,9 @@ CFStringRef app_prefs_domain_cfstr; /* Stubs */ char *display = NULL; -BOOL serverInitComplete = YES; -pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER; +BOOL serverRunning = YES; +pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER; static void signal_handler (int sig) { switch(sig) { diff --git a/xorg-server/hw/xquartz/pbproxy/main.m b/xorg-server/hw/xquartz/pbproxy/main.m index dbdb6d05c..29ce83b35 100644 --- a/xorg-server/hw/xquartz/pbproxy/main.m +++ b/xorg-server/hw/xquartz/pbproxy/main.m @@ -47,17 +47,17 @@ BOOL xpbproxy_is_standalone = NO; x_selection *_selection_object; -extern BOOL serverInitComplete; -extern pthread_mutex_t serverInitCompleteMutex; -extern pthread_cond_t serverInitCompleteCond; +extern BOOL serverRunning; +extern pthread_mutex_t serverRunningMutex; +extern pthread_cond_t serverRunningCond; static inline void wait_for_server_init(void) { /* If the server hasn't finished initializing, wait for it... */ - if(!serverInitComplete) { - pthread_mutex_lock(&serverInitCompleteMutex); - while(!serverInitComplete) - pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex); - pthread_mutex_unlock(&serverInitCompleteMutex); + if(!serverRunning) { + pthread_mutex_lock(&serverRunningMutex); + while(!serverRunning) + pthread_cond_wait(&serverRunningCond, &serverRunningMutex); + pthread_mutex_unlock(&serverRunningMutex); } } diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c index 0e71d3629..c395b42e6 100644 --- a/xorg-server/hw/xquartz/quartz.c +++ b/xorg-server/hw/xquartz/quartz.c @@ -239,8 +239,6 @@ void QuartzUpdateScreens(void) { AppleWMSetScreenOrigin(pRoot); pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL); - miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND); - /* <rdar://problem/7770779> pointer events are clipped to old display region after display reconfiguration * http://xquartz.macosforge.org/trac/ticket/346 */ @@ -268,6 +266,9 @@ void QuartzUpdateScreens(void) { quartzProcs->UpdateScreen(pScreen); + /* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */ + miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND); + /* Tell RandR about the new size, so new connections get the correct info */ RRScreenSizeNotify(pScreen); } @@ -464,11 +465,15 @@ void QuartzSpaceChanged(uint32_t space_id) { void QuartzCopyDisplayIDs(ScreenPtr pScreen, int displayCount, CGDirectDisplayID *displayIDs) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - int size = displayCount * sizeof(CGDirectDisplayID); free(pQuartzScreen->displayIDs); - pQuartzScreen->displayIDs = malloc(size); - memcpy(pQuartzScreen->displayIDs, displayIDs, size); + if(displayCount) { + size_t size = displayCount * sizeof(CGDirectDisplayID); + pQuartzScreen->displayIDs = malloc(size); + memcpy(pQuartzScreen->displayIDs, displayIDs, size); + } else { + pQuartzScreen->displayIDs = NULL; + } pQuartzScreen->displayCount = displayCount; } diff --git a/xorg-server/hw/xquartz/quartzRandR.c b/xorg-server/hw/xquartz/quartzRandR.c index 05641a65d..98b382d65 100644 --- a/xorg-server/hw/xquartz/quartzRandR.c +++ b/xorg-server/hw/xquartz/quartzRandR.c @@ -3,7 +3,7 @@ * * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons, * 2010 Jan Hauffa. - * 2010 Apple Inc. + * 2010-2011 Apple Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -124,44 +124,48 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId, static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, QuartzModeCallback callback, void *data) { - CFDictionaryRef curModeRef, modeRef; - long curBpp; - CFArrayRef modes; - QuartzModeInfo modeInfo; - int i; - BOOL retval = FALSE; + Bool retval = FALSE; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; - curModeRef = CGDisplayCurrentMode(screenId); - if (!curModeRef) - return FALSE; - curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel); + /* Just an 800x600 fallback if we have no attached heads */ + if(pQuartzScreen->displayIDs) { + CFDictionaryRef curModeRef, modeRef; + long curBpp; + CFArrayRef modes; + QuartzModeInfo modeInfo; + int i; + CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; + + curModeRef = CGDisplayCurrentMode(screenId); + if (!curModeRef) + return FALSE; + curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel); - modes = CGDisplayAvailableModes(screenId); - if (!modes) - return FALSE; - for (i = 0; i < CFArrayGetCount(modes); i++) { - int cb; - modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i); - - /* Skip modes that are not usable on the current display or have a - different pixel encoding than the current mode. */ - if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) & - kDisplayModeUsableFlags) != kDisplayModeUsableFlags) - continue; - if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp) - continue; - - QuartzRandRGetModeInfo(modeRef, &modeInfo); - modeInfo.ref = (void *)modeRef; - cb = callback(pScreen, &modeInfo, data); - if (cb == CALLBACK_CONTINUE) - retval = TRUE; - else if (cb == CALLBACK_SUCCESS) - return TRUE; - else if (cb == CALLBACK_ERROR) + modes = CGDisplayAvailableModes(screenId); + if (!modes) return FALSE; + for (i = 0; i < CFArrayGetCount(modes); i++) { + int cb; + modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i); + + /* Skip modes that are not usable on the current display or have a + different pixel encoding than the current mode. */ + if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) & + kDisplayModeUsableFlags) != kDisplayModeUsableFlags) + continue; + if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp) + continue; + + QuartzRandRGetModeInfo(modeRef, &modeInfo); + modeInfo.ref = (void *)modeRef; + cb = callback(pScreen, &modeInfo, data); + if (cb == CALLBACK_CONTINUE) + retval = TRUE; + else if (cb == CALLBACK_SUCCESS) + return TRUE; + else if (cb == CALLBACK_ERROR) + return FALSE; + } } switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) { @@ -225,61 +229,64 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId, static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, QuartzModeCallback callback, void *data) { - CGDisplayModeRef curModeRef, modeRef; - CFStringRef curPixelEnc, pixelEnc; - CFComparisonResult pixelEncEqual; - CFArrayRef modes; - QuartzModeInfo modeInfo; - int i; Bool retval = FALSE; - QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; - curModeRef = CGDisplayCopyDisplayMode(screenId); - if (!curModeRef) - return FALSE; - curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef); - CGDisplayModeRelease(curModeRef); + /* Just an 800x600 fallback if we have no attached heads */ + if(pQuartzScreen->displayIDs) { + CGDisplayModeRef curModeRef, modeRef; + CFStringRef curPixelEnc, pixelEnc; + CFComparisonResult pixelEncEqual; + CFArrayRef modes; + QuartzModeInfo modeInfo; + int i; + CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; + + curModeRef = CGDisplayCopyDisplayMode(screenId); + if (!curModeRef) + return FALSE; + curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef); + CGDisplayModeRelease(curModeRef); - modes = CGDisplayCopyAllDisplayModes(screenId, NULL); - if (!modes) { - CFRelease(curPixelEnc); - return FALSE; - } - for (i = 0; i < CFArrayGetCount(modes); i++) { - int cb; - modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); - - /* Skip modes that are not usable on the current display or have a - different pixel encoding than the current mode. */ - if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) != - kDisplayModeUsableFlags) - continue; - pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef); - pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0); - CFRelease(pixelEnc); - if (pixelEncEqual != kCFCompareEqualTo) - continue; - - QuartzRandRGetModeInfo(modeRef, &modeInfo); - modeInfo.ref = modeRef; - cb = callback(pScreen, &modeInfo, data); - if (cb == CALLBACK_CONTINUE) { - retval = TRUE; - } else if (cb == CALLBACK_SUCCESS) { - CFRelease(modes); - CFRelease(curPixelEnc); - return TRUE; - } else if (cb == CALLBACK_ERROR) { - CFRelease(modes); + modes = CGDisplayCopyAllDisplayModes(screenId, NULL); + if (!modes) { CFRelease(curPixelEnc); return FALSE; } - } + for (i = 0; i < CFArrayGetCount(modes); i++) { + int cb; + modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); + + /* Skip modes that are not usable on the current display or have a + different pixel encoding than the current mode. */ + if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) != + kDisplayModeUsableFlags) + continue; + pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef); + pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0); + CFRelease(pixelEnc); + if (pixelEncEqual != kCFCompareEqualTo) + continue; + + QuartzRandRGetModeInfo(modeRef, &modeInfo); + modeInfo.ref = modeRef; + cb = callback(pScreen, &modeInfo, data); + if (cb == CALLBACK_CONTINUE) { + retval = TRUE; + } else if (cb == CALLBACK_SUCCESS) { + CFRelease(modes); + CFRelease(curPixelEnc); + return TRUE; + } else if (cb == CALLBACK_ERROR) { + CFRelease(modes); + CFRelease(curPixelEnc); + return FALSE; + } + } - CFRelease(modes); - CFRelease(curPixelEnc); + CFRelease(modes); + CFRelease(curPixelEnc); + } switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) { case CALLBACK_SUCCESS: @@ -347,9 +354,13 @@ static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen, static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS); + CGDirectDisplayID screenId; + + if(pQuartzScreen->displayIDs == NULL) + return FALSE; + screenId = pQuartzScreen->displayIDs[0]; if(XQuartzShieldingWindowLevel == 0 && captureDisplay) { if(!X11ApplicationCanEnterRandR()) return FALSE; @@ -379,7 +390,8 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL if(pQuartzScreen->currentMode.ref) CFRelease(pQuartzScreen->currentMode.ref); pQuartzScreen->currentMode = *pMode; - CFRetain(pQuartzScreen->currentMode.ref); + if(pQuartzScreen->currentMode.ref) + CFRetain(pQuartzScreen->currentMode.ref); if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) { CGReleaseAllDisplays(); @@ -406,13 +418,8 @@ static int QuartzRandRSetModeCallback (ScreenPtr pScreen, } static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) { - QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - *rotations = RR_Rotate_0; /* TODO: support rotation */ - if (pQuartzScreen->displayCount == 0) - return FALSE; - return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL); } @@ -427,9 +434,6 @@ static Bool QuartzRandRSetConfig (ScreenPtr pScreen, reqMode.height = pSize->height; reqMode.refresh = rate; - if (pQuartzScreen->displayCount == 0) - return FALSE; - /* Do not switch modes if requested mode is equal to current mode. */ if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode)) return TRUE; @@ -444,26 +448,36 @@ static Bool QuartzRandRSetConfig (ScreenPtr pScreen, static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); + QuartzModeInfo activeMode; + + if(pQuartzScreen->displayCount > 0) { + if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) { + ErrorF("Unable to determine current display mode.\n"); + return FALSE; + } + } else { + memset(&activeMode, 0, sizeof(activeMode)); + activeMode.width = 800; + activeMode.height = 600; + activeMode.refresh = 60; + } if(pQuartzScreen->fullscreenMode.ref) CFRelease(pQuartzScreen->fullscreenMode.ref); if(pQuartzScreen->currentMode.ref) CFRelease(pQuartzScreen->currentMode.ref); - - if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], - &pQuartzScreen->fullscreenMode)) - return FALSE; - if (pQuartzScreen->displayCount > 1) { - pQuartzScreen->fullscreenMode.width = pScreen->width; - pQuartzScreen->fullscreenMode.height = pScreen->height; + if(pQuartzScreen->displayCount > 1) { + activeMode.width = pScreen->width; + activeMode.height = pScreen->height; if(XQuartzIsRootless) - pQuartzScreen->fullscreenMode.height += aquaMenuBarHeight; + activeMode.height += aquaMenuBarHeight; } + pQuartzScreen->fullscreenMode = activeMode; pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN; - pQuartzScreen->rootlessMode = pQuartzScreen->fullscreenMode; + pQuartzScreen->rootlessMode = activeMode; pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS; pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight; @@ -476,7 +490,8 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) { /* This extra retain is for currentMode's copy. * fullscreen and rootless share a retain. */ - CFRetain(pQuartzScreen->currentMode.ref); + if(pQuartzScreen->currentMode.ref) + CFRetain(pQuartzScreen->currentMode.ref); DEBUG_LOG("rootlessMode: %d x %d\n", (int)pQuartzScreen->rootlessMode.width, (int)pQuartzScreen->rootlessMode.height); DEBUG_LOG("fullscreenMode: %d x %d\n", (int)pQuartzScreen->fullscreenMode.width, (int)pQuartzScreen->fullscreenMode.height); diff --git a/xorg-server/hw/xquartz/quartzStartup.c b/xorg-server/hw/xquartz/quartzStartup.c index 00a9e48fd..25ef76efa 100644 --- a/xorg-server/hw/xquartz/quartzStartup.c +++ b/xorg-server/hw/xquartz/quartzStartup.c @@ -56,6 +56,7 @@ struct arg { char **envp; }; +_X_NORETURN static void server_thread (void *arg) { struct arg args = *((struct arg *)arg); free(arg); diff --git a/xorg-server/hw/xquartz/xpr/xprScreen.c b/xorg-server/hw/xquartz/xpr/xprScreen.c index f6a712906..98250e641 100644 --- a/xorg-server/hw/xquartz/xpr/xprScreen.c +++ b/xorg-server/hw/xquartz/xpr/xprScreen.c @@ -193,6 +193,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr *width = 800; *height = 600; PseudoramiXAddScreen(*x, *y, *width, *height); + QuartzCopyDisplayIDs(pScreen, 0, NULL); return; } @@ -253,7 +254,7 @@ xprDisplayInit(void) { CGDisplayCount displayCount; - DEBUG_LOG(""); + TRACE(); CGGetActiveDisplayList(0, NULL, &displayCount); diff --git a/xorg-server/mi/mieq.c b/xorg-server/mi/mieq.c index 236ffcc3b..031b11ab2 100644 --- a/xorg-server/mi/mieq.c +++ b/xorg-server/mi/mieq.c @@ -83,17 +83,17 @@ static EventQueueRec miEventQueue; #include <pthread.h> static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER; -extern BOOL serverInitComplete; -extern pthread_mutex_t serverInitCompleteMutex; -extern pthread_cond_t serverInitCompleteCond; +extern BOOL serverRunning; +extern pthread_mutex_t serverRunningMutex; +extern pthread_cond_t serverRunningCond; static inline void wait_for_server_init(void) { /* If the server hasn't finished initializing, wait for it... */ - if(!serverInitComplete) { - pthread_mutex_lock(&serverInitCompleteMutex); - while(!serverInitComplete) - pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex); - pthread_mutex_unlock(&serverInitCompleteMutex); + if(!serverRunning) { + pthread_mutex_lock(&serverRunningMutex); + while(!serverRunning) + pthread_cond_wait(&serverRunningCond, &serverRunningMutex); + pthread_mutex_unlock(&serverRunningMutex); } } #endif |