panel: focus windows on Escape key press

https://bugzilla.gnome.org/show_bug.cgi?id=671121
This commit is contained in:
Stefano Facchini 2017-11-01 19:43:11 +01:00
parent 93925c99b4
commit feed029ae4

View File

@ -797,6 +797,7 @@ var Panel = new Lang.Class({
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate)); this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress)); this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPress));
Main.overview.connect('showing', Lang.bind(this, function () { Main.overview.connect('showing', Lang.bind(this, function () {
this.actor.add_style_pseudo_class('overview'); this.actor.add_style_pseudo_class('overview');
@ -964,6 +965,16 @@ var Panel = new Lang.Class({
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
}, },
_onKeyPress: function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Escape) {
global.screen.focus_default_window(event.get_time());
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
},
_toggleMenu: function(indicator) { _toggleMenu: function(indicator) {
if (!indicator) // menu not supported by current session mode if (!indicator) // menu not supported by current session mode
return; return;