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 123803 - after doing alt+ctrl+arrows workspace switching, update focus window
after doing alt+ctrl+arrows workspace switching, update focus window
Status: RESOLVED FIXED
Product: metacity
Classification: Other
Component: general
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: Metacity maintainers list
Metacity maintainers list
Depends on:
Blocks:
 
 
Reported: 2003-10-03 22:10 UTC by Havoc Pennington
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: 2.8.x
GNOME version: 2.7/2.8


Attachments
Focus the default window after switching workspaces upon key release (1.76 KB, patch)
2004-09-11 23:33 UTC, Elijah Newren
none Details | Review
Replace assert with a warning (1.90 KB, patch)
2004-09-12 01:25 UTC, Elijah Newren
accepted-commit_now Details | Review

Description Havoc Pennington 2003-10-03 22:10:27 UTC
See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=92212

Though, maybe we were deliberately doing it the way we are?
I may be confused.
Comment 1 Rob Adams 2003-10-03 22:25:36 UTC
I guess the difference is the submitter wants us to focus the default
window both on workspace switch and on release of the modifier.

Maybe a better solution would be to honor EnterNotify/LeaveNotify
events for windows while we have a keyboard grab.
Comment 2 L. David Baron 2003-12-03 01:07:54 UTC
Focusing windows while doing mouse movement during workspace switching
would be better than what I proposed, but what I proposed was easy,
and solved the problem of focus being wrong when focus mattered.

(This bug isn't bothering me as much lately, since I'm not currently
using a Kinesis keyboard, which makes it really easy to do workspace
switching (either horizontal or vertical, but not a combination) with
one hand (holding down both Ctrl and Alt with one thumb).  But I
suspect others with similar setups would notice it.)
Comment 3 Elijah Newren 2004-09-03 19:03:05 UTC
I've spent some time looking at this, and I think I can clear up some of the
confusion, but I have some questions of my own that I hope someone can answer.

First, David's patch adds a comment:
  /* meta_workspace_activate will no-op if we're already on the
  workspace in question, but we need to focus */
I believe that comment should have an s/if/since/.  The switch_to_workspace()
just before that comment (which has since become a meta_workspace_activate()) is
not needed.  The actual workspace switch happens when various keybindings are
pressed (elsewhere in that function), not here when the modifiers are released.
 Perhaps there's an edge cases where both meta_workspace_activate's are
necessary, but I'm having a hard time thinking of one and it really seems odd to
have both.

Second, the real line that David adds is:
   meta_screen_focus_default_window (target_workspace->screen, NULL);
This function no longer exists, but even if it did it should not be used here. 
The reason is that it would change the behavior for click-to-focus too so that
moving the mouse (without clicking) could cause a different window to be
focused, i.e. click-to-focus would behave like mouse focus in this case.  Using
meta_workspace_focus_default_window instead would work for all focus modes
(though in many cases it would result in the same window being focused twice). 
Note that I just recently mentioned this same fix in bug 124798, since I wasn't
aware of David's patch.

Third, I've tried to solve things the way Rob mentioned, because I think that
would be a much cleaner fix.  I think there's two parts to making such a fix,
because there appears to be a synchronous grab or something causing EnterNotify
and LeaveNotify events to be queued until after I release Ctrl & Alt.  So, we
want EnterNotify & LeaveNotify events to be generated from mouse movement while
the workspace switcher popup is showing (as far as I can tell, we don't ever get
these from the server at all), and we also want them to not be queued.  After
twiddling for a number of hours on this, I still can't track down how to get
either of these two parts to work.  Rob, Havoc: Any hints on what I should look
at or how I might get this to work?
Comment 4 Havoc Pennington 2004-09-04 20:39:11 UTC
In principle, when the pointer is ungrabbed we should get an EnterNotify which
should focus a window. Maybe we are just overriding that with the MRU list, for
example.

I have a patch that adds "strict pointer mode" on top of sloppy/mouse focus
modes, where all keyboard heuristics get skipped and keynav basically becomes
hellish. But it does "fix" this. ;-) This patch is from a patch set for a Red
Hat customer that I need to merge during the GNOME 2.10 cycle.

Comment 5 Elijah Newren 2004-09-04 23:13:39 UTC
Actually, I think the EnterNotify is being overridden by the METACITY_SENTINEL
(see bug 124798, and the reference to bug 110970).  But even making that
EnterNotify not be overridden would not "fix" this, because the focusing of the
window would be delayed until the ungrab happens.  (If I merely want a delayed
focusing of the window--which, honestly, may be good enough--I can use the
one-line patch in bug 124798; it works perfectly well).

Your statement that keynav becomes nasty with that patch scares me; I use both
mouse focus and keynav a lot and I really believe that most of the current
problems can be fixed without regressing anything or requiring the user to
choose between those two.  I'd be very interested in taking a look at your patch
and the list of requirements it is meant to satisfy, to see if I can get all the
requirements working without regressing anything else.
Comment 6 Elijah Newren 2004-09-11 23:32:37 UTC
Okay, I have a fix.  Basically, here's the thought process: The user is using
keynav (meaning that we tend to ignore the mouse, but we're merely attempting to
get one of those "mixing of navigation methods" cases right).  The real focus
window is the workspace switcher popup while it remains up.  When the user
releases Ctrl and Alt, the user then wants to interact with the default window
on that workspace and we should focus it.  I'll attach a patch in a minute that
does so (it's quite similar to David's).
Comment 7 Elijah Newren 2004-09-11 23:33:37 UTC
Created attachment 31495 [details] [review]
Focus the default window after switching workspaces upon key release
Comment 8 Havoc Pennington 2004-09-12 00:19:41 UTC
Comment on attachment 31495 [details] [review]
Focus the default window after switching workspaces upon key release

The g_assert scares me a bit; won't we process any events we get between key
press and this code? Surely one of those events could be e.g. a client message
from the workspace switcher, or devil's pie, for example, changing the space.

I might just change the code to use screen->active_workspace rather than
target_workspace, with a comment that we expect but can't guarantee they are
the same?

Maybe I'm just paranoid
Comment 9 Elijah Newren 2004-09-12 01:25:20 UTC
Created attachment 31497 [details] [review]
Replace assert with a warning
Comment 10 Elijah Newren 2004-09-13 00:06:37 UTC
I'm going to throw this on the Gnome 2.8.x milestone; I'm hoping it's reasonable
to try to get all the remaining focus bugs (well, other than the focus stealing
stuff) fixed for the Gnome 2.8.1 release.
Comment 11 Elijah Newren 2004-09-22 16:18:18 UTC
ping?
Comment 12 Havoc Pennington 2004-09-22 18:38:38 UTC
Comment on attachment 31497 [details] [review]
Replace assert with a warning

Okie, thanks.