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 644857 - improve focus handling during
improve focus handling during
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-03-15 20:15 UTC by Dan Winship
Modified: 2011-03-21 18:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
modalDialog: grab focus immediately, not after fade-in (2.27 KB, patch)
2011-03-15 20:15 UTC, Dan Winship
committed Details | Review
altTab: popModal before fading out (1.67 KB, patch)
2011-03-15 20:15 UTC, Dan Winship
committed Details | Review
runDialog: popModal before running the command (5.79 KB, patch)
2011-03-18 15:49 UTC, Dan Winship
needs-work Details | Review
runDialog: popModal before running the command (7.26 KB, patch)
2011-03-21 14:56 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2011-03-15 20:15:05 UTC
improve focus handling during animations

see patches. the grab_key_focus() call currently in modalDialog was
redundant with the pushModal() call, which is why I removed it.
Comment 1 Dan Winship 2011-03-15 20:15:07 UTC
Created attachment 183464 [details] [review]
modalDialog: grab focus immediately, not after fade-in

If the user types Alt+F2 and then immediately starts typing, some keys
can get lost. Fix that by grabbing focus sooner.
Comment 2 Dan Winship 2011-03-15 20:15:10 UTC
Created attachment 183465 [details] [review]
altTab: popModal before fading out

This lets the user start typing in the newly-selected window right
away, without any characters possibly getting eaten during the
animation.
Comment 3 Dan Winship 2011-03-18 15:49:16 UTC
Created attachment 183729 [details] [review]
runDialog: popModal before running the command

If you run a command from Alt+F2 that tries to get a server grab (eg,
xmag), it will fail if it starts up before the run dialog is finished
hiding.

Add a ModalDialog.popModal method, and call that before running the
RunDialog command. If the command succeeds, close the dialog as
before. If it fails, call ModalDialog.pushModal() to put things back
to normal before displaying the error.
Comment 4 Owen Taylor 2011-03-18 16:00:21 UTC
Review of attachment 183464 [details] [review]:

This has been bugging me every time I use St.set_slow_down_factor()!

