summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Byer <bbyer@apple.com>2008-03-31 21:04:37 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-04-02 17:47:59 -0700
commitc1be4e3379d8780dff20390939b657ca0973995a (patch)
treedb7ec46c78329f4a8f73d3c3ef8cc29d477d7610
parent985c631b2e1f113039e6e620f030505435fd9815 (diff)
shovelling code around ...
(cherry picked from commit 2143182ba49195bbb2e9163ea6872fd68e7a4a85)
-rw-r--r--dix/main.c14
-rw-r--r--hw/xquartz/darwinEvents.c106
-rw-r--r--hw/xquartz/darwinKeyboard.c8
-rw-r--r--hw/xquartz/quartz.c123
-rw-r--r--hw/xquartz/quartz.h2
5 files changed, 130 insertions, 123 deletions
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.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();
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 <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);
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index 8d1ee8ec9..355d9f066 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -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
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index ec211cf0a..a65bd3748 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -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);
- }
-}
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