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 $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=..
|
||||
#include "../Kdrive.tmpl"
|
||||
|
||||
|
@ -8,9 +8,9 @@ TSSRCS = ts.c
|
|||
TSOBJS = ts.o
|
||||
#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)
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
@ -397,18 +397,17 @@ static int LinuxKbdTrans;
|
|||
static struct termios LinuxTermios;
|
||||
static int LinuxKbdType;
|
||||
|
||||
int
|
||||
LinuxKeyboardInit (void)
|
||||
void
|
||||
LinuxKeyboardEnable (int fd, void *closure)
|
||||
{
|
||||
struct termios nTty;
|
||||
unsigned char buf[256];
|
||||
int n;
|
||||
|
||||
if (!LinuxKbdType)
|
||||
LinuxKbdType = KdAllocInputType ();
|
||||
|
||||
ioctl (LinuxConsoleFd, KDGKBMODE, &LinuxKbdTrans);
|
||||
tcgetattr (LinuxConsoleFd, &LinuxTermios);
|
||||
ioctl (fd, KDGKBMODE, &LinuxKbdTrans);
|
||||
tcgetattr (fd, &LinuxTermios);
|
||||
|
||||
ioctl(LinuxConsoleFd, KDSKBMODE, K_MEDIUMRAW);
|
||||
ioctl(fd, KDSKBMODE, K_MEDIUMRAW);
|
||||
nTty = LinuxTermios;
|
||||
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
||||
nTty.c_oflag = 0;
|
||||
|
@ -418,16 +417,39 @@ LinuxKeyboardInit (void)
|
|||
nTty.c_cc[VMIN]=1;
|
||||
cfsetispeed(&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);
|
||||
KdRegisterFdEnableDisable (LinuxConsoleFd,
|
||||
LinuxKeyboardEnable,
|
||||
LinuxKeyboardDisable);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
LinuxKeyboardFini (void)
|
||||
{
|
||||
ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans);
|
||||
tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios);
|
||||
LinuxKeyboardDisable (LinuxConsoleFd, 0);
|
||||
KdUnregisterFds (LinuxKbdType, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* 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"
|
||||
#ifdef PSEUDO8
|
||||
|
@ -211,28 +211,6 @@ KdDisableScreen (ScreenPtr 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
|
||||
KdSuspend (void)
|
||||
{
|
||||
|
@ -254,21 +232,13 @@ KdSuspend (void)
|
|||
}
|
||||
|
||||
void
|
||||
KdResume (void)
|
||||
KdDisableScreens (void)
|
||||
{
|
||||
KdCardInfo *card;
|
||||
KdScreenInfo *screen;
|
||||
|
||||
KdSuspend ();
|
||||
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 ();
|
||||
(*kdOsFuncs->Disable) ();
|
||||
kdEnabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,6 +264,26 @@ KdEnableScreen (ScreenPtr pScreen)
|
|||
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
|
||||
KdEnableScreens (void)
|
||||
{
|
||||
|
@ -304,15 +294,8 @@ KdEnableScreens (void)
|
|||
{
|
||||
kdEnabled = TRUE;
|
||||
(*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
|
||||
|
@ -322,7 +305,6 @@ KdProcessSwitch (void)
|
|||
KdDisableScreens ();
|
||||
else
|
||||
{
|
||||
KdReleaseAllKeys ();
|
||||
KdEnableScreens ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* 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 "inputstr.h"
|
||||
|
@ -81,6 +81,8 @@ typedef struct _kdInputFd {
|
|||
int type;
|
||||
int fd;
|
||||
void (*read) (int fd, void *closure);
|
||||
void (*enable) (int fd, void *closure);
|
||||
void (*disable) (int fd, void *closure);
|
||||
void *closure;
|
||||
} KdInputFd;
|
||||
|
||||
|
@ -203,6 +205,8 @@ KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *clos
|
|||
kdInputFds[kdNumInputFds].type = type;
|
||||
kdInputFds[kdNumInputFds].fd = fd;
|
||||
kdInputFds[kdNumInputFds].read = read;
|
||||
kdInputFds[kdNumInputFds].enable = 0;
|
||||
kdInputFds[kdNumInputFds].disable = 0;
|
||||
kdInputFds[kdNumInputFds].closure = closure;
|
||||
++kdNumInputFds;
|
||||
if (kdInputEnabled)
|
||||
|
@ -210,6 +214,22 @@ KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *clos
|
|||
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
|
||||
KdUnregisterFds (int type, Bool do_close)
|
||||
{
|
||||
|
@ -238,7 +258,11 @@ KdDisableInput (void)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < kdNumInputFds; i++)
|
||||
{
|
||||
KdRemoveFd (kdInputFds[i].fd);
|
||||
if (kdInputFds[i].disable)
|
||||
(*kdInputFds[i].disable) (kdInputFds[i].fd, kdInputFds[i].closure);
|
||||
}
|
||||
kdInputEnabled = FALSE;
|
||||
}
|
||||
|
||||
|
@ -250,7 +274,11 @@ KdEnableInput (void)
|
|||
|
||||
kdInputEnabled = TRUE;
|
||||
for (i = 0; i < kdNumInputFds; i++)
|
||||
{
|
||||
KdAddFd (kdInputFds[i].fd);
|
||||
if (kdInputFds[i].enable)
|
||||
(*kdInputFds[i].enable) (kdInputFds[i].fd, kdInputFds[i].closure);
|
||||
}
|
||||
|
||||
/* reset screen saver */
|
||||
xE.u.keyButtonPointer.time = GetTimeInMillis ();
|
||||
|
|
Loading…
Reference in New Issue
Block a user