Merge remote-tracking branch 'jeremyhu/master'

This commit is contained in:
Keith Packard 2011-04-27 12:01:56 -07:00
commit ec9ea40178
64 changed files with 406 additions and 604 deletions

View File

@ -1110,12 +1110,7 @@ XvdiMatchPort(
while (nf--) while (nf--)
{ {
if ((pf->depth == pDraw->depth) if (pf->depth == pDraw->depth)
#if 0
&& ((pDraw->type == DRAWABLE_PIXMAP) ||
(wVisual(((WindowPtr)pDraw)) == pf->visual))
#endif
)
return Success; return Success;
pf++; pf++;
} }

View File

@ -84,7 +84,6 @@ SOFTWARE.
#include "closedev.h" #include "closedev.h"
#include "devbell.h" #include "devbell.h"
#include "getbmap.h" #include "getbmap.h"
#include "getbmap.h"
#include "getdctl.h" #include "getdctl.h"
#include "getfctl.h" #include "getfctl.h"
#include "getfocus.h" #include "getfocus.h"
@ -93,7 +92,6 @@ SOFTWARE.
#include "getprop.h" #include "getprop.h"
#include "getselev.h" #include "getselev.h"
#include "getvers.h" #include "getvers.h"
#include "getvers.h"
#include "grabdev.h" #include "grabdev.h"
#include "grabdevb.h" #include "grabdevb.h"
#include "grabdevk.h" #include "grabdevk.h"

View File

@ -562,11 +562,14 @@ AC_ARG_WITH(apple-application-name,AS_HELP_STRING([--with-apple-application-name
[ APPLE_APPLICATION_NAME="${withval}" ], [ APPLE_APPLICATION_NAME="${withval}" ],
[ APPLE_APPLICATION_NAME="X11" ]) [ APPLE_APPLICATION_NAME="X11" ])
AC_SUBST([APPLE_APPLICATION_NAME]) AC_SUBST([APPLE_APPLICATION_NAME])
AC_ARG_WITH(launchd-id-prefix, AS_HELP_STRING([--with-launchd-id-prefix=PATH], [Prefix to use for launchd identifiers (default: org.x)]), AC_ARG_WITH(launchd-id-prefix, AS_HELP_STRING([--with-launchd-id-prefix=PATH], [Deprecated: Use --with-bundle-id-prefix.]),
[ LAUNCHD_ID_PREFIX="${withval}" ], [ BUNDLE_ID_PREFIX="${withval}" ],
[ LAUNCHD_ID_PREFIX="org.x" ]) [ BUNDLE_ID_PREFIX="org.x" ])
AC_SUBST([LAUNCHD_ID_PREFIX]) AC_ARG_WITH(bundle-id-prefix, AS_HELP_STRING([--with-bundle-id-prefix=PATH], [Prefix to use for bundle identifiers (default: org.x)]),
AC_DEFINE_UNQUOTED(LAUNCHD_ID_PREFIX, "$LAUNCHD_ID_PREFIX", [Prefix to use for launchd identifiers]) [ BUNDLE_ID_PREFIX="${withval}" ],
[ BUNDLE_ID_PREFIX="org.x" ])
AC_SUBST([BUNDLE_ID_PREFIX])
AC_DEFINE_UNQUOTED(BUNDLE_ID_PREFIX, "$BUNDLE_ID_PREFIX", [Prefix to use for bundle identifiers])
AC_ARG_ENABLE(sparkle,AS_HELP_STRING([--enable-sparkle], [Enable updating of X11.app using the Sparkle Framework (default: disabled)]), AC_ARG_ENABLE(sparkle,AS_HELP_STRING([--enable-sparkle], [Enable updating of X11.app using the Sparkle Framework (default: disabled)]),
[ XQUARTZ_SPARKLE="${enableval}" ], [ XQUARTZ_SPARKLE="${enableval}" ],
[ XQUARTZ_SPARKLE="no" ]) [ XQUARTZ_SPARKLE="no" ])
@ -587,7 +590,7 @@ dnl GLX build options
AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]), AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
[AIGLX=$enableval], [AIGLX=$enableval],
[AIGLX=yes]) [AIGLX=yes])
AX_TLS XORG_TLS
AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]), AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]),
[GLX_USE_TLS=$enableval [GLX_USE_TLS=$enableval
if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then

View File

@ -138,7 +138,6 @@ typedef const char *string;
#include <X11/extensions/XI2.h> #include <X11/extensions/XI2.h>
#include "exglobals.h" #include "exglobals.h"
#include "exevents.h" #include "exevents.h"
#include "exglobals.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "dixevents.h" #include "dixevents.h"

View File

@ -61,7 +61,6 @@
#include <pixman.h> #include <pixman.h>
#include "exglobals.h" #include "exglobals.h"
#include "exevents.h" #include "exevents.h"
#include "exglobals.h"
#include "extnsionst.h" #include "extnsionst.h"
#include "listdev.h" /* for sizing up DeviceClassesChangedEvent */ #include "listdev.h" /* for sizing up DeviceClassesChangedEvent */

View File

@ -26,6 +26,11 @@
#include "fb.h" #include "fb.h"
#ifdef __clang__
/* shift overflow is intentional */
#pragma clang diagnostic ignored "-Wshift-overflow"
#endif
/* /*
* Example: srcX = 13 dstX = 8 (FB unit 32 dstBpp 8) * Example: srcX = 13 dstX = 8 (FB unit 32 dstBpp 8)
* *

View File

@ -160,7 +160,7 @@ create_bits_picture (PicturePtr pict,
fbGetPixmapBitsData(pixmap, bits, stride, bpp); fbGetPixmapBitsData(pixmap, bits, stride, bpp);
image = pixman_image_create_bits ( image = pixman_image_create_bits (
pict->format, (pixman_format_code_t)pict->format,
pixmap->drawable.width, pixmap->drawable.height, pixmap->drawable.width, pixmap->drawable.height,
(uint32_t *)bits, stride * sizeof (FbStride)); (uint32_t *)bits, stride * sizeof (FbStride));

View File

@ -78,11 +78,9 @@ static void init_glapi_relocs(void);
/*@{*/ /*@{*/
#if defined(GLX_USE_TLS) #if defined(GLX_USE_TLS)
PUBLIC TLS struct _glapi_table * _glapi_tls_Dispatch PUBLIC TLS struct _glapi_table * _glapi_tls_Dispatch = NULL;
__attribute__((tls_model("initial-exec"))) = NULL;
PUBLIC TLS void * _glapi_tls_Context PUBLIC TLS void * _glapi_tls_Context;
__attribute__((tls_model("initial-exec")));
PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL; PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL;
PUBLIC const void *_glapi_Context = NULL; PUBLIC const void *_glapi_Context = NULL;

View File

@ -83,8 +83,7 @@ typedef void (*_glapi_warning_func)(void *ctx, const char *str, ...);
const extern void *_glapi_Context; const extern void *_glapi_Context;
const extern struct _glapi_table *_glapi_Dispatch; const extern struct _glapi_table *_glapi_Dispatch;
extern TLS void * _glapi_tls_Context extern TLS void * _glapi_tls_Context;
__attribute__((tls_model("initial-exec")));
# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context # define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context

View File

@ -233,8 +233,7 @@ _glthread_SetTSD(_glthread_TSD *, void *);
#if defined(GLX_USE_TLS) #if defined(GLX_USE_TLS)
extern TLS struct _glapi_table * _glapi_tls_Dispatch extern TLS struct _glapi_table * _glapi_tls_Dispatch;
__attribute__((tls_model("initial-exec")));
#define GET_DISPATCH() _glapi_tls_Dispatch #define GET_DISPATCH() _glapi_tls_Dispatch

View File

@ -30,7 +30,6 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include "property.h" #include "property.h"
#include "propertyst.h" #include "propertyst.h"
#include "xf86DDC.h"
#include <string.h> #include <string.h>
#define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA" #define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA"

View File

@ -63,8 +63,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dri.h" #include "dri.h"
#include "sarea.h" #include "sarea.h"
#include "dristruct.h" #include "dristruct.h"
#include "xf86.h"
#include "xf86drm.h"
#include "mi.h" #include "mi.h"
#include "mipointer.h" #include "mipointer.h"
#include "xf86_OSproc.h" #include "xf86_OSproc.h"

View File

@ -58,7 +58,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dri.h" #include "dri.h"
#include "sarea.h" #include "sarea.h"
#include "dristruct.h" #include "dristruct.h"
#include "xf86.h"
#include "xf86drm.h" #include "xf86drm.h"
#include "protocol-versions.h" #include "protocol-versions.h"

View File

@ -48,7 +48,6 @@ _X_EXPORT XF86ModuleData fbdevhwModuleData = {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* our private data, and two functions to allocate/free this */ /* our private data, and two functions to allocate/free this */

View File

@ -31,7 +31,6 @@
#include "xf86.h" #include "xf86.h"
#include "os.h" #include "os.h"
#include "globals.h" #include "globals.h"
#include "xf86.h"
#include "xf86Priv.h" #include "xf86Priv.h"
#include "xf86DDC.h" #include "xf86DDC.h"
#include "mipointer.h" #include "mipointer.h"

View File

@ -21,7 +21,6 @@ is" without express or implied warranty.
#include "regionstr.h" #include "regionstr.h"
#include "pixmapstr.h" #include "pixmapstr.h"
#include "scrnintstr.h" #include "scrnintstr.h"
#include "regionstr.h"
#include "gc.h" #include "gc.h"
#include "servermd.h" #include "servermd.h"
#include "privates.h" #include "privates.h"

View File

@ -507,7 +507,7 @@ bool getGlCapabilities(struct glCapabilities *cap) {
err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers); err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
if(err) { if(err) {
fprintf(stderr, "CGLQueryRendererInfo error: %s\n", CGLErrorString(err)); ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
return err; return err;
} }
@ -518,8 +518,8 @@ bool getGlCapabilities(struct glCapabilities *cap) {
err = handleRendererDescriptions(info, r, &tmpconf); err = handleRendererDescriptions(info, r, &tmpconf);
if(err) { if(err) {
fprintf(stderr, "handleRendererDescriptions returned error: %s\n", CGLErrorString(err)); ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
fprintf(stderr, "trying to continue...\n"); ErrorF("trying to continue...\n");
continue; continue;
} }

View File

@ -139,7 +139,6 @@
#include <glxcontext.h> #include <glxcontext.h>
#include <glxext.h> #include <glxext.h>
#include <glxutil.h> #include <glxutil.h>
#include <glxscreens.h>
#include <GL/internal/glcore.h> #include <GL/internal/glcore.h>
#include "x-hash.h" #include "x-hash.h"
#include "x-list.h" #include "x-list.h"

View File

@ -51,7 +51,6 @@
#include <glxcontext.h> #include <glxcontext.h>
#include <glxext.h> #include <glxext.h>
#include <glxutil.h> #include <glxutil.h>
#include <glxscreens.h>
#include <GL/internal/glcore.h> #include <GL/internal/glcore.h>
#include "capabilities.h" #include "capabilities.h"

View File

@ -33,8 +33,7 @@ libXquartz_la_SOURCES = \
quartzCocoa.m \ quartzCocoa.m \
quartzKeyboard.c \ quartzKeyboard.c \
quartzStartup.c \ quartzStartup.c \
quartzRandR.c \ quartzRandR.c
threadSafety.c
EXTRA_DIST = \ EXTRA_DIST = \
X11Application.h \ X11Application.h \
@ -50,5 +49,4 @@ EXTRA_DIST = \
quartzKeyboard.h \ quartzKeyboard.h \
quartzRandR.h \ quartzRandR.h \
sanitizedCarbon.h \ sanitizedCarbon.h \
sanitizedCocoa.h \ sanitizedCocoa.h
threadSafety.h

View File

@ -41,7 +41,6 @@
#include "quartz.h" #include "quartz.h"
#include "darwinEvents.h" #include "darwinEvents.h"
#include "quartzKeyboard.h" #include "quartzKeyboard.h"
#include "quartz.h"
#include <X11/extensions/applewmconst.h> #include <X11/extensions/applewmconst.h>
#include "micmap.h" #include "micmap.h"
#include "exglobals.h" #include "exglobals.h"
@ -237,8 +236,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
if ([self isActive]) { if ([self isActive]) {
[self deactivate]; [self deactivate];
if (!_x_active && quartzProcs->IsX11Window([e window], if (!_x_active && quartzProcs->IsX11Window([e windowNumber]))
[e windowNumber]))
[self activateX:YES]; [self activateX:YES];
} }
} }
@ -980,7 +978,7 @@ static inline pthread_t create_thread(void *(*func)(void *), void *arg) {
static void *xpbproxy_x_thread(void *args) { static void *xpbproxy_x_thread(void *args) {
xpbproxy_run(); xpbproxy_run();
fprintf(stderr, "xpbproxy thread is terminating unexpectedly.\n"); ErrorF("xpbproxy thread is terminating unexpectedly.\n");
return NULL; return NULL;
} }
@ -1014,7 +1012,7 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
NSMaxY([[NSScreen mainScreen] visibleFrame]); NSMaxY([[NSScreen mainScreen] visibleFrame]);
#ifdef HAVE_LIBDISPATCH #ifdef HAVE_LIBDISPATCH
eventTranslationQueue = dispatch_queue_create(LAUNCHD_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL); eventTranslationQueue = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL);
assert(eventTranslationQueue != NULL); assert(eventTranslationQueue != NULL);
#endif #endif
@ -1023,15 +1021,15 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
last_key_layout = TISCopyCurrentKeyboardLayoutInputSource(); last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
if(!last_key_layout) if(!last_key_layout)
fprintf(stderr, "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n"); ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
#else #else
KLGetCurrentKeyboardLayout(&last_key_layout); KLGetCurrentKeyboardLayout(&last_key_layout);
if(!last_key_layout) if(!last_key_layout)
fprintf(stderr, "X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n"); ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
#endif #endif
if (!QuartsResyncKeymap(FALSE)) { if (!QuartsResyncKeymap(FALSE)) {
fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n"); ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
} }
/* Tell the server thread that it can proceed */ /* Tell the server thread that it can proceed */
@ -1372,7 +1370,7 @@ static const char *untrusted_str(NSEvent *e) {
#endif #endif
/* Update keyInfo */ /* Update keyInfo */
if (!QuartsResyncKeymap(TRUE)) { if (!QuartsResyncKeymap(TRUE)) {
fprintf(stderr, "sendX11NSEvent: Could not build a valid keymap.\n"); ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
} }
} }
} }

