From 8db4ccca1bf2c2d625148c3d12de27de5bab1adc Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Wed, 9 Apr 2008 14:36:58 -0300 Subject: [PATCH] Don't send events in DEVICE_INIT, only after DEVICE_ON. See http://bugs.freedesktop.org/show_bug.cgi?id=2243#c15 for a description of the problem fixed in this patch. Now only the driver leds state is synched with virtual console state, and if required, events are post in DEVICE_ON. This also defines an internal INITFLAG state to know when DEVICE_ON is called after DEVICE_INIT, otherwise, it will only send events for leds that changed state while the device was in "DEVICE_OFF state". --- src/kbd.c | 28 ++++++++++++++++++---------- 1 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/kbd.c b/src/kbd.c index dc9ea7a..7097541 100644 --- a/src/kbd.c +++ b/src/kbd.c @@ -59,6 +59,8 @@ extern int XkbDfltRepeatInterval; #define SCROLLFLAG 4 #define MODEFLAG 8 #define COMPOSEFLAG 16 +/* Used to know when the first DEVICE_ON after a DEVICE_INIT is called */ +#define INITFLAG (1 << 31) static InputInfoPtr KbdPreInit(InputDriverPtr drv, IDevPtr dev, int flags); static int KbdProc(DeviceIntPtr device, int what); @@ -472,15 +474,7 @@ InitKBD(InputInfoPtr pInfo, Bool init) if (init) { pKbd->keyLeds = pKbd->GetLeds(pInfo); UpdateLeds(pInfo); - if (pKbd->keyLeds & CAPSFLAG) { - pKbd->PostEvent(pInfo, KEY_CapsLock, TRUE); - pKbd->PostEvent(pInfo, KEY_CapsLock, FALSE); - } - if (pKbd->keyLeds & NUMFLAG) { - pKbd->PostEvent(pInfo, KEY_NumLock, TRUE); - pKbd->PostEvent(pInfo, KEY_NumLock, FALSE); - } - + pKbd->keyLeds |= INITFLAG; if( pKbd->delay <= 375) rad = 0x00; else if (pKbd->delay <= 625) rad = 0x20; else if (pKbd->delay <= 875) rad = 0x40; @@ -489,8 +483,22 @@ InitKBD(InputInfoPtr pInfo, Bool init) else if (pKbd->rate >= 30) rad |= 0x00; else rad |= ((58 / pKbd->rate) - 2); pKbd->SetKbdRepeat(pInfo, rad); - } else + } else { + int leds = pKbd->keyLeds; + + pKbd->keyLeds = pKbd->GetLeds(pInfo); UpdateLeds(pInfo); + if ((pKbd->keyLeds & CAPSFLAG) != + (leds & INITFLAG ? 0 : leds & CAPSFLAG)) { + pKbd->PostEvent(pInfo, KEY_CapsLock, TRUE); + pKbd->PostEvent(pInfo, KEY_CapsLock, FALSE); + } + if ((pKbd->keyLeds & NUMFLAG) != + (leds & INITFLAG ? 0 : leds & NUMFLAG)) { + pKbd->PostEvent(pInfo, KEY_NumLock, TRUE); + pKbd->PostEvent(pInfo, KEY_NumLock, FALSE); + } + } } static int -- 1.5.4.3