Delete all grabs from all devices when deleting a window.

This commit is contained in:
Peter Hutterer 2007-04-03 19:02:14 +09:30
parent 5f382c9c7f
commit 207f710d16

View File

@ -4637,7 +4637,7 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
WindowPtr parent; WindowPtr parent;
DeviceIntPtr mouse = inputInfo.pointer; DeviceIntPtr mouse = inputInfo.pointer;
DeviceIntPtr keybd = inputInfo.keyboard; DeviceIntPtr keybd = inputInfo.keyboard;
FocusClassPtr focus = keybd->focus; FocusClassPtr focus;
OtherClientsPtr oc; OtherClientsPtr oc;
GrabPtr passive; GrabPtr passive;
GrabPtr grab; GrabPtr grab;
@ -4650,12 +4650,27 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
((grab->window == pWin) || (grab->confineTo == pWin))) ((grab->window == pWin) || (grab->confineTo == pWin)))
(*mouse->coreGrab.DeactivateGrab)(mouse); (*mouse->coreGrab.DeactivateGrab)(mouse);
/* Deactivating a keyboard grab should cause focus events. */
/* Deactivating a keyboard grab should cause focus events. */
grab = keybd->coreGrab.grab; grab = keybd->coreGrab.grab;
if (grab && (grab->window == pWin)) if (grab && (grab->window == pWin))
(*keybd->coreGrab.DeactivateGrab)(keybd); (*keybd->coreGrab.DeactivateGrab)(keybd);
/* And now the real devices */
for (mouse = inputInfo.devices; mouse; mouse = mouse->next)
{
grab = mouse->coreGrab.grab;
if (grab && ((grab->window == pWin) || (grab->confineTo == pWin)))
(*mouse->coreGrab.DeactivateGrab)(mouse);
}
for (keybd = inputInfo.devices; keybd; keybd = keybd->next)
{
if (IsKeyboardDevice(keybd))
{
focus = keybd->focus;
/* If the focus window is a root window (ie. has no parent) then don't /* If the focus window is a root window (ie. has no parent) then don't
delete the focus from it. */ delete the focus from it. */
@ -4682,7 +4697,7 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
parent = parent->parent; parent = parent->parent;
focus->traceGood--; focus->traceGood--;
} while (!parent->realized } while (!parent->realized
/* This would be a good protocol change -- windows being reparented /* This would be a good protocol change -- windows being reparented
during SaveSet processing would cause the focus to revert to the during SaveSet processing would cause the focus to revert to the
nearest enclosing window which will survive the death of the exiting nearest enclosing window which will survive the death of the exiting
client, instead of ending up reverting to a dying window and thence client, instead of ending up reverting to a dying window and thence
@ -4703,9 +4718,14 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
break; break;
} }
} }
}
if (mouse->valuator->motionHintWindow == pWin) if (IsPointerDevice(keybd))
mouse->valuator->motionHintWindow = NullWindow; {
if (keybd->valuator->motionHintWindow == pWin)
keybd->valuator->motionHintWindow = NullWindow;
}
}
if (freeResources) if (freeResources)
{ {