View File

@ -32,10 +32,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define _APPLEWMEXT_H_ #define _APPLEWMEXT_H_
#include "window.h" #include "window.h"
#include <Xplugin.h>
typedef int (*DisableUpdateProc)(void); typedef int (*DisableUpdateProc)(void);
typedef int (*EnableUpdateProc)(void); typedef int (*EnableUpdateProc)(void);
typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level); typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
#if XPLUGIN_VERSION < 4
typedef int (*FrameGetRectProc)(int type, int class, const BoxRec *outer, typedef int (*FrameGetRectProc)(int type, int class, const BoxRec *outer,
const BoxRec *inner, BoxRec *ret); const BoxRec *inner, BoxRec *ret);
typedef int (*FrameHitTestProc)(int class, int x, int y, typedef int (*FrameHitTestProc)(int class, int x, int y,
@ -45,6 +47,17 @@ typedef int (*FrameDrawProc)(WindowPtr pWin, int class, unsigned int attr,
const BoxRec *outer, const BoxRec *inner, const BoxRec *outer, const BoxRec *inner,
unsigned int title_len, unsigned int title_len,
const unsigned char *title_bytes); const unsigned char *title_bytes);
#else
typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class, const BoxRec *outer,
const BoxRec *inner, BoxRec *ret);
typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y,
const BoxRec *outer,
const BoxRec *inner, int *ret);
typedef int (*FrameDrawProc)(WindowPtr pWin, xp_frame_class class, xp_frame_attr attr,
const BoxRec *outer, const BoxRec *inner,
unsigned int title_len,
const unsigned char *title_bytes);
#endif
typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo); typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo);
typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent); typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent);

View File

@ -7,11 +7,11 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>X11</string> <string>X11</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>LAUNCHD_ID_PREFIX.X11</string> <string>BUNDLE_ID_PREFIX.X11</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>X11.icns</string> <string>X11.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>LAUNCHD_ID_PREFIX.X11</string> <string>BUNDLE_ID_PREFIX.X11</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
@ -19,9 +19,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.6.1</string> <string>2.7.0</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.6.1</string> <string>2.7.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>x11a</string> <string>x11a</string>
<key>CSResourcesFileMapped</key> <key>CSResourcesFileMapped</key>

View File

@ -1,7 +1,7 @@
include cpprules.in include cpprules.in
CPP_FILES_FLAGS = \ CPP_FILES_FLAGS = \
-DLAUNCHD_ID_PREFIX="$(LAUNCHD_ID_PREFIX)" \ -DBUNDLE_ID_PREFIX="$(BUNDLE_ID_PREFIX)" \
-DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)" -DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)"
if XQUARTZ_SPARKLE if XQUARTZ_SPARKLE

View File

