Rewrote parts of the Xquartz event-handling code (thanks daniels and whot!)
It should still be considered a work in progress, but mouse events almost work.
This commit is contained in:
parent
ed7ccc481a
commit
39ecd6fff4
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* Darwin event queue and event handling
|
Darwin event queue and event handling
|
||||||
*/
|
|
||||||
/*
|
Copyright 2007 Apple Inc.
|
||||||
Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
|
|
||||||
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
|
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
|
||||||
|
Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
|
||||||
|
|
||||||
This file is based on mieq.c by Keith Packard,
|
This file is based on mieq.c by Keith Packard,
|
||||||
which contains the following copyright:
|
which contains the following copyright:
|
||||||
|
@ -61,6 +61,8 @@ typedef struct _Event {
|
||||||
ScreenPtr pScreen;
|
ScreenPtr pScreen;
|
||||||
} EventRec, *EventPtr;
|
} EventRec, *EventPtr;
|
||||||
|
|
||||||
|
int input_check_zero, input_check_flag;
|
||||||
|
|
||||||
typedef struct _EventQueue {
|
typedef struct _EventQueue {
|
||||||
HWEventQueueType head, tail; /* long for SetInputCheck */
|
HWEventQueueType head, tail; /* long for SetInputCheck */
|
||||||
CARD32 lastEventTime; /* to avoid time running backwards */
|
CARD32 lastEventTime; /* to avoid time running backwards */
|
||||||
|
@ -73,7 +75,6 @@ typedef struct _EventQueue {
|
||||||
|
|
||||||
static EventQueueRec darwinEventQueue;
|
static EventQueueRec darwinEventQueue;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DarwinPressModifierMask
|
* DarwinPressModifierMask
|
||||||
* Press or release the given modifier key, specified by its mask.
|
* Press or release the given modifier key, specified by its mask.
|
||||||
|
@ -177,18 +178,15 @@ static void DarwinSimulateMouseClick(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bool
|
Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
|
||||||
DarwinEQInit(
|
mieqInit();
|
||||||
DevicePtr pKbd,
|
|
||||||
DevicePtr pPtr)
|
|
||||||
{
|
|
||||||
darwinEventQueue.head = darwinEventQueue.tail = 0;
|
darwinEventQueue.head = darwinEventQueue.tail = 0;
|
||||||
darwinEventQueue.lastEventTime = GetTimeInMillis ();
|
darwinEventQueue.lastEventTime = GetTimeInMillis ();
|
||||||
darwinEventQueue.pKbd = pKbd;
|
darwinEventQueue.pKbd = pKbd;
|
||||||
darwinEventQueue.pPtr = pPtr;
|
darwinEventQueue.pPtr = pPtr;
|
||||||
darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
|
darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
|
||||||
darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
|
darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
|
||||||
SetInputCheck (&darwinEventQueue.head, &darwinEventQueue.tail);
|
SetInputCheck(&input_check_zero, &input_check_flag);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,11 +197,10 @@ DarwinEQInit(
|
||||||
* DarwinEQEnqueue - called from event gathering thread
|
* DarwinEQEnqueue - called from event gathering thread
|
||||||
* ProcessInputEvents - called from X server thread
|
* ProcessInputEvents - called from X server thread
|
||||||
* DarwinEQEnqueue should never be called from more than one thread.
|
* DarwinEQEnqueue should never be called from more than one thread.
|
||||||
|
*
|
||||||
|
* This should be deprecated in favor of miEQEnqueue -- BB
|
||||||
*/
|
*/
|
||||||
void
|
void DarwinEQEnqueue(const xEvent *e) {
|
||||||
DarwinEQEnqueue(
|
|
||||||
const xEvent *e)
|
|
||||||
{
|
|
||||||
HWEventQueueType oldtail, newtail;
|
HWEventQueueType oldtail, newtail;
|
||||||
char byte = 0;
|
char byte = 0;
|
||||||
|
|
||||||
|
@ -213,13 +210,12 @@ DarwinEQEnqueue(
|
||||||
// This is difficult to do in a thread-safe way and rarely useful.
|
// This is difficult to do in a thread-safe way and rarely useful.
|
||||||
|
|
||||||
newtail = oldtail + 1;
|
newtail = oldtail + 1;
|
||||||
if (newtail == QUEUE_SIZE)
|
if (newtail == QUEUE_SIZE) newtail = 0;
|
||||||
newtail = 0;
|
|
||||||
/* Toss events which come in late */
|
/* Toss events which come in late */
|
||||||
if (newtail == darwinEventQueue.head)
|
if (newtail == darwinEventQueue.head) return;
|
||||||
return;
|
|
||||||
|
|
||||||
darwinEventQueue.events[oldtail].event = *e;
|
darwinEventQueue.events[oldtail].event = *e;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure that event times don't go backwards - this
|
* Make sure that event times don't go backwards - this
|
||||||
* is "unnecessary", but very useful
|
* is "unnecessary", but very useful
|
||||||
|
@ -244,20 +240,13 @@ DarwinEQEnqueue(
|
||||||
* DarwinEQPointerPost
|
* DarwinEQPointerPost
|
||||||
* Post a pointer event. Used by the mipointer.c routines.
|
* Post a pointer event. Used by the mipointer.c routines.
|
||||||
*/
|
*/
|
||||||
void
|
void DarwinEQPointerPost(xEvent *e) {
|
||||||
DarwinEQPointerPost(
|
|
||||||
xEvent *e)
|
|
||||||
{
|
|
||||||
(*darwinEventQueue.pPtr->processInputProc)
|
(*darwinEventQueue.pPtr->processInputProc)
|
||||||
(e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
|
(e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
|
||||||
DarwinEQSwitchScreen(
|
|
||||||
ScreenPtr pScreen,
|
|
||||||
Bool fromDIX)
|
|
||||||
{
|
|
||||||
darwinEventQueue.pEnqueueScreen = pScreen;
|
darwinEventQueue.pEnqueueScreen = pScreen;
|
||||||
if (fromDIX)
|
if (fromDIX)
|
||||||
darwinEventQueue.pDequeueScreen = pScreen;
|
darwinEventQueue.pDequeueScreen = pScreen;
|
||||||
|
@ -268,8 +257,7 @@ DarwinEQSwitchScreen(
|
||||||
* ProcessInputEvents
|
* ProcessInputEvents
|
||||||
* Read and process events from the event queue until it is empty.
|
* Read and process events from the event queue until it is empty.
|
||||||
*/
|
*/
|
||||||
void ProcessInputEvents(void)
|
void ProcessInputEvents(void) {
|
||||||
{
|
|
||||||
EventRec *e;
|
EventRec *e;
|
||||||
int x, y;
|
int x, y;
|
||||||
xEvent xe;
|
xEvent xe;
|
||||||
|
@ -277,12 +265,15 @@ void ProcessInputEvents(void)
|
||||||
// button number and modifier mask of currently pressed fake button
|
// button number and modifier mask of currently pressed fake button
|
||||||
static int darwinFakeMouseButtonDown = 0;
|
static int darwinFakeMouseButtonDown = 0;
|
||||||
static int darwinFakeMouseButtonMask = 0;
|
static int darwinFakeMouseButtonMask = 0;
|
||||||
|
input_check_flag=0;
|
||||||
|
|
||||||
|
ErrorF("calling mieqProcessInputEvents\n");
|
||||||
|
mieqProcessInputEvents();
|
||||||
|
|
||||||
// Empty the signaling pipe
|
// Empty the signaling pipe
|
||||||
x = sizeof(xe);
|
x = sizeof(xe);
|
||||||
while (x == sizeof(xe)) {
|
while (x == sizeof(xe))
|
||||||
x = read(darwinEventReadFD, &xe, sizeof(xe));
|
x = read(darwinEventReadFD, &xe, sizeof(xe));
|
||||||
}
|
|
||||||
|
|
||||||
while (darwinEventQueue.head != darwinEventQueue.tail)
|
while (darwinEventQueue.head != darwinEventQueue.tail)
|
||||||
{
|
{
|
||||||
|
@ -298,10 +289,16 @@ void ProcessInputEvents(void)
|
||||||
dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
|
dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
|
||||||
xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
|
xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
|
||||||
dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
|
dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
|
||||||
|
|
||||||
|
ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
|
||||||
|
xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY,
|
||||||
|
darwinMainScreenX, darwinMainScreenY,
|
||||||
|
miPointerCurrentScreen()->myNum,
|
||||||
|
dixScreenOrigins[miPointerCurrentScreen()->myNum].x,
|
||||||
|
dixScreenOrigins[miPointerCurrentScreen()->myNum].y);
|
||||||
|
|
||||||
|
//Assumption - screen switching can only occur on motion events
|
||||||
|
|
||||||
/*
|
|
||||||
* Assumption - screen switching can only occur on motion events
|
|
||||||
*/
|
|
||||||
if (e->pScreen != darwinEventQueue.pDequeueScreen)
|
if (e->pScreen != darwinEventQueue.pDequeueScreen)
|
||||||
{
|
{
|
||||||
darwinEventQueue.pDequeueScreen = e->pScreen;
|
darwinEventQueue.pDequeueScreen = e->pScreen;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user