diff --git a/dix/main.c b/dix/main.c index db4347341..8f6507f5c 100644 --- a/dix/main.c +++ b/dix/main.c @@ -113,6 +113,9 @@ Equipment Corporation. #include "dispatch.h" /* InitProcVectors() */ #endif +#include +pthread_key_t threadname_key=0; + #ifdef DPMSExtension #define DPMS_SERVER #include @@ -248,6 +251,17 @@ main(int argc, char *argv[], char *envp[]) char *xauthfile; HWEventQueueType alwaysCheckForInput[2]; + if(threadname_key == 0) ErrorF("pthread_key_create returned %d\n", pthread_key_create(&threadname_key, NULL)); + ErrorF("threadname_key = %d\n", threadname_key); + if(pthread_getspecific(threadname_key) == NULL) { + char *nameptr = malloc(32); + sprintf(nameptr, "main thread %d", random()); + // strcpy(nameptr, "main thread"); + ErrorF("calling: pthread_setspecific(%d, %s)=%d\n", threadname_key, nameptr, pthread_setspecific(threadname_key, nameptr)); + if (pthread_getspecific(threadname_key) != NULL) ErrorF("current thread: %s\n", (char *)pthread_getspecific(threadname_key)); + } else { + if (pthread_getspecific(threadname_key) != NULL) ErrorF("thread was already: %s\n", (char *)pthread_getspecific(threadname_key)); + } display = "0"; InitGlobals(); diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 230050f60..28a712dab 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -52,6 +52,11 @@ in this Software without prior written authorization from The Open Group. #include #include +#define _APPLEWM_SERVER_ +#include "applewmExt.h" +#include + + /* Fake button press/release for scroll wheel move. */ #define SCROLLWHEELUPFAKE 4 #define SCROLLWHEELDOWNFAKE 5 @@ -177,14 +182,103 @@ static void DarwinSimulateMouseClick( DarwinUpdateModifiers(KeyPress, modifierMask); } +/* Generic handler for Xquartz-specifc events. When possible, these should + be moved into their own individual functions and set as handlers using + mieqSetHandler. */ + void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { int i; DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents); for (i=0; iu.u.type) { - case kXquartzControllerNotify: - DEBUG_LOG("kXquartzControllerNotify\n"); - AppleWMSendEvent(AppleWMControllerNotify, - AppleWMControllerNotifyMask, - xe->u.clientMessage.u.l.longs0, - xe->u.clientMessage.u.l.longs1); - break; - - case kXquartzPasteboardNotify: - DEBUG_LOG("kXquartzPasteboardNotify\n"); - AppleWMSendEvent(AppleWMPasteboardNotify, - AppleWMPasteboardNotifyMask, - xe->u.clientMessage.u.l.longs0, - xe->u.clientMessage.u.l.longs1); - break; - - case kXquartzActivate: - DEBUG_LOG("kXquartzActivate\n"); - QuartzShow(xe->u.keyButtonPointer.rootX, - xe->u.keyButtonPointer.rootY); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMIsActive, 0); - break; - - case kXquartzDeactivate: - DEBUG_LOG("kXquartzDeactivate\n"); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMIsInactive, 0); - QuartzHide(); - break; - - case kXquartzDisplayChanged: - DEBUG_LOG("kXquartzDisplayChanged\n"); - QuartzUpdateScreens(); - break; - - case kXquartzWindowState: - DEBUG_LOG("kXquartzWindowState\n"); - RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0, - xe->u.clientMessage.u.l.longs1); - break; - - case kXquartzWindowMoved: - DEBUG_LOG("kXquartzWindowMoved\n"); - RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0); - break; - - case kXquartzToggleFullscreen: - DEBUG_LOG("kXquartzToggleFullscreen\n"); -#ifdef DARWIN_DDX_MISSING - if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot); - else if (quartzHasRoot) QuartzHide(); - else QuartzShow(); -#else - // ErrorF("kXquartzToggleFullscreen not implemented\n"); -#endif - break; - - case kXquartzSetRootless: - DEBUG_LOG("kXquartzSetRootless\n"); -#ifdef DARWIN_DDX_MISSING - QuartzSetRootless(xe->u.clientMessage.u.l.longs0); - if (!quartzEnableRootless && !quartzHasRoot) QuartzHide(); -#else - // ErrorF("kXquartzSetRootless not implemented\n"); -#endif - break; - - case kXquartzSetRootClip: - QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0); - break; - - case kXquartzQuit: - GiveUp(0); - break; - -#if 0 - case kXquartzReadPasteboard: - QuartzReadPasteboard(); - break; - - case kXquartzWritePasteboard: - QuartzWritePasteboard(); - break; -#endif - - case kXquartzBringAllToFront: - DEBUG_LOG("kXquartzBringAllToFront\n"); - RootlessOrderAllWindows(); - break; - - case kXquartzSpaceChanged: - DEBUG_LOG("kXquartzSpaceChanged\n"); - QuartzSpaceChanged(xe->u.clientMessage.u.l.longs0); - break; - default: - ErrorF("Unknown application defined event type %d.\n", xe->u.u.type); - } -} diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h index fbe308a92..ffe06f9c6 100644 --- a/hw/xquartz/quartz.h +++ b/hw/xquartz/quartz.h @@ -130,5 +130,5 @@ void QuartzInitOutput(int argc,char **argv); void QuartzInitInput(int argc, char **argv); void QuartzGiveUp(void); void QuartzProcessEvent(xEvent *xe); - +void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents); #endif