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 361054 - strict focus mode still not working; should look for res_class, not res_name
strict focus mode still not working; should look for res_class, not res_name
Status: RESOLVED FIXED
Product: metacity
Classification: Other
Component: general
2.14.x
Other All
: Normal normal
: ---
Assigned To: Metacity maintainers list
Metacity maintainers list
Depends on:
Blocks:
 
 
Reported: 2006-10-10 03:42 UTC by Dan Mick
Modified: 2006-10-29 20:37 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
If using res_class is the right thing, here's a patch that does so (1.68 KB, patch)
2006-10-10 04:29 UTC, Dan Mick
none Details | Review
Fix "window-ness" to "term-ness" (1.68 KB, patch)
2006-10-10 04:46 UTC, Dan Mick
accepted-commit_now Details | Review

Description Dan Mick 2006-10-10 03:42:14 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:
Comment 1 Elijah Newren 2006-10-10 03:43:53 UTC
Sounds like you already solved the problem.  Care to attach a patch?  ;)
Comment 2 Dan Mick 2006-10-10 03:50:20 UTC
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)
Comment 3 Dan Mick 2006-10-10 04:29:46 UTC
Created attachment 74384 [details] [review]
If using res_class is the right thing, here's a patch that does so
Comment 4 Dan Mick 2006-10-10 04:46:47 UTC
Created attachment 74385 [details] [review]
Fix "window-ness" to "term-ness"

Comment tweak to previous patch
Comment 5 Elijah Newren 2006-10-10 05:55:19 UTC
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?
Comment 6 Dan Mick 2006-10-10 06:08:50 UTC
I can confirm that the class name is correct for gnome-terminal, xterm,
konsole, rxvt, urxvt.  I can't speak for the others.

Comment 7 Dan Mick 2006-10-27 04:24:58 UTC
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.
Comment 8 Elijah Newren 2006-10-28 05:55:18 UTC
Awesome, thanks.  Feel free to commit, or to track someone down to do so.  (Thomas: around?)  I'm drowning in a dissertation right now...
Comment 9 Glynn Foster 2006-10-29 20:37:43 UTC
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.