@ -133,28 +133,12 @@ static PixmapFormatRec formats[] = {
}; };
const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]); const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
#ifndef OSNAME
#define OSNAME " Darwin"
#endif
#ifndef OSVENDOR
#define OSVENDOR ""
#endif
#ifndef PRE_RELEASE
#define PRE_RELEASE XORG_VERSION_SNAP
#endif
#ifndef BUILD_DATE
#define BUILD_DATE ""
#endif
#ifndef XORG_RELEASE
#define XORG_RELEASE "?"
#endif
void void
DarwinPrintBanner(void) DarwinPrintBanner(void)
{ {
// this should change depending on which specific server we are building
ErrorF("Xquartz starting:\n"); ErrorF("Xquartz starting:\n");
ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE ); ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
ErrorF("Build Date: %s\n", BUILD_DATE );
} }
@ -605,6 +589,13 @@ void OsVendorFatalError( void )
void OsVendorInit(void) void OsVendorInit(void)
{ {
if (serverGeneration == 1) { if (serverGeneration == 1) {
char *lf;
char *home = getenv("HOME");
assert(home);
assert(0 < asprintf(&lf, "%s/Library/Logs/X11.%s.log", home, bundle_id_prefix));
LogInit(lf, ".old");
free(lf);
DarwinPrintBanner(); DarwinPrintBanner();
#ifdef ENABLE_DEBUG_LOG #ifdef ENABLE_DEBUG_LOG
{ {

View File

@ -34,8 +34,6 @@
#include <X11/extensions/XKB.h> #include <X11/extensions/XKB.h>
#include <assert.h> #include <assert.h>
#include "threadSafety.h"
#include "darwinfb.h" #include "darwinfb.h"
// From darwin.c // From darwin.c
@ -75,12 +73,15 @@ extern int darwinDesiredDepth;
extern int darwinMainScreenX; extern int darwinMainScreenX;
extern int darwinMainScreenY; extern int darwinMainScreenY;
// bundle-main.c
extern char *bundle_id_prefix;
#define ENABLE_DEBUG_LOG 1 #define ENABLE_DEBUG_LOG 1
#ifdef ENABLE_DEBUG_LOG #ifdef ENABLE_DEBUG_LOG
extern FILE *debug_log_fp; extern FILE *debug_log_fp;
#define DEBUG_LOG_NAME "x11-debug.txt" #define DEBUG_LOG_NAME "x11-debug.txt"
#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%s:%d " msg, threadSafetyID(pthread_self()), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp); #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 #else
#define DEBUG_LOG(msg, args...) #define DEBUG_LOG(msg, args...)
#endif #endif

View File

@ -113,7 +113,7 @@ void darwinEvents_lock(void) {
if((err = pthread_mutex_lock(&mieq_lock))) { if((err = pthread_mutex_lock(&mieq_lock))) {
ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n", ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n",
__FILE__, __FUNCTION__, __LINE__, err); __FILE__, __FUNCTION__, __LINE__, err);
spewCallStack(); xorg_backtrace();
} }
if(darwinEvents == NULL) { if(darwinEvents == NULL) {
pthread_cond_wait(&mieq_ready_cond, &mieq_lock); pthread_cond_wait(&mieq_ready_cond, &mieq_lock);
@ -126,7 +126,7 @@ void darwinEvents_unlock(void) {
if((err = pthread_mutex_unlock(&mieq_lock))) { if((err = pthread_mutex_unlock(&mieq_lock))) {
ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n", ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n",
__FILE__, __FUNCTION__, __LINE__, err); __FILE__, __FUNCTION__, __LINE__, err);
spewCallStack(); xorg_backtrace();
} }
} }
@ -197,8 +197,6 @@ static void DarwinUpdateModifiers(
static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) { static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
XQuartzEvent *e = &(ie->xquartz_event); XQuartzEvent *e = &(ie->xquartz_event);
TA_SERVER();
switch(e->subtype) { switch(e->subtype) {
case kXquartzControllerNotify: case kXquartzControllerNotify:
DEBUG_LOG("kXquartzControllerNotify\n"); DEBUG_LOG("kXquartzControllerNotify\n");
@ -381,8 +379,6 @@ void ProcessInputEvents(void) {
char nullbyte; char nullbyte;
int x = sizeof(nullbyte); int x = sizeof(nullbyte);
TA_SERVER();
mieqProcessInputEvents(); mieqProcessInputEvents();
// Empty the signaling pipe // Empty the signaling pipe

View File

@ -64,6 +64,9 @@
/* From darwinEvents.c ... but don't want to pull in all the server cruft */ /* From darwinEvents.c ... but don't want to pull in all the server cruft */
void DarwinListenOnOpenFD(int fd); void DarwinListenOnOpenFD(int fd);
/* Ditto, from os/log.c */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern int noPanoramiXExtension; extern int noPanoramiXExtension;
#define DEFAULT_CLIENT X11BINDIR "/xterm" #define DEFAULT_CLIENT X11BINDIR "/xterm"
@ -88,7 +91,7 @@ asm (".desc ___crashreporter_info__, 0x10");
static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE; static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE;
static char *launchd_id_prefix = NULL; char *bundle_id_prefix = NULL;
static char *server_bootstrap_name = NULL; static char *server_bootstrap_name = NULL;
#define DEBUG 1 #define DEBUG 1
@ -134,19 +137,27 @@ static mach_port_t checkin_or_register(char *bname) {
/* We probably were not started by launchd or the old mach_init */ /* We probably were not started by launchd or the old mach_init */
kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp); kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "mach_port_allocate(): %s\n", mach_error_string(kr)); ErrorF("mach_port_allocate(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND); kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "mach_port_insert_right(): %s\n", mach_error_string(kr)); ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // bootstrap_register
#endif
kr = bootstrap_register(bootstrap_port, bname, mp); kr = bootstrap_register(bootstrap_port, bname, mp);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "bootstrap_register(): %s\n", mach_error_string(kr)); ErrorF("bootstrap_register(): %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -189,7 +200,7 @@ static int accept_fd_handoff(int connected_fd) {
*((int*)CMSG_DATA(cmsg)) = -1; *((int*)CMSG_DATA(cmsg)) = -1;
if(recvmsg(connected_fd, &msg, 0) < 0) { if(recvmsg(connected_fd, &msg, 0) < 0) {
fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno)); ErrorF("X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno));
return -1; return -1;
} }
@ -222,14 +233,14 @@ static void *socket_handoff_thread(void *arg) {
while(launchd_fd == -1) { while(launchd_fd == -1) {
connected_fd = accept(handoff_data->fd, NULL, NULL); connected_fd = accept(handoff_data->fd, NULL, NULL);
if(connected_fd == -1) { if(connected_fd == -1) {
fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno)); ErrorF("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
sleep(2); sleep(2);
continue; continue;
} }
launchd_fd = accept_fd_handoff(connected_fd); launchd_fd = accept_fd_handoff(connected_fd);
if(launchd_fd == -1) if(launchd_fd == -1)
fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n"); ErrorF("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
close(connected_fd); close(connected_fd);
} }
@ -238,7 +249,7 @@ static void *socket_handoff_thread(void *arg) {
unlink(handoff_data->filename); unlink(handoff_data->filename);
free(handoff_data); free(handoff_data);
fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); ErrorF("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
DarwinListenOnOpenFD(launchd_fd); DarwinListenOnOpenFD(launchd_fd);
#ifndef HAVE_LIBDISPATCH #ifndef HAVE_LIBDISPATCH
@ -266,24 +277,24 @@ static int create_socket(char *filename_out) {
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if(ret_fd == -1) { if(ret_fd == -1) {
fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno)); ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
continue; continue;
} }
if(bind(ret_fd, servaddr, servaddr_len) != 0) { if(bind(ret_fd, servaddr, servaddr_len) != 0) {
fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno)); ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
close(ret_fd); close(ret_fd);
return 0; return 0;
} }
if(listen(ret_fd, 10) != 0) { if(listen(ret_fd, 10) != 0) {
fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno)); ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
close(ret_fd); close(ret_fd);
return 0; return 0;
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out); ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out);
#endif #endif
return ret_fd; return ret_fd;
@ -301,7 +312,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename)
handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t)); handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
if(!handoff_data) { if(!handoff_data) {
fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n"); ErrorF("X11.app: Error allocating memory for handoff_data\n");
return KERN_FAILURE; return KERN_FAILURE;
} }
@ -322,7 +333,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename)
#endif #endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n"); ErrorF("X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
#endif #endif
return KERN_SUCCESS; return KERN_SUCCESS;
@ -347,7 +358,7 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
* unset DISPLAY or we can run into problems with pbproxy * unset DISPLAY or we can run into problems with pbproxy
*/ */
if(!launchd_socket_handed_off) { if(!launchd_socket_handed_off) {
fprintf(stderr, "X11.app: No launchd socket handed off, unsetting DISPLAY\n"); ErrorF("X11.app: No launchd socket handed off, unsetting DISPLAY\n");
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
@ -355,10 +366,10 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
return KERN_FAILURE; return KERN_FAILURE;
} }
fprintf(stderr, "X11.app: do_start_x11_server(): argc=%d\n", argvCnt); ErrorF("X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
for(i=0; i < argvCnt; i++) { for(i=0; i < argvCnt; i++) {
_argv[i] = argv[i]; _argv[i] = argv[i];
fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
} }
_argv[argvCnt] = NULL; _argv[argvCnt] = NULL;
@ -396,7 +407,7 @@ static int startup_trigger(int argc, char **argv, char **envp) {
newenvp = (string_array_t)alloca(envpc * sizeof(string_t)); newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
if(!newargv || !newenvp) { if(!newargv || !newenvp) {
fprintf(stderr, "Memory allocation failure\n"); ErrorF("Memory allocation failure\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -410,16 +421,16 @@ static int startup_trigger(int argc, char **argv, char **envp) {
kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp); kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
fprintf(stderr, "bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr)); ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr));
#else #else
fprintf(stderr, "bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr); ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr);
#endif #endif
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
kr = start_x11_server(mp, newargv, argc, newenvp, envpc); kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr)); ErrorF("start_x11_server: %s\n", mach_error_string(kr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
@ -441,10 +452,10 @@ static int startup_trigger(int argc, char **argv, char **envp) {
/* Start the server */ /* Start the server */
if((s = getenv("DISPLAY"))) { if((s = getenv("DISPLAY"))) {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s); ErrorF("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} else { } else {
fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); ErrorF("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
} }
return execute(command_from_prefs("startx_script", DEFAULT_STARTX)); return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
} }
@ -483,23 +494,23 @@ static void setup_env(void) {
/* fallback to hardcoded value if we can't discover it */ /* fallback to hardcoded value if we can't discover it */
if(!pds) { if(!pds) {
pds = LAUNCHD_ID_PREFIX".X11"; pds = BUNDLE_ID_PREFIX".X11";
} }
server_bootstrap_name = strdup(pds); server_bootstrap_name = strdup(pds);
if(!server_bootstrap_name) { if(!server_bootstrap_name) {
fprintf(stderr, "X11.app: Memory allocation error.\n"); ErrorF("X11.app: Memory allocation error.\n");
exit(1); exit(1);
} }
setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1); setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1);
len = strlen(server_bootstrap_name); len = strlen(server_bootstrap_name);
launchd_id_prefix = malloc(sizeof(char) * (len - 3)); bundle_id_prefix = malloc(sizeof(char) * (len - 3));
if(!launchd_id_prefix) { if(!bundle_id_prefix) {
fprintf(stderr, "X11.app: Memory allocation error.\n"); ErrorF("X11.app: Memory allocation error.\n");
exit(1); exit(1);
} }
strlcpy(launchd_id_prefix, server_bootstrap_name, len - 3); strlcpy(bundle_id_prefix, server_bootstrap_name, len - 3);
/* We need to unset DISPLAY if it is not our socket */ /* We need to unset DISPLAY if it is not our socket */
if(disp) { if(disp) {
@ -511,27 +522,27 @@ static void setup_env(void) {
} }
if(s && *s) { if(s && *s) {
if(strcmp(launchd_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) { if(strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
fprintf(stderr, "X11.app: Detected old style launchd DISPLAY, please update xinit.\n"); ErrorF("X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
} else { } else {
temp = (char *)malloc(sizeof(char) * len); temp = (char *)malloc(sizeof(char) * len);
if(!temp) { if(!temp) {
fprintf(stderr, "X11.app: Memory allocation error creating space for socket name test.\n"); ErrorF("X11.app: Memory allocation error creating space for socket name test.\n");
exit(1); exit(1);
} }
strlcpy(temp, launchd_id_prefix, len); strlcpy(temp, bundle_id_prefix, len);
strlcat(temp, ":0", len); strlcat(temp, ":0", len);
if(strcmp(temp, s) != 0) { if(strcmp(temp, s) != 0) {
/* If we don't have a match, unset it. */ /* If we don't have a match, unset it. */
fprintf(stderr, "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, launchd_id_prefix); ErrorF("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix);
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
free(temp); free(temp);
} }
} else { } else {
/* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */ /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
fprintf(stderr, "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n"); ErrorF("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
unsetenv("DISPLAY"); unsetenv("DISPLAY");
} }
} }
@ -562,9 +573,9 @@ int main(int argc, char **argv, char **envp) {
/* Setup the initial crasherporter info */ /* Setup the initial crasherporter info */
strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__)); strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__));
fprintf(stderr, "X11.app: main(): argc=%d\n", argc); ErrorF("X11.app: main(): argc=%d\n", argc);
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
if(!strcmp(argv[i], "--listenonly")) { if(!strcmp(argv[i], "--listenonly")) {
listenOnly = TRUE; listenOnly = TRUE;
} }
@ -572,7 +583,7 @@ int main(int argc, char **argv, char **envp) {
mp = checkin_or_register(server_bootstrap_name); mp = checkin_or_register(server_bootstrap_name);
if(mp == MACH_PORT_NULL) { if(mp == MACH_PORT_NULL) {
fprintf(stderr, "NULL mach service: %s", server_bootstrap_name); ErrorF("NULL mach service: %s", server_bootstrap_name);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -621,10 +632,10 @@ int main(int argc, char **argv, char **envp) {
} }
/* Main event loop */ /* Main event loop */
fprintf(stderr, "Waiting for startup parameters via Mach IPC.\n"); ErrorF("Waiting for startup parameters via Mach IPC.\n");
kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0); kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
fprintf(stderr, "%s.X11(mp): %s\n", LAUNCHD_ID_PREFIX, mach_error_string(kr)); ErrorF("%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -640,9 +651,9 @@ static int execute(const char *command) {
newargv[2] = command; newargv[2] = command;
newargv[3] = NULL; newargv[3] = NULL;
fprintf(stderr, "X11.app: Launching %s:\n", command); ErrorF("X11.app: Launching %s:\n", command);
for(p=newargv; *p; p++) { for(p=newargv; *p; p++) {
fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p); ErrorF("\targv[%ld] = %s\n", (long int)(p - newargv), *p);
} }
execvp (newargv[0], (char * const *) newargv); execvp (newargv[0], (char * const *) newargv);

View File

@ -69,11 +69,11 @@ int launchd_display_fd(void) {
return ERROR_FD; return ERROR_FD;
} }
listening_fd_array = launch_data_dict_lookup(sockets_dict, LAUNCHD_ID_PREFIX":0"); listening_fd_array = launch_data_dict_lookup(sockets_dict, BUNDLE_ID_PREFIX":0");
if (NULL == listening_fd_array) { if (NULL == listening_fd_array) {
listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0"); listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
if (NULL == listening_fd_array) { if (NULL == listening_fd_array) {
fprintf(stderr,"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", LAUNCHD_ID_PREFIX); fprintf(stderr,"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", BUNDLE_ID_PREFIX);
return ERROR_FD; return ERROR_FD;
} }
} }

View File

@ -40,7 +40,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#define kX11AppBundleId LAUNCHD_ID_PREFIX".X11" #define kX11AppBundleId BUNDLE_ID_PREFIX".X11"
#define kX11AppBundlePath "/Contents/MacOS/X11" #define kX11AppBundlePath "/Contents/MacOS/X11"
static char *server_bootstrap_name = kX11AppBundleId; static char *server_bootstrap_name = kX11AppBundleId;
@ -56,15 +56,6 @@ static char *server_bootstrap_name = kX11AppBundleId;
#include "launchd_fd.h" #include "launchd_fd.h"
#ifndef BUILD_DATE
#define BUILD_DATE "?"
#endif
#ifndef XSERVER_VERSION
#define XSERVER_VERSION "?"
#endif
#define DEBUG 1
static char x11_path[PATH_MAX + 1]; static char x11_path[PATH_MAX + 1];
static pid_t x11app_pid = 0; static pid_t x11app_pid = 0;
@ -197,13 +188,6 @@ int main(int argc, char **argv, char **envp) {
string_t handoff_socket_filename; string_t handoff_socket_filename;
sig_t handler; sig_t handler;
if(argc == 2 && !strcmp(argv[1], "-version")) {
fprintf(stderr, "X.org Release 7.5\n");
fprintf(stderr, "X.Org X Server %s\n", XSERVER_VERSION);
fprintf(stderr, "Build Date: %s\n", BUILD_DATE);
return EXIT_SUCCESS;
}
if(getenv("X11_PREFS_DOMAIN")) if(getenv("X11_PREFS_DOMAIN"))
server_bootstrap_name = getenv("X11_PREFS_DOMAIN"); server_bootstrap_name = getenv("X11_PREFS_DOMAIN");
@ -300,8 +284,8 @@ int main(int argc, char **argv, char **envp) {
/* We have fixed-size string lengths due to limitations in IPC, /* We have fixed-size string lengths due to limitations in IPC,
* so we need to copy our argv and envp. * so we need to copy our argv and envp.
*/ */
newargv = (string_array_t)malloc(argc * sizeof(string_t)); newargv = (string_array_t)calloc((1 + argc), sizeof(string_t));
newenvp = (string_array_t)malloc(envpc * sizeof(string_t)); newenvp = (string_array_t)calloc((1 + envpc), sizeof(string_t));
if(!newargv || !newenvp) { if(!newargv || !newenvp) {
fprintf(stderr, "Xquartz: Memory allocation failure\n"); fprintf(stderr, "Xquartz: Memory allocation failure\n");

View File

@ -1,5 +1,5 @@
AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks \ AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks \
-DLAUNCHD_ID_PREFIX=\"$(LAUNCHD_ID_PREFIX)\" -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\"
AM_CFLAGS=$(XPBPROXY_CFLAGS) AM_CFLAGS=$(XPBPROXY_CFLAGS)

View File

@ -34,7 +34,7 @@
#include <unistd.h> /*for getpid*/ #include <unistd.h> /*for getpid*/
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>
static const char *app_prefs_domain = LAUNCHD_ID_PREFIX".xpbproxy"; static const char *app_prefs_domain = BUNDLE_ID_PREFIX".xpbproxy";
CFStringRef app_prefs_domain_cfstr; CFStringRef app_prefs_domain_cfstr;
/* Stubs */ /* Stubs */
@ -53,12 +53,22 @@ static void signal_handler (int sig) {
} }
} }
void
ErrorF(const char * f, ...)
{
va_list args;
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
}
int main (int argc, const char *argv[]) { int main (int argc, const char *argv[]) {
const char *s; const char *s;
int i; int i;
#ifdef DEBUG #ifdef DEBUG
printf("pid: %u\n", getpid()); ErrorF("pid: %u\n", getpid());
#endif #endif
xpbproxy_is_standalone = YES; xpbproxy_is_standalone = YES;
@ -70,13 +80,13 @@ int main (int argc, const char *argv[]) {
if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) { if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
app_prefs_domain = argv[++i]; app_prefs_domain = argv[++i];
} else if (strcmp (argv[i], "--help") == 0) { } else if (strcmp (argv[i], "--help") == 0) {
printf("usage: xpbproxy OPTIONS\n" ErrorF("usage: xpbproxy OPTIONS\n"
"Pasteboard proxying for X11.\n\n" "Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n" "--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: %s)\n", app_prefs_domain); " (default: %s)\n", app_prefs_domain);
return 0; return 0;
} else { } else {
fprintf(stderr, "usage: xpbproxy OPTIONS...\n" ErrorF("usage: xpbproxy OPTIONS...\n"
"Try 'xpbproxy --help' for more information.\n"); "Try 'xpbproxy --help' for more information.\n");
return 1; return 1;
} }

View File

@ -105,7 +105,7 @@ int xpbproxy_run (void) {
} }
if (xpbproxy_dpy == NULL) { if (xpbproxy_dpy == NULL) {
fprintf (stderr, "xpbproxy: can't open default display\n"); ErrorF("xpbproxy: can't open default display\n");
[pool release]; [pool release];
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -115,7 +115,7 @@ int xpbproxy_run (void) {
if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base, if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
&xpbproxy_apple_wm_error_base)) { &xpbproxy_apple_wm_error_base)) {
fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n"); ErrorF("xpbproxy: can't open AppleWM server extension\n");
[pool release]; [pool release];
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -147,19 +147,3 @@ Time xpbproxy_current_timestamp (void) {
/* FIXME: may want to fetch a timestamp from the server.. */ /* FIXME: may want to fetch a timestamp from the server.. */
return CurrentTime; return CurrentTime;
} }
void debug_printf (const char *fmt, ...) {
static int spew = -1;
if (spew == -1) {
char *x = getenv ("DEBUG");
spew = (x != NULL && atoi (x) != 0);
}
if (spew) {
va_list args;
va_start(args, fmt);
vfprintf (stderr, fmt, args);
va_end(args);
}
}

View File

@ -77,14 +77,16 @@ extern BOOL xpbproxy_have_xfixes;
/* from x-input.m */ /* from x-input.m */
extern BOOL xpbproxy_input_register (void); extern BOOL xpbproxy_input_register (void);
/* os/log.c or app-main.m */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
#ifdef DEBUG #ifdef DEBUG
/* BEWARE: this can cause a string memory leak, according to the leaks program. */ /* BEWARE: this can cause a string memory leak, according to the leaks program. */
# define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args) # define DebugF(msg, args...) ErrorF("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
#else #else
# define DB(msg, args...) do {} while (0) # define DebugF(...) /* */
#endif #endif
#define TRACE() DB("TRACE\n") #define TRACE() DebugF("TRACE\n")
extern void debug_printf (const char *fmt, ...);
#endif /* PBPROXY_H */ #endif /* PBPROXY_H */

View File

@ -87,7 +87,7 @@ static void xpbproxy_process_xevents(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if(pool == nil) { if(pool == nil) {
fprintf(stderr, "unable to allocate/init auto release pool!\n"); ErrorF("unable to allocate/init auto release pool!\n");
return; return;
} }

View File

@ -81,19 +81,19 @@ static struct propdata null_propdata = {NULL, 0, 0};
#ifdef DEBUG #ifdef DEBUG
static void static void
dump_prefs (FILE *fp) { dump_prefs() {
fprintf(fp, ErrorF(fp,
"pbproxy preferences:\n" "pbproxy preferences:\n"
"\tactive %u\n" "\tactive %u\n"
"\tprimary_on_grab %u\n" "\tprimary_on_grab %u\n"
"\tclipboard_to_pasteboard %u\n" "\tclipboard_to_pasteboard %u\n"
"\tpasteboard_to_primary %u\n" "\tpasteboard_to_primary %u\n"
"\tpasteboard_to_clipboard %u\n", "\tpasteboard_to_clipboard %u\n",
pbproxy_prefs.active, pbproxy_prefs.active,
pbproxy_prefs.primary_on_grab, pbproxy_prefs.primary_on_grab,
pbproxy_prefs.clipboard_to_pasteboard, pbproxy_prefs.clipboard_to_pasteboard,
pbproxy_prefs.pasteboard_to_primary, pbproxy_prefs.pasteboard_to_primary,
pbproxy_prefs.pasteboard_to_clipboard); pbproxy_prefs.pasteboard_to_clipboard);
} }
#endif #endif
@ -152,7 +152,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
unsigned char *newbuf = NULL; unsigned char *newbuf = NULL;
#ifdef TEST #ifdef TEST
printf("bytesleft %lu\n", bytesleft); ErrorF("bytesleft %lu\n", bytesleft);
#endif #endif
if (Success != XGetWindowProperty (xpbproxy_dpy, win, property, if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
@ -161,24 +161,29 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
type, &format, &numitems, type, &format, &numitems,
&bytesleft, &chunk)) &bytesleft, &chunk))
{ {
DB ("Error while getting window property.\n"); DebugF ("Error while getting window property.\n");
*pdata = null_propdata; *pdata = null_propdata;
free (buf); free (buf);
return True; return True;
} }
#ifdef TEST #ifdef TEST
printf("format %d numitems %lu bytesleft %lu\n", ErrorF("format %d numitems %lu bytesleft %lu\n",
format, numitems, bytesleft); format, numitems, bytesleft);
printf("type %s\n", XGetAtomName (xpbproxy_dpy, *type)); ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
#endif #endif
/* Format is the number of bits. */ /* Format is the number of bits. */
chunkbytesize = numitems * (format / 8); if (format == 8)
chunkbytesize = numitems;
else if (format == 16)
chunkbytesize = numitems * sizeof(short);
else if (format == 32)
chunkbytesize = numitems * sizeof(long);
#ifdef TEST #ifdef TEST
printf("chunkbytesize %zu\n", chunkbytesize); ErrorF("chunkbytesize %zu\n", chunkbytesize);
#endif #endif
newbuflen = buflen + chunkbytesize; newbuflen = buflen + chunkbytesize;
if (newbuflen > 0) if (newbuflen > 0)
@ -206,7 +211,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
} }
#ifdef TEST #ifdef TEST
printf("bytesleft %lu\n", bytesleft); ErrorF("bytesleft %lu\n", bytesleft);
#endif #endif
} while (bytesleft > 0); } while (bytesleft > 0);
@ -231,13 +236,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (pdata->format != 32) if (pdata->format != 32)
{ {
fprintf(stderr, "Atom list is expected to be formatted as an array of 32bit values.\n"); ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
return None; return None;
} }
for (i = 0, step = pdata->format >> 3; i < pdata->length; i += step) for (i = 0, step = sizeof(long); i < pdata->length; i += step)
{ {
a = (Atom)*(uint32_t *)(pdata->data + i); a = (Atom)*(long *)(pdata->data + i);
if (a == atoms->image_png) if (a == atoms->image_png)
{ {
@ -260,7 +265,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
char *type = XGetAtomName(xpbproxy_dpy, a); char *type = XGetAtomName(xpbproxy_dpy, a);
if (type) if (type)
{ {
DB("Unhandled X11 mime type: %s", type); DebugF("Unhandled X11 mime type: %s", type);
XFree(type); XFree(type);
} }
} }
@ -373,7 +378,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (countNow != changeCount) if (countNow != changeCount)
{ {
DB ("changed pasteboard!\n"); DebugF ("changed pasteboard!\n");
changeCount = countNow; changeCount = countNow;
if (pbproxy_prefs.pasteboard_to_primary) if (pbproxy_prefs.pasteboard_to_primary)
@ -457,9 +462,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return TRUE; return TRUE;
if(owner != None) { if(owner != None) {
fprintf (stderr, "A clipboard manager using window 0x%lx " ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection. "
"already owns the clipboard selection. " "pbproxy will not sync clipboard to pasteboard.\n", owner);
"pbproxy will not sync clipboard to pasteboard.\n", owner);
return FALSE; return FALSE;
} }
@ -486,7 +490,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE (); TRACE ();
DB ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
if(e->selection == atoms->clipboard) { if(e->selection == atoms->clipboard) {
/* /*
@ -503,7 +507,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing /* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing
* to avoid a race. * to avoid a race.
*/ */
fprintf(stderr, "Another clipboard manager was started! " ErrorF("Another clipboard manager was started! "
"xpbproxy is disabling syncing with clipboard.\n"); "xpbproxy is disabling syncing with clipboard.\n");
pbproxy_prefs.clipboard_to_pasteboard = NO; pbproxy_prefs.clipboard_to_pasteboard = NO;
} }
@ -528,7 +532,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* The owner probably died or we are just starting up pbproxy. * The owner probably died or we are just starting up pbproxy.
* Set pbproxy's _selection_window as the owner, and continue. * Set pbproxy's _selection_window as the owner, and continue.
*/ */
DB ("No clipboard owner.\n"); DebugF ("No clipboard owner.\n");
[self copy_completed:atoms->clipboard]; [self copy_completed:atoms->clipboard];
return; return;
} else if (owner == _selection_window) { } else if (owner == _selection_window) {
@ -536,7 +540,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return; return;
} }
DB ("requesting targets\n"); DebugF ("requesting targets\n");
request_atom = atoms->targets; request_atom = atoms->targets;
XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets, XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets,
@ -576,7 +580,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* We are supposed to use an empty event mask, and not propagate * We are supposed to use an empty event mask, and not propagate
* the event, according to the ICCCM. * the event, according to the ICCCM.
*/ */
DB ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor); DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply); XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
XFlush (xpbproxy_dpy); XFlush (xpbproxy_dpy);
@ -613,7 +617,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if ([pbtypes containsObject:NSStringPboardType]) if ([pbtypes containsObject:NSStringPboardType])
{ {
/* We have a string type that we can convert to UTF8, or Latin-1... */ /* We have a string type that we can convert to UTF8, or Latin-1... */
DB ("NSStringPboardType\n"); DebugF ("NSStringPboardType\n");
list[count] = atoms->utf8_string; list[count] = atoms->utf8_string;
++count; ++count;
list[count] = atoms->string; list[count] = atoms->string;
@ -625,18 +629,26 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* TODO add the NSPICTPboardType back again, once we have conversion /* TODO add the NSPICTPboardType back again, once we have conversion
* functionality in send_image. * functionality in send_image.
*/ */
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
#endif
if ([pbtypes containsObject:NSPICTPboardType] if ([pbtypes containsObject:NSPICTPboardType]
|| [pbtypes containsObject:NSTIFFPboardType]) || [pbtypes containsObject:NSTIFFPboardType])
{ {
/* We can convert a TIFF to a PNG or JPEG. */ /* We can convert a TIFF to a PNG or JPEG. */
DB ("NSTIFFPboardType\n"); DebugF ("NSTIFFPboardType\n");
list[count] = atoms->image_png; list[count] = atoms->image_png;
++count; ++count;
list[count] = atoms->image_jpeg; list[count] = atoms->image_jpeg;
++count; ++count;
} }
#ifdef __clang__
#pragma clang diagnostic pop
#endif
if (count) if (count)
{ {
/* We have a list of ATOMs to send. */ /* We have a list of ATOMs to send. */
@ -671,7 +683,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return; return;
} }
DB ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]); DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
data = [pb stringForType:NSStringPboardType]; data = [pb stringForType:NSStringPboardType];
@ -691,19 +703,19 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
length = strlen (bytes); length = strlen (bytes);
if (length < 50) { if (length < 50) {
DB ("UTF-8: %s\n", bytes); DebugF ("UTF-8: %s\n", bytes);
DB ("UTF-8 length: %u\n", length); DebugF ("UTF-8 length: %u\n", length);
} }
} }
else else
{ {
DB ("Latin-1\n"); DebugF ("Latin-1\n");
bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding]; bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
/*WARNING: bytes is not NUL-terminated. */ /*WARNING: bytes is not NUL-terminated. */
length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
} }
DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target, XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
8, PropModeReplace, (unsigned char *) bytes, length); 8, PropModeReplace, (unsigned char *) bytes, length);
@ -745,7 +757,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{ {
if (8 != textprop.format) if (8 != textprop.format)
DB ("textprop.format is unexpectedly not 8 - it's %d instead\n", DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
textprop.format); textprop.format);
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
@ -837,7 +849,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == data) if (nil == data)
{ {
[img autorelease]; [img autorelease];
fprintf(stderr, "unable to convert PICT to TIFF!\n"); ErrorF("unable to convert PICT to TIFF!\n");
return YES; return YES;
} }
@ -913,7 +925,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
imagetype = NSJPEGFileType; imagetype = NSJPEGFileType;
else else
{ {
fprintf(stderr, "internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n"); ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
} }
pbtypes = [pb types]; pbtypes = [pb types];
@ -925,7 +937,14 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype]) if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype])
return; return;
} }
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
#endif
else if ([pbtypes containsObject:NSPICTPboardType]) else if ([pbtypes containsObject:NSPICTPboardType])
#ifdef __clang__
#pragma clang diagnostic pop
#endif
{ {
if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype]) if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype])
return; return;
@ -977,7 +996,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != e->target) if (None != e->target)
DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
if (e->target == atoms->targets) if (e->target == atoms->targets)
{ {
@ -1029,15 +1048,15 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[self release_pending]; [self release_pending];
if (None == e->property) { if (None == e->property) {
DB ("e->property is None.\n"); DebugF ("e->property is None.\n");
[self copy_completed:e->selection]; [self copy_completed:e->selection];
/* Nothing is selected. */ /* Nothing is selected. */
return; return;
} }
#if 0 #if 0
printf ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
printf ("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property)); ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
#endif #endif
if ([self is_incr_type:e]) if ([self is_incr_type:e])
@ -1046,7 +1065,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* This is an INCR-style transfer, which means that we * This is an INCR-style transfer, which means that we
* will get the data after a series of PropertyNotify events. * will get the data after a series of PropertyNotify events.
*/ */
DB ("is INCR\n"); DebugF ("is INCR\n");
if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type)) if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
{ {
@ -1063,7 +1082,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pending.requestor = e->requestor; pending.requestor = e->requestor;
pending.selection = e->selection; pending.selection = e->selection;
DB ("set pending.requestor to 0x%lx\n", pending.requestor); DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
} }
else else
{ {
@ -1076,7 +1095,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* We have the complete selection data.*/ /* We have the complete selection data.*/
[self handle_selection:e->selection type:type propdata:&pdata]; [self handle_selection:e->selection type:type propdata:&pdata];
DB ("handled selection with the first notify_event\n"); DebugF ("handled selection with the first notify_event\n");
} }
} }
@ -1096,7 +1115,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (name) if (name)
{ {
DB ("e->atom %s\n", name); DebugF ("e->atom %s\n", name);
XFree(name); XFree(name);
} }
#endif #endif
@ -1104,7 +1123,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != pending.requestor && PropertyNewValue == e->state) if (None != pending.requestor && PropertyNewValue == e->state)
{ {
DB ("pending.requestor 0x%lx\n", pending.requestor); DebugF ("pending.requestor 0x%lx\n", pending.requestor);
if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type)) if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
{ {
@ -1146,7 +1165,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
case XFixesSelectionWindowDestroyNotify: case XFixesSelectionWindowDestroyNotify:
case XFixesSelectionClientCloseNotify: case XFixesSelectionClientCloseNotify:
default: default:
fprintf(stderr, "Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype); ErrorF("Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
break; break;
} }
} }
@ -1176,7 +1195,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (name) if (name)
{ {
DB ("requesting %s\n", name); DebugF ("requesting %s\n", name);
} }
#endif #endif
request_atom = preferred; request_atom = preferred;
@ -1200,11 +1219,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == data) if (nil == data)
{ {
DB ("unable to create NSData object!\n"); DebugF ("unable to create NSData object!\n");
return; return;
} }
DB ("data retainCount before NSBitmapImageRep initWithData: %u\n", DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n",
[data retainCount]); [data retainCount]);
bmimage = [[NSBitmapImageRep alloc] initWithData:data]; bmimage = [[NSBitmapImageRep alloc] initWithData:data];
@ -1212,11 +1231,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == bmimage) if (nil == bmimage)
{ {
[data autorelease]; [data autorelease];
DB ("unable to create NSBitmapImageRep!\n"); DebugF ("unable to create NSBitmapImageRep!\n");
return; return;
} }
DB ("data retainCount after NSBitmapImageRep initWithData: %u\n", DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n",
[data retainCount]); [data retainCount]);
@try @try
@ -1226,13 +1245,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
@catch (NSException *e) @catch (NSException *e)
{ {
DB ("NSTIFFException!\n"); DebugF ("NSTIFFException!\n");
[data autorelease]; [data autorelease];
[bmimage autorelease]; [bmimage autorelease];
return; return;
} }
DB ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]); DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil]; pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
@ -1246,12 +1265,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil]; [pb declareTypes:pbtypes owner:nil];
if (YES != [pb setData:tiff forType:NSTIFFPboardType]) if (YES != [pb setData:tiff forType:NSTIFFPboardType])
{ {
DB ("writing pasteboard data failed!\n"); DebugF ("writing pasteboard data failed!\n");
} }
[data autorelease]; [data autorelease];
DB ("bmimage retainCount before release %u\n", [bmimage retainCount]); DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]);
[bmimage autorelease]; [bmimage autorelease];
} }
@ -1279,10 +1298,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil]; [pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) { if (YES != [pb setString:string forType:NSStringPboardType]) {
fprintf(stderr, "pasteboard setString:forType: failed!\n"); ErrorF("pasteboard setString:forType: failed!\n");
} }
[string autorelease]; [string autorelease];
DB ("done handling utf8 string\n"); DebugF ("done handling utf8 string\n");
} }
/* This handles the STRING type, which should be in Latin-1. */ /* This handles the STRING type, which should be in Latin-1. */
@ -1308,7 +1327,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil]; [pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) { if (YES != [pb setString:string forType:NSStringPboardType]) {
fprintf(stderr, "pasteboard setString:forType failed in handle_string!\n"); ErrorF("pasteboard setString:forType failed in handle_string!\n");
} }
[string autorelease]; [string autorelease];
} }
@ -1374,7 +1393,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
name = XGetAtomName (xpbproxy_dpy, selection); name = XGetAtomName (xpbproxy_dpy, selection);
if (name) if (name)
{ {
DB ("copy_completed: %s\n", name); DebugF ("copy_completed: %s\n", name);
XFree (name); XFree (name);
} }
#endif #endif
@ -1435,10 +1454,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard); pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
/* This is used for debugging. */ /* This is used for debugging. */
//dump_prefs(stdout); //dump_prefs();
if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) { if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) {
fprintf(stderr, "Disabling sync_primary_on_select functionality due to missing XFixes extension.\n"); ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
pbproxy_prefs.primary_on_grab = NO; pbproxy_prefs.primary_on_grab = NO;
} }

