kdrive: restructure APM/VT switch support to reset keyboard state and flush
buffer on APM resume
This commit is contained in:
parent
bb2e1c53b5
commit
5f310d7f8b
|
@ -1,5 +1,5 @@
|
||||||
XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
|
XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
|
||||||
XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/linux/Imakefile,v 1.5 2001/03/30 02:15:20 keithp Exp $
|
XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/linux/Imakefile,v 1.6 2001/08/09 20:45:15 dawes Exp $
|
||||||
KDRIVE=..
|
KDRIVE=..
|
||||||
#include "../Kdrive.tmpl"
|
#include "../Kdrive.tmpl"
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ TSSRCS = ts.c
|
||||||
TSOBJS = ts.o
|
TSOBJS = ts.o
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SRCS = keyboard.c linux.c ps2.c ms.c bus.c agp.c $(TSSRCS)
|
SRCS = keyboard.c linux.c ps2.c ms.c bus.c agp.c $(TSSRCS)
|
||||||
|
|
||||||
OBJS = keyboard.o linux.o ps2.o ms.o bus.o agp.o $(TSOBJS)
|
OBJS = keyboard.o linux.o ps2.o ms.o bus.o agp.o $(TSOBJS)
|
||||||
|
|
||||||
INCLUDES = -I. $(KDINCS)
|
INCLUDES = -I. $(KDINCS)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/programs/Xserver/hw/kdrive/linux/keyboard.c,v 1.6 2001/03/30 02:15:20 keithp Exp $
|
* $XFree86: xc/programs/Xserver/hw/kdrive/linux/keyboard.c,v 1.7 2001/06/29 14:00:41 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 1999 Keith Packard
|
* Copyright © 1999 Keith Packard
|
||||||
*
|
*
|
||||||
|
@ -397,18 +397,17 @@ static int LinuxKbdTrans;
|
||||||
static struct termios LinuxTermios;
|
static struct termios LinuxTermios;
|
||||||
static int LinuxKbdType;
|
static int LinuxKbdType;
|
||||||
|
|
||||||
int
|
void
|
||||||
LinuxKeyboardInit (void)
|
LinuxKeyboardEnable (int fd, void *closure)
|
||||||
{
|
{
|
||||||
struct termios nTty;
|
struct termios nTty;
|
||||||
|
unsigned char buf[256];
|
||||||
|
int n;
|
||||||
|
|
||||||
if (!LinuxKbdType)
|
ioctl (fd, KDGKBMODE, &LinuxKbdTrans);
|
||||||
LinuxKbdType = KdAllocInputType ();
|
tcgetattr (fd, &LinuxTermios);
|
||||||
|
|
||||||
ioctl (LinuxConsoleFd, KDGKBMODE, &LinuxKbdTrans);
|
|
||||||
tcgetattr (LinuxConsoleFd, &LinuxTermios);
|
|
||||||
|
|
||||||
ioctl(LinuxConsoleFd, KDSKBMODE, K_MEDIUMRAW);
|
ioctl(fd, KDSKBMODE, K_MEDIUMRAW);
|
||||||
nTty = LinuxTermios;
|
nTty = LinuxTermios;
|
||||||
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
||||||
nTty.c_oflag = 0;
|
nTty.c_oflag = 0;
|
||||||
|
@ -418,16 +417,39 @@ LinuxKeyboardInit (void)
|
||||||
nTty.c_cc[VMIN]=1;
|
nTty.c_cc[VMIN]=1;
|
||||||
cfsetispeed(&nTty, 9600);
|
cfsetispeed(&nTty, 9600);
|
||||||
cfsetospeed(&nTty, 9600);
|
cfsetospeed(&nTty, 9600);
|
||||||
tcsetattr(LinuxConsoleFd, TCSANOW, &nTty);
|
tcsetattr(fd, TCSANOW, &nTty);
|
||||||
|
/*
|
||||||
|
* Flush any pending keystrokes
|
||||||
|
*/
|
||||||
|
while ((n = read (fd, buf, sizeof (buf))) > 0)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LinuxKeyboardDisable (int fd, void *closure)
|
||||||
|
{
|
||||||
|
ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans);
|
||||||
|
tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
LinuxKeyboardInit (void)
|
||||||
|
{
|
||||||
|
if (!LinuxKbdType)
|
||||||
|
LinuxKbdType = KdAllocInputType ();
|
||||||
|
|
||||||
|
LinuxKeyboardEnable (LinuxConsoleFd, 0);
|
||||||
KdRegisterFd (LinuxKbdType, LinuxConsoleFd, LinuxKeyboardRead, 0);
|
KdRegisterFd (LinuxKbdType, LinuxConsoleFd, LinuxKeyboardRead, 0);
|
||||||
|
KdRegisterFdEnableDisable (LinuxConsoleFd,
|
||||||
|
LinuxKeyboardEnable,
|
||||||
|
LinuxKeyboardDisable);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LinuxKeyboardFini (void)
|
LinuxKeyboardFini (void)
|
||||||
{
|
{
|
||||||
ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans);
|
LinuxKeyboardDisable (LinuxConsoleFd, 0);
|
||||||
tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios);
|
|
||||||
KdUnregisterFds (LinuxKbdType, FALSE);
|
KdUnregisterFds (LinuxKbdType, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.18 2001/07/20 19:35:29 keithp Exp $ */
|
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.19 2001/07/24 21:26:17 keithp Exp $ */
|
||||||
|
|
||||||
#include "kdrive.h"
|
#include "kdrive.h"
|
||||||
#ifdef PSEUDO8
|
#ifdef PSEUDO8
|
||||||
|
@ -211,28 +211,6 @@ KdDisableScreen (ScreenPtr pScreen)
|
||||||
(*pScreenPriv->card->cfuncs->disable) (pScreen);
|
(*pScreenPriv->card->cfuncs->disable) (pScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
KdDisableScreens (void)
|
|
||||||
{
|
|
||||||
KdCardInfo *card;
|
|
||||||
KdScreenInfo *screen;
|
|
||||||
|
|
||||||
if (kdEnabled)
|
|
||||||
{
|
|
||||||
kdEnabled = FALSE;
|
|
||||||
for (card = kdCardInfo; card; card = card->next)
|
|
||||||
{
|
|
||||||
for (screen = card->screenList; screen; screen = screen->next)
|
|
||||||
if (screen->mynum == card->selected && screen->pScreen)
|
|
||||||
KdDisableScreen (screen->pScreen);
|
|
||||||
if (card->driver)
|
|
||||||
(*card->cfuncs->restore) (card);
|
|
||||||
}
|
|
||||||
(*kdOsFuncs->Disable) ();
|
|
||||||
KdDisableInput ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KdSuspend (void)
|
KdSuspend (void)
|
||||||
{
|
{
|
||||||
|
@ -254,21 +232,13 @@ KdSuspend (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
KdResume (void)
|
KdDisableScreens (void)
|
||||||
{
|
{
|
||||||
KdCardInfo *card;
|
KdSuspend ();
|
||||||
KdScreenInfo *screen;
|
|
||||||
|
|
||||||
if (kdEnabled)
|
if (kdEnabled)
|
||||||
{
|
{
|
||||||
for (card = kdCardInfo; card; card = card->next)
|
(*kdOsFuncs->Disable) ();
|
||||||
{
|
kdEnabled = FALSE;
|
||||||
(*card->cfuncs->preserve) (card);
|
|
||||||
for (screen = card->screenList; screen; screen = screen->next)
|
|
||||||
if (screen->mynum == card->selected && screen->pScreen)
|
|
||||||
KdEnableScreen (screen->pScreen);
|
|
||||||
}
|
|
||||||
KdEnableInput ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +264,26 @@ KdEnableScreen (ScreenPtr pScreen)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KdResume (void)
|
||||||
|
{
|
||||||
|
KdCardInfo *card;
|
||||||
|
KdScreenInfo *screen;
|
||||||
|
|
||||||
|
if (kdEnabled)
|
||||||
|
{
|
||||||
|
for (card = kdCardInfo; card; card = card->next)
|
||||||
|
{
|
||||||
|
(*card->cfuncs->preserve) (card);
|
||||||
|
for (screen = card->screenList; screen; screen = screen->next)
|
||||||
|
if (screen->mynum == card->selected && screen->pScreen)
|
||||||
|
KdEnableScreen (screen->pScreen);
|
||||||
|
}
|
||||||
|
KdEnableInput ();
|
||||||
|
KdReleaseAllKeys ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
KdEnableScreens (void)
|
KdEnableScreens (void)
|
||||||
{
|
{
|
||||||
|
@ -304,15 +294,8 @@ KdEnableScreens (void)
|
||||||
{
|
{
|
||||||
kdEnabled = TRUE;
|
kdEnabled = TRUE;
|
||||||
(*kdOsFuncs->Enable) ();
|
(*kdOsFuncs->Enable) ();
|
||||||
for (card = kdCardInfo; card; card = card->next)
|
|
||||||
{
|
|
||||||
(*card->cfuncs->preserve) (card);
|
|
||||||
for (screen = card->screenList; screen; screen = screen->next)
|
|
||||||
if (screen->mynum == card->selected && screen->pScreen)
|
|
||||||
KdEnableScreen (screen->pScreen);
|
|
||||||
}
|
|
||||||
KdEnableInput ();
|
|
||||||
}
|
}
|
||||||
|
KdResume ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -322,7 +305,6 @@ KdProcessSwitch (void)
|
||||||
KdDisableScreens ();
|
KdDisableScreens ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
KdReleaseAllKeys ();
|
|
||||||
KdEnableScreens ();
|
KdEnableScreens ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.19 2001/07/20 19:35:29 keithp Exp $ */
|
/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.20 2001/08/09 09:06:08 keithp Exp $ */
|
||||||
|
|
||||||
#include "kdrive.h"
|
#include "kdrive.h"
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
|
@ -81,6 +81,8 @@ typedef struct _kdInputFd {
|
||||||
int type;
|
int type;
|
||||||
int fd;
|
int fd;
|
||||||
void (*read) (int fd, void *closure);
|
void (*read) (int fd, void *closure);
|
||||||
|
void (*enable) (int fd, void *closure);
|
||||||
|
void (*disable) (int fd, void *closure);
|
||||||
void *closure;
|
void *closure;
|
||||||
} KdInputFd;
|
} KdInputFd;
|
||||||
|
|
||||||
|
@ -203,6 +205,8 @@ KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *clos
|
||||||
kdInputFds[kdNumInputFds].type = type;
|
kdInputFds[kdNumInputFds].type = type;
|
||||||
kdInputFds[kdNumInputFds].fd = fd;
|
kdInputFds[kdNumInputFds].fd = fd;
|
||||||
kdInputFds[kdNumInputFds].read = read;
|
kdInputFds[kdNumInputFds].read = read;
|
||||||
|
kdInputFds[kdNumInputFds].enable = 0;
|
||||||
|
kdInputFds[kdNumInputFds].disable = 0;
|
||||||
kdInputFds[kdNumInputFds].closure = closure;
|
kdInputFds[kdNumInputFds].closure = closure;
|
||||||
++kdNumInputFds;
|
++kdNumInputFds;
|
||||||
if (kdInputEnabled)
|
if (kdInputEnabled)
|
||||||
|
@ -210,6 +214,22 @@ KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *clos
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KdRegisterFdEnableDisable (int fd,
|
||||||
|
void (*enable) (int fd, void *closure),
|
||||||
|
void (*disable) (int fd, void *closure))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < kdNumInputFds; i++)
|
||||||
|
if (kdInputFds[i].fd == fd)
|
||||||
|
{
|
||||||
|
kdInputFds[i].enable = enable;
|
||||||
|
kdInputFds[i].disable = disable;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
KdUnregisterFds (int type, Bool do_close)
|
KdUnregisterFds (int type, Bool do_close)
|
||||||
{
|
{
|
||||||
|
@ -238,7 +258,11 @@ KdDisableInput (void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < kdNumInputFds; i++)
|
for (i = 0; i < kdNumInputFds; i++)
|
||||||
|
{
|
||||||
KdRemoveFd (kdInputFds[i].fd);
|
KdRemoveFd (kdInputFds[i].fd);
|
||||||
|
if (kdInputFds[i].disable)
|
||||||
|
(*kdInputFds[i].disable) (kdInputFds[i].fd, kdInputFds[i].closure);
|
||||||
|
}
|
||||||
kdInputEnabled = FALSE;
|
kdInputEnabled = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +274,11 @@ KdEnableInput (void)
|
||||||
|
|
||||||
kdInputEnabled = TRUE;
|
kdInputEnabled = TRUE;
|
||||||
for (i = 0; i < kdNumInputFds; i++)
|
for (i = 0; i < kdNumInputFds; i++)
|
||||||
|
{
|
||||||
KdAddFd (kdInputFds[i].fd);
|
KdAddFd (kdInputFds[i].fd);
|
||||||
|
if (kdInputFds[i].enable)
|
||||||
|
(*kdInputFds[i].enable) (kdInputFds[i].fd, kdInputFds[i].closure);
|
||||||
|
}
|
||||||
|
|
||||||
/* reset screen saver */
|
/* reset screen saver */
|
||||||
xE.u.keyButtonPointer.time = GetTimeInMillis ();
|
xE.u.keyButtonPointer.time = GetTimeInMillis ();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user