From 78d09336391faf6e3fe9f67771b03114f23c0b7c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Jan 2014 21:33:30 +0100 Subject: [PATCH] Xi: Ensure DeviceChanged is emitted after grabs are deactivated When a grab on a slave device is deactivated, the master device must be checked, just in case there were events from other devices while the slave device was stolen away by the passive grab. This may introduce misbehaviors on mismatching valuators and device features later on UpdateDeviceState(). Signed-off-by: Carlos Garnacho Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer (cherry picked from commit b2d5ee2e3684951b611fd2068d57cc65fd8305a3) --- Xi/exevents.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index ed6dc36..6b9561e 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1783,8 +1783,25 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device) DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent *) event, NullGrab, NullWindow, device); - if (deactivateDeviceGrab == TRUE) + if (deactivateDeviceGrab == TRUE) { (*device->deviceGrab.DeactivateGrab) (device); + + if (!IsMaster (device) && !IsFloating (device)) { + int flags, num_events = 0; + InternalEvent dce; + + flags = (IsPointerDevice (device)) ? + DEVCHANGE_POINTER_EVENT : DEVCHANGE_KEYBOARD_EVENT; + UpdateFromMaster (&dce, device, flags, &num_events); + BUG_WARN(num_events > 1); + + if (num_events == 1) + ChangeMasterDeviceClasses(GetMaster (device, MASTER_ATTACHED), + &dce.changed_event); + } + + } + event->detail.key = key; } -- 1.9.0