GNOME Bugzilla – Bug 361054
strict focus mode still not working; should look for res_class, not res_name
Last modified: 2006-10-29 20:37:43 UTC
Please describe the problem: strict focus mode is still not working correctly; if I run xterm, and say start xcalc from it, xcalc gets focus, even though it should not. (by "strict focus mode" I mean "with /apps/metacity/general/focus_new_windows" set to "strict"). The problem is that the function to determine whether the currently-focused window is a terminal is comparing window->res_name to a set of known terminal applications, but it's comparing literals that are apparently more suited to compare with window->res_class. I'm not certain what the intent was here; since res_name can be set by the user, res_class would be somewhat safer, so perhaps res_class is correct. Either 1) the strcmp(window->res_name..) should be strcasecmp (or something equivalent that ignores case), or 2) the strings to compare against should be the first string in the WM_CLASS window atom, which is generally lower-case (i.e. "xterm" instead of "XTerm"), or 3) the strcmp should be done against window->res_class instead of res_name. Any of the above fixes resolves the issue; starting xcalc (or any other app that *can* take focus) from xterm now leaves the focus in xterm (when Steps to reproduce: 1. set /apps/metacity/general/focus_new_windows to "strict" 2. from an xterm, type "xcalc &" Actual results: Focus is granted to the new xcalc window Expected results: I expect the focus to stay with the parent xterm window Does this happen every time? Yes Other information:
Sounds like you already solved the problem. Care to attach a patch? ;)
Well, it depends on which direction you want to go; were you the original author? If so, did you really mean res_class? (and another problem is I don't have all the other term programs, so I can't be sure what their res_name or res_class are; xprop WM_CLASS would tell me if I had them to run)
Created attachment 74384 [details] [review] If using res_class is the right thing, here's a patch that does so
Created attachment 74385 [details] [review] Fix "window-ness" to "term-ness" Comment tweak to previous patch
Looks fine to me, if I can find someone to test and verify the res_class of the other terminal programs. I don't at all remember why I used res_name, but anyway, I know that I found others on IRC who had the various programs installed and got the info from them when I wrote it. So, any volunteers to install a bunch of terminal programs and check them out?
I can confirm that the class name is correct for gnome-terminal, xterm, konsole, rxvt, urxvt. I can't speak for the others.
From examination of sources: Eterm is "Eterm" mlterm is "mlterm" multi-gnome-terminal is "Multi-gnome-terminal" kterm is "KTerm" which is exactly what's in the patch. So I submit that the patch is complete and as correct as reasonably possible.
Awesome, thanks. Feel free to commit, or to track someone down to do so. (Thomas: around?) I'm drowning in a dissertation right now...
Committed to HEAD and gnome-2-16 branch, with one minor modification of checking window->res_class at the start of the function rather than res_name. Dan, this change will also make it into our 2.16 based JDS release - probably around snv53.