summaryrefslogtreecommitdiff
path: root/src/kbd.c
diff options
context:
space:
mode:
authorPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-04-09 14:36:58 -0300
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-05-01 14:57:13 +0930
commita1866e2e73f0b401cd8e92fc9ee8db1791585936 (patch)
treea8d2f502277ec38fa17522aef2bbaf9631db5693 /src/kbd.c
parent86b16003ef1134a2471cd3f7ac217db574fa714c (diff)
downloadxorg-driver-xf86-input-keyboard-a1866e2e73f0b401cd8e92fc9ee8db1791585936.tar.gz
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". Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
Diffstat (limited to 'src/kbd.c')
-rw-r--r--src/kbd.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/kbd.c b/src/kbd.c
index dc9ea7a..969d64c 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