Make Esc hide the tray when a notification has focus

It's convenient to have Esc working for expanded new notifications that
have focus and for summary notifications.

https://bugzilla.gnome.org/show_bug.cgi?id=617224
This commit is contained in:
Marina Zhurakhinskaya 2010-07-21 01:26:25 -04:00
parent 95d438b86d
commit 65991cc057

View File

@ -87,6 +87,7 @@ Notification.prototype = {
this._focusActorChangedId = 0;
this._stageInputModeChangedId = 0;
this._capturedEventId = 0;
this._keyPressId = 0;
source.connect('clicked', Lang.bind(this,
function() {
@ -405,6 +406,8 @@ Notification.prototype = {
this._focusWindowChangedId = metaDisplay.connect('notify::focus-window', Lang.bind(this, this._focusWindowChanged));
this._stageInputModeChangedId = global.connect('notify::stage-input-mode', Lang.bind(this, this._stageInputModeChanged));
this._keyPressId = global.stage.connect('key-press-event', Lang.bind(this, this._onKeyPress));
}
// We need to listen to this signal in the overview, as well as in the main view, to make the key bindings such as
@ -454,8 +457,29 @@ Notification.prototype = {
_onCapturedEvent: function(actor, event) {
let source = event.get_source();
if (event.type() == Clutter.EventType.BUTTON_PRESS && !this.actor.contains(source))
this.ungrabFocus();
switch (event.type()) {
case Clutter.EventType.BUTTON_PRESS:
if (!this.actor.contains(source))
this.ungrabFocus();
break;
case Clutter.EventType.KEY_PRESS:
let symbol = event.get_key_symbol();
if (symbol == Clutter.Escape) {
Main.messageTray.escapeTray();
return true;
}
break;
}
return false;
},
_onKeyPress: function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.Escape) {
Main.messageTray.escapeTray();
return true;
}
return false;
},
@ -485,6 +509,11 @@ Notification.prototype = {
this._capturedEventId = 0;
}
if (this._keyPressId > 0) {
global.stage.disconnect(this._keyPressId);
this._keyPressId = 0;
}
this._hasFocus = false;
Main.messageTray.unlock();
@ -1010,6 +1039,17 @@ MessageTray.prototype = {
return false;
},
escapeTray: function() {
this.unlock();
this._pointerInTray = false;
this._pointerInSummary = false;
if (this._notificationTimeoutId) {
Mainloop.source_remove(this._notificationTimeoutId);
this._notificationTimeoutId = 0;
}
this._updateState();
},
// All of the logic for what happens when occurs here; the various
// event handlers merely update variables such as
// 'this._pointerInTray', 'this._summaryState', etc, and