View File

@ -62,7 +62,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <IOKit/pwr_mgt/IOPMLib.h> #include <IOKit/pwr_mgt/IOPMLib.h>
#include <pthread.h> #include <libkern/OSAtomic.h>
#include <signal.h> #include <signal.h>
#include <rootlessCommon.h> #include <rootlessCommon.h>
@ -279,9 +279,9 @@ static void pokeActivityCallback(CFRunLoopTimerRef timer, void *info) {
static void QuartzScreenSaver(int state) { static void QuartzScreenSaver(int state) {
static CFRunLoopTimerRef pokeActivityTimer = NULL; static CFRunLoopTimerRef pokeActivityTimer = NULL;
static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL }; static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL };
static pthread_mutex_t pokeActivityMutex = PTHREAD_MUTEX_INITIALIZER; static OSSpinLock pokeActivitySpinLock = OS_SPINLOCK_INIT;
pthread_mutex_lock(&pokeActivityMutex); OSSpinLockLock(&pokeActivitySpinLock);
if(state) { if(state) {
if(pokeActivityTimer == NULL) if(pokeActivityTimer == NULL)
@ -303,7 +303,7 @@ static void QuartzScreenSaver(int state) {
CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes); CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
} }
QuartzScreenSaverEnd: QuartzScreenSaverEnd:
pthread_mutex_unlock(&pokeActivityMutex); OSSpinLockUnlock(&pokeActivitySpinLock);
} }
void QuartzShowFullscreen(int state) { void QuartzShowFullscreen(int state) {

View File

@ -70,7 +70,7 @@ typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
/* /*
* Rootless helper functions * Rootless helper functions
*/ */
typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber); typedef Bool (*IsX11WindowProc)(int windowNumber);
typedef void (*HideWindowsProc)(Bool hide); typedef void (*HideWindowsProc)(Bool hide);
/* /*

View File

@ -56,8 +56,6 @@
#include "X11Application.h" #include "X11Application.h"
#include "threadSafety.h"
#ifdef NDEBUG #ifdef NDEBUG
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
@ -369,9 +367,9 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue
if (pDev->kbdfeed) if (pDev->kbdfeed)
memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize); memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
//fprintf(stderr, "per_key_repeat =\n"); //ErrorF("per_key_repeat =\n");
//for(i=0; i < XkbPerKeyBitArraySize; i++) //for(i=0; i < XkbPerKeyBitArraySize; i++)
// fprintf(stderr, "%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n"); // ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
/* And now we notify the puppies about the changes */ /* And now we notify the puppies about the changes */
XkbDDXChangeControls(pDev, &old, ctrl); XkbDDXChangeControls(pDev, &old, ctrl);
@ -686,6 +684,11 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
} }
#endif #endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
#endif
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 #if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (chr_data == NULL) { if (chr_data == NULL) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
@ -719,6 +722,10 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
} }
#endif #endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
if(currentKeyLayoutRef) if(currentKeyLayoutRef)
CFRelease(currentKeyLayoutRef); CFRelease(currentKeyLayoutRef);
@ -775,10 +782,16 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
} }
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 #if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
} else { // kchr } else { // kchr
UInt32 c, state = 0, state2 = 0; UInt32 c, state = 0, state2 = 0;
UInt16 code; UInt16 code;
code = i | mods[j]; code = i | mods[j];
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
#endif
c = KeyTranslate (chr_data, code, &state); c = KeyTranslate (chr_data, code, &state);
/* Dead keys are only processed on key-down, so ask /* Dead keys are only processed on key-down, so ask
@ -789,6 +802,10 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
if (state != 0) if (state != 0)
c = KeyTranslate (chr_data, code | 128, &state2); c = KeyTranslate (chr_data, code | 128, &state2);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
/* Characters seem to be in MacRoman encoding. */ /* Characters seem to be in MacRoman encoding. */
if (c != 0 && c != 0x0010) { if (c != 0 && c != 0x0010) {

View File

@ -32,8 +32,6 @@
#include "X11/keysym.h" #include "X11/keysym.h"
#include "inputstr.h" #include "inputstr.h"
#include <pthread.h>
// Each key can generate 4 glyphs. They are, in order: // Each key can generate 4 glyphs. They are, in order:
// unshifted, shifted, modeswitch unshifted, modeswitch shifted // unshifted, shifted, modeswitch unshifted, modeswitch shifted
#define GLYPHS_PER_KEY 4 #define GLYPHS_PER_KEY 4

View File

@ -84,10 +84,7 @@ void QuartzInitServer(int argc, char **argv, char **envp) {
args->argv = argv; args->argv = argv;
args->envp = envp; args->envp = envp;
APPKIT_THREAD_ID = pthread_self(); if (!create_thread(server_thread, args)) {
SERVER_THREAD_ID = create_thread(server_thread, args);
if (!SERVER_THREAD_ID) {
FatalError("can't create secondary thread\n"); FatalError("can't create secondary thread\n");
} }
} }

View File

@ -1,78 +0,0 @@
/*
* Copyright (C) 2008 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.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "threadSafety.h"
#include "os.h"
pthread_t APPKIT_THREAD_ID;
pthread_t SERVER_THREAD_ID;
#include <AvailabilityMacros.h>
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
#include <execinfo.h>
void spewCallStack(void) {
void* callstack[128];
int i, frames = backtrace(callstack, 128);
char** strs = backtrace_symbols(callstack, frames);
for (i = 0; i < frames; ++i) {
ErrorF("%s\n", strs[i]);
}
free(strs);
}
#else
void spewCallStack(void) {
return;
}
#endif
void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line) {
if(pthread_equal(pthread_self(), tid))
return;
/* NOOOO! */
ErrorF("Thread Assertion Failed: self=%s, expected=%s\n%s:%s:%d\n",
threadSafetyID(pthread_self()), threadSafetyID(tid),
file, fun, line);
spewCallStack();
}
const char *threadSafetyID(pthread_t tid) {
if(pthread_equal(tid, APPKIT_THREAD_ID)) {
return "Appkit Thread";
} else if(pthread_equal(tid, SERVER_THREAD_ID)) {
return "Xserver Thread";
} else {
return "Unknown Thread";
}
}

View File

@ -1,56 +0,0 @@
/*
* Copyright (C) 2008 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.
*/
#ifndef _XQ_THREAD_SAFETY_H_
#define _XQ_THREAD_SAFETY_H_
#define DEBUG_THREADS 1
#include <pthread.h>
extern pthread_t APPKIT_THREAD_ID;
extern pthread_t SERVER_THREAD_ID;
/* Dump the call stack */
void spewCallStack(void);
/* Print message to ErrorF if we're in the wrong thread */
void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line);
/* Get a string that identifies our thread nicely */
const char *threadSafetyID(pthread_t tid);
#define threadSafetyAssert(tid) _threadSafetyAssert(tid, __FILE__, __FUNCTION__, __LINE__)
#ifdef DEBUG_THREADS
#define TA_APPKIT() threadSafetyAssert(APPKIT_THREAD_ID)
#define TA_SERVER() threadSafetyAssert(SERVER_THREAD_ID)
#else
#define TA_SERVER()
#define TA_APPKIT()
#endif
#endif /* _XQ_THREAD_SAFETY_H_ */

