shovelling code around ...
This commit is contained in:
parent
6e833e41e2
commit
2143182ba4
14
dix/main.c
14
dix/main.c
@ -110,6 +110,9 @@ Equipment Corporation.
|
|||||||
#include "dispatch.h" /* InitProcVectors() */
|
#include "dispatch.h" /* InitProcVectors() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
pthread_key_t threadname_key=0;
|
||||||
|
|
||||||
#ifdef DPMSExtension
|
#ifdef DPMSExtension
|
||||||
#define DPMS_SERVER
|
#define DPMS_SERVER
|
||||||
#include <X11/extensions/dpms.h>
|
#include <X11/extensions/dpms.h>
|
||||||
@ -252,6 +255,17 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
char *xauthfile;
|
char *xauthfile;
|
||||||
HWEventQueueType alwaysCheckForInput[2];
|
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";
|
display = "0";
|
||||||
|
|
||||||
InitGlobals();
|
InitGlobals();
|
||||||
|
@ -52,6 +52,11 @@ in this Software without prior written authorization from The Open Group.
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <IOKit/hidsystem/IOLLEvent.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. */
|
/* Fake button press/release for scroll wheel move. */
|
||||||
#define SCROLLWHEELUPFAKE 4
|
#define SCROLLWHEELUPFAKE 4
|
||||||
#define SCROLLWHEELDOWNFAKE 5
|
#define SCROLLWHEELDOWNFAKE 5
|
||||||
@ -177,14 +182,103 @@ static void DarwinSimulateMouseClick(
|
|||||||
DarwinUpdateModifiers(KeyPress, modifierMask);
|
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) {
|
void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
|
DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
|
||||||
for (i=0; i<nevents; i++) {
|
for (i=0; i<nevents; i++) {
|
||||||
if (xe[i].u.u.type == kXquartzDeactivate)
|
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();
|
DarwinReleaseModifiers();
|
||||||
QuartzProcessEvent(&xe[i]);
|
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(kXquartzDeactivate, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
|
mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzQuit, DarwinEventHandler);
|
mieqSetHandler(kXquartzQuit, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzReadPasteboard, DarwinEventHandler);
|
mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard);
|
||||||
mieqSetHandler(kXquartzWritePasteboard, DarwinEventHandler);
|
mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard);
|
||||||
mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
|
mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
|
mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
|
mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
|
mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
|
mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzDisplayChanged, DarwinEventHandler);
|
mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
|
||||||
mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
|
mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
|
||||||
mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
|
mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
|
||||||
|
|
||||||
|
@ -730,6 +730,14 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
|
|||||||
* it to an equivalent X keyboard map and modifier map.
|
* it to an equivalent X keyboard map and modifier map.
|
||||||
*/
|
*/
|
||||||
static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
|
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));
|
memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
|
||||||
|
|
||||||
/* TODO: Clean this up
|
/* TODO: Clean this up
|
||||||
|
@ -240,17 +240,17 @@ RREditConnectionInfo (ScreenPtr pScreen)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QuartzUpdateScreens
|
* QuartzDisplayChangeHandler
|
||||||
* Adjust for screen arrangement changes.
|
* Adjust for screen arrangement changes.
|
||||||
*/
|
*/
|
||||||
static void QuartzUpdateScreens(void)
|
void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
|
||||||
{
|
{
|
||||||
ScreenPtr pScreen;
|
ScreenPtr pScreen;
|
||||||
WindowPtr pRoot;
|
WindowPtr pRoot;
|
||||||
int x, y, width, height, sx, sy;
|
int x, y, width, height, sx, sy;
|
||||||
xEvent e;
|
xEvent e;
|
||||||
|
|
||||||
DEBUG_LOG("QuartzUpdateScreens()\n");
|
DEBUG_LOG("QuartzDisplayChangedHandler()\n");
|
||||||
if (noPseudoramiXExtension || screenInfo.numScreens != 1)
|
if (noPseudoramiXExtension || screenInfo.numScreens != 1)
|
||||||
{
|
{
|
||||||
/* FIXME: if not using Xinerama, we have multiple screens, and
|
/* FIXME: if not using Xinerama, we have multiple screens, and
|
||||||
@ -316,7 +316,7 @@ static void QuartzUpdateScreens(void)
|
|||||||
* Calls mode specific screen resume to restore the X clip regions
|
* Calls mode specific screen resume to restore the X clip regions
|
||||||
* (if needed) and the X server cursor state.
|
* (if needed) and the X server cursor state.
|
||||||
*/
|
*/
|
||||||
static void QuartzShow(
|
void QuartzShow(
|
||||||
int x, // cursor location
|
int x, // cursor location
|
||||||
int y )
|
int y )
|
||||||
{
|
{
|
||||||
@ -339,7 +339,7 @@ static void QuartzShow(
|
|||||||
* hidden. Calls mode specific screen suspend to set X clip regions to
|
* hidden. Calls mode specific screen suspend to set X clip regions to
|
||||||
* prevent drawing (if needed) and restore the Aqua cursor.
|
* prevent drawing (if needed) and restore the Aqua cursor.
|
||||||
*/
|
*/
|
||||||
static void QuartzHide(void)
|
void QuartzHide(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ static void QuartzHide(void)
|
|||||||
* QuartzSetRootClip
|
* QuartzSetRootClip
|
||||||
* Enable or disable rendering to the X screen.
|
* Enable or disable rendering to the X screen.
|
||||||
*/
|
*/
|
||||||
static void QuartzSetRootClip(
|
void QuartzSetRootClip(
|
||||||
BOOL enable)
|
BOOL enable)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -377,7 +377,7 @@ static void QuartzSetRootClip(
|
|||||||
* QuartzSpaceChanged
|
* QuartzSpaceChanged
|
||||||
* Unmap offscreen windows, map onscreen windows
|
* 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... */
|
/* 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);
|
DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
|
||||||
}
|
}
|
||||||
@ -412,112 +412,3 @@ QuartzMessageServerThread(
|
|||||||
|
|
||||||
mieqEnqueue(NULL, &xe);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -130,5 +130,5 @@ void QuartzInitOutput(int argc,char **argv);
|
|||||||
void QuartzInitInput(int argc, char **argv);
|
void QuartzInitInput(int argc, char **argv);
|
||||||
void QuartzGiveUp(void);
|
void QuartzGiveUp(void);
|
||||||
void QuartzProcessEvent(xEvent *xe);
|
void QuartzProcessEvent(xEvent *xe);
|
||||||
|
void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user