[gnome-shell] messageTray: Add focusTrap



commit 5623f3b4b556fd7d50f99afe2307ec00634781bc
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Sep 13 18:10:18 2013 +0200

    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 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 62c77e4..fb0b0ef 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();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]