summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
diff options
context:
space:
mode:
authorfaith <faith>2000-12-07 16:15:48 +0000
committerfaith <faith>2000-12-07 16:15:48 +0000
commit8defb3ad1c6d0255088b680be1c2e9dd94569dc0 (patch)
treeb6fe3a0a68886416b3389bc892c45af2c472a657 /xc/programs/Xserver/hw/xfree86/common/xf86Events.c
parentdf383cb53ff84bb2cbfd4a8f5c5b10995e85824e (diff)
Added support for DRI-specific full-screen modeX_4_0_1h-20001207-merge
This mode will be deprecated when a GLX fullscreen extension is available and should only be used when absolutely necessary.
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/common/xf86Events.c')
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Events.c665
1 files changed, 246 insertions, 419 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
index baecd9b5d..2dab5232c 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.75 1999/06/27 09:20:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.101 2000/11/18 19:37:09 tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -31,12 +31,12 @@
#include "compiler.h"
-#include "Xpoll.h"
#include "xf86.h"
#include "xf86Priv.h"
#define XF86_OS_PRIVS
#include "xf86_OSlib.h"
#include "atKeynames.h"
+#include "Xpoll.h"
#ifdef XFreeXDGA
@@ -60,6 +60,18 @@ extern Bool noXkbExtension;
#define XE_POINTER 1
#define XE_KEYBOARD 2
+#ifdef XINPUT
+#define __EqEnqueue(ev) xf86eqEnqueue(ev)
+#else
+#define __EqEnqueue(ev) mieqEnqueue(ev)
+#endif
+
+#define EqEnqueue(ev) { \
+ int __sigstate = xf86BlockSIGIO (); \
+ __EqEnqueue (ev); \
+ xf86UnblockSIGIO(__sigstate); \
+}
+
#ifdef XTESTEXT1
#define XTestSERVER_SIDE
@@ -69,45 +81,19 @@ extern short xtest_mousey;
extern int on_steal_input;
extern Bool XTestStealKeyData();
extern void XTestStealMotionData();
-
-#ifdef XINPUT
-#define ENQUEUE(ev, code, direction, dev_type) \
- (ev)->u.u.detail = (code); \
- (ev)->u.u.type = (direction); \
- if (!on_steal_input || \
- XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
- xtest_mousex, xtest_mousey)) \
- xf86eqEnqueue((ev))
-#else
#define ENQUEUE(ev, code, direction, dev_type) \
(ev)->u.u.detail = (code); \
(ev)->u.u.type = (direction); \
if (!on_steal_input || \
XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
xtest_mousex, xtest_mousey)) \
- mieqEnqueue((ev))
-#endif
-
-#define MOVEPOINTER(dx, dy, time) \
- if (on_steal_input) \
- XTestStealMotionData(dx, dy, XE_POINTER, xtest_mousex, xtest_mousey); \
- miPointerDeltaCursor (dx, dy, time)
-
+ EqEnqueue((ev))
#else /* ! XTESTEXT1 */
-#ifdef XINPUT
#define ENQUEUE(ev, code, direction, dev_type) \
(ev)->u.u.detail = (code); \
(ev)->u.u.type = (direction); \
- xf86eqEnqueue((ev))
-#else
-#define ENQUEUE(ev, code, direction, dev_type) \
- (ev)->u.u.detail = (code); \
- (ev)->u.u.type = (direction); \
- mieqEnqueue((ev))
-#endif
-#define MOVEPOINTER(dx, dy, time) \
- miPointerDeltaCursor (dx, dy, time)
+ EqEnqueue((ev))
#endif
@@ -129,13 +115,17 @@ extern void XTestStealMotionData();
#ifdef USE_VT_SYSREQ
static Bool VTSysreqToggle = FALSE;
#endif /* !USE_VT_SYSREQ */
-static Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for *BSD */
+static Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
+ *BSD and for avoiding VT
+ switches when using the DRI
+ automatic full screen mode.*/
extern fd_set EnabledDevices;
#if defined(XQUEUE)
extern void xf86XqueRequest(void);
#endif
+extern void (*xf86OSPMClose)(void);
static void xf86VTSwitch(void);
@@ -153,114 +143,6 @@ typedef struct x_IHRec {
static IHPtr InputHandlers = NULL;
-#ifndef NEW_INPUT
-static CARD32 buttonTimer(OsTimerPtr timer, CARD32 now, pointer arg);
-
-/*
- * Lets create a simple finite-state machine:
- *
- * state[?][0]: action1
- * state[?][1]: action2
- * state[?][2]: next state
- *
- * action > 0: ButtonPress
- * action = 0: nothing
- * action < 0: ButtonRelease
- *
- * Why this stuff ??? Normally you cannot press both mousebuttons together, so
- * the mouse reports both pressed at the same time ...
- */
-
-static signed char stateTab[48][3] = {
-
-/* nothing pressed */
- { 0, 0, 0 },
- { 0, 0, 8 }, /* 1 right -> delayed right */
- { 0, 0, 0 }, /* 2 nothing */
- { 0, 0, 8 }, /* 3 right -> delayed right */
- { 0, 0, 16 }, /* 4 left -> delayed left */
- { 2, 0, 24 }, /* 5 left & right (middle press) -> middle pressed */
- { 0, 0, 16 }, /* 6 left -> delayed left */
- { 2, 0, 24 }, /* 7 left & right (middle press) -> middle pressed */
-
-/* delayed right */
- { 1, -1, 0 }, /* 8 nothing (right event) -> init */
- { 1, 0, 32 }, /* 9 right (right press) -> right pressed */
- { 1, -1, 0 }, /* 10 nothing (right event) -> init */
- { 1, 0, 32 }, /* 11 right (right press) -> right pressed */
- { 1, -1, 16 }, /* 12 left (right event) -> delayed left */
- { 2, 0, 24 }, /* 13 left & right (middle press) -> middle pressed */
- { 1, -1, 16 }, /* 14 left (right event) -> delayed left */
- { 2, 0, 24 }, /* 15 left & right (middle press) -> middle pressed */
-
-/* delayed left */
- { 3, -3, 0 }, /* 16 nothing (left event) -> init */
- { 3, -3, 8 }, /* 17 right (left event) -> delayed right */
- { 3, -3, 0 }, /* 18 nothing (left event) -> init */
- { 3, -3, 8 }, /* 19 right (left event) -> delayed right */
- { 3, 0, 40 }, /* 20 left (left press) -> pressed left */
- { 2, 0, 24 }, /* 21 left & right (middle press) -> pressed middle */
- { 3, 0, 40 }, /* 22 left (left press) -> pressed left */
- { 2, 0, 24 }, /* 23 left & right (middle press) -> pressed middle */
-
-/* pressed middle */
- { -2, 0, 0 }, /* 24 nothing (middle release) -> init */
- { -2, 0, 0 }, /* 25 right (middle release) -> init */
- { -2, 0, 0 }, /* 26 nothing (middle release) -> init */
- { -2, 0, 0 }, /* 27 right (middle release) -> init */
- { -2, 0, 0 }, /* 28 left (middle release) -> init */
- { 0, 0, 24 }, /* 29 left & right -> pressed middle */
- { -2, 0, 0 }, /* 30 left (middle release) -> init */
- { 0, 0, 24 }, /* 31 left & right -> pressed middle */
-
-/* pressed right */
- { -1, 0, 0 }, /* 32 nothing (right release) -> init */
- { 0, 0, 32 }, /* 33 right -> pressed right */
- { -1, 0, 0 }, /* 34 nothing (right release) -> init */
- { 0, 0, 32 }, /* 35 right -> pressed right */
- { -1, 0, 16 }, /* 36 left (right release) -> delayed left */
- { -1, 2, 24 }, /* 37 left & right (r rel, m prs) -> middle pressed */
- { -1, 0, 16 }, /* 38 left (right release) -> delayed left */
- { -1, 2, 24 }, /* 39 left & right (r rel, m prs) -> middle pressed */
-
-/* pressed left */
- { -3, 0, 0 }, /* 40 nothing (left release) -> init */
- { -3, 0, 8 }, /* 41 right (left release) -> delayed right */
- { -3, 0, 0 }, /* 42 nothing (left release) -> init */
- { -3, 0, 8 }, /* 43 right (left release) -> delayed right */
- { 0, 0, 40 }, /* 44 left -> left pressed */
- { -3, 2, 24 }, /* 45 left & right (l rel, mprs) -> middle pressed */
- { 0, 0, 40 }, /* 46 left -> left pressed */
- { -3, 2, 24 }, /* 47 left & right (l rel, mprs) -> middle pressed */
-};
-
-
-/*
- * Table to allow quick reversal of natural button mapping to correct mapping
- */
-
-/*
- * [JCH-96/01/21] The ALPS GlidePoint pad extends the MS protocol
- * with a fourth button activated by tapping the PAD.
- * The 2nd line corresponds to 4th button on; the drv sends
- * the buttons in the following map (MSBit described first) :
- * 0 | 4th | 1st | 2nd | 3rd
- * And we remap them (MSBit described first) :
- * 0 | 4th | 3rd | 2nd | 1st
- */
-static char reverseMap[32] = { 0, 4, 2, 6, 1, 5, 3, 7,
- 8, 12, 10, 14, 9, 13, 11, 15,
- 16, 20, 18, 22, 17, 21, 19, 23,
- 24, 28, 26, 30, 25, 29, 27, 31};
-
-
-static char hitachMap[16] = { 0, 2, 1, 3,
- 8, 10, 9, 11,
- 4, 6, 5, 7,
- 12, 14, 13, 15 };
-
-#define reverseBits(map, b) (((b) & ~0x0f) | map[(b) & 0x0f])
-#endif
/*
* TimeSinceLastInputEvent --
@@ -417,12 +299,12 @@ ProcessInputEvents ()
extern u_char SpecialServerMap[];
#endif /* ASSUME_CUSTOM_KEYCODES */
-#if !defined(__EMX__)
+#if !defined(__EMX__) && !defined(__SOL8__) && !defined(__CYGWIN__)
void
xf86PostKbdEvent(unsigned key)
{
int scanCode = (key & 0x7f);
- int specialkey;
+ int specialkey = 0;
Bool down = (key & 0x80 ? FALSE : TRUE);
KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
Bool updateLeds = FALSE;
@@ -450,7 +332,8 @@ xf86PostKbdEvent(unsigned key)
#if defined (__sparc__)
if (kbdSun == -1) {
- if (xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ || (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
kbdSun = 1;
else
kbdSun = 0;
@@ -459,7 +342,7 @@ xf86PostKbdEvent(unsigned key)
goto special;
#endif /* __sparc__ */
-#if defined (i386) && defined (SVR4) && !defined (PC98)
+#if defined (i386) && defined (SVR4)
/*
* PANIX returns DICOP standards based keycodes in using 106jp
* keyboard. We need to remap some keys.
@@ -494,8 +377,6 @@ xf86PostKbdEvent(unsigned key)
if (xf86Info.scanPrefix == 0) {
switch (scanCode) {
-
-#ifndef PC98
case KEY_Prefix0:
case KEY_Prefix1:
#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
@@ -508,11 +389,9 @@ xf86PostKbdEvent(unsigned key)
}
break;
#endif
-#endif /* not PC98 */
}
}
-#ifndef PC98
else if (
#ifdef CSRG_BASED
(xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
@@ -551,8 +430,18 @@ xf86PostKbdEvent(unsigned key)
/*
* Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6)
*/
+ case 0x2A:
+ case 0x36:
+ return;
default:
- return; /* skip illegal */
+ xf86MsgVerb(X_INFO, 2, "Unreported Prefix0 scancode: 0x%02x\n",
+ scanCode);
+ /*
+ * "Internet" keyboards are generating lots of new codes. Let them
+ * pass. There is little consistency between them, so don't bother
+ * with symbolic names at this level.
+ */
+ scanCode += 0x78;
}
}
@@ -568,7 +457,6 @@ xf86PostKbdEvent(unsigned key)
if (scanCode != KEY_NumLock) return;
scanCode = KEY_Pause; /* pause */
}
-#endif /* not PC98 */
#endif /* !ASSUME_CUSTOM_KEYCODES */
/*
@@ -581,6 +469,27 @@ xf86PostKbdEvent(unsigned key)
specialkey = scanCode;
#endif /* ASSUME_CUSTOM_KEYCODES */
+ if (xf86IsPc98()) {
+ switch (scanCode) {
+ case 0x0e: specialkey = 0x0e; break; /* KEY_BackSpace */
+ case 0x40: specialkey = 0x4a; break; /* KEY_KP_Minus */
+ case 0x49: specialkey = 0x4e; break; /* KEY_KP_Plus */
+ case 0x62: specialkey = 0x3b; break; /* KEY_F1 */
+ case 0x63: specialkey = 0x3c; break; /* KEY_F2 */
+ case 0x64: specialkey = 0x3d; break; /* KEY_F3 */
+ case 0x65: specialkey = 0x3e; break; /* KEY_F4 */
+ case 0x66: specialkey = 0x3f; break; /* KEY_F5 */
+ case 0x67: specialkey = 0x40; break; /* KEY_F6 */
+ case 0x68: specialkey = 0x41; break; /* KEY_F7 */
+ case 0x69: specialkey = 0x42; break; /* KEY_F8 */
+ case 0x6a: specialkey = 0x43; break; /* KEY_F9 */
+ case 0x6b: specialkey = 0x44; break; /* KEY_F10 */
+ /* case 0x73: specialkey = 0x38; break; KEY_Alt */
+ /* case 0x74: specialkey = 0x1d; break; KEY_LCtrl */
+ default: specialkey = 0x00; break;
+ }
+ }
+
#if defined (__sparc__)
special:
if (kbdSun) {
@@ -648,6 +557,28 @@ special:
}
break;
+ /* Under QNX4, we set the vtPending flag for VT switching and
+ * let the VT switch function do the rest...
+ * This is a little different from the other OS'es.
+ */
+#if defined(QNX4)
+ case KEY_1:
+ case KEY_2:
+ case KEY_3:
+ case KEY_4:
+ case KEY_5:
+ case KEY_6:
+ case KEY_7:
+ case KEY_8:
+ case KEY_9:
+ if (down){
+ xf86Info.vtRequestsPending =
+ specialkey - KEY_1 + 1;
+ return;
+ }
+ break;
+#endif
+
#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT))) || defined(SCO)
/*
* Under Linux, the raw keycodes are consumed before the kernel
@@ -792,17 +723,13 @@ special:
/* Ignore these keys -- ie don't let them cancel an alt-sysreq */
case KEY_Alt:
-#ifndef PC98
case KEY_AltLang:
-#endif /* not PC98 */
break;
-#ifndef PC98
case KEY_SysReqest:
if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask)))
VTSysreqToggle = TRUE;
break;
-#endif /* not PC98 */
default:
if (VTSysreqToggle)
@@ -910,7 +837,6 @@ special:
* ignore releases, toggle on & off on presses.
* Don't deal with the Caps_Lock keysym directly, but check the lock modifier
*/
-#ifndef PC98
if (keyc->modifierMap[keycode] & LockMask ||
keysym[0] == XK_Scroll_Lock ||
keysym[1] == XF86XK_ModeLock ||
@@ -932,14 +858,13 @@ special:
if (keysym[1] == XF86XK_ModeLock) xf86Info.modeSwitchLock = flag;
updateLeds = TRUE;
}
-#endif /* not PC98 */
#ifndef ASSUME_CUSTOM_KEYCODES
/*
* normal, non-keypad keys
*/
if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
-#if !defined(CSRG_BASED) && !defined(MACH386) && !defined(MINIX) && !defined(__OSF__) && !defined(__GNU__)
+#if !defined(CSRG_BASED) && !defined(MACH386) && !defined(MINIX) && !defined(__OSF__) && !defined(__GNU__) && !defined(__CYGWIN__)
/*
* magic ALT_L key on AT84 keyboards for multilingual support
*/
@@ -961,9 +886,14 @@ special:
/*
* check for an autorepeat-event
*/
- if ((down && KeyPressed(keycode)) &&
- (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode]))
- return;
+ if (down && KeyPressed(keycode)) {
+ KbdFeedbackClassRec *kbdfeed = ((DeviceIntPtr)xf86Info.pKeyboard)->kbdfeed;
+ if ((xf86Info.autoRepeat != AutoRepeatModeOn) ||
+ keyc->modifierMap[keycode] ||
+ (kbdfeed && !(kbdfeed->ctrl.autoRepeats[keycode>>3] & ( 1<<(keycode&7) ))))
+ return;
+ }
+
xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis();
/*
@@ -990,208 +920,6 @@ special:
#endif /* !__EMX__ */
-#ifndef NEW_INPUT
-static CARD32
-buttonTimer(OsTimerPtr timer, CARD32 now, pointer arg)
-{
-#ifndef NEW_INPUT
- MouseDevPtr priv = MOUSE_DEV((DeviceIntPtr) arg);
-
- xf86PostMseEvent(((DeviceIntPtr) arg), priv->truebuttons, 0, 0);
-#endif
- return(0);
-}
-#endif
-
-
-/*
- * xf86PostMseEvent --
- * Translate the raw hardware MseEvent into an XEvent(s), and tell DIX
- * about it. Perform a 3Button emulation if required.
- */
-
-#ifndef NEW_INPUT
-void
-xf86PostMseEvent(DeviceIntPtr device, int buttons, int dx, int dy)
-{
- static OsTimerPtr timer = NULL;
- MouseDevPtr private = MOUSE_DEV(device);
- int id, change;
- int truebuttons;
- xEvent mevent[2];
-
-#ifdef AMOEBA
- int pressed;
-
- pressed = ((buttons & BUTTON_PRESS) != 0);
- buttons &= ~BUTTON_PRESS;
-#endif
-
- xf86Info.lastEventTime = mevent->u.keyButtonPointer.time = GetTimeInMillis();
-
- truebuttons = buttons;
- if (private->mseType == PROT_MMHIT)
- buttons = reverseBits(hitachMap, buttons);
- else
- buttons = reverseBits(reverseMap, buttons);
-
- if (dx || dy) {
- /*
- * The accelaration stuff is now done in xf86Xinput.c when XInput
- * support is enabled.
- */
-#ifndef XINPUT
-
- /*
- * accelerate the baby now if sqrt(dx*dx + dy*dy) > threshold !
- * but do some simpler arithmetic here...
- */
- if ((abs(dx) + abs(dy)) >= private->threshold) {
- dx = (dx * private->num) / private->den;
- dy = (dy * private->num)/ private->den;
- }
-
- MOVEPOINTER(dx, dy, mevent->u.keyButtonPointer.time);
-#else
- xf86PostMotionEvent(device, 0, 0, 2, dx, dy);
-#endif
- }
-
- if (private->emulate3Buttons)
- {
-
- /*
- * Hack to operate the middle button even with Emulate3Buttons set.
- * Modifying the state table to keep track of the middle button state
- * would nearly double its size, so I'll stick with this fix. - TJW
- */
- if (private->mseType == PROT_MMHIT)
- change = buttons ^ reverseBits(hitachMap, private->lastButtons);
- else
- change = buttons ^ reverseBits(reverseMap, private->lastButtons);
- if (change & 02)
- {
-#ifndef XINPUT
- ENQUEUE(mevent,
- 2, (buttons & 02) ? ButtonPress : ButtonRelease,
- XE_POINTER);
-#else
- xf86PostButtonEvent(device, 0, 2, (buttons & 02), 0, 0);
-#endif
- }
-
- /*
- * emulate the third button by the other two
- */
- if ((id = stateTab[(buttons & 0x07) + private->emulateState][0]) != 0)
- {
-#ifndef XINPUT
- ENQUEUE(mevent,
- abs(id), (id < 0 ? ButtonRelease : ButtonPress),
- XE_POINTER);
-#else
- xf86PostButtonEvent(device, 0, abs(id), (id >= 0), 0, 0);
-#endif
- }
-
- if ((id = stateTab[(buttons & 0x07) + private->emulateState][1]) != 0)
- {
-#ifndef XINPUT
- ENQUEUE(mevent,
- abs(id), (id < 0 ? ButtonRelease : ButtonPress),
- XE_POINTER);
-#else
- xf86PostButtonEvent(device, 0, abs(id), (id >= 0), 0, 0);
-#endif
- }
-
- private->emulateState = stateTab[(buttons & 0x07) + private->emulateState][2];
- if (stateTab[(buttons & 0x07) + private->emulateState][0] ||
- stateTab[(buttons & 0x07) + private->emulateState][1])
- {
- private->truebuttons = truebuttons;
- timer = TimerSet(timer, 0, private->emulate3Timeout, buttonTimer,
- (pointer)device);
- }
- else
- {
- if (timer)
- {
- TimerFree(timer);
- timer = NULL;
- }
- }
- }
- else
- {
-#ifdef AMOEBA
- if (truebuttons != 0) {
-# ifndef XINPUT
- ENQUEUE(mevent,
- truebuttons, (pressed ? ButtonPress : ButtonRelease),
- XE_POINTER);
-# else
- xf86PostButtonEvent(device, 0, truebuttons, pressed, 0, 0);
-# endif
- }
-#else
- /*
- * real three button event
- * Note that xf86Info.lastButtons has the hardware button mapping which
- * is the reverse of the button mapping reported to the server.
- */
- if (private->mseType == PROT_MMHIT)
- change = buttons ^ reverseBits(hitachMap, private->lastButtons);
- else
- change = buttons ^ reverseBits(reverseMap, private->lastButtons);
- while (change)
- {
- id = ffs(change);
- change &= ~(1 << (id-1));
-# ifndef XINPUT
- ENQUEUE(mevent,
- id, (buttons&(1<<(id-1)))? ButtonPress : ButtonRelease,
- XE_POINTER);
-# else
- xf86PostButtonEvent(device, 0, id, (buttons&(1<<(id-1))), 0, 0);
-# endif
- }
-#endif
- }
- private->lastButtons = truebuttons;
-}
-#endif
-
-
-
-#ifndef NEW_INPUT
-/*
- * xf86Block --
- * Os block handler.
- */
-
-/* ARGSUSED */
-void
-xf86Block(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
-{
-#if defined(XQUEUE)
- /*
- * On MP SVR4 boxes, a race condition exists because the XQUEUE does
- * not have anyway to lock it for exclusive access. This results in one
- * processor putting something on the queue at the same time the other
- * processor is taking it something off. The count of items in the queue
- * can get off by 1. This just goes and checks to see if an extra event
- * was put in the queue a during this period. The signal for this event
- * was ignored while processing the previous event.
- */
-
- if (xf86Screens[0]->vtSema)
- xf86XqueRequest();
-#endif
-}
-#endif
-
-
#ifndef AMOEBA
/*
@@ -1203,17 +931,14 @@ xf86Block(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
void
xf86Wakeup(pointer blockData, int err, pointer pReadmask)
{
-
-#ifndef __EMX__
+#if !defined(__EMX__) && !defined(__QNX__) && !defined(__CYGWIN__)
#ifdef __OSF__
fd_set kbdDevices;
fd_set mseDevices;
#endif /* __OSF__ */
fd_set* LastSelectMask = (fd_set*)pReadmask;
fd_set devicesWithInput;
-#ifdef NEW_INPUT
InputInfoPtr pInfo;
-#endif
if (err >= 0) {
@@ -1221,14 +946,14 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
#ifndef __OSF__
if (XFD_ANYSET(&devicesWithInput)) {
(xf86Info.kbdEvents)();
-#ifndef NEW_INPUT
- (xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
if (pInfo->read_input && pInfo->fd >= 0 &&
(FD_ISSET(pInfo->fd, ((fd_set *)pReadmask)) != 0)) {
+ int sigstate = xf86BlockSIGIO();
+
pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
/*
* Must break here because more than one device may share
* the same file descriptor.
@@ -1237,7 +962,6 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
}
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
}
#else /* __OSF__ */
/*
@@ -1259,16 +983,33 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
(xf86Info.mouseDev->mseEvents)(1);
#endif /* __OSF__ */
}
-#else /* __EMX__ */
+#else /* __EMX__ and __QNX__ */
+
+ InputInfoPtr pInfo;
- (xf86Info.kbdEvents)(); /* Under OS/2, always call */
- (xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
+ (xf86Info.kbdEvents)(); /* Under OS/2 and QNX, always call */
-#endif /* __EMX__ */
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0) {
+ int sigstate = xf86BlockSIGIO();
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ /*
+ * Must break here because more than one device may share
+ * the same file descriptor.
+ */
+ break;
+ }
+ pInfo = pInfo->next;
+ }
- {
- IHPtr ih;
+#endif /* __EMX__ and __QNX__ */
+ if (err >= 0) { /* we don't want the handlers called if select() */
+ IHPtr ih; /* returned with an error condition, do we? */
+
for (ih = InputHandlers; ih; ih = ih->next) {
if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
(FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
@@ -1276,15 +1017,7 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
}
}
}
-
-#ifndef NEW_INPUT
-#if defined(XQUEUE) && !defined(XQUEUE_ASYNC)
- /* This could be done more cleanly */
- if (xf86Info.mouseDev->xqueSema && xf86Info.mouseDev->xquePending)
- xf86XqueRequest();
-#endif
-#endif
-
+
if (xf86VTSwitchPending()) xf86VTSwitch();
if (xf86Info.inputPending) ProcessInputEvents();
@@ -1292,16 +1025,74 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
#endif /* AMOEBA */
+/*
+ * xf86SigioReadInput --
+ * signal handler for the SIGIO signal.
+ */
+static void
+xf86SigioReadInput(int fd,
+ void *closure)
+{
+ int sigstate = xf86BlockSIGIO();
+ InputInfoPtr pInfo = (InputInfoPtr) closure;
+
+ pInfo->read_input(pInfo);
+
+ xf86UnblockSIGIO(sigstate);
+}
+
+/*
+ * xf86AddEnabledDevice --
+ *
+ */
+void
+xf86AddEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
+ AddEnabledDevice(pInfo->fd);
+ }
+}
+
+/*
+ * xf86RemoveEnabledDevice --
+ *
+ */
+void
+xf86RemoveEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
+ RemoveEnabledDevice(pInfo->fd);
+ }
+}
+
+static int *xf86SignalIntercept = NULL;
+
+void
+xf86InterceptSignals(int *signo)
+{
+ if ((xf86SignalIntercept = signo))
+ *signo = -1;
+}
/*
* xf86SigHandler --
- * Catch unexpected signals and exit cleanly.
+ * Catch unexpected signals and exit or continue cleanly.
*/
void
xf86SigHandler(int signo)
{
+ if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
+ /* Re-arm handler just in case */
+ (void) signal(signo, xf86SigHandler);
+ *xf86SignalIntercept = signo;
+ return;
+ }
+
signal(signo,SIG_IGN);
xf86Info.caughtSignal = TRUE;
+#ifdef XF86BIGFONT
+ XF86BigfontCleanup();
+#endif
#if defined(DEBUG) && defined(XFree86LOADER)
if (signo == SIGSEGV)
LoaderDumpSymbols();
@@ -1317,9 +1108,7 @@ static void
xf86VTSwitch()
{
int i;
-#ifdef NEW_INPUT
InputInfoPtr pInfo;
-#endif
IHPtr ih;
#ifdef DEBUG
@@ -1339,33 +1128,29 @@ xf86VTSwitch()
#ifdef DEBUG
ErrorF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
- BOOLTOSTRING(xf86Exiting));
+ BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
#endif
for (i = 0; i < xf86NumScreens; i++) {
- if (!xf86Exiting)
- if (xf86Screens[i]->SaveRestoreImage)
- xf86Screens[i]->SaveRestoreImage(i, SaveImage);
+ if (!(dispatchException & DE_TERMINATE))
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
}
xf86EnterServerState(SETUP);
for (i = 0; i < xf86NumScreens; i++) {
xf86Screens[i]->LeaveVT(i, 0);
}
-#ifndef __EMX__
+#if !defined(__EMX__) && !defined(__CYGWIN__)
DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-#ifndef NEW_INPUT
- DisableDevice((DeviceIntPtr)xf86Info.pMouse);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
DisableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
#endif /* !__EMX__ */
for (ih = InputHandlers; ih; ih = ih->next)
xf86DisableInputHandler(ih);
- xf86AccessLeaveState(); /* We need this here, otherwise */
- xf86AccessLeave(); /* console won't be restored */
+ xf86AccessLeave(); /* We need this here, otherwise */
+ xf86AccessLeaveState(); /* console won't be restored */
if (!xf86VTSwitchAway()) {
/*
@@ -1382,30 +1167,30 @@ xf86VTSwitch()
FatalError("EnterVT failed for screen %d\n", i);
}
xf86EnterServerState(OPERATING);
- if (!xf86Exiting) {
+ if (!(dispatchException & DE_TERMINATE)) {
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->SaveRestoreImage)
- xf86Screens[i]->SaveRestoreImage(i, RestoreImage);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
}
}
SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
-#ifndef __EMX__
+#if !defined(__EMX__) && !defined(__CYGWIN__)
EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-#ifndef NEW_INPUT
- EnableDevice((DeviceIntPtr)xf86Info.pMouse);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
EnableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
#endif /* !__EMX__ */
for (ih = InputHandlers; ih; ih = ih->next)
xf86EnableInputHandler(ih);
} else {
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+
for (i = 0; i < xf86NumScreens; i++) {
/*
* zero all access functions to
@@ -1422,7 +1207,8 @@ xf86VTSwitch()
ErrorF("xf86VTSwitch: Entering\n");
#endif
if (!xf86VTSwitchTo()) return;
-
+ xf86OSPMClose = xf86OSPMOpen();
+
xf86EnableIO();
xf86AccessEnter();
xf86EnterServerState(SETUP);
@@ -1433,24 +1219,20 @@ xf86VTSwitch()
}
xf86EnterServerState(OPERATING);
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->SaveRestoreImage)
- xf86Screens[i]->SaveRestoreImage(i, RestoreImage);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
}
/* Turn screen saver off when switching back */
SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
-#ifndef __EMX__
+#if !defined(__EMX__) && !defined(__CYGWIN__)
EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-#ifndef NEW_INPUT
- EnableDevice((DeviceIntPtr)xf86Info.pMouse);
-#else
pInfo = xf86InputDevs;
while (pInfo) {
EnableDevice(pInfo->dev);
pInfo = pInfo->next;
}
-#endif /* NEW_INPUT */
#endif /* !__EMX__ */
for (ih = InputHandlers; ih; ih = ih->next)
xf86EnableInputHandler(ih);
@@ -1485,15 +1267,18 @@ xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
return ih;
}
-void
+int
xf86RemoveInputHandler(pointer handler)
{
IHPtr ih, p;
-
+ int fd;
+
if (!handler)
- return;
+ return -1;
ih = handler;
+ fd = ih->fd;
+
if (ih->fd >= 0)
RemoveEnabledDevice(ih->fd);
@@ -1507,6 +1292,7 @@ xf86RemoveInputHandler(pointer handler)
p->next = ih->next;
}
xfree(ih);
+ return fd;
}
void
@@ -1537,6 +1323,14 @@ xf86EnableInputHandler(pointer handler)
AddEnabledDevice(ih->fd);
}
+Bool
+xf86EnableVTSwitch(Bool new)
+{
+ Bool old = VTSwitchEnabled;
+ VTSwitchEnabled = new;
+ return old;
+}
+
#ifdef XTESTEXT1
void
@@ -1557,8 +1351,6 @@ XTestJumpPointer(int jx, int jy, int dev_type)
miPointerAbsoluteCursor(jx, jy, GetTimeInMillis() );
}
-
-
void
XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex,
int mousey)
@@ -1582,3 +1374,38 @@ XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex,
#endif /* XTESTEXT1 */
+#ifdef WSCONS_SUPPORT
+
+/* XXX Currently XKB is mandatory. */
+
+void
+xf86PostWSKbdEvent(struct wscons_event *event)
+{
+ int type = event->type;
+ int value = event->value;
+ Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE);
+ KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
+ xEvent kevent;
+ KeySym *keysym;
+ int keycode;
+
+ /*
+ * Now map the scancodes to real X-keycodes ...
+ */
+ keycode = value + MIN_KEYCODE;
+ keysym = keyc->curKeySyms.map +
+ keyc->curKeySyms.mapWidth * (keycode - keyc->curKeySyms.minKeyCode);
+
+ /*
+ * check for an autorepeat-event
+ */
+ if ((down && KeyPressed(keycode)) &&
+ (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode]))
+ return;
+
+ xf86Info.lastEventTime = kevent.u.keyButtonPointer.time
+ = event->time.tv_sec * 1000 + event->time.tv_nsec / 1000000;
+
+ ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
+}
+#endif /* WSCONS_SUPPORT */