[gnome-shell] grabHelper: Allow pressing escape on grab focus grabs
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] grabHelper: Allow pressing escape on grab focus grabs
- Date: Wed, 2 Jan 2013 17:33:38 +0000 (UTC)
commit 52ca15b51410eee2d7e22cdd10fb1e7cb1d14133
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Dec 30 12:32:41 2012 -0500
grabHelper: Allow pressing escape on grab focus grabs
We didn't install the captured event handler on grab focus grabs,
leading to the case where we didn't ungrab correctly.
https://bugzilla.gnome.org/show_bug.cgi?id=690897
js/ui/grabHelper.js | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/grabHelper.js b/js/ui/grabHelper.js
index 9c8df70..315e2d4 100644
--- a/js/ui/grabHelper.js
+++ b/js/ui/grabHelper.js
@@ -183,6 +183,9 @@ const GrabHelper = new Lang.Class({
else if (hadFocus || params.grabFocus)
_navigateActor(newFocus);
+ if ((params.grabFocus || params.modal) && !this._capturedEventId)
+ this._capturedEventId = global.stage.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
+
this._grabStack.push(params);
return true;
},
@@ -192,8 +195,6 @@ const GrabHelper = new Lang.Class({
if (firstGrab) {
if (!Main.pushModal(this._owner, this._modalParams))
return false;
-
- this._capturedEventId = global.stage.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
}
this._modalCount++;
@@ -205,11 +206,6 @@ const GrabHelper = new Lang.Class({
if (this._modalCount > 0)
return;
- if (this._capturedEventId > 0) {
- global.stage.disconnect(this._capturedEventId);
- this._capturedEventId = 0;
- }
-
Main.popModal(this._owner);
global.sync_pointer();
},
@@ -308,6 +304,11 @@ const GrabHelper = new Lang.Class({
this._releaseFocusGrab();
}
+ if (!this.grabbed && this._capturedEventId > 0) {
+ global.stage.disconnect(this._capturedEventId);
+ this._capturedEventId = 0;
+ }
+
if (hadFocus) {
let poppedGrab = poppedGrabs[0];
_navigateActor(poppedGrab.savedFocus);
@@ -316,6 +317,13 @@ const GrabHelper = new Lang.Class({
_onCapturedEvent: function(actor, event) {
let type = event.type();
+
+ if (type == Clutter.EventType.KEY_PRESS &&
+ event.get_key_symbol() == Clutter.KEY_Escape) {
+ this.ungrab({ isUser: true });
+ return true;
+ }
+
let press = type == Clutter.EventType.BUTTON_PRESS;
let release = type == Clutter.EventType.BUTTON_RELEASE;
let button = press || release;
@@ -328,12 +336,6 @@ const GrabHelper = new Lang.Class({
if (!button && this._modalCount == 0)
return false;
- if (type == Clutter.EventType.KEY_PRESS &&
- event.get_key_symbol() == Clutter.KEY_Escape) {
- this.ungrab({ isUser: true });
- return true;
- }
-
if (this._isWithinGrabbedActor(event.get_source()))
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]