From 9d6b8365702e4648e793fea21ad22f7174558680 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 28 Sep 2012 11:49:29 +1000 Subject: [PATCH 1/5] dix: fix crash on XI 1.x grabs on disabled devices. (#54934) If the device is disabled, the sprite window is NULL and dereferencing crashes the server. This is only triggered for XI 1.x grabs (ProcXGrabDevice) as XI2 grabs would trigger another code path, creating a sprite for the disabled device as if detaching it (which is wrong and fixed with this patch too). Grabbing a disabled device doesn't make sense as it won't send events anyway. However, the protocol specs do not prohibit it, so we need to keep it working. Luckily, oldWin is only used for focus out events, which aren't necessary given that the device is disabled. X.Org Bug 54934 Signed-off-by: Peter Hutterer Reviewed-by: Chase Douglas --- dix/events.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dix/events.c b/dix/events.c index 3b40446bc..c0e330b85 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1555,11 +1555,13 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, WindowPtr oldWin; /* slave devices need to float for the duration of the grab. */ - if (grab->grabtype == XI2 && + if (grab->grabtype == XI2 && keybd->enabled && !(passive & ImplicitGrabMask) && !IsMaster(keybd)) DetachFromMaster(keybd); - if (grabinfo->grab) + if (!keybd->enabled) + oldWin = NULL; + else if (grabinfo->grab) oldWin = grabinfo->grab->window; else if (keybd->focus) oldWin = keybd->focus->win; @@ -1569,7 +1571,8 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, oldWin = keybd->focus->win; if (keybd->valuator) keybd->valuator->motionHintWindow = NullWindow; - DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab); + if (oldWin) + DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab); if (syncEvents.playingEvents) grabinfo->grabTime = syncEvents.time; else From 3e6358ee6c33979329b78fe2097a1fdf76fb69cd Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Fri, 7 Sep 2012 21:48:35 -0400 Subject: [PATCH 2/5] Xi: Don't check for TOUCH_END, it's never set This flag is never set, so checking for it here means that we'll never release the simulated mouse button press after the user touches (and releases) the touchscreen for the first time. Fixes a problem where the XO laptop touchpad became totally unusable after touching the screen for the first time (since X then behaved as if the mouse button was held down all the time). Signed-off-by: Daniel Drake Reviewed-by: Chase Douglas Signed-off-by: Peter Hutterer --- Xi/exevents.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 494d07e20..6ed499142 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -949,8 +949,6 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event) if (!(event->flags & TOUCH_POINTER_EMULATED)) return DONT_PROCESS; - if (!(event->flags & TOUCH_END)) - return DONT_PROCESS; DecreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask, &t->state); From 314776eb369ca2e438907795ae030dd743c281fc Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 7 Sep 2012 18:30:23 +0100 Subject: [PATCH 3/5] Touch: Fix duplicate TouchBegin selection with virtual devices Given the following scenario: 1) client A selects for TouchBegin on window W for device D 2) client B selects for TouchBegin on window W for XIAllDevices 3) client C selects for TouchBegin on window W with device E Step 3 will fail with BadImplementation, because attempting to look up XIAllDevices or XIAllMasterDevices with dixLookupDevices doesn't work. This should succeed (or, if it was selecting for device D, fail with BadAccess as it would be a duplicate selection). Fix this by performing the appropriate lookup for virtual devices. Signed-off-by: Daniel Stone Cc: Peter Hutterer Cc: Chase Douglas Signed-off-by: Peter Hutterer --- Xi/xiselectev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c index 0e45cb8cb..ab1b6245f 100644 --- a/Xi/xiselectev.c +++ b/Xi/xiselectev.c @@ -180,8 +180,13 @@ ProcXISelectEvents(ClientPtr client) if (CLIENT_ID(iclient->resource) == client->index) continue; - dixLookupDevice(&tmp, evmask->deviceid, serverClient, - DixReadAccess); + if (evmask->deviceid == XIAllDevices) + tmp = inputInfo.all_devices; + else if (evmask->deviceid == XIAllMasterDevices) + tmp = inputInfo.all_master_devices; + else + dixLookupDevice(&tmp, evmask->deviceid, serverClient, + DixReadAccess); if (!tmp) return BadImplementation; /* this shouldn't happen */ From f64254d85e731d0b4369d871a9a735b03f283ba6 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 23 Aug 2012 15:00:24 +1000 Subject: [PATCH 4/5] mi: drop two useless conditions in miPointerSetPosition pDev cannot be NULL here since fill_pointer_events is the only caller. And if the screen is NULL, then the device tries to send events before it is fully initialised. That certainly shouldn't happen and would be a bug elsewhere. Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- mi/mipointer.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index 4defaf5ec..f34506326 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -575,13 +575,8 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, miPointerPtr pPointer; - if (!pDev) - return NULL; - pPointer = MIPOINTER(pDev); pScreen = pPointer->pScreen; - if (!pScreen) - return NULL; /* called before ready */ x = trunc(*screenx); y = trunc(*screeny); From 7998e26159893674be69183a73a89a53f5608d58 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Fri, 28 Sep 2012 15:03:42 -0700 Subject: [PATCH 5/5] Fix additional gcc -Wwrite-strings warning in xf86 ddx Commit 09e4b78f missed a case. Signed-off-by: Jason Gerecke Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- hw/xfree86/common/xf86Opt.h | 2 +- hw/xfree86/common/xf86Option.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/common/xf86Opt.h b/hw/xfree86/common/xf86Opt.h index 0d808de14..c3ba2d75c 100644 --- a/hw/xfree86/common/xf86Opt.h +++ b/hw/xfree86/common/xf86Opt.h @@ -85,7 +85,7 @@ extern _X_EXPORT int xf86CheckIntOption(XF86OptionPtr optlist, const char *name, extern _X_EXPORT double xf86CheckRealOption(XF86OptionPtr optlist, const char *name, double deflt); extern _X_EXPORT char *xf86CheckStrOption(XF86OptionPtr optlist, - const char *name, char *deflt); + const char *name, const char *deflt); extern _X_EXPORT int xf86CheckBoolOption(XF86OptionPtr list, const char *name, int deflt); extern _X_EXPORT double xf86CheckPercentOption(XF86OptionPtr list, diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index 7cc744029..c2ec79a53 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -276,7 +276,7 @@ xf86CheckRealOption(XF86OptionPtr optlist, const char *name, double deflt) } char * -xf86CheckStrOption(XF86OptionPtr optlist, const char *name, char *deflt) +xf86CheckStrOption(XF86OptionPtr optlist, const char *name, const char *deflt) { return LookupStrOption(optlist, name, deflt, FALSE); }