Fix for focus loops

Jukka Heinonen jhei at
Sun May 12 05:13:50 CDT 2002

On Tue, May 07, 2002, Alexandre Julliard wrote:
> I've been working on this too, and I found that the locally active
> model seems to work better with most window managers, even though it's
> not 100% correct per the spec. Here's the patch I have, please give it
> a try and let me know how it works for you.

If your patch is used in globally active mode 
(Wine config file has "UseTakeFocus" = "Y"), focus
loop problem is fixed. However, if I try locally active 
mode, Wine still enters focus loop.

Some comments about the patch and Wine focus handling:

- Timestamp used in X11DRV_SetFocus is wrong when focus
  has been gained either due to WM_TAKE_FOCUS or due to

- Routine X11DRV_SetFocus may fail to set focus because
  focus might have already been passed to another X11 window.
  In unmanaged mode this is fatal: override_redirect windows
  receive neither WM_TAKE_FOCUS nor FocusIn and if Wine believes
  that a window already has focus it won't call X11DRV_SetFocus even
  when the window receives mouse clicks. 

- If X11DRV_SetFocus fails, Wine routine that triggered
  this call (SetForegroundWindow, SetActiveWindow, SetFocus, etc)
  should also fail. This is what NT5.0 does according to docs,
  by the way. This would make it easy to see which window really has

- It is likely that last_focus will be wrong if routine
  X11DRV_SetFocus fails as described above.

- All Wine windows using override_redirect break ICCCM. 
  This includes all windows in unmanaged mode. In general, it is
  not possible for override_redirect windows to gain input focus 
  without confusing focus handling of window managers. There
  are two exceptions to this generalization which likely apply to 
  full-screen applications and menus.

- In locally active model, transferring focus from top-level window
  to active dialog window requires timestamp CurrentTime which
  breaks ICCCM compliance. This can break window manager focus
  handling in some cases. This is likely not very big an issue,
  but I believe that everything that breaks standards should be
  properly commented.

- One not directly focus relared problem is that some window managers
  always put override_redirect windows on top of managed windows.
  And when you run some applications in managed mode, Wine creates 
  a full screen override_redirect window which has managed dialog

Looking at this list makes me believe that fixing Wine focus handling
should be assigned much higher priority than it has been so far.

Jukka Heinonen <>

More information about the wine-devel mailing list