After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 641810 - MessageTray: factor out focus grabbing from Notification into a separate class
MessageTray: factor out focus grabbing from Notification into a separate class
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: message-tray
unspecified
Other All
: Normal normal
: ---
Assigned To: Dan Winship
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-02-08 07:28 UTC by Marina Zhurakhinskaya
Modified: 2011-02-10 16:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
MessageTray: factor out focus grabbing from Notification into a separate class (15.87 KB, patch)
2011-02-08 07:28 UTC, Marina Zhurakhinskaya
none Details | Review
MessageTray: factor out focus grabbing from Notification into a separate class (15.86 KB, patch)
2011-02-08 07:32 UTC, Marina Zhurakhinskaya
reviewed Details | Review
MessageTray: factor out focus grabbing from Notification into a separate class (15.50 KB, patch)
2011-02-09 05:25 UTC, Marina Zhurakhinskaya
reviewed Details | Review
MessageTray: factor out focus grabbing from Notification into a separate class (18.17 KB, patch)
2011-02-09 21:08 UTC, Marina Zhurakhinskaya
none Details | Review
MessageTray: factor out focus grabbing from Notification into a separate class (18.17 KB, patch)
2011-02-09 22:21 UTC, Marina Zhurakhinskaya
none Details | Review
MessageTray: factor out focus grabbing from Notification into a separate class (18.23 KB, patch)
2011-02-09 22:32 UTC, Marina Zhurakhinskaya
none Details | Review
MessageTray: factor out focus grabbing from Notification into a separate class (1.16 KB, patch)
2011-02-10 03:39 UTC, Marina Zhurakhinskaya
none Details | Review
MessageTray: factor out focus grabbing from Notification into a separate class (18.20 KB, patch)
2011-02-10 03:46 UTC, Marina Zhurakhinskaya
committed Details | Review

Description Marina Zhurakhinskaya 2011-02-08 07:28:12 UTC
That way it can be used when other components of the message tray need to
grab focus, such as the summary bubble with multiple notifications or the
summary item's right click menu.
Comment 1 Marina Zhurakhinskaya 2011-02-08 07:28:15 UTC
Created attachment 180369 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class
Comment 2 Marina Zhurakhinskaya 2011-02-08 07:32:09 UTC
Created attachment 180370 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

A small fix-up to remove an unused argument from the FocusGrabber constructor.
Comment 3 Dan Winship 2011-02-08 14:07:11 UTC
Comment on attachment 180370 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

Do we really need FocusGrabber? Can't it just be moved into MessageTray?

>+        Main.messageTray.focusGrabber.connect('focus-grabbed', Lang.bind(this,
>+            function (focusGrabber, actor) {
>+                if (actor != this.actor)
>+                    return;
>+
>+                if (this._buttonBox)
>+                    this._buttonBox.get_children()[0].grab_key_focus();
>+            }));

So, if grabFocus() did

    actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);

at the end, then that would automatically focus the first widget inside actor that has the can_focus property set, and then I think you don't need the focus-grabbed signal connection either here or in telepathyClient. (Which probably means you don't need the signal either.)

(Well, this also requires that the actor passed to grabFocus() is an StWidget.)
Comment 4 Marina Zhurakhinskaya 2011-02-09 05:25:50 UTC
Created attachment 180439 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

Calling navigate_focus() as you suggested seems to work.

MessageTray already has many member variables and functions, so I think it's
good to separate out a self-containing set of the member variables and
functions related to focus grabbing in a separate class.
Comment 5 Dan Winship 2011-02-09 14:25:39 UTC
Comment on attachment 180439 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

> MessageTray already has many member variables and functions, so I think it's
> good to separate out a self-containing set of the member variables and
> functions related to focus grabbing in a separate class.

True. OK, but it should be entirely an internal detail of MessageTray, not visible to the rest of the shell. (Ie, you should underscore-prefix this.focusGrabber).

It's also inelegant to have FocusGrabber using Main.messageTray to call back into its "parent" object. It would be cleaner to have FocusGrabber emit 'lock', 'unlock', and 'escape' signals, and have MessageTray catch and act on those signals.
Comment 6 Marina Zhurakhinskaya 2011-02-09 21:08:57 UTC
Created attachment 180514 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

Made this._focusGrabber a private variable in MessageTray and switched to using
signals to do locking, unlocking, and escaping the tray.

Made _lock(), _unlock(), and _escapeTray() private functions of the message
tray since they are no longer used from outside of it.

Realized that we should not be unsetting this.actor in FocusGrabber when
we are ungrabbing focus while toggling focus grab mode, so added
this._togglingFocusGrabMode to identify this case.
Comment 7 Marina Zhurakhinskaya 2011-02-09 22:21:18 UTC
Created attachment 180521 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

Removed some stray parentheses.
Comment 8 Marina Zhurakhinskaya 2011-02-09 22:32:18 UTC
Created attachment 180525 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

Another small fix - call Lang.bind() for signal callbacks.
Comment 9 Marina Zhurakhinskaya 2011-02-10 03:39:40 UTC
Created attachment 180549 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

Another small fix - remove stray curly braces.
Comment 10 Marina Zhurakhinskaya 2011-02-10 03:46:37 UTC
Created attachment 180550 [details] [review]
MessageTray: factor out focus grabbing from Notification into a separate class

Actually upload full patch...