From 14d5471981151b27678de826daa078977217477a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 1 May 2009 15:22:37 +1000 Subject: [PATCH] Xext: return BadDevice from XTest if we don't have keys/buttons/valuators. BadDevice is an XI error, but this cannot happen for core XTest fake input anyway since the device will be the matching virtual XTest slave device. Signed-off-by: Peter Hutterer --- Xext/xtest.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Xext/xtest.c b/Xext/xtest.c index 8aca6a0f7..cb32c2858 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -49,6 +49,7 @@ #include #include #include +#include "exglobals.h" #include "modinit.h" @@ -342,6 +343,9 @@ ProcXTestFakeInput(ClientPtr client) { case KeyPress: case KeyRelease: + if (!dev->key) + return BadDevice; + if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code || ev->u.u.detail > dev->key->xkbInfo->desc->max_key_code) { @@ -350,6 +354,9 @@ ProcXTestFakeInput(ClientPtr client) } break; case MotionNotify: + if (!dev->valuator) + return BadDevice; + /* broken lib, XI events have root uninitialized */ if (extension || ev->u.keyButtonPointer.root == None) root = GetCurrentRootWindow(dev); @@ -376,6 +383,9 @@ ProcXTestFakeInput(ClientPtr client) break; case ButtonPress: case ButtonRelease: + if (!dev->button) + return BadDevice; + if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) { client->errorValue = ev->u.u.detail;