messageTray: Add focusTrap

The summary container will trap the focus if any sources are present,
making the message tray menu unreachable by keynav. Apply the same
hack as in searchDisplay and add a focusTrap to move the focus manually
as necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=707799
This commit is contained in:
Florian Müllner 2013-09-13 18:10:18 +02:00
parent a227d595f5
commit 5623f3b4b5

View File

@ -27,6 +27,7 @@ const PopupMenu = imports.ui.popupMenu;
const Params = imports.misc.params;
const Tweener = imports.ui.tweener;
const Util = imports.misc.util;
const ViewSelector = imports.ui.viewSelector;
const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
@ -1811,6 +1812,13 @@ const MessageTray = new Lang.Class({
y_expand: true });
this.actor.add_actor(this._summary);
this._focusTrap = new ViewSelector.FocusTrap({ can_focus: true });
this._focusTrap.connect('key-focus-in', Lang.bind(this,
function() {
this._messageTrayMenuButton.actor.grab_key_focus();
}));
this._summary.add_actor(this._focusTrap);
this._summaryMotionId = 0;
this._summaryBoxPointer = new BoxPointer.BoxPointer(St.Side.BOTTOM,
@ -1935,6 +1943,9 @@ const MessageTray = new Lang.Class({
this._messageTrayMenuButton = new MessageTrayMenuButton(this);
this.actor.add_actor(this._messageTrayMenuButton.actor);
this._messageTrayMenuButton.actor.connect('key-press-event',
Lang.bind(this, this._onTrayButtonKeyPress));
let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM);
gesture.connect('activated', Lang.bind(this, this.toggle));
global.stage.add_action(gesture);
@ -2030,6 +2041,16 @@ const MessageTray = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
_onTrayButtonKeyPress: function(actor, event) {
if (event.get_key_symbol() == Clutter.ISO_Left_Tab) {
this._focusTrap.can_focus = false;
this._summary.navigate_focus(null, Gtk.DirectionType.TAB_BACKWARD, false);
this._focusTrap.can_focus = true;
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
},
_onNotificationKeyRelease: function(actor, event) {
if (event.get_key_symbol() == Clutter.KEY_Escape && event.get_state() == 0) {
this._expireNotification();