GNOME Bugzilla – Bug 125492
Possibly incorrect warning re: SetInputFocus
Last modified: 2004-12-22 21:47:04 UTC
I've seen this warning a few times: Window manager warning: Working around an application which called XSetInputFocus (None) or with RevertToNone instead of RevertToPointerRoot, this is a minor bug in some application. If you can figure out which application causes this please report it as a bug against that application. I've searched to no avail for the app causing it. I suspect the bug is in Metacity itself. It seems to trigger when there are keystrokes just after dismissing a dialog, before focus returns to the MRU window, but I can't reliably reproduce it. I have the best luck with Gedit. Run Gedit, type something, quit, then select "Don't Save" when the alert appears. Also, the warning is misleading: Apps should use only RevertToParent. (Maybe the WM should too?)
I haven't looked at the code but I'm reasonably certain that this warning is issued whenever there is no focused window. Metacity catches this and resets the focus so that keyboard events can be intercepted by metacity. Perhaps this is happening somehow when a window is deleted? Who knows.
I don't see how focus would get set to None if nobody calls XSetInputFocus() with window None or RevertToNone. Keith is there any way?
*** Bug 128096 has been marked as a duplicate of this bug. ***
The protocol spec says that focus can only be set by SetInputFocus or when the current focus window becomes NotViewable. Looking at the code, that seems to be accurately implemented.
There is another way for focus to be set to None. From proto.txt, which came with XFree86: If the focus window later becomes not viewable, the new focus window depends on the revertto argument. If revertto is Parent, the focus reverts to the parent (or the closest viewable ancestor) and the new revertto value is taken to be None.
I actually saw this warning quite a few times while I was trying to test my _NET_WM_USER_TIME stuff, though I'm sure that was unrelated. I'm pretty sure I can duplicate it (and perhaps even fine a 100% repeatable case). Would you like me to try and report back, or is this more of a procedural issue at this point?
evolution seems to cause this warning fairly frequently when "New Message" windows are closed, though not invariably. Based on Gregory's research though, I'd have to say at this point that the warnings are spurious, and since the workaround is in place, they are also harmless. We should remove the warning.
This is really easy to reproduce once you know how...and I just barely figured out how while doing massive testing for bug 152000. Okay, steps to reproduce: In any focus mode: 1) open a new gnome-terminal window 2) open a second tab in the gnome-terminal window 3) Click the X button to close the window (or press Alt+F4 or whatever; just don't close the tabs individually) 4) Note the little confirmation window that comes up. 5) Make sure that when you press the "Close all tabs" button in the confirmation window that comes up, that the default focus window will be the gnome-terminal window that is about to be closed (shouldn't require any effort, just be careful not to interact with other windows). 6) Actually click on the "Close all tabs" button I can duplicate with other apps too (e.g. gedit or several of the gnome-games). The basic idea is to get a confirmation dialog when trying to close a window and have things setup such that Metacity would want to focus the window when the dialog shuts down--and then run into the problem that closing the dialog causes the window to close too.
Gregory's cite seems to explain this: If the focus window later becomes not viewable, the new focus window depends on the revertto argument. If revertto is Parent, the focus reverts to the parent (or the closest viewable ancestor) and the new revertto value is taken to be None. The focus window vanishes, we revert to parent and then revert to goes back to None. So, I guess we need to remove the warning from metacity, though I don't think we want to change the behavior. An X extension to let us specify "revert to some specified window" (with side effect that RevertToNone will never be used) would be welcome. Existence of RevertToNone is basically a bug in the X protocol in my opinion, as it amounts to RevertToUserIsFucked and the root window is always available as a sane default to revert to.
Created attachment 32127 [details] [review] Change the warning to a meta_topic; improve the behavior This patch makes the warning into a meta_topic and makes the comment refer to this bug. It also improves the behavior: we know which window should be focused (the default_focus_window), so we might as well focus it. (When we used to have three different focus window functions and we didn't maintain the invariants mentioned in doc/how-to-get-focus-right.txt, we couldn't have done much better and focusing the no_focus_window was probably close to as sane as we could get). This patch depends on the one in bug 152000 first being applied. I could have made it not depend on that one, but then this patch would have to be updated as soon as the other was applied (since focus_default_window will then need a timestamp).
Comment on attachment 32127 [details] [review] Change the warning to a meta_topic; improve the behavior This looks fine pending the actual existencs of a function called meta_display_thou_shalt_return_a_timestamp (display) :-)
I agree that this is sensible, except that enter_notify_events_will_handle_this probably has to go away as mentioned on bug 152000
Comment on attachment 32127 [details] [review] Change the warning to a meta_topic; improve the behavior I committed. I leave this bug open in case someone wants it as a reminder to file a bug against Xorg.
I filed https://bugs.freedesktop.org/show_bug.cgi?id=2117. Since we have a workaround (even if hacky) and the core bug is in X, I'm resolving as NOTGNOME.