From 5623f3b4b556fd7d50f99afe2307ec00634781bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 13 Sep 2013 18:10:18 +0200 Subject: [PATCH] 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 --- js/ui/messageTray.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 62c77e4b9..fb0b0ef41 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -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();