I think I objected to subclasses modifying _members in an early version of the modalDialog patch and wanted setInitialKeyFocus() instead (in general I'm not a believer in "protected" - subclasses are just more ways to use a public interface), but ray found some way to avoid the need to modify it at all. But if it seems OK to you, go ahead with this way... don't feel that I'm the most authoritative guardian of our JS style.
Comment 5 Owen Taylor 2011-03-18 16:05:30 UTC
Review of attachment 183465 [details] [review]:

Looks fine. (obvious some cut-and-paste-sync-up going on here between altTab and ctrlAltTab, but doesn't seem like worth trying to factor out a baseclass.)
Comment 6 Owen Taylor 2011-03-18 16:18:48 UTC
Review of attachment 183729 [details] [review]:

You need a gdk_display_sync() in here somewhere for this to work reliably, right?

::: js/ui/modalDialog.js
@@ +195,3 @@
+    // dialog unusable as well (by pushing it under the lightbox), so
+    // it needs to be followed shortly by either a close() or a
+    // pushModal()

Not sure I understand the reason for this. In the runDialog case it doesn't seem it would matter, since we don't seem to return to the main loop, but if we did, then this seems like "noisy" interface - to dim temporarily then either undim and show an error or vanish. So, if we don't need it, and it isn't the right effect, why do it?
Comment 7 Dan Winship 2011-03-18 17:37:19 UTC
(In reply to comment #6)
> Not sure I understand the reason for this. In the runDialog case it doesn't
> seem it would matter, since we don't seem to return to the main loop, but if we
> did, then this seems like "noisy" interface - to dim temporarily then either
> undim and show an error or vanish. So, if we don't need it, and it isn't the
> right effect, why do it?

runDialog doesn't re-pushModal in the success case, and we return to the main loop for the fade-out animation in that case.

But the code is still wrong; we should be popModal()ing before the animation in *all* cases, because otherwise the dialog is still sensitive while it's fading out. (Type something in the run dialog and then hit Return twice very quickly and you'll launch two copies.)

As for the noisiness, I did it that way (as opposed to putting a new reactive actor over everything) because it was easy, and it turned out to be totally unnoticeable at normal speeds. (The dialog is fading at that point anyway.) Even slowed down, it's not really very noticeable.
Comment 8 Colin Walters 2011-03-18 17:45:21 UTC
(In reply to comment #7)
> 
> But the code is still wrong; we should be popModal()ing before the animation in
> *all* cases, because otherwise the dialog is still sensitive while it's fading
> out. (Type something in the run dialog and then hit Return twice very quickly
> and you'll launch two copies.)

Ohh...I wonder if *that's* the bug; people who have sticky Enter keys, or are holding it down or something.
Comment 9 Owen Taylor 2011-03-18 17:46:37 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > 
> > But the code is still wrong; we should be popModal()ing before the animation in
> > *all* cases, because otherwise the dialog is still sensitive while it's fading
> > out. (Type something in the run dialog and then hit Return twice very quickly
> > and you'll launch two copies.)
> 
> Ohh...I wonder if *that's* the bug; people who have sticky Enter keys, or are
> holding it down or something.

seems unlikely that someone would have an enter key that 100% reliably activates twice.
Comment 10 Colin Walters 2011-03-18 17:53:22 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > (In reply to comment #7)
> > > 
> > > But the code is still wrong; we should be popModal()ing before the animation in
> > > *all* cases, because otherwise the dialog is still sensitive while it's fading
> > > out. (Type something in the run dialog and then hit Return twice very quickly
> > > and you'll launch two copies.)
> > 
> > Ohh...I wonder if *that's* the bug; people who have sticky Enter keys, or are
> > holding it down or something.
> 
> seems unlikely that someone would have an enter key that 100% reliably
> activates twice.

What if it's set to fast repeat in some keymaps?
Comment 11 Owen Taylor 2011-03-18 18:08:36 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > Not sure I understand the reason for this. In the runDialog case it doesn't
> > seem it would matter, since we don't seem to return to the main loop, but if we
> > did, then this seems like "noisy" interface - to dim temporarily then either
> > undim and show an error or vanish. So, if we don't need it, and it isn't the
> > right effect, why do it?
> 
> runDialog doesn't re-pushModal in the success case, and we return to the main
> loop for the fade-out animation in that case.
> 
> But the code is still wrong; we should be popModal()ing before the animation in
> *all* cases, because otherwise the dialog is still sensitive while it's fading
> out. (Type something in the run dialog and then hit Return twice very quickly
> and you'll launch two copies.)

A different one-line make-insensitive is St.util_set_hidden-from_pick() (though you have to deal with reshow in that case) Should fade-out logic be moved into modalDialog? - seems that with your patch there's some messy runDialog/modalDialog stream-crossing.

> As for the noisiness, I did it that way (as opposed to putting a new reactive
> actor over everything) because it was easy, and it turned out to be totally
> unnoticeable at normal speeds. (The dialog is fading at that point anyway.)
> Even slowed down, it's not really very noticeable.

It's pretty hard to notice run-dialog fade-out as a fade-out at all at normal speeds, though maybe there's some subconcious effect.
Comment 12 Dan Winship 2011-03-21 14:56:31 UTC
Created attachment 183942 [details] [review]
runDialog: popModal before running the command

updated to do gdk_display_sync() and to use a separate event-blocking
actor rather than pushing the dialog under the lightbox.
Comment 13 Owen Taylor 2011-03-21 18:21:18 UTC
Review of attachment 183942 [details] [review]:

Strikes me as a little inconsistent that during close keystrokes are let through but click are blocked, but doubt anyone will notice. (The fade out stuff seems to be weirder - I've had times when things have been left lightboxed, but I can click on them. Unrelated.)

One issue seen in review

::: js/ui/runDialog.js
@@ +241,3 @@
             let symbol = e.get_key_symbol();
             if (symbol == Clutter.Return || symbol == Clutter.KP_Enter) {
+                this.popModal(true);

Doesn't match signature of popModal - as discussed on irc would be possible to make popModal always sync - not sure if that's better or not.
Comment 14 Dan Winship 2011-03-21 18:24:43 UTC
(In reply to comment #13)
> Strikes me as a little inconsistent that during close keystrokes are let
> through but click are blocked

popModal() will revert the focus to somewhere outside of the dialog though, and since clicks are blocked, there's no way to get back in.
Comment 15 Dan Winship 2011-03-21 18:27:11 UTC
Attachment 183464 [details] pushed as bad8dbc - modalDialog: grab focus immediately, not after fade-in
Attachment 183465 [details] pushed as 1e366aa - altTab: popModal before fading out
Attachment 183942 [details] pushed as a40daa3 - runDialog: popModal before running the command