shovelling code around ...

(cherry picked from commit 2143182ba4)
This commit is contained in:
Ben Byer 2008-03-31 21:04:37 -07:00 committed by Jeremy Huddleston
parent 985c631b2e
commit c1be4e3379
5 changed files with 130 additions and 123 deletions

View File

@ -113,6 +113,9 @@ Equipment Corporation.
#include "dispatch.h" /* InitProcVectors() */
#endif
#include <pthread.h>
pthread_key_t threadname_key=0;
#ifdef DPMSExtension
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
@ -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();

View File

@ -52,6 +52,11 @@ in this Software without prior written authorization from The Open Group.
#include <unistd.h>
#include <IOKit/hidsystem/IOLLEvent.h>
#define _APPLEWM_SERVER_
#include "applewmExt.h"
#include <X11/extensions/applewm.h>
/* 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; i<nevents; i++) {
if (xe[i].u.u.type == kXquartzDeactivate)
DarwinReleaseModifiers();
QuartzProcessEvent(&xe[i]);
switch(xe[i].u.u.type) {
case kXquartzControllerNotify:
DEBUG_LOG("kXquartzControllerNotify\n");
AppleWMSendEvent(AppleWMControllerNotify,
AppleWMControllerNotifyMask,
xe[i].u.clientMessage.u.l.longs0,
xe[i].u.clientMessage.u.l.longs1);
break;
case kXquartzPasteboardNotify:
DEBUG_LOG("kXquartzPasteboardNotify\n");
AppleWMSendEvent(AppleWMPasteboardNotify,
AppleWMPasteboardNotifyMask,
xe[i].u.clientMessage.u.l.longs0,
xe[i].u.clientMessage.u.l.longs1);
break;
case kXquartzActivate:
DEBUG_LOG("kXquartzActivate\n");
QuartzShow(xe[i].u.keyButtonPointer.rootX,
xe[i].u.keyButtonPointer.rootY);
AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask,
AppleWMIsActive, 0);
break;
case kXquartzDeactivate:
DEBUG_LOG("kXquartzDeactivate\n");
DarwinReleaseModifiers();
AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask,
AppleWMIsInactive, 0);
QuartzHide();
break;
case kXquartzWindowState:
DEBUG_LOG("kXquartzWindowState\n");
RootlessNativeWindowStateChanged(xe[i].u.clientMessage.u.l.longs0,
xe[i].u.clientMessage.u.l.longs1);
break;
case kXquartzWindowMoved:
DEBUG_LOG("kXquartzWindowMoved\n");
RootlessNativeWindowMoved ((WindowPtr)xe[i].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[i].u.clientMessage.u.l.longs0);
if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
#else
// ErrorF("kXquartzSetRootless not implemented\n");
#endif
break;
case kXquartzSetRootClip:
QuartzSetRootClip((BOOL)xe[i].u.clientMessage.u.l.longs0);
break;
case kXquartzQuit:
GiveUp(0);
break;
case kXquartzBringAllToFront:
DEBUG_LOG("kXquartzBringAllToFront\n");
RootlessOrderAllWindows();
break;
case kXquartzSpaceChanged:
DEBUG_LOG("kXquartzSpaceChanged\n");
QuartzSpaceChanged(xe[i].u.clientMessage.u.l.longs0);
break;
default:
ErrorF("Unknown application defined event type %d.\n", xe[i].u.u.type);
}
}
}
@ -199,14 +293,14 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
mieqSetHandler(kXquartzQuit, DarwinEventHandler);
mieqSetHandler(kXquartzReadPasteboard, DarwinEventHandler);
mieqSetHandler(kXquartzWritePasteboard, DarwinEventHandler);
mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard);
mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard);
mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
mieqSetHandler(kXquartzDisplayChanged, DarwinEventHandler);
mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);

View File

@ -730,6 +730,14 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
* it to an equivalent X keyboard map and modifier map.
*/
static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
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);
memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
/* TODO: Clean this up

View File

@ -232,17 +232,17 @@ RREditConnectionInfo (ScreenPtr pScreen)
#endif
/*
* QuartzUpdateScreens
* QuartzDisplayChangeHandler
* Adjust for screen arrangement changes.
*/
static void QuartzUpdateScreens(void)
void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
{
ScreenPtr pScreen;
WindowPtr pRoot;
int x, y, width, height, sx, sy;
xEvent e;
DEBUG_LOG("QuartzUpdateScreens()\n");
DEBUG_LOG("QuartzDisplayChangedHandler()\n");
if (noPseudoramiXExtension || screenInfo.numScreens != 1)
{
/* FIXME: if not using Xinerama, we have multiple screens, and
@ -308,7 +308,7 @@ static void QuartzUpdateScreens(void)
* Calls mode specific screen resume to restore the X clip regions
* (if needed) and the X server cursor state.
*/
static void QuartzShow(
void QuartzShow(
int x, // cursor location
int y )
{
@ -331,7 +331,7 @@ static void QuartzShow(
* hidden. Calls mode specific screen suspend to set X clip regions to
* prevent drawing (if needed) and restore the Aqua cursor.
*/
static void QuartzHide(void)
void QuartzHide(void)
{
int i;
@ -350,7 +350,7 @@ static void QuartzHide(void)
* QuartzSetRootClip
* Enable or disable rendering to the X screen.
*/
static void QuartzSetRootClip(
void QuartzSetRootClip(
BOOL enable)
{
int i;
@ -369,7 +369,7 @@ static void QuartzSetRootClip(
* QuartzSpaceChanged
* Unmap offscreen windows, map onscreen windows
*/
static void QuartzSpaceChanged(uint32_t space_id) {
void QuartzSpaceChanged(uint32_t space_id) {
/* Do something special here, so we don't depend on quartz-wm for spaces to work... */
DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
}
@ -404,112 +404,3 @@ QuartzMessageServerThread(
mieqEnqueue(NULL, &xe);
}
/*
* QuartzProcessEvent
* Process Quartz specific events.
*/
void QuartzProcessEvent(xEvent *xe) {
switch (xe->u.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);
}
}

View File

@ -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