[comp.windows.x] Focus thrashing

rick@tetrauk.UUCP (Rick Jones) (04/10/91)

I have a problem with multiple dialog boxes which can result in the focus
cycling continuously between 2 or more forms.  The application creates multiple
top-level windows (they happen to be transients, but that doesn't make any
difference).  I'm running the Motif window manager, with auto-raise on focus,
although I think it could happen with any window manager.

When the transient shell gets focus, it has to set focus into the currently
active sub-window.  If the user happens to switch focus between two forms in
quick succession, then the focus of these forms starts to cycle.  The only cure
is to close one of the forms.  It appears to be the result of asynchronous
event handling, in that by the time the shell of form-1 has switched focus to
it's sub-window, form-2's shell has been given focus, initially by the window
manager.  The WM then detects the focus switch to form-1's sub-window, and so
gives focus to form-1's shell.  Then the focus switch to form-2's sub-window
gets through, and so the WM gives focus to form-2's shell.  And so the cycle
continues - this is the best description I can give of what I think is going
on.

Is there any straight-forward cure to this?  I don't really want to change the
basic way I'm handling the forms and sub-windows, since that would be a
retrograde step in application terms.

Please reply by email if possible, I don't usually have time to hack through
the volume of stuff in this newsgroup (interesting though a lot of it is).

-- 
Rick Jones, Tetra Ltd.  Maidenhead, Berks, UK
rick@tetrauk.uucp

Any fool can provide a solution - the problem is to understand the problem