View File

@ -562,7 +562,6 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
(*pScreen->WindowExposures)(pWin, prgn, bsreg); (*pScreen->WindowExposures)(pWin, prgn, bsreg);
pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
pScreen->WindowExposures = DRIWindowExposures; pScreen->WindowExposures = DRIWindowExposures;
} }
@ -587,7 +586,6 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
(*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
/* rewrap */ /* rewrap */
pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
pScreen->CopyWindow = DRICopyWindow; pScreen->CopyWindow = DRICopyWindow;
} }
@ -605,7 +603,6 @@ DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind); returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
/* rewrap */ /* rewrap */
pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
pScreen->ValidateTree = DRIValidateTree; pScreen->ValidateTree = DRIValidateTree;
return returnValue; return returnValue;
@ -632,7 +629,6 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
(*pScreen->PostValidateTree)(pParent, pChild, kind); (*pScreen->PostValidateTree)(pParent, pChild, kind);
/* rewrap */ /* rewrap */
pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
pScreen->PostValidateTree = DRIPostValidateTree; pScreen->PostValidateTree = DRIPostValidateTree;
} }
} }
@ -653,7 +649,6 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
(*pScreen->ClipNotify)(pWin, dx, dy); (*pScreen->ClipNotify)(pWin, dx, dy);
pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
pScreen->ClipNotify = DRIClipNotify; pScreen->ClipNotify = DRIClipNotify;
} }
} }

