grabHelper: Remove explicitly having to select modal

https://bugzilla.gnome.org/show_bug.cgi?id=700735
This commit is contained in:
Jasper St. Pierre 2013-05-23 17:20:30 -04:00
parent eef593a34e
commit 393577ee78
3 changed files with 10 additions and 18 deletions

View File

@ -144,7 +144,6 @@ const GrabHelper = new Lang.Class({
// focus on the clicked on menu item. // focus on the clicked on menu item.
grab: function(params) { grab: function(params) {
params = Params.parse(params, { actor: null, params = Params.parse(params, { actor: null,
modal: false,
focus: null, focus: null,
onUngrab: null }); onUngrab: null });
@ -157,7 +156,7 @@ const GrabHelper = new Lang.Class({
params.savedFocus = focus; params.savedFocus = focus;
if (params.modal && !this._takeModalGrab()) if (!this._takeModalGrab())
return false; return false;
this._grabStack.push(params); this._grabStack.push(params);
@ -169,9 +168,6 @@ const GrabHelper = new Lang.Class({
newFocus.grab_key_focus(); newFocus.grab_key_focus();
} }
if (params.modal && !this._capturedEventId)
this._capturedEventId = global.stage.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
return true; return true;
}, },
@ -180,6 +176,8 @@ const GrabHelper = new Lang.Class({
if (firstGrab) { if (firstGrab) {
if (!Main.pushModal(this._owner, this._modalParams)) if (!Main.pushModal(this._owner, this._modalParams))
return false; return false;
this._capturedEventId = global.stage.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
} }
this._modalCount++; this._modalCount++;
@ -191,6 +189,11 @@ const GrabHelper = new Lang.Class({
if (this._modalCount > 0) if (this._modalCount > 0)
return; return;
global.stage.disconnect(this._capturedEventId);
this._capturedEventId = 0;
this._ignoreRelease = false;
Main.popModal(this._owner); Main.popModal(this._owner);
global.sync_pointer(); global.sync_pointer();
}, },
@ -238,15 +241,7 @@ const GrabHelper = new Lang.Class({
if (poppedGrab.onUngrab) if (poppedGrab.onUngrab)
poppedGrab.onUngrab(params.isUser); poppedGrab.onUngrab(params.isUser);
if (poppedGrab.modal) this._releaseModalGrab();
this._releaseModalGrab();
}
if (!this.grabbed && this._capturedEventId > 0) {
global.stage.disconnect(this._capturedEventId);
this._capturedEventId = 0;
this._ignoreRelease = false;
} }
if (hadFocus) { if (hadFocus) {

View File

@ -1808,7 +1808,6 @@ const MessageTray = new Lang.Class({
let [x, y, mask] = global.get_pointer(); let [x, y, mask] = global.get_pointer();
this._contextMenu.setPosition(Math.round(x), Math.round(y)); this._contextMenu.setPosition(Math.round(x), Math.round(y));
this._grabHelper.grab({ actor: this._contextMenu.actor, this._grabHelper.grab({ actor: this._contextMenu.actor,
modal: true,
onUngrab: Lang.bind(this, function () { onUngrab: Lang.bind(this, function () {
this._contextMenu.close(BoxPointer.PopupAnimation.FULL); this._contextMenu.close(BoxPointer.PopupAnimation.FULL);
}) })
@ -2375,7 +2374,6 @@ const MessageTray = new Lang.Class({
_showTray: function() { _showTray: function() {
if (!this._grabHelper.grab({ actor: this.actor, if (!this._grabHelper.grab({ actor: this.actor,
modal: true,
onUngrab: Lang.bind(this, this._escapeTray) })) { onUngrab: Lang.bind(this, this._escapeTray) })) {
this._traySummoned = false; this._traySummoned = false;
return false; return false;
@ -2720,7 +2718,6 @@ const MessageTray = new Lang.Class({
this._summaryBoxPointer.bin.child = child; this._summaryBoxPointer.bin.child = child;
this._grabHelper.grab({ actor: this._summaryBoxPointer.bin.child, this._grabHelper.grab({ actor: this._summaryBoxPointer.bin.child,
modal: true,
onUngrab: Lang.bind(this, this._onSummaryBoxPointerUngrabbed) }); onUngrab: Lang.bind(this, this._onSummaryBoxPointerUngrabbed) });
this._summaryBoxPointer.actor.opacity = 0; this._summaryBoxPointer.actor.opacity = 0;

View File

@ -1701,7 +1701,7 @@ const PopupMenuManager = new Lang.Class({
if (open) { if (open) {
if (this.activeMenu && !this.activeMenu.isChildMenu(menu)) if (this.activeMenu && !this.activeMenu.isChildMenu(menu))
this.activeMenu.close(BoxPointer.PopupAnimation.FADE); this.activeMenu.close(BoxPointer.PopupAnimation.FADE);
this._grabHelper.grab({ actor: menu.actor, modal: true, focus: menu.sourceActor, this._grabHelper.grab({ actor: menu.actor, focus: menu.sourceActor,
onUngrab: Lang.bind(this, this._closeMenu, menu) }); onUngrab: Lang.bind(this, this._closeMenu, menu) });
} else { } else {
this._grabHelper.ungrab({ actor: menu.actor }); this._grabHelper.ungrab({ actor: menu.actor });