grabHelper: Make sure to call onUngrabbed for all popped actors

This commit is contained in:
Jasper St. Pierre 2012-08-16 13:48:22 -04:00
parent 11dc510ae4
commit 3031036cb0

View File

@ -207,6 +207,7 @@ const GrabHelper = new Lang.Class({
return; return;
let poppedGrab = this._grabStack[grabStackIndex]; let poppedGrab = this._grabStack[grabStackIndex];
let poppedGrabs = this._grabStack.slice(grabStackIndex);
// "Pop" poppedGrab and everything after off by truncating the array. // "Pop" poppedGrab and everything after off by truncating the array.
this._grabStack.length = grabStackIndex; this._grabStack.length = grabStackIndex;
@ -218,8 +219,10 @@ const GrabHelper = new Lang.Class({
let focus = global.stage.key_focus; let focus = global.stage.key_focus;
let hadFocus = focus && this._isWithinGrabbedActor(focus); let hadFocus = focus && this._isWithinGrabbedActor(focus);
if (poppedGrab.onUngrab) for (let i = 0; i < poppedGrabs.length; i++) {
poppedGrab.onUngrab(); if (poppedGrabs[i].onUngrab)
poppedGrabs[i].onUngrab();
}
// If we took away the last grab, ungrab ourselves. // If we took away the last grab, ungrab ourselves.
if (this._grabStack.length == 0) if (this._grabStack.length == 0)