View File

@ -38,7 +38,7 @@ Bool QuartzModeBundleInit(void);
void AppleDRIExtensionInit(void); void AppleDRIExtensionInit(void);
void xprAppleWMInit(void); void xprAppleWMInit(void);
Bool xprInit(ScreenPtr pScreen); Bool xprInit(ScreenPtr pScreen);
Bool xprIsX11Window(void *nsWindow, int windowNumber); Bool xprIsX11Window(int windowNumber);
WindowPtr xprGetXWindow(xp_window_id wid); WindowPtr xprGetXWindow(xp_window_id wid);
void xprHideWindows(Bool hide); void xprHideWindows(Bool hide);

View File

@ -114,8 +114,8 @@ static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) {
static int xprFrameDraw( static int xprFrameDraw(
WindowPtr pWin, WindowPtr pWin,
int class, xp_frame_class class,
unsigned int attr, xp_frame_attr attr,
const BoxRec *outer, const BoxRec *outer,
const BoxRec *inner, const BoxRec *inner,
unsigned int title_len, unsigned int title_len,

View File

@ -57,8 +57,6 @@
#include "xprEvent.h" #include "xprEvent.h"
Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) { Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) {
TA_SERVER();
switch(e->subtype) { switch(e->subtype) {
case kXquartzWindowState: case kXquartzWindowState:
DEBUG_LOG("kXquartzWindowState\n"); DEBUG_LOG("kXquartzWindowState\n");

View File

@ -1,7 +1,7 @@
/* /*
* Xplugin rootless implementation frame functions * Xplugin rootless implementation frame functions
* *
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * Copyright (c) 2002-2011 Apple Computer, Inc. All rights reserved.
* Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved. * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -35,7 +35,6 @@
#include "rootlessCommon.h" #include "rootlessCommon.h"
#include <Xplugin.h> #include <Xplugin.h>
#include "x-hash.h" #include "x-hash.h"
#include "x-list.h"
#include "applewmExt.h" #include "applewmExt.h"
#include "propertyst.h" #include "propertyst.h"
@ -44,9 +43,11 @@
#include "windowstr.h" #include "windowstr.h"
#include "quartz.h" #include "quartz.h"
#include "threadSafety.h" #ifdef HAVE_LIBDISPATCH
#include <dispatch/dispatch.h>
#else
#include <pthread.h> #include <pthread.h>
#endif
#define DEFINE_ATOM_HELPER(func,atom_name) \ #define DEFINE_ATOM_HELPER(func,atom_name) \
static Atom func (void) { \ static Atom func (void) { \
@ -63,7 +64,13 @@ DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
/* Maps xp_window_id -> RootlessWindowRec */ /* Maps xp_window_id -> RootlessWindowRec */
static x_hash_table *window_hash; static x_hash_table *window_hash;
/* Need to guard window_hash since xprIsX11Window can be called from any thread. */
#ifdef HAVE_LIBDISPATCH
static dispatch_queue_t window_hash_serial_q;
#else
static pthread_mutex_t window_hash_mutex; static pthread_mutex_t window_hash_mutex;
#endif
/* Prototypes for static functions */ /* Prototypes for static functions */
static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
@ -93,8 +100,6 @@ static inline xp_error
xprConfigureWindow(xp_window_id id, unsigned int mask, xprConfigureWindow(xp_window_id id, unsigned int mask,
const xp_window_changes *values) const xp_window_changes *values)
{ {
TA_SERVER();
return xp_configure_window(id, mask, values); return xp_configure_window(id, mask, values);
} }
@ -106,8 +111,6 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
unsigned int native_id; unsigned int native_id;
long data; long data;
TA_SERVER();
err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id); err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id);
if (err == Success) if (err == Success)
{ {
@ -137,8 +140,6 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
unsigned int mask = 0; unsigned int mask = 0;
xp_error err; xp_error err;
TA_SERVER();
wc.x = newX; wc.x = newX;
wc.y = newY; wc.y = newY;
wc.width = pFrame->width; wc.width = pFrame->width;
@ -186,15 +187,15 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
return FALSE; return FALSE;
} }
if (window_hash == NULL) #ifdef HAVE_LIBDISPATCH
{ dispatch_async(window_hash_serial_q, ^{
window_hash = x_hash_table_new(NULL, NULL, NULL, NULL); x_hash_table_insert(window_hash, pFrame->wid, pFrame);
pthread_mutex_init(&window_hash_mutex, NULL); });
} #else
pthread_mutex_lock(&window_hash_mutex); pthread_mutex_lock(&window_hash_mutex);
x_hash_table_insert(window_hash, pFrame->wid, pFrame); x_hash_table_insert(window_hash, pFrame->wid, pFrame);
pthread_mutex_unlock(&window_hash_mutex); pthread_mutex_unlock(&window_hash_mutex);
#endif
xprSetNativeProperty(pFrame); xprSetNativeProperty(pFrame);
@ -209,11 +210,16 @@ static void
xprDestroyFrame(RootlessFrameID wid) xprDestroyFrame(RootlessFrameID wid)
{ {
xp_error err; xp_error err;
TA_SERVER();
#ifdef HAVE_LIBDISPATCH
dispatch_async(window_hash_serial_q, ^{
x_hash_table_remove(window_hash, wid);
});
#else
pthread_mutex_lock(&window_hash_mutex); pthread_mutex_lock(&window_hash_mutex);
x_hash_table_remove(window_hash, wid); x_hash_table_remove(window_hash, wid);
pthread_mutex_unlock(&window_hash_mutex); pthread_mutex_unlock(&window_hash_mutex);
#endif
err = xp_destroy_window(x_cvt_vptr_to_uint(wid)); err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
if (err != Success) if (err != Success)
@ -229,8 +235,6 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
{ {
xp_window_changes wc; xp_window_changes wc;
TA_SERVER();
wc.x = newX; wc.x = newX;
wc.y = newY; wc.y = newY;
// ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY); // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
@ -248,8 +252,6 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
{ {
xp_window_changes wc; xp_window_changes wc;
TA_SERVER();
wc.x = newX; wc.x = newX;
wc.y = newY; wc.y = newY;
wc.width = newW; wc.width = newW;
@ -269,8 +271,10 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
xp_window_changes wc; xp_window_changes wc;
unsigned int mask = XP_STACKING; unsigned int mask = XP_STACKING;
#ifdef HAVE_LIBDISPATCH
TA_SERVER(); __block
#endif
RootlessWindowRec *winRec;
/* Stack frame below nextWid it if it exists, or raise /* Stack frame below nextWid it if it exists, or raise
frame above everything otherwise. */ frame above everything otherwise. */
@ -283,18 +287,24 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
wc.sibling = x_cvt_vptr_to_uint(nextWid); wc.sibling = x_cvt_vptr_to_uint(nextWid);
} }
if(window_hash) { #ifdef HAVE_LIBDISPATCH
RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, wid, NULL); dispatch_sync(window_hash_serial_q, ^{
winRec = x_hash_table_lookup(window_hash, wid, NULL);
});
#else
pthread_mutex_lock(&window_hash_mutex);
winRec = x_hash_table_lookup(window_hash, wid, NULL);
pthread_mutex_unlock(&window_hash_mutex);
#endif
if(winRec) { if(winRec) {
if(XQuartzIsRootless) if(XQuartzIsRootless)
wc.window_level = normal_window_levels[winRec->level]; wc.window_level = normal_window_levels[winRec->level];
else if(XQuartzShieldingWindowLevel) else if(XQuartzShieldingWindowLevel)
wc.window_level = XQuartzShieldingWindowLevel + 1; wc.window_level = XQuartzShieldingWindowLevel + 1;
else else
wc.window_level = rooted_window_levels[winRec->level]; wc.window_level = rooted_window_levels[winRec->level];
mask |= XP_WINDOW_LEVEL; mask |= XP_WINDOW_LEVEL;
}
} }
xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc); xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc);
@ -309,8 +319,6 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
{ {
xp_window_changes wc; xp_window_changes wc;
TA_SERVER();
if (pShape != NULL) if (pShape != NULL)
{ {
wc.shape_nrects = RegionNumRects(pShape); wc.shape_nrects = RegionNumRects(pShape);
@ -336,8 +344,6 @@ xprUnmapFrame(RootlessFrameID wid)
{ {
xp_window_changes wc; xp_window_changes wc;
TA_SERVER();
wc.stack_mode = XP_UNMAPPED; wc.stack_mode = XP_UNMAPPED;
wc.sibling = 0; wc.sibling = 0;
@ -356,8 +362,6 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
unsigned int rowbytes[2]; unsigned int rowbytes[2];
xp_error err; xp_error err;
TA_SERVER();
err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL); err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL);
if (err != Success) if (err != Success)
FatalError("Could not lock window %i for drawing.", (int)x_cvt_vptr_to_uint(wid)); FatalError("Could not lock window %i for drawing.", (int)x_cvt_vptr_to_uint(wid));
@ -374,7 +378,6 @@ static void
xprStopDrawing(RootlessFrameID wid, Bool flush) xprStopDrawing(RootlessFrameID wid, Bool flush)
{ {
xp_error err; xp_error err;
TA_SERVER();
err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush); err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
if(err != Success) if(err != Success)
@ -388,8 +391,6 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
static void static void
xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage) xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
{ {
TA_SERVER();
xp_flush_window(x_cvt_vptr_to_uint(wid)); xp_flush_window(x_cvt_vptr_to_uint(wid));
} }
@ -401,8 +402,6 @@ static void
xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
int shift_x, int shift_y) int shift_x, int shift_y)
{ {
TA_SERVER();
xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y); xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y);
} }
@ -416,8 +415,6 @@ xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
{ {
DeleteProperty(serverClient, oldWin, xa_native_window_id()); DeleteProperty(serverClient, oldWin, xa_native_window_id());
TA_SERVER();
xprSetNativeProperty(pFrame); xprSetNativeProperty(pFrame);
} }
@ -429,8 +426,6 @@ static Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
{ {
WindowPtr pWin = pFrame->win; WindowPtr pWin = pFrame->win;
TA_SERVER();
return AppleWMDoReorderWindow(pWin); return AppleWMDoReorderWindow(pWin);
} }
@ -443,8 +438,6 @@ static void
xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
int dx, int dy) int dx, int dy)
{ {
TA_SERVER();
xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid), xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid),
dstNrects, dstRects, dx, dy); dstNrects, dstRects, dx, dy);
} }
@ -479,11 +472,16 @@ xprInit(ScreenPtr pScreen)
{ {
RootlessInit(pScreen, &xprRootlessProcs); RootlessInit(pScreen, &xprRootlessProcs);
TA_SERVER();
rootless_CopyBytes_threshold = xp_copy_bytes_threshold; rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
rootless_CopyWindow_threshold = xp_scroll_area_threshold; rootless_CopyWindow_threshold = xp_scroll_area_threshold;
assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL)));
#ifdef HAVE_LIBDISPATCH
assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL)));
#else
assert(0 == pthread_mutex_init(&window_hash_mutex, NULL));
#endif
return TRUE; return TRUE;
} }
@ -495,73 +493,36 @@ xprInit(ScreenPtr pScreen)
WindowPtr WindowPtr
xprGetXWindow(xp_window_id wid) xprGetXWindow(xp_window_id wid)
{ {
#ifdef HAVE_LIBDISPATCH
RootlessWindowRec *winRec __block;
dispatch_sync(window_hash_serial_q, ^{
winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
});
#else
RootlessWindowRec *winRec; RootlessWindowRec *winRec;
if (window_hash == NULL)
return NULL;
winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
return winRec != NULL ? winRec->win : NULL;
}
#ifdef UNUSED_CODE
/*
* Given the id of a physical window, try to find the top-level (or root)
* X window that it represents.
*/
WindowPtr
xprGetXWindowFromAppKit(int windowNumber)
{
RootlessWindowRec *winRec;
Bool ret;
xp_window_id wid;
if (window_hash == NULL)
return FALSE;
/* need to lock, since this function can be called by any thread */
pthread_mutex_lock(&window_hash_mutex); pthread_mutex_lock(&window_hash_mutex);
if (xp_lookup_native_window(windowNumber, &wid))
ret = xprGetXWindow(wid) != NULL;
else
ret = FALSE;
pthread_mutex_unlock(&window_hash_mutex);
if (!ret) return NULL;
winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
pthread_mutex_unlock(&window_hash_mutex);
#endif
return winRec != NULL ? winRec->win : NULL; return winRec != NULL ? winRec->win : NULL;
} }
#endif
/* /*
* The windowNumber is an AppKit window number. Returns TRUE if xpr is * The windowNumber is an AppKit window number. Returns TRUE if xpr is
* displaying a window with that number. * displaying a window with that number.
*/ */
Bool Bool
xprIsX11Window(void *nsWindow, int windowNumber) xprIsX11Window(int windowNumber)
{ {
Bool ret; Bool ret;
xp_window_id wid; xp_window_id wid;
if (window_hash == NULL)
return FALSE;
/* need to lock, since this function can be called by any thread */
pthread_mutex_lock(&window_hash_mutex);
if (xp_lookup_native_window(windowNumber, &wid)) if (xp_lookup_native_window(windowNumber, &wid))
ret = xprGetXWindow(wid) != NULL; ret = xprGetXWindow(wid) != NULL;
else else
ret = FALSE; ret = FALSE;
pthread_mutex_unlock(&window_hash_mutex);
return ret; return ret;
} }
@ -578,8 +539,6 @@ xprHideWindows(Bool hide)
int screen; int screen;
WindowPtr pRoot, pWin; WindowPtr pRoot, pWin;
TA_SERVER();
for (screen = 0; screen < screenInfo.numScreens; screen++) { for (screen = 0; screen < screenInfo.numScreens; screen++) {
RootlessFrameID prevWid = NULL; RootlessFrameID prevWid = NULL;
pRoot = screenInfo.screens[screen]->root; pRoot = screenInfo.screens[screen]->root;

View File

@ -172,7 +172,6 @@
#include "input.h" #include "input.h"
#include "mipointer.h" #include "mipointer.h"
#include "X11/keysym.h" #include "X11/keysym.h"
#include "mibstore.h"
#include "micoord.h" #include "micoord.h"
#include "dix.h" #include "dix.h"
#include "miline.h" #include "miline.h"

View File

@ -36,8 +36,6 @@
#include "winmultiwindowclass.h" #include "winmultiwindowclass.h"
#include "winprefs.h" #include "winprefs.h"
#include "propertyst.h"
#include "propertyst.h" #include "propertyst.h"
#include "windowstr.h" #include "windowstr.h"

View File

@ -69,8 +69,6 @@ winInitVideo (ScreenPtr pScreen)
#include <X11/extensions/Xv.h> #include <X11/extensions/Xv.h>
#endif #endif
#include "win.h"
#if 0 #if 0

View File

@ -30,9 +30,6 @@
/* Support Damage extension */ /* Support Damage extension */
#undef DAMAGE #undef DAMAGE
/* Build for darwin with Quartz support */
#undef DARWIN_WITH_QUARTZ
/* Use OsVendorVErrorF */ /* Use OsVendorVErrorF */
#undef DDXOSVERRORF #undef DDXOSVERRORF
@ -127,8 +124,8 @@
/* Support application updating through sparkle. */ /* Support application updating through sparkle. */
#undef XQUARTZ_SPARKLE #undef XQUARTZ_SPARKLE
/* Prefix to use for launchd identifiers */ /* Prefix to use for bundle identifiers */
#undef LAUNCHD_ID_PREFIX #undef BUNDLE_ID_PREFIX
/* Build a standalone xpbproxy */ /* Build a standalone xpbproxy */
#undef STANDALONE_XPBPROXY #undef STANDALONE_XPBPROXY
@ -447,7 +444,7 @@
/* Define to 1 if you have the `ffs' function. */ /* Define to 1 if you have the `ffs' function. */
#undef HAVE_FFS #undef HAVE_FFS
/* If the compiler supports a TLS storage class define it to that here */ /* The compiler supported TLS storage class, prefering initial-exec if tls_model is supported */
#undef TLS #undef TLS
/* Correctly set _XSERVER64 for OSX fat binaries */ /* Correctly set _XSERVER64 for OSX fat binaries */

View File

@ -510,17 +510,17 @@ typedef enum {
extern _X_EXPORT const char *LogInit(const char *fname, const char *backup); extern _X_EXPORT const char *LogInit(const char *fname, const char *backup);
extern _X_EXPORT void LogClose(void); extern _X_EXPORT void LogClose(void);
extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value); extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value);
extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args); extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args) _X_ATTRIBUTE_PRINTF(2,0);
extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3); extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3);
extern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format, extern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format,
va_list args); va_list args) _X_ATTRIBUTE_PRINTF(3,0);
extern _X_EXPORT void LogMessageVerb(MessageType type, int verb, const char *format, extern _X_EXPORT void LogMessageVerb(MessageType type, int verb, const char *format,
...) _X_ATTRIBUTE_PRINTF(3,4); ...) _X_ATTRIBUTE_PRINTF(3,4);
extern _X_EXPORT void LogMessage(MessageType type, const char *format, ...) extern _X_EXPORT void LogMessage(MessageType type, const char *format, ...)
_X_ATTRIBUTE_PRINTF(2,3); _X_ATTRIBUTE_PRINTF(2,3);
extern _X_EXPORT void FreeAuditTimer(void); extern _X_EXPORT void FreeAuditTimer(void);
extern _X_EXPORT void AuditF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); extern _X_EXPORT void AuditF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern _X_EXPORT void VAuditF(const char *f, va_list args); extern _X_EXPORT void VAuditF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1,0);
extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN; extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
#ifdef DEBUG #ifdef DEBUG
@ -529,7 +529,7 @@ extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X
#define DebugF(...) /* */ #define DebugF(...) /* */
#endif #endif
extern _X_EXPORT void VErrorF(const char *f, va_list args); extern _X_EXPORT void VErrorF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1,0);
extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern _X_EXPORT void Error(const char *str); extern _X_EXPORT void Error(const char *str);
extern _X_EXPORT void LogPrintMarkers(void); extern _X_EXPORT void LogPrintMarkers(void);

