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 149543 - unshowing desktop has inconsistent focus window
unshowing desktop has inconsistent focus window
Status: RESOLVED FIXED
Product: metacity
Classification: Other
Component: general
2.8.x
Other Linux
: Normal minor
: ---
Assigned To: Metacity maintainers list
Metacity maintainers list
Depends on:
Blocks:
 
 
Reported: 2004-08-06 21:46 UTC by Elijah Newren
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Focus the default window when unshowing the desktop via the panel applet (729 bytes, patch)
2004-08-06 21:47 UTC, Elijah Newren
accepted-commit_now Details | Review

Description Elijah Newren 2004-08-06 21:46:56 UTC
This bug affects both click and sloppy focus methods, but not mouse focus.  When
one unshows the desktop with ctrl-alt-d, the default focus window is focused. 
When one unshows the desktop with the panel applet, no window is focused.

I will attach a one-line patch momentarily that fixes this issue.
Comment 1 Elijah Newren 2004-08-06 21:47:37 UTC
Created attachment 30293 [details] [review]
Focus the default window when unshowing the desktop via the panel applet
Comment 2 Rob Adams 2004-08-06 21:58:46 UTC
Probably should just call focus_default_window from unshow_desktop rather than
go through the code and add that call right after every call to unshow_desktop.

That's a three-line patch, but I think you can handle it.  You're a smart guy :-)
Comment 3 Elijah Newren 2004-08-06 22:48:44 UTC
I had considered that.  There are exactly three calls to unshow_desktop, the one
that isn't mentioned above is window.c's maybe_leave_show_desktop_mode().  I
tried following the cases through there and did notice that, for example,
meta_window_activate (which calls meta_screen_unshow_desktop) would also call
meta_window_focus on the focused window.  So we'd at least be wasting effort by
focusing the same window twice.  It seemed like there might be something more
convoluted there too, but I haven't followed all the cases through completely. 
And I didn't really want to check out all the cases completely because, contrary
to popular opinion, I'm a dumb guy and following all the cases might take me a
long time.  Since that might be a lame excuse, my official one is that it's
wasteful of resources.  :-)

But if focusing the same window twice isn't wasteful enough to care about, I can
try looking into it again.
Comment 4 Elijah Newren 2004-08-07 01:33:10 UTC
Okay, I've thought it through some more.  I believe allowing unshow_desktop to
not focus a window may be what we want to do.  Although there are the two
obvious cases when unshow_desktop is used by itself (and thus the default focus
window is wanted), there are other cases (and more could arise in the future)
where unshow_desktop is used as part of a larger operation where a different
focus window could be wanted than the default one.

For example, launching a window or activating one will cause the "show desktop"
mode to be exited.  It used to be the case that when the "show desktop" mode was
exited in this way, all windows would be unminimized.  (And it's still not an
unreasonable choice of behavior, but someone decided that keeping them minimized
made more sense for Metacity.)  In such a case, when the windows were all
unminimized, unshow_desktop would cause the default window to be focused --and
the default one may not be the launched or activated one.  Yet the launched or
activated one is the one that should be focused.  This would result in
flickering, or perhaps even the wrong window having focus.

This is only one case and it can't currently happen--but there's always the
possibility that we would want to revert the unminimize choice which would make
it possible.  And, of course, other cases similar to this could potentially
arise in the future.

Of course, as you pointed out, Rob, it's probably also not wise to try to
remember to call focus_default_window in all the cases where we need to. 
Perhaps we can add a boolean parameter to unshow_desktop, and have
unshow_desktop call focus_default_window if it's true.  That way the functions
that don't want unshow_desktop to focus a window don't have to have that happen,
but it can be taken care of in the other cases where we clearly do want it.

Does this sound reasonable?  Am I making any sense?  Did I just get confused and
I'm missing something that makes me misunderstand what's going on?  (It's
entirely possible; for some reason I was getting a little perplexed trying to
track down a lot of different what-if's)
Comment 5 Rob Adams 2004-08-07 01:48:45 UTC
Comment on attachment 30293 [details] [review]
Focus the default window when unshowing the desktop via the panel applet

Um, yeah.  Actually I didn't put much that much thought into it.  I had just
failed to notice that there was a case where we weren't calling
focus_default_window.  But, as you point out, we're not and shouldn't be in the
window activation case, so I'd say the original patch is good.
Comment 6 Elijah Newren 2004-08-07 03:14:53 UTC
committed.