GNOME Bugzilla – Bug 133120
wrong focus when changing workspace
Last modified: 2004-12-22 21:47:04 UTC
This bug was originally reported in the Debian BTS: http://bugs.debian.org/210250 "I've got the same problem using 2.6.3 :-(. Autorise is off and it also happens with and without running nautilus. Autofocus is on when mouse is over windows... I've tried with a fresh user (to see if it was a configuration problem and I can still reproduce the problem). This are the steps to reproduce the problem in my computer (hope it helps): - Create a new user and log into X - Go to "Applications/Desktop Preferences/Windows" and select "Select windows when the mouse moves over them" - Go to "Applications/Desktop Preferences/Keyboard Shortcuts" and create shortcuts for switching workspaces (I normally use Ctrl+F1, Ctl+F2, but tried with others). - Open a window (a terminal will do). The window automatically gets the focus (is the only window opened). If you move the mouse over it and then over the background the focus stays on the terminal window as it's kind of "sloppy". - Now, with the mouse OVER the background (not the focused window) move to another workspace (using the KEYS) and go back to the previous workspace. The result is that NO window is focused even that the terminal is the only window in the workspace."
I believe this occurs because workspace.c:meta_workspace_activate_with_focus calls meta_workspace_focus_default window. Replacing it with meta_workspace_focus_mru_window would be wrong because if the mouse enters a window upon switching workspaces, then it should be focused. Thus, the behavior I believe you want is to focus the 'default' window if one is found and otherwise to focus the 'MRU' (most recently used) window. Doing this would require a new function (although it'd be trivial to write as it's mostly just cut and paste from the two previously mentioned existing functions). Note that this would only be for sloppy focus and NOT for mouse focus, because for mouse focus we really don't want a window focused if the pointer isn't in it. I don't care too much either way (since I use mouse focus), but if the Metacity maintainers would like this then I'll write a patch for it; it should be fairly simple.
ostensibly this is intentional, since there s code to explicitly work this way for sloppy and mouse focus. Theoretically, sloppy focus should focus the window underneath the mouse pointer when the workspace is switched. But now that we have the per-workspace MRU, it may make more sense to simply focus the top window in sloppy focus as well. Either way I don't think we can make this change until after the Gnome 2.6 release, since we're past UI freeze.
This has been fixed in CVS as part of the changes in bug 135810.