View File

@ -1,74 +0,0 @@
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_tls.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_TLS
#
# DESCRIPTION
#
# Provides a test for the compiler support of thread local storage (TLS)
# extensions. Defines TLS if it is found. Currently only knows about GCC
# and MSVC. I think SunPro uses the same as GCC, and Borland apparently
# supports either.
#
# LICENSE
#
# Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
AC_DEFUN([AX_TLS], [
AC_MSG_CHECKING(for thread local storage (TLS) class)
AC_CACHE_VAL(ac_cv_tls, [
ax_tls_keywords="__thread __declspec(thread) none"
for ax_tls_keyword in $ax_tls_keywords; do
case $ax_tls_keyword in
none) ac_cv_tls=none ; break ;;
*)
AC_TRY_COMPILE(
[#include <stdlib.h>
static void
foo(void) {
static ] $ax_tls_keyword [ int bar;
exit(1);
}],
[],
[ac_cv_tls=$ax_tls_keyword ; break],
ac_cv_tls=none
)
esac
done
])
if test "$ac_cv_tls" != "none"; then
dnl AC_DEFINE([TLS], [], [If the compiler supports a TLS storage class define it to that here])
AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
fi
AC_MSG_RESULT($ac_cv_tls)
])

57
m4/xorg-tls.m4 Normal file
View File

