From de8be07cc0a8163b6ef04455706fd5ca2cebe587 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 17 Aug 2010 12:08:52 +1000 Subject: [PATCH 01/20] dix: don't create core motion events for non-x/y valuators. Devices that send motion events with valuators other than x/y get core motion events with unchanged x/y coordinates. This confuses some applications. If the DeviceEvent does not have the x/y valuators set, return BadMatch on core conversion, thus skipping the event altogether. Reported-by: Bartosz Brachaczek Signed-off-by: Peter Hutterer Tested-by: Bartosz Brachaczek --- dix/eventconvert.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 4e3de0b46..0f747c1a0 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -102,6 +102,15 @@ EventToCore(InternalEvent *event, xEvent *core) switch(event->any.type) { case ET_Motion: + { + DeviceEvent *e = &event->device_event; + /* Don't create core motion event if neither x nor y are + * present */ + if (!BitIsOn(e->valuators.mask, 0) && + !BitIsOn(e->valuators.mask, 1)) + return BadMatch; + } + /* fallthrough */ case ET_ButtonPress: case ET_ButtonRelease: case ET_KeyPress: From 20cb9c923efa4edc348eba30f956a66413a8208f Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 22 Jul 2010 11:13:10 +0300 Subject: [PATCH 02/20] xkb: Use memcpy for copy that has known length Fixes warning that strncpy is not able to append NULL to the end of destination. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/xkmread.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xkb/xkmread.c b/xkb/xkmread.c index 814bb1d41..9eb86018e 100644 --- a/xkb/xkmread.c +++ b/xkb/xkmread.c @@ -534,8 +534,7 @@ XkbAction *act; case XkbSA_XFree86Private: /* copy the kind of action */ - strncpy((char*)act->any.data, (char*)wire.actionData, - XkbAnyActionDataSize); + memcpy(act->any.data, wire.actionData, XkbAnyActionDataSize); break ; case XkbSA_Terminate: From 1223340644744c0b38aa85f5956eb5ab7c696517 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 22 Jul 2010 11:33:33 +0300 Subject: [PATCH 03/20] xkb: Fix memory leak if opening file fails If fopen fails pointer in buf would be overwriten with a new pointer. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/ddxList.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xkb/ddxList.c b/xkb/ddxList.c index 2256424d0..39bd7397a 100644 --- a/xkb/ddxList.c +++ b/xkb/ddxList.c @@ -161,6 +161,7 @@ char tmpname[PATH_MAX]; } if (!in) { haveDir= FALSE; + free(buf); buf = Xprintf( "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg, XkbBinDirectory,XkbBaseDirectory,componentDirs[what],(long) @@ -176,6 +177,7 @@ char tmpname[PATH_MAX]; } if (!in) { haveDir= FALSE; + free(buf); buf = Xprintf( "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg, componentDirs[what],(long) From 184ef0d35612d6ed0619283d376f04d9a904f47c Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 22 Jul 2010 11:34:54 +0300 Subject: [PATCH 04/20] xkb: Don't check for NULL before calling free Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/ddxList.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xkb/ddxList.c b/xkb/ddxList.c index 39bd7397a..c1ada5c6d 100644 --- a/xkb/ddxList.c +++ b/xkb/ddxList.c @@ -202,8 +202,7 @@ char tmpname[PATH_MAX]; } if (!in) { - if (buf != NULL) - free(buf); + free(buf); #ifdef WIN32 unlink(tmpname); #endif @@ -266,8 +265,7 @@ char tmpname[PATH_MAX]; fclose(in); unlink(tmpname); #endif - if (buf != NULL) - free(buf); + free(buf); return status; } From 2475ef60977f6813dec74ef0837a5915b8a48bbc Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 22 Jul 2010 12:48:55 +0300 Subject: [PATCH 05/20] xkb: Fix NULL pointer dereference xkb->names is dereferenced in else path too. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/xkmread.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xkb/xkmread.c b/xkb/xkmread.c index 9eb86018e..b564195bc 100644 --- a/xkb/xkmread.c +++ b/xkb/xkmread.c @@ -686,7 +686,11 @@ int nRead=0; if ((tmp=XkmGetCountedString(file,buf,100))<1) return -1; nRead+= tmp; - if ((buf[0]!='\0')&&(xkb->names)) { + + if (!xkb->names) + continue; + + if (buf[0]!='\0') { Atom name; name= XkbInternAtom(buf,0); xkb->names->groups[i]= name; From 67cfb66562cd9d39f30fec6fbc38eb1eb5e5b030 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 22 Jul 2010 15:05:57 +0300 Subject: [PATCH 06/20] xkb: Remove redurant intialization code calloc already initializes allocated memory to zero. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/xkbEvents.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index 8028502b9..c020e5e2a 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -1045,15 +1045,6 @@ XkbInterestPtr interest; interest->dev = dev; interest->client = client; interest->resource = id; - interest->stateNotifyMask= 0; - interest->ctrlsNotifyMask= 0; - interest->namesNotifyMask= 0; - interest->compatNotifyMask= 0; - interest->bellNotifyMask= FALSE; - interest->accessXNotifyMask= 0; - interest->iStateNotifyMask= 0; - interest->iMapNotifyMask= 0; - interest->altSymsNotifyMask= 0; interest->next = dev->xkb_interest; dev->xkb_interest= interest; return interest; From adc0697cfcfba295a15d7a307125093cbccd637f Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Thu, 22 Jul 2010 15:11:27 +0300 Subject: [PATCH 07/20] xkb: Fix memory leak in error path map is allocated but not freed if reply length and data don't match. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/xkb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xkb/xkb.c b/xkb/xkb.c index 935f5ea6a..a82cc38cc 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -3019,6 +3019,7 @@ register unsigned bit; to = (CARD8 *)wire; if ((to-map)!=length) { client->errorValue = _XkbErrCode2(0xff,length); + free(map); return BadLength; } } From d6642de7ebdda16e0056600a86a7802bd4c393b7 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 26 Jul 2010 14:50:30 +0300 Subject: [PATCH 08/20] xkb: Fix possible NULL pointer dereference If search for device failed sli is NULL. In that case we have to protect dereference to prevent server crash. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/xkbLEDs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c index f617537cf..16826713e 100644 --- a/xkb/xkbLEDs.c +++ b/xkb/xkbLEDs.c @@ -714,10 +714,12 @@ XkbSrvLedInfoPtr sli; } } } - if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask)) - sli->names= calloc(XkbNumIndicators, sizeof(Atom)); - if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask)) - sli->maps= calloc(XkbNumIndicators, sizeof(XkbIndicatorMapRec)); + if (sli) { + if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask)) + sli->names= calloc(XkbNumIndicators, sizeof(Atom)); + if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask)) + sli->maps= calloc(XkbNumIndicators, sizeof(XkbIndicatorMapRec)); + } return sli; } From 2e6d7174042cc8007e947b7d9fb54acc0ebe29d2 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 26 Jul 2010 15:13:34 +0300 Subject: [PATCH 09/20] xkb: Fix possible NULL pointer dereference sli is null before allocation assigment so deference t osli has to be protected. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/xkbLEDs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c index 16826713e..515e9b701 100644 --- a/xkb/xkbLEDs.c +++ b/xkb/xkbLEDs.c @@ -556,6 +556,7 @@ Bool checkNames; else if ((kf!=NULL)&&((kf->xkb_sli->flags&XkbSLI_IsDefault)!=0)) { XkbDescPtr xkb; xkb= dev->key->xkbInfo->desc; + sli= kf->xkb_sli; sli->physIndicators= xkb->indicators->phys_indicators; if (xkb->names->indicators!=sli->names) { checkNames= TRUE; @@ -584,6 +585,8 @@ Bool checkNames; sli->maps= NULL; sli->names= NULL; } + else + return NULL; if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask)) sli->names= calloc(XkbNumIndicators, sizeof(Atom)); if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask)) From b5c9953bbf4ffd11f1a70d058c6d3feb2bd1bca8 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 26 Jul 2010 15:31:03 +0300 Subject: [PATCH 10/20] xkb: Check if AddResource failed Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer --- xkb/xkb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index a82cc38cc..4105c1c6b 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -224,7 +224,8 @@ ProcXkbSelectEvents(ClientPtr client) masks = XkbFindClientResource((DevicePtr)dev,client); if (!masks){ XID id = FakeClientID(client->index); - AddResource(id,RT_XKBCLIENT,dev); + if (!AddResource(id,RT_XKBCLIENT,dev)) + return BadAlloc; masks= XkbAddClientResource((DevicePtr)dev,client,id); } if (masks) { @@ -5378,7 +5379,8 @@ ProcXkbPerClientFlags(ClientPtr client) } else if (want && (!interest)) { XID id = FakeClientID(client->index); - AddResource(id,RT_XKBCLIENT,dev); + if (!AddResource(id,RT_XKBCLIENT,dev)) + return BadAlloc; interest= XkbAddClientResource((DevicePtr)dev,client,id); if (!interest) return BadAlloc; From 3cc5e4422430e9ca44615f3e63feccd2e5729046 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 23 Jul 2010 14:48:32 +1000 Subject: [PATCH 11/20] xfree86: fix compiler warning about implicied decl of DuplicateModule. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../../../../hw/xfree86/common/xf86Xinput.c: In function ‘xf86AllocateInput’: ../../../../hw/xfree86/common/xf86Xinput.c:722: warning: implicit declaration of function ‘DuplicateModule’ ../../../../hw/xfree86/common/xf86Xinput.c:722: warning: nested extern declaration of ‘DuplicateModule’ ../../../../hw/xfree86/common/xf86Xinput.c:722: warning: assignment makes pointer from integer without a cast Signed-off-by: Peter Hutterer Reviewed-by: Adam Jackson Reviewed-by: Daniel Stone --- hw/xfree86/common/xf86Xinput.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index bd77fe663..877eb0382 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -66,6 +66,7 @@ #include "xf86InPriv.h" #include "compiler.h" #include "extinit.h" +#include "loaderProcs.h" #ifdef DPMSExtension #include From ff109bf84401a451380eb7f3f94a6e0aa2776e3e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 12 Aug 2010 00:09:02 -0700 Subject: [PATCH 12/20] Use GetMaster instead of direct u.master access in core procs Signed-off-by: Alan Coopersmith Acked-by: Daniel Stone Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- dix/devices.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index 2e65a041d..62ff4b04c 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2018,8 +2018,9 @@ ProcChangeKeyboardControl (ClientPtr client) keyboard = PickKeyboard(client); for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { - if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) && - pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { + if ((pDev == keyboard || + (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) + && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); if (ret != Success) return ret; @@ -2027,8 +2028,9 @@ ProcChangeKeyboardControl (ClientPtr client) } for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { - if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) && - pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { + if ((pDev == keyboard || + (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) + && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { ret = DoChangeKeyboardControl(client, pDev, vlist, vmask); if (ret != Success) error = ret; @@ -2088,7 +2090,8 @@ ProcBell(ClientPtr client) newpercent = base - newpercent + stuff->percent; for (dev = inputInfo.devices; dev; dev = dev->next) { - if ((dev == keybd || (!IsMaster(dev) && dev->u.master == keybd)) && + if ((dev == keybd || + (!IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == keybd)) && dev->kbdfeed && dev->kbdfeed->BellProc) { rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess); @@ -2157,7 +2160,8 @@ ProcChangePointerControl(ClientPtr client) } for (dev = inputInfo.devices; dev; dev = dev->next) { - if ((dev == mouse || (!IsMaster(dev) && dev->u.master == mouse)) && + if ((dev == mouse || + (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && dev->ptrfeed) { rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); if (rc != Success) @@ -2166,7 +2170,8 @@ ProcChangePointerControl(ClientPtr client) } for (dev = inputInfo.devices; dev; dev = dev->next) { - if ((dev == mouse || (!IsMaster(dev) && dev->u.master == mouse)) && + if ((dev == mouse || + (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && dev->ptrfeed) { dev->ptrfeed->ctrl = ctrl; } From a90052ba8697e217b0dc68057d7b9202ae8797db Mon Sep 17 00:00:00 2001 From: David Ge Date: Thu, 19 Aug 2010 00:33:57 -0500 Subject: [PATCH 13/20] xkb: Fix RedirectKey didn't send any event. Xorg.log shows error: Valuators reported for non-valuator device. This is caused by uninitialized valuators.mask in _XkbFilterRedirectKey(), which trigger the error in UpdateDeviceState(). Signed-off-by: David Ge Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- xkb/xkbActions.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 8c75301b0..c0204441f 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -806,6 +806,7 @@ ProcessInputProc backupproc; /* never actually used uninitialised, but gcc isn't smart enough * to work that out. */ memset(&old, 0, sizeof(old)); + memset(&ev, 0, sizeof(ev)); if ((filter->keycode!=0)&&(filter->keycode!=keycode)) return 1; From 4a12aecac670debd0dafb17c245fccb93eea2d60 Mon Sep 17 00:00:00 2001 From: Jesse Adkins Date: Wed, 25 Aug 2010 13:48:29 -0700 Subject: [PATCH 14/20] xfree86: Document terminate not mapped by default (bug 25083) Document that terminate is not mapped to Ctrl+Alt+Backspace by default, to help alleviate some confusion. Signed-off-by: Jesse Adkins Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- hw/xfree86/doc/man/Xorg.man.pre | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index 46d0e4468..805f3a3e2 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -1,4 +1,6 @@ .\" $XdotOrg: xserver/xorg/hw/xfree86/doc/man/Xorg.man.pre,v 1.3 2005/07/04 18:41:01 ajax Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' .TH __xservername__ __appmansuffix__ __vendorversion__ .SH NAME __xservername__ - X11R7 X server @@ -440,6 +442,14 @@ Immediately kills the server -- no questions asked. It can be disabled by setting the .B DontZap __xconfigfile__(__filemansuffix__) file option to a TRUE value. +.PP +.RS 8 +It should be noted that zapping is triggered by the +.B Terminate_Server +action in the keyboard map. This action is not part of the default keymaps +but can be enabled with the XKB option +.B \*qterminate:ctrl_alt_bksp\*q. +.RE .TP 8 .B Ctrl+Alt+Keypad-Plus Change video mode to next one specified in the configuration file. From 05e616767e5b7e60b92d31c4042ded5892dce6d4 Mon Sep 17 00:00:00 2001 From: Adam Tkac Date: Wed, 25 Aug 2010 10:38:40 +0200 Subject: [PATCH 15/20] Return Success from generate_modkeymap() when max_keys_per_mod is zero max_keys_per_mod equal to zero is a valid situation so generate_modkeymap should not return BadAlloc in this case. Signed-off-by: Adam Tkac Reviewed-by: Patrick E. Kane Signed-off-by: Peter Hutterer --- dix/inpututils.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dix/inpututils.c b/dix/inpututils.c index 8ec80b5e8..6693c67b3 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -286,7 +286,7 @@ int generate_modkeymap(ClientPtr client, DeviceIntPtr dev, { CARD8 keys_per_mod[8]; int max_keys_per_mod; - KeyCode *modkeymap; + KeyCode *modkeymap = NULL; int i, j, ret; ret = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGetAttrAccess); @@ -310,18 +310,20 @@ int generate_modkeymap(ClientPtr client, DeviceIntPtr dev, } } - modkeymap = calloc(max_keys_per_mod * 8, sizeof(KeyCode)); - if (!modkeymap) - return BadAlloc; + if (max_keys_per_mod != 0) { + modkeymap = calloc(max_keys_per_mod * 8, sizeof(KeyCode)); + if (!modkeymap) + return BadAlloc; - for (i = 0; i < 8; i++) - keys_per_mod[i] = 0; + for (i = 0; i < 8; i++) + keys_per_mod[i] = 0; - for (i = 8; i < MAP_LENGTH; i++) { - for (j = 0; j < 8; j++) { - if (dev->key->xkbInfo->desc->map->modmap[i] & (1 << j)) { - modkeymap[(j * max_keys_per_mod) + keys_per_mod[j]] = i; - keys_per_mod[j]++; + for (i = 8; i < MAP_LENGTH; i++) { + for (j = 0; j < 8; j++) { + if (dev->key->xkbInfo->desc->map->modmap[i] & (1 << j)) { + modkeymap[(j * max_keys_per_mod) + keys_per_mod[j]] = i; + keys_per_mod[j]++; + } } } } From 7925e8945649d4af237e6c3c5593b895a461bd1e Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Wed, 1 Sep 2010 14:45:34 +1000 Subject: [PATCH 16/20] Fix udev population of Bluetooth input device product IDs The udev device_added function takes the vendor and model IDs of added devices and converts them into an attribute that can be matched for by an InputClass configuration using MatchUSBID. Currently, the udev mechanism works for USB devices, but fails to work properly for Bluetooth devices. The product IDs of the event node are actually the IDs of the Bluetooth receiver instead of the device. This patch reads the product ID from the PRODUCT property of the parent of the added device. This tag is set correctly for both USB and Bluetooth input devices. The following devices have been tested by specifying individual InputClass sections in xorg.conf: * Apple Keyboard (Bluetooth) * Apple Magic Trackpad (Bluetooth) * Apple Magic Mouse (Bluetooth) * Microsoft Bluetooth Notebook Mouse 5000 (Bluetooth) * Microsoft IntelliMouse Optical (USB) * N-Trig Touchscreen (USB) * Wacom Bamboo Touch (USB) Signed-off-by: Chase Douglas Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- config/udev.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/config/udev.c b/config/udev.c index 993449075..b7717c96d 100644 --- a/config/udev.c +++ b/config/udev.c @@ -58,7 +58,6 @@ device_added(struct udev_device *udev_device) char *config_info = NULL; const char *syspath; const char *tags_prop; - const char *usb_vendor = NULL, *usb_model = NULL; const char *key, *value, *tmp; InputOption *options = NULL, *tmpo; InputAttributes attrs = {}; @@ -94,6 +93,8 @@ device_added(struct udev_device *udev_device) parent = udev_device_get_parent(udev_device); if (parent) { const char *ppath = udev_device_get_devnode(parent); + const char *product = udev_device_get_property_value(parent, "PRODUCT"); + unsigned int usb_vendor, usb_model; name = udev_device_get_sysattr_value(parent, "name"); LOG_SYSATTR(ppath, "name", name); @@ -104,6 +105,13 @@ device_added(struct udev_device *udev_device) attrs.pnp_id = udev_device_get_sysattr_value(parent, "id"); LOG_SYSATTR(ppath, "id", attrs.pnp_id); + + /* construct USB ID in lowercase hex - "0000:ffff" */ + if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) { + attrs.usb_id = Xprintf("%04x:%04x", usb_vendor, usb_model); + if (attrs.usb_id) + LOG_PROPERTY(path, "PRODUCT", product); + } } if (!name) name = "(unnamed)"; @@ -152,12 +160,6 @@ device_added(struct udev_device *udev_device) } else if (!strcmp(key, "ID_VENDOR")) { LOG_PROPERTY(path, key, value); attrs.vendor = value; - } else if (!strcmp(key, "ID_VENDOR_ID")) { - LOG_PROPERTY(path, key, value); - usb_vendor = value; - } else if (!strcmp(key, "ID_VENDOR_MODEL")) { - LOG_PROPERTY(path, key, value); - usb_model = value; } else if (!strcmp(key, "ID_INPUT_KEY")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; @@ -179,16 +181,6 @@ device_added(struct udev_device *udev_device) } } - /* construct USB ID in lowercase hex - "0000:ffff" */ - if (usb_vendor && usb_model) { - attrs.usb_id = Xprintf("%s:%s", usb_vendor, usb_model); - if (attrs.usb_id) { - char *cur; - for (cur = attrs.usb_id; *cur; cur++) - *cur = tolower(*cur); - } - } - LogMessage(X_INFO, "config/udev: Adding input device %s (%s)\n", name, path); rc = NewInputDeviceRequest(options, &attrs, &dev); From ff055506f0cbb852bed17acb9f9bbf1d715a854e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 23 Aug 2010 13:20:09 +1000 Subject: [PATCH 17/20] dix: fix crash when removing devices on a buttonless MD pointer (#29669) If the master does not have a button class, recalculating the number of buttons required for this master dereferences a NULL pointer. Guard against this, if the master pointer doesn't have a button class, it doesn't need to update it's number of buttons. Reproducible: Two devices on the same master, device NB with axes but no buttons, device A+B with axes and button . If NB was the last one to send an event through the master when A+B is removed from the server, master->button is NULL and leads to the above NULL-pointer dereference. X.Org Bug 29669 Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- dix/devices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/devices.c b/dix/devices.c index 62ff4b04c..f5d295295 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2341,7 +2341,7 @@ RecalculateMasterButtons(DeviceIntPtr slave) maxbuttons = max(maxbuttons, dev->button->numButtons); } - if (master->button->numButtons != maxbuttons) + if (master->button && master->button->numButtons != maxbuttons) { int i; DeviceChangedEvent event; From 86560b5d05f14bdf04d21b3457a66c0d5045db9c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 24 Aug 2010 13:46:35 +1000 Subject: [PATCH 18/20] dix: don't set time to CurrentTime in DeviceChangedEvents. CurrentTime is used by clients to skip setting the time, but not by the server. Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- dix/devices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/devices.c b/dix/devices.c index f5d295295..e506f6ac1 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2352,7 +2352,7 @@ RecalculateMasterButtons(DeviceIntPtr slave) event.header = ET_Internal; event.type = ET_DeviceChanged; - event.time = CurrentTime; + event.time = GetTimeInMillis(); event.deviceid = master->id; event.flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE; event.buttons.num_buttons = maxbuttons; From e00e2e7b68fbc932269d607ac5dc2c441d07ad9d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 23 Aug 2010 08:35:01 +1000 Subject: [PATCH 19/20] xfree86: Check for existence of button class before dereferencing it. The Irxon Super Mini Bluetooth Wireless Keyboard for PC/PDA/Cell Phones keyboards have axes but not buttons. The evdev driver doesn't set up a button class for these keyboards and a motion event handled by DGAProcessPointerEvent dereferences the dev->button NULL pointer, causing a server crash. Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- hw/xfree86/common/xf86DGA.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 82fb52a05..c468c6038 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -1095,7 +1095,7 @@ DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse) ev.header = ET_Internal; ev.length = sizeof(ev); ev.type = event->subtype; - ev.corestate = butc->state; + ev.corestate = butc ? butc->state : 0; if (master && master->key) ev.corestate |= XkbStateFieldFromRec(&master->key->xkbInfo->state); From 71972c2534d490284d3d42b456c2f34b964b2894 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Thu, 2 Sep 2010 10:53:28 +0200 Subject: [PATCH 20/20] linux: Don't lose console events on non-evdev drivers (#29969) The drain_console() function will race with new keyboard events being added by the hardware causing the server to lose keyboard events if the console fd is used for input. Only use the drain_console() when AllowEmptyInput is off which is the best indicator we have for whether the keyboard driver will be used. This patch will only fix the bug when hotplugging is disabled. What we really need is a way to figure out either whether we're _not_ using the keyboard driver (not predictable) or a way for the keyboard driver to disable drain_console(). X.Org Bug 29969 Signed-off-by: Thomas Hellstrom Reviewed-by: Peter Hutterer Reviewed-by: Adam Jackson Signed-off-by: Peter Hutterer --- hw/xfree86/os-support/linux/lnx_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index c8cec2ecb..92bfde48f 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -277,8 +277,9 @@ xf86OpenConsole(void) tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty); /* need to keep the buffer clean, else the kernel gets angry */ - console_handler = xf86AddGeneralHandler(xf86Info.consoleFd, - drain_console, NULL); + if (xf86Info.allowEmptyInput) + console_handler = xf86AddGeneralHandler(xf86Info.consoleFd, + drain_console, NULL); /* we really should have a InitOSInputDevices() function instead * of Init?$#*&Device(). So I just place it here */