summaryrefslogtreecommitdiff
path: root/hw/darwin/darwinEvents.c
diff options
context:
space:
mode:
authorTorrey Lyons <torrey@mrcla.com>2004-09-22 23:38:33 +0000
committerTorrey Lyons <torrey@mrcla.com>2004-09-22 23:38:33 +0000
commit35a3bf13a8be96bb29dce32399c3684c6baa527d (patch)
treec708203fb23a5a3baef19f30c316cef1a1e44744 /hw/darwin/darwinEvents.c
parent1b3fa4d53b287cbe9d38c5f8c9fbbc2298690959 (diff)
Add option for XDarwin to track system keyboard layout changes as they
occur (John Harper and Torrey T. Lyons).
Diffstat (limited to 'hw/darwin/darwinEvents.c')
-rw-r--r--hw/darwin/darwinEvents.c132
1 files changed, 75 insertions, 57 deletions
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 49bb67a94..6bfda00d4 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -2,7 +2,7 @@
* Darwin event queue and event handling
*/
/*
-Copyright (c) 2002 Torrey T. Lyons. All Rights Reserved.
+Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
This file is based on mieq.c by Keith Packard,
@@ -29,7 +29,7 @@ Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86$ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinEvents.c,v 1.6 2004/03/31 22:29:09 torrey Exp $ */
#define NEED_EVENTS
#include "X.h"
@@ -44,6 +44,7 @@ in this Software without prior written authorization from The Open Group.
#include "mipointer.h"
#include "darwin.h"
+#include "darwinKeyboard.h"
#include <sys/types.h>
#include <sys/uio.h>
@@ -51,24 +52,24 @@ in this Software without prior written authorization from The Open Group.
#include <IOKit/hidsystem/IOLLEvent.h>
/* Fake button press/release for scroll wheel move. */
-#define SCROLLWHEELUPFAKE 4
-#define SCROLLWHEELDOWNFAKE 5
+#define SCROLLWHEELUPFAKE 4
+#define SCROLLWHEELDOWNFAKE 5
#define QUEUE_SIZE 256
typedef struct _Event {
- xEvent event;
- ScreenPtr pScreen;
+ xEvent event;
+ ScreenPtr pScreen;
} EventRec, *EventPtr;
typedef struct _EventQueue {
- HWEventQueueType head, tail; /* long for SetInputCheck */
- CARD32 lastEventTime; /* to avoid time running backwards */
- Bool lastMotion;
- EventRec events[QUEUE_SIZE]; /* static allocation for signals */
- DevicePtr pKbd, pPtr; /* device pointer, to get funcs */
- ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
- ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
+ HWEventQueueType head, tail; /* long for SetInputCheck */
+ CARD32 lastEventTime; /* to avoid time running backwards */
+ Bool lastMotion;
+ EventRec events[QUEUE_SIZE]; /* static allocation for signals */
+ DevicePtr pKbd, pPtr; /* device pointer, to get funcs */
+ ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
+ ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
} EventQueueRec, *EventQueuePtr;
static EventQueueRec darwinEventQueue;
@@ -79,7 +80,7 @@ static EventQueueRec darwinEventQueue;
* Press or release the given modifier key, specified by its mask.
*/
static void DarwinPressModifierMask(
- xEvent *xe, // must already have type, time and mouse location
+ xEvent *xe, // must already have type, time and mouse location
int mask) // one of NX_*MASK constants
{
int key = DarwinModifierNXMaskToNXKey(mask);
@@ -225,10 +226,10 @@ DarwinEQEnqueue(
* is "unnecessary", but very useful
*/
if (e->u.keyButtonPointer.time < darwinEventQueue.lastEventTime &&
- darwinEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
+ darwinEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
{
- darwinEventQueue.events[oldtail].event.u.keyButtonPointer.time =
- darwinEventQueue.lastEventTime;
+ darwinEventQueue.events[oldtail].event.u.keyButtonPointer.time =
+ darwinEventQueue.lastEventTime;
}
darwinEventQueue.events[oldtail].pScreen = darwinEventQueue.pEnqueueScreen;
@@ -260,7 +261,7 @@ DarwinEQSwitchScreen(
{
darwinEventQueue.pEnqueueScreen = pScreen;
if (fromDIX)
- darwinEventQueue.pDequeueScreen = pScreen;
+ darwinEventQueue.pDequeueScreen = pScreen;
}
@@ -270,10 +271,10 @@ DarwinEQSwitchScreen(
*/
void ProcessInputEvents(void)
{
- EventRec *e;
- int x, y;
- xEvent xe;
- static int old_flags = 0; // last known modifier state
+ EventRec *e;
+ int x, y;
+ xEvent xe;
+ static int old_flags = 0; // last known modifier state
// button number and modifier mask of currently pressed fake button
static int darwinFakeMouseButtonDown = 0;
static int darwinFakeMouseButtonMask = 0;
@@ -286,10 +287,10 @@ void ProcessInputEvents(void)
while (darwinEventQueue.head != darwinEventQueue.tail)
{
- if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
- e = &darwinEventQueue.events[darwinEventQueue.head];
+ e = &darwinEventQueue.events[darwinEventQueue.head];
xe = e->event;
// Shift from global screen coordinates to coordinates relative to
@@ -299,36 +300,53 @@ void ProcessInputEvents(void)
xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
- /*
- * Assumption - screen switching can only occur on motion events
- */
- if (e->pScreen != darwinEventQueue.pDequeueScreen)
- {
- darwinEventQueue.pDequeueScreen = e->pScreen;
- x = xe.u.keyButtonPointer.rootX;
- y = xe.u.keyButtonPointer.rootY;
- if (darwinEventQueue.head == QUEUE_SIZE - 1)
- darwinEventQueue.head = 0;
- else
- ++darwinEventQueue.head;
- NewCurrentScreen (darwinEventQueue.pDequeueScreen, x, y);
- }
- else
- {
- if (darwinEventQueue.head == QUEUE_SIZE - 1)
- darwinEventQueue.head = 0;
- else
- ++darwinEventQueue.head;
- switch (xe.u.u.type)
- {
- case KeyPress:
- case KeyRelease:
+ /*
+ * Assumption - screen switching can only occur on motion events
+ */
+ if (e->pScreen != darwinEventQueue.pDequeueScreen)
+ {
+ darwinEventQueue.pDequeueScreen = e->pScreen;
+ x = xe.u.keyButtonPointer.rootX;
+ y = xe.u.keyButtonPointer.rootY;
+ if (darwinEventQueue.head == QUEUE_SIZE - 1)
+ darwinEventQueue.head = 0;
+ else
+ ++darwinEventQueue.head;
+ NewCurrentScreen (darwinEventQueue.pDequeueScreen, x, y);
+ }
+ else
+ {
+ if (darwinEventQueue.head == QUEUE_SIZE - 1)
+ darwinEventQueue.head = 0;
+ else
+ ++darwinEventQueue.head;
+ switch (xe.u.u.type)
+ {
+ case KeyPress:
+ if (old_flags == 0
+ && darwinSyncKeymap && darwinKeymapFile == NULL)
+ {
+ /* See if keymap has changed. */
+
+ static unsigned int last_seed;
+ unsigned int this_seed;
+
+ this_seed = DarwinModeSystemKeymapSeed();
+ if (this_seed != last_seed)
+ {
+ last_seed = this_seed;
+ DarwinKeyboardReload(darwinKeyboard);
+ }
+ }
+ /* fall through */
+
+ case KeyRelease:
xe.u.u.detail += MIN_KEYCODE;
- (*darwinEventQueue.pKbd->processInputProc)
- (&xe, (DeviceIntPtr)darwinEventQueue.pKbd, 1);
- break;
+ (*darwinEventQueue.pKbd->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pKbd, 1);
+ break;
- case ButtonPress:
+ case ButtonPress:
miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
xe.u.keyButtonPointer.rootY,
xe.u.keyButtonPointer.time);
@@ -386,7 +404,7 @@ void ProcessInputEvents(void)
miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
xe.u.keyButtonPointer.rootY,
xe.u.keyButtonPointer.time);
- break;
+ break;
case kXDarwinUpdateModifiers:
{
@@ -424,7 +442,7 @@ void ProcessInputEvents(void)
xe.u.u.type = ButtonRelease;
}
(*darwinEventQueue.pPtr->processInputProc)
- (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+ (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
}
}
break;
@@ -455,8 +473,8 @@ void ProcessInputEvents(void)
default:
// Check for mode specific event
DarwinModeProcessEvent(&xe);
- }
- }
+ }
+ }
}
miPointerUpdate();