@ -0,0 +1,57 @@
dnl Copyright © 2011 Apple Inc.
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
dnl and/or sell copies of the Software, and to permit persons to whom the
dnl Software is furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice (including the next
dnl paragraph) shall be included in all copies or substantial portions of the
dnl Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl
dnl Authors: Jeremy Huddleston <jeremyhu@apple.com>
AC_DEFUN([XORG_TLS], [
AC_MSG_CHECKING(for thread local storage (TLS) support)
AC_CACHE_VAL(ac_cv_tls, [
ac_cv_tls=none
keywords="__thread __declspec(thread)"
for kw in $keywords ; do
AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw)
done
])
AC_MSG_RESULT($ac_cv_tls)
if test "$ac_cv_tls" != "none"; then
AC_MSG_CHECKING(for tls_model attribute support)
AC_CACHE_VAL(ac_cv_tls_model, [
save_CFLAGS="$CFLAGS"
dnl -Werror causes clang's default -Wunknown-attributes to become an error
dnl We can't use -Werror=unknown-attributes because gcc doesn't understand it
dnl -Werror=attributes is for gcc, clang seems to ignore it
CFLAGS="$CFLAGS -Werror -Werror=attributes"
AC_TRY_COMPILE([int $ac_cv_tls __attribute__((tls_model("initial-exec"))) test;], [],
ac_cv_tls_model=yes, ac_cv_tls_model=no)
CFLAGS="$save_CFLAGS"
])
AC_MSG_RESULT($ac_cv_tls_model)
if test "x$ac_cv_tls_model" = "xyes" ; then
xorg_tls=$ac_cv_tls' __attribute__((tls_model("initial-exec")))'
else
xorg_tls=$ac_cv_tls
fi
AC_DEFINE_UNQUOTED([TLS], $xorg_tls, [The compiler supported TLS storage class, prefering initial-exec if tls_model is supported])
fi
])

View File

@ -24,7 +24,7 @@ MAN_SUBSTS += -e 's|__logdir__|$(logdir)|g' \
-e 's|__sysconfdir__|$(sysconfdir)|g' \ -e 's|__sysconfdir__|$(sysconfdir)|g' \
-e 's|__xconfigdir__|$(__XCONFIGDIR__)|g' \ -e 's|__xconfigdir__|$(__XCONFIGDIR__)|g' \
-e 's|__xkbdir__|$(XKB_BASE_DIRECTORY)|g' \ -e 's|__xkbdir__|$(XKB_BASE_DIRECTORY)|g' \
-e 's|__laucnd_id_prefix__|$(LAUNCHD_ID_PREFIX)|g' \ -e 's|__laucnd_id_prefix__|$(BUNDLE_ID_PREFIX)|g' \
-e 's|__modulepath__|$(DEFAULT_MODULE_PATH)|g' \ -e 's|__modulepath__|$(DEFAULT_MODULE_PATH)|g' \
-e 's|__default_font_path__|$(COMPILEDDEFAULTFONTPATH)|g' \ -e 's|__default_font_path__|$(COMPILEDDEFAULTFONTPATH)|g' \
-e '\|$(COMPILEDDEFAULTFONTPATH)| s|/,|/, |g' -e '\|$(COMPILEDDEFAULTFONTPATH)| s|/,|/, |g'

View File

@ -325,7 +325,7 @@ RootlessGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
box.x1 = x - glyph->info.x; box.x1 = x - glyph->info.x;
box.y1 = y - glyph->info.y; box.y1 = y - glyph->info.y;
box.x2 = box.x1 + glyph->info.width; box.x2 = box.x1 + glyph->info.width;
box.y2 = box.y2 + glyph->info.height; box.y2 = box.y1 + glyph->info.height;
x += glyph->info.xOff; x += glyph->info.xOff;
y += glyph->info.yOff; y += glyph->info.yOff;
@ -453,7 +453,6 @@ RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst,
pChild = pChild->nextSib; pChild = pChild->nextSib;
} }
anyMarked = TRUE; anyMarked = TRUE;
pFirst = pFirst->nextSib;
} }
if (anyMarked) if (anyMarked)
(* MarkWindow)(pWin->parent); (* MarkWindow)(pWin->parent);

View File

@ -200,7 +200,6 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
RegionRec childUnion; RegionRec childUnion;
Bool overlap; Bool overlap;
RegionPtr borderVisible; RegionPtr borderVisible;
Bool resized;
/* /*
* Figure out the new visibility of this window. * Figure out the new visibility of this window.
* The extent of the universe should be the same as the extent of * The extent of the universe should be the same as the extent of
@ -340,7 +339,6 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
} }
borderVisible = pParent->valdata->before.borderVisible; borderVisible = pParent->valdata->before.borderVisible;
resized = pParent->valdata->before.resized;
RegionNull(&pParent->valdata->after.borderExposed); RegionNull(&pParent->valdata->after.borderExposed);
RegionNull(&pParent->valdata->after.exposed); RegionNull(&pParent->valdata->after.exposed);

View File

@ -1489,7 +1489,7 @@ InvalidHost (
} }
for (host = validhosts; host; host = host->next) for (host = validhosts; host; host = host->next)
{ {
if ((host->family == FamilyServerInterpreted)) { if (host->family == FamilyServerInterpreted) {
if (siAddrMatch (family, addr, len, host, client)) { if (siAddrMatch (family, addr, len, host, client)) {
return 0; return 0;
} }

View File

@ -102,6 +102,10 @@ OR PERFORMANCE OF THIS SOFTWARE.
#include "xf86bigfontsrv.h" #include "xf86bigfontsrv.h"
#endif #endif
#ifdef __clang__
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
#ifdef DDXOSVERRORF #ifdef DDXOSVERRORF
void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL; void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL;
#endif #endif

View File

@ -2,6 +2,11 @@
#include <dix-config.h> #include <dix-config.h>
#endif #endif
#include <X11/Xfuncproto.h>
/* ErrorF is used by xtrans */
extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
#define TRANS_REOPEN #define TRANS_REOPEN
#define TRANS_SERVER #define TRANS_SERVER
#define XSERV_t #define XSERV_t

View File

@ -158,7 +158,7 @@ addFormat (FormatInitRec formats[256],
return ++nformat; return ++nformat;
} }
#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1)) #define Mask(n) ((1 << (n)) - 1)
PictFormatPtr PictFormatPtr
PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)

View File

@ -27,7 +27,6 @@
#include "scrnintstr.h" #include "scrnintstr.h"
#include "windowstr.h" #include "windowstr.h"
#include "scrnintstr.h"
#include "exevents.h" #include "exevents.h"
#include <assert.h> #include <assert.h>

View File

@ -38,7 +38,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "exevents.h" #include "exevents.h"
#include "exglobals.h" #include "exglobals.h"
#include "windowstr.h" #include "windowstr.h"
#include "exevents.h"
#include <xkbsrv.h> #include <xkbsrv.h>
#include "xkb.h" #include "xkb.h"